Debunking a myth: Knuth-Plass as a silver bullet for widow/orphan management

"G. Branden Robinson" <[email protected]>
Newsgroups gmane.comp.printing.groff.general
Message-ID <20260807015854.olo6wuzbuwgza4eu@illithid>
Hi folks,

So there I was, reading the C++ paper P3846r0, not thinking anything
about typography, when I happened upon some exhibits that overturned an
understanding I had that critics of groff have promoted relentlessly.

That misunderstanding, informed more by crowing fanboys of alternative
systems--often ones expressing an animus against the GNU Project and/or
copyleft licensing--is that, if one's typesetter employs the Knuth-Plass
algorithm for breaking lines within paragraphs, one need never worry
about managing widows and orphans...or "stranded lines", as I term them,
since the meanings of "widow" and "orphan" are contested.[1]

I give you the P3846 paper, which looks for all the world like it was
formatted with TeX.  An assumption: I didn't contact the authors to ask
for their document's source.[2]  TeX, of course, employs Knuth-Plass.

See attached screenshots.  You can find the 700 kB PDF here.

https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3846r0.pdf

My discovery is not novel.  I think Peter Schaffter and/or Doug McIlroy
have taken note of this before, and concrete exhibits of what we might
call "evidence" are received indifferently by software partisans.

But one can sometimes, briefly, shut them up (or down) in a given
discussion.  Eventually, some become concerned for their reputational
integrity, or tactically withdraw a favorite fairy story from certain
forums where they know they'll be convincingly gainsaid.

I share this observation to get it on the record, into the mailing list
archives, and provide ammunition to others who prefer facts to BS when
conducting arguments regarding empirically observable phenomena.

So how do you use groff to solve problems like those depicted?

1.  If your full-service macro package supports "keep" macros or
    "display" macros that implicitly keep their contents, and all of
    groff's except for man(7) and mdoc(7) do, use those macros.

2.  You can employ what I call "poor man's keeps".

    2a.  If the first line of a paragraph threatens to strand, use this
         pattern:

         .br
         .ne 2v
         .\" paragraphing macro goes here
         It follows that if the compiler does not know exactly how the
         body of a function will be compiled, it cannot depend on any
         property of that function not fully specified by the C++
         Standard or the ABI.

    2b.  If the last line of a paragraph threatens to strand, use this
         pattern:

         In response, [P3261R2] presented a comprehensive analysis of
         possible
         .ne 2v
         approaches, addressing in detail the concerns now reiterated in
         [P3851R0].
         Following extensive discussion, both SG21 and EWG reaffirmed
         consensus in favour of const-ification.

    2c.  If the paragraph sets in three lines exactly, any division
         across a page break would strand a line.  Use this pattern.

         .br
         .ne 3v
         .\" paragraphing macro goes here
         Sed ut perspiciatis, unde omnis iste natus error sit voluptatem
         accusantium doloremque laudantium, totam rem aperiam eaque
         ipsa, quae ab illo inventore veritatis et quasi architecto.

The utility of the foregoing technique is high only when the output line
length is predictable.  That's usually true for typeset documents; most
are set in portrait mode on U.S. letter or ISO A4 paper formats, which
are themselves of similar dimensions.

When rendering a document to a terminal, line length is a much less
predictable matter, though ergonomic factors tug documents toward the
"standard" terminal width of 80 columns.  Nevertheless, some hackers
have trained themselves to scan very long lines.  But on the gripping
hand, most of the time, any *roff document that a hacker reads in a
terminal is likely to be a man page.  Since both groff(1) and mandoc(1)
employ "continuous rendering" for these by default, the stranded line
problem does not arise.  But should the problem nag for typeset man
pages, or should pagination come back into vogue for man pages read at
the terminal, my proposal for adding `KS`/`KE` macros to man(7) awaits
your support.[3]  (I might end up implementing it on my own initiative
if I ever get too frustrated fixing stranded lines in our typeset
groff-man-pages.pdf document.)

Regards,
Branden

[1] https://en.wikipedia.org/wiki/Widows_and_orphans#Definitions

[2] I suspect one can fool 99% of people, including TeX partisans
    performing gatekeeping of document formats but who review only
    rendered PDFs, by using "groff -T dvi" and then dvi2pdf(1).  See
    attached PDF.

[3] https://lists.gnu.org/archive/html/groff/2022-12/msg00075.html
knuth-plass_no_silver_bullet_1.png (image/png, 225.7 KB) - not displayed
knuth-plass_no_silver_bullet_2.png (image/png, 229.1 KB) - not displayed
grodvi.1.pdf (application/pdf, 67.3 KB) - not displayed
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEh3PWHWjjDgcrENwa0Z6cfXEmbc4FAmp1O9YACgkQ0Z6cfXEm
bc4DRQ//SvgohES8/36ViFlSjOlrcmdyHaVLow6NIIypj1LbicFYMMHDeT+Vmkq1
yQTpX6LmJxOD18qMd8TsNQxsTdOUm3Ay/0dtjqOZ7/Id0S5CKkN5iIpHCyEeg3SY
o4mw4mrkayMpYVlaYHEZtebdSD4R9+b1TCZzILLPD5r6ZHJhc6MQNLh8Rc+gapZ1
JUnFHDeF5NLN5V/0DQlD/T/VVfYNVcpOb6bKintwd1ancCZ3uNeL14c+QbQn1HIn
26nnEHODJfqPc1YofxzqUtUXfm5L+O0zCIK5NAuDCWJD38SyPAbaGUQgS0fiH6Ua
apf42Utty/zIuFKkTIR+j1Yw4F9I2DrtSIN2BuNTx/s98eHzx44XG4SMc+GMyJhl
qmh0dZ4KES+m2Sv71I4JLeP+wyOiU30SA1HJFYjCI1mosS7cXmlBcetNisLA4ugo
xHhBDrknqUsiaCIlEKIB+Yuo1cI94z/4yZwd7wKkx2Wcc7w3O73pcPwriyQ4m/f2
60JehJWUehQ5GLADKW1fAueR7K4WWlLK5+414zs2yEQR6hD8W3y5aYEiP36/w0bm
pH05QJ74nzD4njaQMzTKXsbZOEf640Py7G+blH2v66RViUyJBQu9SLZd3r8cYupv
FSXGejh8HT3J6QG26A2oEpXtCUvobJo0t9FEAlOIqAar2pPH6Hw=
=nXtz
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.