2 ms·
TeX treats the problems of (1) choosing line breaks to turn a stream of words into a stream of lines, and (2) choosing page breaks to turn a stream of lines int
by gjm11 4y ago
TeX treats the problems of (1) choosing line breaks to turn a stream of words into a stream of lines, and (2) choosing page breaks to turn a stream of lines into a stream of pages, separately; it does #1 and then #2. The Knuth-Plass algorithms addresses #1. I think #2 is done by simpler means; there is some support in it for penalizing widow and orphan lines, but no way for that to feed back to the line-breaking process.
In the common case where your pages are just text with a fixed spacing between lines, the only way for #2 to prevent widows and orphans is to make the page one line taller or shorter, making the margins look weird, which typically also gets penalized, and the only question is which penalty is larger. But if there are any variable spacings on the page, there will be the option of making them slightly larger or smaller in order to push a stray line from one page to another.