# Page-breaking over titles of theorems that have lists

When I have multiple part theorems, I use an enumerate environment inside my theorem environment. However, I don't like the list to start at the same level as the theorem title, since this produces an ugly indent, and also because part (1) is then never lined up with the other parts. So I typeset this as follows:

\begin{theorem}
\
\begin{enumerate}
\item First item.
\item Second item.
\end{enumerate}
\end{enumerate}


The problem is that if the theorem occurs near the bottom of a page, LaTeX will break the page right after the Theorem title, producing something that looks like

Theorem 1.

1. First item
2. Second item

Any way to prevent this? (I don't care if a pagebreak occurs before the theorem title or if it occurs after the first item.) Maybe I should be using something else besides a "\"? Many thanks for any help.

• Hi, welcome to tex.sx. Note that it is always good to post full, compilable but minimal examples that recreate the problem, here the theorem heading at the end of the page. This allows other people to analyze the problem and test their solutions. You can use the lipsum or blindtext package to add dummy text like I did in my answer. – Martin Scharrer Mar 9 '11 at 0:52

You can use the \Needspace* macro of the needspace package to tell LaTeX that the following material needs at least a certain amount of space left on the current page, otherwise force a page break. The amount of 3\baselineskip means more or less three lines, i.e. the theorem heading, a separation line and the first item line.

\documentclass{article}
\usepackage{amsthm}
\usepackage{lipsum}
\usepackage{needspace}
\newtheorem{theorem}{Theorem}
\newenvironment{Theorem}{%
\Needspace*{3\baselineskip}%
\theorem
}{\endtheorem}

\begin{document}
\lipsum[1-10]

\begin{Theorem}
\
\begin{enumerate}
\item First item.
\item Second item.
\end{enumerate}
\end{Theorem}
\end{document}

• Hmm, I can't seem to get this to work yet. How exactly do the \theorem and \endtheorem commands relate to the name of the environment? For example, if I call my theorems "thm" instead of "theorem, do I use \thm and \endthm? Many thanks for your help. – Skeptic Mar 9 '11 at 2:59
• @Skeptic: Yes, \theorem and \endtheorem are actually of \begin{theorem} and \end{theorem}. You can write them in the long version if you want. Inside another environment I normally write them like this, because it has some benefits. – Martin Scharrer Mar 9 '11 at 3:16
• @Martin: Interesting, I didn't know - what are the benefits? – Hendrik Vogt Mar 9 '11 at 9:49
• @Hendrik: The main benefit is that the internal environment name macro holds the name of the outer environment during the body of the environment. If the outer \end{...} is missing the error message will contain Theorem here not theorem or thm. For own environments this isn't that important, but for the ones provided by packages it is much more user friendly. Otherwise a user might get \begin{onlyinternallyused-neverseenbytheuser} ended by \end{someother} environment. Further smaller benefits: its a little faster and needs one less grouping level. – Martin Scharrer Mar 9 '11 at 9:54
• @Martin: Thanks a lot for the explanation. This "error message" business has been mentioned on this site from time to time, but I never seriously paid attention. – Hendrik Vogt Mar 9 '11 at 9:59

An alternative to the accepted answer that doesn't require a new theorem environment name is the following:

\documentclass{article}
\usepackage{amsthm}
\usepackage{lipsum}
\usepackage{needspace}
\newtheorem{theorem}{Theorem}

\let\ORGtheorem\theorem
\def\theorem{%
\Needspace*{3\baselineskip}
\ORGtheorem
}
\let\ORGendtheorem\endtheorem
\def\endtheorem{%
\ORGendtheorem
}

\begin{document}
\lipsum[1-10]

\begin{Theorem}
\
\begin{enumerate}
\item First item.
\item Second item.
\end{enumerate}
\end{Theorem}
\end{document}


This solution could be useful if you are creating a style file for existing documents.