Breaks & page tuning

Page breaking in LaTeX works nothing like line breaking. A paragraph is broken by considering every possible split at once and choosing the best overall; a page, once ended, is never reconsidered. So if you type \newpage without understanding why the page ended where it did, you can drag the next forty pages along with it. This page measures the machinery of document rhythm — widows and orphans (\widowpenalty and \clubpenalty, both defaulting to 150), the difference between \raggedbottom and \flushbottom, and the way floats shove text around — and builds a procedure for diagnosing a bad break instead of forcing one.

Why a page ends where it does: the one difference from line breaking

A page ends where it does on the strength of only the information available while that page is being built. TeX pours text downward, watching the legal break points that appear between lines, and the moment the accumulated height exceeds the target it goes back to the cheapest candidate it has seen so far and cuts there. Line breaking inside a paragraph is a global optimisation over every possible arrangement; page breaking is a sequential decision made while moving forward. That is the difference that matters in practice, and it is why fixing the break on page 40 shifts everything from page 41 onward.

Deciding sequentially also means there is no renegotiating afterwards. All TeX has left is a way to declare, as a number, how badly it does not want to break at each candidate — a penalty. A penalty is an integer attached to a break point; the larger it is, the more reluctant TeX is to cut there. 10000 is the special value meaning “never break here”, and -10000 means “always break here”. The machinery that avoids stranding a single line of a paragraph, the machinery that places floats, and the machinery that forbids a break right after a heading are all expressed with this one kind of number. Tuning page breaks is, in effect, tuning penalties.

Widows and orphans: \widowpenalty and \clubpenalty both default to 150

Measured in the article class, \widowpenalty and \clubpenalty are both 150, and \displaywidowpenalty is 50. A widow is the last line of a paragraph stranded alone at the top of a page; an orphan is the first line stranded alone at the bottom. German printers keep the two apart as Hurenkind and Schusterjunge. The first thing that trips people up is the naming: the parameter that suppresses an orphan is not \orphanpenalty — no such variable exists in TeX or LaTeX — but \clubpenalty, a survival of the old printers' term club line for a stranded opening line.

latex
% Print the defaults into the .log yourself:
%   pdflatex penalties.tex  ->  grep MEASURE penalties.log
\documentclass{article}
\begin{document}
\typeout{MEASURE widowpenalty=\the\widowpenalty}
\typeout{MEASURE clubpenalty=\the\clubpenalty}
\typeout{MEASURE displaywidowpenalty=\the\displaywidowpenalty}
\typeout{MEASURE brokenpenalty=\the\brokenpenalty}
x
\end{document}

The number 150 has a pedigree. In TeX Live 2024 those three assignments sit at lines 514–516 of latex.ltx — and the identical three lines appear at 290–292 of Knuth's plain.tex. LaTeX simply inherited plain TeX's defaults and has not revisited them in forty years. And 150 barely does anything in practice. The ugliness — the badness — of pulling a page one line short easily exceeds 1000 in body text, where there is little vertical glue to stretch. A penalty of 150 loses that argument almost every time.

ParameterDefaultWhat it discourages
\widowpenalty150the last line of a paragraph alone at the top of a page
\clubpenalty150the first line of a paragraph alone at the bottom of a page
\displaywidowpenalty50a lone line stranded just before a displayed formula
\brokenpenalty100breaking the page right after a hyphenated line
\interlinepenalty0breaking anywhere inside a paragraph (not discouraged by default)
\predisplaypenalty10000breaking immediately before a displayed formula (effectively forbidden)

There is exactly one place where LaTeX itself abandons these defaults. The thebibliography environment in article.cls calls \sloppy on entry and sets \clubpenalty4000 and \widowpenalty4000 (lines 576–579 of the article.cls shipped with TeX Live 2024). A reference list is a long run of short entries, so widows are frequent, and an entry split across two pages is genuinely hard to read — that is why the standard class makes an effort in this one spot. Which also means the converse: in body text, the standard classes do nothing for you.

What \widowpenalty=10000 actually costs: the trade, measured

