3

I am getting an

underfull \hbox in alignment (badness 10000)

with tabular*. The warning goes away if I adjust the table width by 0.00002pt (as per the MWE below). The difference seems to arise from the length calculations with calc using \real and TeX's fixed point arithmetic.

I know that using tabularx with an X column is a solution, but a) I want to have complete control over the table and b) the "correction" generally depends on the the current \linewidth.

This looks like a trap for those, like me, wanting a clean TeX log file. If one follows example 5.3.1 in The LaTeX Companion (nothing against it though!), one may fall into that trap, more so that it isn't easy to reason out such a tiny difference.

Should one live with that?

\documentclass{article}
\usepackage{calc}
\begin{document}
\newlength{\MyLen}      \setlength{\MyLen}{(\linewidth*\real{0.5}-\tabcolsep)/3}%
\newlength{\MyLenTwo}   \setlength{\MyLenTwo}{\MyLen*\real{1.3}}
\newlength{\MyLenThree} \setlength{\MyLenThree}{\MyLen*\real{0.7}}
\newlength{\MyLenFour}  \setlength{\MyLenFour}{\linewidth*\real{0.5}-(\MyLen+\MyLenTwo+\MyLenThree+\tabcolsep)}
% \showthe\MylenFour % gives 0.00002pt; if that is not accounted for, TeX barks with an "Underfull \hbox (badness 10000) in alignment..."

\begin{tabular*}{0.5\linewidth-0.00002pt}{p{\the\MyLen}@{}p{\the\MyLenTwo}@{}p{\the\MyLenThree}@{}}
First&Second&Third \\
\end{tabular*}
\end{document}
2
  • Isn't 0.5\linewidth easier than \linewidth*\real{0.5}?
    – egreg
    Commented Dec 4, 2013 at 12:12
  • It is, but gives same, regretfully. The discrepancy comes from those fancy multiples of \MyLen, I think.
    – JotBeeL
    Commented Dec 4, 2013 at 13:24

1 Answer 1

3

Just use

\begin{tabular}{p{\the\MyLen}@{}p{\the\MyLenTwo}@{}p{\the\MyLenThree}@{}}
First&Second&Third \\
\end{tabular}

As there is no flexibility in the glue between columns, tabular* can not change the width in any way, so the width using tabular* will be as for tabular but then forced into a box of the specified size, so generating a warning if it doesn't fit exactly. Basically tabular* requires \extracolsep{\fill} to be used somewhere before it does anything useful.

1
  • Thanks David. I take it as it is :-) The real vs fixed point calculation trap for tabular* fans is still ready to spring though... "exact" is what matters.
    – JotBeeL
    Commented Dec 4, 2013 at 13:11

You must log in to answer this question.

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