| 1 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2 |
% |
| 3 |
% Module: ZzTeX Tabular Facilities, version 3 |
| 4 |
% |
| 5 |
% Synopsis: This module contains all the facilities for producing |
| 6 |
% tabular material. This is the third major version. |
| 7 |
% |
| 8 |
% Author: Paul C. Anagnostopoulos |
| 9 |
% Created: 4 June 2004 |
| 10 |
% |
| 11 |
% Copyright 1989--2020 by Paul C. Anagnostopoulos |
| 12 |
% under The MIT License (opensource.org/licenses/MIT) |
| 13 |
% |
| 14 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 15 |
|
| 16 |
% Tabular Block |
| 17 |
% ------- ----- |
| 18 |
|
| 19 |
|
| 20 |
\defineblock{\tabular}{\endtabular}{\false}{} |
| 21 |
|
| 22 |
%~block tabular Type |
| 23 |
% \abovepenalty = integer % Penalty above text. |
| 24 |
% \aboveskip = glue % Space b/b above text. |
| 25 |
% \belowpenalty = integer % Penalty below text. |
| 26 |
% \belowskip = glue % Space b/b below text. |
| 27 |
% \bodyfont = {font} % Body font. |
| 28 |
% \columngutter = glue % Width of column gutter. |
| 29 |
% \colheadbelowskip = dimen % Space b/b below column heads. |
| 30 |
% \colheadcolor = {color} % Color of Column heads. |
| 31 |
% \colheadfont = {font} % Column head font. |
| 32 |
% \interrowskip = dimen % Extra space between rows. |
| 33 |
% \leftindent = glue % Left indentation. |
| 34 |
% \parhang = dimen % Paragraph column hang. |
| 35 |
% \parrag = dimen % Paragraph raggedness. |
| 36 |
% \parskip = skip % Paragraph skip. |
| 37 |
% \rightindent = glue % Right indentation. |
| 38 |
% \rulecolcolor = {color} % Color of table rules. |
| 39 |
% \rulecolwidth = dimen % Width of column rules. |
| 40 |
% \sideheadaboveskip = dimen % Space b/b above side heads. |
| 41 |
% \sideheadbelowskip = dimen % Space b/b below side heads. |
| 42 |
% \sideheadcolor = {color} % Color of side heads. |
| 43 |
% \sideheadfont = {font} % Side head font. |
| 44 |
% \spannerheadcolor = {color} % Color of spanner heads. |
| 45 |
% \spannerheadfont = {font} % Spanner head font. |
| 46 |
% \spannerruleaboveskip = dimen % Space b/b above spanner rules. |
| 47 |
% \spannerrulebelowskip = dimen % Space b/b below spanner rules. |
| 48 |
% \spannerrulecolor = {color} % Color of spanner rules. |
| 49 |
% \spannerruleheight = dimen % Spanner rule thickness. |
| 50 |
% \style = {...} % Style description. |
| 51 |
% \tabbottomruleaboveskip = dimen % Space b/b above bottom rules. |
| 52 |
% \tabheadrulebelowskip = dimen % Space b/b below head rules. |
| 53 |
% \def \tabnoteformat ##1{...} % Format of table note references. |
| 54 |
% \tabrulecolor = {color} % Color of table rules. |
| 55 |
% \tabruleheight = dimen % Table rule thickness. |
| 56 |
% \tabtoprulebelowskip = dimen % Space b/b below top rules. |
| 57 |
% \width = dimen % Width of tabular material. |
| 58 |
%~end |
| 59 |
|
| 60 |
\defineskip{\colheadbelowskip}{0pt} |
| 61 |
\definetoks{\colheadcolor} |
| 62 |
\definetoks{\colheadfont} |
| 63 |
\definetoks{\rulecolcolor} |
| 64 |
\definedimen{\rulecolwidth}{0pt} |
| 65 |
\definedimen{\sideheadaboveskip}{0pt} |
| 66 |
\definedimen{\sideheadbelowskip}{0pt} |
| 67 |
\definetoks{\sideheadcolor} |
| 68 |
\definetoks{\sideheadfont} |
| 69 |
\definetoks{\spannerheadcolor} |
| 70 |
\definetoks{\spannerheadfont} |
| 71 |
\definedimen{\spannerruleaboveskip}{0pt} |
| 72 |
\definedimen{\spannerrulebelowskip}{0pt} |
| 73 |
\definetoks{\spannerrulecolor} |
| 74 |
\definedimen{\spannerruleheight}{0pt} |
| 75 |
\definedimen{\tabbottomruleaboveskip}{0pt} |
| 76 |
\definedimen{\tabheadrulebelowskip}{0pt} |
| 77 |
\definetoks{\tabrulecolor} |
| 78 |
\definedimen{\tabruleheight}{0pt} |
| 79 |
\definedimen{\tabtoprulebelowskip}{0pt} |
| 80 |
|
| 81 |
|
| 82 |
\def \tabular #1#2{% {type}{template} |
| 83 |
\endgraf |
| 84 |
\beginblockscope{tabular}% |
| 85 |
\global\increment \tabulardepth |
| 86 |
\abovepenalty = \breakgood %~default hard |
| 87 |
\belowpenalty = \breakbetter %~default hard |
| 88 |
\processdesign{\tabular}{#1}% |
| 89 |
\global\increment \tabularnumber |
| 90 |
\zsetuptabular{#2}% |
| 91 |
\tabularformat |
| 92 |
\defineatsigncommand @A{\adjustcolrule}% |
| 93 |
\defineatsigncommand @C{\closeuprows}% |
| 94 |
\defineatsigncommand @N{\nocolrule}% |
| 95 |
\defineatsigncommand @S{\skipabovespannerrule}% |
| 96 |
\defineatsigncommand @T{\skipbelowspannerrule}% |
| 97 |
\offinterlineskip |
| 98 |
\nobreak |
| 99 |
\tabskip=\leftskip |
| 100 |
\halign \if \dimneqlp{\width}{\naturalwidth}to \width \fi \bgroup |
| 101 |
\span\the\zpreamble \tabskip=\rightskip \cr} |
| 102 |
|
| 103 |
\def \endtabular {% |
| 104 |
\crcr |
| 105 |
\egroup % \halign |
| 106 |
\if \posp{\prevdepth}% % Does the last line have a strut? |
| 107 |
\kern -.5\interrowskip % Yes, eliminate extra depth from |
| 108 |
\prevdepth = \dp\strutbox % \interrowskip. |
| 109 |
\else |
| 110 |
\prevdepth = \tabruleheight % No, compensate for bottom rule. |
| 111 |
\fi |
| 112 |
\futurelet\nexttoken \zendtabular} |
| 113 |
|
| 114 |
\def \zendtabular {% |
| 115 |
\endtabularformat |
| 116 |
\global\decrement \tabulardepth |
| 117 |
\endblockscope{tabular}% |
| 118 |
\parnext} |
| 119 |
|
| 120 |
\def \tabularformat {% |
| 121 |
\bbskipabove{\abovepenalty}{\aboveskip}% |
| 122 |
\fakepar % This empty paragraph allows |
| 123 |
\hbox{}% % the \bbskipabove to work. |
| 124 |
\kern |
| 125 |
\if \dimzerop{\tabtoprulebelowskip}-\ht\zrowstrut \else -\tabruleheight \fi |
| 126 |
\alterindentation{\leftindent}{\rightindent}} |
| 127 |
|
| 128 |
\def \endtabularformat{% |
| 129 |
\bbskipbelowblockpar{\nexttoken}{\belowpenalty}{\belowskip}} |
| 130 |
|
| 131 |
\def \adjustcolumngutter #1{% {amount} %^tabular |
| 132 |
\with{\advance\columngutter by #1}} |
| 133 |
|
| 134 |
\def \adjustinterrowskip #1{% {amount} %^tabular |
| 135 |
\with{\advance\interrowskip by #1}} |
| 136 |
|
| 137 |
% Set Up Tabular |
| 138 |
% --- -- ------- |
| 139 |
|
| 140 |
|
| 141 |
\definecount{\tabcolcount}{0} % Number of columns in table. |
| 142 |
\definetoks{\zpreamble} % Preamble for \halign. |
| 143 |
\definetoks{\ztabspacerow} % Special row for vertical spacing. |
| 144 |
\definebox{\zrowstrut} % Strut for table rows. |
| 145 |
\definebox{\zparcelltopstrut} % Strut for first line of par cell. |
| 146 |
\definebox{\zparcellbotstrut} % Strut for last line of par cell. |
| 147 |
|
| 148 |
\def \zsetuptabular #1{% {template} |
| 149 |
\zanaltemplate{#1}% |
| 150 |
\the\bodyfont |
| 151 |
\calculate \tdimena = {\interrowskip,/,2,+,\ht\strutbox}% |
| 152 |
\calculate \tdimenb = {\interrowskip,/,2,+,\dp\strutbox}% |
| 153 |
\setbox \zrowstrut = \hbox{\vrule width 0pt |
| 154 |
height \tdimena depth \tdimenb}% |
| 155 |
\setbox \zparcelltopstrut = \hbox{\vrule width 0pt |
| 156 |
height \tdimena depth 0pt}% |
| 157 |
\setbox \zparcellbotstrut = \hbox{\vrule width 0pt |
| 158 |
height 0pt depth \tdimenb}% |
| 159 |
\global\zprevrowclass = \zrcpream |
| 160 |
\global\zcurrowclass = \zrcpream |
| 161 |
\gdef \zcolrulegate {}% |
| 162 |
\global\setflag \zcolrulesenabled = \false |
| 163 |
\everycr = {\noalign{\ztabcr}}} |
| 164 |
|
| 165 |
% Analyze Template |
| 166 |
% ------- -------- |
| 167 |
|
| 168 |
|
| 169 |
\defineskip{\zpendgutter}{0pt} |
| 170 |
|
| 171 |
|
| 172 |
\def \zanaltemplate #1{% {template} |
| 173 |
\setbox\zboxa = \hbox{% |
| 174 |
\defineatsigncommand @!{\zcustomrulecol}% |
| 175 |
\defineatsigncommand @>{\zgutterspec}% |
| 176 |
\defineatsigncommand @c{\zcentercol}% |
| 177 |
\defineatsigncommand @C{\zcenternumbercol}% |
| 178 |
\defineatsigncommand @e{\zemptycol}% |
| 179 |
\defineatsigncommand @l{\zleftcol}% |
| 180 |
\defineatsigncommand @L{\zleftnumbercol}% |
| 181 |
\defineatsigncommand @p{\zparcol}% |
| 182 |
\defineatsigncommand @r{\zrightcol}% |
| 183 |
\defineatsigncommand @R{\zrightnumbercol}% |
| 184 |
\defineatsigncommand @s{\zspecialcol}% |
| 185 |
\defineatsigncommand @|{\zrulecol}% |
| 186 |
\global\tabcolcount = 0 |
| 187 |
\global\zpreamble = {}% |
| 188 |
\global\ztabspacerow = {}% |
| 189 |
#1}% |
| 190 |
\tabcolcount = \tabcolcount |
| 191 |
\zpreamble = \zpreamble |
| 192 |
\ztabspacerow = \ztabspacerow} |
| 193 |
|
| 194 |
\def \zcentercol {% |
| 195 |
\zstartcol{\false}% |
| 196 |
\zappendpreamble{\hfil ##\rowstrut \hfil}} |
| 197 |
|
| 198 |
\def \zcenternumbercol #1{% |
| 199 |
\zstartcol{\false}% |
| 200 |
\zmeasuredanumber #1..\zmark |
| 201 |
\edef \znext {% |
| 202 |
\noexpand\zappendpreamble{% |
| 203 |
\hfil \noexpand\zsetnumbercell{\the\tdimena}{\the\tdimenb}{####}\hfil}}% |
| 204 |
\znext} |
| 205 |
|
| 206 |
\def \zcustomrulecol #1#2{% {color}{width} |
| 207 |
\if \dimeqlp{\zpendgutter}{\mindimen}\zpendgutter = .5\columngutter \fi |
| 208 |
\zstartcol{\true}% |
| 209 |
\zappendpreamble{\zsetcolrule{#1}{#2}{##}}% |
| 210 |
\zpendgutter = .5\columngutter} |
| 211 |
|
| 212 |
\def \zemptycol #1{% {width} |
| 213 |
\zstartcol{\false}% |
| 214 |
\zappendpreamble{##\rowstrut \hspace{#1}}} |
| 215 |
|
| 216 |
\def \zgutterspec #1{% {width} |
| 217 |
\zparsegutterspec #1*\zmark} |
| 218 |
|
| 219 |
\def \zparsegutterspec #1*#2\zmark{% |
| 220 |
\zpendgutter = #1\relax |
| 221 |
\if \notp{\emptyargp{#2}}% |
| 222 |
\advance \zpendgutter by \columngutter |
| 223 |
\advance \zpendgutter by -1\columngutter |
| 224 |
\fi} |
| 225 |
|
| 226 |
\def \zleftcol {% |
| 227 |
\zstartcol{\false}% |
| 228 |
\zappendpreamble{##\rowstrut \hfil}} |
| 229 |
|
| 230 |
\def \zleftnumbercol #1{% |
| 231 |
\zstartcol{\false}% |
| 232 |
\zmeasuredanumber #1..\zmark |
| 233 |
\edef \znext {% |
| 234 |
\noexpand\zappendpreamble{% |
| 235 |
\noexpand\zsetnumbercell{\the\tdimena}{\the\tdimenb}{####}\hfil}}% |
| 236 |
\znext} |
| 237 |
|
| 238 |
\def \zparcol #1{% {width} |
| 239 |
\zstartcol{\false}% |
| 240 |
\zappendpreamble{\zsetparcol{#1}{##}}} |
| 241 |
|
| 242 |
\def \zrightcol {% |
| 243 |
\zstartcol{\false}% |
| 244 |
\zappendpreamble{\hfil ##\rowstrut}} |
| 245 |
|
| 246 |
\def \zrightnumbercol #1{% |
| 247 |
\zstartcol{\false}% |
| 248 |
\zmeasuredanumber #1..\zmark |
| 249 |
\edef \znext {% |
| 250 |
\noexpand\zappendpreamble{% |
| 251 |
\hfil \noexpand\zsetnumbercell{\the\tdimena}{\the\tdimenb}{####}}}% |
| 252 |
\znext} |
| 253 |
|
| 254 |
\def \zrulecol {% |
| 255 |
\if \dimeqlp{\zpendgutter}{\mindimen}\zpendgutter = .5\columngutter\relax \fi |
| 256 |
\zstartcol{\true}% |
| 257 |
\zappendpreamble{\zsetcolrule{}{}{##}}% |
| 258 |
\zpendgutter = .5\columngutter\relax} |
| 259 |
|
| 260 |
\def \zspecialcol #1{% {template} |
| 261 |
\zstartcol{\false}% |
| 262 |
\zappendpreamble{#1\rowstrut}} |
| 263 |
|
| 264 |
\def \zstartcol #1{% {rule-column?} |
| 265 |
\if \posp{\tabcolcount}% |
| 266 |
\if \dimeqlp{\zpendgutter}{\mindimen}\zpendgutter = \columngutter \fi |
| 267 |
\edef \znext {\noexpand\zappendpreamble{\tabskip=\the\zpendgutter &}}% |
| 268 |
\znext |
| 269 |
\global\ztabspacerow = \expandafter{\the\ztabspacerow &}% |
| 270 |
\fi |
| 271 |
\global\increment \tabcolcount |
| 272 |
\if \notp{#1}% |
| 273 |
\global\ztabspacerow = \expandafter{\the\ztabspacerow |
| 274 |
\omit \copy \ztabvspacebox}% |
| 275 |
\fi |
| 276 |
\zpendgutter = \mindimen} |
| 277 |
|
| 278 |
\def \zappendpreamble #1{% {preamble stuff} |
| 279 |
\global\zpreamble = \expandafter{\the\zpreamble #1}} |
| 280 |
|
| 281 |
% Preamble Helpers |
| 282 |
% -------- ------- |
| 283 |
|
| 284 |
|
| 285 |
\def \zmeasuredanumber #1.#2.#3\zmark{% |
| 286 |
\measuretextwidth{\tdimena}{#1}% |
| 287 |
\measuretextwidth{\tdimenb}{.#2}% |
| 288 |
\if \andp{\emptyargp{#2}}{\emptyargp{#3}}\tdimenb = 0pt\fi} |
| 289 |
|
| 290 |
\def \zsetcolrule #1#2#3{% {color}{width}{adjustment} |
| 291 |
\if \emptyargp{#1}\color{\the\tabrulecolor}\else \color{#1}\fi |
| 292 |
\vrule width \if \emptyargp{#2}\rulecolwidth \else #2\fi |
| 293 |
\zcolrulegate #3% |
| 294 |
\endcolor} |
| 295 |
|
| 296 |
\def \zsetnumbercell #1#2#3{% {pre-width}{post-width}{text} |
| 297 |
\gdef \zcellstyle {}% |
| 298 |
\zsplitdanumber #3..\zmark |
| 299 |
\if \dimzerop{#2}% |
| 300 |
\if \emptytoksp{\ztoksb}% |
| 301 |
\hbox to #1{\hfil \the\ztoksa}% |
| 302 |
\else |
| 303 |
\error{celldecpt}{Template picture did not include a decimal point}% |
| 304 |
\fi |
| 305 |
\else |
| 306 |
\hbox to #1{\hfil \the\ztoksa}% |
| 307 |
\hbox to #2{\zcellstyle \the\ztoksb \hfil}% |
| 308 |
\fi |
| 309 |
\rowstrut} |
| 310 |
|
| 311 |
\long\def \zsetparcol #1#2{% {width}{text} |
| 312 |
\vtop{% |
| 313 |
\zpushvcontext |
| 314 |
\baselineskip = \normalbaselineskip |
| 315 |
\lineskiplimit = 0pt \lineskip = 0pt |
| 316 |
%%% \setindentation{0pt}{0pt}% |
| 317 |
\settextwidth{#1}% |
| 318 |
\setparrag{\parrag}% |
| 319 |
\leftskip = \parhang |
| 320 |
\parindent = -\parhang |
| 321 |
\parfillskip = \normalparfillskip |
| 322 |
\unhcopy \zparcelltopstrut |
| 323 |
#2% |
| 324 |
\if \hmodep \unhcopy \zparcellbotstrut \par \fi |
| 325 |
\zpopvcontext}} |
| 326 |
|
| 327 |
\def \zsplitdanumber #1.#2.#3\zmark{% |
| 328 |
\ztoksa = {#1}% |
| 329 |
\ztoksb = {.#2}% |
| 330 |
\if \andp{\emptyargp{#2}}{\emptyargp{#3}}\ztoksb = {}\fi} |
| 331 |
|
| 332 |
% Row Class |
| 333 |
% --- ----- |
| 334 |
|
| 335 |
|
| 336 |
\definecount{\zprevrowclass}{0} |
| 337 |
\definecount{\zcurrowclass}{0} |
| 338 |
|
| 339 |
\chardef \zrcpream = 0 |
| 340 |
\chardef \zrcdata = 1 |
| 341 |
\chardef \zrchead = 2 |
| 342 |
\chardef \zrcrule = 3 |
| 343 |
\chardef \zrcvspace = 4 |
| 344 |
\chardef \zrcbbskip = 5 |
| 345 |
|
| 346 |
\def \zsetrowclass #1{% |
| 347 |
\if \gtrp{#1}{\zcurrowclass}\global\zcurrowclass = #1\relax \fi} |
| 348 |
|
| 349 |
\def \ztabcr {% |
| 350 |
\global\zprevrowclass = \zcurrowclass |
| 351 |
\global\zcurrowclass = \zrcdata |
| 352 |
\global\setflag \zcolrulesenabled = \false} |
| 353 |
|
| 354 |
% Cell Facilities |
| 355 |
% ---- ---------- |
| 356 |
|
| 357 |
|
| 358 |
%~ This command produces a phantom zero, which is useful for aligning |
| 359 |
%~ numbers when decimal-aligned columns are not being used. |
| 360 |
|
| 361 |
\def \0{\phantom{0}} %^tabular |
| 362 |
|
| 363 |
\zremovePlaindef \hideskip |
| 364 |
\defineskip{\hideskip}{-1000pt plus 1fill} |
| 365 |
|
| 366 |
%~ This command "hides" the width of the cell from the column width calculation |
| 367 |
%~ process. The cell does not participate in determining the widest cell of |
| 368 |
%~ the column. If the cell is wider than the calculated column width, it will |
| 369 |
%~ stick into the left or right column gutter, depending on the position of the |
| 370 |
%~ |\hidewidth| command. |
| 371 |
|
| 372 |
\def \hidewidth {\hskip \hideskip} %^tabular |
| 373 |
|
| 374 |
%~ This command discards the templates for the specified number of columns and |
| 375 |
%~ creates one cell that spans them all. The content of the cell is specified |
| 376 |
%~ immediately following the command. This spanning cell has no template, so |
| 377 |
%~ you must include all the required commands in the cell text. This is usually done |
| 378 |
%~ using one of the cell override commands such as |\leftcell|. |
| 379 |
|
| 380 |
\def \multispan #1{% {columns} %^tabular |
| 381 |
\omit |
| 382 |
\tcounta = #1% |
| 383 |
\loop \ifnum \tcounta > 1 \zspan \repeat |
| 384 |
\let \omit = \relax % In case the next thing is a \leftcell or whatever. |
| 385 |
\ignorespaces} |
| 386 |
|
| 387 |
\def \zspan {\span\omit \decrement \tcounta} |
| 388 |
|
| 389 |
\def \rowstrut {% |
| 390 |
\unhcopy \zrowstrut} |
| 391 |
|
| 392 |
\def \zcellstyle {} |
| 393 |
|
| 394 |
\def \setcellstyle #1{% |
| 395 |
#1% |
| 396 |
\gdef \zcellstyle {#1}% |
| 397 |
\ignorespaces} |
| 398 |
|
| 399 |
%~ This command sets a table note reference, usually a lowercase |
| 400 |
%~ letter. The format of the reference is determined by the design. |
| 401 |
|
| 402 |
\def \tabnote #1{% {note-mark} %^tabular |
| 403 |
{\tabnoteformat{#1}}} |
| 404 |
|
| 405 |
% Cell Overrides |
| 406 |
% ---- --------- |
| 407 |
|
| 408 |
|
| 409 |
%~ This command overrides the template for the column and sets |
| 410 |
%~ a centered cell. It must appear immediately after the |
| 411 |
%~ ampersand (|&&|) that begins the cell. |
| 412 |
|
| 413 |
\def \centercell #1{% {text} %^tabular |
| 414 |
\omit |
| 415 |
\hfil #1\rowstrut \hfil} |
| 416 |
|
| 417 |
%~ This command overrides the template for the column and sets |
| 418 |
%~ a flush left cell. It must appear immediately after the |
| 419 |
%~ ampersand (|&&|) that begins the cell. |
| 420 |
|
| 421 |
\def \leftcell #1{% {text} %^tabular |
| 422 |
\omit |
| 423 |
#1\rowstrut \hfil} |
| 424 |
|
| 425 |
%~ This command overrides the template for the column and sets |
| 426 |
%~ a paragraph cell. It must appear immediately after the |
| 427 |
%~ ampersand (|&&|) that begins the cell. |
| 428 |
|
| 429 |
\def \parcell #1#2{% {width}{text} %^tabular |
| 430 |
\omit |
| 431 |
\zsetparcol{#1}{#2}} |
| 432 |
|
| 433 |
%~ This command overrides the template for the column and sets |
| 434 |
%~ a flush right cell. It must appear immediately after the |
| 435 |
%~ ampersand (|&&|) that begins the cell. |
| 436 |
|
| 437 |
\def \rightcell #1{% {text} %^tabular |
| 438 |
\omit |
| 439 |
\hfil #1\rowstrut} |
| 440 |
|
| 441 |
% Column Heads |
| 442 |
% ------ ----- |
| 443 |
|
| 444 |
|
| 445 |
%~ This column head command produces a centered head. |
| 446 |
|
| 447 |
\def \centerhead #1{% {heading} %^tabular |
| 448 |
\centercell{% |
| 449 |
\the\colheadfont \colortext{\the\colheadcolor}{#1}% |
| 450 |
\zchkadjheads}} |
| 451 |
|
| 452 |
%~ This column head command produces a flush left head. |
| 453 |
|
| 454 |
\def \lefthead #1{% {heading} %^tabular |
| 455 |
\leftcell{% |
| 456 |
\the\colheadfont \colortext{\the\colheadcolor}{#1}% |
| 457 |
\zchkadjheads}} |
| 458 |
|
| 459 |
%~ This column head command produces a flush right head. |
| 460 |
|
| 461 |
\def \righthead #1{% {heading} %^tabular |
| 462 |
\rightcell{% |
| 463 |
\the\colheadfont \colortext{\the\colheadcolor}{#1}% |
| 464 |
\zchkadjheads}} |
| 465 |
|
| 466 |
%~ This command produces a spanner head that spans the specified |
| 467 |
%~ number of columns. |
| 468 |
|
| 469 |
\def \spannerhead #1#2{% {columns}{heading} %^tabular |
| 470 |
\multispan{#1}% |
| 471 |
\centercell{\the\spannerheadfont \colortext{\the\spannerheadcolor}{#2}}% |
| 472 |
\zsetrowclass{\zrchead}} |
| 473 |
|
| 474 |
\def \zchkadjheads {% |
| 475 |
\if \andp{\eqlp{\zprevrowclass}{\zrchead}}{\posp{\interrowskip}}% |
| 476 |
\warning{adjheads}{Two adjacent rows of heads need to be closed up}% |
| 477 |
\global\zprevrowclass = \zrcdata |
| 478 |
\fi |
| 479 |
\zsetrowclass{\zrchead}} |
| 480 |
|
| 481 |
% Side Heads |
| 482 |
% ---- ----- |
| 483 |
|
| 484 |
%~ This command is a shorthand for producing a cut-in head that spans the |
| 485 |
%~ entire width of the table. It is equivalent to: |
| 486 |
%~ |
| 487 |
%~ | \skipabovesidehead |
| 488 |
%~ | \sidehead{*all-columns*}{*heading*}\cr |
| 489 |
%~ | \skipbelowsidehead |
| 490 |
|
| 491 |
\def \cutinhead #1{% {heading} %^tabular |
| 492 |
\skipabovesidehead |
| 493 |
\sidehead{\tabcolcount}{#1}\cr |
| 494 |
\skipbelowsidehead} |
| 495 |
|
| 496 |
%~ This command produces a side head that spans the specified number of |
| 497 |
%~ columns. It is similar to |\spannerhead|. It is almost always the case that a |
| 498 |
%~ |\sidehead| row should be preceded by a |\skipabovesidehead| and followed by a |
| 499 |
%~ |\skipbelowsidehead|. |
| 500 |
|
| 501 |
\def \sidehead #1#2{% {columns}{heading} %^tabular |
| 502 |
\multispan{#1}% |
| 503 |
\leftcell{\the\sideheadfont \colortext{\the\sideheadcolor}{#2}}} |
| 504 |
|
| 505 |
% Vertical Spacing |
| 506 |
% -------- ------- |
| 507 |
|
| 508 |
|
| 509 |
%~ This command eliminates the inter-row space between two rows. It must be |
| 510 |
%~ used between two consective rows of table heads. Shorthand: |@C|. |
| 511 |
|
| 512 |
\def \closeuprows {% %^tabular |
| 513 |
\tabvspace{-\interrowskip}} |
| 514 |
|
| 515 |
%~ This command adds extra space between column heads and the first data row. |
| 516 |
%~ It must be used in tables that do not have head rules. |
| 517 |
|
| 518 |
\def \skipbelowcolhead {% %^tabular |
| 519 |
\zchkbelowhead |
| 520 |
\tabbbskip{\colheadbelowskip}} |
| 521 |
|
| 522 |
%~ This command produces the appropriate vertical space above |
| 523 |
%~ a spanner rule. Shorthand: |@S|. See also |\skipbelowspannerrule|. |
| 524 |
|
| 525 |
\def \skipabovespannerrule {% %^tabular |
| 526 |
\tabbbskip{\spannerruleaboveskip}} |
| 527 |
|
| 528 |
%~ This command produces the appropriate vertical space below |
| 529 |
%~ a spanner rule. Shorthand: |@T|. See also |\skipabovespannerrule|. |
| 530 |
|
| 531 |
\def \skipbelowspannerrule {% %^tabular |
| 532 |
\tabbbskip{\spannerrulebelowskip}} |
| 533 |
|
| 534 |
%~ This command produces the appropriate vertical space above |
| 535 |
%~ a side head. See also |\skipbelowsidehead|. |
| 536 |
|
| 537 |
\def \skipabovesidehead {% %^tabular |
| 538 |
\tabbbskip{\sideheadaboveskip}} |
| 539 |
|
| 540 |
%~ This command produces the appropriate vertical space below |
| 541 |
%~ a side head. See also |\skiabovewsidehead|. |
| 542 |
|
| 543 |
\def \skipbelowsidehead {% %^tabular |
| 544 |
\tabbbskip{\sideheadbelowskip}} |
| 545 |
|
| 546 |
%~ This command produces extra vertical space so that the base-to-base space |
| 547 |
%~ between the preceding and following rows is as specified. |
| 548 |
|
| 549 |
\def \tabbbskip #1{% {amount} %^tabular |
| 550 |
\ztabbbskip{#1,-,\dp\zrowstrut,-,\ht\zrowstrut}% |
| 551 |
\the\ztabspacerow\cr} |
| 552 |
|
| 553 |
%~ This command produces extra vertical space between a row and a rule. |
| 554 |
%~ It must be used instead of |\tabbbskip| to obtain the desired results when |
| 555 |
%~ spacing above horizontal rules. See also |\tabbbskipbelowrule|. |
| 556 |
|
| 557 |
\def \tabbbskipaboverule #1{% {amount} %^tabular |
| 558 |
\noalign{\nobreak}% |
| 559 |
\ztabbbskip{#1,-,\dp\zrowstrut,-,\tabruleheight}% |
| 560 |
\noalign{\if \zcolrulesenabled \zsuppresscolrules \fi}% |
| 561 |
\the\ztabspacerow \if \zcolrulesenabled \zallowcolrules \fi\cr |
| 562 |
\noalign{\nobreak}} |
| 563 |
|
| 564 |
%~ This command produces extra vertical space between a rule and a row. |
| 565 |
%~ It must be used instead of |\tabbbskip| to obtain the desired results when |
| 566 |
%~ spacing below horizontal rules. See also |\tabbbskipaboverule|. |
| 567 |
|
| 568 |
\def \tabbbskipbelowrule #1{% {amount} %^tabular |
| 569 |
\ztabbbskip{#1,-,\ht\zrowstrut}% |
| 570 |
\the\ztabspacerow\cr} |
| 571 |
|
| 572 |
%~ This command produces the specified amount of extra vertical space |
| 573 |
%~ between two rows of the table. |
| 574 |
|
| 575 |
\def \tabvspace #1{% {amount} %^tabular |
| 576 |
\noalign{% |
| 577 |
\zsetrowclass{\zrcvspace}% |
| 578 |
\zsetvspacebox{#1}}% |
| 579 |
\the\ztabspacerow\cr} |
| 580 |
|
| 581 |
\def \ztabbbskip #1{% |
| 582 |
\noalign{% |
| 583 |
\zsetrowclass{\zrcbbskip}% |
| 584 |
\if \eqlp{\zprevrowclass}{\zrcbbskip}% |
| 585 |
\tdimena = 0pt\relax |
| 586 |
\else |
| 587 |
\calculate \tdimena = {#1}% |
| 588 |
\fi |
| 589 |
\zsetvspacebox{\tdimena}}} |
| 590 |
|
| 591 |
\definebox{\ztabvspacebox} |
| 592 |
\setbox \ztabvspacebox = \hbox{}% |
| 593 |
|
| 594 |
\def \zsetvspacebox #1{% |
| 595 |
\if \dimnegp{#1}% |
| 596 |
\vskip #1\relax |
| 597 |
\dp\ztabvspacebox = 0pt |
| 598 |
\else |
| 599 |
\dp\ztabvspacebox = #1\relax |
| 600 |
\fi} |
| 601 |
|
| 602 |
\def \zchkbelowhead {% |
| 603 |
\noalign{% |
| 604 |
\if \neqlp{\zprevrowclass}{\zrchead}% |
| 605 |
\warning{needheads}{The previous row should be a row of column heads}% |
| 606 |
\fi}} |
| 607 |
|
| 608 |
% Horizontal Rules |
| 609 |
% ---------- ----- |
| 610 |
|
| 611 |
|
| 612 |
%~ This command produces a custom version of the partial table rule |
| 613 |
%~ (|\partialtabrule|). The color and thickness of the rules is specified |
| 614 |
%~ explicitly. |
| 615 |
|
| 616 |
\def \custompartialtabrule #1#2#3{% {color}{thickness}{columns} %^tabular |
| 617 |
\multispan{#3}% |
| 618 |
\color{#1}% |
| 619 |
\ruleleaders{\hrule height #2 depth 0pt}% |
| 620 |
\endcolor} |
| 621 |
|
| 622 |
%~ This command produces a custom version of the table spanner rule |
| 623 |
%~ (|\spannerrule|). The color and thickness of the rules is specified |
| 624 |
%~ explicitly. |
| 625 |
|
| 626 |
\def \customspannerrule #1#2#3{% {color}{thickness}{columns} %^tabular |
| 627 |
\multispan{#3}% |
| 628 |
\rowstrut |
| 629 |
\color{#1}% |
| 630 |
\ruleleaders{\hrule height #2 depth 0pt}% |
| 631 |
\endcolor} |
| 632 |
|
| 633 |
%~ This command produces a custom version of the table rule |
| 634 |
%~ (|\tabrule|). The color and thickness of the rules is specified |
| 635 |
%~ explicitly. |
| 636 |
|
| 637 |
\def \customtabrule #1#2{% {color}{thickness} %^tabular |
| 638 |
\multispan{\tabcolcount}% |
| 639 |
\color{#1}% |
| 640 |
\ruleleaders{\hrule height #2 depth 0pt}% |
| 641 |
\endcolor\cr} |
| 642 |
|
| 643 |
%~ This command produces a table rule across the specified number of columns. |
| 644 |
%~ It is similar to |\spannerrule| but sets a rule of the same thickness |
| 645 |
%~ as |\tabrule|. |
| 646 |
|
| 647 |
\def \partialtabrule #1{% {columns} %^tabular |
| 648 |
\custompartialtabrule{\the\tabrulecolor}{\tabruleheight}{#1}} |
| 649 |
|
| 650 |
%~ This command produces a spanner rule across the specified number of columns. |
| 651 |
%~ The color and thickness of the rule are determined by the design. A row with |
| 652 |
%~ spanner rules is usually preceded and followed by |\skipabovespannerrule| and |
| 653 |
%~ |\skipbelowspannerrule|. |
| 654 |
|
| 655 |
\def \spannerrule #1{% {columns} %^tabular |
| 656 |
\customspannerrule{\the\spannerrulecolor}{\spannerruleheight}{#1}} |
| 657 |
|
| 658 |
%~ This command produces the standard bottom rule in a table. Which rules are |
| 659 |
%~ required is specified in the |\style| parameter of the |\tabular| design. |
| 660 |
%~ This command is not followed by |\cr|. |
| 661 |
|
| 662 |
\def \tabbottomrule {% %^tabular |
| 663 |
\tabbbskipaboverule{\tabbottomruleaboveskip}% |
| 664 |
\tabrule} |
| 665 |
|
| 666 |
%~ This command produces the standard head rule in a table. Which rules are |
| 667 |
%~ required is specified in the |\style| parameter of the |\tabular| design. |
| 668 |
%~ This command is not followed by |\cr|. |
| 669 |
|
| 670 |
\def \tabheadrule {% %^tabular |
| 671 |
\zchkbelowhead |
| 672 |
\tabbbskipaboverule{\colheadbelowskip}% |
| 673 |
\tabrule |
| 674 |
\tabbbskipbelowrule{\tabheadrulebelowskip}} |
| 675 |
|
| 676 |
%~ This command produces a table rule across the entire width of the table. The |
| 677 |
%~ color and thickness of the rule are determined by the design. This command |
| 678 |
%~ is not followed by |\cr|. |
| 679 |
|
| 680 |
\def \tabrule {% %^tabular |
| 681 |
\customtabrule{\the\tabrulecolor}{\tabruleheight}} |
| 682 |
|
| 683 |
%~ This command produces the standard top rule in a table. Which rules are |
| 684 |
%~ required is specified in the |\style| parameter of the |\tabular| design. |
| 685 |
%~ This command is not followed by |\cr|. |
| 686 |
|
| 687 |
\def \tabtoprule {% %^tabular |
| 688 |
\tabrule |
| 689 |
\noalign{\nobreak}% |
| 690 |
\tabbbskipbelowrule{\tabtoprulebelowskip}} |
| 691 |
|
| 692 |
% Vertical Rules |
| 693 |
% -------- ----- |
| 694 |
|
| 695 |
|
| 696 |
%~ This command is used in the normally empty cell corresponding to a vertical |
| 697 |
%~ rule column. It adjusts the width, height, and/or depth of the rule in that |
| 698 |
%~ cell. To adjust one of those dimensions, specify the new dimension in |
| 699 |
%~ points, without the usual |pt|, in the appropriate argument position. |
| 700 |
%~ Omitted dimensions will have their standard values. You must specify both |
| 701 |
%~ commas and the semicolon. Shorthand: |@A*width*,*height*,*depth*;| |
| 702 |
|
| 703 |
\def \adjustcolrule #1,#2,#3;{% width,height,depth; %^tabular |
| 704 |
\if \notp{\emptyargp{#1}}width #1pt\fi |
| 705 |
\if \notp{\emptyargp{#2}}height #2pt\fi |
| 706 |
\if \notp{\emptyargp{#3}}depth #3pt\fi\relax} |
| 707 |
|
| 708 |
%~ This command can be used between rows of a table to allow all vertical |
| 709 |
%~ rules. This is typically done after the column head portion of a table. If |
| 710 |
%~ |\allowcolrules| appears just before |\tabheadrule|, it is deferred until |
| 711 |
%~ after the vertical space above the horizontal rule, so that the vertical |
| 712 |
%~ rules recommence precisely at the horizontal rule. See also |
| 713 |
%~ |\suppresscolrules|. |
| 714 |
|
| 715 |
\def \allowcolrules {% %^tabular |
| 716 |
\noalign{% |
| 717 |
\zallowcolrules |
| 718 |
\global\setflag \zcolrulesenabled = \true}} |
| 719 |
|
| 720 |
\def \zallowcolrules {% |
| 721 |
\gdef \zcolrulegate {}} |
| 722 |
|
| 723 |
%~ This command can be used between rows of a table to suppress all vertical |
| 724 |
%~ rules. This is typically done for the column head portion of a table. |
| 725 |
%~ See also |\allowcolrules|. |
| 726 |
|
| 727 |
\def \suppresscolrules {% %^tabular |
| 728 |
\noalign{\zsuppresscolrules}} |
| 729 |
|
| 730 |
\def \zsuppresscolrules {% |
| 731 |
\gdef \zcolrulegate {\nocolrule}} |
| 732 |
|
| 733 |
%~ This command is used in the normally empty cell corresponding to a vertical |
| 734 |
%~ rule column. It suppresses the vertical rule in that cell. Shorthand: |@N|. |
| 735 |
|
| 736 |
\def \nocolrule {% %^tabular |
| 737 |
width 0pt } |
| 738 |
|
| 739 |
% Inter-Row Facilities |
| 740 |
% --------- ---------- |
| 741 |
|
| 742 |
|
| 743 |
%~ This command can be used between rows of a table to insert vertical material |
| 744 |
%~ that is independent of the rows themselves. It is rarely needed. |
| 745 |
|
| 746 |
\def \adjusttabular #1{% {commands} %^tabular |
| 747 |
\noalign{#1}} |
| 748 |
|
| 749 |
\let \adjusttab = \adjusttabular |
| 750 |
|
| 751 |
% Low-Level Alignment Facilities |
| 752 |
% --------- --------- ---------- |
| 753 |
|
| 754 |
|
| 755 |
\let \completerow = \cr |
| 756 |
|
| 757 |
\def \ialign {\everycr = {}\tabskip=0pt \halign} |
| 758 |
|
| 759 |
\def \oalign #1{% {row...} |
| 760 |
\ensurepar |
| 761 |
\vtop{\baselineskip = 0pt |
| 762 |
\lineskip = .25ex |
| 763 |
\ialign{##\cr #1\crcr}}} |
| 764 |
|
| 765 |
\def \ooalign {% |
| 766 |
\lineskiplimit = -\maxdimen |
| 767 |
\oalign} |
| 768 |
|
| 769 |
\def \ozalign {% |
| 770 |
\lineskiplimit = 0pt\relax |
| 771 |
\oalign} |