246

TUGboat, Volume 39 (2018), No. 3

Managing forlorn paragraph lines(a.k.a. widows and orphans) in LATEXFrank MittelbachContents
1

The name of the game246

2

The problem

246

3

Fixing the problem

247

4

Using TEX’s \looseness approach

249

5

Identifying pages with widows or orphans

250

1

The name of the game

Splitting off the first or last line of a paragraph ata page or column break is considered bad practicein typesetting circles. It is thus not surprising thatthe craftspeople have come up with fairly descriptive
names for such lines when they appear in typeset
documents.
Commonly used are the terms “widow” for thelast and “orphan” for the first line. These are, forexample used in English, French (“veuve” and “orpheline”), Italian (“Vedova” and “Orfano”), Spanish(“lı́nea huérfana” and “lı́nea viuda”), or to a lesser
extent in German (“Witwe” and “Waise”).
One way to remember them is to think of orphaned lines appearing at the start (birth) and widows near the end (death) of a paragraph or by using
Bringhurst’s mnemonic, “An orphan has no past; awidow has no future” [6].
German typesetters coined some more profane
descriptions by calling the widow line a “Hurenkind”(child of a whore) and the orphan line a “Schusterjunge” (son of a shoemaker) allegedly because theseboys have been notoriously meddlesome. For German practitioners these are still the predominantly
used terms, though “Witwen” and “Waisen” are also
well understood. Dutch uses “hoerenjong” and “weeskind” which translates to son of a whore and orphan,i.e., somewhere in between the German usage andthe other languages.
Don Knuth catered for this typographic detail in
the TEX program by providing parameters whose values are used as penalties if the pagination algorithm
considers breaking in such a place. Widow lines
are penalized via \widowpenalty; however, orphans
are not controlled by \orphanpenalty as one might
expect, but by a parameter named \clubpenalty.
There have been some queries about this choiceof names on Stack Exchange and after a little Internet
searching I found a listing for “club line” in the
Collins English Dictionary Digital Edition [1], listingFrank Mittelbach

it as a British (!) term used in printing for an orphan
line. Further checks through the first dozen or sopages of google hits for “club line” by its own, and thesame with additional restrictions such as “printing”
or “typography” revealed a handful of additionalreferences (two of which mentioned that Knuth used
the term — thus circular references). So on the whole
it was a meager result and all except one indicateda use of the term in British not American English.
Contrast this with a search for “orphan line” ingoogle: Now we will find that nearly all the resultsin the first five pages are relevant, with only two or
three near the end being unrelated.
However, what we also see from following themup is that about a third of them give the terms
different meanings, either by swapping the definition of orphan and widow lines or by giving thema slightly different meaning altogether: The lastline of a paragraph being nearly empty, i.e., containing only a single word or even part of a single
word.1
Most of the time, though, the forlorn lines wewant to deal with are called widows and orphans andthis is what we will call them in the remainder of
the article, even if we have to set a \clubpenalty
to deal with one of them.
2

The problem

Essentially everyone in typography circles agrees thatwidows and orphans are very distracting to the reader
as well as a sign of bad craftsmanship, and should
therefore be avoided. In fact, most writing guides andother books on typography generally suggest that adocument should have no such lines whatsoever, e.g.,in older editions of the Chicago Manual of Style [2]we find “A page should not begin with the last lineof a paragraph unless it is full measure and should
not end with the first line of a new paragraph.”
However, that is easier said than done, so in anewer edition of that guide [4] we now find “A pageshould not begin with the last line of a paragraphunless it is full measure. (A page can, however, end
with the first line of a new paragraph.)” instead.
As a result of this sort of guidance many journalclasses for LATEX completely forbid widows and orphans by setting \widowpenalty and \clubpenalty
to 10000 which prohibits a break at such points —TUGboat being no exception.
1 ...

as demonstrated here. In TEX this kind of typographical issue can also be dealt with, although by different means and somewhat more manually: The parameter\finalhyphenpenalty can make hyphenation in the last line
unattractive, and using unbreakable spaces will ensure that
there is more than one word in the last line; \parfillskip
can also help.

