summaryrefslogtreecommitdiff
path: root/macros/latex209/contrib/tables/tables.sty
blob: 0b40afab6e90f528fc92d04fc642c914b40974b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
%  modified by Bob Taylor for University of Rochester 20-Mar-87:
%  \line macro in Cowan's code is disabled by LaTeX, so I've
%  changed all instances of \line in Cowan's code to the new
%  definition \tableline as defined right after this comment.
%
   \def\tableline{\hbox to \hsize}
%
% +--------------------------------------------------------------------+
% ]                                                                    ]
% ]                           TABLES.TEX                               ]
% ]                                                                    ]
% ]                     Ray F. Cowan  15-Feb-85                        ]
% ]                                                                    ]
% ]                       Princeton University                         ]
% ]                                                                    ]
% ]                     Last Revision: 21-Nov-85                       ]
% ]                                                                    ]
% ]   Macros I find handy for making tables.  See TABLEDOC TEX for     ]
% ]   a longer description.  The token-counting macros are straight    ]
% ]   from the TeXbook's "Dirty Tricks" appendix.                      ]
% ]                                                                    ]
% +--------------------------------------------------------------------+
%
\newbox\hdbox%
\newcount\hdrows%
\newcount\multispancount%
\newcount\ncase%
\newcount\ncols% This is the number of primary text columns in the table.
\newcount\nrows%
\newcount\nspan%
\newcount\ntemp%
\newdimen\hdsize%
\newdimen\newhdsize%
\newdimen\parasize%
\newdimen\spreadwidth%
\newdimen\thicksize%
\newdimen\thinsize%
\newdimen\tablewidth%
\newif\ifcentertables%
\newif\ifendsize%
\newif\iffirstrow%
\newif\iftableinfo%
\newtoks\dbt%
\newtoks\hdtks%
\newtoks\savetks%
\newtoks\tableLETtokens%
\newtoks\tabletokens%
\newtoks\widthspec%
%
%  Book-keeping stuff--see how often these macros are called.
%
%\immediate\write15{%
%CP SMSG GJMSINK TEXTABLE --> TABLE MACROS V. 851121 JOB = \jobname%
%}%
%
%  Turn on table diagnostics.
%
\tableinfotrue%
\catcode`\@=11%  Allows use of "@" in macro names, like PLAIN.TEX does.
\def\out#1{\immediate\write16{#1}}%  Debugging aid.  Writes #1 on the
%                                    user's terminal and in the log file.
%
%  Define the \tstrut height, depth in terms of the x_height parameter.
%
\def\tstrut{\vrule height3.1ex depth1.2ex width0pt}%
\def\and{\char`\&}%  Allows us to get an `&' in the text.  This is the
%                    same as using the PLAIN TeX macro \&.
\def\tablerule{\noalign{\hrule height\thinsize depth0pt}}%
\thicksize=1.5pt%  Default thickness for fat rules.  The user should feel
%                  free to change this to his preference.
\thinsize=0.6pt%   Default thickness for thin rules.
\def\thickrule{\noalign{\hrule height\thicksize depth0pt}}%
\def\hrulefill{\leaders\hrule\hfill}%
\def\bigrulefill{\leaders\hrule height\thicksize depth0pt \hfill}%
\def\ctr#1{\hfil\ #1\hfil}%
\def\altctr#1{\hfil #1\hfil}%
\def\vctr#1{\hfil\vbox to0pt{\vss\hbox{#1}\vss}\hfil}%
%
%  Here are things for controlling the width of the finished table.
%
\tablewidth=-\maxdimen%
\spreadwidth=-\maxdimen%
\def\tabskipglue{0pt plus 1fil minus 1fil}%
%
%  Stuff for centering or not.
%
\centertablestrue%
\def\centeredtables{%
   \centertablestrue%
}%
\def\noncenteredtables{%
   \centertablesfalse%
}%
%
%  \vctr vertically centers its argument in the row.
%
\parasize=4in%
\long\def\para#1{%  Used to make little paragraphs out of one entry.
   {%
      \vtop{%
         \hsize=\parasize%
         \baselineskip14pt%
         \lineskip1pt%
         \lineskiplimit1pt%
         \noindent #1%
         \vrule width0pt depth6pt%
      }%
   }%
}%
%
\gdef\ARGS{########}%  Produces the correct number of #'s in the preamble
%                      by the time eveything is expanded and \halign sees
%                      it.
\gdef\headerARGS{####}%  Same as \ARGS, but used in \header macros.
\def\@mpersand{&}%  Allows us to get alignment tab characters later
%                   when we have made the character "&" an active macro.
{\catcode`\|=13%  Make |'s locally active.
\gdef\letbarzero{\let|0}%  Globally define a macro that allows us to
%                          keep active |'s from being expanded in edef's.
\gdef\letbartab{\def|{&&}}%
\gdef\letvbbar{\let\vb|}%
%  This \def will cause active |'s read by
%                            \ruledtable to be converted into double
%                            alignment tabs.
}%  End of locally active |'s.
%
{\catcode`\&=4%  Make these alignment tabs.
\def\ampskip{&\omit\hfil&}%  This local macro skips a vertical rule.
\catcode`\&=13%  Now make &'s into active macros.
\let&0%  This allows us to expand \ampskip in the next \xdef without
%        attempting to expand the & and getting an "undefined control
%        sequence" error.
\xdef\letampskip{\def&{\ampskip}}%
\gdef\letnovbamp{\let\novb&\let\tab&}
%  This will cause active &'s read by
%                                   \ruledtable to be converted into
%                                   double tabs and an \omit'ted \vrule.
}%  End of locally active &'s.
%
\def\begintable{%  Here we make |'s and &'s active characters so we can
%                  interpret them as macros.  Note that this action is
%                  true only until we encounter the matching \endgroup
%                  token later at the end of the \ruledtable macro.
   \begingroup%
   \catcode`\|=13\letbartab\letvbbar%
   \catcode`\&=13\letampskip\letnovbamp%
   \def\multispan##1{%  We must redefine \multispan to count the number
%                       of primary columns, not physical columns.
      \omit \mscount##1%
      \multiply\mscount\tw@\advance\mscount\m@ne%
      \loop\ifnum\mscount>\@ne \sp@n\repeat%
   }%  End of \multispan macro.
   \def\|{%
      &\omit\widevline&%
   }%
   \ruledtable%  Now we call \ruledtable to do the real work.
}%  End of \begintable macro.
%
\long\def\ruledtable#1\endtable{%
%
%  This macro reads in the user's data entries
%  and converts them into a ruled table.
%
%  Important note:  Many macros and parameters are re-defined here, and
%  these must be kept local to the table macros to avoid conflict with
%  their use outside of tables.  This is done by the \begingroup token
%  macro \begintable and the \endgroup token at the end of
%  this macro.
%
   \offinterlineskip%  Needed to make rules touch each other.
   \tabskip 0pt%  Needed for same reason as \offinterlineskip.
   \def\widevline{\vrule width\thicksize}%  Make outer \vrule's wider.
   \def\endrow{\@mpersand\omit\hfil\crnorm\@mpersand}%
   \def\crthick{\@mpersand\crnorm\thickrule\@mpersand}%
   \def\crnorule{\@mpersand\crnorm\@mpersand}%
   \let\nr=\crnorule%  A shorter abbreviation.
   \def\endtable{\@mpersand\crnorm\thickrule}%