The widow disappears and a short page arrives in its place. Set a document with 20 lines per page and six-line paragraphs in \flushbottom and measure: with the defaults, page 1 takes 23 lines and the last line of the fourth paragraph is stranded alone at the top of page 2. Add \widowpenalty=10000 and page 1 drops to 22 lines, the final two lines travel together to the next page, and the widow is gone. But the log gains a line.

log
Underfull \vbox (badness 10000) has occurred while \output is active []

The warning means TeX could not fill the page down to its target height, and it appears only under \flushbottom. Run the same experiment under \raggedbottom and the warning never fires — the page is allowed to stop short, so there is nothing to fill. The cost of \widowpenalty=10000, then, shows up as uneven stretched leading under \flushbottom, and a varying strip of white at the foot under \raggedbottom. Either way the cost is not zero. Even so, for a manuscript that is mostly running text, 10000 is a defensible setting: readers reliably notice a single stranded line, and most of them never notice a page that stops one line early.

latex
% A defensible pair of settings for a text-heavy manuscript.
\widowpenalty=10000
\clubpenalty=10000
% Also stop a two-line gap opening before a displayed formula:
\displaywidowpenalty=10000
% Prefer this over sprinkling \newpage through the source.

\raggedbottom vs \flushbottom, and which one you already have

\flushbottom stretches vertical space so that every page ends at the same height; \raggedbottom lets the bottoms vary. This is where a great deal of published advice is wrong: the default for a one-sided article is \raggedbottom, not \flushbottom. article.cls, report.cls and book.cls all end with \if@twoside \else \raggedbottom \fi, so unless you asked for twoside you are in ragged-bottom mode. Only book, which is twoside by default, stays on the flush-bottom side. Ask for two columns and every one of those classes calls \flushbottom explicitly.

Class optionsWhat is actually in forceHow the foot looks
\documentclass{article}\raggedbottomthe foot sits at a different height on each page
\documentclass[twoside]{article}\flushbottomfeet line up; leading may be stretched
\documentclass{book}\flushbottombook is twoside by default, so this is what you get
\documentclass[twocolumn]{article}\flushbottomcalled explicitly by the class; uneven columns are conspicuous

The mechanism is almost disappointingly simple. In latex.ltx, \raggedbottom is defined as \def\@textbottom{\vskip \z@ \@plus.0001fil} and \flushbottom as \let\@textbottom\relax. The first places a glue of zero length that can stretch infinitely at the very bottom of the page; that fil overwhelms the small finite stretch available in the text above it, so all the slack is absorbed at the foot. Ask for \meaning\@textbottom and article answers macro:->\vskip \z@ \@plus .0001fil while book answers \relax — one line in the preamble tells you which mode your own document is in.

latex
% Which bottom mode am I in? Put this in the preamble and read the .log.
\makeatletter
\AtBeginDocument{\typeout{MEASURE textbottom=\meaning\@textbottom}}
\makeatother
% article  -> macro:->\vskip \z@ \@plus .0001fil   (\raggedbottom)
% book     -> \relax                                (\flushbottom)

When floats push the text around: \topfraction and \textfraction

When a page break looks inexplicable, the culprit is usually a float. Before placing a figure or table, LaTeX checks how much of the page it may occupy and how many are already there. Measured in the standard classes: top floats may fill up to \topfraction = .7 of the text height, bottom floats up to \bottomfraction = .3, at least \textfraction = .2 must remain as actual text, and a page holds at most totalnumber = 3 floats (topnumber = 2 at the top, bottomnumber = 1 at the bottom). A figure that fails any one of these tests is not placed on that page but deferred to a later one. Deferred floats are placed before the text that follows them, which is how you end up with the prose on page 12 and its figure on page 14.

ParameterDefaultMeaning
\topfraction.7fraction of the text height top floats may occupy
\bottomfraction.3fraction bottom floats may occupy
\textfraction.2minimum fraction of a float page that must remain text
\floatpagefraction.5minimum fill before a float-only page is allowed
totalnumber3total floats allowed on one page
topnumber2floats allowed at the top of a page
bottomnumber1floats allowed at the bottom of a page

