1

In The Elements of Typographical Style, the author notes (§2.4.8) that widows—single lines occurring at the top of a page—should be avoided. Yet the text height of two facing pages should be the same, and so a line should be removed from both pages in the spread (§2.4.9).

I assume that TeX has the ability to perform this kind of check. What solutions are possible (or already exist) to solve this general problem?

The same solution could be applied to orphans, though Robert Bringhurst does not seem to be so concerned about these.

lockstep
  • 250,273
Micah Walter
  • 452
  • 4
  • 15
  • Options include mostly adjusting penalties (see What are penalties and which ones are defined?. For example, \widowpenalty; however, this might not be perfect. I would suggest a manual adjustment during final production of the document, perhaps also fiddling around with \enlargethispage and/or \looseness (see Which choice of line-breaking parameters gives the minimum number of lines and Squeeze some more lines on the current page). – Werner Sep 18 '14 at 22:31
  • Note that in this type of book, I want to keep the distance between lines and paragraphs completely even. Manual adjustment is always a possibility, but this seems like the kind of task which can (and should) be automated. Perhaps it will need to come down to my writing a package! – Micah Walter Sep 18 '14 at 22:33
  • 1
    I think that TeX outputs page-by-page. So if the right page will be one line shorter to avoid a widow, I'm not sure there is any way for TeX to automatically adjust the left page. It might be different the other way around i.e. if TeX knows it had to shorten the left to avoid a widow, maybe you could then get it to adjust the right. But perhaps I am wrong about this? – cfr Sep 18 '14 at 22:43
  • 2
    PAge breaking is no-way that easy to automate. Certain relevant problems are proven to be NP-hard. So there is always a final-tweak phase and also strongly recommended. Here is more http://tex.stackexchange.com/questions/114292/why-no-vertical-mode-knuth-plass – percusse Sep 18 '14 at 22:44
  • Thanks for pointing me to the resources. I'm wondering, though, the conditions under which page-break optimization is NP-complete. Under ordinary conditions with only body text and perhaps section headings, a solution (or at least heuristics) should be possible. – Micah Walter Sep 18 '14 at 23:14
  • Also: I found this question about the issue on the [luatex] group. http://tug.org/pipermail/luatex/2012-October/003795.html – Micah Walter Sep 18 '14 at 23:23
  • @JohnPeyton: Although highly unlikely, it is possible to construct a document that requires infinitely many compilation cycles. If this cycling is associated with your optimization technique (of adding/removing a line on a page), then you might never be able to fully optimize the page... – Werner Sep 18 '14 at 23:47
  • @Werner: Yes! If exceptions like these are truly rare, we can make a note of this in the aux file and let the widow be printed rather than get caught in the cycle. – Micah Walter Sep 18 '14 at 23:49
  • @JohnPeyton: Good luck then! – Werner Sep 18 '14 at 23:50
  • 1
    They are not rare. With floats, the problem is really compicated. It's not merely a few checks whether remaning line number is 1 or not. You might need to give away the line breaking optimality etc. Espcially if you have nonbreakable things like display math etc. It is quite complicated before even you arrive to the core NP part. Off the top of my head, I had three pages in my thesis that never had proper page breaking. – percusse Sep 19 '14 at 00:06
  • @percusse I'm not considering texts with floats here. Presumably they can have their own system of avoiding widows, which would include stretchable space around the floats. – Micah Walter Sep 19 '14 at 13:41
  • Exceptions are more than the general case, you have one for floats, one for boxes one for math, one for inline math with different baselineskips, one for this and that, and you'll be overwhelmed with the spaghetti. I'm not trying to discourage you but as @Werner put good luck :) – percusse Sep 19 '14 at 13:46
  • if the material is your own, you have one option that hasn't been mentioned in other comments: rewrite. and your description sounds like you envision grid alignment, which introduces complications of its own, even if your document is "straight text", for example when you have facing pages, one with a section heading at the top, and the other with no section headings. i join in the good luck chorus. – barbara beeton Sep 19 '14 at 14:06

1 Answers1

1

Paul Isambert discusses a theoretical solution in TUGboat: Strategies against widows. This is his fourth and preferred solution to the problem. He provides example macros, which assume three passes, though does not provide a package.

Micah Walter
  • 452
  • 4
  • 15