定理标题位于外边距(偶数/奇数页)

定理标题位于外边距(偶数/奇数页)

我希望定理/定义/等标签出现在页边距(考虑偶数页和奇数页)。首先,我尝试使用包thmtools(下面的代码和图片)。但是,我只能将标签始终放在左边距。特别是,我不知道如何thmtools与结合ifoddpage

接下来,我尝试了ntheorem(下面的代码和图片)。使用ntheorem,标签放置工作正常,但我无法更改定理标题的字体样式(下图中的“一些重要定理”)并将其放在一行上。此外,我无法摆脱缩进。最后,它还破坏了我的autoref参考资料。

总结:我正在寻找一个允许的定理环境

  • 标签页边距(奇数页/偶数页)
  • 标签、标题和正文的完全样式控制
  • autoref兼容性(特别是,我想对不同的定理环境(例如定理,定义等)使用单个计数器)

我快要放弃了,所以我真的希望有人能帮助我。

代碼thmtools

\documentclass[10pt, a4paper, twoside]{article}
\usepackage[a4paper, inner=1.25in, outer=1.25in]{geometry}

\usepackage{color}
\usepackage{amsthm}
\usepackage{thmtools}

\newlength{\spaceblength}
\settowidth{\spaceblength}{\bfseries\ }
\declaretheoremstyle[
    headfont=\bfseries,
    notefont=\bfseries,
    notebraces={}{\\[\parskip]}, % Braces for additional text
    bodyfont=\normalfont\itshape,
    headpunct={},
    headformat={%
        \makebox[0pt][r]{\color{red}\NAME\ \NUMBER\ \ }\hskip-\spaceblength{\NOTE}%
    }
]{boxstyle}

\declaretheorem[style=boxstyle,numberwithin=section]{theorem}

\begin{document}

\begin{theorem}[Some Important Theorem]
    This is a theorem. This is a theorem. This is a theorem. This is a theorem. This is a theorem.
    This is a theorem. This is a theorem. This is a theorem. This is a theorem. This is a theorem.

    This is a theorem. This is a theorem. This is a theorem. This is a theorem. This is a theorem.
    This is a theorem. This is a theorem. This is a theorem. This is a theorem. This is a theorem.
\end{theorem}

\newpage

\begin{theorem}[Some Important Theorem]
    This is a theorem. This is a theorem. This is a theorem. This is a theorem. This is a theorem.
    This is a theorem. This is a theorem. This is a theorem. This is a theorem. This is a theorem.

    This is a theorem. This is a theorem. This is a theorem. This is a theorem. This is a theorem.
    This is a theorem. This is a theorem. This is a theorem. This is a theorem. This is a theorem.
\end{theorem}

\end{document}

代碼ntheorem

\documentclass[10pt, a4paper, twoside]{article}
\usepackage[a4paper, inner=1.25in, outer=1.25in]{geometry}

\usepackage{color}
\usepackage{ifoddpage}
\usepackage{ntheorem}

\makeatletter%
\newtheoremstyle{nonumoutermargin}%
{\item[\checkoddpage\ifoddpageoroneside\rlap{\hskip\linewidth\theorem@headerfont {\hskip18pt##1}}%
\else\llap{\theorem@headerfont{##1}\hskip6pt}\fi]}%
{\item[\checkoddpage\ifoddpageoroneside\rlap{\hskip\linewidth\theorem@headerfont   {\hskip18pt##1}}%
\else\llap{\theorem@headerfont{##1}\hskip6pt}\fi##3]}

\newtheoremstyle{outermargin}%
{\item[\checkoddpage\ifoddpageoroneside\rlap{\hskip\linewidth\theorem@headerfont {\hskip18pt##1\hskip\labelsep##2}}%
\else\llap{\theorem@headerfont{##1\hskip\labelsep##2}\hskip6pt}\fi]}%
{\item[\checkoddpage\ifoddpageoroneside\rlap{\hskip\linewidth\theorem@headerfont{\hskip18pt##1\hskip\labelsep##2}}%
\else\llap{\theorem@headerfont{##1\hskip\labelsep##2}\hskip6pt}\fi##3]}
\makeatother

\theoremindent=0pt
\theoremheaderfont{\upshape\bfseries\color{red}}
\theoremstyle{outermargin}
\newtheorem{theorem}{Theorem}[section]

\begin{document}

\begin{theorem}[Some Important Theorem]
    This is a theorem. This is a theorem. This is a theorem. This is a theorem. This is a theorem.
    This is a theorem. This is a theorem. This is a theorem. This is a theorem. This is a theorem.

    This is a theorem. This is a theorem. This is a theorem. This is a theorem. This is a theorem.
    This is a theorem. This is a theorem. This is a theorem. This is a theorem. This is a theorem.
\end{theorem}

\newpage

\begin{theorem}[Some Important Theorem]
    This is a theorem. This is a theorem. This is a theorem. This is a theorem. This is a theorem.
    This is a theorem. This is a theorem. This is a theorem. This is a theorem. This is a theorem.

    This is a theorem. This is a theorem. This is a theorem. This is a theorem. This is a theorem.
    This is a theorem. This is a theorem. This is a theorem. This is a theorem. This is a theorem.
\end{theorem}

\end{document}

在此处输入图片描述

答案1

我继续寻找答案,下面的方法对我有用(我想我以前尝试过但没有编译......):

\documentclass[10pt, a4paper, twoside]{article}
\usepackage[a4paper, inner=1.25in, outer=1.25in]{geometry}

\usepackage{color}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{ifoddpage}

\newlength{\spaceblength}
\settowidth{\spaceblength}{\bfseries\ }
\declaretheoremstyle[
    headfont=\bfseries,
    notefont=\bfseries,
    notebraces={}{\\[\parskip]}, % Braces for additional text
    bodyfont=\normalfont\itshape,
    headpunct={},
    headformat={%
        \checkoddpage\ifoddpage\rlap{\hskip\textwidth\color{red}\ \ \ \NAME\ \NUMBER}\hskip-\spaceblength{\NOTE}%
        \else\makebox[0pt][r]{\color{red}\NAME\ \NUMBER\ \ \ }\hskip-\spaceblength{\NOTE}\fi%
    },
]{boxstyle}

\declaretheorem[style=boxstyle,numberwithin=section]{theorem}

\begin{document}

\begin{theorem}[Some Important Theorem]
    This is a theorem. This is a theorem. This is a theorem. This is a theorem. This is a theorem.
    This is a theorem. This is a theorem. This is a theorem. This is a theorem. This is a theorem.

    This is a theorem. This is a theorem. This is a theorem. This is a theorem. This is a theorem.
    This is a theorem. This is a theorem. This is a theorem. This is a theorem. This is a theorem.
\end{theorem}

\newpage

\begin{theorem}[Some Important Theorem]
    This is a theorem. This is a theorem. This is a theorem. This is a theorem. This is a theorem.
    This is a theorem. This is a theorem. This is a theorem. This is a theorem. This is a theorem.

    This is a theorem. This is a theorem. This is a theorem. This is a theorem. This is a theorem.
    This is a theorem. This is a theorem. This is a theorem. This is a theorem. This is a theorem.
\end{theorem}

\end{document}

相关内容