2

I've run into some spacing problems when attempting to create my own theorem styles using thmtools. What I want can be condensed into the following points:

  • Theorem name should be in the margin and spaced relative to the text body by a \marginparsep width.
  • The theorem note should be in the text body and have a space following it.
  • If no note is used, the following text should still be aligned to the text body with no indents.

I realize that I can create a separate theorem style for when I want to use a note and when I don't, but I'm looking for a solution that doesn't require that if possible.

Here's an example that illustrates the problem I've ran into: enter image description here

And here's the code for the above example:

\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 Answers1

1

Since the notebraces are embedded in \NOTE you can add the desired space after the closing brace and it will be called only if there is a 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}

enter image description here

DG'
  • 21,727