8

In the end of Chapter14 of TeXbook, there is a macro called \signed:

\def\signed #1 (#2){{\unskip\nobreak\hfil\penalty50
  \hskip2em\hbox{}\nobreak\hfil\sl#1\/ \rm(#2)
  \parfillskip=0pt \finalhyphendemerits=0 \par}}

which is used to add the reviewer's name and address in the end of the review. And the \finalhyphendemerits=0 is used to prevent TeX from preferring two final lines to one final line.

I'm still quite confused about the functional of \finalhyphendemerits here. Does setting \finalhyphendemerits always help to make more white space to the last line?

Can someone give more explanations (better with an example) please?

2 Answers 2

9

Left with penalty set to 0 right with default

It is really just that simple: adds extra penalty if the second last line ends with a hyphen.

The left is \finalhyphendemerits=0, right is with the default 5000.

\hsize=2.9in
\finalhyphendemerits=0
But I must explain to you how all this mistaken idea of denouncing
pleasure and praising pain was born and I will give you a complete
account of the system.
\bye

Cite TeX by Topic

\finalhyphendemerits Penalty added when the penultimate line of a paragraph ends with a hyphen. Plain TEX default: 5000.

Note that in The TeXbook it says:

The one-line solution will usually be preferred if it is feasible.

Setting \finalhyphendemerits=0 helps the second last line to be more compact, making more space to the last line, thus makes the one-line version much likely to occur.

7
  • Does setting \finalhyphendemerits=0 make more space to the last line in all cases?
    – Stephen
    Commented Jul 1, 2023 at 8:04
  • @Stephen no, usually no difference (as no hyphen anyway) or it can make more or less space depending if hyphen is avoided by squeezing the word in to the penultmate line or taking the word over to the last line Commented Jul 1, 2023 at 8:33
  • 2
    I don't know what TeX by topic says, but the unit of \finalhyphendemerit is not TeX-penalty, but it is penalty square, marked as "demerit" in TeXbook.
    – wipet
    Commented Jul 1, 2023 at 10:39
  • @Stephen no, it really depends on the text content, and current width to see when finalhypendemerit would make a difference
    – LdBeth
    Commented Jul 1, 2023 at 15:50
  • @wipet penalties (and demerits) are just integers, although the formula does square penalty to compute demerit per line before add the extra demerit parameters, the choice of taking squares is only justified by practice, so TeX by Topics doesn’t trying to make a difference from the demerit and penalty other than stating penalty needs to be squared to have same weight as demerit
    – LdBeth
    Commented Jul 1, 2023 at 16:13
9

enter image description here

In a normal paragraph, with a short last line, a hyphen on the penultimate line appears as the last thing at the right margin and just has white space below it. This is normally discouraged by \finalhyphendemerits.

Here, the white space in the last line does not apply as the last line is always flush to the margin as seen by the extra example added. Worse if you do force a linebreak to avoid hypenation being on the penultmate line, you can have the opposite of the desired effect and force white space below the hyphen as seen here if the example is repeated without setting \finalhyphendemerits to zero.

\def\signed #1 (#2){{\unskip\nobreak\hfil\penalty50\hskip2em
  \hbox{}\nobreak\hfil\sl#1\/ \rm(#2)
  \parfillskip=0pt \finalhyphendemerits=0 \endgraf}}

\hbox{\vrule
\vbox{\hsize 3.6in \parindent0pt
  This is a case where the name and address fit in nicely with the review.
  \signed A. Reviewer (Ann Arbor, Mich.)
  \medskip
  But sometimes an extra line must be added. \signed N. Bourbaki (Paris)
  \medskip
  This is a case where the name and address fit most excellently with the review.
  \signed A. Reviewer (Ann Arbor, Mich.)
}\vrule}

\bigskip

\def\signed #1 (#2){{\unskip\nobreak\hfil\penalty50\hskip2em
  \hbox{}\nobreak\hfil\sl#1\/ \rm(#2)
  \parfillskip=0pt \endgraf}}

\hbox{\vrule
\vbox{\hsize 3.6in \parindent0pt
  This is a case where the name and address fit in nicely with the review.
  \signed A. Reviewer (Ann Arbor, Mich.)
  \medskip
  But sometimes an extra line must be added. \signed N. Bourbaki (Paris)
  \medskip
  This is a case where the name and address fit most excellently with the review.
  \signed A. Reviewer (Ann Arbor, Mich.)
}\vrule}

\bye

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .