1
\documentclass{report}
\usepackage[bottom=1cm, top =1cm]{geometry}
\usepackage{lipsum}
\begin{document}
\lipsum[1-8]
\lipsum[5][1-5]

another paragraph

consider the following cases:

case1

case2

\lipsum[6-7]
\end{document}

In the output the listing of cases and the introductory statement are on separate pages:

enter image description here

I am thinking about inserting an empty line after "another paragraph" to nudge the introductory statement over to the next page. Or two empty lines if two lines of the introductory statement were to be nudged over.

Or maybe somebody has a better idea how to control the text distribution in this case?

Viesturs
  • 7,895
  • 1
    If I were you, I would use a list environment, and if the cases go to the next page, I let them go –  Apr 24 '19 at 09:11
  • @JouleV, there may be awkward situations when there are even multiple pages of floats between the introductory statement and the list. Therefore it is important to find a nudge. In the case of a list there may be a formula or a longtable, etc. – Viesturs Apr 24 '19 at 09:15
  • Note that two empty lines have the same effect as one empty line (a new paragraph). – campa Apr 24 '19 at 09:15

1 Answers1

6

Use a list and set the begin penalty (requires package enumitem) so that it doesn't get separated from the introductary sentence:

\documentclass{report}
\usepackage[bottom=1cm, top =1cm]{geometry}
\usepackage{lipsum}
\usepackage{enumitem}
\begin{document}
\lipsum[1-8]
\lipsum[5][1-5]

another paragraph

consider the following cases:
\begin{itemize}[label={},leftmargin=\parindent,beginpenalty=10000,nosep]
\item case1

\item case2
\end{itemize}

\lipsum[6-7]
\end{document}

If you have floats interfering: ignore them until the document is finished. Float placement should be optimized as the last step.

Viesturs
  • 7,895
Ulrike Fischer
  • 327,261
  • What to write if instead of a list I have a formula? – Viesturs Apr 24 '19 at 09:41
  • 1
    Normally latex will try to avoid a page break there anyway (if you don't add an empty line/\par before the formula). – Ulrike Fischer Apr 24 '19 at 09:44
  • 1
    See also https://tex.stackexchange.com/questions/4471/unbreakable-block. Another, IMO (but others may disagree) legitimate technique is to add \pagebreaks to coax desirable breaking: but that is strictly to be done when the entire content of the document is finalised. – Paul Stanley Apr 24 '19 at 09:46
  • "if you don't add an empty line/\par before the formula" - will the same apply to lstlisting and longtable? – Viesturs Apr 24 '19 at 16:24
  • 1
    No, longtable and listings inserts a \par themselves. – Ulrike Fischer Apr 24 '19 at 16:30