在尝试使用 创建自己的定理样式时,我遇到了一些间距问题thmtools
。我想要的可以归结为以下几点:
- 定理名称应位于边距内,并与正文保持一定
\marginparsep
宽度的距离。 - 定理注释应在正文中,后面留有空格。
- 如果未使用注释,则后面的文本仍应与文本主体对齐,且不缩进。
我意识到我可以为何时想使用注释和何时不想使用注释创建一个单独的定理样式,但如果可能的话,我正在寻找一种不需要这样做的解决方案。
以下是上述示例的代码:
\documentclass[11pt,a4paper]{scrartcl}
\usepackage{amsthm}
\usepackage{thmtools}
\declaretheoremstyle[
spaceabove=6pt, spacebelow=6pt,
headfont=\bfseries\scshape,
notefont=\normalfont, notebraces={(}{)},
bodyfont=\normalfont,
headpunct={},
postheadspace={0pt},
headformat={%
\makebox[0pt][r]{\NAME\ \NUMBER\hspace{\marginparsep}}\NOTE%
}
]{problemA}
\declaretheorem[
name=Theorem,
style=problemA
]{theoremA}
\makeatletter
\declaretheoremstyle[
spaceabove=6pt, spacebelow=6pt,
headfont=\bfseries\scshape,
notefont=\normalfont, notebraces={(}{)},
bodyfont=\normalfont,
headpunct={},
postheadspace={0pt},
preheadhook=\renewcommand\thmt@space{}, % Removes \NOTE spacing
headformat={%
\makebox[0pt][r]{\NAME\ \NUMBER\hspace{\marginparsep}}\NOTE%
}
]{problemB}
\declaretheoremstyle[
spaceabove=6pt, spacebelow=6pt,
headfont=\bfseries,
notefont=\normalfont, notebraces={(}{)},
bodyfont=\normalfont,
headpunct={},
postheadspace={5pt},
preheadhook=\renewcommand\thmt@space{}, % Removes \NOTE spacing
headformat={%
\makebox[0pt][r]{\NAME\ \NUMBER\hspace{\marginparsep}}\NOTE%
}
]{problemC}
\makeatother
\declaretheorem[
name=Theorem,
style=problemB
]{theoremB}
\declaretheorem[
name=Theorem,
style=problemC
]{theoremC}
\begin{document}
\begin{theoremA}[Test]
Here we get undesired space around \texttt{\textbackslash NOTE}.
\end{theoremA}
\begin{theoremB}[Test]
Now we eliminated the undesired space.
\end{theoremB}
\begin{theoremB}
Also works without the note.
\end{theoremB}
\begin{theoremC}[Test]
Also works with \texttt{postheadspace}.
\end{theoremC}
\begin{theoremC}
But now we get an indent when we don't use a note.
\end{theoremC}
\end{document}
答案1
由于notebraces
嵌入,\NOTE
您可以添加所需的空间后结束括号,只有当有注释时才会调用它:
\documentclass[11pt,a4paper]{scrartcl}
\usepackage{amsthm}
\usepackage{thmtools}
\makeatletter
\declaretheoremstyle[
spaceabove=6pt, spacebelow=6pt,
headfont=\bfseries,
notefont=\normalfont, notebraces={(}{)\hspace{5pt}},
bodyfont=\normalfont,
headpunct={},
postheadspace={0pt},
preheadhook=\renewcommand\thmt@space{}, % Removes \NOTE spacing
headformat={%
\makebox[0pt][r]{\NAME\ \NUMBER\hspace{\marginparsep}}\NOTE%
}
]{fivept}
\usepackage{xspace}
\declaretheoremstyle[
spaceabove=6pt, spacebelow=6pt,
headfont=\bfseries,
notefont=\normalfont, notebraces={(}{) },
bodyfont=\normalfont,
headpunct={},
postheadspace={0pt},
preheadhook=\renewcommand\thmt@space{}, % Removes \NOTE spacing
headformat={%
\makebox[0pt][r]{\NAME\ \NUMBER\hspace{\marginparsep}}\NOTE%
}
]{singlespace}
\makeatother
\declaretheorem[
name=Theorem,
style=fivept
]{fivept}
\declaretheorem[
name=Theorem,
style=singlespace
]{singlespace}
\begin{document}
\begin{fivept}[Test]
\verb|notebraces={(}{)\hspace{5pt}}|
\end{fivept}
\begin{fivept}
No undesired space.
\end{fivept}
\begin{singlespace}[Test]
\verb|notebraces={(}{) }|
\end{singlespace}
\begin{singlespace}
Also no undesired space.
\end{singlespace}
\end{document}