0

I am getting a page break in the middle of my document for reasons I cannot explain. I condensed the code down to the following extremely simple MWE that reproduces the issue.

\documentclass{article}

\usepackage{lipsum}

\begin{document}

{\LARGE Title}

\section{Section 1}

\subsection{Subsection 1} \lipsum[1][4]

\subsection{Subsection 2} \lipsum[1][5]

\subsection{Subsection 3} \lipsum[1][9-10]

\section{Section 2}

\subsection{Subsection 4} \lipsum[1][6-11]

\section{Section 3}

\subsection{All remaining sections/subsections need to be here...}

\subsection{...in order to generate the mystery page break} \subsection{It seems if you delete...} \subsection{...any of the remaining subsections...} \subsection{...then it makes the page break vanish.}

\section{Section 4}

\subsection{Another subsection} \subsection{And another} \subsection{And another}

\section{Section 5}

\end{document}

The output looks like this:

two pages of document with page break visible

Where is that page break coming from?

It seems especially weird to me that if I delete, for example, Section 5 from the document, the page break goes away. Presumably, that is because without Section 5 the entire document would fit onto a single page. But, so what? Wouldn't that also suggest that it makes sense to break the page right before Section 5?

All of this suggests to me that somehow LaTeX is doing some sophisticated decision-making about the best place to break the pages. If so, then this must be documented someplace, I suppose. But it seems hard to imagine what logic would lead to a break right in the middle of the first page like that.

Can anyone help to clarify?

  • 1
    This is a FAQ, after section 3 you only have section headings and latex does not break after a section heading, so as it will not all fit on one page it breaks at the only place possible. Add any text after any of the section headings and page breaks will be allowed – David Carlisle Jan 14 '22 at 14:10
  • @DavidCarlisle: Okay, I see. I did try to find the answer on here before. Seeing as how it is an FAQ, should I delete the question? – Louis Deaett Jan 14 '22 at 14:12
  • No I'll find a duplicate (there must be one somewhere:-) – David Carlisle Jan 14 '22 at 14:15
  • It's always easier to search for the answer than the question:-) – David Carlisle Jan 14 '22 at 14:19
  • I had seen the question "Overfull box and broken pagination..." of which it's claimed this is a duplicate. But since my document had no overfull warnings, that didn't sound like my question, and so I didn't navigate to it. Therefore, I'll leave this question up to point others to that one. (The answer there does answer the question here.) I suppose it might be appropriate to just edit the title of that question, but I'm not sure. – Louis Deaett Jan 14 '22 at 14:26
  • hmm fair enough. There is never a need to delete a duplicate (the site uses duplicates to help drive search to the original) although I take your point here that maybe it's not so obviously a dup, it is if you know the answer as in the same issue that the run of section headings is unbreakable, it's just that you get different behaviour here as there is a (bad) page break that allows it to avoid over full page whereas in the other question there is not. I could unclose and you could self answer if you prefer – David Carlisle Jan 14 '22 at 14:34
  • Thanks, @DavidCarlisle. I won't advocate to unclose, since the accepted answer to the linked question definitely resolves my problem. As long as this question remains visible and searchable for others in the future, I think it will drive traffic to the useful information there, as you suggest. So that seems all to the good. And many thanks for your help, as I myself would still be confused without it! – Louis Deaett Jan 14 '22 at 14:58

0 Answers0