TUGboat, Volume 39 (2018), No. 3
But doing this introduces severe problems: As
LATEX (and in fact all major typesetting systems
to date) use a greedy algorithm to determine thepagination of a document, it will recognize problems
with orphan or widow lines late in the game andwill have only the current page to work with. Thismeans the best it can do to avoid the situation is
to push an orphan to the next page if there is notenough room to squeeze in another line. The same
happens with widows; here LATEX is forced to movethe second-last line to the next page even though it
would still nicely fit.
As a result the current page will have an additional line-height worth of white space that needs tobe distributed somewhere on the page. If there areheadings, displays, lists or other objects for which
the design allows some flexibility in the surrounding
white space, then this extra space may not createmuch of an issue. If, however, the page consists
only of text or objects without any flexibility, thenall LATEX can do is run the page or column short,
generating a fairly ugly hole at the bottom.2
Related problems
Besides widows and orphans there are a numberof similar issues that typography manuals mandate
eliminating if at all possible. One is a paragraph split
across pages at a hyphenation point so that only apart of the word is visible at any time; another isa widow line with a following display formula. For
both, TEX offers parameters to control the undesirability of the scenario. By default Don Knuth
considered them of lesser importance and provided
default values of 100 and 50 for \brokenpenalty
and \displaywidowpenalty, respectively while hespecified 150 for orphans and widows. However, if
your style guide (or your class file) wants to avoid
them at all cost then you are in precisely the same situation as with widows and orphans discussed above.
A special variation of the last issue is a display
formula starting a page, that is, with the introductorymaterial completely on the previous page or column.
That is considered a no-go by nearly everybody so in
TEX the controlling \predisplaypenalty parameterhas by default a value of 10000. But again, there
may be valid reasons to ignore this advice in a special
situation, e.g., when the space constraints are high.
3247
and at all costs is to manually resolve the issues when
they arise. For this one finds a number of suggestionsin the typography literature; a good collection is
given in the guidelines section of the Wikipedia pageon “Widows and Orphans” [5]. We will look at them
one by one below and discuss their applicability andpossible implementation in a LATEX document.
I Forcing a page break early, producing ashorter page
This is what LATEX and most other typesetting tools
automatically do if you completely forbid widows
and orphans and if often leads to badly filled pages
as discussed above.
However, if you force the page break manually,
you can lessen the impact by also explicitly forcing
earlier breaks and thereby shifting the extra whitespace to a page or column where it can be absorbedby the available flexibility on that page.
I Adjusting the leading, the space between linesof text (although such carding or feathering
is usually frowned upon)That is indeed frowned upon and for good reason.
The human eye is tuned to notice even small differences in the vertical spacing of lines and acrosscolumns or pages such changes, even if they are small,are very noticeable and distracting. Besides, managing such a change in a LATEX document wouldbe, while possible, quite cumbersome, so this is notparticularly useful advice for us.
I Adjusting the spacing between words to produce ‘tighter’ or ‘looser’ paragraphs
This is certainly a practical option if you choose theright paragraph or paragraphs, e.g., those that are
somewhat longer and that have a last line that iseither nearly full (for lengthening) or nearly empty(for shortening). In that case squeezing the word
spaces might result in one line less and extending it
might get you an additional line (with just a wordor two). In many cases the resulting gray value isstill of acceptable quality so this is a typical trickof the trade. In LATEX this is achieved by using the\looseness parameter that is discussed in Section 4.
Note that you do not necessarily need to manipulate one of the paragraphs of the problem page;
there might be a better candidate on an earlier page.
I Adjusting hyphenation within the paragraphFixing the problem

The alternative to preventing widows and orphans (orhyphens across page boundaries, etc.) automatically2 This can be observed on the first page of this article,
where an orphan line was pushed onto the current page. Fortunately, the resulting hole is partly masked by the footnote.

This is a variation of the “change the number of paragraph lines” type of approach. However, given thatLATEX is usually good in considering most of the possible hyphenation points when breaking paragraphs,
one is unlikely to gain much if anything. Thus, thissuggestion might have some merits in a system thatManaging forlorn paragraph lines (a.k.a. widows and orphans) in LATEX

