At 2026-05-08T06:18:41-0300, Sebastien Peterson-Boudreau wrote: > Of course, it would be best if we could adjust spacing across the > entire paragraph to prevent runts, but what about just putting the > last word of the paragraph on the last line by itself if it would be > hyphenated (choosing a full runt over a half runt) -- perhaps this > would require keeping _two_ lines in memory at once (one to format, > and one to know if we're at the end of the paragraph?), which is still > too much for roff...
Have you experimented with other hyphenation control parameters?
I wonder if GNU troff's `hym` or `hys` might get you what you need, at
least in the particular case(s) that motivated you to write.
If not, then a development possibility may exist.
I'm a little nervous about making our hyphenation breaking algorithm
even more complex,[1] but I don't think we need two lines of memory to
solve this problem. Or, from a different perspective, we already have
those "two lines" in memory because we have:
* the pending output line
and
* a configured line length
The way breaking _already works_ is that a break happens if the length
of the pending output line exceeds the configured line length.
I _think_ we also already know one more thing:
* whether there's a "hard" break at the end of the word that must be
broken at the line length; in other words, whether we'd adjust the
pending output line after breaking it or not
Put differently yet another way, we know whether the word that must be
broken at the line length ends the paragraph or not. If we didn't know
that, either we'd never adjust lines at all in the absence of `\p` or
`.brp`, or we'd also always adjust the final line of any paragraph with
more than one word on it (and, as of groff 1.24, emit a warning in
category "break" about an underset line).
So what I think we could change GNU troff to do is, if hyphenation is
enabled and the line length bisects a word, check to see if that word is
a "runt"--the last one in a paragraph. If it's not a runt, do what we
already do. If it _is_ a runt, suppress its hyphenation.
This could be made more complicated, for instance by considering runt
words with multiple hyphenation break points in them and progressively
"backing up over them" until some satisfactory threshold is reached.
But for a first attempt, I'd want to try the simplest approach and see
how many people's problems are solved by it.
I should also add that this alteration to the algorithm might just trade
one kind of ugliness for another.
Here's a meatspace simulation.
Before:
Sed ut perspiciatis, unde omnis iste natus error sit voluptatem accusan-
tium doloremque laudantium, totam rem aperiam eaque ipsa, quae ab illo
inventore veritatis et quasi architecto beatae vitae dicta sunt, explic-
abo.
After:
Sed ut perspiciatis, unde omnis iste natus error sit voluptatem accusan-
tium doloremque laudantium, totam rem aperiam eaque ipsa, quae ab illo
inventore veritatis et quasi architecto beatae vitae dicta sunt,
explicabo.
Here we see significantly more spreading on the third line than before.
I admit that this precise case isn't shockingly bad, but there
inevitably will be cases that are. It's more likely when the line
length is a smaller multiple of the average word length, as when laying
out the page with multiple columns.
Anyway, if we did add this feature, it should of course be configurable
on demand. For symmetry with existing features, probably a new request
and a new read-only register of the same name, prefixed with a dot.
I'm not enamored of it as a final name, but for the time being we might
call this the "hyrunt gambit". (Why "gambit"? Because I don't know
that it would remove more typographical ugliness than it creates.)
Regards,
Branden
[1] Once again cgit.git.savannah.gnu.org is unresponsive, so I'm linking
to The Man.
https://github.com/GitMirroring/groff/blob/103561eaea6a149993276df00801665eea855583/src/roff/troff/env.cpp#L2275
https://github.com/GitMirroring/groff/blob/103561eaea6a149993276df00801665eea855583/src/roff/troff/env.cpp#L2153
https://github.com/GitMirroring/groff/blob/103561eaea6a149993276df00801665eea855583/src/roff/troff/env.cpp#L2051
signature.asc
Description: PGP signature
