In other words:
I have several columns in a tabular environment defined a "p{3cm}", as opposed
to "c", "l", or whatever.
I want the text in these boxes to be left-justified, or ragged-right.
If I enter the text as {\raggedright da da da da da} it does NOT left justify
the text. It makes it flush left AND right. But is still gives underful \hbox
messages.
If I enter the text as \raggedright{da da da da da} it works just fine, but NOT
for the last column in the table. When I do it this way, it gives the error
"!Misplaced \noalign." at the position of the \hline following the table. I.E.,
this last column is followed by "\\", followed by "\hline", to draw a line at
the bottom of the table. This is how I end all of my tables and it only gives me
a problem when I try this \raggedright option.
Any suggestions?
Much thanks,
Brian
ru...@eggneb.astro.ucla.edu
Here's what I do: For each entry that you wish to place left or right, do a
\multicolumn{1}{l}{<text to be moved left>}
This is really ugly, and only shortened up somewhat if you do
\newcommand{\ml}{\multicolumn{1}{l}}
and then use
\ml{<text>}
in your table entries. If there's any other way to do this than by doing this
for every entry in the table, I'd sure like to know about it.
--
Patrick Duffy, du...@theory.chem.ubc.ca
"It's difficult to work in a group when you're omnipotent."
-- "Q", Star Trek the Next Generation
>How can I force the text in a parbox-type column in a table to be ragged-right?
[stuff deleted]
>Any suggestions?
>Much thanks,
>Brian
>ru...@eggneb.astro.ucla.edu
Try using the flushleft environment. For example
\begin{tabular}{p{2in}p{2in}}
\begin{flushleft}
aaaaaaa \\ aaaaaa \\ aaaaa \\ aaaa \\ aaa \\ aa \\ a
\end{flushleft}
&
\begin{flushleft}
bbbbbbb \\ bbbbbb \\ bbbbb \\ bbbb \\ bbb \\ bb \\ b
\end{flushleft}
\end{tabular}
Barry Adams (ba...@ramsey.cs.laurentian.ca)
Previous postings have suggested using the flushleft environment
and using
\multicolumn{1}{l}{<text to be moved left>}
The multicolumn solution does not really do the right thing, as it
produces text in LR (aka internal horizontal) mode, so TeX does not
break the lines to the width specified in the p{...} preamble
The flushleft environment unfortunately falls foul of a `feature' of
the way LaTeX terminates `p' columns, it results in a blank line being
produced after the entry.
A better solution is to use the \raggedright command. If the column in
question is the final column of the table, you will need to reinstate
the \\ comand to terminate a table row, as \ragedright redefines it.
One way to do this is to go
\newcommand{\PreserveBackslash}[1]{\let\temp=\\#1\let\\=\temp}
and use \PreserveBackslash\raggedright at the start of each entry.
...
To see the difference, compare
\documentstyle{article}
\newcommand{\PreserveBackslash}[1]{\let\temp=\\#1\let\\=\temp}
\begin{document}
\begin{tabular}{cp{1in}}
xxx & \multicolumn{1}{l}{Some ragged right text. Some ragged right text.}\\
yyy & \multicolumn{1}{l}{Some ragged right text. Some ragged right text.}\\
\end{tabular}
\begin{tabular}{cp{1in}}
xxx & \begin{flushleft}
Some ragged right text. Some ragged right text.\end{flushleft}\\
yyy & \begin{flushleft}
Some ragged right text. Some ragged right text.\end{flushleft}\\
\end{tabular}
%
%
\begin{tabular}{cp{1in}}
xxx & \PreserveBackslash\raggedright
Some ragged right text. Some ragged right text.\\
yyy & \PreserveBackslash\raggedright
Some ragged right text. Some ragged right text.
\end{tabular}
\end{document}
If you use array.sty from the ARRAY package at any CTAN server, you
can go
\newcolumntype{P}[1]{>{\PreserveBackslash\raggedright}p{#1}}
and then the above could be shortened to
%
\begin{tabular}{cP{1in}}
xxx &Some ragged right text. Some ragged right text.\\
yyy &Some ragged right text. Some ragged right text.
\end{tabular}
David