Discussion:
Right-justifying text in multi-line table entries
(too old to reply)
Charlie Zender
2004-10-02 06:15:57 UTC
Permalink
Hi,

I am using LaTeX to format a table in the tabular environment.
One of the columns contains text that is intended to wrap and thus
take up two rows. It is formatted with
{\raggedright}p{1.85in}<{}
I manually separate the contents of these cells in to first and
second rows with \newline because I want the region names in the
first row and the cooredinates in the second, e.g.,

Eastern Sahel \newline 10N-15N, 10W-20E

which will appear as

Eastern Sahel
10N-15N, 10W-20E

Question: How do I right-justify the contents of the second row?

I've tried inserting an \hfill after the newline but LaTeX ignores the
\hfill unless some real text appears before the \hfill in the same
row. I've tried to fool LaTeX by inserting various non-printing space
before the \hfill but no luck. Removing \raggedright does not seem to
help. Any ideas?

Thanks!
Charlie
--
Charlie Zender, ***@uci.edu, (949) 824-2987, Department of Earth
System Science, University of California, Irvine CA 92697-3100
Harry Schmidt
2004-10-02 07:39:58 UTC
Permalink
Post by Charlie Zender
I am using LaTeX to format a table in the tabular environment.
One of the columns contains text that is intended to wrap and thus
take up two rows. It is formatted with
{\raggedright}p{1.85in}<{}
I manually separate the contents of these cells in to first and
second rows with \newline because I want the region names in the
first row and the cooredinates in the second, e.g.,
Eastern Sahel \newline 10N-15N, 10W-20E
Maybe you should create a markup-command to typeset this logically.
Post by Charlie Zender
which will appear as
Eastern Sahel
10N-15N, 10W-20E
Question: How do I right-justify the contents of the second row?
This is quite independent of the tabular environment.
Post by Charlie Zender
I've tried inserting an \hfill after the newline but LaTeX ignores the
\hfill unless some real text appears before the \hfill in the same
row.
Use \mbox{}\hfill.

Harry
Ulrich M. Schwarz
2004-10-02 07:53:50 UTC
Permalink
Post by Charlie Zender
Hi,
I am using LaTeX to format a table in the tabular environment.
One of the columns contains text that is intended to wrap and thus
take up two rows. It is formatted with
{\raggedright}p{1.85in}<{}
I manually separate the contents of these cells in to first and
second rows with \newline because I want the region names in the
first row and the cooredinates in the second, e.g.,
Eastern Sahel \newline 10N-15N, 10W-20E
which will appear as
Eastern Sahel
10N-15N, 10W-20E
Question: How do I right-justify the contents of the second row?
Wouldn't it be easier to make that two rows? You can glue together
other entries that occupy both rows with the multirow package, and you
can change the formatting of single cells with a 1-column multicolumn:

\documentclass{article}

\usepackage{array, multirow}

\begin{document}

\begin{tabular}{p{1in}|p{1.85in}|}
\multirow{2}{1.85in}{Deserts} & Eastern Sahel \\
& \multicolumn{1}{r|}{10-15N, 10W-20E}\\
\end{tabular}

\end{document}

(Vertical lines for illustration only, you know you shouldn't use them.)

HTH
Ulrich
--
Getting lost in the \footnotes and \temporals? Talcum makes LaTeX more fun.
Now with whole new bugs ;), and, of course, still with special Beamer support.
http://talcum.sarovar.org/ (Current release: 0.4.2, 20040910)
Christian Ebert
2004-10-02 08:14:29 UTC
Permalink
Post by Charlie Zender
Hi,
I am using LaTeX to format a table in the tabular environment.
One of the columns contains text that is intended to wrap and thus
take up two rows. It is formatted with
{\raggedright}p{1.85in}<{}
I manually separate the contents of these cells in to first and
second rows with \newline because I want the region names in the
first row and the cooredinates in the second, e.g.,
Eastern Sahel \newline 10N-15N, 10W-20E
which will appear as
Eastern Sahel
10N-15N, 10W-20E
Question: How do I right-justify the contents of the second row?
I am not sure what you want exactly but I'll have a guess:

\documentclass{article}
\usepackage{array}
\newcolumntype{P}{>{\hspace{0pt}\arraybackslash\raggedleft}p{1.85in}}
\begin{document}
\begin{tabular}{lP}
Test & Eastern Sahel\\
10N-15N, 10W-20E\tabularnewline
Test & Text that is wrapped and
right-justified
\end{tabular}
\end{document}

HTH

c
--
So dacht ich. Nächstens mehr.
_HÖLDERLIN: H Y P E R I O N_ <http://www.blacktrash.org/>
Donald Arseneau
2004-10-02 11:13:29 UTC
Permalink
Post by Charlie Zender
Eastern Sahel \newline 10N-15N, 10W-20E
Question: How do I right-justify the contents of the second row?
\newcommand\newrightline{\newline\hspace*{\fill}}


Donald Arseneau ***@triumf.ca
Charlie Zender
2004-10-02 17:47:32 UTC
Permalink
Thanks to everyone who responded to my question, my table looks beautiful.

Charlie
--
Charlie Zender, ***@uci.edu, (949) 824-2987, Department of Earth
System Science, University of California, Irvine CA 92697-3100
Continue reading on narkive:
Loading...