[Tex/LaTex] Underfull \vbox – how to find offending page

vertical alignmentwarnings

I am compiling a large latex template, here, and always have a few underfull \vbox warnings.
I know that they're just issues with the spacing, discussion here, but is there a way to configure the warning message to tell me where the problem occurs?

That way I can easily find the problem pages, in both the PDF and the source, and decide if I need to fix it.

Best Answer

Most commonly under- and overfull \vboxes are associated with pages that don't have enough or too much content on them (as they are constructed as a vertical list of boxes). So, at the page-level, you can find the offending construction by looking at your log. Here's a quick example:

\documentclass{article}
\usepackage{lipsum}
\tracingpages1
\tracingoutput1
\begin{document}

\lipsum[1-50]
\noindent\rule{\textwidth}{1.1\textheight}
\lipsum[1-50]

\end{document}

The above code contains some dummy text followed by a single "paragraph" that is clearly bigger (vertically) than the text block (has a height of 10% more than \textheight). It also includes some tracing commands used for debugging. The .log shows

%% goal height=550.0, max depth=5.0
% t=10.0 g=550.0 b=10000 p=0 c=100000#
% t=22.0 g=550.0 b=10000 p=150 c=100000#
% t=34.0 g=550.0 b=10000 p=0 c=100000#
% t=46.0 plus 1.0 g=550.0 b=10000 p=250 c=100000#
% t=58.0 plus 1.0 g=550.0 b=10000 p=0 c=100000#
% t=70.0 plus 1.0 g=550.0 b=10000 p=0 c=100000#
% t=82.0 plus 1.0 g=550.0 b=10000 p=0 c=100000#
% t=94.0 plus 1.0 g=550.0 b=10000 p=0 c=100000#
% t=106.0 plus 1.0 g=550.0 b=10000 p=150 c=100000#
% t=118.0 plus 1.0 g=550.0 b=10000 p=0 c=100000#
% t=725.9478 plus 2.0 g=550.0 b=* p=150 c=*


Completed box being shipped out [10] []

%% goal height=550.0, max depth=5.0
% t=605.00336 g=550.0 b=* p=150 c=*#

Overfull \vbox (55.00336pt too high) has occurred while \output is active []



Completed box being shipped out [11] []

which we interpret as page [10] and being shipped out without problem. Then, after page [10] an Overfull \vbox occurred. Most likely this box is associated with page [11] as page [10] was already shipped out before this message occurred. Tracking the page construction of page [10] is not all that "user-friendly", as Knuth says himself. However, we use the following interpretation from the TeXBook (Chapter 15: How TeX Makes Lines into Pages, p 112):

The first line, which starts with %% is written when the first box or insertion enters the current page list; it shows the goal height and the max depth that will be used for that page (namely, the current values of \vsize and \maxdepth). [...] dimensions in the log file are always displayed in points.

The subsequent lines, which start with a single %, are written whenever a legal breakpoint is being moved from the list of recent contributions to the current page list. Every % line shows t, which is the total height so far if a page break were to occur, and g, which is the goal height; in this example g stays fixed [...], but g would have decreased if insertions such as footnotes had occurred on the page. The values of t are steadily increasing from 10 to 22 to 34, etc.; baselines are 12pt apart at the top of the page and 11pt apart at the bottom (where material is set in nine-point type).

We are essentially seeing one % line per hbox of text being placed on the current page. However, the % lines are generated by the penalty or glue items that follow the hboxes, not by the boxes themselves. Each % line shows also the badness b, the penalty p, and the cost c associated with a breakpoint; if this cost is the best so far, it is marked with a # sign, meaning that "this breakpoint will be used for the current page if nothing better comes along." [Wherever you have a badness of] b=10000, [...] they are so bad that TeX considers them indistinguishable; in such cases c=100000, so TeX simply accumulates material until the page is full enough to have b<10000. [...]. The notation b=* and c=* on the final line means that b and c are infinite; the total height [t] cannot be reduced to [g] by shrinking the available glue. Therefore the page is ejected at the best previous place [...].

It's therefore obvious that while reading content for page [10] TeX reached a point where there the total height could not be reduced to the goal height and the page was shipped out/ejected at the previous best break point, with that content spilling over to the subsequent page (page [11]). Page [11] only has a single, optimal (yet infinite) cost associated with the breakpoint, so the page is shipped out again... this time overfull as 605.00336pt is 55.00336pt too large for the 550pt page goal.