248

TUGboat, Volume 39 (2018), No. 3

does not hyphenate well (or at all) but with LATEXI Reduce the tracking of the words
one is better off applying \looseness.
Tracking in this context means adjusting the spacing
If you have a very badly broken paragraph bebetween characters in a uniform way (in contrast tocause of a missed hyphenation point you should fix
kerning, which means adjusting the spacing between
that anyway (by adding \- or a \hyphenation exindividual glyph pairs, e.g., “AV” cf. “AV”).
ception) regardless of whether or not there is a widow
Figure 1 shows a line of text with different
or orphan nearby.
amounts of tracking (negative and positive) applied.
I Adjusting the page’s margins
Clearly by applying tracking one can shorten or
lengthen a text. However, when comparing the lines
Now this is an interesting approach. In contrast toside by side it is also obvious that the gray value ofchanges in \baselineskip small changes in the line
words
changes fairly rapidly too. Thus even withwidth are virtually undetectable without a ruler —small
tracking
values, changes may become noticeunless you make it a huge change. Unfortunately, it
able
and
thus
distracting.
To illustrate the pointA
is not really an option when using L TEX as the unthis
articlecontains
one
manipulatedparagraph; see
derlying TEX engine essentially assumes a fixed line
if
you
can
spot
it
—
perhapsitwason an earlier
width throughout, so it is fairly difficult to change
page
and
you
thought:hmm
that
doesn’tlook quitethat at arbitrary places.
4
right.
In other words, this advice is really geared toOn the whole, common typographical advice iswards interactive systems where you can change thetonot
use tracking for such purposes or, if there
width of a text region and get an immediate reflow
isnobetteralternative, then only with very small
as a visual feedback.
tracking values in which case there may not be any
I Subtle scaling of the page, though too muchnoticeable effects on the paragraph length unless you
non-uniform scaling can visibly distort theare lucky. It is possible to experiment in LATEX if
letters
you load the microtype package and use, for example,
In principle, that would be possible with LATEX\textls.
though so far nobody has implemented the necessary
I Adding a pull quote to the text
changes to the output routine. That
(more common for magazines)
is, when a column or page runs short “An orphan has no past;
it will be scaled to the right height
Pull quotes are catch phrases froma widow has no future”
before attaching headers and footthe text that are “pulled out” anders. Instead of a non-uniform scaling, one could dotypeset prominently again in a different place, typiuniform scaling and adjust the horizontal widths ofcally in a larger and often different font. They serve
headers and footers accordingly.
as eye catchers and if carefully chosen will give the
However, that approach has issues already disreader a preview of the content or main points of ancussed: Scaling means we get a different leading
article.
(though this time the characters will also grow). And
The design needs to clearly distinguish them
if we do non-linear scaling, i.e., only vertically, thenfrom other display material, e.g., there should be
we will distort characters and from a certain point
no way to confuse them with headings, etc. In twoonwards this will also be noticeable. So it is questioncolumn texts this is often done by placing them inable whether this will actually improve the situation.
a window with both columns flowing around them(asshown on this page), but placing them into the
I Rewriting a portion of the paragraphcontent of one column is also often done.
This is obviously something you can do only if you are
Placing them within a single column is fairly
the author and not typesetting some text written byeasy in TEX, all you need to do is to define an enviothers. But if so, it is a valid strategy since it enablesronment that places the material between paragraph
you to easily shorten or enlarge a paragraph so thatlines (using \vadjust if used inside paragraph text).
your orphan or widow is reunited with other lines.
Producing pull quotes with the column texts
Again, there is no requirement to do this rewrite
flowing around it, is more manual work and fairly
with the paragraph causing the issue (as implied bycumbersome, but doable. On the present page, we
the advice); you can choose any3 earlier paragraphused the wrapfig package. The approach, as well as
to achieve the desired effect.
a few others are discussed in answers to a question
3 Well, “any” is an exaggeration: If you change a paragraphon Stack Exchange [3].
on an earlier page the gained (or extra) space might get
swallowed up by available flexibility on some intermediate
page and your widow or orphan thus stays put.

