# Output routine and \box255

The \box255 referred to in this question applies only to the container of the latest chunk of the MVL, as cut by the page builder. Now the question: I read somewhere that

\setbox0=\vbox to \vsize{\unvbox255}


may yield an underfull box error even when \box0 has the same height as \box255. The apparent remedy, which seems to be

\setbox0=\vbox to \vsize{\unvbox255\vfill}


doesn’t solve the problem: it may give an overfull box. Is there any reason why underfull and overfull \box255 aren’t reported? The TeX Book, page 400, simply said nothing is reported in this case. Is it only so that a page may be ejected prematurely?

-
"When \box255 is packaged for use by the output routine", not "whenever \box255 is used". When TeX calls the output routine, it packages up \box255 and it's this the moment when over or underfull boxes are not reported. – egreg Jun 1 '12 at 6:35
@lockstep: Please I can't see what you've edited. Can you please add a comment? – Ahmed Musa Jun 1 '12 at 6:38
@egreg: Yes, that is indeed the question. I have edited my question. – Ahmed Musa Jun 1 '12 at 6:45
If the box resulting from \setbox0=\vbox to \vsize{\unvbox255\vfill} is overfull or underfull, TeX will of course report the fact. – egreg Jun 1 '12 at 6:52
I only added some tags. – lockstep Jun 1 '12 at 6:56

TeX makes the assumption that the material that the page builder packages in box 255 is further processed by the output routine before it is either finally shipped out (via \shipout) or returned to the main vertical galley.

It therefore doesn't make much sense to issue a warning for underfull or overfull boxes at that point if the assumption is that the output routine will anyway unbox this material and attach running header and footers etc. As during that process you will get those warnings again.

Furthermore, Don Knuth does give a reason on page 400 why TeX keeps silent at this point:

Sometimes an output routine needs to know why it was invoked, so there's a problem of communicating information from the rest of the program. \TeX\ provides general |\mark| operations, but marks don't always yield the right sorts of clues. Then there's ^|\outputpenalty|, which can be tested to see what penalty occurred at a breakpoint; any penalty of $-10000$, $-10001$, $-10002$, or less, forces the output routine to act, hence different penalty values can be used to pass different messages. \ (When the output routine puts material back on the list of contributions, it need not restore the penalty at the breakpoint.) \ If output has been forced by a highly negative value of/ |\outputpenalty|, the output routine can use |\vbox{\unvcopy255}| to discover how full the page-so-far actually is. Underfull and overfull boxes are not reported when |\box255| is packaged for use by the output routine, so there's no harm in ejecting a page prematurely if you want to pass a signal.

This is, for example what LaTeX is using all the time to manage float material and if that would result in a huge number of spurious warnings otherwise.

Concerning the fact that you might even get "overfull" box messages if you rebox 255: In a few cases when there are no legal pages breaks earlier, 255 might in fact contain more than its nominal height. In addition one should not forget that reboxing involves parameters like \boxmaxdepth and depending on their setting the final size might vary.

-
Thanks. Both answers are equally valuable, but only one can be accepted. Please can you possibly give example messages that explain the statement "hence different penalty values can be used to pass different messages"? – Ahmed Musa Jun 1 '12 at 22:55
Any value smaller than -9999 is an unconditional break that will trigger the output routine. LaTeX, for example, uses -10001 to -10004 to indicate that a certain float situation came up. E.g., -10001 is used by \clearpage to tell the output routine to ship out dangling floats. As you can see from the quote above it is a trick already thought of by Don Knuth. – Frank Mittelbach Jun 2 '12 at 6:07

There is nothing very different about box255 here, you can see a similar effect with normal boxes.

\setbox2\vbox{\hbox{}}
\ht2=\vsize

\setbox0=\vbox to \vsize{\copy2}

\setbox0=\vbox to \vsize{\unvbox2}

\bye


The above produces

\$ pdftex ufb
This is pdfTeX, Version 3.1415926-2.3-1.40.12 (TeX Live 2011/Cygwin)
restricted \write18 enabled.
entering extended mode
(./ufb.tex
Underfull \vbox (badness 10000) detected at line 9
)
(see the transcript file for additional information)
No pages of output.
Transcript written on ufb.log.


Note how copying the box does not generate underful message but unboxing it does because then the (0 sized) contents are used but the artificially sized height \vsize of the box is lost in the unboxing process. The behaviour of the output routine when packing box 255 is similar, if you unbox 255 you get the natural height of its contents which may not be \vsize.

-