Page breaking

Ordinarily LaTeX automatically takes care of breaking output into pages with its usual aplomb. But if you are writing commands, or tweaking the final version of a document, then you may need to understand how to influence its actions.

LaTeX’s algorithm for splitting a document into pages is more complex than just waiting until there is enough material to fill a page and outputting the result. Instead, LaTeX typesets more material than would fit on the page and then chooses a break that is optimal in some way (it has the smallest badness). An example of the advantage of this approach is that if the page has some vertical space that can be stretched or shrunk, such as with rubber lengths between paragraphs, then LaTeX can use that to avoid widow lines (where a new page starts with the last line of a paragraph; LaTeX can squeeze the extra line onto the first page) and orphans (where the first line of paragraph is at the end of a page; LaTeX can stretch the material of the first page so the extra line falls on the second page). Another example is where LaTeX uses available vertical shrinkage to fit on a page not just the header for a new section but also the first two lines of that section.

But LaTeX does not optimize over the entire document’s set of page breaks. So it can happen that the first page break is great but the second one is lousy; to break the current page LaTeX doesn’t look as far ahead as the next page break. So occasionally you may want to influence page breaks while preparing a final version of a document.

See Layout, for more material that is relevant to page breaking.

© 2007–2018 Karl Berry
Public Domain Software
http://latexref.xyz/Page-breaking.html