Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Please why does the following fail?

% \hss -> \hskip 0pt plus 1fil minus 1fil
\setbox0\hbox to 10mm{\hss\unhbox0\hss}

And what makes LaTeX's




The following schemes work

% Case 1
\setbox\boxb\hbox to 10mm{\hss\unhbox\boxa\hss}
x \box\boxb y


% Case 2
\setbox\boxb\hbox to 10mm{\hss\box\boxa\hss}
x \unhbox\boxb y

I just wonder why \unhbox\boxb gives an error in case 1. When precisely is \hss evaluated? Inside or outside the box?

TeX by Topic (Section 18.3.1) says that

\leftskip=0cm plus 0.5fil \rightskip=0cm minus 0.5fil

gives the error "infinite shrinkage..." But this doesn't seem to have a direct link with the issue in question.

share|improve this question
add comment

1 Answer

up vote 13 down vote accepted

What's happening in your sample code is that first, you create a box of 10mm width having some glue at both ends and a letter in the middle. The glue is set, within the box, so that the whole space is filled. Then you unbox it. The contents are emptied into the main horizontal list, and the glue is reset in that context. The error you are getting is

! Infinite glue shrinkage found in a paragraph.

which comes about when TeX starts trying to reset the infinitely-shrinkable \hss (this despite the fact that it only needs to expand, and you can see in the output that the letter a is indeed centered on its line).

The situation with your new example is exactly the same. If you place a whole box into a paragraph, then regardless of the glue in it, there will be no infinite shrinkage because the glue is already set in the box. If you unbox it, then the glue loses its dimensions and has to be reset, and its infinite shrink component gives an error.

Perhaps it is best to think of the situation as follows. Let . denote glue and let - denote set glue; i.e. actual space. I'll write an actual box with bars |. Then you have the following correspondence:

\hbox to 10cm {\hss a\hss} ---> \hbox to 10cm {.a.} ---> |---a---|

First the \hbox examines the horizontal list inside, which includes glue, and sets the length of that glue so that it fills the box, resulting in the last picture. Suppose that's the box stored in \box0. Then your example is:

\unhbox0 ---> \unhbox |---a---| ---> .a. ---> -----------a------------

You see, when the bars are removed, the -'s revert to .'s and have to be reinterpreted, leading to some different lengths, as shown at right. The problem is that even though those lengths are stretched, the glue itself has an infinite shrink component, and this is not allowed in a computation outside an \hbox.

share|improve this answer
The error is not mentioned in the TeXbook; module 825 in "TeX the program" talks about this. TeX by Topic says something in section 18.3.1. –  egreg Jul 7 '12 at 8:10
@egreg: Looking at texbytopic, it never occurred to me that you could have negative growth rather than shrinkage. –  Ryan Reich Jul 7 '12 at 8:21
The - revert to . and have to be reinterpreted. The reverse engineering of glue nodes is what seems to defy my logic. Why is the \unhbox\boxb not simply a directive that says put the \boxb here the way it was completed, as long as the box has been completed, even if that completion had glue nodes. Is every \unhbox an invitation to TeX to reverse engineer? If yes, then I rest my question. Moreover, I think no_shrink_error should have been no_shrink_warn, since no_shrink_error_yet prevents the error message from appearing twice? –  Ahmed Musa Jul 8 '12 at 9:16
@Ahmed in short, yes. But the only thing that TeX changes when unboxing is glue. As for the message, I don't know what Knuth had in mind. –  Ryan Reich Jul 8 '12 at 9:21
... twice in a paragraph. –  Ahmed Musa Jul 8 '12 at 9:22
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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