| 1 |
%% file: TXSruled.doc - Ruled Tables - TeXsis version 2.18 |
| 2 |
%% @(#) $Id: TXSruled.doc,v 18.2 2000/05/17 00:19:46 myers Exp $ |
| 3 |
%======================================================================* |
| 4 |
% (C) copyright 1994, 1999 by Eric Myers and Frank E. Paige. |
| 5 |
% This file is a part of TeXsis. Distribution and/or modifications |
| 6 |
% are allowed under the terms of the LaTeX Project Public License (LPPL). |
| 7 |
% See the file COPYING or ftp://ftp.texsis.org/texsis/LPPL |
| 8 |
%======================================================================* |
| 9 |
\ifx\undefined\bs \texsis\input TXSdocM.doc\draft\fi |
| 10 |
|
| 11 |
\noindent |
| 12 |
While \cs{halign} in Plain \TeX\ is convenient for making simple |
| 13 |
tables, it is still difficult to make tables with horizontal and |
| 14 |
vertical rules. Indeed, typesetting ruled tables in \TeX\ has often |
| 15 |
been likened to programming a computer in assembler language. Even |
| 16 |
\TeXbook\ acknowledges that ``people who know how to make ruled tables |
| 17 |
are generally known as \TeX\ Masters.''\reference{Masters}\relax |
| 18 |
D.E.~Knuth, {\sl The \TeX book} (Addison Wesley, 1986), page 245 |
| 19 |
\endreference |
| 20 |
The macros described below take a great deal of the difficulty out of |
| 21 |
making ruled tables, so that anybody can become a |
| 22 |
\TeX\ Master, or at least a master of ruled tables. |
| 23 |
\index{ruled tables}\index{tables!ruled|see{ruled tables}} |
| 24 |
|
| 25 |
\def\VT{\char'174} % the vertical var character ``|'' is needed below |
| 26 |
|
| 27 |
The basic idea behind making a ruled table is similar to |
| 28 |
\cs{halign}, and the syntax is the same as the Princeton table macros |
| 29 |
known as |TABLES.TEX| by Ray Cowan\reference{Cowan} Ray F.~Cowan, {\sl |
| 30 |
Making Tables with Macros} (unpublished) |
| 31 |
\endreference\index{Cowan, Ray F.} |
| 32 |
(although the \TeXsis\ macros are quite different internally and run |
| 33 |
about 5 times faster). You begin the table material with \cs{ruledtable} |
| 34 |
and end it with \cs{endruledtable}. The table material is a list of items |
| 35 |
to appear in the rows and columns of the tables. Just as with \cs{halign}, |
| 36 |
you can separate items in different columns with |&|\index{&@{\tt \&}} |
| 37 |
and end a row with |
| 38 |
\cs{cr}. The |&| \idx{alignment character}\index{&@{\tt \&}} |
| 39 |
separates columns without putting a |
| 40 |
vertical rule between the columns, while \cs{cr} ends a line and puts a |
| 41 |
thin horizontal rule under it. To get a vertical rule between columns |
| 42 |
replace the |&|\index{&@{\tt \&}} |
| 43 |
with a `{\tt\VT}' (the vertical line), and to end a line |
| 44 |
without a horizontal rule under it replace the \cs{cr} with \cs{crnorule}. |
| 45 |
One important thing to remember is to end the last line in the table |
| 46 |
with \cs{endruledtable} instead of \cs{cr}. |
| 47 |
|
| 48 |
\bigskip |
| 49 |
\pagecheck{2cm} |
| 50 |
|
| 51 |
As a first example, here is a simple ruled table, |
| 52 |
{\singlespaced |
| 53 |
\bigskip\tenpoint |
| 54 |
\ruledtable |
| 55 |
Year | World Population \cr |
| 56 |
8000 B.C. | ~~~5000000 \crnorule |
| 57 |
~~50 B.C. | ~200000000 \crnorule |
| 58 |
1650 A.D. | ~500000000 \crnorule |
| 59 |
1850 A.D. | 1000000000 \crnorule |
| 60 |
1945 A.D. | 2300000000 \crnorule |
| 61 |
1980 A.D. | 4400000000 |
| 62 |
\endruledtable |
| 63 |
\smallskip} |
| 64 |
\pagecheck{2cm}\noindent |
| 65 |
and here are the instructions that created it, |
| 66 |
\TeXexample |
| 67 |
|smalltt\ruledtable |
| 68 |
Year |VT World Population \cr |
| 69 |
8000 B.C. |VT ~~~5000000 \crnorule |
| 70 |
~~50 B.C. |VT ~200000000 \crnorule |
| 71 |
1650 A.D. |VT ~500000000 \crnorule |
| 72 |
1850 A.D. |VT 1000000000 \crnorule |
| 73 |
1945 A.D. |VT 2300000000 \crnorule |
| 74 |
1980 A.D. |VT 4400000000 |
| 75 |
\endruledtable |
| 76 |
|endTeXexample |
| 77 |
This example also appears in \TeXbook, on page~246, where it is typeset using |
| 78 |
|\halign|. Compare how the two are constructed |
| 79 |
and see which way you think is easier. |
| 80 |
|
| 81 |
By default each item in the table is centered in its column. Inside |
| 82 |
a table the tie character ``|~|''\index{~@{\tt\char'176}} takes up the space |
| 83 |
of exactly one digit (it is the same as saying |
| 84 |
|\phantom{0}|),\index{phantom@{\tt\bs phantom\lb 0\rb}} and this has been |
| 85 |
used to line up the digits of the entries in both columns. It is also |
| 86 |
possible to change the definition of the \cs{TableItem} macro so that each |
| 87 |
entry in each column is left or right justified. This is described a |
| 88 |
little bit later. |
| 89 |
|
| 90 |
Something to note about this example table is that the outer |
| 91 |
rules are thicker than the others. You can also get a thick |
| 92 |
vertical rule between columns by using ``{\tt\bs\VT}'' in place of |
| 93 |
``{\tt\VT}'', and you can get a thick horizontal rule below a row by |
| 94 |
replacing the \cs{cr} with \cs{crthick}. The widths of thick and |
| 95 |
thin rules are controlled by the dimensions \cs{thicksize} and |
| 96 |
\cs{thinsize}. If you don't want thick rules at all simply say |
| 97 |
|\thicksize=\thinsize|, which makes the thick rules as thin |
| 98 |
as the thin rules. |
| 99 |
|
| 100 |
Some synonyms: \cs{CR} is the same as \cs{crthick}, \cs{nr} is the |
| 101 |
same as \cs{crnorule}, and \cs{crrule} is the same as \cs{cr} (actually |
| 102 |
it's the other way around). \cs{tab} is the same as |&|\index{&@{\tt \&}} |
| 103 |
--- it separates columns without a vertical rule. \cs{vb} is the same as |
| 104 |
{\tt\VT}, it separates columns with a thin vertical bar, while |
| 105 |
\cs{Vb} is the same as {\tt\bs\VT} and separates the columns with a |
| 106 |
thick vertical bar. You can also use \cs{dbl} to separate columns |
| 107 |
with a double vertical rule. |
| 108 |
|
| 109 |
As in Plain \TeX\ you can use \cs{span} in place of |
| 110 |
|&|\index{&@{\tt \&}} (or the other column separators) to join two |
| 111 |
columns together into one, and you can use \cs{omit} as the very first |
| 112 |
token in a column to tell it to omit the fancy column layout (the |
| 113 |
centering or other spacing). |
| 114 |
You can also use \cs{multispan} to \cs{span} and \cs{omit} several |
| 115 |
columns, just as in an \cs{halign}. |
| 116 |
The only difference is that the number of columns you tell it to |
| 117 |
\cs{multispan} is the number of columns of the table it spans --- in a |
| 118 |
ruled table constructed with \cs{halign} you would count the columns |
| 119 |
{\sl and} any vertical rules (because the rules are also columns of |
| 120 |
the \cs{halign}). |
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
\table{example-II} |
| 125 |
\caption{Another example of a ruled table.} |
| 126 |
\intablelist{Example of a ruled table --- AT\&T Common Stock.} |
| 127 |
\singlespaced |
| 128 |
\tenpoint |
| 129 |
\ruledtable |
| 130 |
\multispan3\hfil AT\&T Common Stock \hfil\CR |
| 131 |
Year \dbl Price | Dividend \cr |
| 132 |
1971 \dbl 41-54 | \$2.60 \cr |
| 133 |
~~~2 \dbl 41-54 | \$2.70 \cr |
| 134 |
~~~3 \dbl 46-55 | \$2.87 \cr |
| 135 |
~~~4 \dbl 40-53 | \$3.24 \cr |
| 136 |
~~~5 \dbl 45-52 | \$3.40 \cr |
| 137 |
~~~6 \dbl 51-59 | ~~.95 |
| 138 |
\endruledtable |
| 139 |
\endtable |
| 140 |
|
| 141 |
\Tbl{example-II} is another sample table, again taken |
| 142 |
{from} \TeXbook. Something important to notice is that the last |
| 143 |
ruled table example didn't have a table number or a caption, |
| 144 |
while this one does. That's because the last example was created |
| 145 |
using just \cs{ruledtable}, while this example is inside of |
| 146 |
\cs{table}. The point is that \cs{table} and \cs{ruledtable} do |
| 147 |
separate things and can be used either separately or together; |
| 148 |
\cs{table} creates the space for the table and gives it a caption |
| 149 |
and a number, while \cs{ruledtable} actually constructs the body of |
| 150 |
the ruled table. The instructions that created \Tbl{example-II} |
| 151 |
are: |
| 152 |
\smallskip\goodbreak |
| 153 |
\TeXexample |
| 154 |
|smalltt\table{example-II} |
| 155 |
\caption{Another example of a ruled table.} |
| 156 |
\singlespaced |
| 157 |
\ruledtable |
| 158 |
\multispan3\hfil AT\&T Common Stock \hfil\CR |
| 159 |
Year \dbl Price |VT Dividend \cr |
| 160 |
1971 \dbl 41-54 |VT \$2.60 \cr |
| 161 |
~~~2 \dbl 41-54 |VT \$2.70 \cr |
| 162 |
~~~3 \dbl 46-55 |VT \$2.87 \cr |
| 163 |
~~~4 \dbl 40-53 |VT \$3.24 \cr |
| 164 |
~~~5 \dbl 45-52 |VT \$3.40 \cr |
| 165 |
~~~6 \dbl 51-59 |VT ~~.95 |
| 166 |
\endruledtable |
| 167 |
\endtable |
| 168 |
|endTeXexample |
| 169 |
\bigskip\goodbreak |
| 170 |
|
| 171 |
\table{SiHCl} |
| 172 |
\caption{Parameters used in the MS-X$\alpha$ calculations for |
| 173 |
the chlorosilane molecules, H$_{\rm x}$SiCl$_{\rm 4-x}$; |
| 174 |
x=0--4.} |
| 175 |
\intablelist{Example of a ruled table --- Parameters used in the |
| 176 |
MS-X$\alpha$ calculations for the chlorosilane molecules, |
| 177 |
H$_{\rm x}$SiCl$_{\rm 4-x}$; x=0--4.} |
| 178 |
\singlespaced |
| 179 |
\tenpoint |
| 180 |
\ruledtable |
| 181 |
\vctr{Molecule} | \vctr{Region} | Radius | |
| 182 |
\vctr{$\alpha _{\rm HF}$}|\multispan{2} $l_{\rm max}$ \crnorule |
| 183 |
\cskip | \cskip | \cskip |\cskip| \crule | \crule \crpart |
| 184 |
| | (au) | | initial state | final state \CR |
| 185 |
|
| 186 |
SiCl$_4$ | outersphere | 6.21 | 0.7238 | 4 | 7\crnorule |
| 187 |
| Si | 2.20 | 0.7275 | 2 | 3\crnorule |
| 188 |
| Cl | 2.40 | 0.7233 | 2 | 3\cr |
| 189 |
|
| 190 |
SiHCl$_3$ | outersphere | 6.21 | 0.7260 | 4 | 7\crnorule |
| 191 |
| Si | 2.16 | 0.7275 | 2 | 3\crnorule |
| 192 |
| Cl | 2.40 | 0.7233 | 2 | 3\crnorule |
| 193 |
| H | 1.20 | 0.7772 | 1 | 2\cr |
| 194 |
|
| 195 |
SiH$_2$Cl$_2$ | outersphere | 6.25 | 0.7295 | 4 | 7\crnorule |
| 196 |
| Si | 2.20 | 0.7275 | 2 | 3\crnorule |
| 197 |
| Cl | 2.40 | 0.7233 | 2 | 3\crnorule |
| 198 |
| H | 1.20 | 0.7772 | 1 | 2\cr |
| 199 |
|
| 200 |
SiH$_3$Cl | outersphere | 6.30 | 0.7360 | 4 | 7\crnorule |
| 201 |
| Si | 2.20 | 0.7275 | 2 | 3\crnorule |
| 202 |
| Cl | 2.40 | 0.7233 | 2 | 3\cr |
| 203 |
|
| 204 |
SiH$_4$ | outersphere | 4.10 | 0.7524 | 4 | 7 \crnorule |
| 205 |
| Si | 2.04 | 0.7275 | 2 | 3 \crnorule |
| 206 |
| H | 1.20 | 0.7772 | 1 | 2 |
| 207 |
\endruledtable |
| 208 |
\bigskip\bigskip |
| 209 |
\endtable |
| 210 |
|
| 211 |
Sometimes it is desirable to have rules across only some of the columns |
| 212 |
of a table. In this case put \cs{crule} in the columns that are to have |
| 213 |
rules, \cs{cskip} in the columns where no rules are desired, and |
| 214 |
end the line with \cs{crpart}, which signals that the line contains a |
| 215 |
partial rule. The column headings in \Tbl{SiHCl} are an example of |
| 216 |
partial rules in a table. |
| 217 |
That table was created with the commands,\reference{Bozek, 1991} |
| 218 |
J.D.~Bozek, Ph.D. thesis (unpublished), Department of Chemistry, |
| 219 |
University of Western Ontario, London, Ontario CANADA |
| 220 |
\endreference\relax |
| 221 |
\TeXexample |
| 222 |
|smalltt\table{SiHCl} |
| 223 |
\caption{...} |
| 224 |
\singlespaced\tenpoint |
| 225 |
\ruledtable |
| 226 |
\vctr{Molecule} |VT \vctr{Region} |VT Radius |VT |
| 227 |
\vctr{$\alpha _{\rm HF}$}|VT\multispan{2} $l_{\rm max}$ |
| 228 |
\crnorule |
| 229 |
\cskip |VT \cskip |VT \cskip |VT\cskip|VT \crule |VT \crule \crpart |
| 230 |
|VT |VT (au) |VT |VT initial state |VT final state \CR |
| 231 |
SiCl$_4$ |VT outersphere |VT 6.21 |VT 0.7238 |VT 4 |VT 7 \crnorule |
| 232 |
|VT Si |VT 2.20 |VT 0.7275 |VT 2 |VT 3 \crnorule |
| 233 |
|VT Cl |VT 2.40 |VT 0.7233 |VT 2 |VT 3 ... |
| 234 |
... |
| 235 |
\endruledtable |
| 236 |
\endtable |
| 237 |
|endTeXexample |
| 238 |
\bigskip\goodbreak |
| 239 |
|
| 240 |
|
| 241 |
Ruled tables are normally centered on the page, but you can turn |
| 242 |
off the centering with \cs{noncenteredtables}. |
| 243 |
Then the table becomes just another piece to add to a horizontal list. |
| 244 |
One thing this lets you do is have two tables side by side on the |
| 245 |
page, like so: |
| 246 |
\nobreak |
| 247 |
\noncenteredtables\index{ruled tables!centered} |
| 248 |
\bigskip |
| 249 |
\line{\tenpoint\ruledtable |
| 250 |
Item ABC | Item DEF \cr |
| 251 |
Item GHI | Item JKL \endruledtable |
| 252 |
\hfil |
| 253 |
\ruledtable |
| 254 |
Data 111 | Data 222 \cr |
| 255 |
Data 333 | Data 444 \cr |
| 256 |
Data 555 | Data 666 \endruledtable} |
| 257 |
\bigskip |
| 258 |
\pagecheck{5\baselineskip} |
| 259 |
\noindent |
| 260 |
This pair of tables was produced by saying: |
| 261 |
\TeXexample |
| 262 |
|smalltt\noncenteredtables |
| 263 |
\medskip |
| 264 |
\line{\ruledtable |
| 265 |
Item ABC |VT Item DEF \cr |
| 266 |
Item GHI |VT Item JKL \endruledtable |
| 267 |
\hfil |
| 268 |
\ruledtable |
| 269 |
Data 111 |VT Data 222 \cr |
| 270 |
Data 333 |VT Data 444 \cr |
| 271 |
Data 555 |VT Data 666 \endruledtable} |
| 272 |
\smallskip |
| 273 |
|endTeXexample |
| 274 |
\noindent Saying \cs{centeredtables} turns table centering back on. |
| 275 |
Tables are then centered across the page, and a table is then |
| 276 |
added to a {\sl vertical\/} list. |
| 277 |
\bigskip\goodbreak |
| 278 |
|
| 279 |
Usually \cs{ruledtable} makes tables as wide as their natural |
| 280 |
width, but it is possible to make them wider by setting the dimension |
| 281 |
\cs{tablewidth} to the width desired before saying \cs{ruledtable}. We can |
| 282 |
make the same table in \Tbl{example-II} but with the width set to |
| 283 |
10cm: \index{ruled tables!size} |
| 284 |
\bigskip |
| 285 |
\noncenteredtables |
| 286 |
\tablewidth=10cm |
| 287 |
\line{\tenpoint\hfil\vbox{\singlespaced |
| 288 |
\ruledtable |
| 289 |
\multispan3\hfill AT\&T Common Stock \hfill\CR |
| 290 |
Year \dbl Price | Dividend \cr |
| 291 |
1971 \dbl 41-54 | \$2.60 \cr |
| 292 |
~~~2 \dbl 41-54 | \$2.70 \cr |
| 293 |
~~~3 \dbl 46-55 | \$2.87 \cr |
| 294 |
~~~4 \dbl 40-53 | \$3.24 \cr |
| 295 |
~~~5 \dbl 45-52 | \$3.40 \cr |
| 296 |
~~~6 \dbl 51-59 | ~~.95\rlap* |
| 297 |
\endruledtable |
| 298 |
\hbox{* (first quarter only)} |
| 299 |
\vss}\hfil} |
| 300 |
\smallskip |
| 301 |
\noindent |
| 302 |
The careful reader will notice that the version of |
| 303 |
\Tbl{example-II} in \TeXbook\ had a footnote to the last entry, |
| 304 |
and we have added that here. To do so we had to put the footnote in an |
| 305 |
\cs{hbox} and stack it under the table, so we had to turn off table |
| 306 |
centering. The table is therefore a bit more complicated to make, but |
| 307 |
not much: \index{ruled tables!footnotes} |
| 308 |
\TeXexample |
| 309 |
|smalltt\noncenteredtables |
| 310 |
\tablewidth=10cm |
| 311 |
\line{\tenpoint\hfil\vbox{\singlespaced |
| 312 |
\ruledtable |
| 313 |
\multispan3\hfill AT\&T Common Stock \hfill\CR |
| 314 |
Year \dbl Price |VT Dividend \cr |
| 315 |
1971 \dbl 41-54 |VT \$2.60 \cr |
| 316 |
~~~2 \dbl 41-54 |VT \$2.70 \cr |
| 317 |
~~~3 \dbl 46-55 |VT \$2.87 \cr |
| 318 |
~~~4 \dbl 40-53 |VT \$3.24 \cr |
| 319 |
~~~5 \dbl 45-52 |VT \$3.40 \cr |
| 320 |
~~~6 \dbl 51-59 |VT ~~.95\rlap* |
| 321 |
\endruledtable |
| 322 |
\hbox{* (first quarter only)} |
| 323 |
\vss}\hfil} |
| 324 |
|endTeXexample |
| 325 |
\centeredtables % turn back on! |
| 326 |
\noindent |
| 327 |
If we had not wanted to add the footnote, then the table would have |
| 328 |
been typed the same way as \Tbl{example-II} except for setting |
| 329 |
the \cs{tablewidth}. |
| 330 |
|
| 331 |
Important note: \cs{tablewidth} is turned ``off'' after the |
| 332 |
table is made, so the next table will have its natural width unless |
| 333 |
you explicitly set \cs{tablewidth} again! \index{ruled tables!size} |
| 334 |
\bigskip\goodbreak |
| 335 |
|
| 336 |
\cs{ruledtable} normally inserts a \cs{quad} of space around each |
| 337 |
item. If you have a very wide table, especially one with many columns, |
| 338 |
you may wish to reduce this. \cs{TightTables} make this spacing a single |
| 339 |
space, the minimum acceptable. \cs{LooseTables} restores the default |
| 340 |
spacing. You can define this space to be something else by |
| 341 |
re-defining \cs{tablespace}, for example as \index{ruled tables!spacing} |
| 342 |
\TeXexample |
| 343 |
\def\tablespace{\ \ } |
| 344 |
|endTeXexample |
| 345 |
\noindent |
| 346 |
If the table is still too wide with \cs{TightTables}, you will probably |
| 347 |
have to reformat it or print it in landscape mode (tilted 90\degrees on |
| 348 |
the page). |
| 349 |
\bigskip\goodbreak |
| 350 |
|
| 351 |
|
| 352 |
The careful reader may also have noticed that in the |
| 353 |
examples in \Tbl{example-II} and \Tbl{SiHCl} we said |
| 354 |
\cs{singlespaced}. That's |
| 355 |
because the spacing of the rows of a table can be controlled just like |
| 356 |
the spacing of the text with \cs{singlespaced}, \cs{doublespaced}, |
| 357 |
etc. \index{ruled tables!spacing} |
| 358 |
The space between the rows of a table is set by a strut called |
| 359 |
\cs{tstrut}, which holds the rows apart. Its default definition is |
| 360 |
\TeXexample |
| 361 |
\def\tstrut{\vrule height 3.1ex depth 1.2ex width 0pt} |
| 362 |
|endTeXexample |
| 363 |
\noindent |
| 364 |
You can change the spacing between rows by changing the definition of |
| 365 |
this strut. One of the things \cs{singlespaced} does is define the |
| 366 |
\cs{tstrut} to be 0.5ex higher and deeper than a parenthesis. |
| 367 |
\cs{doublespaced}, \cs{triplespaced}, and \cs{widenspacing} all increase the |
| 368 |
height and depth of the strut in proportion to the increase in the |
| 369 |
baseline spacing. |
| 370 |
|
| 371 |
If you put something in a table which is larger than the strut, |
| 372 |
then it will touch the rules above or below. You can fix this by |
| 373 |
inserting your own strut into that row. More simply, you can say |
| 374 |
\cs{bigitem}\arg{stuff}, and the ``stuff'' will be positioned correctly |
| 375 |
with a nice amount of space above and below. \index{ruled tables!spacing} |
| 376 |
\medskip |
| 377 |
|
| 378 |
You can also decide whether or not you want diagnostic messages |
| 379 |
printed when a table is created. Saying \cs{tableinfotrue} causes a |
| 380 |
message to be printed on your terminal every time a ruled table is |
| 381 |
created. The message tells you how many rows and columns were in the |
| 382 |
table. This is useful information, because it can tell you immediately |
| 383 |
if you made a mistake in the table or left out a row or column. |
| 384 |
\cs{tableinfotrue} is the default, but you can turn off these messages |
| 385 |
by saying |
| 386 |
\cs{tableinfofalse}. In any case, you will be warned if a row has a |
| 387 |
different number of columns from the previous one. |
| 388 |
\medskip |
| 389 |
|
| 390 |
The tables we have demonstrated so far all contain numbers, but |
| 391 |
sometimes it is desirable to have an entry in a table which is a |
| 392 |
paragraph of text. \index{ruled tables!text} For that purpose, you can |
| 393 |
use \cs{para}\arg{text}. The width of the paragraph is determined by |
| 394 |
the dimension \cs{parasize}, which defaults to 4 inches. |
| 395 |
\medskip |
| 396 |
|
| 397 |
Tables \use{Tb.tablemac;a} and \use{Tb.tablemac;b} summarize the most |
| 398 |
important commands for making ruled tables. |
| 399 |
|
| 400 |
Finally, we can discuss how you can change how each column of |
| 401 |
a table is constructed. The macros which build the table take |
| 402 |
each entry and pass it to a macro called \cs{TableItem}. The |
| 403 |
default definition of \cs{TableItem} is: |
| 404 |
\vskip 0pt\goodbreak |
| 405 |
\TeXexample |
| 406 |
|smalltt\def\TableItem#1{% % centers item in ruled table |
| 407 |
\hfil\tablespace % left glue |
| 408 |
#1\killspace % item, no space after |
| 409 |
\tablespace\hfil % right glue |
| 410 |
}% |
| 411 |
|endTeXexample |
| 412 |
|
| 413 |
|
| 414 |
%% TABLE A |
| 415 |
|
| 416 |
\bottomtable{tablemac;a} |
| 417 |
\caption{Basic table macros for use with {\tt\bs ruledtable}.}% |
| 418 |
\intablelist{Basic macros for {\tt\bs ruledtable}}% |
| 419 |
\tablewidth=\hsize |
| 420 |
\LeftJustifyTables |
| 421 |
\ruledtable |
| 422 |
\sl Macro name\relax |
| 423 |
| \sl Description \relax \crthick |
| 424 |
\tt\bs ruledtable\relax |
| 425 |
| \para{Starts a ruled table.}\cr |
| 426 |
\vtop{\noindent\hsize=1.6in\normalbaselines |
| 427 |
\tt\char124\quad \rm (vertical bar)\hfil\break |
| 428 |
or \tt\bs vb\hfil}\relax |
| 429 |
| \para{Separates one column from the next, with a |
| 430 |
a thin vertical rule between them.}\cr |
| 431 |
\tt\&\ \rm or\tt\ \bs tab \relax |
| 432 |
| \para{Separates one column from the next, but with |
| 433 |
no rule between them.}\cr |
| 434 |
\tt\bs cr\relax |
| 435 |
| \para{Ends the current row, and starts the next |
| 436 |
one. The completed row will be separated from |
| 437 |
the next with a thin horizontal rule.}\cr |
| 438 |
\vtop{\noindent\hsize=1.6in\normalbaselines |
| 439 |
\tt\bs crthick \hfil\break \rm or \tt\bs CR\hfil }\relax |
| 440 |
| \para{Similar to {\tt\bs cr}, but the rows will |
| 441 |
be separated with a thick horizontal rule.}\cr |
| 442 |
\vtop{\noindent\hsize=1.6in\normalbaselines |
| 443 |
\tt\bs crnorule \hfil\break \rm or \tt\bs nr\hfil }\relax |
| 444 |
| \para{Similar to {\tt\bs cr}, but the rows will |
| 445 |
not be separated by a rule.}\cr |
| 446 |
\tt\bs\char124 \relax |
| 447 |
| \para{Same as {\tt\char124}, but with a thick vertical rule.}\cr |
| 448 |
\tt\bs dbl |
| 449 |
| \para{Same as {\tt\char124}, but with two thin vertical rules.}\cr |
| 450 |
\tt\bs endruledtable\relax |
| 451 |
| \para{Ends the ruled table.}% |
| 452 |
\endruledtable |
| 453 |
\line{\hfil {\sl Continued...}}% |
| 454 |
\endtable |
| 455 |
|
| 456 |
%% TABLE B (FULL PAGE) |
| 457 |
|
| 458 |
\fulltable{tablemac;b} |
| 459 |
\caption{Additional macros for use with {\tt\bs ruledtable}.} |
| 460 |
\intablelist{Additional macros for {\tt\bs ruledtable}} |
| 461 |
\tablewidth=\hsize |
| 462 |
\LeftJustifyTables |
| 463 |
\line{{\sl Continued...}\hfil} |
| 464 |
\smallskip |
| 465 |
\ruledtable |
| 466 |
\sl Macro name\relax |
| 467 |
| \sl Description \relax \crthick |
| 468 |
\tt\bs multispan\lb{\it n}\rb\relax |
| 469 |
| \para{Makes the next entry span the next $n$ |
| 470 |
columns, where $n$ is an integer, $n>0$. |
| 471 |
See {\tt\bs omit} below.} \cr |
| 472 |
\tt\bs omit \relax |
| 473 |
| \para{This \TeX\ primitive causes the normal |
| 474 |
template for its entry to be omitted, allowing |
| 475 |
the user to do something else with this entry.} \cr |
| 476 |
\tt\bs para\arg{text}\relax |
| 477 |
| \para{Formats {\sl text\/} into a neat little |
| 478 |
paragraph like this one. The width of the |
| 479 |
paragraph produced is determined by the dimension |
| 480 |
{\tt\bs parasize}. The default is 4 inches. } \cr |
| 481 |
\tt\bs parasize=\meta{dimen} \relax |
| 482 |
| \para{Sets the width of paragraphs for the {\tt\bs para} |
| 483 |
macro.} \cr |
| 484 |
\tt\bs TableItem\arg{stuff}\relax |
| 485 |
| \para{Used in the standard template, this |
| 486 |
macro centers its argument in the column. The |
| 487 |
user can redefine it for special effects.} \cr |
| 488 |
\tt\bs tablespace |
| 489 |
| \para{The spacing around each item for {\tt\bs TableItem}.}\cr |
| 490 |
\vtop{\noindent\hsize=1.4in\normalbaselines |
| 491 |
\tt\bs LooseTables \hfil\break |
| 492 |
\tt\bs TightTables\hfil}\relax |
| 493 |
| \para{Set {\tt\bs tablespace} to {\tt\bs quad} and {\tt\bs\ } |
| 494 |
respectively.\hfill\break\ }\cr |
| 495 |
\vtop{\noindent\hsize=1.6in\normalbaselines |
| 496 |
\tt\bs TrailingSpaces \hfil\break |
| 497 |
\tt\bs NoTrailingSpaces \hfil}\relax |
| 498 |
| \para{Use trailing spaces and glue items in table entries |
| 499 |
(default) or ignore them. See text.}\cr |
| 500 |
\tt\bs bigitem\arg{stuff}\relax |
| 501 |
| \para{Use this for something that would normally |
| 502 |
not fit in one line of a table to make the spacing |
| 503 |
between rows large enough for this item.} \cr |
| 504 |
\tt\bs vctr\arg{stuff}\relax |
| 505 |
| \para{Centers the item {\sl vertically\/} so that |
| 506 |
it can appear between two rows.}\cr |
| 507 |
\tt\bs centeredtables\relax |
| 508 |
| \para{Turns table centering on. Each table |
| 509 |
will be centered left-to-right on the page. |
| 510 |
This is the default.} \cr |
| 511 |
\tt\bs noncenteredtables\relax |
| 512 |
| \para{Turns table centering off. Each table |
| 513 |
is returned as an {\tt\bs hbox}, and it is up |
| 514 |
to the user to place it as desired.} \cr |
| 515 |
\vtop{\noindent\hsize=1.6in\normalbaselines |
| 516 |
\tt\bs tableinfotrue \hfil\break |
| 517 |
\tt\bs tableinfofalse\hfil}\relax |
| 518 |
| \para{Turns on or off the diagnostic message telling |
| 519 |
you how many rows and columns were found in the |
| 520 |
table. }\cr |
| 521 |
\tt\bs thicksize=\meta{dimen} \relax |
| 522 |
| \para{This dimension specifies the thickness |
| 523 |
of the thick rules in the table. The default |
| 524 |
size is 1.5 points.} \cr |
| 525 |
\tt\bs thinsize=\meta{dimen} \relax |
| 526 |
| \para{This dimension specifies the thickness |
| 527 |
of thin rules in the table. The default |
| 528 |
size is 0.8 points.} \cr |
| 529 |
\tt\bs tablewidth=\meta{dimen} \relax |
| 530 |
| \para{Specifies how wide to make the next |
| 531 |
table. If not specified, the table is made to |
| 532 |
its natural width. This value is reset |
| 533 |
following the construction of each table.} |
| 534 |
\endruledtable |
| 535 |
\vfill |
| 536 |
\endtable |
| 537 |
|
| 538 |
|
| 539 |
The \cs{hfil} glue on both sides of the argument causes the item to be |
| 540 |
centered in the column, while \cs{tablespace} (which defaults to \cs{quad}) |
| 541 |
insures that there will be at least some amount of space between the |
| 542 |
item and the vertical rules on each side. Because of the way that |
| 543 |
\TeX\ handles macro arguments, if you type a table with spaces between |
| 544 |
the text and the next column separator, an extra \cs{space} will be |
| 545 |
inserted into the table. If you first say \cs{NoTrailingSpaces}, then |
| 546 |
\cs{killspace} in the above macro is defined to remove any trailing glue |
| 547 |
items. \cs{hfill} is redefined by the table macros so that if it is the |
| 548 |
last token in an entry, then that entry is properly left justified, |
| 549 |
but to insert any other trailing glue, you must say |
| 550 |
\example |
| 551 |
\meta{text}\meta{glue}|\null| |
| 552 |
\endexample |
| 553 |
\noindent |
| 554 |
The default is \cs{TrailingSpaces}, which does incorporate any trailing |
| 555 |
spaces into the table but which also treats any trailing glue items |
| 556 |
normally. |
| 557 |
|
| 558 |
|
| 559 |
You can change the definition of \cs{TableItem} to suit your own |
| 560 |
purpose. The simplest modification is to omit the \cs{hfil} on the left |
| 561 |
or right so that each entry is right or left justified. This is so |
| 562 |
commonly used that saying \cs{RightJustifyTables} or |
| 563 |
\cs{LeftJustifyTables} makes the appropriate change for you. Saying |
| 564 |
\cs{NoJustifyTables} restores \cs{TableItem} to its original centering |
| 565 |
function. \index{ruled tables!customization} |
| 566 |
|
| 567 |
Since \cs{TableItem} is used to create every column of the table, you |
| 568 |
cannot use it to modify a single column. To justify just one column |
| 569 |
you can simply put \cs{hfill} to the left or right of each item in the |
| 570 |
column, since \cs{hfill} is infinitely more stretchy than \cs{hfil}. (The |
| 571 |
behavior of glue items other than \cs{hfill} depends on whether |
| 572 |
\cs{NoTrailingSpaces} has been set.) With a little more work it is |
| 573 |
possible to design special or unusual tables by redefining the |
| 574 |
``preamble'' of the table. This is possible because \cs{ruledtable} |
| 575 |
uses \cs{halign} with a preamble called \cs{TablePreamble}. The default |
| 576 |
definition of \cs{TablePreamble} is: |
| 577 |
\TeXexample |
| 578 |
\def\TablePreamble{% % \ruledtable preamble |
| 579 |
\TableItem{####}% % the first item |
| 580 |
\plaintab\plaintab % && means repeat this |
| 581 |
\TableItem{####}% % the subsequent items |
| 582 |
\plaincr}% % end of preamble |
| 583 |
|endTeXexample |
| 584 |
\noindent |
| 585 |
The syntax for \cs{TablePreamble} is like an \cs{halign} preamble in Plain |
| 586 |
\TeX\, but with |&| replaced by \cs{plaintab}, \cs{cr} replaced by |
| 587 |
\cs{plaincr}, and |#| replaced by |####|. If you have read this far and |
| 588 |
want to try changing \cs{TablePreable} then you should read the source |
| 589 |
code and the comments that go with it in the file |TXSruled.tex.| |
| 590 |
|
| 591 |
As a final note we point out that it is also possible for you to create |
| 592 |
your own column separators with the macro \cs{nextcolumn}. This macro |
| 593 |
takes a single argument which is used to separate one column of the |
| 594 |
table from another. Thus for example, the \cs{dbl} macro for creating a |
| 595 |
double vertical rule between columns is defined as: |
| 596 |
\TeXexample |
| 597 |
\def\dbl{% |
| 598 |
\nextcolumn{\vrule width\thinsize |
| 599 |
\hskip\thinsize\vrule width\thinsize}} |
| 600 |
|endTeXexample |
| 601 |
\relax |
| 602 |
\index{ruled tables!customization} |
| 603 |
|
| 604 |
%>>> EOF TXSruled.doc <<< |