1

I have in my paper a theorem-like environment which consists only of an enumerated list. It looks bad if I just type it in vanilla, so I add a $\,$ before the enumerate (see also enter link description here).

The problem is, it so happens that the theorem header is printed on one page, while the first item is printed on another, which is clearly awful.

I don't mind some items being printed on a page separate from the header (so this is not a solution to my problem), but if all the content is separated from the header, this is really bad, in my opinion.

Is there a solution, preferably one that will not cause great problems when the theorem shifts slightly after subsequent changes in the surrounding text?

MWE:

\documentclass{article}
\usepackage{amsthm}
\usepackage{lipsum}

\newtheorem{thm}{Theorem}



\begin{document}

    \lipsum[1-4]
    a\\a\\a\\a\\a\\a\\a\\

    %%%Looks bad!!!
    \begin{thm}$\,$
        \begin{enumerate}
            \item
            a
            \item
            b\qed
        \end{enumerate}
    \end{thm}

\end{document}
  • You can use the \needpsace package. \needspace{3\baselineskip} will go to next page if there is not sufficient room for 3 lines on current page. – Peter Grill Feb 28 '16 at 12:27
  • @PeterGrill: This looks like exactly what I need. Would you mind posting this as an answer? – tomasz Feb 28 '16 at 12:48
  • A minor issue is that the command itself does seem to take a minimal amount of vertical space. But this is not that bad. – tomasz Feb 28 '16 at 12:51
  • the usual suggestion for starting a list on a new line for a theorem (with amsthm) is to use \leavevmode rather than \,. but there's still the danger of "breakage", so \needspace may still be needed. – barbara beeton Feb 28 '16 at 13:43
  • @barbarabeeton: \leavevmode has the same effect. (Well, I did not check to see if the effect is exactly the same, but the problem persists.) – tomasz Feb 28 '16 at 13:47
1

With the \needpsace package, you can apply \needspace{3\baselineskip} before the theorem and then TeX will go to next page if there is not sufficient room for 3 lines on current page:

enter image description here

Notes:

  • The showframe package was used just to show the page margins. It is not needed in your actual use case.

Code:

\documentclass{article}
\usepackage{amsthm}
\usepackage{lipsum}
\usepackage{needspace}
\usepackage{showframe}

\newtheorem{thm}{Theorem}

\begin{document}

    \lipsum[1-4]
    a\\a\\a\\a\\a\\a\\a\\

    \needspace{3\baselineskip}%
    %%%Looks good now!!!
    \begin{thm}$\,$
        \begin{enumerate}
            \item
            a
            \item
            b\qed
        \end{enumerate}
    \end{thm}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.