[texhax] Raggedright in fixed-width table column

E. Krishnan ekmath at asianetindia.com
Tue Feb 12 00:46:51 CET 2008


On Mon, 11 Feb 2008, Brandon Kuczenski wrote:

> Hello all,
>
> I am trying to construct a table that looks like this:
>
> \begin{tabular}{l p{10cm}}
> ...
>
> and then define the entries in the table using this command:
>
> \newcommand{\tableentry}[2]{%
> #1 & #2 \\
> }
>
> except I would like the text in the 10cm parbox to be raggedright, rather
> than justified.

There are two solutions, both using the "array" package.

1. \usepackage{array}

    \newcommand{\tableentry}[2]{#1 & #2 \\}
    \newcolumntype{P}[1]{>{#1\arraybackslash}p{10cm}}
    \begin{tabular}{lP{\raggedright}}


2. \usepackage{array}

    \newcommand{\tableentry}[2]{#1 & #2 \tabularnewline}
    \begin{tabular}{l>{\raggedright}p{10cm}}


-- 
Krishnan


More information about the texhax mailing list