# Underfull hbox in tabular

I'm trying to make a table with fixed column widths. Cells in the first column will generally not have enough text to require a line break within the cell. The second column's cells will quite often be multi-line cells. Whenever I have a cell in the first column require a linebreak I get an "underfull \hbox" warning like:

Underfull \hbox (badness 10000) in paragraph at lines 7--7

Here is an example of what I am currently doing:

\documentclass[twocolumn]{article}

\begin{document}
\begin{table}
\begin{tabular}{|p{0.25\columnwidth}|p{0.75\columnwidth}|}
\hline
longish line of text & second cell that will often have a lot of text\\
\hline
\end{tabular}
\end{table}
\end{document}


I don't require that the column widths be fixed to what they are, or fixed at all. I just want to allow newlines in both columns without having the first column get too wide (and cause excessive newlines in the second column). I also need to have this table fit in a twocolumn environment, which is where most of the space restriction comes from.

-

If \raggedright is acceptable...

\documentclass[twocolumn]{article}

\begin{document}
\begin{table}
\begin{tabular}{|p{0.25\columnwidth}|p{0.75\columnwidth}|}
\hline
\raggedright % PS
longish line of text & second cell that will often have a lot of text\\
\hline
\end{tabular}
\end{table}
\end{document}


A second version:

\documentclass[twocolumn]{article}
\usepackage{array}

\begin{document}
\begin{table}
\begin{tabular}{|>{\raggedright}p{0.25\columnwidth}|p{0.75\columnwidth}|}
\hline
%\raggedright % PS
longish line of text & second cell that will often have a lot of text\\
\hline
\end{tabular}
\end{table}

\end{document}


And you'd better add Werner's corrections.

-
Thats perfect, I think it even ends up looking better than trying to justify only two words. Is there a better way to get \raggedright for every line than putting it before every row that is a problem? –  Matt May 14 '13 at 1:41
You should also use a column specification of the form |p{\dimexpr0.25\columnwidth-2\tabcolsep-1.5\arrayrulewidth}|p{\dimexpr0.75\colu‌​mnwidth-2\tabcolsep-1.5\arrayrulewidth}| –  Werner May 14 '13 at 1:41
@Matt You can add \usepackage{array} \begin{document} \begin{table} \begin{tabular}{|>{\raggedright}p{0.25\columnwidth}|p{0.75\columnwidth}|}. Please read also Werner's correction to avoid overfull hboxes. –  Przemysław Scherwentke May 14 '13 at 2:10
Recall that if \raggedright is used in the last column, the row must be terminated by \tabularnewline (or \arraybackslash from the array package should be used). –  egreg May 14 '13 at 7:56