8

I have a not-that-complicate table like below, but I always got a error "Underfull \vbox (badness 10000) detected at line 127", hopefully you can reproduce it. Does anybody know the reason and how to fix it? This is a just an example and I may have about 100 tables in one file and I would like to fix it at the beginning.

\documentclass{article}
\usepackage{array}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\usepackage{geometry}
\usepackage[parfill]{parskip}  
\geometry{letterpaper} 
\usepackage{graphicx}   
\usepackage{longtable}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{colortbl, xcolor}
\usepackage{amssymb}
\usepackage{enumitem}
\usepackage{float}
\usepackage{color}
\usepackage{multirow}
\usepackage{epstopdf}
   \hfuzz=\maxdimen
   \tolerance=10000
   \hbadness=10000


\begin{document}
\begin{longtable}{rL{2cm}L{3.5cm}L{2cm}L{4cm}L{1.8cm}}
  \hline
 & Variable & Description & Type & Values & Missing \\ 
  \hline
1 & sid & child id & string &  &  \\ 
   \rowcolor[gray]{0.8}2 & specnum & specimen number  & string &  &  \\ 
  3 & specseq & specimen sequence & string &  &  \\ 
   \rowcolor[gray]{0.8}4 & spectype & specimen type  & string &  &  \\ 
  5 & vstnum & visit number & integer &  &  \\ 
   \rowcolor[gray]{0.8}6 & vstwk & visit week & string &  &  \\ 
  7 & vstdetail & visit details  & string &  &  \\ 
   \rowcolor[gray]{0.8}8 & lps & α lps gmu/ml (endocab) & integer &  -9= missing & -9 \\ 
  9 & rept & do you need to repeat sample? & categorical & 1 = yes, 2 = no &  \\ 
   \rowcolor[gray]{0.8}10 & resn & reason for repeating & categorical & 3=sample out of range, 4 = assay failed, -9 = not applicable & -9 \\ 
  11 & comnt & comment & string &  &  \\ 
   \rowcolor[gray]{0.8}12 & specdt & date of specimen collection dd/mm/yy & date &  & 1999-09-09 \\ 
  13 & assydt & date assay performed dd/mm/yy & date &  & 1999-09-09 \\ 
   \rowcolor[gray]{0.8}14 & dedt & date entered & date &  & 1999-09-09 \\ 
  15 & qcdt & date checked & date &  & 1999-09-09 \\ 
   \rowcolor[gray]{0.8}16 & batch & assay batch \# & integer &  &  \\ 
  17 & version & batch version & string &  &  \\ 
   \rowcolor[gray]{0.8} \hline
\hline
\end{longtable}
\end{document}

2 Answers2

7

the underfull box warning is only a warning, not an error.

\documentclass[landscape]{article}



\usepackage{longtable}

\addtolength\textwidth{120pt}


\usepackage[T1]{fontenc}


\usepackage{array}

\showoutput
\newcolumntype{L}[1]{>{\raggedright\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\arraybackslash\hspace{0pt}}m{#1}}



\begin{document}

\begin{longtable}{rL{2cm}L{3.5cm}L{2cm}L{4cm}L{1.8cm}}
\hline
1 & sid & child id & string &  &  
\end{longtable}


\end{document}

the above shows the box that is underfull is a blank line that is trying to be baselineskip high, but only contains a 0.4pt high rule from \hline.

this is apparently an undocumented feature of the longtable package. I'd blame the author of the package.

David Carlisle
  • 757,742
2

Per David Carlisle's example, putting the top/bottom hlines as head/foot avoids the underfull warning:

\begin{longtable}{rL{2cm}L{3.5cm}L{2cm}L{4cm}L{1.8cm}}
\hline
\endhead
\hline
\endfoot
1 & sid & child id & string &  &  
\end{longtable}

In my case it was weird that I have the exact table imported to four documents but only one generated the underfull message. Must be something to do with how the table fits with surrounding (different in each document) text to fill the page.

KC7HP
  • 41