Knuth-Plass: adjacent demerits on the first line

Jonathan Fine jfine2358 at gmail.com
Wed May 3 17:18:48 CEST 2023


Hi Didier

Thank you for your attention to detail. You ask a good question.

Exercise 14.12 of The TeXBook  gives an example of a demerits calculation
for the first line (of story.tex at \hsize 2.5in and \tolerance 1000).

Reading the solution, it seems clear to me that Don Knuth was aware of this
behaviour.

The K-P algorithm will indeed "favor paragraph solutions for which the
first line is as close to natural spacing as possible", but only when all
other things are equal.

For those that don't already know, the K-P algorithm uses dynamic
programming, so no decision regarding the first line until the end of the
paragraph. This allows TeX to typeset paragraphs as well as reasonably
possible, even if the \parfillskip at the end is zero.

Here's an article on https://en.wikipedia.org/wiki/Dynamic_programming.

I hope this helps you. I think there's more to be said, before all becomes
clear.

best regards

Jonathan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://tug.org/pipermail/texhax/attachments/20230503/95d631af/attachment.html>


More information about the texhax mailing list.