# A problem with underfull \hbox in alignment (tabular*) and/or perhaps the calc package

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}

-
Welcome to TeX.SX! –  Claudio Fiandrino Dec 4 '13 at 11:36
Isn't 0.5\linewidth easier than \linewidth*\real{0.5}? –  egreg Dec 4 '13 at 12:12
It is, but gives same, regretfully. The discrepancy comes from those fancy multiples of \MyLen, I think. –  JotBeeL Dec 4 '13 at 13:24

\begin{tabular}{p{\the\MyLen}@{}p{\the\MyLenTwo}@{}p{\the\MyLenThree}@{}}

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.