When a float is to blame, the log says so first. If a figure marked [h] cannot go there, LaTeX announces LaTeX Warning: 'h' float specifier changed to 'ht'. and quietly moves it to the top. If too many deferred floats pile up it stops with ! LaTeX Error: Too many unprocessed floats. (the \@fltovf message in latex.ltx). In practice the standard remedies are \FloatBarrier from placeins at section boundaries, which confines figures to the section they belong to, or \afterpage{\clearpage} from the afterpage package, which flushes the queue only once the current page has been finished. A bare \clearpage written in place leaves a large hole in the middle of the text.

latex
\usepackage{placeins}   % \FloatBarrier
\usepackage{afterpage}  % \afterpage{\clearpage}

% Keep every figure inside the section that discusses it:
\let\oldsection\section
\renewcommand\section{\FloatBarrier\oldsection}

% Or loosen the rules instead of forcing breaks:
\renewcommand{\topfraction}{0.85}
\renewcommand{\textfraction}{0.1}
\renewcommand{\floatpagefraction}{0.75}

How to fix a bad page break: what to try before forcing it

There is an order to it: identify the cause, then fix a global setting, and only then touch the one page that is still wrong by hand. Do it in the opposite order and a single added sentence upstream destroys all the manual work. Identification starts in the .log. An Underfull \vbox means \flushbottom and your penalties are pulling against each other; a float specifier changed message means a float; a run of Overfull \hbox means the problem is in line breaking, which is another page's territory. Once you know the cause you can choose what to move: a penalty, a float fraction, or the length of the paragraph itself.

  • Read the .log. Which of Underfull \vbox, float specifier changed or Overfull \hbox appears tells you who the culprit is.
  • Raise \widowpenalty and \clubpenalty in the preamble. Because it applies document-wide, what you fix stays fixed.
  • If a float is at fault, use \FloatBarrier or adjust \topfraction. Widening the placement specifier to [htbp] also helps.
  • Make the paragraph itself one line shorter or longer. Rewording a single phrase is often the most durable fix of all.
  • \enlargethispage{\baselineskip} makes just that page one line taller. Only now are you working by hand.
  • \newpage and \pagebreak are the last resort. Once inserted, they must be rechecked every time the text changes.

\looseness is the way to ask TeX for “one line shorter”. Written inside a paragraph, \looseness=-1 means “set this one line shorter if you can” and +1 means one line longer. Measurement is sobering, though. In a paragraph with \tolerance=9999 and \emergencystretch=3em, \looseness=1 did stretch six lines to seven — at the price of six Underfull \hbox warnings. And \looseness=-1, the direction everyone actually wants, failed to change the line count at all, because no shorter arrangement existed within \tolerance. \looseness is a move worth trying, not a lever that reliably works. When it does nothing, deleting one word from the manuscript is quicker.

latex
% Ask for one line fewer inside the paragraph itself.
% \looseness is reset by every \par, so it must sit inside the paragraph.
\tolerance=9999 \emergencystretch=3em
Some paragraph text ... \looseness=-1

% Only after the above has failed: one page, one line taller.
\enlargethispage{\baselineskip}

Where \pagebreak, \linebreak and \- are covered

This page is about document-wide rhythm; the individual break commands belong elsewhere. The page-side commands — \pagebreak[n] and \nopagebreak[n] (n from 0 to 4), the unconditional \newpage, \clearpage which also flushes pending floats, and \cleardoublepage which adds a blank page in two-sided work — are covered under page-break tuning. The line-side ones — \\, \newline, \linebreak[n], \nolinebreak[n], the discretionary hyphen \-, the preamble exception list \hyphenation{man-u-script} and the hyphenat package — are covered under line-break tuning. Paragraph structure and \par itself belong to the paragraphs page. And Overfull \hbox, \sloppy and \emergencystretch have a dedicated error page, where \sloppy is measured out as nothing but four assignments (\tolerance 9999, \emergencystretch 3em, \hfuzz .5\p@, \vfuzz\hfuzz).

Finally, one member of this family is already being used on your behalf without a word. The sectioning commands temporarily raise \clubpenalty to 10000 for the paragraph that follows a heading, so that no page break can fall immediately after it — this is what the \@clubpenalty machinery in latex.ltx is for. That is why a heading stranded alone at the foot of a page essentially never happens in stock LaTeX. If it does happen, it is because a home-made macro replaced the sectioning command.