At 2026-05-08T04:20:46-0300, Sebastien Peterson-Boudreau wrote:
> Recently, while writing a document, I noticed that groff hyphenated
> the last word of the last line of a paragraph. This looked very ugly,
> so I inserted a \% before the word to prevent it, but that made me
> realize this left a runt at the end of the paragraph. I was wondering:
> is this intentional by the hyphenation algorithm?

Yes.  There's no mechanism in any troff any I know of that penalizes or
assigns a score to this outcome.  (There _is_ one to prevent a
hyphenation break on a line before a vertical position trap; see the
`hy` request description.)

> Does it do this to avoid runts? Because I think leaving half of a word
> on the last line is worse than leaving an entire word on the last line
> :p (personally, I don't even find runts that bothersome... maybe I'm a
> bad typographer...)

I agree with you, but to the best of my knowledge no *roff is designed
to penalize such situations.  Automatic detection and prevention of this
outcome is one of the features touted of the Knuth-Plass algorithm
(K/P), which however is difficult to implement in GNU _troff_ (and I
assume other *roffs) because *roffs are designed around the principle of
formatting one output line, delivering it to the output device, and then
forgetting about it utterly.  Early *roffs were designed to work on
computers that were so resource-constrained that today we'd find them
fit only to serve as microcontrollers for elevators or microwave ovens.

To do K/P, the formatter has to keep an entire paragraph "in mind" at
once.  A breaking decision can propagate backward through its lines,
altering their adjustment and breaking to minimize their "badness".  I
don't know how K/P handles a paragraph that exceeds the page height.

Regards,
Branden

Attachment: signature.asc
Description: PGP signature

Reply via email to