3

The following example uses \signed macro from page 106 of TeXbook:

\tracingonline=1
\tracingparagraphs=1
\def\signed #1 (#2){{\unskip\nobreak\hfil\penalty50
  \hskip2em\hbox{}\nobreak\hfil\sl#1\/ \rm(#2)
  \parfillskip=0pt \finalhyphendemerits=0 \par}}
\hsize 3.0in \noindent
But sometimes an extra line must be added. \signed N. Bourbaki (Paris)
\bye

Tracing shows:

@firstpass
\tenrm But sometimes an extra line must be added. 
@\penalty via @@0 b=0 p=50 d=2600
@@1: line 1.2 t=2600 -> @@0
 [] \tensl N. 
@ via @@0 b=96 p=0 d=11236
@ via @@1 b=0 p=0 d=100
@@2: line 2.2 t=2700 -> @@1
@@3: line 1.3 t=11236 -> @@0
Bourbaki
@\kern via @@1 b=0 p=0 d=100
@@4: line 2.2 t=2700 -> @@1
 \tenrm (Paris)
@\par via @@1 b=0 p=-10000 d=100
@@5: line 2.2- t=2700 -> @@1

When empty hbox is removed, tracing shows

@firstpass
\tenrm But sometimes an extra line must be added. 
@\penalty via @@0 b=0 p=50 d=2600
@@1: line 1.2 t=2600 -> @@0
  \tensl N. 
@ via @@0 b=96 p=0 d=11236
@@2: line 1.3 t=11236 -> @@0

and then first pass fails. Why?

  • it's some way like if you replace \signed with \hskip2em. – touhami Jun 27 at 5:22
  • @touhami interestingly, if \signed is defined as \def\signed{\unskip\nobreak\hfil\penalty50 \hskip2em\hbox{}\nobreak\hfil}, first pass always succeeds – Igor Liferenko Jun 27 at 5:58
  • OK but this is not what i meant. What i mean is that as far as lines breaking is concerned you can get the same behaviour with \signed replaced with \hskip2em and with \hskip2em\hbox{} – touhami Jun 27 at 6:07
6

Glue and penalties are discardable, so without the box the entire

\nobreak\hfil\penalty50\hskip2em\nobreak\hfil

sequence is discardable

If the break happens at the p50 then you would have N Bourbarki (Paris) on the second line, so you get badness from stretching two word spaces to fill the line"

But actually it takes the break after N. as that is penalty 0 which in this case is enough to compensate that Bourbarki (Paris) has only one word space to stretch so more badness from that but no penalty at the break.

Conversely, the \hbox{} is non discardable so if the break is taken at the penalty50, the 2em glue is discarded and the \hbox{} ends up at the start of the next line with the glue expanding to flush the text to the right. (This is basically the difference between \hspace and \hspace* in latex)

  • So, without \hbox{}, if the author name is shorter than \hsize, break will never be done at any finite penalty? – Igor Liferenko Jun 27 at 8:42
  • I mean, is there any input where break will be done at penalty50? – Igor Liferenko Jun 27 at 8:44
  • @IgorLiferenko yes it's taken in your example, the break happens at the p50 and the 2em space is discarded, so on the second line you get an empty hbox and the hfill – David Carlisle Jun 27 at 8:52
  • I'm asking about the case without \hbox{}. – Igor Liferenko Jun 27 at 9:00
  • @IgorLiferenko sorry, first answer was basically wrong. I hope this one is better – David Carlisle Jun 27 at 10:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.