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}
tomasz
  • 825
  • 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
  • i did say that \needspace would still be needed. @PeterGrill's suggestion is the real answer; i was just trying to tidy up the corners. the problem is known -- the beginning of a list is defined to be a good place to break a page -- and is on a list of problems to be investigated. – barbara beeton Feb 28 '16 at 13:53
  • @barbarabeeton: Sure, thanks for the information. By the way, is there any advantage to using \leavevmode instead of $,$? – tomasz Feb 28 '16 at 14:04
  • other than \leavevmode is conceptually "cleaner" with respect to how the theorem environment is defined, not really. (and, granted, "cleaner" is not easy to define; but it's what's recommended by the person who wrote the code.) – barbara beeton Feb 28 '16 at 14:21
  • @barbarabeeton: Okay, thanks. I'll stick to that in the future. :) – tomasz Feb 28 '16 at 14:34
  • @barbarabeeton what about changing \@beginparpenalty? – touhami Feb 28 '16 at 16:11
  • @touhami -- seems worth testing, but it'll take a few days before i have time. will report. – barbara beeton Feb 28 '16 at 22:45

1 Answers1

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}

Peter Grill
  • 223,288