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.

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.

share|improve this question
    
IMHO you need to split on a baseline. –  Yiannis Lazarides Dec 16 '11 at 14:40
add comment

2 Answers

up vote 10 down vote accepted

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}%
  \vbadness=10000 \afterassignment\restorevbadness}
\def\restorevbadness{\vbadness=\currentvbadness\relax}

...
\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.

share|improve this answer
    
The choosen box register is only for the the example. –  Marco Daniel Dec 16 '11 at 14:54
add comment

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 specified dimen ; TEX will go through the original box register (which must contain a vertical box) to find 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.

share|improve this answer
    
+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
add comment

Your Answer

 
discard

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.