[texhax] Checking the length of paragraph last line

Uwe Lück uwe.lueck at web.de
Sat Oct 15 18:14:49 CEST 2005

At 22:48 14.10.05, Robin Fairbairns wrote:
> > Fifteen or so years back, someone came up with a macro that would, in
> > effect, measure the last line of a paragraph so that you could decide
> > whether to put an identifying tag (like an author's name) in the white
> > space after a short final line or on the next line if the paragraph
> > final line stretched near the right margin.
>
>you don't mean the thing in the texbook, do you?  my copy's isolated
>from my by the stairs and the arthritis, but the source has
>
>\def\signed #1 (#2){{\unskip\nobreak\hfil\penalty50\hskip2em
>   \hbox{}\nobreak\hfil\sl#1\/ \rm(#2)
>   \parfillskip=0pt \finalhyphendemerits=0 \endgraf}}
>
>which he then uses as
>
>\begindisplay
>\vbox{\hsize 3.0in \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)}
>\enddisplay

Indeed, it's TeXbook p. 106, as I tried to contribute to the discussion
William mentions:

>>>
The problem is analogous to placing the author's name right-aligned
after a short text, which TeXbook p. 14 deals with. Accordingly, an
alternative would be something like

\newcommand*{\magicmacro}[1]{{%
\nobreak\hfil\null\nobreak\hfil#1\parfillskip=0pt\par}}
<<<

Strangely ... 14 is the number of the chapter, not the page.