[comp.text] centering tables

gm@romeo.cs.duke.edu (Greg McGary) (03/10/89)

In article <601@sunset.MATH.UCLA.EDU> adam@MATH.UCLA.EDU () writes:
>How do you center a table? For example, the ATT stock table on
>page 247 of the Texbook. I tried \centerline and this sort of
>works depending on the \halign to dimen parameter. 

One of the easiest way to accomplish this is to exploit `display math'
mode.

$$\vbox{\halign{<preamble>\cr
	   <table-body>\cr}}$$

This centers the \vbox and puts some extra space above and below.

If you don't want the extra verticle space, you can do this:

\centerline{\vbox{\halign{<preamble>\cr
	   <table-body>\cr}}}

Alternatively, you can do `\halign to\hsize' to make the \halign
expand to the width of the page, then you'll have to add infintely
stretchable glue before the first column and after the last column.
To learn how to set \tabskip glue, I'll refer you to pages 237, 238
in the TeXbook.

Good Luck!

-- Greg McGary
-- 4201 University Drive #102, Durham, NC 27707       voice: (919) 490-6037
-- {decvax,hplabs,seismo,mcnc}!duke!gm                 data: (919) 493-5953
--                                  gm@cs.duke.edu