14

I got some strange "underfull \vbox (badness 10000) detected at line ..." warnings, obviously at each of my "longtable"s. Is there a way to fix them (I actually don't see the cause) or do I have to ignore them?

Minimal working example (PdfLaTeX tells these warnings triply for each run on compiling with longtable [2000/10/22 v4.10 Multi-page Table package (DPC)]; each \demounderfullvbox might be replaced by the full example code or the source may be reduced to one longtable, what doesn't change behavior):

\documentclass[english,11pt,a4paper]{article}
\usepackage{longtable}

\newcommand{\demounderfullvbox}{%
    \begin{longtable}{|l|p{2in}|}
    %
    \endfirsthead
    %
    \hline\multicolumn{2}{|l|}{\textsl{\ldots continued from previous page}}\\*
    \endhead
    %
    \multicolumn{2}{|l|}{\textsl{will be continued on next page\ldots}}\\*
    \hline
    \endfoot
    %
    \hline
    \endlastfoot
    %
    \hline%
    aa: & 4711\\
    \hline%
    aaa: & 2\\
    \hline%
    aaaa: & 4711-2\\
    \end{longtable}
}

\begin{document}
\newpage
%
\demounderfullvbox
\demounderfullvbox
\demounderfullvbox

\end{document}

If tabular is used instead of longtable, no warnings occur, but that doesn't solve the problem, as much more rows can be placed in the tables.

Removing the trailing \\ in the aaaa: line has no effect either.

The "underfull \vbox" warnings seem to specify a source line that looks ok to me (this is more clearly when \demounderfullvbox is replaced by the example code), think the warning is provocated on computation of first LTchunk?

Thanks for help and suggestions in advance!

2 Answers 2

15

The underfull box is in fact the \hline at the start of the table (entered just after \endlastfoot)

If instead you remove it from there and put it at the end of the first head, as below, it all works out.

The reason for this eludes me at present but I'm sure it is all explained in detail in the package documentation......

\documentclass[english,11pt,a4paper]{article}
\usepackage{longtable}
\showboxdepth10
\showboxbreadth10

\newcommand{\demounderfullvbox}{%
    \begin{longtable}{|l|p{2in}|}
        \hline%
    \endfirsthead
    %
    \hline
    \multicolumn{2}{|l|}{\textsl{\ldots continued from previous page}}
    \endhead
    %
    \multicolumn{2}{|l|}{\textsl{will be continued on next page\ldots}}\\
    \hline
    \endfoot
    %
    \hline
    \endlastfoot
    %
    aa: & 4711\\
    \hline%
    aaa: & 2\\
    \hline%
    aaaa: & 4711-2
    \end{longtable}%
}

\begin{document}
\newpage
%
\demounderfullvbox
\demounderfullvbox
\demounderfullvbox

\end{document}
1
  • Oops - that simple \hline position was it... I must have moved it some days ago with the intent to have all "data" rows with the same source layout, but haven't recognized the side effect... Thank you very much for answering so quickly!
    – tueftl
    Commented Sep 11, 2012 at 12:52
7

The example can be simplified to

\showboxdepth=\maxdimen
\showboxbreadth=\maxdimen

\documentclass{article}
\usepackage{longtable}[2004/02/01]
\begin{document}
  \begin{longtable}{l}
    \hline
    x
  \end{longtable}
\end{document}

The .log file contains:

Package: longtable 2004/02/01 v4.11 Multi-page Table package (DPC)
[...]
Underfull \vbox (badness 10000) detected at line 10

\vbox(8.39996+0.0)x345.0
.\penalty 10000
.\hbox(0.4+0.0)x345.0, glue set 163.8611fill
..\glue(\tabskip) 0.0 plus 1.0fill
..\hbox(0.4+0.0)x17.27782, glue set 17.27782fill
...\leaders 0.0 plus 1.0fill
....\rule(0.4+0.0)x*
..\glue(\tabskip) 0.0 plus 1.0fill

Package longtable splits its contens in chunks (in \LT@start):

\dimen@ii\vfuzz
\vfuzz\maxdimen
  \setbox\tw@\copy\z@
  \setbox\tw@\vsplit\tw@ to \ht\@arstrutbox
  \setbox\tw@\vbox{\unvbox\tw@}%
\vfuzz\dimen@ii

Because of \unvbox\tw@ it does not matter if the splitted box by \vsplit is too large or too small. \setbox\tw@\vbox{\unvbox\tw@} sets the box in its natural size. Overfull boxes are catched by \vfuzz. If \hline starts the table, then \hline and the next line is too large for \ht\@arstrutbox. But the line itself is too small for \ht\@arstrutbox and generates the underfull \vbox.

BTW, the documentation says:

Also \hline may be used, as in tabular.

Therefore I consider this behavior as bug that can be fixed by setting \vbadness to 10000, see lines marked with (added):

\makeatletter
\def\LT@start{%
  \let\LT@start\endgraf
  \endgraf\penalty\z@\vskip\LTpre
  \dimen@\pagetotal
  \advance\dimen@ \ht\ifvoid\LT@firsthead\LT@head\else\LT@firsthead\fi
  \advance\dimen@ \dp\ifvoid\LT@firsthead\LT@head\else\LT@firsthead\fi
  \advance\dimen@ \ht\LT@foot
  \edef\restore@vbadness{\vbadness\the\vbadness\relax}% (added)
  \vbadness=\@M % (added)
  \dimen@ii\vfuzz
  \vfuzz\maxdimen
    \setbox\tw@\copy\z@
    \setbox\tw@\vsplit\tw@ to \ht\@arstrutbox
    \setbox\tw@\vbox{\unvbox\tw@}%
  \vfuzz\dimen@ii
  \restore@vbadness % (added)
  \advance\dimen@ \ht
        \ifdim\ht\@arstrutbox>\ht\tw@\@arstrutbox\else\tw@\fi
  \advance\dimen@\dp
        \ifdim\dp\@arstrutbox>\dp\tw@\@arstrutbox\else\tw@\fi
  \advance\dimen@ -\pagegoal
  \ifdim \dimen@>\z@\vfil\break\fi
      \global\@colroom\@colht
  \ifvoid\LT@foot\else
    \advance\vsize-\ht\LT@foot
    \global\advance\@colroom-\ht\LT@foot
    \dimen@\pagegoal\advance\dimen@-\ht\LT@foot\pagegoal\dimen@
    \maxdepth\z@
  \fi
  \ifvoid\LT@firsthead\copy\LT@head\else\box\LT@firsthead\fi\nobreak
  \output{\LT@output}%
}
\makeatother
8
  • Thanks, I'd spotted the first bit but ran out of time checking if it would be safe just to silence the warning. I guess an update is called for... Commented Sep 11, 2012 at 14:41
  • @DavidCarlisle Agreed. Also feel free to consider Caption at foot of long tables as feature request :-) Commented Sep 11, 2012 at 15:04
  • @DavidCarlisle: maybe I've found another problem in the apart from that brilliant longtable.
    – tueftl
    Commented Sep 18, 2012 at 12:29
  • Yes saw that, been too busy to look this week, may have to be the weekend, or if you are lucky @HeikoOberdiek may fix it for you:-) Commented Sep 18, 2012 at 12:32
  • 1
    @Arsenal fixed in the sources for longtable 4.15 github.com/latex3/latex2e/commit/… Commented Apr 18, 2021 at 8:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .