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.

I am having a problem with the following document, pdflatex is continuously complaining with Underfull \hbox (badness 10000) in alignment at lines 3--7 in this sample, but it does for many more lines in the original doc.

I've read it has to do with the \\ in the code, but as far as I know it is the way of finishing a row in a tabular context, and if I remove them it does not compile.

\documentclass{article}
\begin{document}
\begin{tabular*}{0.9\textwidth}{l}
  \hline
  Test \\
  \hline
\end{tabular*}
\end{document}
share|improve this question
    
I made your example a lot smaller. This makes the problem far easier to pinpoint (one could also remove the two \hline and the `\`, but that would make your text nonsensical. –  Caramdir Feb 6 '11 at 22:50
    
That \ should be \\ (stupid comment markup). –  Caramdir Feb 6 '11 at 23:13
    
@Caramdir Oops. Fixed. –  Alan Munn Feb 6 '11 at 23:23
add comment

2 Answers

up vote 7 down vote accepted

LaTeX is essentially telling you that you want a table with \textwidth size, but only provide content that is 4 characters long. Maybe the following example shows where the problem is:

\begin{tabular*}{0.9\textwidth}{|l|}
  \hline
  Test \\
  \hline
\end{tabular*}

This produces

result

which is usually not the intended outcome. The easiest way to fix this is to use the tabularx environment from the package of the same name and use the X column type (which adds filling space).

\documentclass{article}
\usepackage{tabularx}
\begin{document}
\begin{tabularx}{0.9\textwidth}{|X|}
  \hline
  Test\\
  \hline
\end{tabularx}
\end{document}

result with tabularx


The reason that your example does not compile without \\ is that \hline has to be placed at the beginning of a row. Removing both \\ and the following \hline compiles, but shows the same problem.

share|improve this answer
add comment

It is the way how you are using tabular*. It makes no sense to have the starred version with only one column. In such a case one should use the unstarred version with the p-column specifier. With at least two columns for tabular* you didn't get underfull boxes.

\documentclass{article}
\begin{document}

\begin{tabular*}{0.9\textwidth}{l@{\extracolsep{\fill}}r}\hline
  Test & Test\\\hline
\end{tabular*}

\bigskip
\begin{tabular}{p{0.9\textwidth}}\hline
  Test \\\hline
\end{tabular}

\end{document}
share|improve this answer
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.