Frank Mittelbach

4 The answer is given at the end of the article.

TUGboat, Volume 39 (2018), No. 3

249

Tracking is the uniform increase or decrease of spacing between glyphs.
−0.05 em
Tracking is the uniform increase or decrease of spacing between glyphs.
−0.03 em
Tracking is the uniform increase or decrease of spacing between glyphs.
−0.02 em
Tracking is the uniform increase or decrease of spacing between glyphs.
−0.01 em
Tracking is the uniform increase or decrease of spacing between glyphs.
— LATEX’s default setting —Tracking is the uniform increase or decrease of spacing between glyphs.
+0.01 em
Tracking is the uniform increase or decrease of spacing between glyphs.
+0.02 em
Tracking is the uniform increase or decrease of spacing between glyphs.
+0.05 em
Tracking is the uniform increase or decrease of spacing between glyphs.
+0.07 em
Figure 1: Tracking in action

As the above advice already mentions, these are
more commonly found in magazine type documents,
so this approach may or may not be applicable.
I Adding a figure to the text, or resizing an
existing figure
Just like adding a pull quote, resizing a figure will
obviously change the amount of material a column
can hold and thus will enable us to move an orphan
or widow out of harm’s way. Whether or not it isa valid option depends on the figure in question;
often enough graphics do offer some freedom andcan be adjusted either by scaling (up or down) or bycropping, etc.
Summary
To resolve issues with widows and orphans one has
to somehow adjust the amount of material typeset
in the respective column or page. For LATEX users
the most promising approaches are• forcing material from one column to the next
through explicit page breaks;• generating more or less material by lengtheningor shortening some paragraphs;• rewriting paragraphs (if you are the author);• or resizing a float.
Adjusting the line width for a single column is rather
difficult to achieve in LATEX and therefore not recommended, even though it can lead to good results.
Applying tracking seldom works well, it usually either
makes no difference or results in noticeable grey-level
differences.
Using pull quotes is similar to changing or resizing floats or modifying paragraphs. However, thequotes carry meaning and so you can’t simply add
one arbitrarily for the sake of better pagination.
Thus, adding or moving them around is a bit likechanging the document structure and you therefore
have to be careful not to sacrifice semantics for form.
This makes them a less desirable approach.
Scaling the page or changing the leading is typographically rather questionable, so these can’t berecommended (besides their being rather complicatedto achieve with LATEX).
In any case, it should be noted though that all
approaches are manual and thus the adjustments
will become invalid the moment there is a documentchange that modifies the amount of material typeset.
It is therefore of paramount importance to manually
fix widows and orphans only at the very last stageof producing the final document. Otherwise all theeffort might be in vain and will need to be undone
or changed over and over again.
The situation would be somewhat different if
TEX was extended to globally optimize pagination
rather than applying a greedy algorithm as it currently does. Some theoretical work in that direction
has been carried out in recent years by the current author and it may eventually lead to a production-readysystem using LuaTEX [7, 8]. However, at present it isavailable only in a private prototype implementationand can’t be used with vanilla LATEX.
4

Using TEX’s \looseness approach

TEX (and therefore LATEX) uses a globally optimizing
line-breaking algorithm to find the best breaks for agiven paragraph based on a given set of parameters.
One can ask TEX to try to find a solution (within
given quality boundaries) that is a number of lines
longer or shorter than the optimal result. If such asolution exists it will be used; if not, then TEX will
try to match the request as closely as possible.
The paragraph will still be optimized (under the
new conditions), i.e., its overall gray level will be
fairly uniform, etc., but, inevitably, the inter-word
spacing will get looser or tighter in the process.
To activate this feature you need to set theparameter \looseness to the desired value. Thishas to be done directly in front of (or within) the
paragraph text via low-level TEX syntax\looseness=1% to lengthen by one line%
% <- no blank line here!
The text that gets manipulated ...
as there is no LATEX interface available.

