# How to avoid underfull vbox in combination with \vsplit?

In the following example I am using the command \vsplit. I can't see the reason why \vsplit produced an overfull \vbox

\documentclass{article}
\parindent0pt
\def\exampletext{Text Text Text Text Text Text Text Text Text Text Text Text
Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text
Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text }
\fboxsep=0pt
\fboxrule=1pt
\hfuzz=\maxdimen
\begin{document}
\setbox1=\vbox{
\hsize=8cm
\bfseries\huge\exampletext}
\boxmaxdepth0pt
\setbox0\vsplit1to2cm
\setbox0=\vbox{\unvbox0}
\fbox{\box0}

\fbox{\box1}
\end{document}


I used \hfuzz=\maxdimen to avoid overfull hbox in this example.

-
IMHO you need to split on a baseline. –  Yiannis Lazarides Dec 16 '11 at 14:40

You get the Underfull \vbox message when TeX is doing the \vsplit: it wants to build a \vbox to 2cm, but it has to use a break point that doesn't produce a 2 cm high box. You correctly do \setbox0=\vbox{\unvbox0}, but the underfull box has already been produced.

\def\silencewarning{\edef\currentvbadness{\the\vbadness}%

...
\silencewarning
\setbox0\vsplit1to2cm
...


This will tell TeX not to warn for the underfull box, but do the same computations as before. If your computations are performed in a group, then set \vbadness to 10000 (or \@M, which is the same) and forget about it.

Note. Box registers 1, 3, 5, 7 and 9 should be used only for global assignments. Not every package conforms to this recommendation, however.

-
The choosen box register is only for the the example. –  Marco Daniel Dec 16 '11 at 14:54

It should result in an underfull vbox instead of an overfull one. TeX by topic has this to say about \vsplit:

The extracted result of \vsplit 8-bit number to dimen is a box with the following properties.

Height equal to the speciﬁed dimen ; TEX will go through the original box register (which must contain a vertical box) to ﬁnd the best breakpoint. This may result in an underfull box. ...

If I understand this correctly, it means that TeX breaks earlier than the 2cm you specify, resulting in an underfull vbox. You would have to use the exact height of x lines to not get the underfull vbox warning. For instance, if we use \ht1 instead of 2cm as the dimen, no warning is generated. Because, again according to TeX by topic:

The bottom of the original box is always a valid breakpoint for the \vsplit operation. If this breakpoint is taken, the remainder box register is void.

-
+1 I accepted the answer of egreg because I need a fix height. Thanks for the response. –  Marco Daniel Dec 16 '11 at 15:11