In a question some time ago, I was trying to implement a wrapper around the \widowpenalties command in order provide an easier interface to limiting orphans and widows in LaTeX.
Thanks to Martin Scharrer’s answer, this question gave birth to a new package called nowidow, which is now available in TeXLive 2011.
Simple usage
To limit widows and orphans in your whole document, you can simply load the package with the all option. You can specify the default amount of minimal lines to be kept in the end (orphans) or beginning (widows) of pages (the default value is 2):
Fine tuning
If you wish to set a specific penalty for a given paragraph, the \nowidow (the subject of the original question) and \noclub macros will help you. They both take an optional argument to override the default value:
which will look ugly if I don't set<br />
a widow penalty to force 3 lines to appear<br />
on the next page.<br />
\nowidow[3]
The full documentation can be found on the CTAN.
Suggestions and bug reports are welcome!
Looks good, but sadly only version 0.2 without the
option is currently available with TeX Live 2011. At least “TeX Live Utility” claims that now newer version is available, where CTAN lists the version at 0.4
I’m aware of that @Alex. Version 0.4 is from 2 days ago and is not yet distributed in TeXLive. You can however download the package from CTAN directly (or even from github on https://github.com/raphink/nowidow) and install it locally.
Version 0.4 is not in TL2011.
Great solution. I wrote something on my blog about widows and orphans a few months ago, but it looks like I’ll need to update it. This is indeed user-friendly and easy to use.
Cool. I’m happy if it can be useful.
Thanks! It worked, and saved me a lot of time. But I did notice a side effect: it indeed makes the text height (I am using single column page, and text height means the total height/length of the text on a page) between different pages not quite balanced. E.g., on page 22 with a line moved to next page to fix a widow line, the text height is ~2 lines shorter than that in page 21.
Though I do not quite understand the mechanism used by nowidow package, I have an idea to potential improve the side effect:
a. When detecting orphan lines on beginning of current page, try to increase the line spacing (and try to keep text height similar to other pages) from previous page to move another line to current page.
b. Similarly, if detecting an orphan line at the end of current page, then increase the line spacing of current page to move the orphan line to next page. Or, really necessary, shrink the line spacing to move another line from next page. Again, try to keep text height not changed significantly.
Since I am not a tex guru, I am not sure whether my idea is feasible or not.
Thanks again for your work!
Hi Yaoguang,
The
package only maps on the internal widow/orphan functionalities of TeX. It does not have any intelligence of its own.