Managing forlorn paragraph lines (a.k.a. widows and orphans) in LATEX250
TEX automatically resets the value to zero whenever a \par command or blank line is encountered;thus it will affect at most one paragraph.
A value of -1 has the best chance to work if thelast line is already nearly empty (and the paragraphis of reasonable length). Lengthening is somewhat
easier as inter-word spaces can stretch arbitrarily (aslong as they do not exceed the \tolerance), whereas
they can shrink by only a fixed amount. But again
there is a better chance for success if the last line isalready (nearly) filled.
So far so easy, but there are a few pitfalls thatneed to be avoided: First of all, with a positive valueof \looseness TEX will usually move only a single
word or even part of a single word into the last line, as
this way there is more material in the others and thus
less stretching of the inter-word spaces necessary. As
this usually looks rather ugly, it is best to tie the lastwords together by using ˜ and if necessary prevent
hyphenation of the last word by placing an \mboxaround it.
Secondly, lengthening of a paragraph may go
horribly wrong (as shown here) if the document is set
with a high \tolerance value, e.g., most definitely
when a \sloppy declaration is in force.
The \tolerance defines how bad a line canget while still being a candidate for the linebreaking algorithm and \sloppy (or sloppypar)
simply sets this tolerance nearly5 to infinity, i.e., arbitrarily bad lines are acceptable
and thus you might end up with a paragraph like this one (where we asked for two
extra lines and got them).
With a lower\tolerance value that would never have happened: TEX would have refused to produce a result
like this.
Seeing the previous paragraph you might ask
yourself why one would want to use a high, let alone
infinite, \tolerance at all. The reason is that thiscaters for situations where line breaking is very difficult. If there is a better solution with a lower
tolerance value TEX would use it, but if not it could
still proceed. So normally we wouldn’t see such badparagraphs even with a high tolerance in force (it justmeans that TEX evaluates more candidate solutions).
But if we apply \looseness we explicitly ask TEX
to deviate from the optimal number of lines and tofulfill this request TEX may resort to a solution withbad lines that nobody would want.
5 In the early days of L
ATEX \sloppy used to set the tolerance to 10000 (i.e., TEX’s infinity) but that tended to produce
even more bizarre looking paragraphs: TEX then made one line
really,reallybad
andallothersperfect,
as that looked to the optimizer to be the best solution.

Frank Mittelbach

TUGboat, Volume 39 (2018), No. 3
5

Identifying pages with widows ororphans

If the document class you use sets \widowpenalty
and \clubpenalty to 10000, then LATEX will automatically prevent widows and orphans, i.e., an orphan is forced to the top of the next page or column;
and the same with the line preceding a widow. The
downside, as discussed previously, is partly empty
pages and if space is a premium (for example, if
your conference paper is not allowed to be more thanX pages in total) then this is a possible problem.
Thus you are better off allowing widows and orphans(by changing the parameter values) and manuallycorrecting them in one way or another.
The question then becomes, how do you identify
the problematic page breaks without manually going
through the printout of your document and searchingfor them? While that is certainly an option it is error
prone and it would be much nicer if LATEX (even if
it can’t automatically resolve the issues for you) atleast identifies them so that you only have to checkthe problem pages.
This is possible by simply loading the package
widows-and-orphans.6 This package adjusts the parameter values slightly so that so that all possiblecombinations lead to distinctive numbers. For example, instead of the LATEX default values it would
choose\widowpenalty= 150\clubpenalty= 152\displaywidowpenalty = 50
\brokenpenalty= 101
so that it can distinguish between a widow and anorphan (\widowpenalty or \clubpenalty) or a display widow that comes together with a hyphen at the
break (\displaywidowpenalty + \brokenpenalty).
In case you wonder why 151 wasn’t used: that value
is already used by LATEX for \@medpenalty which
you get if you issue \nopagebreak[2]. By making
sure that all technically possible combinations leadto unique numbers it is only necessary to look at thepenalty of the page break to determine whether or
not that break exhibits one or more of the problems.
So at any page or column break the \outputpenalty
is inspected and depending on the findings a warningor error is generated that can then be checked andcorrected manually.
To ease this process further the package has
a number of key/value options. The check option
determines how findings are handled: the default
6 The implementation of the package (which is written in
the expl3 programming language) is documented in a separate
article in this TUGboat issue [9].

