5

I'd like to have table of 15cm with fixed-width cells. I use tabularx package. For some reason, the following code gives underfull \hbox (badness 10000) in alignment . What causes this warning? How can I fix this?

\documentclass[a4paper,12pt]{report}

\usepackage[polish]{babel}

\usepackage[top=25mm,bottom=25mm,left=35mm,right=25mm]{geometry}
\usepackage{tabularx}

\begin{document}

\begin{table}[!ht]
\begin{tabularx}{150mm}{|>{\hsize=0.3\hsize}X|>{\hsize=0.6\hsize}X|>{\hsize=1\hsize}X|>{\hsize=1.55\hsize}X|>{\hsize=1\hsize}X|>{\hsize=1.55\hsize}X|}
\hline
a & b & c & d & e & f \tabularnewline
\hline
\end{tabularx}
\end{table}

\end{document}
  • What do you mean by "fixed-width" cells? As in, you know their lengths? – Werner Jul 9 '14 at 21:15
  • That is no problem. There are internal rounding errors. Try ... >{\hsize=1.45\hsize}X|X|>{\hsize=1.65\hsize}X|} \hline and it should go. I used a short X for \hsize=1\hsize – user2478 Jul 9 '14 at 21:27
  • Thank you. I knew it has something to do with rounding. So If i use 1.55 then 2.5cm*1.55=3.875 and there are three digits after comma, which causes rounding error. Is it possible to fix this rounding error somehow? – Karol Majewski Jul 9 '14 at 21:37
  • Hmm... on the other hand, 2.5cm*1.45=3.625 and again three digits after comma, but no error. Perhaps I don't understand why those errors happen. – Karol Majewski Jul 9 '14 at 21:54
5

I really wouldn't use tabularx here, as you really know all the column widths in advance, however if you do use it you can add some stretch glue to pad out the box

\documentclass[a4paper,12pt]{report}

\usepackage[polish]{babel}

\usepackage[top=25mm,bottom=25mm,left=35mm,right=25mm]{geometry}
\usepackage{tabularx}

\begin{document}

\begin{table}[!ht]
\begin{tabularx}{150mm}{!{\extracolsep{\fill}}|>{\hsize=0.3\hsize}X|>{\hsize=0.6\hsize}X|>{\hsize=1\hsize}X|>{\hsize=1.55\hsize}X|>{\hsize=1\hsize}X|>{\hsize=1.55\hsize}X|}
\hline
a & b & c & d & e & f \tabularnewline
\hline
\end{tabularx}
\end{table}

\hbox to 150mm{\hbox to 149.99mm{}}


\end{document}

The problem is that if a box is a fraction overfull TeX will not report it (if it is less than \hfuzz) but an underful box with no stretchable glue is always infinitely bad, as shown by the \hbox example at the end of the above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.