%
   \let\crnorm=\cr%  Allows us to use \cr for our own purposes.
%
%  Cause user-typed \cr's to follow a row with a \tablerule.
%
   \edef\cr{\@mpersand\crnorm\tablerule\@mpersand}%
%
   \the\tableLETtokens%  Get the user's extra \let's, if any.
%
%  Put the data entries into a token register so we can scan through them
%  and see what the user is asking us to do.
%
   \tabletokens={&#1}%  We add an extra alignment tab to the beginning
%                       of the first row to allow for the first \vrule.
%
%  Now count how many rows are in the table and return the result in
%  count register \nrows; do the same for columns, and return that
%  in register \ncols.
%
   \countROWS\tabletokens\into\nrows%
   \countCOLS\tabletokens\into\ncols%
%
%  Now do a little arithmetic to convert the number of primary columns
%  into the number of physical columns that the alignment preamble must
%  prepare for;  similarly for rows.
%
   \advance\ncols by -1%
   \divide\ncols by 2%
   \advance\nrows by 1%
%
%  Tell the user how many rows and columns we found in his data, if he
%  wants to know.
%
   \iftableinfo %
      \immediate\write16{[Nrows=\the\nrows, Ncols=\the\ncols]}%
   \fi%
%
%  Now we actually go ahead and produce the table.
%
   \ifcentertables
      \ifhmode \par\fi%  Make sure we are in vertical mode.
      \tableline{%  The final table comes out as an \hbox of width the \hsize.
      \hss%  The final table will be centered left-to-right.
   \else %
      \hbox{%
   \fi
      \vbox{%
         \makePREAMBLE{\the\ncols}%  Generate the preamble.
         \edef\next{\preamble}%  This line and the next line force the
         \let\preamble=\next%    expansion of all \ARGS tokens into the
%                                appropriate number of #'s.
         \makeTABLE{\preamble}{\tabletokens}%  Go do the \halign here.
      }%  End of \vbox.
      \ifcentertables \hss}\else }\fi%  Finish the centering effect.
%                                       It is important that no spaces
%                                       follow the two `}' here.
%  }%  End of \tableline
   \endgroup%  Return all local macros and parameters to their outside
%              values.
   \tablewidth=-\maxdimen%  Reset \tablewidth to normal.
   \spreadwidth=-\maxdimen% Same for \spreadwidth.
}%  End of macro \ruledtable.
%
\def\makeTABLE#1#2{%  Does an \halign for the \ruledtable macro.
   {%  Start of local parameter values.
%
   \let\ifmath0%     These macros would cause trouble if they were to be
   \let\header0%     expanded in the following \xdef; we \let them be
   \let\multispan0%  equal to a digit, because digits can't be expanded.
%
%  Set up the width specification here.
%
   \ncase=0%
   \ifdim\tablewidth>-\maxdimen \ncase=1\fi%
   \ifdim\spreadwidth>-\maxdimen \ncase=2\fi%
   \relax%  This \relax is absolutely necessary, without it the following
%           \ifcase will always take \ncase=0.
%
   \ifcase\ncase %
      \widthspec={}%
   \or %
      \widthspec=\expandafter{\expandafter t\expandafter o%
                 \the\tablewidth}%
   \else %
      \widthspec=\expandafter{\expandafter s\expandafter p\expandafter r%
                 \expandafter e\expandafter a\expandafter d%
                 \the\spreadwidth}%
   \fi %
%\out{Widthspec=O\the\widthspecE}%
%\out{Preamble=O\preambleE}%
   \xdef\next{%  We must force the preamble to be expanded BEFORE the
      \halign\the\widthspec{%
%        \halign is done;  this \edef\next{...}\next construction
%                does the trick.
      #1%  This is the preamble text.
%
      \noalign{\hrule height\thicksize depth0pt}%  Makes the top \hrule.
%
      \the#2\endtable%  This is the main body.
%
%     \noalign{\hrule height0.7pt depth0pt}%  Makes the last \hrule.
      }%  End of \halign.
   }%  End of \next.
   }%  End of local values.
   \next%  This \next must be outside of the local values, because now
%          we want those troublesome macros in the \let's above to have
%          their normal actions.
}%  End of macro \makeTABLE.
%
\def\makePREAMBLE#1{%  This macro generates the necessary preamble for a
%                      ruled table with #1 primary columns.
%                      (Primary columns means the number of columns NOT
%                       counting those used for vertical rules.)
   \ncols=#1%  Get the number of columns desired.
   \begingroup%  Start local parameter definitions.
   \let\ARGS=0%  This is the key to the whole thing; it prevents \ARGS
%                from being expanded in the following \edef's.
   \edef\xtp{\widevline\ARGS\tabskip\tabskipglue%
   &\ctr{\ARGS}\tstrut}%  A 1-column preamble.  Gets the sizing right.
   \advance\ncols by -1%  One column has been generated; decrement the
%                         counter.
   \loop%  Append as many further columns as needed to the preamble.
      \ifnum\ncols>0 %
      \advance\ncols by -1%
      \edef\xtp{\xtp&\vrule width\thinsize\ARGS&\ctr{\ARGS}}%
   \repeat
   \xdef\preamble{\xtp&\widevline\ARGS\tabskip0pt%
   \crnorm}%  Adds the last \vrule.
   \endgroup%  End of local parameters.
}%  End of macro \makePREAMBLE.
%
\def\countROWS#1\into#2{%  This counts the number of rows in #1 by
%                          looking for control sequences that end a row,
%                          e.g., \cr, \crthick, etc., and puts the result
%                          into count register #2.
   \let\countREGISTER=#2%
   \countREGISTER=0%
%  \out{In countROWS:  tokens are O\the#1E}%
   \expandafter\ROWcount\the#1\endcount%
}%
%
\def\ROWcount{%
   \afterassignment\subROWcount\let\next= %
}%
\def\subROWcount{%
%  \out{In subROWcount:  next is O\meaning\nextE}%  Debugging aid.
   \ifx\next\endcount %
      \let\next=\relax%
   \else%
      \ncase=0%
      \ifx\next\cr %
         \global\advance\countREGISTER by 1%
         \ncase=0%
      \fi%
      \ifx\next\endrow %
         \global\advance\countREGISTER by 1%
         \ncase=0%
      \fi%
      \ifx\next\crthick %
         \global\advance\countREGISTER by 1%
         \ncase=0%
      \fi%
      \ifx\next\crnorule %
         \global\advance\countREGISTER by 1%
         \ncase=0%
      \fi%
      \ifx\next\header %
%     \out{In subROWcount:  next=header, ncase set=1}%
         \ncase=1%
      \fi%
%     \out{In subROWcount:  ncase is O\the\ncaseE}%
      \relax%
      \ifcase\ncase %
         \let\next\ROWcount%
%        \out{subROWcount---> ncase=\the\ncase}%
      \or %
         \let\next\argROWskip%
%        \out{subROWcount---> ncase=\the\ncase}%
      \else %
      \fi%
   \fi%
%  \out{subROWcount---> NEXT=\meaning\next}%
   \next%
}%  End of macro \subROWcount.
%
\def\counthdROWS#1\into#2{%
\dvr{10}%
   \let\countREGISTER=#2%
   \countREGISTER=0%
\dvr{11}%
%  \out{In counthdROWS:  tokens are O\the#1E}%
\dvr{13}%
   \expandafter\hdROWcount\the#1\endcount%
\dvr{12}%
}%
%
\def\hdROWcount{%
   \afterassignment\subhdROWcount\let\next= %
}%
\def\subhdROWcount{%
%\out{In subhdROWcount:  next is O\meaning\nextE}%
   \ifx\next\endcount %
      \let\next=\relax%
   \else%
      \ncase=0%
      \ifx\next\cr %
         \global\advance\countREGISTER by 1%
         \ncase=0%
      \fi%
      \ifx\next\endrow %
         \global\advance\countREGISTER by 1%
         \ncase=0%
      \fi%
      \ifx\next\crthick %
         \global\advance\countREGISTER by 1%
         \ncase=0%
      \fi%
      \ifx\next\crnorule %
         \global\advance\countREGISTER by 1%
         \ncase=0%
      \fi%
      \ifx\next\header %
%\out{In subhdROWcount:  next=header, ncase set=1}%
         \ncase=1%
      \fi%
%\out{In subhdROWcount:  ncase is O\the\ncaseE}%
\relax%
      \ifcase\ncase %
         \let\next\hdROWcount%
%\out{subhdROWcount---> ncase=\the\ncase}%
      \or%
         \let\next\arghdROWskip%
%\out{subhdROWcount---> ncase=\the\ncase}%
      \else %
      \fi%
   \fi%
%\out{subhdROWcount---> NEXT=\meaning\next}%
   \next%
}%
%
{\catcode`\|=13\letbartab
\gdef\countCOLS#1\into#2{%
%  \out{In countCOLS:  tokens are O\the#1E}
   \let\countREGISTER=#2%
   \global\countREGISTER=0%
   \global\multispancount=0%
   \global\firstrowtrue
   \expandafter\COLcount\the#1\endcount%
   \global\advance\countREGISTER by 3%
   \global\advance\countREGISTER by -\multispancount
%  \out{countCOLS-->O\the\countREGISTERE}
}%
%
\gdef\COLcount{%
   \afterassignment\subCOLcount\let\next= %
}%
{\catcode`\&=13%
\gdef\subCOLcount{%
%\out{In subCOLcount: next is O\meaning\nextE}
   \ifx\next\endcount %
      \let\next=\relax%
   \else%
      \ncase=0%
      \iffirstrow
         \ifx\next& %
            \global\advance\countREGISTER by 2%
            \ncase=0%
         \fi%
         \ifx\next\span %
            \global\advance\countREGISTER by 1%
            \ncase=0%
         \fi%
         \ifx\next| %
            \global\advance\countREGISTER by 2%
            \ncase=0%
         \fi
         \ifx\next\|
            \global\advance\countREGISTER by 2%
            \ncase=0%
         \fi
         \ifx\next\multispan
            \ncase=1%
            \global\advance\multispancount by 1%
         \fi
         \ifx\next\header
            \ncase=2%
         \fi
         \ifx\next\cr       \global\firstrowfalse \fi
         \ifx\next\endrow   \global\firstrowfalse \fi
         \ifx\next\crthick  \global\firstrowfalse \fi
         \ifx\next\crnorule \global\firstrowfalse \fi
      \fi%  End of \iffirstrow.
\relax%\out{subCOL-->  ncase=O\the\ncaseE}
% \out{subCOL-->  next=\meaning\next}
      \ifcase\ncase %
         \let\next\COLcount%
      \or %
         \let\next\spancount%
      \or %
         \let\next\argCOLskip%
      \else %
      \fi %
   \fi%
%  \out{subCOL-->  countREGISTER=O\the\countREGISTERE}
   \next%
}%
\gdef\argROWskip#1{%
%  Deletes the next balanced, undelimited argument from a
%                 token list.
% \out{---> Entering argROWskip <---}
% \out{In argROWskip:  deleted arg is O#1E}%
   \let\next\ROWcount \next%
}%  End of macro \argskip.
\gdef\arghdROWskip#1{%
%  Deletes the next balanced, undelimited argument from a
%                 token list.
% \out{---> Entering arghdROWskip <---}
% \out{In arghdROWskip:  deleted arg is O#1E}%
   \let\next\ROWcount \next%
}%  End of macro \arghdROWskip.
\gdef\argCOLskip#1{%
%  Deletes the next balanced, undelimited argument from a
%                 token list.
% \out{---> Entering argCOLskip <---}
% \out{In argCOLskip:  deleted arg is O#1E}%
   \let\next\COLcount \next%
}%  End of macro \argskip.
}%  End of active &'s.
}%  End of active |'s.
\def\spancount#1{%\out{spancount--->\meaning#1}
   \nspan=#1\multiply\nspan by 2\advance\nspan by -1%
   \global\advance \countREGISTER by \nspan
%  \out{number spancount--->\the\nspan; \the\countREGISTER}
   \let\next\COLcount \next}%
%
%\def\dvr#1{\vrule width 1.0pt depth 0pt height 12pt$_{#1}$}
\def\dvr#1{\relax}%
% \omit\hfil%
% \parindent=0pt\hsize=1.1in\valign{%
% \vfil#\vfil&\vfil#\vfil\cr\hfil\hbox{\ Added to\ }\hfil&%
% \hfil\hbox{\ empty events\ }\hfil\cr}\hfil%
\def\header#1{%
\dvr{1}{\let\cr=\@mpersand%
\hdtks={#1}%
%\out{In header:  hdtks=O\the\hdtksE}%
\counthdROWS\hdtks\into\hdrows%
\advance\hdrows by 1%
\ifnum\hdrows=0 \hdrows=1 \fi%
%\out{In header:  Nhdrows=O\the\hdrowsE}%
\dvr{5}\makehdPREAMBLE{\the\hdrows}%
%\out{In header:  headerpreamble=O\headerpreambleE}%
\dvr{6}\getHDdimen{#1}%
%\out{In header:  hdsize=O\the\hdsizeE}%
%\striplastCR{#1}%
{\parindent=0pt\hsize=\hdsize{\let\ifmath0%
\xdef\next{\valign{\headerpreamble #1\crnorm}}}\dvr{7}\next\dvr{8}%
}%
}\dvr{2}}%  End of macro \header.
%\def\striplastCR#1\cr{\xdef\headerbody{#1}}%
\def\makehdPREAMBLE#1{%This macro generates the necessary preamble for a
\dvr{3}%
%                      ruled table with \ncols primary columns.
%                      (Primary columns means the number of columns NOT
%                       counting those used for vertical rules.
\hdrows=#1%  Get the number of columns desired.
{%  Start local parameter definitions.
\let\headerARGS=0%
%  This is the key to the whole thing; it prevents \ARGS
\let\cr=\crnorm%
%                from being expanded in the followin \edef's.
\edef\xtp{\vfil\hfil\hbox{\headerARGS}\hfil\vfil}%
\advance\hdrows by -1%  One row has been generated; decrement the
%                         counter.
\loop%  Append as many further rows as needed to the preamble.
\ifnum\hdrows>0%
\advance\hdrows by -1%
\edef\xtp{\xtp&\vfil\hfil\hbox{\headerARGS}\hfil\vfil}%
\repeat%
\xdef\headerpreamble{\xtp\crcr}%
}%  End of local parameters.
\dvr{4}}%  End of \makehdPREAMBLE.
%
\def\getHDdimen#1{%
%\out{In getHDdimen:  Arg 1=O#1E}%
\hdsize=0pt%
\getsize#1\cr\end\cr%
}%  End of macro getHDdimen.
\def\getsize#1\cr{%
%\out{In getsize:  Arg 1=O#1E}%
%  Here we have to check arg#1 and see if the first token in #1 is an
%    \end; if so, we stop, else we check the width of arg#1.
%  We recall that each arg#1 will be terminated with a \cr token.
\endsizefalse\savetks={#1}%
%\out{In getsize:  the savetks = O\the\savetksE}%
\expandafter\lookend\the\savetks\cr%
%\out{In getsize:  ifendsize = O\meaning\ifendsizeE}%
\relax \ifendsize \let\next\relax \else%
\setbox\hdbox=\hbox{#1}\newhdsize=1.0\wd\hdbox%
\ifdim\newhdsize>\hdsize \hdsize=\newhdsize \fi%
%\out{In getsize:  hdsize=O\the\hdsizeE}%
%\out{In getsize:  newhdsize=O\the\newhdsizeE}%
\let\next\getsize \fi%
\next%
}%
\def\lookend{\afterassignment\sublookend\let\looknext= }%
\def\sublookend{\relax%
%\out{In sublookend:  looknext = O\looknextE}%
\ifx\looknext\cr %
%\out{In sublooknext:  looknext=cr}%
\let\looknext\relax \else %
%\out{In sublooknext:  looknext/=cr}%
   \relax
   \ifx\looknext\end \global\endsizetrue \fi%
   \let\looknext=\lookend%
    \fi \looknext%
}%
%
%  Allow the user to make his own names for crthick, etc.
%
\def\tablelet#1{%
   \tableLETtokens=\expandafter{\the\tableLETtokens #1}%
}%
\catcode`\@=12%  Change @'s back to their normal category code.
%