# How do I prevent widow/orphan lines?

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?

-

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
@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}
``````
-
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
@EmitTaste - Note the spelling of the package: it's `nowidow`, not `nowindow`. – Mico Nov 8 '14 at 16:32
I wish there was a `nowindows` package... – Ivan Kapitonov Nov 5 '15 at 8:49
@IvanKapitonov It's called GNU/Linux :-) – ℝaphink Nov 6 '15 at 20:13

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
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

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`).

-

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.

-
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