widow/orphan control 

Newsgroups: comp.text.tex
Date: 1995/08/31
> I was wondering if a widow/orphan control packages existed in LaTeX.

I don't know about packages, but you could put the following line \widowpenalty=1000 \clubpenalty=1000 in a file and call it a package. That one just makes such lines quite unlikely. Here's another package which should make them impossible: \widowpenalty=10000 \clubpenalty=10000

As a general rule, I wouldn't use a value higher than 1000 or 2000 for a penaly of this sort, since TeX's page making algorithm gets a little frantic when the penalties start getting high. Also, leaving the first line of a paragraph at the bottom of a page (many people call this a widow line) is not as bad as having the last line of a paragraph at the top of a page (many people also call this a widow line — the terminology is not standardised), so you may want to make the \clubpenalty smaller.

Patrick TJ McPhee

widow/orphan control 

Date: 1996/05/07
> LaTeX/TeX insist on putting countless widows and orphans in my
> document. How can I make it favor shorter pages and stop this?

You can try increasing the \widowpenalty (and perhaps the \displaywidow- penalty) parameters. These are penalties assessed for breaking a page so that only one line of a paragraph appears on the top of the next page. (\displaywidowpenalty is used if there's a display just after the single line.) There's also \clubpenalty, the penalty for leaving breaking after the first line of a paragraph.

Both Plain and LaTeX set \clubpenalty and \widowpenalty to 150 and \displaywidowpenalty to 50. These are fairly small values, discouraging those breakpoints but not at the expense of otherwise distorting the page.

In my experience, unless you use \flushbottom, most pages have enough stretchability that widows and club lines are rares - it's easy to break elsewhere, so TeX has little reason to "pay the penalty". Once you request that all pages be exactly the same length, however, TeX's job becomes considerably harder. Usually, the reason TeX creates a club line or orphan is that there really is no good solution without it - as forcing a break where you think it should go will quickly demonstrate in the form of an underful vbox (the whole page). In my dissertation, which I decided to set \flushbottom, I ended up having to "touch up" perhaps 10% of the pages to avoid widows, club lines, or underful vboxes. (The final document runs through LaTeX in \flushbottom and \fussy modes with no warnings.) "Touching up" can often be done by playing with \looseness; sometimes, however, I had to re-word the text a bit. It's of course also possible to deliberately lengthen or shorten a problem page - there's a style file that lets you do that, something like "longpage".

I would not expect a completely automatic solution. Increasing the penalties for widows and club lines will simply move the difficulty elsewhere. A truely automatic solution would require at least the ability to typeset groups of pages, rather than TeX's current page-at- a-time optimization, and might require an automatic ability to feed back page breaking information into the paragraph builder - a kind of automatic looseness. I suppose we might see the former in E-TeX, but I wouldn't bet on the latter being practical.

Jerry

widow/orphan control 

> Hi. I vaguely recall from a long, long time ago a way to tell LaTeX (or
> maybe TeX) that I wanted the following n lines to be on the same page. Can't

Three ways to ensure enough space left on page:

\def\need#1{vskip0pt plus #1 \penalty-60 \vskip 0pt plus-#1\relax}

Unfortunately, this grabs only an approximate space, and the exact amount depends on the usual "badness" of a normal break. One way to ensure getting the right space is to eliminate the badness of ordinary breaks:

\raggedbottom \topskip 1\topskip plus1000pt % like \raggedbottom; moreso \def\need#1{vskip #1\penalty0 \vskip-#1\relax}

Which works OK, if you don't mind raggedbottom pages…very ragged.

Finally, there is another method that works very well, as long as you use it between paragraphs (i.e., not in a \vadjust{}) and not with multicol.sty:

\def\need#1{\par \penalty-100 \begingroup % preserve \dimen@
  \dimen@\pagegoal \advance\dimen@-\pagetotal % space left
  \ifdim #1>\dimen@ % not enough space left
%    only do \vfil if some space left on page
     \ifdim\dimen@>\z@ \vskip -\pagedepth plus 1fil \fi
     \break
  \fi \endgroup}

Somebody put something similar in a package recently.

Donald Arseneau

widow/orphan control 

> Could you show me how to include this in a plain TeX
> file? I.e., \dimen@ and \z@ are causing errors. Is there
> an implied definition somewhere, e.g., \newdimen\dimen@,
> \newdimen\z@?
> Also, I would like to use the idea without changing
> catcodes of @.
  1. change the catcode of @ to 11 ( \catcode`@=11 )
  2. look up \dimen@ in the TeXbook, and/or replace it by \dimen0, or 0pt

David Kastrup