TUGboat, Volume 39 (2018), No. 3
is warning in which case warnings are written to
the terminal and the .log file. In the last phaseof document development you may want to changethat to error in which case the package will stop at
each problem with an error message rather than justa warning. In the opposite direction, info will not
clutter the terminal with messages and only writes
to the .log. And if you know for sure that all theremaining issues have to stay, you can also use thevalue none in which case no checks are done at all.
Why would one want the last option instead of
not loading the package? The reason is this: as the
package has to change the parameter settings slightly,
not loading it would mean running the documentwith different values and even though those changes
are minimal, it is possible to construct examples
where the difference matters and leads to changed
results. So once you have fixed what is possible tofix it’s safest to still load the package, even if you nolonger want the remaining warnings. Another reason
is that the package offers the command \WaOsetupthat allows you to change options mid-document, e.g.,turn the warnings off for chapters already handled,
but turn them on again for others.
Instead of suppressing all checking for a partof the document via \WaOsetup you can issue thecommand \WaOignorenext somewhere in the document, after which the next check — for the current
page or column — will be silenced. The check is still
performed and if no problems are found you will
receive an error message, because either you haveadded it to the wrong page or your text has changed
and it is no longer needed.
The package also offers options to set individual parameters to “reasonable” values. These are
widows, orphans, hyphens that all accept default(LATEX default), avoid (higher value but still possible) or prevent. And there are also the valuelessoptions default-all, avoid-all and prevent-all
to set all parameters in one go. Of course, as analternative one can always change the parameters
individually in the preamble or even in the middle ofthe document by assigning explicit numerical values.
If you want to see the resulting parameter settings (and the combinations that need to be uniquein order to allow the package to work) you can issue
the command \WaOparameters at any point after
the preamble, which will give you a somewhat terse
listing.
Answer to the riddle
The paragraph with negative tracking (−0.01 em) is
the first one after “I Rewriting a portion . . . ” onpage 248, toward the bottom of the first column.

251
Due to the tracking it needs one line less compared to the default line breaks. But as a resultof the tracking, the characters are noticeably closer
to each other, for example, in the word “obviously”.
Depending on your aesthetic judgment, a value of±0.02 em is roughly the borderline of what can beconsidered acceptable, so if that or a lower value
works, it might be an option.
References[1] Anonymous. Collins English dictionary —complete & unabridged 2012 digital edition.
https://www.collinsdictionary.com/
dictionary/english/club-line.
[2] Anonymous. The Chicago Manual of Style.
University of Chicago Press, Chicago, IL, USA,
14th edition, 1993.
[3] Anonymous. How can you create
pullquotes?, 2012. https://tex.
stackexchange.com/questions/45709/
how-do-you-create-pull-quotes.
[4] Anonymous. The Chicago Manual of Style.
University of Chicago Press, Chicago, IL, USA,
17th edition, 2017.
[5] Anonymous. Widows and orphans, 2017.
https://en.wikipedia.org/wiki/Widows_
and_orphans.
[6] Robert Bringhurst. The Elements ofTypographic Style. Hartley & Marks Publishers,
Point Roberts, WA, USA and Vancouver, BC,
Canada, 1992.
[7] Frank Mittelbach. A general framework for
globally optimized pagination. In Proceedingsof the 2016 ACM Symposium on Document
Engineering, DocEng ’16, pages 11–20, New
York, NY, USA, 2016. ACM. Downloadfrom https://www.latex-project.org/
publications.
[8] Frank Mittelbach. Effective floating
strategies. In Proceedings of the 2017 ACM
Symposium on Document Engineering,
DocEng ’17, pages 29–38, New York, NY,
USA, 2017. ACM. Download from https://www.latex-project.org/publications.
[9] Frank Mittelbach. The widows-and-orphans
package. TUGboat 39:3, 2018, 252–262.
https://ctan.org/pkg/widows-and-orphans Frank Mittelbach
Mainz, Germany
frank.mittelbach (at)latex-project dot org
https://www.latex-project.org

Managing forlorn paragraph lines (a.k.a. widows and orphans) in LATEX