Knuth-Plass: adjacent demerits on the first line
Don Hosek
don.hosek at gmail.com
Wed May 3 22:34:42 CEST 2023
>
> if I understand sections #859 and #864 in the KP algorithm correctly,
> TeX adds adjacent demerits to solutions for the /first/ line which are
> not in the decent fit class. That is because the root active node in
> #864 is initialized with a fitness of decent_fit, and there's no
> special-casing of the first line in #859.
>
> If this is correct, I find it weird to consider adjacent demerits for
> the first line, given that there is no previous line to actually compare
> with.
>
> Again, IIUC, doing this will favor paragraph solutions for which the
> first line is as close to natural spacing as possible. But what about
> the repercussions on the subsequent lines? Given the default values for
> adjacent demerits and hyphen penalties for example, it seems to me that
> it would be possible for the KP algorithm to prefer a paragraph solution
> with a decent first line over one with fewer hyphens.
>
> I couldn't find a rationale for this design decision anywhere, so I'm
> wondering if there is one, and if somebody actually knows about it.
>
>
Part of this comes down to the fact that the first line is at a
disadvantage compared to other lines in the paragraph¹ when it comes to
line breaking options since you can’t adjust previous lines to make the
line breaks better. This is part of why TeX has a tendency to let the first
line go overfull or have badness 10000 (depending on the \tolerance
setting).
-dh
⸻
1. The last line is usually less disadvantaged thanks to \parfillskip
making things much easier on the line breaking algorithm, although
non-standard settings for \parfillskip could come into play. These are rare
enough, though, that there’s no need for different treating.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://tug.org/pipermail/texhax/attachments/20230503/fe13b859/attachment.html>
More information about the texhax
mailing list.