I have problem with aligning text in a table. Here is my example:
\documentclass{article}
\begin{document}
\begin{figure}
\begin{tabular}{| l | p{1.5cm} | p{1.5cm}| }
\hline
& percentage difference & key size increase \\ \hline
N = 90 trials & 2.1 \% & 76 \% \\ \hline
N = 180 trials & 1.3 \% & 40 \% \\ \hline
\end{tabular}
\caption{Caption here.}
\end{figure}
\end{document}
the problem is a cell with text 'key size increase', there is big space between
words 'key' and 'size', how can I fix it.
Best Answer
A
\parbox
justifies its content. That’s the reason why there's so much space between “key” und “size”.I find the table column specifier
p{<width>}
in this case very unsatisfying as the resulting column has a minimum width.I'd rather insert manually line-breaks with one of the following solutions:
\lbCell
: An innertabular
that exists of only one column (I prefer ac
entered heading),\pCell
: a\pbox[<vertical alignment>]{<maximum width>}{<content>}
.The
\pbox
macro is provided by thepbox
package. The resulting box collapses to the minimal required width.The first optional argument of both
\*Cell
macros denote the vertical alignment of the insertestabular
/pbox
and is per defaultt
op.Not related to you question, I also uses the
booktabs
package to provide a more appealing output (so many lines!) of your tabular.Code
Output