Article View: comp.text
Article #6127Re: Printing tables in LaTeX
From: Atul Kacker
Date: Fri, 07 Apr 1989 13:26
Date: Fri, 07 Apr 1989 13:26
41 lines
2049 bytes
2049 bytes
In article <412@mqws2.fed.FRB.GOV> m1swd00@fed.frb.gov (Sean W. Doyle) writes:
>
>Two LaTeX table formatting questions:
>
>1. Is there an easy way to format numbers in a table aligned vertically
> by decimal point?
>
>For example, how would I print a table of the following sort:
>
> 1.234 1.2345 1.2
> .323 .7890 .1
> -2.009 .0902 .3
>
I'm sure there are other ways to do it, but what I ended up using in my
thesis, was a combination of "tables" macro (available from the latex-style
collection at sun.soe.clarkson.edu) and the following kludge from The
TeXbook (p.241). Basically what you do is to take a character (? in this
case) and make it active and then use it to manually align decimal points.
Crude, but hey, it works.
----------------------------
\documentstyle[tables]{report}
\begin{document}
% ------------ kludge for aligning decimal points
\newdimen\digitwidth
\setbox0=\hbox{\rm0}
\digitwidth=\wd0
\catcode`?=\active
\def?{\kern\digitwidth}
% ----------- use the table environment in LaTeX
\begin{table}[p]
\begintable % the begintable and endtable are for the tables macros
339.1 | 275.4 | 1220 | ?0.67 | 23.0 | 0.19 | 292.2 | 3.76 \cr
339.8 | 274.6 | 1190 | ?3.10 | 23.0 | 0.19 | 292.1 | 3.85 \cr
347.1 | 277.0 | 1150 | 20.75 | 22.9 | 0.22 | 298.4 | 3.53 \cr
348.3 | 276.1 | 1150 | 28.20 | 22.9 | 0.23 | 299.1 | 3.51 \cr
352.9 | 291.8 | 1160 | ?0.24 | 22.0 | 0.18 | 308.9 | 2.95 \cr
357.4 | 287.1 | 1160 | 19.90 | 23.0 | 0.22 | 309.4 | 3.11
\endtable
\end{table}
\end{document}
----------------------------------
Technical Details
Message-ID:
<1432@ur-cc.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!rochester!uhura.cc.rochester.edu!akk2References:
<412@mqws2.fed.FRB.GOV>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!rochester!uhura.cc.rochester.edu!akk2 From: akk2@uhura.cc.rochester.edu (Atul Kacker) Newsgroups: comp.text Subject: Re: Printing tables in LaTeX Keywords: LaTeX, Table macros Message-ID: <1432@ur-cc.UUCP> Date: 7 Apr 89 13:26:10 GMT References: <412@mqws2.fed.FRB.GOV> Reply-To: akk2@uhura.cc.rochester.edu (Atul Kacker) Distribution: usa Organization: University of Rochester Lines: 41