How do I prevent a line from appearing by itself:

Orphan: at the bottom of the page, or
Widow: at the top of the page?

  • there's a new (better) answer. Perhaps you want to reconsider? – Ooker Dec 13 '17 at 13:37
up vote 54 down vote accepted

As Brent points out, you cannot always do this. The best you can do is to tell TeX that it's infinitely bad for these to appear:

\widowpenalty10000
\clubpenalty10000

One thing to keep in mind is that when presented with multiple infinitely bad options, TeX just picks one of them so you can still get widows or orphans.

  • I looked up somewhere else and they had \widowpenalty=10000. It didn't work then. Thanks! :) – Kit Oct 16 '10 at 1:30
  • 10
    @Kit (it's a late comment, but anyway) You don't need the = in the assignment, but it doesn't hurt. \widowpenalty=10000 and \widowpenalty 10000 are the same. – topskip Oct 4 '11 at 8:38

You can now use the nowidow package to make this task easier:

\usepackage[all]{nowidow}
  • 2
    Where do I find nowindow.sty, I don't seem to have it in my standard (Mac) TeX install... Thanks – Emit Taste Oct 25 '13 at 9:03
  • 9
    @EmitTaste - Note the spelling of the package: it's nowidow, not nowindow. – Mico Nov 8 '14 at 16:32
  • Does it also take care of orphans? – Raffi Khatchadourian Oct 11 '17 at 13:52
  • 1
    @RaffiKhatchadourian yes, it does. See the docs (in particular the \noclub and \setnoclub commands). – ℝaphink Oct 12 '17 at 14:53

The Memoir manual, in section 3.5 "Sloppybottom" discusses this in some detail, which I won't reproduce here.

Be prepared even to re-word in the most intractable cases.


Update:

I think the specific commands like \enlargethispage and \sloppybottom are exclusively for the memoir package, but here's a snippet extracted from the aforementioned that you may care to adjust (you can see the extensive comments in the original):

\clubpenalty=9996
\widowpenalty=9999
\brokenpenalty=4991
\predisplaypenalty=10000
\postdisplaypenalty=1549
\displaywidowpenalty=1602

Personally, I tend to avoid this TinXering with Plain TeX internals; although I don't know how to do it specifically for newlfm, I'd probably opt for adjusting the textheight on a case-by-case basis, as a final tidy-up before publishing.

  • I'm using newlfm. Is this applicable, too? – Kit Oct 16 '10 at 1:18
  • 7
    while \sloppybottom is indeed memoir-specific (\raggedbottom is the comparable "plain" command), \enlargethispage is defined in base latex, so should be usable with any document class. – barbara beeton Sep 27 '11 at 13:27
  • I'm using KOMA Script, do you recommend to use those values there? – Aradnix Oct 27 '17 at 22:14
  • 1
    @Aradnix I can't say I'd recommend it, but it's certainly with a try (:-) – Brent.Longborough Oct 27 '17 at 23:28
  • I did it but also I need to increase the div value and adjust the BCOR (binding correction) factor for avoid the widow lines. Thanks. – Aradnix Oct 30 '17 at 20:22

This FAQ answer gives some tips, including enlarging/reducing the (double-)page, setting the paragraph tighter, using \raggedbottom (for which, see also this FAQ answer which discusses putting some stretch in the \topskip).

Sometimes, even with all of the suggestions above, you end up with an odd looking page, something without an apparent solution if you are not at the liberty of rewording the text. For those instances, I have developed a simple command, Kern, which allows to increase or decrease character tracking by fractions of a point.

% Kern
% #1 kerning amount
% #2 text
\newcommand{\Kern}[2]{\addfontfeature{LetterSpace=#1}#2\addfontfeature{LetterSpace=0}\null}%

So if you have some text, you would decrease tracking thus:

\Kern{-1.0}{Sometimes, even with all of the suggestions above, 
you end up with an odd looking page, something without an apparent
solution if you are not at the liberty of rewording the text.}

And, conversely, increase tracking thus:

\Kern{+1.0}{Sometimes, even with all of the suggestions above, 
you end up with an odd looking page, something without an apparent
solution if you are not at the liberty of rewording the text.}

Following up Nico's comment, this solution works with XeLaTeX and LuaLaTex only, and you need to have fontspec loaded.

  • You may want to make an explicit mention of the fact that this approach can only be employed if (a) the document is compiled with either XeLaTeX or LuaLaTeX and (b) if the fontspec package is loaded. It would also be helpful if you gave a couple of examples of how to use \Kern{...}{...}. – Mico Apr 29 at 19:46

I'd been using the 10000 penalty for years (since 2005). This morning I learned the default was 150, and 500 was pretty aggressive. When I dropped from 10000 to 500, the widow/orphan lines went up (from 2 to 3). When I left it at default, the typical widow/orphan lines went toward 4...and new sections were more frequently shoved to the next page.

Now it looks the way I wanted to.

  • 5
    This reads more like a comment than a standalone answer. Please consider augmenting a posting a bit, e.g., to provide specific, tangible examples of what you mean by "the widow/orphan lines went up (from 2 to 3)." To make such a statement usable, one needs to know things such how many lines per page you have, the average length of your paragraphs, and if the widows/orphans appear in short or long paragraphs. – Mico Nov 8 '14 at 16:35
  • Sorry about that. I am specifically referring to a 6"x9" novel format. I target 39 lines-per-page. When I used the 10000 penalty, I would find frequent paragraphs (out of a 230-page novel) that had 2 line widows or orphans. By stepping down to the default (150) "fixed" it to 4 lines. The specific paragraph lengths of the work in question was closer to 8-10 lines per paragraph. So, instead of having 1 or 2 lines on one page and the balance on the other, the split was more amicable. Does that help? – Merovech Nov 9 '14 at 18:31

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.