Tuning page breaks

LaTeX surveys the whole document and chooses page breaks for you, but sometimes you want to step in: “break the page right here,” “don’t tear this heading from its text,” “a lone first line of a paragraph got stranded at the bottom.” The tools fall into three families: commands that suggest or force a break, devices that prevent a break, and penalties that discourage widows and orphans. This page walks through when to reach for each.

Suggesting versus forcing a break

First, the tools that *change* the page. The key distinction here is between **\pagebreak and \newpage. Both end the page at that point, but they treat the leftover space in opposite ways. \pagebreak stretches the vertical space so the text reaches the bottom of the page (the normal bottom margin), spreading things out. \newpage**, by contrast, does *not* stretch: it leaves the rest of the page blank and moves on.

Which to use depends on intent. To pack the text naturally down to the bottom before breaking, use \pagebreak; to start fresh on a clean new page (the end of a chapter, say), use \newpage. Note, though, that \pagebreak can break mid-paragraph as a side effect. The official reference also notes that because \pagebreak stretches the page’s vertical space where possible, with \flushbottom in force it can trigger an underfull-box warning or look odd.

\pagebreak takes an **optional strength argument \pagebreak[n] (n from 0 to 4)**. Four is an outright demand and is also the default when you omit the argument; lower numbers are milder “if possible” requests, with \pagebreak[0] amounting to mere permission to break here. It follows the same convention as \linebreak[n] for lines — think of it as the page-level counterpart.

Flushing floats with clearpage

A stronger relative of \newpage is **\clearpage. Besides ending the page and moving on, it outputs all the pending floats (figures and tables) first**, then breaks. Because LaTeX floats figure and table to wherever it judges best, they can land on a later page than where you wrote them. When a section must come *after* its figures, putting \clearpage at the boundary flushes the accumulated floats before the new page begins.

For double-sided printing, **\cleardoublepage** helps. Like \clearpage it clears the floats, and under the twoside option it makes the next body content start on a right-hand, odd-numbered page, inserting a blank verso (even) page if necessary. This is the familiar behavior for books that open each chapter on a right-hand page (the default in the book class). Note also that in two-column mode \newpage only ends the current column — to end the whole page you need \clearpage or \cleardoublepage.

Preventing a page break

Now the tools for the opposite — “don’t break here.” The basic one is **\nopagebreak[n]**, which discourages a page break at that point; n sets how insistent it is (0 to 4, default 4). \nopagebreak[0] is a suggestion to avoid the break if possible, while \nopagebreak[4] is a firm prohibition. Place it at a seam you do not want torn — between a heading and the text right after it, or between a figure and its explanation.

To keep a somewhat larger stretch together on one page, there is the declaration **\samepage** and the samepage environment of the same name. It works by assigning infinite penalties to every possible break point inside the enclosed region so it will not break within. But as the TeX FAQ cautions, it is not a cure-all: to keep running text together you must end the paragraph inside the environment, and if the enclosed material emits its own break hints, \samepage has no power over them.

More reliable is the **needspace package**. After \usepackage{needspace}, writing **\needspace{3\baselineskip} means “if there is not 3 lines’ worth of space between here and the bottom of the page, start a new page” — in other words, continue if three lines fit, otherwise move to a fresh page.** It is the go-to for keeping a heading and its first few lines together. Expressing the length as a multiple of \baselineskip (the line spacing) is the intuitive choice, though pt or cm work too. There is also \Needspace{...}, which reserves the space more exactly, and \Needspace*{...}, which makes a short page flush-bottom under \flushbottom (the latter two are used between paragraphs).

Widows and orphans

An orphan is a lone first line of a paragraph left at the very bottom of a page; a widow is a lone last line of a paragraph sitting by itself at the top of the next page. Both read poorly and are the kind of bad break typesetting tries to avoid. (The terminology varies between sources, but the TeX FAQ defines an orphan as “the first line of a paragraph at the end of a page” and a widow as “the last line of a paragraph at the start of a page.”)

Two integer penalties hold them back. **\clubpenalty governs orphans (breaking *after* the first line of a paragraph), and \widowpenalty** governs widows (breaking *before* the last line). The larger the value, the more LaTeX judges a break there “not worth it” and avoids it. The standard-class default is 150 (mild discouragement). Per the TeX FAQ there are really only two meaningful settings: finite (150 or 500 — it scarcely matters which) to allow widows and orphans, and infinite (10000 or more) to forbid them.

To forbid them, set both to the maximum in the preamble. The usual incantation is:

latex
\clubpenalty=10000
\widowpenalty=10000

But a blanket ban has a cost. To dodge a bad break, LaTeX drops a line from the page, so the bottoms of pages no longer line up — they go ragged. That is exactly why the default stops at “mild discouragement.” In practice, rather than pinning everything to 10000, you get a higher-quality result by fixing only the offending spots by hand during final proofreading. The classic targeted fix is **\enlargethispage{\baselineskip}, which temporarily enlarges the \textheight of the current page only** to admit one more line; lengthening the bottom paragraph by a line pulls the spilled last line back onto the page and clears the widow. When you need to squeeze a line in even at the cost of tightening the spacing, use the starred \enlargethispage*{\baselineskip}.

Command quick reference

Here are the main page-break commands and parameters at a glance. The needspace commands require loading that package; the rest are standard LaTeX.

CommandWhat it does
\pagebreak[n]Suggest/force a break (n=0–4, default 4); stretches vertical space to the bottomCan break mid-paragraph
\newpageEnd the page now; no stretching, rest left blankIn two-column, ends only the column
\clearpageEnd the page and flush all pending floats first, then breakUse to keep a section after its figures
\cleardoublepageLike clearpage, but under twoside starts on a right (odd) page, inserting a blank if neededFor books opening chapters on the right
\nopagebreak[n]Discourage a break at this point (n=0–4, default 4)Keep a heading with its text
\samepageInfinite penalties on breaks inside the region to hold it on one page (environment too)Not foolproof; end paragraphs inside
\needspace{N\baselineskip}Break unless N lines’ worth of space remains (needspace package)Keep a heading with its first lines
\clubpenaltyInteger discouraging orphans (a stranded first line); default 150, forbid with 10000Higher means more avoided
\widowpenaltyInteger discouraging widows (a stranded last line); default 150, forbid with 10000Higher means more avoided
\enlargethispage{\baselineskip}Enlarge the current page’s textheight only, fitting one more lineStarred form squeezes a line in

Using these in practice

The cardinal rule is to tune page breaks last. Adding or removing even one character shifts every subsequent break, so sprinkling manual \newpage commands midstream leaves awkward gaps every time you later edit the text. Finish the content first, then inspect pagination at the final stage. For widows and orphans too, rather than leaning entirely on a blanket ban in the preamble, fixing just the conspicuous spots individually — with \enlargethispage and the like — is the surer path to pages whose bottoms line up cleanly.

Page breaking is a separate layer from line breaking (\linebreak or \\), and it interacts closely with the placement of figure and table. For line tuning see “Tuning line breaks,” for paragraphs themselves see “Line & paragraph breaks,” and for positioning floats see “Float placement.”