On Thursday, June 20, 2002, at 02:29 PM, Mary wrote:
> Incidently, a neat trick to get all the decimal points to line up in,
> ......
> so that you have each decimal . exactly below the previous, is to
> actually define . as a column separator.
> \begin{tabular}{|r|l|r@{.}r|r@{.}r|r@{.}r|}
> \hline
> 1 & Fried penguin & $3 & 00 & $0 & 30 & $3 & 30 \\
> 2 & Diced penguin & $9 & 00 & $0 & 90 & $9 & 90 \\
> \hline
> \end{tabular}
>
> @{.} tells it to use . to separate columns, rather than |
>
Thats a rather neat trick and one that I might well use myself.
Brad Thopmson may be interested to read up on the dcolumn package for
tables. Its for lining up numbers on decimal points or other characters.
Here is a simple example. Note the multicolumn spanning just a single
column is required to get the text 'Col3' to align properly. Remove it
to see the difference.
\usepackage{dcolumn}
\newcolumntype{d}[1]{D{.}{\cdot}{#1}}
% D{input separator}{output separator}{nnumber of decimal places}
\begin{tabular}{lrd{2}}
\hline
Col 1 &Col 2 &\multicolumn{1}{r}{Col 3}\\
\hline
text 1 &1.2 &20.12\\
text 1 &2.3 &40.12\\
\hline
\end{tabular}
I think the horizontal lines of the standard latex tables lines are
little too cluttered so use the "booktabs" package. Here is an example
where I have used the newly defined 'd' column format as well to align
on decimal points.
\usepackage{booktabs}
\begin{tabular}{@{}lld{2}@{}} \toprule
\multicolumn{2}{c}{Item} \\ \cmidrule(r){1-2}
Animal & Description & \multicolumn{1}{r}{Price (\$)}\\ \midrule
Gnat & per gram & 13.5 \\
& each & 0.01 \\
Gnu & stuffed & 92.5 \\
Emu & stuffed & 33.33 \\
Armadillo & frozen & 8.99 \\ \bottomrule
\end{tabular}
Note that the toprule and bottomrule are slightly thicker than the
midrules and there is more vertical spacing.
When your business correspondence is converted to latex tables your
clients will likely notice the neater and more professional appearance
of the table designs.
Michael Lake
Caver, Linux enthusiast and interested in anything technical.
UTS CRICOS Provider Code: 00099F
DISCLAIMER
========================================================================
This email message and any accompanying attachments may contain
confidential information. If you are not the intended recipient, do not
read, use, disseminate, distribute or copy this message or attachments.
If you have received this message in error, please notify the sender
immediately and delete this message. Any views expressed in this message
are those of the individual sender, except where the sender expressly,
and with authority, states them to be the views the University of
Technology Sydney. Before opening any attachments, please check them for
viruses and defects.
========================================================================
--
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug