Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!jarthur!nntp-server.caltech.edu!news From: marcel@cs.caltech.edu (Marcel van der Goot) Newsgroups: comp.text.tex Subject: Re: TABLES-- Alligning the decimal points. Summary: Knuth's fix Message-ID: <1991Jan31.041733.18119@nntp-server.caltech.edu> Date: 31 Jan 91 04:17:33 GMT References: <1991Jan25.114530.2289@vax5.cit.cornell.edu> <1991Jan26.221417.24115@Neon.Stanford.EDU> Sender: news@nntp-server.caltech.edu Distribution: comp Organization: California Institute of Technology (CS dept) Lines: 39 Nntp-Posting-Host: stun4r.cs.caltech.edu There have been quite some postings concerning alignment of decimal points, with more and more complicated macro sets. (Nothing wrong with that.) However, in the TeXbook Knuth gives a simple solution (well, it's more a "fix") to the problem. Quoting: > This isn't especially pleasing to the eye, but that's what > people do, so you might have to conform to the practice. > [...] > But the author usually prefers to use another, less sophisticated > method, which takes advantage of the fact that the digits 0, 1, ..., 9 > have the same width in most fonts: You can choose a character that's > not used elsewhere in the table, say `?', and change it to an active > character that produces a blank space exactly equal to the width of > a digit. Then it's usually no chore to put such nulls into the table > entries so that each column can be regarded as either centered or > right-justified or left-justified. For example. `??0.2010' and > `297.1???' have the same width, so their decimal points will line up > easily. Here is one way to set up `?' for this purpose: > > \newdimen\digitwidth > \setbox0=\hbox{\rm0} > \dgitwidth=\wd0 > \catcode`?=\active > \def?{\kern\digitwidth} > > The last two definitions should be local to some group, e.g., inside a > \vbox, so that `?' will resume its normal behavior when the table is > finished. This is indeed not very elegant, but simple and reliable. Marcel van der Goot .---------------------------------------------------------------- | Blauw de viooltjes, marcel@vlsi.cs.caltech.edu | Rood zijn de rozen; | Een rijm kan gezet | Met plaksel en dozen. |