| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% Copyright (C) 1993-2025 |
| 4 |
% |
| 5 |
% The LaTeX Project and any individual authors listed elsewhere |
| 6 |
% in this file. |
| 7 |
% |
| 8 |
% This file is part of the Standard LaTeX `Tools Bundle'. |
| 9 |
% ------------------------------------------------------- |
| 10 |
% |
| 11 |
% It may be distributed and/or modified under the |
| 12 |
% conditions of the LaTeX Project Public License, either version 1.3c |
| 13 |
% of this license or (at your option) any later version. |
| 14 |
% The latest version of this license is in |
| 15 |
% https://www.latex-project.org/lppl.txt |
| 16 |
% and version 1.3c or later is part of all distributions of LaTeX |
| 17 |
% version 2005/12/01 or later. |
| 18 |
% |
| 19 |
% The list of all files belonging to the LaTeX `Tools Bundle' is |
| 20 |
% given in the file `manifest.txt'. |
| 21 |
% |
| 22 |
% \fi |
| 23 |
%\iffalse % this is a METACOMMENT ! |
| 24 |
% |
| 25 |
%% Package `array' to use with LaTeX 2e |
| 26 |
%% Copyright (C) 1989-1998 Frank Mittelbach, all rights reserved. |
| 27 |
%<+package>\NeedsTeXFormat{LaTeX2e}[1995/06/01] |
| 28 |
%<+package> |
| 29 |
% For anything before 2016-10-06 we load the 2016 version and hope for the best: |
| 30 |
%<+package>\DeclareRelease{}{1994-06-01}{array-2016-10-06.sty} |
| 31 |
% |
| 32 |
%<+package>\DeclareRelease{}{2016-10-06}{array-2016-10-06.sty} |
| 33 |
%<+package>\DeclareRelease{v2.4}{2020-02-10}{array-2020-02-10.sty} |
| 34 |
%<+package>\DeclareRelease{v2.5}{2023-11-01}{array-2023-11-01.sty} |
| 35 |
%<+package>\DeclareCurrentRelease{}{2024-06-01} |
| 36 |
%<+package> |
| 37 |
% \end{macrocode} |
| 38 |
% Current version needs a new kernel. |
| 39 |
% \begin{macrocode} |
| 40 |
%<+package>\NeedsTeXFormat{LaTeX2e}[2024/06/01] |
| 41 |
%<+package>\ProvidesPackage{array} |
| 42 |
%<+package> [2025/09/25 v2.6n Tabular extension package (FMi)] |
| 43 |
% |
| 44 |
% \fi |
| 45 |
% |
| 46 |
%% |
| 47 |
% |
| 48 |
% |
| 49 |
% \changes{v2.4g}{2018/04/07}{Renamed internal \cs{mcell@box} to |
| 50 |
% \cs{ar@mcellbox} and \cs{align@mcell} to \cs{ar@align@mcell} |
| 51 |
% to avoid conflict with makecell package} |
| 52 |
% |
| 53 |
% \changes{v2.4c}{2008/09/09}{(WR) Typo fix in documentation} |
| 54 |
% |
| 55 |
% \changes{v2.3c}{1995/11/02}{(DPC) minor doc changes} |
| 56 |
% |
| 57 |
% \changes{v2.3a}{1994/10/16}{Added code for \cs{firsthline} and |
| 58 |
% friends} |
| 59 |
% |
| 60 |
% \changes{v2.2c}{1994/03/14}{removed check for \cs{@tfor} bug} |
| 61 |
% |
| 62 |
% \changes{v1.0b}{1987/06/04}{`@classi (faster), |
| 63 |
% `@classvi (new) A in preamble means |
| 64 |
% \&\& in `halign.} |
| 65 |
% |
| 66 |
% \changes{v1.1a}{1987/07/05}{New concept: |
| 67 |
% preamblechar: c,l,r,C,L,R,A,p,t,{\tt !|},@,!!} |
| 68 |
% \changes{v1.1b}{1987/09/21}{Again p like original \LaTeX{} and z for |
| 69 |
% centered `parbox.} |
| 70 |
% |
| 71 |
% \changes{v1.2a}{1987/09/27}{Completely new implementation.} |
| 72 |
% \changes{v1.2b}{1987/10/06}{{\tt !|} does no longer generate space at |
| 73 |
% start or end of the preamble. Otherwise `hline |
| 74 |
% is too long.} |
| 75 |
% \changes{v1.2b}{1987/10/06}{Enlarged `@arstrutbox by 1pt (Test-Impl) |
| 76 |
% with dimen `@strutheight.} |
| 77 |
% \changes{v1.2c}{1987/10/22}{New dimen parameter `extrarowheight |
| 78 |
% (default: 0pt).} |
| 79 |
% \changes{v1.2c}{1987/10/22}{Enlarged `@arstrutbox by `extrarowheight. |
| 80 |
% Thus you may avoid large characters to |
| 81 |
% overprint a `hline.} |
| 82 |
% \changes{v1.2c}{1987/10/22}{Introduced `m@th in `@array to allow |
| 83 |
% non-zero values of `mathsurround.} |
| 84 |
% \changes{v1.2d}{1987/11/02}{Completed the documentation.} |
| 85 |
% \changes{v1.2e}{1987/11/03}{Bug fixed: A at start of preamble resulted |
| 86 |
% in an error since `@mkpream generated |
| 87 |
% `@arstrut \& ... as a preamble.} |
| 88 |
% \changes{v1.2f}{1987/11/09}{`@testpach documented.} |
| 89 |
% |
| 90 |
% \changes{v1.3a}{1987/11/11}{Again a new implementation, with a new |
| 91 |
% concept (cf. the documentation).} |
| 92 |
% \changes{v1.3b}{1988/03/17}{`@decl expands now into `@empty, i.e., it |
| 93 |
% disappears when the preamble is generated, |
| 94 |
% except when the user specifies A\{\} or |
| 95 |
% B\{\}.} |
| 96 |
% |
| 97 |
% \changes{v1.4a}{1988/03/18}{Test implementation of use of token |
| 98 |
% registers in order to do without `protect.} |
| 99 |
% \changes{v1.4b}{1988/03/19}{Changed erroneous class numbers: |
| 100 |
% 5 -!> 6 |
| 101 |
% 6 -!> 7 |
| 102 |
% 7 -!> 5 |
| 103 |
% Corresponding changes in the macros.} |
| 104 |
% \changes{v1.4c}{1988/03/19}{Everything except p,z now works with token |
| 105 |
% registers.} |
| 106 |
% |
| 107 |
% \changes{v1.9a}{1988/03/20}{Last (so I hope) major change: 1) Options |
| 108 |
% B,A now called !>,<. These options now point |
| 109 |
% to the column they modify.} |
| 110 |
% \changes{v1.9a}{1988/03/20}{2) `protect is no longer necessary. But |
| 111 |
% still the macro `@expast needs top be |
| 112 |
% modified. `multicolumn still does not work.} |
| 113 |
% \changes{v1.9b}{1988/04/29}{inserted missing `fi in `@testpach. |
| 114 |
% Corrected \LaTeX bug in `@tfor.} |
| 115 |
% \changes{v1.9c}{1988/05/07}{Re-introduced `@endpbox. |
| 116 |
% `multicolumn now works!! Version number still |
| 117 |
% 1.9 since the documentation is still not |
| 118 |
% finished.} |
| 119 |
% \changes{v1.9c}{1988/05/07}{1) `def `the@toks \{`the ...\} remaining |
| 120 |
% only in `@mkpream. 2) Removed `@classiii and |
| 121 |
% replaced by `save@decl.} |
| 122 |
% \changes{v1.9c}{1988/05/07}{3) `insert@column contains only `@tempcnta |
| 123 |
% and `count@ counters. 4) `@@startpbox and |
| 124 |
% `@@endpbox now totally obsolete.} |
| 125 |
% \changes{v1.9d}{1988/05/10}{Replaced `number by `the where the `toks |
| 126 |
% registers' contents are used.} |
| 127 |
% \changes{v1.9e}{1988/05/11}{Re-introduced `@xargarraycr and |
| 128 |
% `@yargarraycr, since `endtemplate seems to |
| 129 |
% be `outer.} |
| 130 |
% \changes{v1.9f}{1988/05/20}{Small changes finally carried out: |
| 131 |
% 1) `par!=`@empty. |
| 132 |
% 2) \{..ifnum0!=!`\}... $\to$ `bgroup and |
| 133 |
% analogously `egroup.} |
| 134 |
% \changes{v1.9g}{1988/02/24}{Inserted again \{..ifnum0!=!`\}.., |
| 135 |
% c.f. Appendix D of the \protect\TeX{}book.} |
| 136 |
% \changes{v1.9h}{1988/06/28}{No longer necessary to read in the file |
| 137 |
% twice.} |
| 138 |
% \changes{v1.9i}{1988/06/28}{Corrected typo in german version.} |
| 139 |
% \changes{v1.9j}{1988/11/23}{In a `r' column an extra `kern`z@ is |
| 140 |
% needed.} |
| 141 |
% \changes{v1.9j}{1988/11/23}{Otherwise the `hfil on the left side |
| 142 |
% will be removed by the `unskip in |
| 143 |
% `insert@column if the entry is empty.} |
| 144 |
% \changes{v1.9k}{1988/06/28}{Corrected typo in german version.} |
| 145 |
% \changes{v1.9k}{1989/01/16}{`begin{Macro} changed to `begin{macro} in |
| 146 |
% documentation.} |
| 147 |
% |
| 148 |
% \changes{v2.0a}{1989/05/12}{\cs{@thetoks} changed to \cs{the@toks}.} |
| 149 |
% \changes{v2.0a}{1989/05/12}{source changed to reflect new doc.sty |
| 150 |
% conventions.} |
| 151 |
% \changes{v2.0a}{1989/05/12}{t option renamed to p to be compatible to |
| 152 |
% the original.} |
| 153 |
% \changes{v2.0a}{1989/05/12}{File renamed from arraye.sty to |
| 154 |
% array.sty.} |
| 155 |
% \changes{v2.0b}{1989/05/17}{Three forgotten end macro added.} |
| 156 |
% \changes{v2.0b}{1989/05/17}{All lines shortened to 72 or less.} |
| 157 |
% \changes{v2.2a}{1994/02/03}{Upgrade to \LaTeXe} |
| 158 |
% |
| 159 |
% \DoNotIndex{\@depth,\@ehc,\@fortmp,\@height,\@ifnextchar,\@ifstar} |
| 160 |
% \DoNotIndex{\@ifundefined,\@ne,\@nil,\@tempa,\@tempb} |
| 161 |
% \DoNotIndex{\@tempcnta,\@tempd,\@tempdima,\@whilenum,\@width,\\} |
| 162 |
% \DoNotIndex{\@tforloop} |
| 163 |
% \DoNotIndex{\advance} |
| 164 |
% \DoNotIndex{\baselineskip,\begingroup,\bgroup} |
| 165 |
% \DoNotIndex{\cr,\crcr,\csname} |
| 166 |
% \DoNotIndex{\def,\do,\docdate,\dp} |
| 167 |
% \DoNotIndex{\edef,\egroup,\else,\endcsname,\endinput,\expandafter} |
| 168 |
% \DoNotIndex{\fi,\filedate,\fileversion} |
| 169 |
% \DoNotIndex{\gdef} |
| 170 |
% \DoNotIndex{\hbox,\hfil,\hsize,\hskip,\ht} |
| 171 |
% \DoNotIndex{\if,\ifcase,\ifdim,\ifnum,\ifx,\ignorespaces} |
| 172 |
% \DoNotIndex{\kern} |
| 173 |
% \DoNotIndex{\leavevmode,\let,\lineskip} |
| 174 |
% \DoNotIndex{\m@ne,\multispan} |
| 175 |
% \DoNotIndex{\newcount,\newdimen,\noalign} |
| 176 |
% \DoNotIndex{\or} |
| 177 |
% \DoNotIndex{\relax} |
| 178 |
% \DoNotIndex{\setbox,\space,\strutbox} |
| 179 |
% \DoNotIndex{\tabskip,\thr@@,\the,\toks,\toks@,\tw@,\typeout} |
| 180 |
% \DoNotIndex{\unhcopy,\unskip} |
| 181 |
% \DoNotIndex{\vbox,\vcenter,\vline,\vrule,\vtop,\vskip} |
| 182 |
% \DoNotIndex{\xdef} |
| 183 |
% \DoNotIndex{\z@} |
| 184 |
% |
| 185 |
% |
| 186 |
% \providecommand\env[1]{\texttt{#1}} |
| 187 |
% |
| 188 |
% \providecommand\hook[1]{\texttt{#1\DescribeHook[noprint]{#1}}} |
| 189 |
% \providecommand\socket[1]{\texttt{#1\DescribeSocket[noprint]{#1}}} |
| 190 |
% \providecommand\plug[1]{\texttt{#1\DescribePlug[noprint]{#1}}} |
| 191 |
% |
| 192 |
% \NewDocElement[printtype=\textit{socket},idxtype=socket,idxgroup=Sockets]{Socket}{socketdecl} |
| 193 |
% \NewDocElement[printtype=\textit{hook},idxtype=hook,idxgroup=Hooks]{Hook}{hookdecl} |
| 194 |
% \NewDocElement[printtype=\textit{plug},idxtype=plug,idxgroup=Plugs]{Plug}{plugdecl} |
| 195 |
% |
| 196 |
% |
| 197 |
% \GetFileInfo{array.sty} |
| 198 |
% |
| 199 |
% \title{A new implementation of \LaTeX's \textsf{tabular} |
| 200 |
% and \textsf{array} environment\thanks{This file |
| 201 |
% has version number \fileversion, last |
| 202 |
% revised \filedate.}} |
| 203 |
% \author{Frank Mittelbach |
| 204 |
% \and |
| 205 |
% David Carlisle\thanks{David kindly agreed on the inclusion |
| 206 |
% of the \texttt{\textbackslash{}newcolumntype} implementation, |
| 207 |
% formerly in |
| 208 |
% \texttt{newarray.sty} into this package.}} |
| 209 |
% |
| 210 |
% \date{Printed \today} |
| 211 |
% |
| 212 |
% \MaintainedByLaTeXTeam{tools} |
| 213 |
% \maketitle |
| 214 |
% |
| 215 |
% |
| 216 |
% |
| 217 |
% \MakeShortVerb{\=} |
| 218 |
% |
| 219 |
% \begin{abstract} |
| 220 |
% This article describes an extended implementation of the \LaTeX\ |
| 221 |
% \textsf{array}-- and \textsf{tabular}--environments. The special |
| 222 |
% merits of this implementation are further options to format columns |
| 223 |
% and the fact that fragile \LaTeX--commands don't have to be |
| 224 |
% =\protect='ed any more within those environments. |
| 225 |
% |
| 226 |
% The major part of the code for this package dates back to 1988---so |
| 227 |
% does some of its documentation. |
| 228 |
% \end{abstract} |
| 229 |
% |
| 230 |
% |
| 231 |
% |
| 232 |
% \section{Introduction} |
| 233 |
% |
| 234 |
% This new implementation of the \textsf{array}-- and |
| 235 |
% \textsf{tabular}--environments is part of a larger project in which |
| 236 |
% we are trying to improve the \LaTeX\--code in some aspects and to |
| 237 |
% make \LaTeX\ even easier to handle. |
| 238 |
% |
| 239 |
% The reader should be familiar with the general structure of the |
| 240 |
% environments |
| 241 |
% mentioned above. Further information can be found in |
| 242 |
% \cite{bk:lamport} and \cite{bk:GMS94}. |
| 243 |
% The additional options which can be used in the |
| 244 |
% preamble as well as those which now have a slightly different meaning |
| 245 |
% are described in table~\ref{tab:opt}. |
| 246 |
% |
| 247 |
% \DescribeMacro\extrarowheight |
| 248 |
% Additionally we introduce a new |
| 249 |
% parameter called =\extrarowheight=. If it takes a positive |
| 250 |
% length, the value of the parameter is added to the normal height of |
| 251 |
% every row of the table, while |
| 252 |
% the depth will remain the same. This is important for tables |
| 253 |
% with horizontal lines because those lines normally touch the |
| 254 |
% capital letters. |
| 255 |
% For example, we used =\setlength{\extrarowheight}{1pt}= |
| 256 |
% in table~\ref{tab:opt}. |
| 257 |
% |
| 258 |
% \begin{table}[!t] |
| 259 |
% \begin{center} |
| 260 |
% \setlength{\extrarowheight}{1pt} |
| 261 |
% \begin{tabular}{|>{\ttfamily}c|m{9cm}|} |
| 262 |
% \hline |
| 263 |
% \multicolumn{2}{|c|}{Unchanged options}\\ |
| 264 |
% \hline |
| 265 |
% l & Left adjusted column. \\ |
| 266 |
% c & Centered adjusted column. \\ |
| 267 |
% r & Right adjusted column. \\ |
| 268 |
% p\{width\} & Equivalent to =\parbox[t]{width}=. \\ |
| 269 |
% @\{decl.\} & Suppresses inter-column space and inserts |
| 270 |
% \texttt{decl.}\ instead. \\ |
| 271 |
% \hline |
| 272 |
% \multicolumn{2}{|c|}{New options}\\ |
| 273 |
% \hline |
| 274 |
% m\{width\} & Defines a column of width \texttt{width}. |
| 275 |
% Every entry will be centered in proportion to |
| 276 |
% the rest of the line. It is somewhat like |
| 277 |
% =\parbox{width}=. \\ |
| 278 |
% \hline |
| 279 |
% b\{width\} & Coincides with =\parbox[b]{width}=. \\ |
| 280 |
% \hline |
| 281 |
% >\{decl.\} & Can be used before an \texttt{l}, \texttt{r}, |
| 282 |
% \texttt{c}, \texttt{p}, \texttt{m} or a |
| 283 |
% \texttt{b} option. It inserts \texttt{decl.}\ |
| 284 |
% directly in front of the entry of the column. |
| 285 |
% \\ |
| 286 |
% \hline |
| 287 |
% <\{decl.\} & Can be used after an \texttt{l}, \texttt{r}, |
| 288 |
% \texttt{c}, =p{..}=, =m{..}= or a =b{..}= |
| 289 |
% option. It inserts \texttt{decl.}\ right |
| 290 |
% after the entry of the column. \\ |
| 291 |
% \hline |
| 292 |
% | & Inserts a vertical line. The distance between |
| 293 |
% two columns will be enlarged by the width of |
| 294 |
% the line |
| 295 |
% in contrast to the original definition of |
| 296 |
% \LaTeX. \\ |
| 297 |
% \hline |
| 298 |
% !\{decl.\} & Can be used anywhere and corresponds with the |
| 299 |
% \texttt{|} option. The difference is that |
| 300 |
% \texttt{decl.} is inserted instead of a |
| 301 |
% vertical line, so this option doesn't |
| 302 |
% suppress the normally inserted space between |
| 303 |
% columns in contrast to =@{...}=.\\ |
| 304 |
% \hline\hline |
| 305 |
% w\{align\}\{width\} & Sets the cell content in a box of the |
| 306 |
% specified \texttt{width} aligned according to |
| 307 |
% the \texttt{align} parameter which could be |
| 308 |
% either \texttt{l}, \texttt{c} or |
| 309 |
% \texttt{r}. Works essentially like |
| 310 |
% =\makebox[=width=][=align=]{=cell=}= so |
| 311 |
% silently overprints if the cell content is |
| 312 |
% wider than the specified width. If that is |
| 313 |
% not desired use \texttt{W} instead.\\ |
| 314 |
% \hline |
| 315 |
% W\{align\}\{width\} & Like \texttt{w} but spits out an overfull |
| 316 |
% box warning (and an overfullrule marker in |
| 317 |
% draft mode) when the cell content is too wide |
| 318 |
% to fit. This also means that the alignment is |
| 319 |
% different if there is too much material, |
| 320 |
% because it then always protrudes to the right!\\ |
| 321 |
% \hline |
| 322 |
% \end{tabular} |
| 323 |
% \end{center} |
| 324 |
% \caption{The preamble options.} \label{tab:opt} |
| 325 |
% \end{table} |
| 326 |
% |
| 327 |
% |
| 328 |
% We will discuss a few examples using the new preamble options before |
| 329 |
% dealing with the implementation. |
| 330 |
% \begin{itemize} |
| 331 |
% \item |
| 332 |
% If you want to use a special font (for example =\bfseries=) in a |
| 333 |
% flushed left column, this can be done with =>{\bfseries}l=. You |
| 334 |
% do not have to begin every entry of the column with =\bfseries= |
| 335 |
% any more. |
| 336 |
% \item |
| 337 |
% In columns which have been generated with \texttt{p}, \texttt{m} |
| 338 |
% or \texttt{b}, the default value of =\parindent= is |
| 339 |
% \textsf{0pt}. |
| 340 |
% This can be changed with \\ |
| 341 |
% =>{\setlength{\parindent}{1cm}}p=. |
| 342 |
% \item |
| 343 |
% The \texttt{>}-- and \texttt{<}--options were originally |
| 344 |
% developed for the following application: |
| 345 |
% =>{$}c<{$}= generates a column in math |
| 346 |
% mode in a \textsf{tabular}--environment. If you use this type |
| 347 |
% of a preamble in an \textsf{array}--environment, you get a |
| 348 |
% column in LR mode because the additional \$'s cancel the |
| 349 |
% existing \$'s. |
| 350 |
% \item |
| 351 |
% One can also think of more complex applications. A problem |
| 352 |
% which has |
| 353 |
% been mentioned several times in \TeX{}hax can be solved with |
| 354 |
% =>{\centerdots}c=\linebreak[0]=<{\endcenterdots}=. |
| 355 |
% To center decimals at their |
| 356 |
% decimal points you (only?) have to define the following macros: |
| 357 |
% \begin{verbatim} |
| 358 |
%{\catcode`\.\active\gdef.{\egroup\setbox2\hbox\bgroup}} |
| 359 |
%\def\centerdots{\catcode`\.\active\setbox0\hbox\bgroup} |
| 360 |
%\def\endcenterdots{\egroup\ifvoid2 \setbox2\hbox{0}\fi |
| 361 |
% \ifdim \wd0>\wd2 \setbox2\hbox to\wd0{\unhbox2\hfill}\else |
| 362 |
% \setbox0\hbox to\wd2{\hfill\unhbox0}\fi |
| 363 |
% \catcode`\.12 \box0.\box2} |
| 364 |
%\end{verbatim} |
| 365 |
% Warning: The code is bad, it doesn't work with more than one |
| 366 |
% dot in a cell and doesn't work when the tabular is used in the |
| 367 |
% argument of some other command. A much better version is |
| 368 |
% provided in the \texttt{dcolumn.sty} by David Carlisle. |
| 369 |
% \item |
| 370 |
% Using =c!{\hspace{1cm}}c= you get space between two |
| 371 |
% columns which is enlarged by one centimeter, while |
| 372 |
% =c@{\hspace{1cm}}c= gives you exactly one centimeter |
| 373 |
% space between two columns. |
| 374 |
% |
| 375 |
% \item |
| 376 |
% A declaration like =w{l}{3cm}= (or even shorter =wl{3cm}=) |
| 377 |
% works like an =l= column except that the width will always be |
| 378 |
% =3cm= regardless of the cell content. Same with =w{c}= or |
| 379 |
% =w{r}=. This means that it is easy to set up tables in which all |
| 380 |
% columns have predefined widths. |
| 381 |
% \end{itemize} |
| 382 |
% |
| 383 |
% |
| 384 |
% |
| 385 |
% \subsection{A note on the allowed content of \texttt{>\{...\}} and |
| 386 |
% \texttt{<\{...\}}} |
| 387 |
% |
| 388 |
% These specifiers are meant to hold declarations, such as |
| 389 |
% \verb=>{\itshape}=. They cannot end in commands that take arguments |
| 390 |
% without providing these arguments as part of the \verb={...}=. It |
| 391 |
% would be a mistaken assumption that they pick up all or parts of the |
| 392 |
% alignment entry data if their argument is not provided. E.g., |
| 393 |
% \verb=>{\textbf}= would not make the whole column bold nor would it |
| 394 |
% make the first character bold (technically it would try to |
| 395 |
% bolden \cs{ignorespaces}). Thus, it would not fail with an error, |
| 396 |
% but effectively the output would be wrong and not as expected. |
| 397 |
% |
| 398 |
% \subsection{The behavior of the \cs{\textbackslash} command} |
| 399 |
% |
| 400 |
% In the basic \texttt{tabular} implementation of \LaTeX{} the \cs{\textbackslash} |
| 401 |
% command ending the rows of the \texttt{tabular} or \texttt{array} has |
| 402 |
% a somewhat inconsistent behavior if its optional argument is used. The |
| 403 |
% result then depends on the type of rightmost column and as remarked in |
| 404 |
% Leslie Lamport's \LaTeX{} manual~\cite{bk:lamport} may not always produce the |
| 405 |
% expected extra space. |
| 406 |
% |
| 407 |
% |
| 408 |
% Without the \textsf{array} package the extra space requested by the |
| 409 |
% optional argument of \cs{\textbackslash} is measured from the last baseline of |
| 410 |
% the rightmost column (indicated by ``x'' in the following |
| 411 |
% example). As a result, swapping the column will give different |
| 412 |
% results: |
| 413 |
% \begin{verbatim} |
| 414 |
% \begin{tabular}[t]{lp{1cm}} |
| 415 |
% 1 & 1\newline x \\[20pt] 2 & 2 \end{tabular} |
| 416 |
% \begin{tabular}[t]{p{1cm}l} |
| 417 |
% 1\newline 1 & x \\[20pt] 2 & 2 \end{tabular} |
| 418 |
% \end{verbatim} |
| 419 |
% \pagebreak |
| 420 |
% If you run this without the \textsf{array} package you will get the |
| 421 |
% following result: |
| 422 |
% \begin{center} |
| 423 |
% \begin{tabular}[t]{lp{1cm}} |
| 424 |
% 1 & 1\newline x \\[32pt] 2 & 2 \end{tabular} |
| 425 |
% \begin{tabular}[t]{p{1cm}l} |
| 426 |
% 1\newline 1 & x \\[20pt] 2 & 2 \end{tabular} |
| 427 |
% \end{center} |
| 428 |
% In contrast, when the \textsf{array} package is loaded, the requested |
| 429 |
% space in the optional argument is always measured from the baseline of |
| 430 |
% the whole row and not from the last baseline of the rightmost column, thus |
| 431 |
% swapping columns doesn't change the spacing and we same table height |
| 432 |
% with an effective 8pt of extra space (as the second line already takes |
| 433 |
% up 12pt of the requested 20pt): |
| 434 |
% \begin{center} |
| 435 |
% \begin{tabular}[t]{lp{1cm}} |
| 436 |
% 1 & 1\newline x \\[20pt] 2 & 2 \end{tabular} |
| 437 |
% \begin{tabular}[t]{p{1cm}l} |
| 438 |
% 1\newline 1 & x \\[20pt] 2 & 2 \end{tabular} |
| 439 |
% \end{center} |
| 440 |
% |
| 441 |
% This correction of behavior only makes a difference if the rightmost column |
| 442 |
% is a \texttt{p}-column. Thus if you add the \textsf{array} |
| 443 |
% package to an existing document, you should verify the spacing in all |
| 444 |
% tables that have this kind of structure. |
| 445 |
% |
| 446 |
% |
| 447 |
% \subsection{Defining new column specifiers} |
| 448 |
% |
| 449 |
% \DeleteShortVerb{\=} |
| 450 |
% \MakeShortVerb{\"} |
| 451 |
% \DescribeMacro{\newcolumntype} |
| 452 |
% Whilst it is handy to be able to type |
| 453 |
% \begin{quote} |
| 454 |
% ">{"\meta{some declarations}"}{c}<{"\meta{some more |
| 455 |
% declarations}"}" |
| 456 |
% \end{quote} |
| 457 |
% if you have a one-off column in a table, it is rather inconvenient |
| 458 |
% if you often use columns of this form. The new version allows you |
| 459 |
% to define a new column specifier, say \texttt{x}, which will expand to |
| 460 |
% the primitives column specifiers.\footnote{This command was named |
| 461 |
% \texttt{\textbackslash{}newcolumn} in the \texttt{newarray.sty}. |
| 462 |
% At the moment \texttt{\textbackslash{}newcolumn} is still supported |
| 463 |
% (but gives a warning). In later releases it will vanish.} Thus we |
| 464 |
% may define |
| 465 |
% \begin{quote} |
| 466 |
% "\newcolumntype{x}{>{"\meta{some declarations}"}{c}<{"\meta{some |
| 467 |
% more declarations}"}}"\hspace*{-3cm} ^^A no overfull from this line |
| 468 |
% \end{quote} |
| 469 |
% One can then use the \texttt{x} column specifier in the preamble |
| 470 |
% arguments of all \texttt{array} or \texttt{tabular} environments in |
| 471 |
% which you want columns of this form. |
| 472 |
% |
| 473 |
% It is common to need math-mode and LR-mode columns in the same |
| 474 |
% alignment. If we define: |
| 475 |
% \begin{quote} |
| 476 |
% "\newcolumntype{C}{>{$}c<{$}}" \\ |
| 477 |
% "\newcolumntype{L}{>{$}l<{$}}" \\ |
| 478 |
% "\newcolumntype{R}{>{$}r<{$}}" |
| 479 |
% \end{quote} |
| 480 |
% Then we can use \texttt{C} to get centered LR-mode in an |
| 481 |
% \texttt{array}, or centered math-mode in a \texttt{tabular}. |
| 482 |
% |
| 483 |
% The example given above for `center decimal points' could be |
| 484 |
% assigned to a \texttt{d} specifier with the following command. |
| 485 |
% \begin{quote} |
| 486 |
% "\newcolumntype{d}{>{\centerdots}c<{\endcenterdots}}" |
| 487 |
% \end{quote} |
| 488 |
% |
| 489 |
% The above solution always centers the dot in the |
| 490 |
% column. This does not look too good if the column consists of large |
| 491 |
% numbers, but to only a few decimal places. An alternative definition |
| 492 |
% of a \texttt{d} column is |
| 493 |
% \begin{quote} |
| 494 |
% "\newcolumntype{d}[1]{>{\rightdots{#1}}r<{\endrightdots}}" |
| 495 |
% \end{quote} |
| 496 |
% where the appropriate macros in this case are:\footnote{The package |
| 497 |
% \texttt{dcolumn.sty} contains more robust macros based on these |
| 498 |
% ideas.} |
| 499 |
% \begin{verbatim} |
| 500 |
% \def\coldot{.}% Or if you prefer, \def\coldot{\cdot} |
| 501 |
% {\catcode`\.=\active |
| 502 |
% \gdef.{$\egroup\setbox2=\hbox to \dimen0 \bgroup$\coldot}} |
| 503 |
% \def\rightdots#1{% |
| 504 |
% \setbox0=\hbox{$1$}\dimen0=#1\wd0 |
| 505 |
% \setbox0=\hbox{$\coldot$}\advance\dimen0 \wd0 |
| 506 |
% \setbox2=\hbox to \dimen0 {}% |
| 507 |
% \setbox0=\hbox\bgroup\mathcode`\.="8000 $} |
| 508 |
% \def\endrightdots{$\hfil\egroup\box0\box2} |
| 509 |
%\end{verbatim} |
| 510 |
% Note that "\newcolumntype" takes the same optional argument as |
| 511 |
% "\newcommand" which declares the number of arguments of the column |
| 512 |
% specifier being defined. Now we can specify "d{2}" in our preamble |
| 513 |
% for a column of figures to at most two decimal places. |
| 514 |
% |
| 515 |
% A rather different use of the "\newcolumntype" system takes |
| 516 |
% advantage of the fact that the replacement text in the |
| 517 |
% "\newcolumntype" command may refer to more than one column. Suppose |
| 518 |
% that a document contains a lot of \texttt{tabular} environments that |
| 519 |
% require the same preamble, but you wish to experiment with different |
| 520 |
% preambles. Lamport's original definition allowed you to do the |
| 521 |
% following (although it was probably a mis-use of the system). |
| 522 |
% \begin{quote} |
| 523 |
% "\newcommand{\X}{clr}"\\ |
| 524 |
% "\begin{tabular}{\X}" \ldots |
| 525 |
% \end{quote} |
| 526 |
% \texttt{array.sty} takes great care \textbf{not} to expand the |
| 527 |
% preamble, and so the above does not work with the new scheme. With |
| 528 |
% the new version this functionality is returned: |
| 529 |
% \begin{quote} |
| 530 |
% "\newcolumntype{X}{clr}"\\ |
| 531 |
% "\begin{tabular}{X}" \ldots |
| 532 |
% \end{quote} |
| 533 |
% |
| 534 |
% The replacement text in a "\newcolumntype" command may refer to any of |
| 535 |
% the primitives of \texttt{array.sty} see table \ref{tab:opt} on page |
| 536 |
% \pageref{tab:opt}, or to any new letters defined in other |
| 537 |
% "\newcolumntype" commands. |
| 538 |
% |
| 539 |
% |
| 540 |
% \DescribeMacro{\showcols}A list of all the currently active |
| 541 |
% "\newcolumntype" definitions is sent to the terminal and log file if |
| 542 |
% the "\showcols" command is given. |
| 543 |
% |
| 544 |
% |
| 545 |
% \subsection{Special variations of \texttt{\textbackslash hline}} |
| 546 |
% |
| 547 |
% The family of \texttt{tabular} environments allows |
| 548 |
% vertical positioning with respect to the baseline of |
| 549 |
% the text in which the environment appears. By default the |
| 550 |
% environment appears centered, but this can be changed to |
| 551 |
% align with the first or last line in the environment by |
| 552 |
% supplying a \texttt{t} or \texttt{b} value to the |
| 553 |
% optional position argument. However, this does not work |
| 554 |
% when the first or last element in the environment is a |
| 555 |
% "\hline" command---in that case the environment is |
| 556 |
% aligned at the horizontal rule. |
| 557 |
% |
| 558 |
% \pagebreak[3] |
| 559 |
% |
| 560 |
% Here is an example: |
| 561 |
% \begin{center} |
| 562 |
% \begin{minipage}[t]{.4\linewidth} |
| 563 |
% Tables |
| 564 |
% \begin{tabular}[t]{l} |
| 565 |
% with no\\ hline \\ commands \\ used |
| 566 |
% \end{tabular} versus \\ tables |
| 567 |
% \begin{tabular}[t]{|l|} |
| 568 |
% \hline |
| 569 |
% with some \\ hline \\ commands \\ |
| 570 |
% \hline |
| 571 |
% \end{tabular} used. |
| 572 |
% \end{minipage} |
| 573 |
% \begin{minipage}[t]{.5\linewidth} |
| 574 |
% \begin{verbatim} |
| 575 |
% Tables |
| 576 |
% \begin{tabular}[t]{l} |
| 577 |
% with no\\ hline \\ commands \\ used |
| 578 |
% \end{tabular} versus tables |
| 579 |
% \begin{tabular}[t]{|l|} |
| 580 |
% \hline |
| 581 |
% with some \\ hline \\ commands \\ |
| 582 |
% \hline |
| 583 |
% \end{tabular} used. |
| 584 |
% \end{verbatim} |
| 585 |
% \end{minipage} |
| 586 |
% \end{center} |
| 587 |
% |
| 588 |
% \DescribeMacro\firsthline |
| 589 |
% \DescribeMacro\lasthline |
| 590 |
% Using "\firsthline" and "\lasthline" will |
| 591 |
% cure the problem, and the tables will align properly as long |
| 592 |
% as their first or last line does not contain extremely large |
| 593 |
% objects. |
| 594 |
% \begin{center} |
| 595 |
% \begin{minipage}[t]{.4\linewidth} |
| 596 |
% Tables |
| 597 |
% \begin{tabular}[t]{l} |
| 598 |
% with no\\ line \\ commands \\ used |
| 599 |
% \end{tabular} versus \\ tables |
| 600 |
% \begin{tabular}[t]{|l|} |
| 601 |
% \firsthline |
| 602 |
% with some \\ line \\ commands \\ |
| 603 |
% \lasthline |
| 604 |
% \end{tabular} used. |
| 605 |
% \end{minipage} |
| 606 |
% \begin{minipage}[t]{.5\linewidth} |
| 607 |
% \begin{verbatim} |
| 608 |
% Tables |
| 609 |
% \begin{tabular}[t]{l} |
| 610 |
% with no\\ line \\ commands \\ used |
| 611 |
% \end{tabular} versus tables |
| 612 |
% \begin{tabular}[t]{|l|} |
| 613 |
% \firsthline |
| 614 |
% with some \\ line \\ commands \\ |
| 615 |
% \lasthline |
| 616 |
% \end{tabular} used. |
| 617 |
% \end{verbatim} |
| 618 |
% \end{minipage} |
| 619 |
% \end{center} |
| 620 |
% \DescribeMacro\extratabsurround |
| 621 |
% The implementation of these two commands contains an extra |
| 622 |
% dimension, which is called "\extratabsurround", to add some |
| 623 |
% additional space at the top and the bottom of such an environment. |
| 624 |
% This is useful if such tables are nested. |
| 625 |
% |
| 626 |
% \section{Final Comments} |
| 627 |
% |
| 628 |
% \subsection{Handling of rules} |
| 629 |
% |
| 630 |
% There are two possible approaches to the handling of horizontal and |
| 631 |
% vertical rules in tables: |
| 632 |
% \begin{enumerate} |
| 633 |
% \item rules can be placed into the available space without |
| 634 |
% enlarging the table, or |
| 635 |
% \item rules can be placed between columns or rows thereby enlarging |
| 636 |
% the table. |
| 637 |
% \end{enumerate} |
| 638 |
% For vertical rules \texttt{array.sty} implements the second |
| 639 |
% possibility while the default implementation in the \LaTeX{} kernel |
| 640 |
% implements the first concept. |
| 641 |
% Both concepts have their merits but |
| 642 |
% one has to be aware of the individual implications. |
| 643 |
% \begin{itemize} |
| 644 |
% \item |
| 645 |
% With standard \LaTeX{} adding vertical rules to a table will |
| 646 |
% not affect the |
| 647 |
% width of the table (unless double rules are used), e.g., |
| 648 |
% changing a preamble from \verb=lll= to \verb=l|l|l= does not |
| 649 |
% affect the document other than adding rules to the table. In |
| 650 |
% contrast, with \texttt{array.sty} a table that just fit the |
| 651 |
% \verb=\textwidth= might now produce an overfull box. |
| 652 |
% \item |
| 653 |
% With standard \LaTeX{} modifying the width of rules could result |
| 654 |
% in ugly looking tables because without adjusting the |
| 655 |
% \verb=\tabcolsep=, etc.\ the space between rule and column could |
| 656 |
% get too small (or too large). In fact even overprinting of text is |
| 657 |
% possible. In contrast, with \texttt{array.sty} modifying any such |
| 658 |
% length usually works well as the actual visual white space (from |
| 659 |
% \verb=\tabcolsep=, etc.) does not depend on the width of the |
| 660 |
% rules. |
| 661 |
% \item |
| 662 |
% With standard \LaTeX{} boxed tabulars actually have strange |
| 663 |
% corners because the horizontal rules end in the middle of the |
| 664 |
% vertical ones. This looks very unpleasant when a large |
| 665 |
% \verb=\arrayrulewidth= is chosen. In that case a simple table like |
| 666 |
%\begin{verbatim} |
| 667 |
%\setlength{\arrayrulewidth}{5pt} |
| 668 |
%\begin{tabular}{|l|} |
| 669 |
% \hline A \\ \hline |
| 670 |
%\end{tabular} |
| 671 |
%\end{verbatim} |
| 672 |
% will produce something like |
| 673 |
% \begin{center} |
| 674 |
%\setlength{\arrayrulewidth}{5pt} |
| 675 |
%\begin{tabular}{@{}l@{}} |
| 676 |
% \hline \null\hskip-.5\arrayrulewidth\vline |
| 677 |
% \hskip\tabcolsep |
| 678 |
% A\hskip\tabcolsep |
| 679 |
% \vline\hskip-.5\arrayrulewidth\null \\ \hline |
| 680 |
%\end{tabular} |
| 681 |
% \quad |
| 682 |
% instead of |
| 683 |
% \quad |
| 684 |
%\begin{tabular}{|l|} |
| 685 |
% \hline A \\ \hline |
| 686 |
%\end{tabular} |
| 687 |
% \end{center} |
| 688 |
% \end{itemize} |
| 689 |
% |
| 690 |
% Horizontal rules produced with \cs{hline} add to the table height in |
| 691 |
% both implementations but they differ in handling double \cs{hline}s. |
| 692 |
% In contrast a \cs{cline} does not change the table |
| 693 |
% height.\footnote{All a bit inconsistent, but nothing that can be |
| 694 |
% changed after being 30+ years in existence.} |
| 695 |
% |
| 696 |
% \subsection{Comparisons with older versions of \texttt{array.sty}} |
| 697 |
% |
| 698 |
% There are some differences in the way version 2.1 treats incorrect |
| 699 |
% input, even if the source file does not appear to use any of the |
| 700 |
% extra features of the new version. |
| 701 |
% \begin{itemize} |
| 702 |
% \item A preamble of the form "{wx*{0}{abc}yz}" was treated by |
| 703 |
% versions prior to 2.1 as "{wx}". Version 2.1 treats it as "{wxyz}" |
| 704 |
% \item An incorrect positional argument such as \texttt{[Q]} was |
| 705 |
% treated as \texttt{[c]} by \texttt{array.sty}, but is now treated as |
| 706 |
% \texttt{[t]}. |
| 707 |
% \item A preamble such as "{cc*{2}}" with an error in |
| 708 |
% a $*$-form will generate different errors in the new version. In |
| 709 |
% both cases the error message is not particularly helpful to the |
| 710 |
% casual user. |
| 711 |
% \item Repeated \texttt{<} or \texttt{>} constructions |
| 712 |
% generated an error in earlier versions, but are now allowed in |
| 713 |
% this package. ">{"\meta{decs1}"}>{"\meta{decs2}"}" is treated the |
| 714 |
% same as ">{"\meta{decs2}\meta{decs1}"}". |
| 715 |
% \item The "\extracolsep" |
| 716 |
% command does not work with the old versions of \texttt{array.sty}, |
| 717 |
% see the comments in \texttt{array.bug}. With version 2.1 |
| 718 |
% "\extracolsep" may again be used in \texttt{@}-expressions as in |
| 719 |
% standard \LaTeX, and also in \texttt{!}-expressions (but see the |
| 720 |
% note below). |
| 721 |
% \end{itemize} |
| 722 |
% |
| 723 |
% Prior to version 2.4f the space added by the optional argument to "\\" |
| 724 |
% was added inside an m-cell if the last column was of type |
| 725 |
% \texttt{m}. As a result that cell was vertically centered with that |
| 726 |
% space inside, resulting in a strange offset. Since 2.4f, this space |
| 727 |
% is now added after centering the cell. |
| 728 |
% |
| 729 |
% A similar problem happened when "\extrarowheight" was used. For that |
| 730 |
% reason m-cells now manually position the cell content which |
| 731 |
% allows to ignore this extra space request during the vertical alignment. |
| 732 |
% |
| 733 |
% |
| 734 |
% \subsection{Bugs and Features} |
| 735 |
% |
| 736 |
% \begin{itemize} |
| 737 |
% \item Error messages generated when parsing the column specification |
| 738 |
% refer to the preamble argument \textbf{after} it has been re-written |
| 739 |
% by the "\newcolumntype" system, not to the preamble entered by the |
| 740 |
% user. This seems inevitable with any system based on |
| 741 |
% pre-processing and so is classed as a \textbf{feature}. |
| 742 |
% |
| 743 |
% \item The treatment of multiple \texttt{<} or \texttt{>} |
| 744 |
% declarations may seem strange at first. Earlier implementations |
| 745 |
% treated ">{"\meta{decs1}"}>{"\meta{decs2}"}" the same as |
| 746 |
% ">{"\meta{decs1}\meta{decs2}"}". However this did not give the |
| 747 |
% user the opportunity of overriding the settings of a |
| 748 |
% "\newcolumntype" defined using these declarations. For example, |
| 749 |
% suppose in an \texttt{array} environment we use a \texttt{C} |
| 750 |
% column defined as above. The \texttt{C} specifies a centered text |
| 751 |
% column, however ">{\bfseries}C", which re-writes to |
| 752 |
% ">{\bfseries}>{$}c<{$}" would not specify a bold column as might |
| 753 |
% be expected, as the preamble would essentially expand to |
| 754 |
% "\hfil$\bfseries$#$ $\hfil" and so the column entry would not be in the |
| 755 |
% scope of the "\bfseries"\,! The present version switches the order |
| 756 |
% of repeated declarations, and so the above example now produces a |
| 757 |
% preamble of the form "\hfil$" "$\bfseries#$" "$\hfil", and the |
| 758 |
% dollars cancel each other out without limiting the scope of the |
| 759 |
% "\bfseries". |
| 760 |
% |
| 761 |
% \item The use of "\extracolsep" has been subject to the following |
| 762 |
% two restrictions. There must be at most one "\extracolsep" |
| 763 |
% command per "@", or "!" expression and the command must be |
| 764 |
% directly entered into the "@" expression, not as part of a macro |
| 765 |
% definition. Thus "\newcommand{\ef}{\extracolsep{\fill}}" \ldots |
| 766 |
% "@{\ef}" does not work with this package. However you can use |
| 767 |
% something like |
| 768 |
% "\newcolumntype{e}{@{\extracolsep{\fill}}" instead. |
| 769 |
% |
| 770 |
% \item As noted by the \LaTeX{} book, for the purpose of |
| 771 |
% "\multicolumn" each column with the exception of the first one |
| 772 |
% consists of the entry and the \emph{following} inter-column |
| 773 |
% material. This means that in a tabular with the preamble |
| 774 |
% "|l|l|l|l|" input such as "\multicolumn{2}{|c|}" in |
| 775 |
% anything other than the first column is incorrect. |
| 776 |
|
| 777 |
% In the standard array/tabular implementation this error is not so |
| 778 |
% noticeable as that version contains negative spacing so that each |
| 779 |
% "|" takes up no horizontal space. But since in this package the |
| 780 |
% vertical lines take up their natural width one sees two lines if |
| 781 |
% two are specified. |
| 782 |
% |
| 783 |
% \end{itemize} |
| 784 |
% |
| 785 |
% |
| 786 |
% \section{Support for tagged PDF} |
| 787 |
% |
| 788 |
% With version 2.6a the package is made tagging aware, which means that |
| 789 |
% it will automatically produce tagged tables (necessary, for example, for |
| 790 |
% accessibility) if tagging is requested via \cs{DocumentMetadata}. |
| 791 |
% |
| 792 |
% More granular control, e.g., explicitly deciding which cells are |
| 793 |
% header cells, etc., is currently under development, but syntax for |
| 794 |
% this will not appear in this package. Instead it will become |
| 795 |
% available across all tabular-generating packages and then |
| 796 |
% automatically apply here as well. |
| 797 |
% |
| 798 |
% Enabling \LaTeX{} to automatically produce tagged PDF is a long-term |
| 799 |
% project and this is a tiny step in this puzzle. For more information |
| 800 |
% on the project and already available functionality, see |
| 801 |
% \url{https://latex-project.org/publications/indexbytopic/pdf} and |
| 802 |
% \url{https://github.com/latex3/tagging-project}. |
| 803 |
% |
| 804 |
% |
| 805 |
% |
| 806 |
% \changes{v2.2b}{1994/02/04}{Removed interactive prompt} |
| 807 |
% |
| 808 |
% \MaybeStop{ |
| 809 |
% \begin{thebibliography}{1} |
| 810 |
% \bibitem{bk:GMS94} \textsc{M.~Goossens}, \textsc{F.~Mittelbach} |
| 811 |
% and \textsc{A.~Samarin}. |
| 812 |
% \newblock The \LaTeX{} Companion. |
| 813 |
% \newblock |
| 814 |
% Addison-Wesley, Reading, Massachusetts, 1994. |
| 815 |
% \bibitem{bk:knuth} \textsc{D. E. Knuth}. |
| 816 |
% \newblock The \TeX{}book (Computers \& Typesetting Volume A). |
| 817 |
% \newblock |
| 818 |
% Addison-Wesley, Reading, Massachusetts, 1986. |
| 819 |
% \bibitem{bk:lamport} \textsc{L. Lamport}. |
| 820 |
% \newblock |
| 821 |
% \LaTeX\ --- A Document Preparation System. |
| 822 |
% \newblock |
| 823 |
% Addison-Wesley, Reading, Massachusetts, 1986. |
| 824 |
% \end{thebibliography} |
| 825 |
% } ^^A end of \MaybeStop |
| 826 |
% |
| 827 |
% |
| 828 |
% |
| 829 |
% |
| 830 |
% \section{The documentation driver file} |
| 831 |
% |
| 832 |
% The first bit of code contains the documentation driver file for |
| 833 |
% \TeX{}, i.e., the file that will produce the documentation you are |
| 834 |
% currently reading. It will be extracted from this file by the |
| 835 |
% \texttt{docstrip} program. |
| 836 |
% \begin{macrocode} |
| 837 |
%<*driver> |
| 838 |
\NeedsTeXFormat{LaTeX2e}[2024/06/01] |
| 839 |
% \end{macrocode} |
| 840 |
% |
| 841 |
% We switched from \cls{ltxdoc} to \cls{l3doc} to get support for |
| 842 |
% code written in the L3 programming layer. The first is that we |
| 843 |
% are currently missing \cs{MaintainedByLaTeXTeam}, so we have to |
| 844 |
% provide that for now. |
| 845 |
% \begin{macrocode} |
| 846 |
\documentclass{l3doc} |
| 847 |
|
| 848 |
% currently missing in l3doc |
| 849 |
\makeatletter |
| 850 |
\def\MaintainedBy#1{\gdef\@maintainedby{#1}} |
| 851 |
\let\@maintainedby\@empty |
| 852 |
\def\MaintainedByLaTeXTeam#1{% |
| 853 |
{\gdef\@maintainedby{% |
| 854 |
This file is maintained by the \LaTeX{} Project team.\\% |
| 855 |
Bug reports can be opened (category \texttt{#1}) at\\% |
| 856 |
\url{https://latex-project.org/bugs.html}.}}} |
| 857 |
\def\@maketitle{% |
| 858 |
\newpage |
| 859 |
\null |
| 860 |
\vskip 2em% |
| 861 |
\begin{center}% |
| 862 |
\let \footnote \thanks |
| 863 |
{\LARGE \@title \par}% |
| 864 |
\vskip 1.5em% |
| 865 |
{\large |
| 866 |
\lineskip .5em% |
| 867 |
\begin{tabular}[t]{c}% |
| 868 |
\@author |
| 869 |
\end{tabular}\par}% |
| 870 |
\vskip 1em% |
| 871 |
{\large \@date}% |
| 872 |
\ifx\@maintainedby\@empty |
| 873 |
\else |
| 874 |
\vskip 1em% |
| 875 |
\fbox{\fbox{\begin{tabular}{@{}l@{}}\@maintainedby\end{tabular}}}% |
| 876 |
\fi |
| 877 |
\end{center}% |
| 878 |
\par |
| 879 |
\vskip 1.5em} |
| 880 |
\makeatother |
| 881 |
|
| 882 |
% undo the default is not used: |
| 883 |
|
| 884 |
\IfFormatAtLeastTF {2020/10/01} |
| 885 |
{\AtBeginDocument[ltxdoc]{\DeleteShortVerb{\|}} } |
| 886 |
{\AtBeginDocument{\DeleteShortVerb{\|}} } |
| 887 |
|
| 888 |
\usepackage{array} |
| 889 |
|
| 890 |
% Allow large table at bottom |
| 891 |
\renewcommand{\bottomfraction}{0.7} |
| 892 |
|
| 893 |
\EnableCrossrefs |
| 894 |
%\DisableCrossrefs % Say \DisableCrossrefs if index is ready |
| 895 |
|
| 896 |
\RecordChanges % Gather update information |
| 897 |
|
| 898 |
\CodelineIndex % Index code by line number |
| 899 |
|
| 900 |
%\OnlyDescription % comment out for implementation details |
| 901 |
%\OldMakeindex % use if your MakeIndex is pre-v2.9 |
| 902 |
|
| 903 |
\begin{document} |
| 904 |
\DocInput{array.dtx} |
| 905 |
\end{document} |
| 906 |
%</driver> |
| 907 |
% \end{macrocode} |
| 908 |
% |
| 909 |
% |
| 910 |
% \section{A note on the updates done December 2023} |
| 911 |
% |
| 912 |
% We introduced support for tagged PDF and at the same time we added |
| 913 |
% code to determine row and column numbers for each cell in |
| 914 |
% preparation for supporting formatting or type specifications for individual |
| 915 |
% cells (or group of cells) from the outside, e.g., \enquote{rows 1, |
| 916 |
% 2, and 10 are header rows} (syntax to be decided). |
| 917 |
% |
| 918 |
% This new code is already written with L3 programming layer conventions |
| 919 |
% while most of the legacy code is still as it was before. This make the code |
| 920 |
% currently somewhat clattered, unfortunately. Eventually this will all move to L3 |
| 921 |
% programming layer but this will take time. |
| 922 |
% |
| 923 |
% |
| 924 |
% \begin{macrocode} |
| 925 |
%<@@=tbl> |
| 926 |
\ExplSyntaxOn |
| 927 |
% \end{macrocode} |
| 928 |
% |
| 929 |
% |
| 930 |
% |
| 931 |
% |
| 932 |
% |
| 933 |
% \section{The construction of the preamble} |
| 934 |
% |
| 935 |
% \DeleteShortVerb{\"} |
| 936 |
% \MakeShortVerb{\=} |
| 937 |
% |
| 938 |
% It is obvious that those environments will consist mainly of an |
| 939 |
% =\halign=, because \TeX\ typesets tables using this primitive. |
| 940 |
% That is why we will now take a look at the algorithm which determines |
| 941 |
% a preamble for a =\halign= starting with a given user preamble |
| 942 |
% using the options mentioned above. |
| 943 |
% |
| 944 |
% |
| 945 |
% The current version is defined at the top of the file looking |
| 946 |
% something like this |
| 947 |
% \begin{macrocode} |
| 948 |
%<*package> |
| 949 |
%\NeedsTeXFormat{LaTeX2e}[1994/05/13] |
| 950 |
%\ProvidesPackage{array}[\filedate\space version\fileversion] |
| 951 |
% \end{macrocode} |
| 952 |
% |
| 953 |
% The most interesting macros of this implementation are without doubt |
| 954 |
% those which are responsible for the construction of the preamble for |
| 955 |
% the =\halign=. The underlying algorithm was developed by |
| 956 |
% \textsc{Lamport} (resp.\ \textsc{Knuth}, see texhax V87\#??), and it |
| 957 |
% has been extended and improved. |
| 958 |
% |
| 959 |
% The user preamble will be read \textsf{token} by \textsf{token}. A |
| 960 |
% \textsf{token} is a single character like \texttt{c} or a block |
| 961 |
% enclosed in ={...}=. For example the preamble of |
| 962 |
% =\begin{tabular}=\linebreak[0]={lc||c@{\hspace{1cm}}}= consists of |
| 963 |
% the \textsf{token} \texttt{l}, \texttt{c}, \texttt{|}, \texttt{|}, |
| 964 |
% \texttt{@} and =\hspace{1cm}=. |
| 965 |
% |
| 966 |
% The currently used \textsf{token} and the one, used before, are needed |
| 967 |
% to decide on how the construction of the preamble has to be |
| 968 |
% continued. |
| 969 |
% In the example mentioned above the \texttt{l} causes the preamble |
| 970 |
% to begin with =\hskip\tabcolsep=. Furthermore |
| 971 |
% =# \hfil= would be appended to define a flush left column. |
| 972 |
% The next \textsf{token} is a \texttt{c}. Because it was preceded by an |
| 973 |
% \texttt{l} it generates a new column. This is done with |
| 974 |
% =\hskip \tabcolsep & \hskip \tabcolsep=. The column which is to |
| 975 |
% be centered will be appended with =\hfil # \hfil=. |
| 976 |
% The \textsf{token} \texttt{|} would then add a space of |
| 977 |
% =\hskip \tabcolsep= |
| 978 |
% and a vertical line because the last |
| 979 |
% \textsf{tokens} was a \texttt{c}. |
| 980 |
% The following \textsf{token} \texttt{|} would only add a space |
| 981 |
% =\hskip \doublerulesep= because it was preceded by the |
| 982 |
% \textsf{token} \texttt{|}. We will not discuss our example further but |
| 983 |
% rather take a look at the general case of constructing preambles. |
| 984 |
% |
| 985 |
% The example shows that the desired preamble for the |
| 986 |
% =\halign= can be constructed as soon as the action of all |
| 987 |
% combinations |
| 988 |
% of the preamble \textsf{tokens} are specified. There are 18 such |
| 989 |
% \textsf{tokens} |
| 990 |
% so we have $19 \cdot 18 \string= 342$ combinations if we count the |
| 991 |
% beginning of |
| 992 |
% the preamble as a special \textsf{token}. Fortunately, there are many |
| 993 |
% combinations which generate the same spaces, so we can define |
| 994 |
% \textsf{token} classes. We will identify a |
| 995 |
% \textsf{token} within a class with a number, so we can insert the |
| 996 |
% formatting (for example of a column). |
| 997 |
% Table~\ref{tab:Klassen} lists all \textsf{token} classes and |
| 998 |
% their corresponding numbers. |
| 999 |
% \begin{table}[ht] |
| 1000 |
% \begin{center} |
| 1001 |
% \begin{tabular}[t]{>{\ttfamily}ccc} |
| 1002 |
% \textsf{token} & =\@chclass= & =\@chnum= \\[2mm] |
| 1003 |
% c & 0 & 0 \\ |
| 1004 |
% l & 0 & 1 \\ |
| 1005 |
% r & 0 & 2 \\ |
| 1006 |
% m-arg & 0 & 3 \\ |
| 1007 |
% p-arg & 0 & 4 \\ |
| 1008 |
% b-arg & 0 & 5 \\ |
| 1009 |
% | & 1 & 0 \\ |
| 1010 |
% !-arg & 1 & 1 \\ |
| 1011 |
% <-arg & 2 & --- \\ |
| 1012 |
% >-arg & 3 & --- |
| 1013 |
% \end{tabular} |
| 1014 |
% \kern3mm \vrule \kern3mm% |
| 1015 |
% \begin{tabular}[t]{>{\ttfamily}ccc} |
| 1016 |
% \textsf{token} & =\@chclass= & =\@chnum= \\[2mm] |
| 1017 |
% Start & 4 & --- \\ |
| 1018 |
% @-arg & 5 & --- \\ |
| 1019 |
% ! & 6 & --- \\ |
| 1020 |
% @ & 7 & --- \\ |
| 1021 |
% < & 8 & --- \\ |
| 1022 |
% > & 9 & --- \\ |
| 1023 |
% m & 10 & 3 \\ |
| 1024 |
% p & 10 & 4 \\ |
| 1025 |
% b & 10 & 5 |
| 1026 |
% \end{tabular} |
| 1027 |
% \end{center} |
| 1028 |
% \caption{Classes of preamble \textsf{tokens}} |
| 1029 |
% \label{tab:Klassen} |
| 1030 |
% \end{table} |
| 1031 |
% |
| 1032 |
% |
| 1033 |
% \begin{macro}[int]{\@chclass} |
| 1034 |
% \begin{macro}[int]{\@chnum} |
| 1035 |
% \begin{macro}[int]{\@lastchclass} |
| 1036 |
% The class and the number of the current \textsf{token} are saved in |
| 1037 |
% the |
| 1038 |
% \textsf{count} registers =\@chclass= |
| 1039 |
% and =\@chnum=, while the class of the previous |
| 1040 |
% \textsf{token} is stored in the |
| 1041 |
% \textsf{count} register =\@lastchclass=. |
| 1042 |
% All of the mentioned registers are already allocated in |
| 1043 |
% the \LaTeX{} format, |
| 1044 |
% which is the reason why the following three lines of code are |
| 1045 |
% commented out. |
| 1046 |
% Later throughout the text I will not mention it again explicitly |
| 1047 |
% whenever I use a =%= sign. These parts are already defined in |
| 1048 |
% the \LaTeX{} format. |
| 1049 |
% \begin{macrocode} |
| 1050 |
% \newcount \@chclass |
| 1051 |
% \newcount \@chnum |
| 1052 |
% \newcount \@lastchclass |
| 1053 |
% \end{macrocode} |
| 1054 |
% \end{macro} |
| 1055 |
% \end{macro} |
| 1056 |
% \end{macro} |
| 1057 |
% |
| 1058 |
% |
| 1059 |
% |
| 1060 |
% \begin{macro}[int]{\@addtopreamble} |
| 1061 |
% We will save the already constructed preamble for |
| 1062 |
% the =\halign= |
| 1063 |
% in the global macro =\@preamble=. This will then be |
| 1064 |
% enlarged with |
| 1065 |
% the command =\@addtopreamble=. |
| 1066 |
% \begin{macrocode} |
| 1067 |
\def\@addtopreamble#1{\xdef\@preamble{\@preamble #1}} |
| 1068 |
% \end{macrocode} |
| 1069 |
% \end{macro} |
| 1070 |
% |
| 1071 |
% |
| 1072 |
% |
| 1073 |
% |
| 1074 |
% |
| 1075 |
% \subsection{The character class of a \textsf{token}} |
| 1076 |
% |
| 1077 |
% \begin{macro}[int]{\@testpach} |
| 1078 |
% \changes{v2.0a}{1989/05/12}{p option renamed to m (middle).} |
| 1079 |
% \changes{v2.0a}{1989/05/12}{t option renamed to p to be compatible to |
| 1080 |
% the original.} |
| 1081 |
% With the help of =\@lastchclass= we can now define a macro |
| 1082 |
% which determines the class and the number of a given preamble |
| 1083 |
% \textsf{token} |
| 1084 |
% and assigns them to the registers |
| 1085 |
% =\@chclass= and =\@chnum=. |
| 1086 |
% \changes{v2.0f}{1992/02/29}{Argument removed since implicitly known} |
| 1087 |
% \begin{macrocode} |
| 1088 |
\ExplSyntaxOff |
| 1089 |
\def\@testpach{\@chclass |
| 1090 |
% \end{macrocode} |
| 1091 |
% First we deal with the cases in which the \textsf{token} |
| 1092 |
% (=#1=) is the argument of \texttt{!}, \texttt{@}, \texttt{<} or |
| 1093 |
% \texttt{>}. We can see this from the value of =\@lastchclass=: |
| 1094 |
% \begin{macrocode} |
| 1095 |
\ifnum \@lastchclass=6 \@ne \@chnum \@ne \else |
| 1096 |
\ifnum \@lastchclass=7 5 \else |
| 1097 |
\ifnum \@lastchclass=8 \tw@ \else |
| 1098 |
\ifnum \@lastchclass=9 \thr@@@@ |
| 1099 |
% \end{macrocode} |
| 1100 |
% Otherwise we will assume that the \textsf{token} belongs to the |
| 1101 |
% class $0$ |
| 1102 |
% and assign the corresponding number to =\@chnum= if our |
| 1103 |
% assumption is correct. |
| 1104 |
% \begin{macrocode} |
| 1105 |
\else \z@ |
| 1106 |
% \end{macrocode} |
| 1107 |
% If the last \textsf{token} was a \texttt{p}, \texttt{m} or a |
| 1108 |
% \texttt{b}, =\@chnum= already has the right value. This is the |
| 1109 |
% reason for the somewhat curious choice of the \textsf{token} |
| 1110 |
% numbers in class $10$. |
| 1111 |
% \begin{macrocode} |
| 1112 |
\ifnum \@lastchclass = 10 \else |
| 1113 |
% \end{macrocode} |
| 1114 |
% Otherwise we will check if =\@nextchar= is either a \texttt{c}, |
| 1115 |
% \texttt{l} or an \texttt{r}. Some applications change the |
| 1116 |
% catcodes of certain characters like ``\texttt{@}'' in |
| 1117 |
% \texttt{amstex.sty}. As a result the tests below would fail since |
| 1118 |
% they assume non-active character tokens. Therefore we evaluate |
| 1119 |
% =\@nextchar= once thereby turning the first token of its |
| 1120 |
% replacement text into a char. At this point here this should have |
| 1121 |
% been the only char present in =\@nextchar= which put into via a |
| 1122 |
% =\def=. |
| 1123 |
% \changes{v2.0f}{1992/02/29}{Ensure to test a char which is not active} |
| 1124 |
% \begin{macrocode} |
| 1125 |
\edef\@nextchar{\expandafter\string\@nextchar}% |
| 1126 |
\@chnum |
| 1127 |
\if \@nextchar c\z@ \else |
| 1128 |
\if \@nextchar l\@ne \else |
| 1129 |
\if \@nextchar r\tw@ \else |
| 1130 |
% \end{macrocode} |
| 1131 |
% If it is a different \textsf{token}, we know that the class was |
| 1132 |
% not $0$. We assign the value $0$ to =\@chnum= because this value |
| 1133 |
% is needed for the \texttt{|}--\textsf{token}. Now we must check |
| 1134 |
% the remaining classes. Note that the value of =\@chnum= is |
| 1135 |
% insignificant here for most classes. |
| 1136 |
% \begin{macrocode} |
| 1137 |
\z@ \@chclass |
| 1138 |
\if\@nextchar |\@ne \else |
| 1139 |
\if \@nextchar !6 \else |
| 1140 |
\if \@nextchar @7 \else |
| 1141 |
\if \@nextchar <8 \else |
| 1142 |
\if \@nextchar >9 \else |
| 1143 |
% \end{macrocode} |
| 1144 |
% The remaining permitted \textsf{tokens} are \texttt{p}, |
| 1145 |
% \texttt{m} and \texttt{b} (class $10$). |
| 1146 |
% \begin{macrocode} |
| 1147 |
10 |
| 1148 |
\@chnum |
| 1149 |
\if \@nextchar m\thr@@@@ \else |
| 1150 |
\if \@nextchar p4 \else |
| 1151 |
\if \@nextchar b5 \else |
| 1152 |
% \end{macrocode} |
| 1153 |
% Now the only remaining possibility is a forbidden \textsf{token}, |
| 1154 |
% so we choose class $0$ and number $0$ and give an error message. |
| 1155 |
% Then we finish the macro by closing all =\if='s. |
| 1156 |
% \begin{macrocode} |
| 1157 |
\z@ \@chclass \z@ \@preamerr \z@ \fi \fi \fi \fi |
| 1158 |
\fi \fi \fi \fi \fi \fi \fi \fi \fi \fi \fi \fi} |
| 1159 |
\ExplSyntaxOn |
| 1160 |
% \end{macrocode} |
| 1161 |
% \end{macro} |
| 1162 |
% |
| 1163 |
% |
| 1164 |
% |
| 1165 |
% |
| 1166 |
% |
| 1167 |
% \subsection{Multiple columns (\texorpdfstring{$*$}{*}--form)} |
| 1168 |
% |
| 1169 |
% \begin{macro}[int]{\@xexpast} |
| 1170 |
% \begin{macro}[int]{\the@toks} |
| 1171 |
% \begin{macro}[int]{\the@toksz} |
| 1172 |
% \label{@xexpast} Now we discuss the macro that deletes all forms |
| 1173 |
% of type =*{=\textit{N\/}=}{=\textit{String\/}=}= from a user |
| 1174 |
% preamble and replaces them with \textit{N} copies of |
| 1175 |
% \textit{String}. Nested $*$--expressions are dealt with |
| 1176 |
% correctly, that means $*$--expressions are not substituted if |
| 1177 |
% they are in explicit braces, as in =@{*}=. |
| 1178 |
% |
| 1179 |
% This macro is called via |
| 1180 |
% =\@xexpast=\meta{preamble}=*0x\@@@@=. |
| 1181 |
% The $*$--expression =*0x= is being used to terminate the |
| 1182 |
% recursion, |
| 1183 |
% as we shall see later, and =\@@@@= serves as an argument |
| 1184 |
% delimiter. =\@xexpast= has four arguments. The first |
| 1185 |
% one is the part of the |
| 1186 |
% user preamble before the first $*$--expression while the second |
| 1187 |
% and third ones are the arguments of the first $*$--expression |
| 1188 |
% (that is \textit{N} and \textit{String} in the notation mentioned |
| 1189 |
% above). |
| 1190 |
% The fourth argument is the rest of the preamble. |
| 1191 |
% \begin{macrocode} |
| 1192 |
\def\@xexpast#1*#2#3#4\@@@@{% |
| 1193 |
% \end{macrocode} |
| 1194 |
% The number of copies of \textit{String} (=#2=) that are to be |
| 1195 |
% produced will be saved in a \textsf{count} register. |
| 1196 |
% \begin{macrocode} |
| 1197 |
\@tempcnta #2 |
| 1198 |
% \end{macrocode} |
| 1199 |
% We save the part of the preamble which does not |
| 1200 |
% contain a $*$--form (=#1=) |
| 1201 |
% in a \PlainTeX\ \textsf{token} register. |
| 1202 |
% We also save \textit{String} (=#3=) using a \LaTeX\ |
| 1203 |
% \textsf{token} register. |
| 1204 |
% \begin{macrocode} |
| 1205 |
\toks@={#1}\@temptokena={#3}% |
| 1206 |
% \end{macrocode} |
| 1207 |
% Now we have to use a little trick to produce \textit{N} copies of |
| 1208 |
% \textit{String}. |
| 1209 |
% We could try =\def\@tempa{#1}= and then |
| 1210 |
% \textit{N} times =\edef\@tempa{\@tempa#3}=. This would have the |
| 1211 |
% undesired effect that all macros within =#1= and =#3= |
| 1212 |
% would be expanded, although, for example, constructions like |
| 1213 |
% =@{..}= are not supposed to be changed. |
| 1214 |
% That is why we =\let= two control sequences to |
| 1215 |
% be equivalent to =\relax=. |
| 1216 |
% \begin{macrocode} |
| 1217 |
\let\the@toksz\relax \let\the@toks\relax |
| 1218 |
% \end{macrocode} |
| 1219 |
% Then we ensure that =\@tempa= contains |
| 1220 |
% ={\the@toksz\the@toks...\the@toks}= (the macro |
| 1221 |
% =\the@toks= exactly \textit{N\/} times) as substitution text. |
| 1222 |
% \begin{macrocode} |
| 1223 |
\def\@tempa{\the@toksz}% |
| 1224 |
\ifnum\@tempcnta >0 \@whilenum\@tempcnta >0\do |
| 1225 |
{\edef\@tempa{\@tempa\the@toks}\advance \@tempcnta \m@ne}% |
| 1226 |
% \end{macrocode} |
| 1227 |
% If \textit{N\/} was greater than zero we prepare for another call |
| 1228 |
% of =\@xexpast=. Otherwise we assume we have reached the end of |
| 1229 |
% the user preamble, because we had appended =*0x\@@@@= when we first |
| 1230 |
% called =\@xexpast=. In other words: if the user inserts |
| 1231 |
% =*{0}{..}= in his preamble, \LaTeX\ ignores the rest of it. |
| 1232 |
% \begin{macrocode} |
| 1233 |
\let \@tempb \@xexpast \else |
| 1234 |
\let \@tempb \@xexnoop \fi |
| 1235 |
% \end{macrocode} |
| 1236 |
% Now we will make sure that the part of the user preamble, which |
| 1237 |
% was already dealt with, will be saved again in =\@tempa=. |
| 1238 |
% \begin{macrocode} |
| 1239 |
\def\the@toksz{\the\toks@}\def\the@toks{\the\@temptokena}% |
| 1240 |
\edef\@tempa{\@tempa}% |
| 1241 |
% \end{macrocode} |
| 1242 |
% We have now evaluated the first $*$--expression, and the user |
| 1243 |
% preamble up to this point |
| 1244 |
% is saved in =\@tempa=. We will put the contents of |
| 1245 |
% =\@tempa= and the rest of the user preamble together and work |
| 1246 |
% on the result with =\@tempb=. This macro either corresponds |
| 1247 |
% to =\@xexpast=, so that the next |
| 1248 |
% $*$--expression is handled, or to the macro =\@xexnoop=, |
| 1249 |
% which only ends the recursion by deleting its argument. |
| 1250 |
% \begin{macrocode} |
| 1251 |
\expandafter \@tempb \@tempa #4\@@@@} |
| 1252 |
% \end{macrocode} |
| 1253 |
% \end{macro} |
| 1254 |
% \end{macro} |
| 1255 |
% \end{macro} |
| 1256 |
% |
| 1257 |
% \begin{macro}[int]{\@xexnoop} |
| 1258 |
% So the first big problem is solved. Now it is easy to |
| 1259 |
% specify =\@xexnoop=. |
| 1260 |
% Its argument is delimited by =\@@@@= and it simply expands to |
| 1261 |
% nothing. |
| 1262 |
% \begin{macrocode} |
| 1263 |
% \def\@xexnoop#1\@@@@{} |
| 1264 |
% \end{macrocode} |
| 1265 |
% \end{macro} |
| 1266 |
% |
| 1267 |
% |
| 1268 |
% |
| 1269 |
% |
| 1270 |
% \section{The insertion of declarations |
| 1271 |
% (\texttt{>}, \texttt{<}, \texttt{!}, \texttt{@})} |
| 1272 |
% |
| 1273 |
% |
| 1274 |
% The preamble will be enlarged with the help of =\xdef=, but the |
| 1275 |
% arguments of \texttt{>}, \texttt{<},~\texttt{!}\ and \texttt{@} are |
| 1276 |
% not supposed to be expanded during the construction (we want an |
| 1277 |
% implementation that doesn't need a =\protect=). So we have to find a |
| 1278 |
% way to inhibit the expansion of those arguments. |
| 1279 |
% |
| 1280 |
% We will solve this problem with \textsf{token} registers. We need |
| 1281 |
% one register for every \texttt{!}\ and \texttt{@}, while we need two |
| 1282 |
% for every \texttt{c}, \texttt{l}, \texttt{r}, \texttt{m}, \texttt{p} |
| 1283 |
% or \texttt{b}. This limits the number of columns of a table because |
| 1284 |
% there are only 256 \textsf{token} registers. But then, who needs |
| 1285 |
% tables with more than 100 columns? |
| 1286 |
% |
| 1287 |
% One could also find a solution which only needs two or three |
| 1288 |
% \textsf{token} registers by proceeding similarly as in the macro |
| 1289 |
% =\@xexpast= (see page \pageref{@xexpast}). The advantage of our |
| 1290 |
% approach is the fact that we avoid some of the problems that arise |
| 1291 |
% with the other method\footnote{Maybe there are also historical |
| 1292 |
% reasons.}. |
| 1293 |
% |
| 1294 |
% So how do we proceed? Let us assume that we had =!{foo}= in the |
| 1295 |
% user preamble and say we saved \texttt{foo} in |
| 1296 |
% \textsf{token} register $5$. Then we call |
| 1297 |
% =\@addtopreamble{\the@toks5}= where |
| 1298 |
% =\the@toks= is defined in a way that it does not expand |
| 1299 |
% (for example it could be equivalent to =\relax=). Every |
| 1300 |
% following call |
| 1301 |
% of =\@addtopreamble= leaves =\the@toks5= unchanged in |
| 1302 |
% =\@preamble=. If the construction of the preamble is completed |
| 1303 |
% we change the definition of =\the@toks= to |
| 1304 |
% =\the\toks= and expand =\@preamble= for the last time. |
| 1305 |
% During this process all parts of the form |
| 1306 |
% =\the@toks=\meta{Number} |
| 1307 |
% will be substituted by the contents of the respective \textsf{token} |
| 1308 |
% registers. |
| 1309 |
% |
| 1310 |
% As we can see from this informal discussion the construction of the |
| 1311 |
% preamble has to take place within a group, so that the |
| 1312 |
% \textsf{token} registers we use will be freed later on. For that |
| 1313 |
% reason we keep all assignments to =\@preamble= global; therefore the |
| 1314 |
% replacement text of this macro will remain the same after we leave |
| 1315 |
% the group. |
| 1316 |
% |
| 1317 |
% \begin{macro}[int]{\count@} |
| 1318 |
% We further need a \textsf{count} register to remember which |
| 1319 |
% \textsf{token} register is to be used next. This will be |
| 1320 |
% initialized with $-1$ if we want to begin with the \textsf{token} |
| 1321 |
% register $0$. We use the \PlainTeX\ scratch register =\count@= |
| 1322 |
% because everything takes place locally. All we have to do is |
| 1323 |
% insert =\the@toks= =\the= =\count@= into the preamble. |
| 1324 |
% =\the@toks= will remain unchanged and =\the\count@= expands into |
| 1325 |
% the saved number. |
| 1326 |
% \end{macro} |
| 1327 |
% |
| 1328 |
% \begin{macro}[int]{\prepnext@tok} |
| 1329 |
% The macro =\prepnext@tok= is in charge of preparing the next |
| 1330 |
% \textsf{token} register. For that purpose we increase |
| 1331 |
% =\count@= by $1$: |
| 1332 |
% \begin{macrocode} |
| 1333 |
\def\prepnext@tok{\advance \count@ \@ne |
| 1334 |
% \end{macrocode} |
| 1335 |
% Then we locally delete any contents the |
| 1336 |
% \textsf{token} register might have. |
| 1337 |
% \begin{macrocode} |
| 1338 |
\toks\count@{}} |
| 1339 |
% \end{macrocode} |
| 1340 |
% \end{macro} |
| 1341 |
% |
| 1342 |
% \begin{macro}[int]{\save@decl} |
| 1343 |
% During the construction of the preamble the current |
| 1344 |
% \textsf{token} is always saved in the macro =\@nextchar= (see the |
| 1345 |
% definition of =\@mkpream= on page \pageref{@mkpream}). The macro |
| 1346 |
% =\save@decl= saves it into the next free \textsf{token} register, |
| 1347 |
% i.e.\ in =\toks\count@=. |
| 1348 |
% \changes{v2.0c}{1990/08/14}{\cs{relax} removed and added elsewhere.} |
| 1349 |
% \begin{macrocode} |
| 1350 |
\def\save@decl{\toks\count@ \expandafter{\@nextchar}} |
| 1351 |
% \end{macrocode} |
| 1352 |
% The reason for the use of =\relax= is the following |
| 1353 |
% hypothetical situation in the preamble: |
| 1354 |
% \quad =..\the\toks1\the\toks2..= \quad \TeX\ expands |
| 1355 |
% =\the\toks2= first in order to find out if the digit =1= |
| 1356 |
% is followed by other digits. E.g.\ a =5= saved in the |
| 1357 |
% \textsf{token} register $2$ would lead \TeX\ to insert the contents |
| 1358 |
% of \textsf{token} register $15$ instead of $1$ later on. |
| 1359 |
% |
| 1360 |
% The example above referred to an older version of =\save@decl= which |
| 1361 |
% inserted a =\relax= inside the token register. This is now moved to |
| 1362 |
% the places where the actual token registers are inserted (look for |
| 1363 |
% =\the@toks=) because the old version would still make =@= |
| 1364 |
% expressions to moving arguments since after expanding the second |
| 1365 |
% register while looking for the end of the number the contents of the |
| 1366 |
% token register is added so that later on the whole register will be |
| 1367 |
% expanded. This serious bug was found after nearly two years |
| 1368 |
% international use of this package by Johannes Braams. |
| 1369 |
% \end{macro} |
| 1370 |
% |
| 1371 |
% |
| 1372 |
% |
| 1373 |
% How does the situation look like, if we want to add another column |
| 1374 |
% to the preamble, i.e.\ if we have found a \texttt{c}, \texttt{l}, |
| 1375 |
% \texttt{r}, \texttt{p}, \texttt{m} or \texttt{b} in the user |
| 1376 |
% preamble? In this case we have the problem of the \textsf{token} |
| 1377 |
% register from =>{..}= and =<{..}= having to be inserted at this |
| 1378 |
% moment because formatting instructions like =\hfil= have to be set |
| 1379 |
% around them. On the other hand it is not known yet, if any =<{..}= |
| 1380 |
% instruction will appear in the user preamble at all. |
| 1381 |
% |
| 1382 |
% We solve this problem by adding two \textsf{token} registers at a |
| 1383 |
% time. This explains, why we have freed the \textsf{token} registers |
| 1384 |
% in =\prepnext@tok=. |
| 1385 |
% |
| 1386 |
% \begin{macro}[int]{\insert@column} |
| 1387 |
% \begin{macro}[int]{\@sharp} |
| 1388 |
% \begin{macro}[int]{\textonly@unskip} |
| 1389 |
% \begin{macro}[int]{\@protected@firstofone} |
| 1390 |
% We now define the macro =\insert@column= which will do |
| 1391 |
% this work for us. |
| 1392 |
% \begin{macrocode} |
| 1393 |
\def\insert@column{% |
| 1394 |
% \end{macrocode} |
| 1395 |
% |
| 1396 |
% For tagging we insert as special socket, that adds the necessary |
| 1397 |
% PDF tag at the beginning of the cell if tagging is enabled. |
| 1398 |
% \changes{v2.6a}{2023/12/11}{Support for tagged PDF} |
| 1399 |
% \begin{macrocode} |
| 1400 |
\UseTaggingSocket{tbl/cell/begin}% |
| 1401 |
% \end{macrocode} |
| 1402 |
% Next we have to insert the toks register holding the content of |
| 1403 |
% \verb=>{...}=. Here, we assume that the \textsf{count} register |
| 1404 |
% =\@tempcnta= has saved the value $=\count@= - 1$. |
| 1405 |
% |
| 1406 |
% To keep \TeX{} happy if there is a look ahead in the tabular |
| 1407 |
% preamble, i.e., starting in \verb=>{...}=, which uses the |
| 1408 |
% Appendix~D trick (for example, anything with a trailing optional |
| 1409 |
% argument defined by \pkg{ltcmd}), we wrap everything here in a |
| 1410 |
% protected version of \cs{@firstofone}. \TeX{} otherwise can get |
| 1411 |
% confused about the value of the master counter, and we get some |
| 1412 |
% strange errors. We suspected that there was an underlying issue |
| 1413 |
% is the \TeX{} engine, but it turned out to be rather hard to get |
| 1414 |
% to the bottom of it, because the master counter is not accessible |
| 1415 |
% through \TeX{}'s tracing tools. Thus, all we could do was |
| 1416 |
% producing various example documents, observing results, as well |
| 1417 |
% as staring at a printout of the \TeX{} program. As an example, |
| 1418 |
% without this approach, something like |
| 1419 |
% \begin{verbatim} |
| 1420 |
% \NewDocumentCommand\foo{o}{x} |
| 1421 |
% \begin{tabular}{>{\foo}l} |
| 1422 |
% Foo |
| 1423 |
% \end{tabular} |
| 1424 |
% \end{verbatim} |
| 1425 |
% failed. That can be fixed by adding a \cs{relax} after the |
| 1426 |
% \cs{@tempcnta}, but that then leads to issues if you are |
| 1427 |
% collecting whole cells (tagging code or \pkg{collcell}), where |
| 1428 |
% you can no longer alter the meaning of \cs{cr} as the master |
| 1429 |
% counter goes wrong due to an obscure bug (or perhaps, say, an |
| 1430 |
% undocumented feature of \TeX{}). Eventually, we were able to pin |
| 1431 |
% down the root cause and really understand why |
| 1432 |
% \cs{@protected@firstofone} solves the problem, even though it |
| 1433 |
% looks like a nonsense addition to the code that does nothing |
| 1434 |
% useful.\footnote{So it is a \TeX{} engine bug that was in there |
| 1435 |
% from day one, or if you like, it is a hidden feature that is not |
| 1436 |
% explained; neither in the \TeX{}book nor in the program code. We |
| 1437 |
% don't really expect this to change in \TeX{} after such a long |
| 1438 |
% time, other than perhaps documenting it as a feature, so this is |
| 1439 |
% a proper solution to the problem and not just a workaround.} |
| 1440 |
% |
| 1441 |
% The problem is that \TeX{} tries to conserve stack space, and |
| 1442 |
% when the last token of an existing token list is a macro, then |
| 1443 |
% this token list is \emph{first} removed from memory (reducing the |
| 1444 |
% stack) \emph{before} the macro replacement text (as a new |
| 1445 |
% token list) is given to the parser adding a new stack level. This |
| 1446 |
% is done using the routine \texttt{end\_token\_list} in the \TeX{} |
| 1447 |
% program and ending the u-part of an \cs{halign} column with this |
| 1448 |
% routine immediately sets the \emph{master counter} used by alignments to |
| 1449 |
% zero (see chapter~22 and Appendix~D of the \TeX{}book). This |
| 1450 |
% means that technically the expansion of the last token in the u-part (if it |
| 1451 |
% is a macro) is not executed in the context of the u-part, but in |
| 1452 |
% the context of the alignment entry in the document. That normally |
| 1453 |
% doesn't make any difference whatsoever --- unless you play |
| 1454 |
% around (as we sometimes have to) with tricks like those from |
| 1455 |
% Appendix~D. |
| 1456 |
% |
| 1457 |
% To illustrate the issue we show a bit of strange low-level plain |
| 1458 |
% \TeX{} code.\footnote{If all of this looks mighty strange to you, |
| 1459 |
% don't worry. You will be unlikely to need to know about it. It is |
| 1460 |
% just there so that programmers at some point in the future do not |
| 1461 |
% have to wonder too much why there is this odd |
| 1462 |
% \cs{@protected@firstofone} that apparently does nothing |
| 1463 |
% useful. It took us several nights of head scratching to come up |
| 1464 |
% with these minimal examples and then some more time to understand |
| 1465 |
% what the heck is going on inside \TeX{}---thanks to Bruno for the |
| 1466 |
% right ideas on the latter.} Below are two very special grouping |
| 1467 |
% commands that are like \cs{bgroup} and \cs{egroup} but also |
| 1468 |
% affect the alignment master counter when expanded (see |
| 1469 |
% \TeX{}book p.385). If one of them is used as the |
| 1470 |
% last macro in the u-part of a column, then you get strange errors |
| 1471 |
% that you shouldn't get. |
| 1472 |
% \begin{verbatim} |
| 1473 |
% \def\bbgroup{{\ifnum0=`}\fi} |
| 1474 |
% \def\eegroup{\ifnum0=`{\fi}} |
| 1475 |
% |
| 1476 |
% % Fails with an error message, but there should be none: |
| 1477 |
% \halign{% |
| 1478 |
% \message{u-part^^J}% |
| 1479 |
% \bbgroup % <-- in the u-part |
| 1480 |
% \eegroup % <-- in the u-part |
| 1481 |
% #% |
| 1482 |
% \message{v-part^^J}% |
| 1483 |
% \hfill\cr |
| 1484 |
% \message{body^^J}x |
| 1485 |
% \cr |
| 1486 |
% } |
| 1487 |
% |
| 1488 |
% % Fails but should work, the v-part is never reached: |
| 1489 |
% \halign{% |
| 1490 |
% \message{u-part^^J}% |
| 1491 |
% \bbgroup % <-- in the u-part |
| 1492 |
% #% |
| 1493 |
% \message{v-part^^JJ}% |
| 1494 |
% \eegroup % <-- in the v-part |
| 1495 |
% \hfill\cr |
| 1496 |
% \message{body^^J}x |
| 1497 |
% \cr |
| 1498 |
% } |
| 1499 |
% \end{verbatim} |
| 1500 |
% |
| 1501 |
% So the trick we use now is making \cs{@protected@firstofone} the |
| 1502 |
% last macro in the u-part, i.e., before the \cs{@sharp}. That way |
| 1503 |
% its argument is always fully expanded as part of the alignment |
| 1504 |
% entry and not as part of the u-part and this way we know exactly |
| 1505 |
% what the master counter value is at this point, regardless of the content of |
| 1506 |
% \verb=>{...}=. |
| 1507 |
% |
| 1508 |
% \changes{v2.6f}{2024/09/13}{Stop parsing for optional argument (gh/1468)} |
| 1509 |
% \changes{v2.6g}{2024/10/12}{Further work to support optional args in preamble (gh/1468)} |
| 1510 |
% \begin{macrocode} |
| 1511 |
\@protected@firstofone { \the@toks \the \@tempcnta \ignorespaces } |
| 1512 |
% \end{macrocode} |
| 1513 |
% Next follows the =#= sign which specifies the place |
| 1514 |
% where the text of the column shall be inserted. To avoid |
| 1515 |
% errors during the expansions in |
| 1516 |
% =\@addtopreamble= we hide this sign in the command |
| 1517 |
% =\@sharp= which is temporarily occupied with |
| 1518 |
% =\relax= during the build-up of the preamble. |
| 1519 |
% To remove unwanted spaces before and after the column in text mode, |
| 1520 |
% we set an =\ignorespaces= in front (see above) and a =\unskip= |
| 1521 |
% afterwards; in math mode, the latter is suppressed while the |
| 1522 |
% \cs{ignorespaces} makes no difference. |
| 1523 |
% \changes{v2.0e}{1991/02/07}{Added \{\} around \cs{@sharp} for new ftsel} |
| 1524 |
% \changes{v2.0h}{1992/06/22}{Removed \{\} again in favor of |
| 1525 |
% \cs{d@llarbegin}} |
| 1526 |
% \changes{v2.6b}{2024/04/08}{Do not \cs{unskip} if in math mode (gh/1323)} |
| 1527 |
% \begin{macrocode} |
| 1528 |
\@sharp \textonly@unskip |
| 1529 |
% \end{macrocode} |
| 1530 |
% Then the second \textsf{token} register follows whose number should |
| 1531 |
% be saved in =\count@=. |
| 1532 |
% We make sure that there will be no further expansion after reading |
| 1533 |
% the number, by finishing with =\relax=. The case above is not |
| 1534 |
% critical since it is ended by =\ignorespaces=. |
| 1535 |
% \changes{v2.0c}{1990/08/14}{\cs{relax} added to avoid problem |
| 1536 |
% \cs{the}\cs{toks0}\cs{the}\cs{toks1}.} |
| 1537 |
% \begin{macrocode} |
| 1538 |
\the@toks \the \count@ \relax |
| 1539 |
% \end{macrocode} |
| 1540 |
% |
| 1541 |
% And another socket for tagging that adds the necessary closing tag |
| 1542 |
% if enabled. |
| 1543 |
% \changes{v2.6a}{2023/12/11}{Support for tagged PDF} |
| 1544 |
% \begin{macrocode} |
| 1545 |
\UseTaggingSocket{tbl/cell/end}% |
| 1546 |
} |
| 1547 |
% \end{macrocode} |
| 1548 |
% Do the unskip only if we are in hmode: |
| 1549 |
% \changes{v2.6b}{2024/04/08}{Do not \cs{unskip} if in math mode (gh/1323)} |
| 1550 |
% \begin{macrocode} |
| 1551 |
\protected\def\textonly@unskip{\ifhmode\unskip\fi} |
| 1552 |
% \end{macrocode} |
| 1553 |
% \changes{v2.6g}{2024/10/12}{Further work to support optional args in preamble (gh/1468)} |
| 1554 |
% We need an engine-protected function that is just \cs{@firstofone}: |
| 1555 |
% \begin{macrocode} |
| 1556 |
\protected\long\def\@protected@firstofone#1{#1} |
| 1557 |
% \end{macrocode} |
| 1558 |
% \end{macro} |
| 1559 |
% \end{macro} |
| 1560 |
% \end{macro} |
| 1561 |
% \end{macro} |
| 1562 |
% |
| 1563 |
% \begin{macro}[int]{\insert@pcolumn} |
| 1564 |
% Handling pcolumn-cells needs slightly different handling when |
| 1565 |
% doing tagging. Rather than changing the plugs in |
| 1566 |
% \cs{insert@column} back and forth, we simply use a different |
| 1567 |
% version of \cs{insert@column} that has its own sockets. |
| 1568 |
% \changes{v2.6a}{2023/12/11}{Support for tagged PDF} |
| 1569 |
% \begin{macrocode} |
| 1570 |
\def\insert@pcolumn{% |
| 1571 |
\UseTaggingSocket{tbl/pcell/begin}% |
| 1572 |
% \end{macrocode} |
| 1573 |
% \changes{v2.6f}{2024/09/13}{Stop parsing for optional argument (gh/1468)} |
| 1574 |
% \begin{macrocode} |
| 1575 |
\the@toks \the \@tempcnta \relax |
| 1576 |
\ignorespaces \@sharp \unskip |
| 1577 |
\the@toks \the \count@ \relax |
| 1578 |
\UseTaggingSocket{tbl/pcell/end}% |
| 1579 |
} |
| 1580 |
% \end{macrocode} |
| 1581 |
% \end{macro} |
| 1582 |
% |
| 1583 |
% |
| 1584 |
% \subsection{The separation of columns} |
| 1585 |
% |
| 1586 |
% \begin{macro}[int]{\@addamp} |
| 1587 |
% In the preamble a =&= has to be inserted between any two columns; |
| 1588 |
% before the first column there should not be a =&=. As the user |
| 1589 |
% preamble may start with a \texttt{|} we have to remember somehow |
| 1590 |
% if we have already inserted a =#= (i.e.\ a column). This is done |
| 1591 |
% with the boolean variable =\if@firstamp= that we test in |
| 1592 |
% =\@addamp=, the macro that inserts the =&=. |
| 1593 |
% \begin{macrocode} |
| 1594 |
% \newif \@iffirstamp |
| 1595 |
\def\@addamp { |
| 1596 |
\if@firstamp |
| 1597 |
\@firstampfalse |
| 1598 |
\else |
| 1599 |
% \end{macrocode} |
| 1600 |
% If we are after the first column we have to insert a \verb=&= and |
| 1601 |
% also update the cell data. |
| 1602 |
% \changes{v2.6a}{2023/12/11}{Managing cell indexes} |
| 1603 |
% \begin{macrocode} |
| 1604 |
\edef\@preamble{\@preamble & |
| 1605 |
\noexpand\tbl_update_cell_data: } |
| 1606 |
\fi |
| 1607 |
} |
| 1608 |
% \end{macrocode} |
| 1609 |
% \end{macro} |
| 1610 |
% |
| 1611 |
% |
| 1612 |
% |
| 1613 |
% \begin{macro}[int]{\@acol} |
| 1614 |
% \begin{macro}[int]{\@acolampacol} |
| 1615 |
% \begin{macro}[int]{\col@sep} |
| 1616 |
% We will now define some abbreviations for the extensions, |
| 1617 |
% appearing most often in the preamble build-up. |
| 1618 |
% Here =\col@sep= is a \textsf{dimen} register which is set |
| 1619 |
% equivalent to =\arraycolsep= in an \textsf{array}--environment, |
| 1620 |
% otherwise it is set equivalent to =\tabcolsep=. |
| 1621 |
% \begin{macrocode} |
| 1622 |
\newdimen\col@sep |
| 1623 |
\def\@acol{\@addtopreamble{\hskip\col@sep}} |
| 1624 |
% \def\@acolampacol{\@acol\@addamp\@acol} |
| 1625 |
% \end{macrocode} |
| 1626 |
% \end{macro} |
| 1627 |
% \end{macro} |
| 1628 |
% \end{macro} |
| 1629 |
% |
| 1630 |
% |
| 1631 |
% \subsection{The macro \texttt{\textbackslash @mkpream}} |
| 1632 |
% |
| 1633 |
% \begin{macro}[int]{\@mkpream} |
| 1634 |
% \emph{The code below has been replaced long time ago by an |
| 1635 |
% extended version further down but the code and its documentation |
| 1636 |
% was left here for reference. It is now commented out to avoid |
| 1637 |
% confusion.} |
| 1638 |
% \begin{macro}[int]{\the@toks} |
| 1639 |
% \label{@mkpream} |
| 1640 |
% Now we can define the macro which builds up the preamble for the |
| 1641 |
% =\halign=. |
| 1642 |
% First we initialize =\@preamble=, =\@lastchclass= |
| 1643 |
% and the boolean variable =\if@firstamp=. |
| 1644 |
% \begin{macrocode} |
| 1645 |
%\def\@mkpream#1{\gdef\@preamble{}\@lastchclass 4 \@firstamptrue |
| 1646 |
% \end{macrocode} |
| 1647 |
% During the build-up of the preamble we cannot directly use the |
| 1648 |
% =#= sign; this would lead to an error message in the next |
| 1649 |
% =\@addtopreamble= call. |
| 1650 |
% Instead, we use the command =\@sharp= at places where later |
| 1651 |
% a =#= will be. |
| 1652 |
% This command is at first given the meaning =\relax=; |
| 1653 |
% therefore it will not be expanded when the preamble |
| 1654 |
% is extended. |
| 1655 |
% In the macro =\@array=, shortly before the =\halign= |
| 1656 |
% is carried out, =\@sharp= is given its final meaning. |
| 1657 |
% |
| 1658 |
% In a similar way, |
| 1659 |
% we deal with the commands =\@startpbox= and |
| 1660 |
% =\@endpbox=, although the reason is different here: these |
| 1661 |
% macros expand in many \textsf{tokens} which would delay the |
| 1662 |
% build-up of the preamble. |
| 1663 |
% \begin{macrocode} |
| 1664 |
% \let\@sharp\relax\let\@startpbox\relax\let\@endpbox\relax |
| 1665 |
% \end{macrocode} |
| 1666 |
% Two more are needed to deal with the code that handles struts |
| 1667 |
% for extra space after a row from =\\[<space>]= |
| 1668 |
% (=\do@row@strut=) and code that manages m-cells depending on |
| 1669 |
% their heights (=\ar@align@mcell=). |
| 1670 |
% \changes{v2.4e}{2016/10/07}{Fixing SX68732} |
| 1671 |
% \changes{v2.4f}{2017/11/04}{Managing m-cells without \cs{vcenter}} |
| 1672 |
% \begin{macrocode} |
| 1673 |
% \let\do@row@strut\relax |
| 1674 |
% \let\ar@align@mcell\relax |
| 1675 |
% \end{macrocode} |
| 1676 |
% Now we remove possible $*$-forms in the user preamble with the |
| 1677 |
% command =\@xexpast=. As we already know, this command saves |
| 1678 |
% its result in the macro =\@tempa=. |
| 1679 |
% \begin{macrocode} |
| 1680 |
% \@xexpast #1*0x\@@@@ |
| 1681 |
% \end{macrocode} |
| 1682 |
% Afterwards we initialize all registers and macros, that we need |
| 1683 |
% for the build-up of the preamble. |
| 1684 |
% Since we want to start with the \textsf{token} register $0$, |
| 1685 |
% =\count@= has to contain the value $-1$. |
| 1686 |
% \begin{macrocode} |
| 1687 |
% \count@\m@ne |
| 1688 |
% \let\the@toks\relax |
| 1689 |
% \end{macrocode} |
| 1690 |
% Then we call up =\prepnext@tok= in order to prepare the |
| 1691 |
% \textsf{token} register $0$ for use. |
| 1692 |
% \begin{macrocode} |
| 1693 |
% \prepnext@tok |
| 1694 |
% \end{macrocode} |
| 1695 |
% To evaluate the user preamble (without stars) saved in |
| 1696 |
% =\@tempa= we use the \LaTeX--macro =\@tfor=. |
| 1697 |
% The strange appearing construction with =\expandafter= is |
| 1698 |
% based on the fact that we have to put the replacement text of |
| 1699 |
% =\@tempa= and not the macro =\@tempa= to this |
| 1700 |
% \LaTeX--macro. |
| 1701 |
% \begin{macrocode} |
| 1702 |
% \expandafter \@tfor \expandafter \@nextchar |
| 1703 |
% \expandafter :\expandafter =\@tempa \do |
| 1704 |
% \end{macrocode} |
| 1705 |
% The body of this loop (the group after the =\do=) |
| 1706 |
% is executed for one \textsf{token} at a time, whereas |
| 1707 |
% the current \textsf{token} is saved in =\@nextchar=. |
| 1708 |
% At first we evaluate the current \textsf{token} with the already |
| 1709 |
% defined macro =\@testpach=, i.e.\ we assign to |
| 1710 |
% =\@chclass= the character class and to =\@chnum= |
| 1711 |
% the character number of this \textsf{token}. |
| 1712 |
% \changes{v2.0f}{1992/02/29}{\cs{@testpach} now without arg} |
| 1713 |
% \begin{macrocode} |
| 1714 |
% {\@testpach |
| 1715 |
% \end{macrocode} |
| 1716 |
% Then we branch out depending on the value of =\@chclass= into |
| 1717 |
% different macros that extend the preamble respectively. |
| 1718 |
% \begin{macrocode} |
| 1719 |
% \ifcase \@chclass \@classz \or \@classi \or \@classii |
| 1720 |
% \or \save@decl \or \or \@classv \or \@classvi |
| 1721 |
% \or \@classvii \or \@classviii \or \@classix |
| 1722 |
% \or \@classx \fi |
| 1723 |
% \end{macrocode} |
| 1724 |
% Two cases deserve our special attention: Since the current |
| 1725 |
% \textsf{token} cannot have the character class $4$ (start) we |
| 1726 |
% have skipped this possibility. If the character class is $3$, |
| 1727 |
% only the content of =\@nextchar= has to be saved into the current |
| 1728 |
% \textsf{token} register; therefore we call up =\save@decl= |
| 1729 |
% directly and save a macro name. After the preamble has been |
| 1730 |
% extended we assign the value of =\@chclass= to the counter |
| 1731 |
% =\@lastchclass= to assure that this information will be available |
| 1732 |
% during the next run of the loop. |
| 1733 |
% \begin{macrocode} |
| 1734 |
% \@lastchclass\@chclass}% |
| 1735 |
% \end{macrocode} |
| 1736 |
% After the loop has been finished space must still be added to |
| 1737 |
% the created preamble, depending on the last \textsf{token}. |
| 1738 |
% Depending on the value of =\@lastchclass= we perform |
| 1739 |
% the necessary operations. |
| 1740 |
% \begin{macrocode} |
| 1741 |
% \ifcase\@lastchclass |
| 1742 |
% \end{macrocode} |
| 1743 |
% If the last class equals $0$ we add a |
| 1744 |
% =\hskip \col@sep=. |
| 1745 |
% \begin{macrocode} |
| 1746 |
% \@acol \or |
| 1747 |
% \end{macrocode} |
| 1748 |
% If it equals $1$ we do not add any additional space so that the |
| 1749 |
% horizontal lines do not exceed the vertical ones. |
| 1750 |
% \begin{macrocode} |
| 1751 |
% \or |
| 1752 |
% \end{macrocode} |
| 1753 |
% Class $2$ is treated like class $0$ because a =<{...}= can |
| 1754 |
% only directly follow after class $0$. |
| 1755 |
% \begin{macrocode} |
| 1756 |
% \@acol \or |
| 1757 |
% \end{macrocode} |
| 1758 |
% Most of the other possibilities can only appear if the user |
| 1759 |
% preamble was defective. Class $3$ is not allowed since after a |
| 1760 |
% =>{..}= there must always follow a \texttt{c}, \texttt{l}, |
| 1761 |
% \texttt{r}, \texttt{p},\texttt{m} or \texttt{b}. We report an |
| 1762 |
% error and ignore the declaration given by ={..}=. |
| 1763 |
% \begin{macrocode} |
| 1764 |
% \@preamerr \thr@@@@ \or |
| 1765 |
% \end{macrocode} |
| 1766 |
% If =\@lastchclass= is $4$ the user preamble has been empty. |
| 1767 |
% To continue, we insert a =#= in the preamble. |
| 1768 |
% \begin{macrocode} |
| 1769 |
% \@preamerr \tw@ \@addtopreamble\@sharp \or |
| 1770 |
% \end{macrocode} |
| 1771 |
% Class $5$ is allowed again. In this case |
| 1772 |
% (the user preamble ends with =@{..}=) we need not |
| 1773 |
% do anything. |
| 1774 |
% \begin{macrocode} |
| 1775 |
% \or |
| 1776 |
% \end{macrocode} |
| 1777 |
% Any other case means that the arguments to =@=, \texttt{!}, |
| 1778 |
% \texttt{<}, \texttt{>}, \texttt{p}, \texttt{m} or \texttt{b} have |
| 1779 |
% been forgotten. So we report an error and ignore the last |
| 1780 |
% \textsf{token}. |
| 1781 |
% \begin{macrocode} |
| 1782 |
% \else \@preamerr \@ne \fi |
| 1783 |
% \end{macrocode} |
| 1784 |
% Now that the build-up of the preamble is almost finished we can |
| 1785 |
% insert the \textsf{token} registers and therefore redefine |
| 1786 |
% =\the@toks=. The actual insertion, though, is performed |
| 1787 |
% later. |
| 1788 |
% \begin{macrocode} |
| 1789 |
% \def\the@toks{\the\toks}} |
| 1790 |
% \end{macrocode} |
| 1791 |
% \end{macro} |
| 1792 |
% \end{macro} |
| 1793 |
% |
| 1794 |
% |
| 1795 |
% |
| 1796 |
% \section{The macros \texttt{\textbackslash @classz} |
| 1797 |
% to \texttt{\textbackslash @classx}} |
| 1798 |
% |
| 1799 |
% The preamble is extended by the macros =\@classz= to |
| 1800 |
% =\@classx= which are called by =\@mkpream= |
| 1801 |
% depending on =\@lastchclass= |
| 1802 |
% (i.e. the character class of the last \textsf{token}). |
| 1803 |
% \begin{macro}[int]{\@classx} |
| 1804 |
% First we define =\@classx= because of its important r\^ole. |
| 1805 |
% When it is called we find that the current |
| 1806 |
% \textsf{token} is \texttt{p}, \texttt{m} or \texttt{b}. |
| 1807 |
% That means that a new column has to start. |
| 1808 |
% \begin{macrocode} |
| 1809 |
\def\@classx{% |
| 1810 |
% \end{macrocode} |
| 1811 |
% Depending on the value of =\@lastchclass= different actions |
| 1812 |
% must take place: |
| 1813 |
% \begin{macrocode} |
| 1814 |
\ifcase \@lastchclass |
| 1815 |
% \end{macrocode} |
| 1816 |
% If the last character class was $0$ we separate the columns by |
| 1817 |
% =\hskip\col@sep= followed by =&= and another |
| 1818 |
% =\hskip\col@sep=. |
| 1819 |
% \begin{macrocode} |
| 1820 |
\@acolampacol \or |
| 1821 |
% \end{macrocode} |
| 1822 |
% If the last class was class $1$ --- that means that a vertical |
| 1823 |
% line was |
| 1824 |
% drawn, --- before this line a =\hskip\col@sep= was inserted. |
| 1825 |
% Therefore there has to be only a =&= followed by |
| 1826 |
% =\hskip\col@sep=. But this =&= may be inserted only |
| 1827 |
% if this is not the first column. This process is controlled |
| 1828 |
% by =\if@firstamp= in the macro =\addamp=. |
| 1829 |
% \begin{macrocode} |
| 1830 |
\@addamp \@acol \or |
| 1831 |
% \end{macrocode} |
| 1832 |
% Class $2$ is treated like class $0$ because =<{...}= can only |
| 1833 |
% follow after class $0$. |
| 1834 |
% \begin{macrocode} |
| 1835 |
\@acolampacol \or |
| 1836 |
% \end{macrocode} |
| 1837 |
% Class $3$ requires no actions because all things necessary have |
| 1838 |
% been done by the preamble \textsf{token} \texttt{>}. |
| 1839 |
% \begin{macrocode} |
| 1840 |
\or |
| 1841 |
% \end{macrocode} |
| 1842 |
% Class $4$ means that we are at the beginning of the preamble. |
| 1843 |
% Therefore we start the preamble with =\hskip\col@sep= and |
| 1844 |
% then call =\@firstampfalse=. This makes sure that a later |
| 1845 |
% =\@addamp= inserts the character |
| 1846 |
% =&= into the preamble. |
| 1847 |
% \begin{macrocode} |
| 1848 |
\@acol \@firstampfalse \or |
| 1849 |
% \end{macrocode} |
| 1850 |
% For class $5$ \textsf{tokens} only the character =&= is inserted |
| 1851 |
% as a column separator. Therefore we call =\@addamp=. |
| 1852 |
% \begin{macrocode} |
| 1853 |
\@addamp |
| 1854 |
% \end{macrocode} |
| 1855 |
% Other cases are impossible. For an example |
| 1856 |
% $=\@lastchclass= \string= 6$---as it might appear in a |
| 1857 |
% preamble of the form =...!p...=---\texttt{p} would have |
| 1858 |
% been taken as an argument of \texttt{!}\ by =\@testpach=. |
| 1859 |
% \begin{macrocode} |
| 1860 |
\fi} |
| 1861 |
% \end{macrocode} |
| 1862 |
% \end{macro} |
| 1863 |
% |
| 1864 |
% \changes{v2.6h}{2024/12/02}{Add tagging sockets for luamml support} |
| 1865 |
% Until the sockets are in the release we test for existence |
| 1866 |
% and declare them. |
| 1867 |
% \begin{macrocode} |
| 1868 |
\str_if_exist:cF { l__socket_tagsupport/math/luamml/array/save_plug_str } |
| 1869 |
{ |
| 1870 |
\NewSocket{tagsupport/math/luamml/array/save}{0} |
| 1871 |
\NewSocket{tagsupport/math/luamml/array/finalize}{0} |
| 1872 |
\NewSocket{tagsupport/math/luamml/array/initcol}{0} |
| 1873 |
\NewSocket{tagsupport/math/luamml/array/finalizecol}{1} |
| 1874 |
\AssignSocketPlug{tagsupport/math/luamml/array/finalizecol}{noop} |
| 1875 |
} |
| 1876 |
% \end{macrocode} |
| 1877 |
% \begin{macro}[int]{\@classz} |
| 1878 |
% If the character class of the last \textsf{token} is $0$ we have |
| 1879 |
% \texttt{c}, \texttt{l}, \texttt{r} or an argument of \texttt{m}, |
| 1880 |
% \texttt{b} or\ \texttt{p}. In the first three cases the preamble |
| 1881 |
% must be extended the same way as if we had class $10$. The |
| 1882 |
% remaining two cases do not require any action because the space |
| 1883 |
% needed was generated by the last \textsf{token} (i.e.\ |
| 1884 |
% \texttt{m}, \texttt{b} or \texttt{p}). Since =\@lastchclass= has |
| 1885 |
% the value $10$ at this point nothing happens when =\@classx= is |
| 1886 |
% called. So the macro =\@chlassz= may start like this: |
| 1887 |
% \begin{macrocode} |
| 1888 |
\def\@classz{\@classx |
| 1889 |
% \end{macrocode} |
| 1890 |
% According to the definition of =\insert@column= we must store |
| 1891 |
% the number of the \textsf{token} register in which a preceding |
| 1892 |
% =>{..}= might have stored its argument into |
| 1893 |
% =\@tempcnta=. |
| 1894 |
% \begin{macrocode} |
| 1895 |
\@tempcnta \count@ |
| 1896 |
% \end{macrocode} |
| 1897 |
% To have $=\count@= \string= =\@tmpcnta= + 1$ we prepare |
| 1898 |
% the next \textsf{token} register. |
| 1899 |
% \begin{macrocode} |
| 1900 |
\prepnext@tok |
| 1901 |
% \end{macrocode} |
| 1902 |
% Now the preamble must be extended with the column whose format |
| 1903 |
% can be determined by =\@chnum=. |
| 1904 |
% \begin{macrocode} |
| 1905 |
\@addtopreamble{\ifcase \@chnum |
| 1906 |
% \end{macrocode} |
| 1907 |
% If =\@chnum= has the value $0$ a centered column has to be |
| 1908 |
% generated. |
| 1909 |
% So we begin with stretchable space. |
| 1910 |
% \begin{macrocode} |
| 1911 |
\hfil |
| 1912 |
% \end{macrocode} |
| 1913 |
% We also add a space of 1sp just in case the first thing in the |
| 1914 |
% cell is a command doing an =\unskip=. |
| 1915 |
% \changes{v2.4k}{2018/12/30}{Add extra \cs{hskip} to guard against an |
| 1916 |
% \cs{unskip} at the start of a c-column cell (gh/102)} |
| 1917 |
% \begin{macrocode} |
| 1918 |
\hskip1sp% |
| 1919 |
% \end{macrocode} |
| 1920 |
% The command =\d@llarbegin= follows expanding into =\begingroup= |
| 1921 |
% (in the \textsf{tabular}--environment) or into =$=. Doing this |
| 1922 |
% (provided an appropriate setting of =\d@llarbegin=) we achieve |
| 1923 |
% that the contents of the columns of an \textsf{array}--environment |
| 1924 |
% are set in math mode while those of a \textsf{tabular}--environment |
| 1925 |
% are set in LR mode. |
| 1926 |
% \begin{macrocode} |
| 1927 |
\d@llarbegin |
| 1928 |
% \end{macrocode} |
| 1929 |
% Now we insert the contents of the two \textsf{token} registers |
| 1930 |
% and the symbol |
| 1931 |
% for the column entry (i.e.\ =#= or |
| 1932 |
% more precise =\@sharp=) using =\insert@column=. |
| 1933 |
% \begin{macrocode} |
| 1934 |
\insert@column |
| 1935 |
% \end{macrocode} |
| 1936 |
% We end this case with =\d@llarend= and =\hfil= where =\d@llarend= |
| 1937 |
% again is either =$= or =\endgroup=. |
| 1938 |
% The strut to enforce a regular row height is placed between the two. |
| 1939 |
% \changes{v2.4e}{2016/10/07}{Fixing SX68732} |
| 1940 |
% \begin{macrocode} |
| 1941 |
\d@llarend |
| 1942 |
\do@row@strut \hfil \or |
| 1943 |
% \end{macrocode} |
| 1944 |
% The templates for \texttt{l} and \texttt{r} (i.e.\ =\@chnum= $1$ |
| 1945 |
% or $2$) are generated the same way. Since one =\hfil= is |
| 1946 |
% missing the text is moved to the relevant side. |
| 1947 |
% The =\kern\z@= is needed in case of an empty column |
| 1948 |
% entry. Otherwise |
| 1949 |
% the =\unskip= in =\insert@column= removes the |
| 1950 |
% =\hfil=. Changed to =\hskip1sp= so that it interacts better with |
| 1951 |
% =\@bsphack=. |
| 1952 |
% \changes{v2.3f}{1996/04/22} |
| 1953 |
% {(DPC) Extra \cs{kern} keeps tabcolsep in empty l columns |
| 1954 |
% internal/2122} |
| 1955 |
% \changes{v2.3i}{1996/06/14} |
| 1956 |
% {Change both \cs{kern}\cs{z@} to \cs{hskip}1sp for latex/2160} |
| 1957 |
% \changes{v2.4e}{2016/10/07}{Fixing SX68732} |
| 1958 |
% \begin{macrocode} |
| 1959 |
\hskip1sp\d@llarbegin\insert@column\d@llarend |
| 1960 |
\do@row@strut \hfil \or |
| 1961 |
\hfil\hskip1sp\d@llarbegin\insert@column\d@llarend |
| 1962 |
\do@row@strut \or |
| 1963 |
% \end{macrocode} |
| 1964 |
% The templates for \texttt{p}, \texttt{m} and \texttt{b} mainly |
| 1965 |
% consist of a \textsf{box}. In case of \texttt{m} it is generated |
| 1966 |
% by =\vcenter=. This command is allowed only in math |
| 1967 |
% mode. Therefore we start with a~=$=. |
| 1968 |
% \changes{v2.4f}{2017/11/04}{Managing m-cells without \cs{vcenter}} |
| 1969 |
% \begin{macrocode} |
| 1970 |
\setbox\ar@mcellbox\vbox |
| 1971 |
% \end{macrocode} |
| 1972 |
% The part of the templates which is the same in all three cases |
| 1973 |
% (\texttt{p}, \texttt{m} and \texttt{b}) is built by the macros |
| 1974 |
% =\@startpbox= and =\@endpbox=. =\@startpbox= has an argument: the |
| 1975 |
% width of the column which is stored in the current \textsf{token} |
| 1976 |
% (i.e.\ =\@nextchar=). Between these two macros we find the well |
| 1977 |
% known =\insert@column= or rather the variant for tagging: |
| 1978 |
% \cs{insert@pcolumn}. The strut is placed after the box. |
| 1979 |
% \changes{v2.4e}{2016/10/07}{Fixing SX68732} |
| 1980 |
% \changes{v2.4f}{2017/11/04}{Managing m-cells without \cs{vcenter}} |
| 1981 |
% \changes{v2.6a}{2023/12/11}{Support for tagged PDF} |
| 1982 |
% \begin{macrocode} |
| 1983 |
\@startpbox{\@nextchar}\insert@pcolumn \@endpbox |
| 1984 |
\ar@align@mcell |
| 1985 |
\do@row@strut \or |
| 1986 |
% \end{macrocode} |
| 1987 |
% The templates for \texttt{p} and \texttt{b} are generated in the |
| 1988 |
% same way though we do not need the =$= characters because we use |
| 1989 |
% =\vtop= or =\vbox=. |
| 1990 |
% \changes{v2.4e}{2016/10/07}{Fixing SX68732} |
| 1991 |
% \changes{v2.6a}{2023/12/11}{Support for tagged PDF} |
| 1992 |
% \begin{macrocode} |
| 1993 |
\vtop \@startpbox{\@nextchar}\insert@pcolumn \@endpbox\do@row@strut \or |
| 1994 |
\vbox \@startpbox{\@nextchar}\insert@pcolumn \@endpbox\do@row@strut |
| 1995 |
% \end{macrocode} |
| 1996 |
% Other values for =\@chnum= are impossible. Therefore we |
| 1997 |
% end the arguments to =\@addtopreamble= and =\ifcase=. |
| 1998 |
% Before we come to the end of =\@classz= we have to |
| 1999 |
% prepare the next \textsf{token} register. |
| 2000 |
% \begin{macrocode} |
| 2001 |
\fi}\prepnext@tok} |
| 2002 |
% \end{macrocode} |
| 2003 |
% \end{macro} |
| 2004 |
% |
| 2005 |
|
| 2006 |
% |
| 2007 |
% \begin{macro}[int]{\ar@mcellbox} |
| 2008 |
% When dealing with m-cells we need a box to measure the cell |
| 2009 |
% height. |
| 2010 |
% \changes{v2.4f}{2017/11/04}{Managing m-cells without \cs{vcenter}} |
| 2011 |
% \begin{macrocode} |
| 2012 |
\newbox\ar@mcellbox |
| 2013 |
% \end{macrocode} |
| 2014 |
% \end{macro} |
| 2015 |
% |
| 2016 |
% |
| 2017 |
% \begin{macro}[int]{\ar@align@mcell} |
| 2018 |
% M-cells are supposed to be vertically centered within the table |
| 2019 |
% row. In the original implementation that was done using |
| 2020 |
% =\vcenter= but the issue with that approach is that it centers |
| 2021 |
% the material based on the math-axis. In most situations that |
| 2022 |
% comes out quit right, but if, for example, an m-cell has only a |
| 2023 |
% single line worth of material inside it will be positioned |
| 2024 |
% differently to a =l=, =c= or =r= cell or to a =p= or =b= cell |
| 2025 |
% with the same content. |
| 2026 |
% |
| 2027 |
% For that reason the new implementation does the centering |
| 2028 |
% manually: First we check the height of the cell and if that is |
| 2029 |
% less or equal to =\ht\strutbox= we assume that this is a |
| 2030 |
% single line cell. In that case we don't do any vertical maneuver |
| 2031 |
% and simply output the box, i.e., make it behave like a single |
| 2032 |
% line p-cell. |
| 2033 |
% |
| 2034 |
% We use the height of \cs{strutbox} not \cs{@arstrutbox} in the comparison, |
| 2035 |
% because \cs{box}\cs{ar@mcellbox} does not have any strut |
| 2036 |
% incorporated and if \cs{arraystretch} is made very |
| 2037 |
% small the test would otherwise incorrectly assume a multi-line cell. |
| 2038 |
% \changes{v2.4f}{2017/11/04}{Managing m-cells without \cs{vcenter}} |
| 2039 |
% \changes{v2.5g}{2022/09/04}{Test against \cs{strutbox} height (gh/766)} |
| 2040 |
% \begin{macrocode} |
| 2041 |
\def\ar@align@mcell{% |
| 2042 |
\ifdim \ht\ar@mcellbox > \ht\strutbox |
| 2043 |
% \end{macrocode} |
| 2044 |
% Otherwise we realign vertically by lowering the box. The question |
| 2045 |
% is how much do we need to move down? If there is any |
| 2046 |
% =\arraystretch= in place then the first line will have some |
| 2047 |
% unusual height and we don't want to consider that when finding |
| 2048 |
% the middle point. So we subtract from the cell height the height |
| 2049 |
% of that strut. But of course we want to include the normal height |
| 2050 |
% of the first line (which would be something like =\ht\strutbox=) |
| 2051 |
% so we need to add that. On the other hand, when centering around |
| 2052 |
% the mid-point of the cell, we also need to account for the depth |
| 2053 |
% of the last line (which is nominally something like |
| 2054 |
% =\dp\strutbox=). Both together equals =\baselineskip= so that is |
| 2055 |
% what we add and then lower the cell by half of the resulting value. |
| 2056 |
% \begin{macrocode} |
| 2057 |
\begingroup |
| 2058 |
\dimen@\ht\ar@mcellbox |
| 2059 |
\advance\dimen@-\ht\@arstrutbox |
| 2060 |
\advance\dimen@\baselineskip |
| 2061 |
\lower.5\dimen@\box\ar@mcellbox |
| 2062 |
\endgroup |
| 2063 |
\else % assume one line and align at baseline |
| 2064 |
\box\ar@mcellbox |
| 2065 |
\fi} |
| 2066 |
% \end{macrocode} |
| 2067 |
% \end{macro} |
| 2068 |
% |
| 2069 |
|
| 2070 |
% |
| 2071 |
% \begin{macro}[int]{\@classix} |
| 2072 |
% \emph{The code below has been replaced long time ago by an |
| 2073 |
% extended version further down but the code and its documentation |
| 2074 |
% was left here for reference. It is now commented out to avoid |
| 2075 |
% confusion.} |
| 2076 |
% |
| 2077 |
% In case of class $9$ (\texttt{>}--\textsf{token}) we first check |
| 2078 |
% if the character class of the last |
| 2079 |
% \textsf{token} was $3$. In this case we have a |
| 2080 |
% user preamble of the form =..>{...}>{...}..= which |
| 2081 |
% is not allowed. We only give an error message and continue. |
| 2082 |
% So the declarations defined by the first =>{...}= |
| 2083 |
% are ignored. |
| 2084 |
% \begin{macrocode} |
| 2085 |
%\def\@classix{\ifnum \@lastchclass = \thr@@@@ |
| 2086 |
% \@preamerr \thr@@@@ \fi |
| 2087 |
% \end{macrocode} |
| 2088 |
% Furthermore, we call up =\@class10= because afterwards always a |
| 2089 |
% new column is started by \texttt{c}, \texttt{l}, \texttt{r}, |
| 2090 |
% \texttt{p}, \texttt{m} or \texttt{b}. |
| 2091 |
% \begin{macrocode} |
| 2092 |
% \@classx} |
| 2093 |
% \end{macrocode} |
| 2094 |
% \end{macro} |
| 2095 |
% |
| 2096 |
% |
| 2097 |
% |
| 2098 |
% \begin{macro}[int]{\@classviii} |
| 2099 |
% \emph{The code below has been replaced long time ago by an |
| 2100 |
% extended version further down but the code and its documentation |
| 2101 |
% was left here for reference. It is now commented out to avoid |
| 2102 |
% confusion.} |
| 2103 |
% |
| 2104 |
% If the current \textsf{token} is a \texttt{<} the last character |
| 2105 |
% class must be $0$. In this case it is not necessary to extend the |
| 2106 |
% preamble. Otherwise we output an error message, set =\@chclass= |
| 2107 |
% to $6$ and call =\@classvi=. By doing this we achieve that |
| 2108 |
% \texttt{<} is treated like \texttt{!}. |
| 2109 |
% \begin{macrocode} |
| 2110 |
%\def\@classviii{\ifnum \@lastchclass >\z@ |
| 2111 |
% \@preamerr 4\@chclass 6 \@classvi \fi} |
| 2112 |
% \end{macrocode} |
| 2113 |
% \end{macro} |
| 2114 |
% |
| 2115 |
% \begin{macro}[int]{\@arrayrule} |
| 2116 |
% There is only one incompatibility with the original definition: |
| 2117 |
% the definition of =\@arrayrule=. In the original a line without |
| 2118 |
% width\footnote{So the space between \texttt{cc} and \texttt{c|c} |
| 2119 |
% is equal.} is created by multiple insertions of |
| 2120 |
% =\hskip .5\arrayrulewidth=. |
| 2121 |
% We only insert a vertical line into the |
| 2122 |
% preamble. This is done to prevent problems with \TeX's main |
| 2123 |
% memory when generating tables with many vertical lines in them |
| 2124 |
% (especially in the case of \textsf{floats}). |
| 2125 |
% \begin{macrocode} |
| 2126 |
\def\@arrayrule{\@addtopreamble \vline} |
| 2127 |
% \end{macrocode} |
| 2128 |
% \end{macro} |
| 2129 |
% |
| 2130 |
% \begin{macro}[int]{\@classvii} |
| 2131 |
% As a consequence it follows that in case of class $7$ |
| 2132 |
% (=@= \textsf{token}) the preamble need not to be extended. |
| 2133 |
% In the original definition $=\@lastchclass= \string= 1$ |
| 2134 |
% is treated by inserting =\hskip .5\arrayrulewidth=. |
| 2135 |
% We only check if the last \textsf{token} was of class $3$ which is |
| 2136 |
% forbidden. |
| 2137 |
% \begin{macrocode} |
| 2138 |
\def\@classvii{\ifnum \@lastchclass = \thr@@@@ |
| 2139 |
% \end{macrocode} |
| 2140 |
% If this is true we output an error message and |
| 2141 |
% ignore the declarations stored |
| 2142 |
% by the last =>{...}=, because these are overwritten |
| 2143 |
% by the argument of \texttt{@}. |
| 2144 |
% \begin{macrocode} |
| 2145 |
\@preamerr \thr@@@@ \fi} |
| 2146 |
% \end{macrocode} |
| 2147 |
% \end{macro} |
| 2148 |
% |
| 2149 |
% |
| 2150 |
% \begin{macro}[int]{\@classvi} |
| 2151 |
% If the current \textsf{token} is a regular \texttt{!}\ and the |
| 2152 |
% last class was $0$ or $2$ we extend the preamble with |
| 2153 |
% =\hskip\col@sep=. If the last \textsf{token} was of class $1$ |
| 2154 |
% (for instance \texttt{|}) we extend with =\hskip \doublerulesep= |
| 2155 |
% because the construction =!{...}= has to be treated like |
| 2156 |
% \texttt{|}. |
| 2157 |
% \begin{macrocode} |
| 2158 |
\def\@classvi{\ifcase \@lastchclass |
| 2159 |
\@acol \or |
| 2160 |
\@addtopreamble{\hskip \doublerulesep}\or |
| 2161 |
\@acol \or |
| 2162 |
% \end{macrocode} |
| 2163 |
% Now =\@preamerr...= should follow because a |
| 2164 |
% user preamble of the form =..>{..}!.= is not allowed. |
| 2165 |
% To save memory we call =\@classvii= instead which also |
| 2166 |
% does what we want. |
| 2167 |
% \begin{macrocode} |
| 2168 |
\@classvii |
| 2169 |
% \end{macrocode} |
| 2170 |
% If =\@lastchclass= is $4$ or $5$ nothing has to be done. |
| 2171 |
% Class $6$ to $10$ are not possible. |
| 2172 |
% So we finish the macro. |
| 2173 |
% \begin{macrocode} |
| 2174 |
\fi} |
| 2175 |
% \end{macrocode} |
| 2176 |
% \end{macro} |
| 2177 |
% |
| 2178 |
% \begin{macro}[int]{\@classii} |
| 2179 |
% \begin{macro}[int]{\@classiii} |
| 2180 |
% In the case of character classes $2$ and $3$ (i.e.\ the argument |
| 2181 |
% of \texttt{<} or \texttt{>}) we only have to store the current |
| 2182 |
% \textsf{token} (=\@nextchar=) into the corresponding |
| 2183 |
% \textsf{token} register since the preparation and |
| 2184 |
% insertion of these registers |
| 2185 |
% are done by the macro =\@classz=. |
| 2186 |
% This is equivalent to calling =\save@decl= in the case of |
| 2187 |
% class $3$. To save command identifiers we do this call up |
| 2188 |
% in the macro =\@mkpream=. |
| 2189 |
% |
| 2190 |
% Class $2$ exhibits a more complicated situation: the |
| 2191 |
% \textsf{token} registers have already been inserted by |
| 2192 |
% =\@classz=. So the value of =\count@= is too high |
| 2193 |
% by one. Therefore we decrease =\count@= by $1$. |
| 2194 |
% \begin{macrocode} |
| 2195 |
\def\@classii{\advance \count@ \m@ne |
| 2196 |
% \end{macrocode} |
| 2197 |
% Next we store the current \textsf{token} into the correct |
| 2198 |
% \textsf{token} register by calling =\save@decl= and then |
| 2199 |
% increase the value of =\count@= again. At this point we |
| 2200 |
% can save memory once more (at the cost of time) if we use the |
| 2201 |
% macro =\prepnext@tok=. |
| 2202 |
% \begin{macrocode} |
| 2203 |
\save@decl\prepnext@tok} |
| 2204 |
% \end{macrocode} |
| 2205 |
% \end{macro} |
| 2206 |
% \end{macro} |
| 2207 |
% |
| 2208 |
% |
| 2209 |
% \begin{macro}[int]{\@classv} |
| 2210 |
% \emph{The code below has been replaced long time ago by an |
| 2211 |
% extended version further down but the code and its documentation |
| 2212 |
% was left here for reference. It is now commented out to avoid |
| 2213 |
% confusion.} |
| 2214 |
% |
| 2215 |
% If the current \textsf{token} is of class $5$ then it is an |
| 2216 |
% argument of a \texttt{@} \textsf{token}. It must be stored into a |
| 2217 |
% \textsf{token} register. |
| 2218 |
% \begin{macrocode} |
| 2219 |
%\def\@classv{\save@decl |
| 2220 |
% \end{macrocode} |
| 2221 |
% We extend the preamble with a command which inserts this |
| 2222 |
% \textsf{token} register into the preamble when its construction |
| 2223 |
% is finished. The user expects that this argument is worked out in |
| 2224 |
% math mode if it was used in an |
| 2225 |
% \textsf{array}--environment. Therefore we surround it with |
| 2226 |
% =\d@llar...='s. |
| 2227 |
% \changes{v2.0c}{1990/08/14}{\cs{relax} added to avoid problem |
| 2228 |
% `the`toks0`the`toks1.} |
| 2229 |
% \begin{macrocode} |
| 2230 |
% \@addtopreamble{\d@llarbegin\the@toks\the\count@\relax\d@llarend}% |
| 2231 |
% \end{macrocode} |
| 2232 |
% Finally we must prepare the next \textsf{token} register. |
| 2233 |
% \begin{macrocode} |
| 2234 |
% \prepnext@tok} |
| 2235 |
% \end{macrocode} |
| 2236 |
% \end{macro} |
| 2237 |
% |
| 2238 |
% \begin{macro}[int]{\@classi} |
| 2239 |
% In the case of class $0$ we were able to generate the necessary |
| 2240 |
% space between columns by using the macro =\@classx=. |
| 2241 |
% Analogously the macro =\@classvi= can be used for class $1$. |
| 2242 |
% \begin{macrocode} |
| 2243 |
\def\@classi{\@classvi |
| 2244 |
% \end{macrocode} |
| 2245 |
% Depending on =\@chnum= a vertical line |
| 2246 |
% \begin{macrocode} |
| 2247 |
\ifcase \@chnum \@arrayrule \or |
| 2248 |
% \end{macrocode} |
| 2249 |
% or (in case of =!{...}=) the current \textsf{token} --- stored |
| 2250 |
% in =\@nextchar= --- has to be inserted into the preamble. |
| 2251 |
% This corresponds to calling =\@classv=. |
| 2252 |
% \begin{macrocode} |
| 2253 |
\@classv \fi} |
| 2254 |
% \end{macrocode} |
| 2255 |
% \end{macro} |
| 2256 |
% |
| 2257 |
% |
| 2258 |
% |
| 2259 |
% \begin{macro}[int]{\@startpbox,\@startpbox@action} |
| 2260 |
% In =\@classz= the macro =\@startpbox= is used. |
| 2261 |
% The width of the \textsf{parbox} is passed as an argument. |
| 2262 |
% =\vcenter=, =\vtop= or =\vbox= are already in the |
| 2263 |
% preamble. So we start with the braces for the wanted box. |
| 2264 |
% \changes{v2.4i}{2018/09/13}{Add group to prevent color leak (gh/72)} |
| 2265 |
% \begin{macrocode} |
| 2266 |
\def\@startpbox#1{\bgroup |
| 2267 |
\color@begingroup |
| 2268 |
% \end{macrocode} |
| 2269 |
% The argument is the width of the box. This information has to be |
| 2270 |
% assigned to =\hsize=. |
| 2271 |
% Then we assign default values to several parameters used in a |
| 2272 |
% \textsf{parbox}. |
| 2273 |
% \changes{v2.3k}{1998/05/12}{Use \cs{setlength} to set \cs{hsize}, |
| 2274 |
% so that the calc package can be applied here (pr/2793)} |
| 2275 |
% \begin{macrocode} |
| 2276 |
\setlength\hsize{#1}\@arrayparboxrestore |
| 2277 |
% \end{macrocode} |
| 2278 |
% Our main problem is to obtain the same distance between succeeding |
| 2279 |
% lines of the \textsf{parbox}. |
| 2280 |
% We have to remember that the distance between two \textsf{parboxes} |
| 2281 |
% should be defined by =\@arstrut=. That means that it can be |
| 2282 |
% greater than the distance in a \textsf{parbox}. |
| 2283 |
% Therefore it is not enough to set a =\@arstrut= at the |
| 2284 |
% beginning and at the end of the \textsf{parbox}. This would |
| 2285 |
% dimension the distance |
| 2286 |
% between first and second line and the distance between the two |
| 2287 |
% last lines of the \textsf{parbox} wrongly. |
| 2288 |
% To prevent this we set an invisible rule of height |
| 2289 |
% =\@arstrutbox= |
| 2290 |
% at the beginning of the \textsf{parbox}. This has no effect on the |
| 2291 |
% depth of the first line. At the end of the \textsf{parbox} we set |
| 2292 |
% analogously another invisible rule which only affects the depth |
| 2293 |
% of the last line. It is necessary to wait inserting this strut |
| 2294 |
% until the paragraph actually starts to allow for things like |
| 2295 |
% =\parindent= changes via =>{...}=. |
| 2296 |
% \changes{v2.1c}{1992/12/14}{Use `everypar to insert strut} |
| 2297 |
% \begin{macrocode} |
| 2298 |
\everypar{% |
| 2299 |
\vrule \@height \ht\@arstrutbox \@width \z@ |
| 2300 |
\everypar{}}% |
| 2301 |
} |
| 2302 |
% \end{macrocode} |
| 2303 |
% |
| 2304 |
% \changes{v2.6h}{2024/12/17}{New \cs{@startpbox@action} to do the real work |
| 2305 |
% after the preamble is built (gh/1585)} |
| 2306 |
% Starting with 2.6h, \cs{@startpbox} is used only during the |
| 2307 |
% built-up of the preamble and then changed to \cs{@startpbox@action} |
| 2308 |
% which does the real work. For an explanation of this code see |
| 2309 |
% the documentation in \cs{@mkpream}. We keep the \cs{@startpbox} |
| 2310 |
% definition on top-level in case there are tabular packages that |
| 2311 |
% built the preamble differently and expect that it contains |
| 2312 |
% \cs{@startpbox} (\pkg{longtable} at the moment). |
| 2313 |
% \begin{macrocode} |
| 2314 |
\let\@startpbox@action\@startpbox |
| 2315 |
% \end{macrocode} |
| 2316 |
% \end{macro} |
| 2317 |
% |
| 2318 |
% \begin{macro}[int]{\@endpbox} |
| 2319 |
% If there are any declarations defined by =>{...}= |
| 2320 |
% and =<{...}= |
| 2321 |
% they now follow in the macro =\@classz= --- the contents |
| 2322 |
% of the column in between. |
| 2323 |
% So the macro =\@endpbox= must insert the \textsf{specialstrut} |
| 2324 |
% mentioned earlier and then close the group opened by |
| 2325 |
% =\@startpbox=. |
| 2326 |
% \changes{v2.2d}{1994/05/16}{Use \LaTeXe \cs{@finalstrut}} |
| 2327 |
% \changes{v2.3g}{1996/05/07}{Add \cs{hfil} for tools/2120} |
| 2328 |
% \changes{v2.4i}{2018/09/13}{Add group to prevent color leak (gh/72)} |
| 2329 |
% \changes{v2.5d}{2021/02/10}{Explicitly run \cs{par} at the end of pboxes} |
| 2330 |
% \begin{macrocode} |
| 2331 |
\def\@endpbox{\@finalstrut\@arstrutbox \par \color@endgroup \egroup\hfil} |
| 2332 |
% \end{macrocode} |
| 2333 |
% \end{macro} |
| 2334 |
% |
| 2335 |
% \begin{macro}[int]{\@finalstrut} |
| 2336 |
% We also have to adjust \cs{@finalstrut} so that it doesn't back |
| 2337 |
% up by a \cs{baselineskip} when the the current vlist is completely empty. |
| 2338 |
% This should go eventually to \file{ltboxes} but not in a PL. |
| 2339 |
% \changes{v2.6i}{2025/05/19}{Ensure \cs{arraystretch} is taken into |
| 2340 |
% account inside a tabular (gh/1730)} |
| 2341 |
% \changes{v2.6j}{2025/06/08}{Fix gh/1730 correctly (gh/1765)} |
| 2342 |
% \begin{macrocode} |
| 2343 |
\def\@finalstrut#1{% |
| 2344 |
\unskip |
| 2345 |
\ifhmode \nobreak |
| 2346 |
\else |
| 2347 |
\ifnum\lastnodetype>\m@ne |
| 2348 |
\vskip-\baselineskip |
| 2349 |
\fi |
| 2350 |
\fi |
| 2351 |
\vrule\@width\z@\@height\z@\@depth\dp#1} |
| 2352 |
% \end{macrocode} |
| 2353 |
% \end{macro} |
| 2354 |
% |
| 2355 |
% |
| 2356 |
% \section{Building and calling \texttt{\textbackslash halign}} |
| 2357 |
% |
| 2358 |
% \begin{macro}[int]{\@array} |
| 2359 |
% After we have discussed the macros needed for the evaluation |
| 2360 |
% of the user preamble we can define the macro =\@array= |
| 2361 |
% which uses these macros to create a =\halign=. |
| 2362 |
% It has two arguments. The first one is a position argument |
| 2363 |
% which can be \texttt{t}, \texttt{b} or \texttt{c}; the |
| 2364 |
% second one describes the wanted preamble, |
| 2365 |
% e.g.\ it has the form =|c|c|c|=. |
| 2366 |
% \begin{macrocode} |
| 2367 |
\def\@array[#1]#2{ |
| 2368 |
% \end{macrocode} |
| 2369 |
% First we define a \textsf{strut} whose size basically corresponds |
| 2370 |
% to a normal \textsf{strut} multiplied by the factor |
| 2371 |
% =\arraystretch=. |
| 2372 |
% This \textsf{strut} is then inserted into every row and enforces |
| 2373 |
% a minimal distance between two rows. |
| 2374 |
% Nevertheless, when using horizontal lines, large letters |
| 2375 |
% (like accented capital letters) still collide with such lines. |
| 2376 |
% Therefore at first we add to the height of a normal \textsf{strut} |
| 2377 |
% the value of the parameter =\extrarowheight=. |
| 2378 |
% \begin{macrocode} |
| 2379 |
\@tempdima \ht \strutbox |
| 2380 |
\advance \@tempdima by\extrarowheight |
| 2381 |
\setbox \@arstrutbox \hbox{\vrule |
| 2382 |
\@height \arraystretch \@tempdima |
| 2383 |
\@depth \arraystretch \dp \strutbox |
| 2384 |
\@width \z@}% |
| 2385 |
% \end{macrocode} |
| 2386 |
% Before starting a table we have to initialize the variables |
| 2387 |
% holding row and column information for cells. We also have |
| 2388 |
% locally store the information related to the current cell (if we |
| 2389 |
% are already inside a table) so that we can restore it once the |
| 2390 |
% inner table is finished. |
| 2391 |
% \changes{v2.6a}{2023/12/11}{Managing cell indexes} |
| 2392 |
% The total number of table columns of the current table is |
| 2393 |
% determined in \cs{tbl_count_table_cols:} but this is called in |
| 2394 |
% a group, so local settings do not survive. Thus, to save away the |
| 2395 |
% outer value of \cs{g_@@_table_cols_tl} we do that also |
| 2396 |
% \cs{tbl_init_cell_data_for_table:}. |
| 2397 |
% \changes{v2.6k}{2025/07/18}{Set cs{tbl_init_cell_data_for_table} here} |
| 2398 |
% \begin{macrocode} |
| 2399 |
\tbl_init_cell_data_for_table: |
| 2400 |
% \end{macrocode} |
| 2401 |
% Then we open a group, in which the user preamble is evaluated by |
| 2402 |
% the macro =\@mkpream=. As we know this must happen locally. |
| 2403 |
% This macro creates a preamble for a =\halign= and saves |
| 2404 |
% its result globally in the control sequence =\@preamble=. |
| 2405 |
% \begin{macrocode} |
| 2406 |
\begingroup |
| 2407 |
\@mkpream{#2}% |
| 2408 |
% \end{macrocode} |
| 2409 |
% Figure out how many columns this table has: |
| 2410 |
% \changes{v2.6a}{2023/12/11}{Managing cell indexes} |
| 2411 |
% \begin{macrocode} |
| 2412 |
\tbl_count_table_cols: |
| 2413 |
% \end{macrocode} |
| 2414 |
% We again redefine =\@preamble= so that a call up of =\@preamble= |
| 2415 |
% now starts the =\halign=. Thus also the arguments of \texttt{>}, |
| 2416 |
% \texttt{<}, \texttt{@} and \texttt{!}, saved in the |
| 2417 |
% \textsf{token} registers are inserted into the preamble. The |
| 2418 |
% =\tabskip= at the beginning and end of the preamble is set to |
| 2419 |
% \textsf{0pt} (in the beginning by the use of =\ialign=). Also the |
| 2420 |
% command =\@arstrut= is build in, which inserts the |
| 2421 |
% =\@arstrutbox=, defined above. Of course, the opening brace after |
| 2422 |
% =\ialign= has to be implicit as it will be closed in =\endarray= |
| 2423 |
% or another macro. |
| 2424 |
% \changes{v2.3m}{1998/12/31}{Added \cs{noexpand} in front of \cs{ialign} |
| 2425 |
% to guard against interesting :-) changes to \cs{halign} done to support |
| 2426 |
% text glyphs in math} |
| 2427 |
% |
| 2428 |
% The =\noexpand= in front of =\ialign= does no harm in standard \LaTeX{} |
| 2429 |
% and was added since some experimental support for using text glyphs in math |
| 2430 |
% redefines =\halign= with the result that is becomes expandable with |
| 2431 |
% disastrous results in cases like this. |
| 2432 |
% In the kernel definition for this macro the problem does |
| 2433 |
% not surface because there =\protect= is set (which is not necessary in this |
| 2434 |
% implementation as there is no arbitrary user input that can get expanded) and |
| 2435 |
% the experimental code made the redefinition robust. Whether this is the right |
| 2436 |
% approach is open to question; consider the =\noexpand= a courtesy to allow an |
| 2437 |
% unsupported redefinition of a \TeX{} primitive for the moment (as people rely |
| 2438 |
% on that experimental code). |
| 2439 |
% \begin{macrocode} |
| 2440 |
\xdef\@preamble{ |
| 2441 |
% \end{macrocode} |
| 2442 |
% \cs{ialign} in the original definition is replaced by |
| 2443 |
% \cs{ar@ialign} defined below. This does what \cs{ialign} does but |
| 2444 |
% additionally handles the tagging structure for the whole table if necessary. |
| 2445 |
% \changes{v2.6a}{2023/12/11}{Support for tagged PDF} |
| 2446 |
% \begin{macrocode} |
| 2447 |
\noexpand \ar@ialign |
| 2448 |
\@halignto |
| 2449 |
\bgroup \@arstrut |
| 2450 |
% \end{macrocode} |
| 2451 |
% What we have not explained yet is the macro =\@halignto= |
| 2452 |
% that was just used. Depending on its replacement text the |
| 2453 |
% =\halign= becomes a =\halign= \texttt{to} \meta{dimen}. |
| 2454 |
% |
| 2455 |
% Next, a tagging support socket is inserted adding the start row tag. |
| 2456 |
% \changes{v2.6a}{2023/12/11}{Support for tagged PDF} |
| 2457 |
% \begin{macrocode} |
| 2458 |
\UseTaggingSocket{tbl/row/begin} |
| 2459 |
% \end{macrocode} |
| 2460 |
% At the start of the preamble for the first column we call |
| 2461 |
% \cs{tbl_init_cell_data_for_row:} to initialize the cell index data. In |
| 2462 |
% later columns this data is updated via \cs{tbl_update_cell_data:}. |
| 2463 |
% \changes{v2.6a}{2023/12/11}{Managing cell indexes} |
| 2464 |
% \begin{macrocode} |
| 2465 |
\tbl_init_cell_data_for_row: |
| 2466 |
% \end{macrocode} |
| 2467 |
% |
| 2468 |
% \begin{macrocode} |
| 2469 |
\@preamble |
| 2470 |
\tabskip \z@ \cr} |
| 2471 |
% \end{macrocode} |
| 2472 |
% Now we close the group again. Thus |
| 2473 |
% =\@startpbox= and =\@endpbox= as well as all |
| 2474 |
% \textsf{token} registers get their former meaning back. |
| 2475 |
% \begin{macrocode} |
| 2476 |
\endgroup |
| 2477 |
% \end{macrocode} |
| 2478 |
% To support the \texttt{delarray.sty} package we include a hook |
| 2479 |
% into this part of the code which is a no-op in the main package. |
| 2480 |
% \changes{v2.1a}{1992/07/03}{Hook for delarray added} |
| 2481 |
% \begin{macrocode} |
| 2482 |
\@arrayleft |
| 2483 |
% \end{macrocode} |
| 2484 |
% Now we decide depending on the position argument in which |
| 2485 |
% \textsf{box} the =\halign= is to be put. (=\vcenter= may be used |
| 2486 |
% because we are in math mode.) |
| 2487 |
% \changes{v2.1a}{1992/07/03}{Wrong spec is now equiv to [t]} |
| 2488 |
% \begin{macrocode} |
| 2489 |
\if #1t\vtop \else \if#1b\vbox \else \vcenter \fi \fi |
| 2490 |
% \end{macrocode} |
| 2491 |
% Now another implicit opening brace appears; then definitions |
| 2492 |
% which shall stay local follow. While constructing the |
| 2493 |
% =\@preamble= in =\@mkpream= the =#= sign must be |
| 2494 |
% hidden in the macro =\@sharp= which is =\let= to |
| 2495 |
% =\relax= at that moment (see definition of =\@mkpream= |
| 2496 |
% on page~\pageref{@mkpream}). |
| 2497 |
% All these now get their actual meaning. |
| 2498 |
% \begin{macrocode} |
| 2499 |
\bgroup |
| 2500 |
\let \@sharp ##\let \protect \relax |
| 2501 |
% \end{macrocode} |
| 2502 |
% With the above defined \textsf{struts} we fix down the distance |
| 2503 |
% between rows by setting =\lineskip= and =\baselineskip= |
| 2504 |
% to \textsf{0pt}. Since there have to be set =$='s |
| 2505 |
% around every column in the \textsf{array}--environment |
| 2506 |
% the parameter =\mathsurround= should |
| 2507 |
% also be set to \textsf{0pt}. This prevents additional space between |
| 2508 |
% the rows. |
| 2509 |
% \begin{macrocode} |
| 2510 |
\lineskip \z@ |
| 2511 |
\baselineskip \z@ |
| 2512 |
% \end{macrocode} |
| 2513 |
% Don't use \cs{m@th} here as that signals to the math tagging |
| 2514 |
% code that this is fake math that should not be tagged. |
| 2515 |
% \changes{v2.6a}{2023/12/11}{Support for tagged PDF} |
| 2516 |
% \begin{macrocode} |
| 2517 |
\mathsurround \z@ |
| 2518 |
% \end{macrocode} |
| 2519 |
% Beside, we have to assign a special meaning (which we still have |
| 2520 |
% to specify) to the line separator =\\=. We also have to |
| 2521 |
% redefine the command =\par= in such a way that empty lines in |
| 2522 |
% =\halign= cannot do any damage. We succeed in doing so |
| 2523 |
% by choosing something that will disappear when expanding. |
| 2524 |
% After that we only have to call up =\@preamble= to |
| 2525 |
% start the wanted =\halign=. |
| 2526 |
% \changes{v2.3b}{1994/12/08}{add \cs{tabularnewline}} |
| 2527 |
% \changes{v2.6m}{2025/09/24}{Check \cs{currentgrouptype} in \cs{par} (gh1864)} |
| 2528 |
% \changes{v2.6n}{2025/09/25}{double @ for l3doc conventions (gh1864)} |
| 2529 |
% \begin{macrocode} |
| 2530 |
\let\\\@arraycr \let\tabularnewline\\% |
| 2531 |
\def\par{\ifnum\currentgrouptype=6~ \else\@@@@par\fi}% |
| 2532 |
% \end{macrocode} |
| 2533 |
% Another socket for tagging. TODO: what about \cs{arrayleft} above? |
| 2534 |
% \begin{macrocode} |
| 2535 |
\UseTaggingSocket{tbl/init} |
| 2536 |
% \end{macrocode} |
| 2537 |
% |
| 2538 |
% \begin{macrocode} |
| 2539 |
\@preamble |
| 2540 |
} |
| 2541 |
% \end{macrocode} |
| 2542 |
% \end{macro} |
| 2543 |
% |
| 2544 |
% |
| 2545 |
% |
| 2546 |
% \begin{macro}[int]{\ar@ialign} |
| 2547 |
% A new command that replaces \cs{ialign} used previously. \cs{everycr} is |
| 2548 |
% also applied to the \cs{cr} ending the preamble so we have to |
| 2549 |
% program around that. |
| 2550 |
% \changes{v2.6a}{2023/12/11}{Support for tagged PDF} |
| 2551 |
% \begin{macrocode} |
| 2552 |
\def\ar@ialign{% |
| 2553 |
% \end{macrocode} |
| 2554 |
% |
| 2555 |
% \begin{macrocode} |
| 2556 |
\everycr{% |
| 2557 |
\noalign{% |
| 2558 |
% \end{macrocode} |
| 2559 |
% If this \cs{cr} was at the end of a real row (e.g., not at the |
| 2560 |
% end of the table preamble) we have add a row end tag. |
| 2561 |
% \begin{macrocode} |
| 2562 |
\tbl_if_row_was_started:T { \UseTaggingSocket{tbl/row/end} } |
| 2563 |
% \end{macrocode} |
| 2564 |
% The we prepare for the next row. |
| 2565 |
% \begin{macrocode} |
| 2566 |
\tbl_update_cell_data_for_next_row: |
| 2567 |
}% |
| 2568 |
}% |
| 2569 |
\tabskip\z@skip\halign} |
| 2570 |
% \end{macrocode} |
| 2571 |
% \end{macro} |
| 2572 |
% |
| 2573 |
% |
| 2574 |
% |
| 2575 |
% |
| 2576 |
% |
| 2577 |
% \begin{macro}[no-user-doc]{\arraybackslash} |
| 2578 |
% \changes{v2.4a}{2003/12/17}{(DPC) Macro added (from tabularx)} |
| 2579 |
% Restore =\\= for use in array and tabular environment (after |
| 2580 |
% =\raggedright= etc.). |
| 2581 |
% \begin{macrocode} |
| 2582 |
\def\arraybackslash{\let\\\tabularnewline} |
| 2583 |
% \end{macrocode} |
| 2584 |
% \end{macro} |
| 2585 |
% |
| 2586 |
% \begin{macro}[no-user-doc]{\extrarowheight} |
| 2587 |
% The \textsf{dimen} parameter used above also needs to be |
| 2588 |
% allocated. As a default value we use \textsf{0pt}, to ensure |
| 2589 |
% compatibility with standard \LaTeX. |
| 2590 |
% \begin{macrocode} |
| 2591 |
\newdimen \extrarowheight |
| 2592 |
\extrarowheight=0pt |
| 2593 |
% \end{macrocode} |
| 2594 |
% \end{macro} |
| 2595 |
% |
| 2596 |
% \begin{macro}[int]{\@arstrut} |
| 2597 |
% Now the insertion of =\@arstrutbox= through =\@arstut= |
| 2598 |
% is easy since we know exactly in which mode \TeX\ is while working |
| 2599 |
% on the =\halign= preamble. |
| 2600 |
% \begin{macrocode} |
| 2601 |
\def\@arstrut{\unhcopy\@arstrutbox} |
| 2602 |
% \end{macrocode} |
| 2603 |
% \end{macro} |
| 2604 |
% |
| 2605 |
% |
| 2606 |
% \section{The line separator \texttt{\textbackslash\textbackslash}} |
| 2607 |
% |
| 2608 |
% \begin{macro}[int]{\@arraycr} |
| 2609 |
% In the macro =\@array= the line separator =\\= is |
| 2610 |
% =\let= to the command =\@arraycr=. |
| 2611 |
% \changes{v2.3c}{1995/04/23}{Avoid adding an ord atom in math} |
| 2612 |
% \changes{v2.5e}{2021/04/20}{Use \cs{protected} for \cs{\textbackslash} variant (gh/548)} |
| 2613 |
% \begin{macrocode} |
| 2614 |
\protected\def\@arraycr { |
| 2615 |
% \end{macrocode} |
| 2616 |
% Add code that figures out if the current table row is incomplete |
| 2617 |
% (not enough \verb=&=s). It can then do extra actions, such as |
| 2618 |
% inserting missing cell tags. |
| 2619 |
% \changes{v2.6a}{2023/12/11}{Managing cell indexes} |
| 2620 |
% \begin{macrocode} |
| 2621 |
\tbl_count_missing_cells:n {@arraycr} |
| 2622 |
% \end{macrocode} |
| 2623 |
% TODO: maybe this is also the right place to add a socket that |
| 2624 |
% could be used to actually enter missing cells instead of just |
| 2625 |
% adding tagging structures for them later. This would be optional |
| 2626 |
% but in many cases it would be the right thing to do (for example |
| 2627 |
% if tables contain vertical lines or similar visual structures |
| 2628 |
% that require fully specified rows. |
| 2629 |
% |
| 2630 |
% |
| 2631 |
% We then start a special brace which I have directly |
| 2632 |
% copied from the original definition. It is |
| 2633 |
% necessary, because the =\futurelet= in =\@ifnextchar= |
| 2634 |
% might |
| 2635 |
% expand a following =&= \textsf{token} in a construction like |
| 2636 |
% =\\ &=. This would otherwise end the alignment template at a |
| 2637 |
% wrong time. On the other hand we have to be careful to avoid |
| 2638 |
% producing a real group, i.e.\ ={}=, because the command will also |
| 2639 |
% be used for the array environment, i.e.\ in math mode. In that |
| 2640 |
% case an extra ={}= would produce an ord atom which could mess up |
| 2641 |
% the spacing. For this reason we use a combination that does not |
| 2642 |
% really produce a group at all but modifies the master counter so |
| 2643 |
% that a =&= will not be considered belonging to the current |
| 2644 |
% =\halign= while we are looking for a =*= or =[=. |
| 2645 |
% For further information see |
| 2646 |
% \cite[Appendix~D]{bk:knuth}. |
| 2647 |
% \begin{macrocode} |
| 2648 |
\iffalse{\fi\ifnum 0=`}\fi |
| 2649 |
% \end{macrocode} |
| 2650 |
% Then we test whether the user is using the star form and ignore |
| 2651 |
% a possible star (I also disagree with this procedure, because a |
| 2652 |
% star does not make any sense here). |
| 2653 |
% \begin{macrocode} |
| 2654 |
\@ifstar \@xarraycr \@xarraycr} |
| 2655 |
% \end{macrocode} |
| 2656 |
% \end{macro} |
| 2657 |
|
| 2658 |
|
| 2659 |
|
| 2660 |
|
| 2661 |
|
| 2662 |
% |
| 2663 |
% \begin{macro}[int]{\@xarraycr} |
| 2664 |
% In the command =\@xarraycr= we test if an optional argument |
| 2665 |
% exists. |
| 2666 |
% \begin{macrocode} |
| 2667 |
\def\@xarraycr{\@ifnextchar [% |
| 2668 |
% \end{macrocode} |
| 2669 |
% If it does, we branch out into the macro =\@argarraycr= if |
| 2670 |
% not we close the special brace (mentioned above) and end the row |
| 2671 |
% of the =\halign= with a =\cr=. |
| 2672 |
% \changes{v2.3c}{1995/04/23}{Avoid adding an ord atom in math} |
| 2673 |
% \begin{macrocode} |
| 2674 |
\@argarraycr {\ifnum 0=`{}\fi\cr}} |
| 2675 |
% \end{macrocode} |
| 2676 |
% \end{macro} |
| 2677 |
% |
| 2678 |
% |
| 2679 |
% \begin{macro}[int]{\@argarraycr} |
| 2680 |
% If additional space is requested by the user this case is treated |
| 2681 |
% in the macro =\@argarraycr=. First we close the special brace |
| 2682 |
% and then we test if the additional space is positive. |
| 2683 |
% \changes{v2.3c}{1995/04/23}{Avoid adding an ord atom in math} |
| 2684 |
% \begin{macrocode} |
| 2685 |
\def\@argarraycr[#1]{\ifnum0=`{}\fi\ifdim #1>\z@ |
| 2686 |
% \end{macrocode} |
| 2687 |
% If this is the case we create an invisible vertical rule with |
| 2688 |
% depth =\dp\@arstutbox=${}+{}$\meta{wanted\ space}. |
| 2689 |
% Thus we achieve that all vertical lines specified |
| 2690 |
% in the user preamble by a \texttt{|} are now |
| 2691 |
% generally drawn. |
| 2692 |
% Then the row ends with a =\cr=. |
| 2693 |
% |
| 2694 |
% If the space is negative we end the row at once with a =\cr= |
| 2695 |
% and move back up with a =\vskip=. |
| 2696 |
% |
| 2697 |
% While testing these macros I found out that the |
| 2698 |
% =\endtemplate= |
| 2699 |
% created by =\cr= and =&= is something like an |
| 2700 |
% =\outer= primitive and therefore it should not appear in |
| 2701 |
% incomplete =\if= statements. Thus the following solution was |
| 2702 |
% chosen which hides the =\cr= in other macros when \TeX\ |
| 2703 |
% is skipping conditional text. |
| 2704 |
% \changes{v2.3c}{1995/04/23}{Use \cs{expandafter}'s in conditional} |
| 2705 |
% \begin{macrocode} |
| 2706 |
\expandafter\@xargarraycr\else |
| 2707 |
\expandafter\@yargarraycr\fi{#1}} |
| 2708 |
% \end{macrocode} |
| 2709 |
% \end{macro} |
| 2710 |
% |
| 2711 |
% \begin{macro}[int]{\@xargarraycr} |
| 2712 |
% \begin{macro}[int]{\@yargarraycr} |
| 2713 |
% The following macros were already explained above. |
| 2714 |
% \changes{v2.4e}{2016/10/07}{Fixing SX68732} |
| 2715 |
% \begin{macrocode} |
| 2716 |
\def\@xargarraycr#1{\unskip\gdef\do@row@strut |
| 2717 |
{\@tempdima #1\advance\@tempdima \dp\@arstrutbox |
| 2718 |
\vrule \@depth\@tempdima \@width\z@\global\let\do@row@strut\relax}% |
| 2719 |
% \end{macrocode} |
| 2720 |
% If the last column is a =\multicolumn= cell then we need to |
| 2721 |
% insert the row strut now as it isn't inside the template (as that |
| 2722 |
% got =\omit=ted). |
| 2723 |
% \changes{v2.4h}{2018/04/30}{Fixing issue 42} |
| 2724 |
% \begin{macrocode} |
| 2725 |
\ifnum\@multicnt >\z@ \do@row@strut \fi |
| 2726 |
\cr} |
| 2727 |
\let\do@row@strut\relax |
| 2728 |
% \end{macrocode} |
| 2729 |
% |
| 2730 |
% \cs{@yargarraycr} is the same as in the \LaTeX{} kernel |
| 2731 |
% (depending on the date of the kernel with one of the two |
| 2732 |
% definitions below). We therefore do not define it again. |
| 2733 |
% \changes{v2.5b}{2020/04/22}{Don't define \cs{@yargarraycr} unnecessarily} |
| 2734 |
% \begin{macrocode} |
| 2735 |
%\def\@yargarraycr#1{\cr\noalign{\@vspace@calcify{#1}}} % 2020-10-01 |
| 2736 |
%\def\@yargarraycr#1{\cr\noalign{\vskip #1}} |
| 2737 |
% \end{macrocode} |
| 2738 |
% \end{macro} |
| 2739 |
% \end{macro} |
| 2740 |
% |
| 2741 |
% |
| 2742 |
% |
| 2743 |
% |
| 2744 |
% \section{Spanning several columns} |
| 2745 |
% |
| 2746 |
% \begin{macro}[no-user-doc]{\multicolumn} |
| 2747 |
% If several columns should be held together with a special format |
| 2748 |
% the command =\multicolumn= must be used. It has three |
| 2749 |
% arguments: the number of columns to be covered; the format for |
| 2750 |
% the result column and the actual column entry. |
| 2751 |
% \changes{v2.3j}{1998/01/29}{Command made \cs{long} to match |
| 2752 |
% kernel change for pr/2180} |
| 2753 |
% \changes{v2.6a}{2023/12/11}{Support for tagged PDF} |
| 2754 |
% \begin{macrocode} |
| 2755 |
\long\def\multicolumn#1#2#3{% |
| 2756 |
% \end{macrocode} |
| 2757 |
% First we combine the given number of columns into a single one; |
| 2758 |
% then we start a new block so that the following definition is kept |
| 2759 |
% local. |
| 2760 |
% \begin{macrocode} |
| 2761 |
\multispan{#1}\begingroup |
| 2762 |
% \end{macrocode} |
| 2763 |
% For tagging support we have to solve two problems: |
| 2764 |
% \cs{multicolumn} must handle the row begin if it is used there, |
| 2765 |
% and it must save the numbers of cells it spans so that we can add |
| 2766 |
% a suitable ColSpan attribute. We do this in the next macro |
| 2767 |
% (which in turn calls the \texttt{tbl/row/begin} socket, if |
| 2768 |
% necessary). |
| 2769 |
% \changes{v2.6a}{2023/12/11}{Managing cell indexes} |
| 2770 |
% \begin{macrocode} |
| 2771 |
\tbl_update_multicolumn_cell_data:n {#1} |
| 2772 |
% \end{macrocode} |
| 2773 |
% Since a =\multicolumn= should only describe the format of a |
| 2774 |
% result column, we redefine =\@addamp= in such a way that one gets |
| 2775 |
% an error message if one uses more than one \texttt{c}, |
| 2776 |
% \texttt{l}, \texttt{r}, \texttt{p}, \texttt{m} or \texttt{b} in |
| 2777 |
% the second argument. One should consider that this definition is |
| 2778 |
% local to the build-up of the preamble; an \textsf{array}-- or |
| 2779 |
% \textsf{tabular}--environment in the third argument of the |
| 2780 |
% =\multicolumn= is therefore worked through correctly as well. |
| 2781 |
% \begin{macrocode} |
| 2782 |
\def\@addamp{\if@firstamp \@firstampfalse \else |
| 2783 |
\@preamerr 5\fi}% |
| 2784 |
% \end{macrocode} |
| 2785 |
% Then we evaluate the second argument with the help of |
| 2786 |
% =\@mkpream=. |
| 2787 |
% Now we still have to insert the contents of the \textsf{token} |
| 2788 |
% register into the =\@preamble=, i.e.\ we have to say |
| 2789 |
% =\xdef\@preamble{\@preamble}=. This is achieved shorter by |
| 2790 |
% writing: |
| 2791 |
% \begin{macrocode} |
| 2792 |
\@mkpream{#2}\@addtopreamble\@empty |
| 2793 |
% \end{macrocode} |
| 2794 |
% After the =\@preamble= is created we forget all local |
| 2795 |
% definitions and occupations of the \textsf{token} registers. |
| 2796 |
% \begin{macrocode} |
| 2797 |
\endgroup |
| 2798 |
% \end{macrocode} |
| 2799 |
% Now we update the colspan attribute. This needs setting after |
| 2800 |
% the group as it is hidden inside the plug in \cs{insert@column}. |
| 2801 |
% \changes{v2.6a}{2023/12/11}{Support for tagged PDF} |
| 2802 |
% \begin{macrocode} |
| 2803 |
\UseTaggingSocket{tbl/colspan}{#1}% |
| 2804 |
% \end{macrocode} |
| 2805 |
% In the special situation of =\multicolumn= =\@preamble= |
| 2806 |
% is not needed as preamble for a =\halign= but it is directly |
| 2807 |
% inserted into our table. Thus instead of =\sharp= |
| 2808 |
% there has to be the column entry (=#3=) wanted by the user. |
| 2809 |
% \begin{macrocode} |
| 2810 |
\def\@sharp{#3}% |
| 2811 |
% \end{macrocode} |
| 2812 |
% Now we can pass the =\@preamble= to \TeX\ . For safety |
| 2813 |
% we start with an =\@arstrut=. This should usually be in the |
| 2814 |
% template for the first column however we do not know if this |
| 2815 |
% template was overwritten by our =\multicolumn=. |
| 2816 |
% We also add a =\null= at the right end to prevent any following |
| 2817 |
% =\unskip= (for example from =\\[..]=) to remove the =\tabcolsep=. |
| 2818 |
% \changes{v2.2e}{1994/06/01}{Added \cs{null}} |
| 2819 |
% \begin{macrocode} |
| 2820 |
\@arstrut \@preamble |
| 2821 |
\null |
| 2822 |
\ignorespaces} |
| 2823 |
% \end{macrocode} |
| 2824 |
% \end{macro} |
| 2825 |
% |
| 2826 |
% |
| 2827 |
% |
| 2828 |
% \section{The Environment Definitions} |
| 2829 |
% |
| 2830 |
% After these preparations we are able to define the environments. They |
| 2831 |
% only differ in the initializations of =\d@llar...=, =\col@sep= |
| 2832 |
% and =\@halignto=. |
| 2833 |
% |
| 2834 |
% \begin{macro}[int]{\@halignto} |
| 2835 |
% \begin{macro}[no-user-doc]{\d@llarbegin} |
| 2836 |
% \begin{macro}[no-user-doc]{\d@llarend} |
| 2837 |
% =\d@llar= has to be |
| 2838 |
% locally assigned since otherwise nested \textsf{tabular} and \textsf{array} |
| 2839 |
% environments (via =\multicolumn=) are impossible. |
| 2840 |
% For 25 years or so =\@halignto= was set globally (to save space on the |
| 2841 |
% save stack, but that was a mistake: if there is a tabular in the |
| 2842 |
% output routine (e.g., in the running header) then that tabular is |
| 2843 |
% able overwrite the =\@halignto= |
| 2844 |
% setting of a tabular in the main text resulting in a very weird error. |
| 2845 |
% \changes{v2.4d}{2016/10/06}{\cs{@halignto} set locally (pr/4488)} |
| 2846 |
% \changes{v2.0g}{1992/06/18}{`d@llarbegin defined on top-level.} |
| 2847 |
% When the new font selection scheme is in force we have to |
| 2848 |
% we surround all =\halign= entries |
| 2849 |
% with braces. See remarks in TUGboat 10\#2. Actually we are going |
| 2850 |
% to use =\begingroup= and =\endgroup=. However, this is only |
| 2851 |
% necessary when we are in text mode. In math the surrounding |
| 2852 |
% dollar signs will already serve as the necessary extra grouping |
| 2853 |
% level. Therefore we switch the settings of =\d@llarbegin= and |
| 2854 |
% =\d@llarend= between groups and dollar signs. |
| 2855 |
% \begin{macrocode} |
| 2856 |
\let\d@llarbegin\begingroup |
| 2857 |
\let\d@llarend\endgroup |
| 2858 |
% \end{macrocode} |
| 2859 |
% \end{macro} |
| 2860 |
% \end{macro} |
| 2861 |
% \end{macro} |
| 2862 |
% |
| 2863 |
% |
| 2864 |
% \begin{macro}[no-user-doc]{\array} |
| 2865 |
% Our new definition of =\array= then reads: |
| 2866 |
% \changes{v2.0d}{1990/08/20}{`d@llar local to preamble.} |
| 2867 |
% \changes{v2.4d}{2016/10/06}{\cs{@halignto} set locally (pr/4488)} |
| 2868 |
% In math mode we additionally add also the tagging sockets for luamml. |
| 2869 |
% \changes{v2.6h}{2024/12/02}{Add tagging sockets for luamml support}. |
| 2870 |
% The =math/luamml/array/finalizecol= takes as argument a number (0, 1, 2) |
| 2871 |
% that should represent the alignment (c,l,r). |
| 2872 |
% TODO: instead of =\the\@chnum= a proper tl should be used. |
| 2873 |
% TODO: the w and W columntypes must be redefined - currently they |
| 2874 |
% insert stray mtext columns. |
| 2875 |
% \begin{macrocode} |
| 2876 |
\def\array{\col@sep\arraycolsep |
| 2877 |
\def\d@llarbegin{$\tag_socket_use:n { math/luamml/array/initcol }} |
| 2878 |
\def\d@llarend |
| 2879 |
{ |
| 2880 |
\tag_socket_use:nn { math/luamml/save/nn }{{}{mtd}} |
| 2881 |
$ |
| 2882 |
\tag_socket_use:nn { math/luamml/array/finalizecol}{\the\@chnum} |
| 2883 |
} |
| 2884 |
\def\@halignto{}% |
| 2885 |
% \end{macrocode} |
| 2886 |
% Since there might be an optional argument we call another |
| 2887 |
% macro which is also used by the other environments. |
| 2888 |
% \begin{macrocode} |
| 2889 |
\@tabarray} |
| 2890 |
% \end{macrocode} |
| 2891 |
% \end{macro} |
| 2892 |
% |
| 2893 |
% \begin{macro}[int]{\@tabarray} |
| 2894 |
% \emph{The code below has been replaced long time ago by an |
| 2895 |
% extended version further down but the code and its documentation |
| 2896 |
% was left here for reference. It is now commented out to avoid |
| 2897 |
% confusion.} |
| 2898 |
% |
| 2899 |
% This macro tests for a optional bracket and then calls up |
| 2900 |
% =\@array= or =\@array[c]= (as default). |
| 2901 |
% \begin{macrocode} |
| 2902 |
%\def\@tabarray{\@ifnextchar[{\@array}{\@array[c]}} |
| 2903 |
% \end{macrocode} |
| 2904 |
% \end{macro} |
| 2905 |
% |
| 2906 |
% |
| 2907 |
% \begin{macro}[no-user-doc]{\tabular} |
| 2908 |
% \begin{macro}[no-user-doc]{\tabular*} |
| 2909 |
% The environments \textsf{tabular} and \textsf{tabular$*$} differ |
| 2910 |
% only in the initialization of the command =\@halignto=. Therefore |
| 2911 |
% we define |
| 2912 |
% \changes{v2.4d}{2016/10/06}{\cs{@halignto} set locally (pr/4488)} |
| 2913 |
% \begin{macrocode} |
| 2914 |
\def\tabular{\def\@halignto{}\@tabular} |
| 2915 |
% \end{macrocode} |
| 2916 |
% and analogously for the star form. We evaluate the argument first |
| 2917 |
% using =\setlength= so that users of the \texttt{calc} package can |
| 2918 |
% write code like\\ =\begin{tabular*}{(\columnwidth-1cm)/2}...= |
| 2919 |
% \changes{v2.3l}{1998/05/13}{Use \cs{setlength} evaluate arg |
| 2920 |
% so that the calc package can be applied here (pr/2793)} |
| 2921 |
% \changes{v2.4d}{2016/10/06}{\cs{@halignto} set locally (pr/4488)} |
| 2922 |
% \begin{macrocode} |
| 2923 |
\expandafter\def\csname tabular*\endcsname#1{% |
| 2924 |
\setlength\dimen@{#1}% |
| 2925 |
\edef\@halignto{to\the\dimen@}\@tabular} |
| 2926 |
% \end{macrocode} |
| 2927 |
% \end{macro} |
| 2928 |
% \end{macro} |
| 2929 |
% |
| 2930 |
% \begin{macro}[int]{\@tabular} |
| 2931 |
% The rest of the job is carried out by the =\@tabular= macro: |
| 2932 |
% \begin{macrocode} |
| 2933 |
\providecommand\UseMathForPositioningText{} |
| 2934 |
\providecommand\@kernel@tabular@init{} |
| 2935 |
\def\@tabular{% |
| 2936 |
% \end{macrocode} |
| 2937 |
% First of all we have to make sure that we start out in |
| 2938 |
% \textsf{hmode}. Otherwise we might find our table dangling by |
| 2939 |
% itself on a line. |
| 2940 |
% \begin{macrocode} |
| 2941 |
\leavevmode |
| 2942 |
% \end{macrocode} |
| 2943 |
% Now that we know we are in hmode we can add the start tag for the |
| 2944 |
% whole table. |
| 2945 |
% \changes{v2.6a}{2023/12/11}{Support for tagged PDF} |
| 2946 |
% \begin{macrocode} |
| 2947 |
\UseTaggingSocket{tbl/hmode/begin}% |
| 2948 |
% \end{macrocode} |
| 2949 |
% It should be taken into consideration that the macro =\@array= |
| 2950 |
% must be called in math mode. Therefore we open a \textsf{box}, |
| 2951 |
% insert a =$= and then assign the correct values to =\col@sep= and |
| 2952 |
% =\d@llar...=. |
| 2953 |
% \changes{v2.0d}{1990/08/20}{`d@llar local to preamble.} |
| 2954 |
% \changes{v2.6h}{2025/02/18}{Surround dollar with \cs{MathCollectTrue}/\cs{MathCollectFalse}}% |
| 2955 |
% \changes{v2.6l}{2025/09/09}{Use \cs{UseMathForPositioningText} instead (tagging/973+983)}% |
| 2956 |
% \begin{macrocode} |
| 2957 |
\hbox \bgroup |
| 2958 |
\UseMathForPositioningText $% |
| 2959 |
\col@sep\tabcolsep |
| 2960 |
\let\d@llarbegin\begingroup |
| 2961 |
\let\d@llarend\endgroup |
| 2962 |
% \end{macrocode} |
| 2963 |
% \changes{v2.6h}{2025/02/18}{Add internal kernel hook to switch math collection method}% |
| 2964 |
% \begin{macrocode} |
| 2965 |
\@kernel@tabular@init |
| 2966 |
% \end{macrocode} |
| 2967 |
% Now everything \textsf{tabular} specific is done and we are able to |
| 2968 |
% call the =\@tabarray= macro. |
| 2969 |
% \begin{macrocode} |
| 2970 |
\@tabarray} |
| 2971 |
% \end{macrocode} |
| 2972 |
% \end{macro} |
| 2973 |
% |
| 2974 |
% \begin{macro}[no-user-doc]{\endarray} |
| 2975 |
% |
| 2976 |
% When the processing of \textsf{array} is finished we have to |
| 2977 |
% close the =\halign= |
| 2978 |
% and afterwards the surrounding \textsf{box} selected by |
| 2979 |
% =\@array=. To save \textsf{token} space we then redefine |
| 2980 |
% =\@preamble= |
| 2981 |
% because its replacement text isn't longer needed. |
| 2982 |
% |
| 2983 |
% To handle cell indexes, we do not use \cs{crcr} but a variant |
| 2984 |
% that also handles missing cells as necessary. |
| 2985 |
% \changes{v2.6a}{2023/12/11}{Support for tagged PDF} |
| 2986 |
% \changes{v2.6h}{2024/12/02}{Add tagging sockets for luamml support}% |
| 2987 |
% \begin{macrocode} |
| 2988 |
\def\endarray { |
| 2989 |
\tbl_crcr:n{endarray} |
| 2990 |
\tag_socket_use_expandable:n { math/luamml/array/save } |
| 2991 |
\egroup |
| 2992 |
\tag_socket_use:n { tbl/finalize } |
| 2993 |
% \end{macrocode} |
| 2994 |
% |
| 2995 |
% If tables are nested into another then it is necessary to |
| 2996 |
% restore information about the cell the inner table started |
| 2997 |
% in. Otherwise, the cell index data structures reflect the |
| 2998 |
% status in the outer table as they |
| 2999 |
% are globally manipulated. We restore in all cases even if we are |
| 3000 |
% not in a nesting situation as that makes the code simpler (and |
| 3001 |
% probably faster). |
| 3002 |
% |
| 3003 |
% \cs{endtabular} and \cs{endtabular*} inherit from \cs{endarray} |
| 3004 |
% so we only need to change that. \texttt{tabularx} uses a similar method. |
| 3005 |
% \changes{v2.6a}{2023/12/11}{Managing cell indexes} |
| 3006 |
% \begin{macrocode} |
| 3007 |
\tbl_restore_outer_cell_data: |
| 3008 |
% \end{macrocode} |
| 3009 |
% |
| 3010 |
% \begin{macrocode} |
| 3011 |
\egroup |
| 3012 |
\tag_socket_use:n { math/luamml/array/finalize } |
| 3013 |
\@arrayright \gdef\@preamble{}% |
| 3014 |
} |
| 3015 |
% \end{macrocode} |
| 3016 |
% \end{macro} |
| 3017 |
% |
| 3018 |
% |
| 3019 |
% |
| 3020 |
% |
| 3021 |
% \begin{macro}[no-user-doc]{\endtabular} |
| 3022 |
% \begin{macro}[no-user-doc]{\endtabular*} |
| 3023 |
% To end a \textsf{tabular} or \textsf{tabular$*$} environment we |
| 3024 |
% call up =\endarray=, close the math mode and then the surrounding |
| 3025 |
% =\hbox=. This math mode around the tabular should not be surrounded by |
| 3026 |
% any =\mathsurround= so we cancel that with =\m@th=. |
| 3027 |
% \changes{v2.5f}{2021/07/12}{Cancel any outside \cs{mathsurround} (gh/614)} |
| 3028 |
% \begin{macrocode} |
| 3029 |
\def\endtabular{\endarray\m@th $\egroup |
| 3030 |
% \end{macrocode} |
| 3031 |
% |
| 3032 |
% \changes{v2.6a}{2023/12/11}{Support for tagged PDF} |
| 3033 |
% \begin{macrocode} |
| 3034 |
\UseTaggingSocket{tbl/hmode/end}% |
| 3035 |
} |
| 3036 |
\expandafter\let\csname endtabular*\endcsname=\endtabular |
| 3037 |
% \end{macrocode} |
| 3038 |
% \end{macro} |
| 3039 |
% \end{macro} |
| 3040 |
% |
| 3041 |
% |
| 3042 |
% |
| 3043 |
% \section{Last minute definitions} |
| 3044 |
% |
| 3045 |
% |
| 3046 |
% If this file is used as a package file we should =\let= all macros |
| 3047 |
% to =\relax= that were used in the original but are no longer |
| 3048 |
% necessary. |
| 3049 |
% \begin{macrocode} |
| 3050 |
\let\@ampacol=\relax \let\@expast=\relax |
| 3051 |
\let\@arrayclassiv=\relax \let\@arrayclassz=\relax |
| 3052 |
\let\@tabclassiv=\relax \let\@tabclassz=\relax |
| 3053 |
\let\@arrayacol=\relax \let\@tabacol=\relax |
| 3054 |
\let\@tabularcr=\relax \let\@@@@endpbox=\relax |
| 3055 |
\let\@argtabularcr=\relax \let\@xtabularcr=\relax |
| 3056 |
% \end{macrocode} |
| 3057 |
% |
| 3058 |
% \begin{macro}[int]{\@preamerr} |
| 3059 |
% \changes{v2.6d}{2024/06/14}{Keep message sources out of L3 code (gh/1378)} |
| 3060 |
% We also have to redefine the error routine =\@preamerr= since |
| 3061 |
% new kind of errors are possible. |
| 3062 |
% The code for this macro is not perfect yet; |
| 3063 |
% it still needs too much memory. |
| 3064 |
% \begin{macrocode} |
| 3065 |
\ExplSyntaxOff |
| 3066 |
\def\@preamerr#1{\def\@tempd{{..} at wrong position: }% |
| 3067 |
\PackageError{array}{% |
| 3068 |
\ifcase #1 Illegal pream-token (\@nextchar): `c' used\or %0 |
| 3069 |
Missing arg: token ignored\or %1 |
| 3070 |
Empty preamble: `l' used\or %2 |
| 3071 |
>\@tempd token ignored\or %3 |
| 3072 |
<\@tempd changed to !{..}\or %4 |
| 3073 |
Only one column-spec. allowed.\fi}\@ehc} %5 |
| 3074 |
% \end{macrocode} |
| 3075 |
% \end{macro} |
| 3076 |
% |
| 3077 |
% |
| 3078 |
% |
| 3079 |
% \section |
| 3080 |
% [Defining your own column specifiers] |
| 3081 |
% {Defining your own column specifiers\footnotemark} |
| 3082 |
% |
| 3083 |
% \footnotetext{The code and the documentation in this section was |
| 3084 |
% written by David. So far only the code from newarray was plugged |
| 3085 |
% into array so that some parts of the documentation still claim |
| 3086 |
% that this is newarray and even worse, some parts of the code are |
| 3087 |
% unnecessarily doubled. This will go away in a future release. For |
| 3088 |
% the moment we thought it would be more important to bring both |
| 3089 |
% packages together.} |
| 3090 |
% \changes{v2.1a}{1992/07/03}{Newcolumn stuff added} |
| 3091 |
% |
| 3092 |
% \DeleteShortVerb{\=} |
| 3093 |
% \MakeShortVerb{\"} |
| 3094 |
% |
| 3095 |
% \begin{macro}[no-user-doc]{\newcolumn} |
| 3096 |
% In \texttt{newarray.sty} the macro for specifying new columns was |
| 3097 |
% named "\newcolumn". When the functionality was added to |
| 3098 |
% \texttt{array.sty} the command was renamed "\newcolumntype". |
| 3099 |
% Initially both names were supported, but now (In versions of this |
| 3100 |
% package distributed for \LaTeXe) the old name is not defined. |
| 3101 |
% \changes{v2.2a}{1994/02/03}{Now made `newcolumn an error} |
| 3102 |
% \changes{v2.2a}{1994/02/04}{Removed `newcolumn} |
| 3103 |
% \begin{macrocode} |
| 3104 |
%<*ncols> |
| 3105 |
% \end{macrocode} |
| 3106 |
% \end{macro} |
| 3107 |
% |
| 3108 |
% \begin{macro}[no-user-doc]{\newcolumntype} |
| 3109 |
% \changes{v2.1b}{1992/06/07}{Macro renamed from `newcolumn} As |
| 3110 |
% described above, the "\newcolumntype" macro gives users the chance |
| 3111 |
% to define letters, to be used in the same way as the primitive |
| 3112 |
% column specifiers, `c' `p' etc. |
| 3113 |
% \begin{macrocode} |
| 3114 |
\def\newcolumntype#1{% |
| 3115 |
% \end{macrocode} |
| 3116 |
% "\NC@char" was added in V2.01 so that active characters, like "@" in |
| 3117 |
% AMS\LaTeX\ may be used. This trick was stolen from \texttt{array.sty} |
| 3118 |
% 2.0h. Note that we need to use the possibly active token, |
| 3119 |
% "#1", in several places, as that is the token that actually |
| 3120 |
% appears in the preamble argument. |
| 3121 |
% \begin{macrocode} |
| 3122 |
\edef\NC@char{\string#1}% |
| 3123 |
% \end{macrocode} |
| 3124 |
% First we check whether there is already a definition for this column. |
| 3125 |
% Unlike "\newcommand" we give a warning rather than an error if it is |
| 3126 |
% defined. If it is a new column, add "\NC@do" \meta{column} to |
| 3127 |
% the list "\NC@list". |
| 3128 |
% \begin{macrocode} |
| 3129 |
\@ifundefined{NC@find@\NC@char}% |
| 3130 |
{\@tfor\next:=<>clrmbp@!|\do |
| 3131 |
{% |
| 3132 |
% \end{macrocode} |
| 3133 |
% We use \cs{noexpand} on the tokens from the list in case one or |
| 3134 |
% the other (typically \texttt{@}, \texttt{!} or \texttt{|}) has |
| 3135 |
% been made active. |
| 3136 |
% \changes{v2.4l}{2019/08/31}{Add a necessary \cs{expandafter} (github/148)} |
| 3137 |
% \begin{macrocode} |
| 3138 |
\if\expandafter\noexpand\next\NC@char |
| 3139 |
\PackageWarning{array}% |
| 3140 |
{Redefining primitive column \NC@char}\fi}% |
| 3141 |
\NC@list\expandafter{\the\NC@list\NC@do#1}}% |
| 3142 |
{\PackageWarning{array}{Column \NC@char\space is already defined}}% |
| 3143 |
% \end{macrocode} |
| 3144 |
% Now we define a macro with an argument delimited by the new column |
| 3145 |
% specifier, this is used to find occurrences of this specifier in the |
| 3146 |
% user preamble. |
| 3147 |
% \begin{macrocode} |
| 3148 |
\@namedef{NC@find@\NC@char}##1#1{\NC@{##1}}% |
| 3149 |
% \end{macrocode} |
| 3150 |
% If an optional argument was not given, give a default argument of 0. |
| 3151 |
% \begin{macrocode} |
| 3152 |
\@ifnextchar[{\newcol@{\NC@char}}{\newcol@{\NC@char}[0]}} |
| 3153 |
\ExplSyntaxOn |
| 3154 |
% \end{macrocode} |
| 3155 |
% \end{macro} |
| 3156 |
% \begin{macro}[int]{\newcol@} |
| 3157 |
% We can now define the macro which does the rewriting, |
| 3158 |
% "\@reargdef" takes the same arguments as "\newcommand", but |
| 3159 |
% does not check that the command is new. For a column, say `D' with |
| 3160 |
% one argument, define a command "\NC@rewrite@D" with one |
| 3161 |
% argument, which recursively calls "\NC@find" on the user preamble |
| 3162 |
% after replacing the first token or group with the replacement text |
| 3163 |
% specified in the "\newcolumntype" command. "\NC@find" will find the |
| 3164 |
% next occurrence of `D' as it will be "\let" equal to |
| 3165 |
% "\NC@find@D" by "\NC@do". |
| 3166 |
% \begin{macrocode} |
| 3167 |
\def\newcol@#1[#2]#3{\expandafter\@reargdef |
| 3168 |
\csname NC@rewrite@#1\endcsname[#2]{\NC@find#3}} |
| 3169 |
% \end{macrocode} |
| 3170 |
% \end{macro} |
| 3171 |
% \begin{macro}[int]{\NC@} |
| 3172 |
% Having found an occurrence of the new column, save the preamble |
| 3173 |
% before the column in "\@temptokena", then check to see if we |
| 3174 |
% are at the end of the preamble. (A dummy occurrence of the column |
| 3175 |
% specifier will be placed at the end of the preamble by "\NC@do". |
| 3176 |
% \begin{macrocode} |
| 3177 |
\def\NC@#1{% |
| 3178 |
\@temptokena\expandafter{\the\@temptokena#1}\futurelet\next\NC@ifend} |
| 3179 |
% \end{macrocode} |
| 3180 |
% \end{macro} |
| 3181 |
% \begin{macro}[int]{\NC@ifend} |
| 3182 |
% We can tell that we are at the end as "\NC@do" will place a "\relax" |
| 3183 |
% after the dummy column. |
| 3184 |
% \begin{macrocode} |
| 3185 |
\def\NC@ifend{% |
| 3186 |
% \end{macrocode} |
| 3187 |
% If we are at the end, do nothing. (The whole preamble will now be in |
| 3188 |
% "\@temptokena".) |
| 3189 |
% \begin{macrocode} |
| 3190 |
\ifx\next\relax |
| 3191 |
% \end{macrocode} |
| 3192 |
% Otherwise set the flag "\if@tempswa", and rewrite the column. |
| 3193 |
% "\expandafter" introduced 1n V2.01 |
| 3194 |
% \begin{macrocode} |
| 3195 |
\else\@tempswatrue\expandafter\NC@rewrite\fi} |
| 3196 |
% \end{macrocode} |
| 3197 |
% \end{macro} |
| 3198 |
% \begin{macro}[int]{\NC@do} |
| 3199 |
% If the user has specified `C' and `L' as new columns, the list of |
| 3200 |
% rewrites (in the token register "\NC@list") will look like |
| 3201 |
% "\NC@do *" "\NC@do C" "\NC@do L". |
| 3202 |
% So we need to define "\NC@do" as a one argument macro which |
| 3203 |
% initializes the rewriting of the specified column. Let us assume that |
| 3204 |
% `C' is the argument. |
| 3205 |
% \begin{macrocode} |
| 3206 |
\def\NC@do#1{% |
| 3207 |
% \end{macrocode} |
| 3208 |
% First we let "\NC@rewrite" and "\NC@find" be |
| 3209 |
% "\NC@rewrite@C" and "\NC@find@C" respectively. |
| 3210 |
% \begin{macrocode} |
| 3211 |
\expandafter\let\expandafter\NC@rewrite |
| 3212 |
\csname NC@rewrite@\string#1\endcsname |
| 3213 |
\expandafter\let\expandafter\NC@find |
| 3214 |
\csname NC@find@\string#1\endcsname |
| 3215 |
% \end{macrocode} |
| 3216 |
% Clear the token register "\@temptokena" after putting the present |
| 3217 |
% contents of the register in front of the token "\NC@find". At the |
| 3218 |
% end we place the tokens `"C\relax"' which "\NC@ifend" will use |
| 3219 |
% to detect the end of the user preamble. |
| 3220 |
% \begin{macrocode} |
| 3221 |
\expandafter\@temptokena\expandafter{\expandafter}% |
| 3222 |
\expandafter\NC@find\the\@temptokena#1\relax} |
| 3223 |
% \end{macrocode} |
| 3224 |
% \end{macro} |
| 3225 |
% |
| 3226 |
% \begin{macro}[no-user-doc]{\showcols} |
| 3227 |
% This macro is useful for debugging "\newcolumntype" specifications, |
| 3228 |
% it is the equivalent of the primitive "\show" command for macro |
| 3229 |
% definitions. All we need to do is locally redefine "\NC@do" to take |
| 3230 |
% its argument (say `C') and then "\show" the (slightly modified) |
| 3231 |
% definition of "\NC@rewrite@C". Actually as the list always |
| 3232 |
% starts off with "\NC@do *" and we do not want to print the |
| 3233 |
% definition of the $*$-form, define "\NC@do" to throw away the first |
| 3234 |
% item in the list, and then redefine itself to print the rest of the |
| 3235 |
% definitions. |
| 3236 |
% \begin{macrocode} |
| 3237 |
\def\showcols{{\def\NC@do##1{\let\NC@do\NC@show}\the\NC@list}} |
| 3238 |
% \end{macrocode} |
| 3239 |
% \end{macro} |
| 3240 |
% \begin{macro}[int]{\NC@show} |
| 3241 |
% If the column `C' is defined as above, then |
| 3242 |
% "\show\NC@rewrite@C" would output\\ |
| 3243 |
% "\long macro: ->\NC@find >{$}c<{$}". |
| 3244 |
% We want to strip the "long macro: ->" and the "\NC@find". So first we |
| 3245 |
% use "\meaning" and then apply the macro "\NC@strip" to the tokens so |
| 3246 |
% produced and then "\typeout" the required string. |
| 3247 |
% \begin{macrocode} |
| 3248 |
\def\NC@show#1{% |
| 3249 |
\typeout{Column~ #1\expandafter\expandafter\expandafter\NC@strip |
| 3250 |
\expandafter\meaning\csname NC@rewrite@#1\endcsname\@@@@}} |
| 3251 |
% \end{macrocode} |
| 3252 |
% \end{macro} |
| 3253 |
% \begin{macro}[int]{\NC@strip} |
| 3254 |
% Delimit the arguments to "\NC@strip" with `\texttt{:}', `\texttt{->}', |
| 3255 |
% a space, and "\@@@@" to pull out the required parts of the output from |
| 3256 |
% "\meaning". |
| 3257 |
% \begin{macrocode} |
| 3258 |
\ExplSyntaxOff |
| 3259 |
\def\NC@strip#1:#2->#3 #4\@@@@{#2 -> #4} |
| 3260 |
\ExplSyntaxOn |
| 3261 |
% \end{macrocode} |
| 3262 |
% \end{macro} |
| 3263 |
% \begin{macro}[int]{\NC@list} |
| 3264 |
% Allocate the token register used for the rewrite list. |
| 3265 |
% \begin{macrocode} |
| 3266 |
\newtoks\NC@list |
| 3267 |
% \end{macrocode} |
| 3268 |
% \end{macro} |
| 3269 |
% |
| 3270 |
% \subsection{The \texorpdfstring{$*$}{*}--form} |
| 3271 |
% We view the $*$-form as a slight generalization of the system |
| 3272 |
% described in the previous subsection. The idea is to define a $*$ |
| 3273 |
% column by a command of the form: |
| 3274 |
% \begin{verbatim} |
| 3275 |
% \newcolumntype{*}[2]{% |
| 3276 |
% \count@=#1\ifnum\count@>0 |
| 3277 |
% \advance\count@ by -1 #2*{\count@}{#2}\fi} |
| 3278 |
% \end{verbatim} |
| 3279 |
% \begin{macro}[int]{\NC@rewrite@*}\label{NC@rewrite@*} |
| 3280 |
% \changes{v2.4b}{2005/08/23}{Fix occasional spurious space (PR/3755)} |
| 3281 |
% This does not work however as "\newcolumntype" takes great care not |
| 3282 |
% to expand anything in the preamble, and so the "\if" is never |
| 3283 |
% expanded. "\newcolumntype" sets up various other parts of the |
| 3284 |
% rewrite correctly though so we can define: |
| 3285 |
% \begin{macrocode} |
| 3286 |
\newcolumntype{*}[2]{} |
| 3287 |
% \end{macrocode} |
| 3288 |
% Now we must correct the definition of "\NC@rewrite@*". The |
| 3289 |
% following is probably more efficient than a direct translation of |
| 3290 |
% the idea sketched above, we do not need to put a $*$ in the preamble |
| 3291 |
% and call the rewrite recursively, we can just put "#1" copies of |
| 3292 |
% "#2" into "\@temptokena". (Nested $*$ forms will be expanded |
| 3293 |
% when the whole rewrite list is expanded again, see "\@mkpream") |
| 3294 |
% \begin{macrocode} |
| 3295 |
\long\@namedef{NC@rewrite@*}#1#2{% |
| 3296 |
% \end{macrocode} |
| 3297 |
% Store the number. |
| 3298 |
% \begin{macrocode} |
| 3299 |
\count@#1\relax |
| 3300 |
% \end{macrocode} |
| 3301 |
% Put "#1" copies of "#2" in the token register. |
| 3302 |
% \begin{macrocode} |
| 3303 |
\loop |
| 3304 |
\ifnum\count@>\z@ |
| 3305 |
\advance\count@\m@ne |
| 3306 |
\@temptokena\expandafter{\the\@temptokena#2}% |
| 3307 |
\repeat |
| 3308 |
% \end{macrocode} |
| 3309 |
% "\NC@do" will ensure that "\NC@find" is "\let" equal |
| 3310 |
% to "\NC@find@*". |
| 3311 |
% \begin{macrocode} |
| 3312 |
\NC@find} |
| 3313 |
% \end{macrocode} |
| 3314 |
% \end{macro} |
| 3315 |
% |
| 3316 |
% \subsection{Modifications to internal macros of \texttt{array.sty}} |
| 3317 |
% |
| 3318 |
% \begin{macro}[int]{\@xexpast} |
| 3319 |
% \begin{macro}[int]{\@xexnoop} |
| 3320 |
% These macros are used to expand $*$-forms in |
| 3321 |
% \texttt{array.sty}. "\let" them to "\relax" to save space. |
| 3322 |
% \begin{macrocode} |
| 3323 |
\let\@xexpast\relax |
| 3324 |
\let\@xexnoop\relax |
| 3325 |
% \end{macrocode} |
| 3326 |
% \end{macro} |
| 3327 |
% \end{macro} |
| 3328 |
% |
| 3329 |
% \begin{macro}[int]{\save@decl} |
| 3330 |
% We do not assume that the token register is free, we add the new |
| 3331 |
% declarations to the front of the register. This is to allow user |
| 3332 |
% preambles of the form, ">{foo}>{bar}..". Users are not encouraged to |
| 3333 |
% enter such expressions directly, but they may result from the |
| 3334 |
% rewriting of "\newcolumntype"'s. |
| 3335 |
% \begin{macrocode} |
| 3336 |
\def\save@decl{\toks \count@ = \expandafter\expandafter\expandafter |
| 3337 |
{\expandafter\@nextchar\the\toks\count@}} |
| 3338 |
% \end{macrocode} |
| 3339 |
% \end{macro} |
| 3340 |
% |
| 3341 |
% \begin{macro}[int]{\@mkpream} |
| 3342 |
% The main modification to "\@mkpream" is to replace the call to |
| 3343 |
% "\@xexpast" (which expanded $*$-forms) by a loop which expands |
| 3344 |
% all "\newcolumntype" specifiers. |
| 3345 |
% \changes{v2.4e}{2016/10/07}{Fixing SX68732} |
| 3346 |
% \changes{v2.4f}{2017/11/04}{Managing m-cells without \cs{vcenter}} |
| 3347 |
% \begin{macrocode} |
| 3348 |
\ExplSyntaxOff % really oldstyle using \@tfor := |
| 3349 |
\def\@mkpream#1{\gdef\@preamble{}\@lastchclass 4 \@firstamptrue |
| 3350 |
\let\@sharp\relax |
| 3351 |
% \end{macrocode} |
| 3352 |
% |
| 3353 |
% The "\@startpbox" (which is called for "p", "m" or "b" columns) |
| 3354 |
% receives a user supplied argument: the width of the |
| 3355 |
% paragraph-column. Normally that is something harmless like a length or a |
| 3356 |
% simple length expression, but with the calc package involved it |
| 3357 |
% could break under an "\edef" operation, which is how the preamble |
| 3358 |
% is constructed. We now make use of "\unexpanded" here to prevent that. The |
| 3359 |
% "\expandafter" gymnastics are necessary to expand the "#1" exactly |
| 3360 |
% once (since it will get "\@nextchar" as its value and need its |
| 3361 |
% content). However, once added to the preamble, no further |
| 3362 |
% expansion should happen if the preamble is extended. Therefore we |
| 3363 |
% change from \cs{@startpbox} to \cs{@startpbox@action}. The latter |
| 3364 |
% then has a trivial definition and expands (including its |
| 3365 |
% argument) to itself while the preamble is being built. Outside of this |
| 3366 |
% preamble build up \cs{@startpbox@action} does the actual work. |
| 3367 |
% |
| 3368 |
% \changes{v2.4j}{2018/11/13}{Do not expand argument of |
| 3369 |
% \cs{@startpbox} while building the tabular preamble (sx/459285)} |
| 3370 |
% \changes{v2.6h}{2024/12/17}{Expand argument of \cs{@startpbox} |
| 3371 |
% exactly once while the preamble is being built, and use |
| 3372 |
% \cs{@startpbox@action} later to do the real work (gh/1585)} |
| 3373 |
% \begin{macrocode} |
| 3374 |
\def\@startpbox##1{\unexpanded\expandafter{\expandafter |
| 3375 |
\@startpbox@action\expandafter{##1}}}% |
| 3376 |
\def\@startpbox@action##1{\unexpanded{\@startpbox@action{##1}}}% |
| 3377 |
\let\@endpbox\relax |
| 3378 |
\let\do@row@strut\relax |
| 3379 |
\let\ar@align@mcell\relax |
| 3380 |
% \end{macrocode} |
| 3381 |
% Now we remove possible $*$-forms and user-defined column |
| 3382 |
% specifiers in the user preamble by repeatedly executing the list |
| 3383 |
% "\NC@list" until the re-writes have no more effect. The |
| 3384 |
% expanded preamble will then be in the token register |
| 3385 |
% "\@temptokena". Actually we need to know at this point that |
| 3386 |
% this is not "\toks0". |
| 3387 |
% \begin{macrocode} |
| 3388 |
\@temptokena{#1}\@tempswatrue |
| 3389 |
\@whilesw\if@tempswa\fi{\@tempswafalse\the\NC@list}% |
| 3390 |
% \end{macrocode} |
| 3391 |
% Afterwards we initialize all registers and macros, that we need |
| 3392 |
% for the build-up of the preamble. |
| 3393 |
% \begin{macrocode} |
| 3394 |
\count@\m@ne |
| 3395 |
\let\the@toks\relax |
| 3396 |
\prepnext@tok |
| 3397 |
% \end{macrocode} |
| 3398 |
% Having expanded all tokens defined using "\newcolumntype" (including |
| 3399 |
% "*"), we evaluate the remaining tokens, which are saved in |
| 3400 |
% "\@temptokena". We use the \LaTeX--macro "\@tfor" to inspect each |
| 3401 |
% token in turn. |
| 3402 |
% \begin{macrocode} |
| 3403 |
\expandafter \@tfor \expandafter \@nextchar |
| 3404 |
\expandafter :\expandafter =\the\@temptokena \do |
| 3405 |
% \end{macrocode} |
| 3406 |
% "\@testpatch" does not take an argument since \texttt{array.sty} 2.0h. |
| 3407 |
% \begin{macrocode} |
| 3408 |
{\@testpach |
| 3409 |
\ifcase \@chclass \@classz \or \@classi \or \@classii |
| 3410 |
\or \save@decl \or \or \@classv \or \@classvi |
| 3411 |
\or \@classvii \or \@classviii |
| 3412 |
% \end{macrocode} |
| 3413 |
% In \texttt{newarray.sty} class 9 is equivalent to class 10. |
| 3414 |
% \begin{macrocode} |
| 3415 |
\or \@classx |
| 3416 |
\or \@classx \fi |
| 3417 |
\@lastchclass\@chclass}% |
| 3418 |
\ifcase\@lastchclass |
| 3419 |
\@acol \or |
| 3420 |
\or |
| 3421 |
\@acol \or |
| 3422 |
\@preamerr \thr@@@@ \or |
| 3423 |
\@preamerr \tw@ \@addtopreamble\@sharp \or |
| 3424 |
\or |
| 3425 |
\else \@preamerr \@ne \fi |
| 3426 |
\def\the@toks{\the\toks}} |
| 3427 |
\ExplSyntaxOn |
| 3428 |
% \end{macrocode} |
| 3429 |
% \end{macro} |
| 3430 |
% |
| 3431 |
% \begin{macro}[int]{\@classix} |
| 3432 |
% \texttt{array.sty} does not allow repeated \texttt{>} |
| 3433 |
% declarations for the same column. This is allowed in |
| 3434 |
% \texttt{newarray.sty} as documented in the introduction. Removing |
| 3435 |
% the test for this case makes class 9 equivalent to class 10, and |
| 3436 |
% so this macro is redundant. It is "\let" to "\relax" to save |
| 3437 |
% space. |
| 3438 |
% \begin{macrocode} |
| 3439 |
\let\@classix\relax |
| 3440 |
% \end{macrocode} |
| 3441 |
% \end{macro} |
| 3442 |
% |
| 3443 |
% \begin{macro}[int]{\@classviii} |
| 3444 |
% In \texttt{newarray.sty} explicitly allow class 2, as repeated |
| 3445 |
% \texttt{<} expressions are accepted by this package. |
| 3446 |
% \begin{macrocode} |
| 3447 |
\def\@classviii{\ifnum \@lastchclass >\z@\ifnum\@lastchclass=\tw@\else |
| 3448 |
\@preamerr 4\@chclass 6 \@classvi \fi\fi} |
| 3449 |
% \end{macrocode} |
| 3450 |
% \end{macro} |
| 3451 |
% |
| 3452 |
% \begin{macro}[int]{\@classv} |
| 3453 |
% Class 5 is \texttt{@}-expressions (and is also called by class 1) |
| 3454 |
% This macro was incorrect in Version~1. Now we do not expand the |
| 3455 |
% "@"-expression, but instead explicitly replace an |
| 3456 |
% "\extracolsep" command by an assignment to "\tabskip" by a |
| 3457 |
% method similar to the "\newcolumntype" system described above. |
| 3458 |
% "\d@llarbegin" "\d@llarend" were introduced in V2.01 to match |
| 3459 |
% \texttt{array.sty} 2.0h. |
| 3460 |
% \begin{macrocode} |
| 3461 |
\def\@classv{\save@decl |
| 3462 |
\expandafter\NC@ecs\@nextchar\extracolsep{}\extracolsep\@@@@@@ |
| 3463 |
\@addtopreamble{\d@llarbegin\the@toks\the\count@\relax\d@llarend}% |
| 3464 |
\prepnext@tok} |
| 3465 |
% \end{macrocode} |
| 3466 |
% \end{macro} |
| 3467 |
% |
| 3468 |
% \begin{macro}[int]{\NC@ecs} |
| 3469 |
% Rewrite the first occurrence of "\extracolsep{1in}" to |
| 3470 |
% "\tabskip1in\relax". As a side effect discard any tokens after a |
| 3471 |
% second "\extracolsep", there is no point in the user entering two of |
| 3472 |
% these commands anyway, so this is not really a restriction. |
| 3473 |
% \begin{macrocode} |
| 3474 |
\def\NC@ecs#1\extracolsep#2#3\extracolsep#4\@@@@@@{\def\@tempa{#2}% |
| 3475 |
\ifx\@tempa\@empty\else\toks\count@={#1\tabskip#2\relax#3}\fi} |
| 3476 |
%</ncols> |
| 3477 |
% \end{macrocode} |
| 3478 |
% \end{macro} |
| 3479 |
% |
| 3480 |
% |
| 3481 |
% \subsection{Support for the \texttt{delarray.sty}} |
| 3482 |
% |
| 3483 |
% The \texttt{delarray.sty} package extends the array syntax by |
| 3484 |
% supporting the notation of delimiters. To this end we extend the |
| 3485 |
% array parsing mechanism to include a hook which can be used by this |
| 3486 |
% (or another) package to do some additional parsing. |
| 3487 |
% |
| 3488 |
% \begin{macro}[int]{\@tabarray} |
| 3489 |
% This macro tests for an optional bracket and then calls up |
| 3490 |
% "\@@@@array" or "\@@@@array[c]" (as default). |
| 3491 |
% \begin{macrocode} |
| 3492 |
%<*package> |
| 3493 |
\def\@tabarray{\@ifnextchar[{\@@@@array}{\@@@@array[c]}} |
| 3494 |
% \end{macrocode} |
| 3495 |
% \end{macro} |
| 3496 |
% \begin{macro}[int]{\@@@@array} |
| 3497 |
% This macro tests could then test an optional delimiter before the |
| 3498 |
% left brace of the main preamble argument. Here in the main package |
| 3499 |
% it simply is let to be "\@array". |
| 3500 |
% \begin{macrocode} |
| 3501 |
\let\@@@@array\@array |
| 3502 |
% \end{macrocode} |
| 3503 |
% \end{macro} |
| 3504 |
% |
| 3505 |
% \begin{macro}[int]{\@arrrayleft} |
| 3506 |
% \begin{macro}[int]{\@arrayright} |
| 3507 |
% We have to declare the hook we put into "\@array" above. |
| 3508 |
% A similar hook \cs{@arrayright} will be inserted into the |
| 3509 |
% "\endarray" to gain control. Both defaults to empty. |
| 3510 |
% \begin{macrocode} |
| 3511 |
\let\@arrayleft\@empty |
| 3512 |
\let\@arrayright\@empty |
| 3513 |
% \end{macrocode} |
| 3514 |
% \end{macro} |
| 3515 |
% \end{macro} |
| 3516 |
% |
| 3517 |
% \subsection{Support for \texttt{\textbackslash firsthline} and |
| 3518 |
% \texttt{\textbackslash lasthline}} |
| 3519 |
% |
| 3520 |
% The Companion~\cite[p.137]{bk:GMS94} suggests two additional |
| 3521 |
% commands to control the alignments in case of tabulars with |
| 3522 |
% horizontal lines. They are now added to this package. |
| 3523 |
% |
| 3524 |
% \begin{macro}[no-user-doc]{\extratabsurround} |
| 3525 |
% The extra space around a table when "\firsthline" or "\lasthline" |
| 3526 |
% are used. |
| 3527 |
% \begin{macrocode} |
| 3528 |
\newlength{\extratabsurround} |
| 3529 |
\setlength{\extratabsurround}{2pt} |
| 3530 |
% \end{macrocode} |
| 3531 |
% \end{macro} |
| 3532 |
% |
| 3533 |
% \begin{macro}[int]{\backup@length} |
| 3534 |
% This register will be used internally by "\firsthline" and |
| 3535 |
% "\lasthline". |
| 3536 |
% \begin{macrocode} |
| 3537 |
\newlength{\backup@length} |
| 3538 |
% \end{macrocode} |
| 3539 |
% \end{macro} |
| 3540 |
% |
| 3541 |
% \begin{macro}[no-user-doc]{\firsthline} |
| 3542 |
% \changes{v2.3h}{1996/05/25}{Complete reimplementation} |
| 3543 |
% This code can probably be improved but for the moment it should |
| 3544 |
% serve. |
| 3545 |
% |
| 3546 |
% We start by producing a single tabular row without any visible |
| 3547 |
% content that will produce the external reference point in case |
| 3548 |
% "[t]" is used. We need to suppress the \cs{tabcolsep} in the |
| 3549 |
% \cs{multicolumn} in case there wasn't any in the real column. |
| 3550 |
% |
| 3551 |
% \changes{v2.5c}{2020/07/20}{Suppress all column space (gh/322)} |
| 3552 |
% \begin{macrocode} |
| 3553 |
\newcommand{\firsthline}{% |
| 3554 |
\multicolumn1{@{}c@{}}{% |
| 3555 |
% \end{macrocode} |
| 3556 |
% Within this row we calculate "\backup@length" to be the height |
| 3557 |
% plus depth of a standard line. In addition we have to add the |
| 3558 |
% width of the "\hline", something that was forgotten in the |
| 3559 |
% original definition. |
| 3560 |
% \begin{macrocode} |
| 3561 |
\global\backup@length\ht\@arstrutbox |
| 3562 |
\global\advance\backup@length\dp\@arstrutbox |
| 3563 |
\global\advance\backup@length\arrayrulewidth |
| 3564 |
% \end{macrocode} |
| 3565 |
% Finally we do want to make the height of this first line be a bit |
| 3566 |
% larger than usual, for this we place the standard array strut |
| 3567 |
% into it but raised by "\extratabsurround" |
| 3568 |
% \begin{macrocode} |
| 3569 |
\raise\extratabsurround\copy\@arstrutbox |
| 3570 |
% \end{macrocode} |
| 3571 |
% And we should also cancel the guard otherwise we end up with two. |
| 3572 |
% \begin{macrocode} |
| 3573 |
\kern-1sp% |
| 3574 |
% \end{macrocode} |
| 3575 |
% Having done all this we end the line and back up by the value of |
| 3576 |
% "\backup@length" and then finally place our "\hline". This should |
| 3577 |
% place the line exactly at the right place but keep the reference |
| 3578 |
% point of the whole tabular at the baseline of the first row. |
| 3579 |
% \begin{macrocode} |
| 3580 |
}\\[-\backup@length]\hline |
| 3581 |
} |
| 3582 |
% \end{macrocode} |
| 3583 |
% \end{macro} |
| 3584 |
% |
| 3585 |
% \begin{macro}[no-user-doc]{\lasthline} |
| 3586 |
% \changes{v2.3h}{1996/05/25}{Complete reimplementation} |
| 3587 |
% For "\lasthline" the situation is even worse and I got it |
| 3588 |
% completely wrong initially. |
| 3589 |
% |
| 3590 |
% The problem in this case is that if the optional argument "[b]" |
| 3591 |
% is used we do want the reference point of the tabular be at the |
| 3592 |
% baseline of the last row but at the same time do want the |
| 3593 |
% depth of this last line increased by "\extratabsurround" without |
| 3594 |
% changing the placement "\hline". |
| 3595 |
% |
| 3596 |
% We start by placing the rule followed by an invisible row. We |
| 3597 |
% need to suppress the \cs{tabcolsep} in the multicol in case there |
| 3598 |
% wasn't any in the real column. |
| 3599 |
% \changes{v2.5c}{2020/07/20}{Suppress all column space (gh/322)} |
| 3600 |
% \begin{macrocode} |
| 3601 |
\newcommand{\lasthline}{\hline\multicolumn1{@{}c@{}}{% |
| 3602 |
% \end{macrocode} |
| 3603 |
% We now calculate "\backup@length" to be the height and depth of |
| 3604 |
% two lines plus the width of the rule. |
| 3605 |
% \begin{macrocode} |
| 3606 |
\global\backup@length2\ht\@arstrutbox |
| 3607 |
\global\advance\backup@length2\dp\@arstrutbox |
| 3608 |
\global\advance\backup@length\arrayrulewidth |
| 3609 |
% \end{macrocode} |
| 3610 |
% This will bring us back to the baseline of the second last row: |
| 3611 |
% \begin{macrocode} |
| 3612 |
}\\[-\backup@length]% |
| 3613 |
% \end{macrocode} |
| 3614 |
% Thus if we now add another invisible row the reference point of |
| 3615 |
% that row will be at the baseline of the last row (and will be the |
| 3616 |
% reference for the whole tabular). Since this row is invisible we |
| 3617 |
% can enlarge its depth by the desired amount. |
| 3618 |
% \begin{macrocode} |
| 3619 |
\multicolumn1{@{}c@{}}{% |
| 3620 |
\lower\extratabsurround\copy\@arstrutbox |
| 3621 |
\kern-1sp% |
| 3622 |
}% |
| 3623 |
} |
| 3624 |
% \end{macrocode} |
| 3625 |
% \end{macro} |
| 3626 |
% |
| 3627 |
% |
| 3628 |
% \subsection{Getting the spacing around rules right} |
| 3629 |
% |
| 3630 |
% Beside a larger functionality \texttt{array.sty} has one |
| 3631 |
% important difference to the standard \texttt{tabular} and |
| 3632 |
% \texttt{array} environments: horizontal and vertical rules make a |
| 3633 |
% table larger or wider, e.g., \verb=\doublerulesep= really denotes |
| 3634 |
% the space between two rules and isn't measured from the middle of |
| 3635 |
% the rules. |
| 3636 |
% |
| 3637 |
% \begin{macro}[int]{\@xhline} |
| 3638 |
% For vertical rules this is implemented by the definitions above, |
| 3639 |
% for horizontal rules we have to take out the backspace. |
| 3640 |
% \changes{v2.3d}{1995/11/19}{fix space between double rules pr/1945} |
| 3641 |
% \begin{macrocode} |
| 3642 |
\CheckCommand*\@xhline{\ifx\reserved@a\hline |
| 3643 |
\vskip\doublerulesep |
| 3644 |
\vskip-\arrayrulewidth |
| 3645 |
\fi |
| 3646 |
\ifnum0=`{\fi}} |
| 3647 |
\renewcommand*\@xhline{\ifx\reserved@a\hline |
| 3648 |
\vskip\doublerulesep |
| 3649 |
\fi |
| 3650 |
\ifnum0=`{\fi}} |
| 3651 |
%</package> |
| 3652 |
% \end{macrocode} |
| 3653 |
% \end{macro} |
| 3654 |
|
| 3655 |
% \subsection{Implementing column types \texttt{w} and \texttt{W}} |
| 3656 |
% |
| 3657 |
% In TugBoat 38/2 an extension was presented that implemented two |
| 3658 |
% additional column types \texttt{w} and \texttt{W}. These have now |
| 3659 |
% been added to the package itself. |
| 3660 |
% |
| 3661 |
% |
| 3662 |
% \begin{macro}[int]{\ar@cellbox} |
| 3663 |
% For \texttt{w} and \texttt{W} column types we need a box to |
| 3664 |
% temporarily hold the cell content. |
| 3665 |
% \changes{v2.4f}{2017/11/07}{Macro added} |
| 3666 |
% \begin{macrocode} |
| 3667 |
\newsavebox\ar@cellbox |
| 3668 |
% \end{macrocode} |
| 3669 |
% \end{macro} |
| 3670 |
% |
| 3671 |
% |
| 3672 |
% \begin{macro}[no-user-doc]{\newcolumntype w} |
| 3673 |
% The \texttt{w} column type has two arguments: the first holds the |
| 3674 |
% alignment which is either "l", "c", or "r" and the second is the |
| 3675 |
% nominal width of the column. |
| 3676 |
% \changes{v2.4f}{2017/11/07}{Column type added} |
| 3677 |
% \changes{v2.5a}{2020/04/06}{Use \cs{d@llarbegin} and \cs{d@llarend} so |
| 3678 |
% that cell is typeset in math mode inside \texttt{array} (gh/297)} |
| 3679 |
% \begin{macrocode} |
| 3680 |
\newcolumntype{w}[2]{% |
| 3681 |
% \end{macrocode} |
| 3682 |
% Before the cell content we start an "lrbox"-environment to |
| 3683 |
% collect the cell material into the previously allocated box |
| 3684 |
% "\ar@cellbox". We add \cs{d@llarbegin} (and later \cs{d@llarend}) |
| 3685 |
% so that the content is typeset in math mode if we are in an |
| 3686 |
% \texttt{array} environment. |
| 3687 |
% \begin{macrocode} |
| 3688 |
>{\begin{lrbox}\ar@cellbox\d@llarbegin}% |
| 3689 |
% \end{macrocode} |
| 3690 |
% Then comes a specifier for the cell content. We use "c", but |
| 3691 |
% that doesn't matter as in the end we will always put a box of a |
| 3692 |
% specific width ("#2") into the cells of that column, so "l" or |
| 3693 |
% "r" would give the same result. There is only a difference if |
| 3694 |
% there are also very wide "\multicolumn" rows overwriting the |
| 3695 |
% setting in which case "c" seems to be slightly better. |
| 3696 |
% \begin{macrocode} |
| 3697 |
c% |
| 3698 |
% \end{macrocode} |
| 3699 |
% At the end of the cell we end the "lrbox" environment so that all |
| 3700 |
% of the cell content is now in box "\ar@cellbox". As a final step we |
| 3701 |
% put that box into a "\makebox" using the optional arguments of |
| 3702 |
% that command to achieve the correct width and the desired |
| 3703 |
% alignment within that width. We unbox the collected material so |
| 3704 |
% that any stretchable glue inside can interact with the alignment. |
| 3705 |
% \changes{v2.4m}{2020/02/10}{Unbox collected material so that |
| 3706 |
% stretchable glue inside can act (gh/270)} |
| 3707 |
% \begin{macrocode} |
| 3708 |
<{\d@llarend \end{lrbox}% |
| 3709 |
\makebox[#2][#1]{\unhbox\ar@cellbox}}} |
| 3710 |
% \end{macrocode} |
| 3711 |
% \end{macro} |
| 3712 |
|
| 3713 |
% |
| 3714 |
% |
| 3715 |
% \begin{macro}[no-user-doc]{\newcolumntype W} |
| 3716 |
% The \texttt{W} is similar but in this case we want a warning if |
| 3717 |
% the cell content is too wide. |
| 3718 |
% \changes{v2.4f}{2017/11/07}{Column type added} |
| 3719 |
% \changes{v2.5a}{2020/04/06}{Use \cs{d@llarbegin} and \cs{d@llarend} so |
| 3720 |
% that cell is typeset in math mode inside \texttt{array} (gh/297)} |
| 3721 |
% \begin{macrocode} |
| 3722 |
\newcolumntype{W}[2] |
| 3723 |
{>{\begin{lrbox}\ar@cellbox\d@llarbegin}% |
| 3724 |
c% |
| 3725 |
<{\d@llarend\end{lrbox}% |
| 3726 |
\let\hss\hfil |
| 3727 |
\makebox[#2][#1]{\unhbox\ar@cellbox}}} |
| 3728 |
% \end{macrocode} |
| 3729 |
% This is a bit sneaky, as it temporarily disables "\hss", but |
| 3730 |
% given that we know what goes into that box it should be |
| 3731 |
% sufficient. |
| 3732 |
% \end{macro} |
| 3733 |
% |
| 3734 |
% |
| 3735 |
% \subsection{Handling \cs{cline}} |
| 3736 |
% |
| 3737 |
% In the past \pkg{array} did not have to concern itself with |
| 3738 |
% \cs{cline} but simply used the definition already provided in the |
| 3739 |
% kernel. However, for tagged PDF output this definition is |
| 3740 |
% insufficient, because it causes incorrect row counting and the rules |
| 3741 |
% it generates would need to be marked as artifacts. |
| 3742 |
% We therefore update it here. |
| 3743 |
% |
| 3744 |
% |
| 3745 |
% \begin{macro}[int]{\@cline} |
| 3746 |
% Tagging support for \cs{cline} |
| 3747 |
% \changes{v2.6e}{2024/07/13}{Support for tagging \cs{cline} (tagging/134)} |
| 3748 |
% \begin{macrocode} |
| 3749 |
\ExplSyntaxOn |
| 3750 |
\def\@cline#1-#2\@nil{ |
| 3751 |
\omit |
| 3752 |
\@multicnt#1 |
| 3753 |
\advance\@multispan\m@ne |
| 3754 |
\ifnum\@multicnt=\@ne\@firstofone{&\omit}\fi |
| 3755 |
\@multicnt#2 |
| 3756 |
\advance\@multicnt-#1 |
| 3757 |
\advance\@multispan\@ne |
| 3758 |
% \end{macrocode} |
| 3759 |
% The rule needs artifact tagging in tagged PDF. |
| 3760 |
% \begin{macrocode} |
| 3761 |
\UseTaggingSocket{tbl/leaders/begin} |
| 3762 |
\leaders\hrule\@height\arrayrulewidth\hfill |
| 3763 |
\UseTaggingSocket{tbl/leaders/end} |
| 3764 |
% \end{macrocode} |
| 3765 |
% To the row counting the above appears like an extra row, so we |
| 3766 |
% have to correct the count. |
| 3767 |
% \begin{macrocode} |
| 3768 |
\tbl_gdecr_row_count: |
| 3769 |
\cr |
| 3770 |
\noalign{\vskip-\arrayrulewidth} |
| 3771 |
} |
| 3772 |
\ExplSyntaxOff |
| 3773 |
% \end{macrocode} |
| 3774 |
% \end{macro} |
| 3775 |
% |
| 3776 |
% |
| 3777 |
% \begin{macrocode} |
| 3778 |
\ExplSyntaxOff |
| 3779 |
% \end{macrocode} |
| 3780 |
% |
| 3781 |
% |
| 3782 |
% \PrintIndex |
| 3783 |
% \PrintChanges |
| 3784 |
% |
| 3785 |
% \Finale |
| 3786 |
% |
| 3787 |
\endinput |