[texhax] justify columns in longtable

Douglas Lewan d_lewan2000 at yahoo.com
Tue Mar 1 06:28:08 CET 2005


Sarah Bluhme wrote:

> Hello,
>
> I was wondering if someone can help me with a Latex problem. Using the 
> tabular or longtable environment, I have columns that are word-wrapped 
> like the second one here:
>
> \begin{longtable}{|l|p{3cm}|}
>
> My problem is that the text in it is justified on both sides which 
> looks awful in a relatively narrow column which may only be wide 
> enough for 2 or 3 words. How can I insert the \raggedright (or some 
> other) command to take effect over the whole column?
>
> Many thanks,
>
> Sarah Bluhme

Try using the  array  package.  It allows significant control over 
formatting within table entries.  Here's an example of a table with 
raggedright adjustment:

\usepackage{array}
\begin{tabular}{|>{\raggedright}p{5cm}
     |>{\raggedright}p{5cm}|}
\hline
Your long left column text here.  And I really mean looooooong.
&
In the right hand column there's a fair amount of text too.
Off the top of my head I don't know what this table's really about.
\tabularnewline \hline
The left hand column doesn't always have to be so wide.
&
But apparently the right hand column does.
And it turns out to be gibberish, gibberish, gibberish.
\tabularhewline \hline
\end{tabular}

See pages 246, 247 of _The LaTeX Companion_, second addition, for details.
-- 
,Doug
Douglas Lewan
email: d_lewan2000 at yahoo.com <mailto:d_lewan2000 at yahoo.com>
cell: 908 7207 908

        Some programming languages manage to absorb
        change but withstand progress.




More information about the texhax mailing list