1

In the package ntheorem, there is a theorem style called break, the corresponding code defining it reads:

\newtheoremstyle{break}%
  {\item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont
          ##1\ ##2\theorem@separator}\hbox{\strut}}}]}%
  {\item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont
          ##1\ ##2\ (##3)\theorem@separator}\hbox{\strut}}}]}

I adopted this code to make it work with amsthm, below is a MWE.

\documentclass{article}

\usepackage{amsthm}
\newtheoremstyle{break}
    {}{}
    {\normalfont}{}
    {\bfseries}{}
    {0pt}
    {%
        \rlap{\vbox{\hbox{%
            \thmname{#1}\thmnumber{\nobreakspace #2}%
            {\thmnote{\hspace{.4em}$($#3$)$}}%
        }\hbox{\strut}\vskip0pt}}%
    }

\theoremstyle{break}
\newtheorem{theorem}{Theorem}

\usepackage{blindtext}


\begin{document}

Text

\begin{theorem}
    \blindtext
\end{theorem}

\begin{theorem}
    \begin{itemize}
        \item text
        \item text
        \item text
    \end{itemize}
\end{theorem}

\end{document}

enter image description here

This works perfectly and in particular works when the theorem begins with a list, which is not the case for the simple definition given in the amsthm manual:

\newtheoremstyle{break}%
  {}{}%
  {\itshape}{}%
  {\bfseries}{}%  % Note that final punctuation is omitted.
  {\newline}{}

The main problem with this simple one is that when the theorem begins with an itemize or enumerate list, one would have to write \leavevmode\vspace{-\baselineskip}, see @Mico's nice answer below. A friend of mine strongly advise me to make this automatic. Also, if one writes this in an article, when the template changes, one would have to manually remove those \leavevmode\vspace{-\baselineskip}, and even though this can be done by defining it as a separate macro and redefining it each time, it is definitely not simple and elegant.

My question is:

  1. How does this code (I mean the one in the MWE, adopted from ntheorem) work? I'm not familiar with these plain TeX macros so I don't quite understand what is going on here.
  2. You may notice that I added a \vskip0pt after \hbox{\strut}, which surprisingly adds some extra vertical space after the theorem heading (which is exactly what I wanted, though I don't know why this happens). Why would this happen?
1
  • @Mico Yes, as I have stated in the question, the code there does not work well when the theorem begins with an itemize or enumerate list, one would still have to manually add \leavevmode or something like this.
    – Jinwen
    Commented Apr 23, 2022 at 7:14

1 Answer 1

1

Section 4.3.1 of the user guide of the amsthm package is entitled "Theorem style break". I'll quote it here in its entirety [highlighting added]:

enter image description here enter image description here


To summarize, inserting the instructions \leavevmode and \vspace{-\baselineskip} right before \begin{enumerate} fixes the problem. It's not sufficient to insert just \leavevmode.

Speaking for myself, I think that executing \leavevmode \vspace{-\baselineskip} if and when necessary is easier than to try to adapt some code from the ntheorem package. The ntheorem and amsthm packages may share similar user-level commands such \newtheorem and \theoremstyle, but they are very different "under the hood".

enter image description here

\documentclass{article}

\usepackage{amsthm}
\newtheoremstyle{break}% % see section 4.3.1 of amsthm user guide
   {}{}{\itshape}{}{\bfseries}{}{\newline}{}
\theoremstyle{break}
\newtheorem{breakthm}{Theorem}

\usepackage{lipsum,enumitem}

\begin{document}

\begin{breakthm}
    \lipsum[2][1-3]
\end{breakthm}

\begin{breakthm} 
    \leavevmode \vspace{-\baselineskip}
    \begin{itemize}[nosep] % 'nosep' is optional
        \item text
        \item text
        \item text
    \end{itemize}
\end{breakthm}

\end{document}
9
  • Yes, I am aware of this and am always using this method. But a friend of mine strongly advise me to make this automatically. Also, if I write this in the article, when the template changes, I would have to remove this \leavevmode\vspace{-\baselineskip}, and even though this can be done by defining it as a separate macro and redefining it each time, it is definitely not simple and elegant.
    – Jinwen
    Commented Apr 23, 2022 at 7:45
  • Aren't amsthm theorems still just single item lists? Thus issuing \iten starts a new line (not at pc, so haven't tested on this example)
    – daleif
    Commented Apr 23, 2022 at 7:48
  • @Jinwen - It would have been useful to state this information explicitly, in the body of the query.
    – Mico
    Commented Apr 23, 2022 at 7:48
  • @daleif - Inserting an \item instruction will create a line break. However, it will also insert an inordinate amount of vertical whitespace; that's the problem alluded to in the excerpt from the user guide shown above.
    – Mico
    Commented Apr 23, 2022 at 7:52
  • At least some of these use a zero item spacing. So I haven't had issues with it. Ahh well
    – daleif
    Commented Apr 23, 2022 at 7:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .