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 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}
share|improve this question
    
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. –  user42153 Dec 4 '13 at 13:24
add comment

1 Answer

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.

share|improve this answer
    
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. –  user42153 Dec 4 '13 at 13:11
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.