| 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 |
| 24 |
%% File: longtable.dtx Copyright (C) 1990-2020 David Carlisle |
| 25 |
% |
| 26 |
%<*dtx> |
| 27 |
\ProvidesFile{longtable.dtx} |
| 28 |
%</dtx> |
| 29 |
%<package>\NeedsTeXFormat{LaTeX2e}[1995/06/01] |
| 30 |
%<package> |
| 31 |
% Try the 2020 version for any rollback before that date: |
| 32 |
%<package>\DeclareRelease{}{1994-06-01}{longtable-2020-01-07.sty} |
| 33 |
%<package> |
| 34 |
%<package>\DeclareRelease{v4.13}{2020-01-02}{longtable-2020-01-07.sty} |
| 35 |
%<package>\DeclareCurrentRelease{}{2020-02-07} |
| 36 |
%<package> |
| 37 |
%<package>\ProvidesPackage{longtable} |
| 38 |
%<driver> \ProvidesFile{longtable.drv} |
| 39 |
% \fi |
| 40 |
% \ProvidesFile{longtable.dtx} |
| 41 |
[2025-10-13 v4.24 Multi-page Table package (DPC)] |
| 42 |
% |
| 43 |
% \iffalse |
| 44 |
%<*driver> |
| 45 |
\documentclass{ltxdoc} |
| 46 |
\usepackage{longtable} |
| 47 |
\begin{document} |
| 48 |
\DocInput{longtable.dtx} |
| 49 |
\end{document} |
| 50 |
%</driver> |
| 51 |
% \fi |
| 52 |
% |
| 53 |
% \GetFileInfo{longtable.dtx} |
| 54 |
% \title{The \textsf{longtable} package\thanks{This file |
| 55 |
% has version number \fileversion, last |
| 56 |
% revised \filedate.}} |
| 57 |
% \author{David Carlisle\thanks{The new algorithm for aligning `chunks' |
| 58 |
% of a table used in version 4 of this package was devised, coded |
| 59 |
% and documented by David Kastrup.}} |
| 60 |
% \date{\filedate} |
| 61 |
% |
| 62 |
% \let\package\textsf |
| 63 |
% \let\env\textsf |
| 64 |
% \providecommand\finalclearpage{\clearpage} |
| 65 |
% |
| 66 |
% \MaintainedByLaTeXTeam{tools} |
| 67 |
% \maketitle |
| 68 |
% |
| 69 |
% \begin{abstract} |
| 70 |
% This package defines the \env{longtable} environment, a multi-page |
| 71 |
% version of \env{tabular}. |
| 72 |
% \end{abstract} |
| 73 |
% |
| 74 |
% \DeleteShortVerb{\|} |
| 75 |
% \MakeShortVerb{\"} |
| 76 |
% |
| 77 |
% \changes{v0.00}{1989/11/06} |
| 78 |
% {`Version 0' distributed as longtab.sty |
| 79 |
% always used just one chunk for the whole table} |
| 80 |
% |
| 81 |
% \changes{v1.00}{1990/12/20} |
| 82 |
% {Initial version} |
| 83 |
% |
| 84 |
% \changes{v2.00}{1991/06/17} |
| 85 |
% {Support NFSS and array.sty} |
| 86 |
% |
| 87 |
% \changes{v3.00}{1992/03/16} |
| 88 |
% {New implementation. tables may now start anywhere on the page.} |
| 89 |
% |
| 90 |
% \changes{v3.01}{1992/04/06} |
| 91 |
% {(Michel Goossens) If a chunk ends on a line in which the first |
| 92 |
% entry is empty, weird errors occur. Added special begin and end |
| 93 |
% groups, (\cs{ifnum}0 ) stuff as explained in Appendix D.} |
| 94 |
% |
| 95 |
% \changes{v3.02}{1992/04/09} |
| 96 |
% {(Michel Goossens) Longtable fails if the table counter is reset |
| 97 |
% during a document. Now use an internal counter, but still |
| 98 |
% increment table so \cs{caption} and \cs{label} work out right.} |
| 99 |
% |
| 100 |
% \changes{v3.03}{1992/06/25} |
| 101 |
% {Add \cs{@ifundefined\{reset@font\}} so that the documentation may |
| 102 |
% be processed with old versions of \LaTeX.} |
| 103 |
% \changes{v3.03}{1992/06/25} |
| 104 |
% {Modify the treatment of \cs{d@llar} to match the new versions of |
| 105 |
% Mittelbach's array.sty (array.sty v2.0h)} |
| 106 |
% |
| 107 |
% \changes{v3.04}{1992/11/12} |
| 108 |
% {(Jean-Pierre Drucbert) Longtable failed when used with |
| 109 |
% \cs{includeonly}.} |
| 110 |
% \changes{v3.04}{1992/11/12} |
| 111 |
% {Fix bug which stopped \cs{kill} working correctly in headings.} |
| 112 |
% \changes{v3.04}{1992/11/12} |
| 113 |
% {(Graham Gough) Made \cs{setlongtables} issue a warning message.} |
| 114 |
% \changes{v3.04}{1992/11/12} |
| 115 |
% {(Sebastian Rahtz) longtable ran out of memory on really long |
| 116 |
% tables. Another bug introduced in V3.} |
| 117 |
% |
| 118 |
% \changes{v3.05}{1992/11/20} |
| 119 |
% {(Juergen Peus) Table was hard coded into the captions, Now the |
| 120 |
% captions use \cs{fnum@table}, so \cs{tablename} will be used.} |
| 121 |
% |
| 122 |
% \changes{v3.06}{1993/01/21} |
| 123 |
% {(Ingo Hoffmann) longtable fails with letter style. |
| 124 |
% The table counter is not defined, and the .aux file is not used in |
| 125 |
% the same way. This version will use a .lta file for letter style.} |
| 126 |
% |
| 127 |
% \changes{v3.07}{1993/06/09} |
| 128 |
% {Allow the \LaTeX\ syntax \cs{setcounter}\{LTchunksize\}\{10\}} |
| 129 |
% |
| 130 |
% \changes{v3.08}{1993/06/09} |
| 131 |
% {Update for \LaTeXe} |
| 132 |
% |
| 133 |
% \changes{v3.09}{1994/03/15} |
| 134 |
% {New ltxdoc style} |
| 135 |
% |
| 136 |
% \changes{v3.11}{1994/05/22} |
| 137 |
% {Option handling added, new style errors and warnings} |
| 138 |
% |
| 139 |
% \changes{v3.12}{1994/06/30} |
| 140 |
% {Remove special letter class handling from v3.06, not needed for |
| 141 |
% new letter class} |
| 142 |
% |
| 143 |
% \changes{v4.00}{1996/04/08} |
| 144 |
% {(DK) New algorithm to align chunks devised and coded by David |
| 145 |
% Kastrup} |
| 146 |
% |
| 147 |
% \changes{v4.02}{1996/04/16} |
| 148 |
% {(DPC/DK) documentation improvements} |
| 149 |
% |
| 150 |
% \changes{v4.06}{1997/06/28} |
| 151 |
% {(DK) new email address} |
| 152 |
% |
| 153 |
% |
| 154 |
% |
| 155 |
% \makeatletter |
| 156 |
% \def\@oddfoot{\normalfont\rmfamily\dotfill Page \thepage\dotfill} |
| 157 |
% \def\@oddhead{\dotfill{\normalfont\ttfamily longtable.sty}\dotfill} |
| 158 |
% \def\ps@titlepage{\let\@oddhead\@empty} |
| 159 |
% \makeatother |
| 160 |
% |
| 161 |
% |
| 162 |
% \setlength\LTleft\parindent |
| 163 |
% \setlength\LTright\fill |
| 164 |
% \setcounter{LTchunksize}{10} |
| 165 |
% |
| 166 |
% \def\v{\char`} |
| 167 |
% |
| 168 |
% ^^A \vbox to 100pt makes the page breaks the same on the first run. |
| 169 |
% \changes{v3.08}{1993/06/09} |
| 170 |
% {No need to use \cs{vbox} with \LaTeXe\ minipage} |
| 171 |
% \noindent\begin{minipage}[t][130pt]{\textwidth} |
| 172 |
% \listoftables |
| 173 |
% \end{minipage} |
| 174 |
% |
| 175 |
% \section{Introduction} |
| 176 |
% |
| 177 |
% The \package{longtable} package defines a new environment, |
| 178 |
% \DescribeEnv{longtable} |
| 179 |
% \env{longtable}, which has most of the features of the \env{tabular} |
| 180 |
% environment, but produces tables which may be broken by \TeX's |
| 181 |
% standard page-breaking algorithm. It also shares some features with |
| 182 |
% the \env{table} environment. In particular it uses by default the same counter, |
| 183 |
% \texttt{table}, and has a similar "\caption" command. Also, the |
| 184 |
% standard "\listoftables" command lists tables produced by either the |
| 185 |
% \env{table} or \env{longtable} environments. |
| 186 |
% |
| 187 |
% The following example uses most of the features of the \env{longtable} |
| 188 |
% environment. An edited listing of the input for this example appears |
| 189 |
% in Section~\ref{listing}. |
| 190 |
% |
| 191 |
% \textbf{Note:} Various parts of the following table will |
| 192 |
% \textbf{not} line up correctly until this document has been run |
| 193 |
% through \LaTeX\ several times. This is a characteristic feature of |
| 194 |
% this package, as described below. |
| 195 |
% |
| 196 |
% \begin{longtable}{@{*}r||p{1in}@{*}} |
| 197 |
% KILLED & LINE!!!! \kill |
| 198 |
% \caption |
| 199 |
% [An optional table caption (used in the list of tables)] |
| 200 |
% {A long table\label{long}}\\ |
| 201 |
% \hline\hline |
| 202 |
% \multicolumn{2}{@{*}c@{*}}% |
| 203 |
% {This part appears at the top of the table}\\ |
| 204 |
% \textsc{First}&\textsc{Second}\\ |
| 205 |
% \hline\hline |
| 206 |
% \endfirsthead |
| 207 |
% \caption[]{(continued)}\\ |
| 208 |
% \hline\hline |
| 209 |
% \multicolumn{2}{@{*}c@{*}}% |
| 210 |
% {This part appears at the top of every other page}\\ |
| 211 |
% \textbf{First}&\textbf{Second}\\ |
| 212 |
% \hline\hline |
| 213 |
% \endhead |
| 214 |
% \hline |
| 215 |
% This goes at the&bottom.\\ |
| 216 |
% \hline |
| 217 |
% \endfoot |
| 218 |
% \hline |
| 219 |
% These lines will&appear\\ |
| 220 |
% in place of the & usual foot\\ |
| 221 |
% at the end& of the table\\ |
| 222 |
% \hline |
| 223 |
% \endlastfoot |
| 224 |
% \env{longtable} columns are specified& in the \\ |
| 225 |
% same way as in the \env{tabular}& environment.\\ |
| 226 |
% "@{*}r||p{1in}@{*}"& in this case.\\ |
| 227 |
% Each row ends with a& "\\" command.\\ |
| 228 |
% The "\\" command has an& optional\\ |
| 229 |
% argument, just as in& the\\ |
| 230 |
% \env{tabular}&environment.\\[10pt] |
| 231 |
% See the effect of "\\[10pt]"&?\\ |
| 232 |
% Lots of lines& like this.\\ |
| 233 |
% Lots of lines& like this.\\ |
| 234 |
% Lots of lines& like this.\\ |
| 235 |
% Lots of lines& like this.\\ |
| 236 |
% Also "\hline" may be used,& as in \env{tabular}.\\ |
| 237 |
% \hline |
| 238 |
% That was a "\hline"&.\\ |
| 239 |
% \hline\hline |
| 240 |
% That was "\hline\hline"&.\\ |
| 241 |
% \multicolumn{2}{||c||}% |
| 242 |
% {This is a \ttfamily\v\\multicolumn\v{2\v}\v{||c||\v}}\\ |
| 243 |
% If a page break occurs at a "\hline" then& a line is drawn\\ |
| 244 |
% at the bottom of one page and at the& top of the next.\\ |
| 245 |
% \hline |
| 246 |
% The "[t] [b] [c]" argument of \env{tabular}& can not be used.\\ |
| 247 |
% The optional argument may be one of& "[l] [r] [c]"\\ |
| 248 |
% to specify whether the table should be& adjusted\\ |
| 249 |
% to the left, right& or centrally.\\ |
| 250 |
% \hline\hline |
| 251 |
% Lots of lines& like this.\\ |
| 252 |
% Lots of lines& like this.\\ |
| 253 |
% Lots of lines& like this.\\ |
| 254 |
% Lots of lines& like this.\\ |
| 255 |
% Lots of lines& like this.\\ |
| 256 |
% Lots of lines& like this.\\ |
| 257 |
% Lots of lines& like this.\\ |
| 258 |
% Lots of lines& like this.\\ |
| 259 |
% Lots of lines& like this.\\ |
| 260 |
% Lots of lines& like this.\\ |
| 261 |
% Lots of lines& like this.\\ |
| 262 |
% Lots of lines& like this.\\ |
| 263 |
% Lots of lines& like this.\\ |
| 264 |
% Lots of lines& like this.\\ |
| 265 |
% Lots of lines& like this.\\ |
| 266 |
% Lots of lines& like this.\\ |
| 267 |
% Lots of lines& like this.\\ |
| 268 |
% Lots of lines& like this.\\ |
| 269 |
% Lots of lines& like this.\\ |
| 270 |
% Lots of lines& like this.\\ |
| 271 |
% Some lines may take up a lot of space, like this: & |
| 272 |
% \raggedleft This last column is a ``p'' column so this |
| 273 |
% ``row'' of the table can take up several lines. Note however that |
| 274 |
% \TeX\ will never break a page within such a row. Page breaks only |
| 275 |
% occur between rows of the table or at "\hline" commands. |
| 276 |
% \tabularnewline |
| 277 |
% Lots of lines& like this.\\ |
| 278 |
% Lots of lines& like this.\\ |
| 279 |
% Lots of lines& like this.\\ |
| 280 |
% Lots of lines& like this.\\ |
| 281 |
% Lots of lines& like this.\\ |
| 282 |
% Lots of lines& like this.\\ |
| 283 |
% Lots of lines& like this.\\ |
| 284 |
% \hline |
| 285 |
% Lots\footnote{This is a footnote.} of lines& like this.\\ |
| 286 |
% Lots of lines& like this\footnote{\env{longtable} takes special |
| 287 |
% precautions, so that footnotes may also be used in `p' columns.}\\ |
| 288 |
% \hline |
| 289 |
% Lots of lines& like this.\\ |
| 290 |
% Lots of lines& like this. |
| 291 |
% \end{longtable} |
| 292 |
% |
| 293 |
% \section{Chunk Size} |
| 294 |
% |
| 295 |
% \DescribeMacro{LTchunksize} |
| 296 |
% In order to \TeX\ multi-page tables, it is necessary to break up the |
| 297 |
% table into smaller chunks, so that \TeX\ does not have to keep |
| 298 |
% everything in memory at one time. By default \env{longtable} uses 20 |
| 299 |
% rows per chunk, but this can be set by the user, with e.g., |
| 300 |
% "\setcounter{LTchunksize}{10}".\footnote |
| 301 |
% {You can also use the plain \TeX\ syntax |
| 302 |
% {\ttfamily\v\\LTchunksize=10.}} |
| 303 |
% These chunks do not affect page breaking, |
| 304 |
% thus if you are using a \TeX\ with a lot of memory, you can set |
| 305 |
% "LTchunksize" to be several pages of the table. \TeX\ will run |
| 306 |
% faster with a large "LTchunksize". However, if necessary, |
| 307 |
% \env{longtable} can work with "LTchunksize" set to 1, in which case |
| 308 |
% the memory taken up is negligible. |
| 309 |
% Note that if you use the commands for setting the table head or foot |
| 310 |
% (see below), the "LTchunksize" must be at least as large as the |
| 311 |
% number of rows in each of the head or foot sections. |
| 312 |
% |
| 313 |
% This document specifies "\setcounter{LTchunksize}{200}". If you look |
| 314 |
% at the previous table, after the \emph{first} run of \LaTeX\ you will |
| 315 |
% see that various parts of the table do not line up. |
| 316 |
% \LaTeX\ will also have printed a warning that the column |
| 317 |
% widths had changed. \env{longtable} writes information onto the |
| 318 |
% ".aux" file, so that it can line up the different chunks. |
| 319 |
% Prior to version~4 of this package, this information was not used |
| 320 |
% unless a "\setlongtables" command was issued, however, now the |
| 321 |
% information is always used, via a new algorithm,\footnote{Due to |
| 322 |
% David Kastrup.} and so "\setlongtables" is no longer needed. It is |
| 323 |
% defined (but does nothing) for the benefit of old documents that |
| 324 |
% use it. |
| 325 |
% |
| 326 |
% \begin{table} |
| 327 |
% \centering |
| 328 |
% \begin{tabular}{||l|l|l||} |
| 329 |
% \hline\hline |
| 330 |
% A&\env{tabular}& environment\\ |
| 331 |
% \hline |
| 332 |
% within&a floating&\env{table}\\ |
| 333 |
% \hline\hline |
| 334 |
% \end{tabular} |
| 335 |
% \caption{A floating table} |
| 336 |
% \end{table} |
| 337 |
% |
| 338 |
% \section{Counter and Caption Types} |
| 339 |
% |
| 340 |
% As mentioned in the introduction \env{longtable} uses and updates by default |
| 341 |
% the \texttt{table} counter, the "\caption" command creates a table caption |
| 342 |
% which is added to the list of tables. |
| 343 |
% Packages like \pkg{ltcaption} added more flexibility here by adding the |
| 344 |
% command "\LTcaptype" which allowed to change the type, e.g. to a listing. |
| 345 |
% Starting with version 4.21 \pkg{longtable} supports this command directly. |
| 346 |
% \DescribeMacro{\LTcaptype}% |
| 347 |
% By redefining this command it is possible to change the counter and caption type. |
| 348 |
% After "\renewcommand\LTcaptype{"\meta{counter}"}" \env{longtable} will update |
| 349 |
% the counter \meta{counter}, use "\fnum@"\meta{counter} in the caption (which |
| 350 |
% typically will make use of "\"\meta{counter}"name" and "\the"\meta{counter}), and |
| 351 |
% write content line entries into the file with the extension stored in the |
| 352 |
% command "\ext@"\meta{counter}. When \pkg{hyperref} is loaded the name of |
| 353 |
% the anchor will use \meta{counter} too. Packages or documents that change |
| 354 |
% "\LTcaptype" to some nonstandard value must ensure that the counter |
| 355 |
% \meta{counter} and the commands "\fnum@"\meta{counter} |
| 356 |
% and "\ext@"\meta{counter} exist and do not error. |
| 357 |
% If "\LTcaptype" is empty no counter is advanced and "\"\meta{counter}"name" in |
| 358 |
% the caption is suppressed. |
| 359 |
% |
| 360 |
% |
| 361 |
% \section{Captions and Headings} |
| 362 |
% |
| 363 |
% At the start of the table one may specify lines which are to appear at |
| 364 |
% the top of every page (under the headline, but before the other lines |
| 365 |
% of the table). |
| 366 |
% \DescribeMacro{\endhead} |
| 367 |
% The lines are entered as normal, but the last "\\" command is |
| 368 |
% replaced by a "\endhead" command. |
| 369 |
% \DescribeMacro{\endfirsthead} |
| 370 |
% If the first page should have a different heading, then this should be |
| 371 |
% entered in the same way, and terminated with the "\endfirsthead" |
| 372 |
% command. The "LTchunksize" should be at least as large as the |
| 373 |
% number of rows in the heading. |
| 374 |
% \DescribeMacro{\endfoot} |
| 375 |
% There are also "\endfoot" and "\endlastfoot" |
| 376 |
%\DescribeMacro{\endlastfoot} |
| 377 |
% commands which are used in the same way (at the \emph{start} of the |
| 378 |
% table) to specify rows (or an "\hline") to appear at the bottom of |
| 379 |
% each page. In certain situations, you may want to place lines which |
| 380 |
% logically belong in the table body at the end of the \env{firsthead}, |
| 381 |
% or the beginning of the \env{lastfoot}. This helps to control which |
| 382 |
% lines appear on the first and last page of the table. |
| 383 |
% |
| 384 |
% \DescribeMacro{\caption}% |
| 385 |
% The "\caption{...}" command is essentially equivalent to\\ |
| 386 |
% "\multicolumn{n}{c}{\parbox{\LTcapwidth}{...}}"\\ |
| 387 |
% where \texttt{n} is the number of columns of the table. You may set |
| 388 |
% the width of the caption with a command such as |
| 389 |
% "\setlength{\LTcapwidth}{2in}" |
| 390 |
% in the preamble of your document. The default is 4in. "\caption" also |
| 391 |
% writes the information to produce an entry in the list of tables. As |
| 392 |
% with the "\caption" command in the \env{figure} and \env{table} |
| 393 |
% environments, an optional argument specifies the text to appear in the |
| 394 |
% list of tables if this is different from the text to appear in the |
| 395 |
% caption. Thus the caption for table \ref{long} was specified as |
| 396 |
% {\ttfamily |
| 397 |
% "\caption"[An optional table caption |
| 398 |
% (used in the list of tables)]\v{A long |
| 399 |
% table"\label{long}"\v}}. |
| 400 |
% |
| 401 |
% You may wish the caption on later pages to be different to that on the |
| 402 |
% first page. In this case put the "\caption" command in the first |
| 403 |
% heading, and put a subsidiary caption in a "\caption[]" command in |
| 404 |
% the main heading. If the optional argument to "\caption" is empty, |
| 405 |
% no entry is made in the list of tables. Alternatively, if you do not |
| 406 |
% want the table number to be printed each time, use the "\caption*" |
| 407 |
% command. |
| 408 |
% |
| 409 |
% The captions are set based on the code for the \package{article} |
| 410 |
% class. |
| 411 |
% If you have redefined the standard "\@makecaption" command to produce |
| 412 |
% a different format for the captions, you may |
| 413 |
% need to make similar changes to the \package{longtable} version, |
| 414 |
% "\LT@makecaption". See the code section for more details. |
| 415 |
% |
| 416 |
% A more convenient method of customising captions is given by the |
| 417 |
% \package{caption(2)} package, which provides commands for customising |
| 418 |
% captions, and arranges that the captions in standard environments, and |
| 419 |
% many environments provided by packages (including \package{longtable}) |
| 420 |
% are modified in a compatible manner. |
| 421 |
% |
| 422 |
% You may use the "\label" command so that you can cross reference |
| 423 |
% \env{longtable}s with "\ref". Note, however, that the "\label" command |
| 424 |
% should not be used in a heading that may appear more than once. Place |
| 425 |
% it either in the \env{firsthead}, or in the body of the table. It |
| 426 |
% should not be the \emph{first} command in any entry. |
| 427 |
% |
| 428 |
% \section{Multicolumn entries} |
| 429 |
% |
| 430 |
% The "\multicolumn" command may be used in \env{longtable} in exactly |
| 431 |
% the same way as for \env{tabular}. So you may want to skip this |
| 432 |
% section, which is rather technical, however coping with "\multicolumn" |
| 433 |
% is one of the main problems for an environment such as |
| 434 |
% \env{longtable}. The main effect that a user will see is that |
| 435 |
% certain combinations of "\multicolumn" entries will result in a |
| 436 |
% document needing more runs of \LaTeX\ before the various `chunks' of |
| 437 |
% a table align. |
| 438 |
% |
| 439 |
% The examples in this section are set with "LTchunksize" set to the |
| 440 |
% minimum value of one, to demonstrate the effects when "\multicolumn" |
| 441 |
% entries occur in different chunks. |
| 442 |
% |
| 443 |
% \begin{table}[!htp] |
| 444 |
% \begin{center} |
| 445 |
% \LTchunksize=1 |
| 446 |
% \makeatletter |
| 447 |
% |
| 448 |
% \global\let\LT@save@row\relax |
| 449 |
% \let\LT@warn\@gobble |
| 450 |
% \let\LT@final@warn\relax |
| 451 |
% |
| 452 |
% \newcommand\ltexample[1]{ |
| 453 |
% \stepcounter{LT@tables} |
| 454 |
% \expandafter\let\csname LT@\romannumeral\c@LT@tables\endcsname |
| 455 |
% \LT@save@row |
| 456 |
% \addtocounter{LT@tables}{-1} |
| 457 |
% \begin{longtable}{|c|c|c|} |
| 458 |
% \caption{A difficult {\cs{multicolumn}} combination: |
| 459 |
% pass #1\label{pass#1}}\\ |
| 460 |
% \hline |
| 461 |
% 1&2&3\\ |
| 462 |
% \multicolumn{3}{|c|}{wide multicolumn spanning 1--3}\\ |
| 463 |
% \multicolumn{2}{|c|}{multicolumn 1--2}&3\\ |
| 464 |
% wide 1&2&3\\ |
| 465 |
% \hline |
| 466 |
% \end{longtable} |
| 467 |
% } |
| 468 |
% |
| 469 |
% \ltexample{1} |
| 470 |
% |
| 471 |
% \ltexample{2} |
| 472 |
% |
| 473 |
% \ltexample{3} |
| 474 |
% |
| 475 |
% \ltexample{4} |
| 476 |
% |
| 477 |
% \end{center} |
| 478 |
% \end{table} |
| 479 |
% |
| 480 |
% Consider Table~\ref{pass1}. |
| 481 |
% In the second chunk, \env{longtable} sees the wide |
| 482 |
% multicolumn entry. At this point it thinks that the first two |
| 483 |
% columns are very narrow. All |
| 484 |
% the width of the multicolumn entry is assumed to be in the |
| 485 |
% third column. (This is a `feature' of \TeX's primitive "\halign" |
| 486 |
% command.) \env{longtable} then passes the information that there |
| 487 |
% is a wide third column to the later chunks, with the result that the |
| 488 |
% first pass over the table is too wide. |
| 489 |
% |
| 490 |
% If the `saved row' from this first pass was re-inserted into the |
| 491 |
% table on the next pass, the table would line up in two passes, but |
| 492 |
% would be much two wide. |
| 493 |
% |
| 494 |
% \DescribeMacro{\kill}% |
| 495 |
% The solution to this problem used in Versions 1~and~2, was to use a |
| 496 |
% "\kill" line. If a line is "\kill"ed, by using "\kill" rather than |
| 497 |
% "\\" at the end of the line, it is used in calculating |
| 498 |
% column widths, but removed from the final table. Thus entering |
| 499 |
% "\kill"ed copies of the last two rows before the wide multicolumn |
| 500 |
% entry would mean that "\halign" `saw' the wide entries in the first |
| 501 |
% two columns, and so would not widen the third column by so much to |
| 502 |
% make room for the multicolumn entry. |
| 503 |
% |
| 504 |
% In Version~3, a new solution was introduced. If the saved row in |
| 505 |
% the ".aux" file was not being used, \env{longtable} used a special |
| 506 |
% `draft' form of "\multicolumn", this modified the definition, so the |
| 507 |
% spanning entry was never considered to be wider than the columns it |
| 508 |
% spanned. So after the first pass, the ".aux" file stored the |
| 509 |
% widest normal entry for each column, no column was widened due to |
| 510 |
% "\span"ned columns. By default \env{longtable} ignored the ".aux" |
| 511 |
% file, and so each run of \LaTeX\ was considered a first pass. Once the |
| 512 |
% "\setlongtables" declaration was given, the saved row in the ".aux" |
| 513 |
% file, and the proper definition of "\multicolumn" were used. If any |
| 514 |
% "\multicolumn" entry caused one of the columns to be widened, this |
| 515 |
% information could not be passed back to earlier chunks, and so the |
| 516 |
% table would not correctly line up until the third pass. This algorithm |
| 517 |
% always converged in three passes as described above, but in examples |
| 518 |
% such as the ones in Tables \ref{pass1}--\ref{pass4}, the final |
| 519 |
% widths were not optimal as the width of column~2, which is |
| 520 |
% determined by a "\multicolumn" entry, was not known when the final |
| 521 |
% width for column~3 was fixed, due to the fact that \emph{both} |
| 522 |
% "\multicolumn" commands were switched from `draft' mode to `normal' |
| 523 |
% mode at the same time. |
| 524 |
% |
| 525 |
% Version~4 alleviates the problem considerably. |
| 526 |
% The first pass of the table will |
| 527 |
% indeed have the third column much too wide. However, on the next pass |
| 528 |
% \env{longtable} will notice the error and reduce the column width |
| 529 |
% accordingly. If this has to propagate to chunks before the |
| 530 |
% "\multicolumn" one, an additional pass will, of course, be |
| 531 |
% needed. It is possible to construct tables where this rippling up of |
| 532 |
% the correct widths takes several passes to `converge' and produce a |
| 533 |
% table with all chunks aligned. However in |
| 534 |
% order to need many passes one needs to construct a table with |
| 535 |
% many overlapping "\multicolumn" entries, all being wider than the |
| 536 |
% natural widths of the columns they span, and all occurring in |
| 537 |
% different chunks. In the typical case the algorithm will converge |
| 538 |
% after three or four passes, and the benefits of not needing to edit |
| 539 |
% the document before the final run to add "\setlongtables", and the |
| 540 |
% better choice of final column widths in the case of multiple |
| 541 |
% "\multicolumn" entries will hopefully more than pay for the extra |
| 542 |
% passes that may possibly be needed. |
| 543 |
% |
| 544 |
% So Table~\ref{pass1} converges after 4~passes, as seen in |
| 545 |
% Table~\ref{pass4}. |
| 546 |
% |
| 547 |
% You can still speed the convergence by introducing judicious "\kill" |
| 548 |
% lines, if you happen to have constellations like the above. |
| 549 |
% |
| 550 |
% If you object even to \LaTeX-ing a file twice, you should |
| 551 |
% make the first line of |
| 552 |
% every \env{longtable} a "\kill" line that contains the widest entry |
| 553 |
% to be used in each column. All chunks will then line up on the first |
| 554 |
% pass. |
| 555 |
% |
| 556 |
% \section{Adjustment} |
| 557 |
% |
| 558 |
% The optional argument of \env{longtable} controls the |
| 559 |
% horizontal alignment of the table. The possible options are "[c]", |
| 560 |
% "[r]" and "[l]", for centring, |
| 561 |
% right and left adjustment, respectively. |
| 562 |
% \DescribeMacro{\LTleft} |
| 563 |
% Normally centring is the default, but this document specifies |
| 564 |
% \DescribeMacro{\LTright} |
| 565 |
%\begin{verbatim} |
| 566 |
% \setlength\LTleft\parindent |
| 567 |
% \setlength\LTright\fill |
| 568 |
%\end{verbatim} |
| 569 |
% in the preamble, |
| 570 |
% which means that the tables are set flush left, but |
| 571 |
% indented by the usual paragraph indentation. Any lengths can be |
| 572 |
% specified for these two parameters, but at least one of them should be |
| 573 |
% a rubber length so that it fills up the width of the page, unless |
| 574 |
% rubber lengths are added between the columns using the |
| 575 |
% "\extracolsep" command. |
| 576 |
% For instance |
| 577 |
%\begin{verbatim} |
| 578 |
% \begin{tabular*}{\textwidth}{@{\extracolsep{...}}...} |
| 579 |
%\end{verbatim} |
| 580 |
% produces a full width table, to get a similar effect with |
| 581 |
% \env{longtable} specify |
| 582 |
%\begin{verbatim} |
| 583 |
% \setlength\LTleft{0pt} |
| 584 |
% \setlength\LTright{0pt} |
| 585 |
% \begin{longtable}{@{\extracolsep{...}}...} |
| 586 |
%\end{verbatim} |
| 587 |
% |
| 588 |
% \section{Changes} |
| 589 |
% |
| 590 |
% This section highlights the major changes since version~2. A more |
| 591 |
% detailed change log may be produced at the end of the code listing |
| 592 |
% if the "ltxdoc.cfg" file specifies |
| 593 |
%\begin{verbatim} |
| 594 |
% \AtBeginDocument{\RecordChanges} |
| 595 |
% \AtEndDocument{\PrintChanges} |
| 596 |
%\end{verbatim} |
| 597 |
% |
| 598 |
% Changes made between versions 2 and 3. |
| 599 |
% \begin{itemize} |
| 600 |
% \item The mechanism for adding the head and foot of the table has been |
| 601 |
% completely rewritten. With this new mechanism, \env{longtable} does |
| 602 |
% not need to issue a "\clearpage" at the start of the table, and so the |
| 603 |
% table may start half way down a page. Also the "\endlastfoot" command, |
| 604 |
% which could not safely be implemented under the old scheme, has been |
| 605 |
% added. |
| 606 |
% \item \env{longtable} now issues an error if started in the scope of |
| 607 |
% "\twocolumn", or the \env{multicols} environment. |
| 608 |
% \item The separate documentation file "longtable.tex" has been |
| 609 |
% merged with the package file, "longtable.dtx" using Mittelbach's |
| 610 |
% \package{doc} package. |
| 611 |
% \item Support for footnotes has been added. Note however that |
| 612 |
% "\footnote" will not work in the `head' or `foot' sections of the |
| 613 |
% table. In order to put a footnote in those sections (e.g., inside a |
| 614 |
% caption), use "\footnotemark" at that point, and "\footnotetext" |
| 615 |
% anywhere in the table \emph{body} that will fall on the same page. |
| 616 |
% \item The treatment of "\multicolumn" has changed, making |
| 617 |
% "\kill" lines unnecessary, at the price of sometimes requiring a |
| 618 |
% third pass through \LaTeX. |
| 619 |
% \item The "\newpage" command now works inside a \env{longtable}. |
| 620 |
% \end{itemize} |
| 621 |
% |
| 622 |
% Changes made between versions 3 and 4. |
| 623 |
% \begin{itemize} |
| 624 |
% \item A new algorithm is used for aligning chunks. As well as the |
| 625 |
% widest width in each column, \package{longtable} remembers which |
| 626 |
% chunk produced this maximum. This allows it to check that the |
| 627 |
% maximum is still achieved in later runs. As \package{longtable} can |
| 628 |
% now deal with columns shrinking as the file is edited, the |
| 629 |
% "\setlongtables" system is no longer needed and is disabled. |
| 630 |
% |
| 631 |
% \item An extra benefit of the new algorithm's ability to deal with |
| 632 |
% `shrinking' columns is that it can give better (narrower) column |
| 633 |
% widths in the case of overlapping "\multicolumn" entries in |
| 634 |
% different chunks than the previous algorithm produced. |
| 635 |
% |
| 636 |
% \item The `draft' multicolumn system has been removed, along with |
| 637 |
% related commands such as "\LTmulticolumn". |
| 638 |
% |
| 639 |
% \item The disadvantage of the new algorithm is that it can take more |
| 640 |
% passes. The theoretical maximum is approximately twice the length |
| 641 |
% of a `chain' of columns with overlapping "\multicolumn" entries, |
| 642 |
% although in practice it usually converges as fast as the old |
| 643 |
% version. (Which always converged in three passes once |
| 644 |
% "\setlongtables" was activated.) |
| 645 |
% |
| 646 |
% \item "\\*" and "\nopagebreak" commands may be used to control page |
| 647 |
% breaking. |
| 648 |
% |
| 649 |
% \end{itemize} |
| 650 |
% |
| 651 |
% |
| 652 |
% \section{Summary} |
| 653 |
% |
| 654 |
% ^^A Allow the table to stick into the left margin. |
| 655 |
% \setlength{\LTleft}{0pt plus 1fill minus 1fill} |
| 656 |
% \setlength{\LTright}{0pt} |
| 657 |
% |
| 658 |
% \begin{longtable}{@{}l@{\hspace{10pt}}p{.8\linewidth}@{}} |
| 659 |
% \caption[A summary of \env{longtable} commands]% |
| 660 |
% {\normalsize A summary of \env{longtable} commands}\\ |
| 661 |
% \multicolumn{2}{c}{\textbf{Parameters}}\\* |
| 662 |
% \hline |
| 663 |
% "\LTleft"& |
| 664 |
% Glue to the left of the table. \hfill("\fill")\\ |
| 665 |
% "\LTright"& |
| 666 |
% Glue to the right of the table. \hfill("\fill")\\ |
| 667 |
% "\LTpre"& |
| 668 |
% Glue before the table. \hfill("\bigskipamount")\\ |
| 669 |
% "\LTpost"& |
| 670 |
% Glue after the table. \hfill("\bigskipamount")\\ |
| 671 |
% "\LTcapwidth"& |
| 672 |
% The width of a parbox containing the caption.\hfill(4in)\\ |
| 673 |
% "LTchunksize"& |
| 674 |
% The number of rows per chunk. \hfill(20)\\[5pt] |
| 675 |
% \multicolumn{2}{c}{\textbf{Optional |
| 676 |
% arguments to} \ttfamily\v\\begin\v{longtable\v}}\\* |
| 677 |
% \hline |
| 678 |
% \it none& Position as specified by "\LTleft" and "\LTright".\\ |
| 679 |
% "[c]"& Centre the table.\\ |
| 680 |
% "[l]"& Place the table flush left.\\ |
| 681 |
% "[r]"& Place the table flush right.\\[5pt] |
| 682 |
% \pagebreak[2] |
| 683 |
% \multicolumn{2}{c}{\textbf{Commands |
| 684 |
% to end table rows}}\\* |
| 685 |
% \hline |
| 686 |
% "\\"& |
| 687 |
% Specifies the end of a row\\ |
| 688 |
% "\\"\oarg{dim}& Ends row, then adds vertical space |
| 689 |
% (as in the \env{tabular} environment).\\ |
| 690 |
% "\\*"& |
| 691 |
% The same as "\\" but disallows a page break after the row.\\ |
| 692 |
% "\tabularnewline"& |
| 693 |
% Alternative to "\\" for use in the scope of "\raggedright" and |
| 694 |
% similar commands that redefine "\\".\\ |
| 695 |
% "\kill"& |
| 696 |
% Row is `killed', but is used in calculating widths.\\ |
| 697 |
% "\endhead"& |
| 698 |
% Specifies rows to appear at the top of every page.\\ |
| 699 |
% "\endfirsthead"& |
| 700 |
% Specifies rows to appear at the top of the first page.\\ |
| 701 |
% "\endfoot"& |
| 702 |
% Specifies rows to appear at the bottom of every page.\\ |
| 703 |
% "\endlastfoot"& |
| 704 |
% Specifies rows to appear at the bottom of the last page.\\[5pt] |
| 705 |
% \multicolumn{2}{c}{\textbf{\env{longtable} caption commands}}\\* |
| 706 |
% \hline |
| 707 |
% "\caption"\marg{caption}& |
| 708 |
% Caption `Table ?: \meta{caption}', and a `\meta{caption}' |
| 709 |
% entry in the list of tables.\\ |
| 710 |
% "\caption"\oarg{lot}\marg{caption}& |
| 711 |
% Caption `Table ?: \meta{caption}', and a `\meta{lot}' |
| 712 |
% entry in the list of tables.\\ |
| 713 |
% "\caption[]"\marg{caption}& |
| 714 |
% Caption `Table ?: \meta{caption}', |
| 715 |
% but no entry in the list of tables.\\ |
| 716 |
% "\caption*"\marg{caption}& |
| 717 |
% Caption `\meta{caption}', but no entry in the list of tables.\\[5pt] |
| 718 |
% \multicolumn{2}{c}{%^^A |
| 719 |
% \textbf{Commands available at the start of a row}}\\* |
| 720 |
% \hline |
| 721 |
% "\pagebreak"& |
| 722 |
% Force a page break.\\* |
| 723 |
% "\pagebreak"\oarg{val}& A `hint' between 0 and 4 |
| 724 |
% of the desirability of a break.\\ |
| 725 |
% "\nopagebreak"& Prohibit a page break.\\* |
| 726 |
% "\nopagebreak"\oarg{val}& A `hint' between 0 and 4 of the undesirability |
| 727 |
% of a break.\\ |
| 728 |
% "\newpage"& |
| 729 |
% Force a page break.\\[5pt] |
| 730 |
% \multicolumn{2}{c}{\textbf{Footnote commands |
| 731 |
% available inside \env{longtable}}}\\* |
| 732 |
% \hline |
| 733 |
% "\footnote"& |
| 734 |
% Footnotes, but may not be used in the table head \& foot.\\* |
| 735 |
% "\footnotemark"& |
| 736 |
% Footnotemark, may be used in the table head \& foot.\\* |
| 737 |
% "\footnotetext"& |
| 738 |
% Footnote text, use in the table body.\\[5pt] |
| 739 |
% \multicolumn{2}{c}{\textbf{Setlongtables}}\\ |
| 740 |
% \hline |
| 741 |
% "\setlongtables"& Obsolete command. Does nothing now. |
| 742 |
% \end{longtable} |
| 743 |
% |
| 744 |
% |
| 745 |
% \finalclearpage |
| 746 |
% \section{Verbatim highlights from Table \protect\ref{long}} |
| 747 |
% \label{listing} |
| 748 |
% \begingroup\catcode`\/=0 |
| 749 |
% \begin{verbatim} |
| 750 |
% \begin{longtable}{@{*}r||p{1in}@{*}} |
| 751 |
% KILLED & LINE!!!! \kill |
| 752 |
% \caption[An optional table caption /ldots]{A long table\label{long}}\\ |
| 753 |
% \hline\hline |
| 754 |
% \multicolumn{2}{@{*}c@{*}}% |
| 755 |
% {This part appears at the top of the table}\\ |
| 756 |
% \textsc{First}&\textsc{Second}\\ |
| 757 |
% \hline\hline |
| 758 |
% \endfirsthead |
| 759 |
% \caption[]{(continued)}\\ |
| 760 |
% \hline\hline |
| 761 |
% \multicolumn{2}{@{*}c@{*}}% |
| 762 |
% {This part appears at the top of every other page}\\ |
| 763 |
% \textbf{First}&\textbf{Second}\\ |
| 764 |
% \hline\hline |
| 765 |
% \endhead |
| 766 |
% \hline |
| 767 |
% This goes at the&bottom.\\ |
| 768 |
% \hline |
| 769 |
% \endfoot |
| 770 |
% \hline |
| 771 |
% These lines will&appear\\ |
| 772 |
% in place of the & usual foot\\ |
| 773 |
% at the end& of the table\\ |
| 774 |
% \hline |
| 775 |
% \endlastfoot |
| 776 |
% \env{longtable} columns are specified& in the \\ |
| 777 |
% same way as in the \env{tabular}& environment.\\ |
| 778 |
% /ldots |
| 779 |
% \multicolumn{2}{||c||}{This is a /ldots}\\ |
| 780 |
% /ldots |
| 781 |
% Some lines may take/ldots& |
| 782 |
% \raggedleft This last column is a ``p'' column/ldots |
| 783 |
% \tabularnewline |
| 784 |
% /ldots |
| 785 |
% Lots of lines& like this.\\ |
| 786 |
% /ldots |
| 787 |
% \hline |
| 788 |
% Lots\footnote{/ldots} of lines& like this.\\ |
| 789 |
% Lots of lines& like this\footnote{/ldots}\\ |
| 790 |
% \hline |
| 791 |
% Lots of lines& like this.\\ |
| 792 |
% /ldots |
| 793 |
% \end{longtable} |
| 794 |
% \end{verbatim} |
| 795 |
% \endgroup |
| 796 |
% |
| 797 |
% \MaybeStop{} |
| 798 |
% |
| 799 |
% \finalclearpage |
| 800 |
% \section{The Macros} |
| 801 |
% |
| 802 |
% \begin{macrocode} |
| 803 |
%<*package> |
| 804 |
% \end{macrocode} |
| 805 |
% |
| 806 |
% \subsection{Initial code} |
| 807 |
% |
| 808 |
% Before declaring the package options, we must define some defaults |
| 809 |
% here. |
| 810 |
% |
| 811 |
% \begin{macro}{\LT@err} |
| 812 |
% The error generating command |
| 813 |
% \begin{macrocode} |
| 814 |
\def\LT@err{\PackageError{longtable}} |
| 815 |
% \end{macrocode} |
| 816 |
% \end{macro} |
| 817 |
% |
| 818 |
% \begin{macro}{\LT@warn} |
| 819 |
% The warning generating command |
| 820 |
% \begin{macrocode} |
| 821 |
\def\LT@warn{\PackageWarning{longtable}} |
| 822 |
% \end{macrocode} |
| 823 |
% \end{macro} |
| 824 |
% |
| 825 |
% \begin{macro}{\LT@final@warn} |
| 826 |
% \changes{v4.04}{1996/05/24} |
| 827 |
% {Macro added} |
| 828 |
% If any \env{longtable}s have not aligned, generate a warning at the |
| 829 |
% end of the run at "\AtEndDocument". |
| 830 |
% \begin{macrocode} |
| 831 |
\def\LT@final@warn{% |
| 832 |
\AtEndDocument{% |
| 833 |
\LT@warn{Table \@width s have changed. Rerun LaTeX.\@gobbletwo}}% |
| 834 |
\global\let\LT@final@warn\relax} |
| 835 |
% \end{macrocode} |
| 836 |
% \end{macro} |
| 837 |
% |
| 838 |
% \subsection{Options} |
| 839 |
% |
| 840 |
% The first two options deal with error handling. They are compatible |
| 841 |
% with the options used by the \texttt{tracefnt} package. |
| 842 |
% |
| 843 |
% \begin{macro}{errorshow} |
| 844 |
% \emph{Only} show errors on the terminal. `warnings' are just sent to |
| 845 |
% the log file. |
| 846 |
% \changes{v3.14}{1995/04/25} |
| 847 |
% {Change string from LT to longtable} |
| 848 |
% \begin{macrocode} |
| 849 |
\DeclareOption{errorshow}{% |
| 850 |
\def\LT@warn{\PackageInfo{longtable}}} |
| 851 |
% \end{macrocode} |
| 852 |
% \end{macro} |
| 853 |
% |
| 854 |
% \begin{macro}{pausing} |
| 855 |
% \changes{v3.14}{1995/04/25} |
| 856 |
% {Change string from LT to longtable} |
| 857 |
% \changes{v3.15}{1995/06/15} |
| 858 |
% {Use single hash for latex/1557} |
| 859 |
% Make every warning message into an error so \TeX\ stops. |
| 860 |
% May be useful for debugging. |
| 861 |
% \begin{macrocode} |
| 862 |
\DeclareOption{pausing}{% |
| 863 |
\def\LT@warn#1{% |
| 864 |
\LT@err{#1}{This is not really an error}}} |
| 865 |
% \end{macrocode} |
| 866 |
% \end{macro} |
| 867 |
% |
| 868 |
% \begin{macro}{set} |
| 869 |
% \begin{macro}{final} |
| 870 |
% \changes{v4.01}{1996/04/11} |
| 871 |
% {(DPC) make set and final options no op} |
| 872 |
% The next options are just alternative syntax for the |
| 873 |
% "\setlongtables" declaration. |
| 874 |
% \begin{macrocode} |
| 875 |
\DeclareOption{set}{} |
| 876 |
\DeclareOption{final}{} |
| 877 |
% \end{macrocode} |
| 878 |
% \end{macro} |
| 879 |
% \end{macro} |
| 880 |
% |
| 881 |
% |
| 882 |
% \begin{macrocode} |
| 883 |
\ProcessOptions |
| 884 |
% \end{macrocode} |
| 885 |
% |
| 886 |
% \subsection{User Settable Parameters} |
| 887 |
% |
| 888 |
% \begin{macro}{\LTleft} |
| 889 |
% \begin{macro}{\LTright} |
| 890 |
% Glue to the left and right of the table, default "\fill" (ie |
| 891 |
% centred). |
| 892 |
% \begin{macrocode} |
| 893 |
\newskip\LTleft \LTleft=\fill |
| 894 |
\newskip\LTright \LTright=\fill |
| 895 |
% \end{macrocode} |
| 896 |
% \end{macro} |
| 897 |
% \end{macro} |
| 898 |
% |
| 899 |
% \begin{macro}{\LTpre} |
| 900 |
% \begin{macro}{\LTpost} |
| 901 |
% Glue before and after the \env{longtable}. "\bigskip" by default. |
| 902 |
% \begin{macrocode} |
| 903 |
\newskip\LTpre \LTpre=\bigskipamount |
| 904 |
\newskip\LTpost \LTpost=\bigskipamount |
| 905 |
% \end{macrocode} |
| 906 |
% \end{macro} |
| 907 |
% \end{macro} |
| 908 |
% |
| 909 |
% \begin{macro}{\LTchunksize} |
| 910 |
% \changes{v4.14}{2020/02/07} |
| 911 |
% {Increase default chunksize from 20 to 200} |
| 912 |
% Chunk size (the number of rows taken per "\halign"). Default 200. |
| 913 |
% \begin{macrocode} |
| 914 |
\newcount\LTchunksize \LTchunksize=200 |
| 915 |
% \end{macrocode} |
| 916 |
% \end{macro} |
| 917 |
% |
| 918 |
% \begin{macro}{\c@LTchunksize} |
| 919 |
% Added in V3.07 to allow the \LaTeX\ syntax |
| 920 |
% "\setcounter{LTchunksize}{10}". |
| 921 |
% \begin{macrocode} |
| 922 |
\let\c@LTchunksize\LTchunksize |
| 923 |
% \end{macrocode} |
| 924 |
% \end{macro} |
| 925 |
% |
| 926 |
% \begin{macro}{\LTcapwidth} |
| 927 |
% Width of the "\parbox" containing the caption. Default 4in. |
| 928 |
% \begin{macrocode} |
| 929 |
\newdimen\LTcapwidth \LTcapwidth=4in |
| 930 |
% \end{macrocode} |
| 931 |
% \end{macro} |
| 932 |
% |
| 933 |
% \begin{macro}{\LTcaptype} |
| 934 |
% The name used as counter, in caption, "\addcontentsline" and in targets. |
| 935 |
% "\providecommand" is used for compability with \pkg{ltcaption} |
| 936 |
% \changes{v4.21}{2024/07/04} |
| 937 |
% {Added \cs{LTcaptype} to support other types beside table.} |
| 938 |
% \begin{macrocode} |
| 939 |
\providecommand\LTcaptype{table} |
| 940 |
% \end{macrocode} |
| 941 |
% \end{macro} |
| 942 |
% \subsection{Internal Parameters} |
| 943 |
% |
| 944 |
% \begin{macro}{\LT@head} |
| 945 |
% \begin{macro}{\LT@firsthead} |
| 946 |
% \begin{macro}{\LT@foot} |
| 947 |
% \begin{macro}{\LT@lastfoot} |
| 948 |
% Boxes for the table head and foot. |
| 949 |
% \begin{macrocode} |
| 950 |
\newbox\LT@head |
| 951 |
\newbox\LT@firsthead |
| 952 |
\newbox\LT@foot |
| 953 |
\newbox\LT@lastfoot |
| 954 |
% \end{macrocode} |
| 955 |
% \end{macro} |
| 956 |
% \end{macro} |
| 957 |
% \end{macro} |
| 958 |
% \end{macro} |
| 959 |
% |
| 960 |
% \begin{macro}{\LT@gbox} |
| 961 |
% \changes{v4.14}{2020/02/07} |
| 962 |
% {global box added (tools/2914)} |
| 963 |
% \begin{macrocode} |
| 964 |
\newbox\LT@gbox |
| 965 |
% \end{macrocode} |
| 966 |
% \end{macro} |
| 967 |
% |
| 968 |
% \begin{macro}{\LT@cols} |
| 969 |
% Counter for number of columns. |
| 970 |
% \begin{macrocode} |
| 971 |
\newcount\LT@cols |
| 972 |
% \end{macrocode} |
| 973 |
% \end{macro} |
| 974 |
% |
| 975 |
% \begin{macro}{\LT@rows} |
| 976 |
% Counter for rows up to chunksize. |
| 977 |
% \begin{macrocode} |
| 978 |
\newcount\LT@rows |
| 979 |
% \end{macrocode} |
| 980 |
% \end{macro} |
| 981 |
% |
| 982 |
% \begin{macro}{\c@LT@tables} |
| 983 |
% Counter for the tables, added in V3.02. Previous versions just used |
| 984 |
% the \LaTeX\ counter "table", but this fails if "table" is |
| 985 |
% reset during a document, eg \package{report} class resets it every |
| 986 |
% chapter. |
| 987 |
% |
| 988 |
% This was changed from "\newcount\LT@tables" in V3.04. \LaTeX\ counters |
| 989 |
% are preserved correctly when "\includeonly" is used. In the rest of |
| 990 |
% the file "\LT@tables" has been replaced by "\c@LT@tables" without |
| 991 |
% further comment. |
| 992 |
% \changes{v4.21}{2024/07/04} |
| 993 |
% {Provide a \cs{theH}-representation for targets.} |
| 994 |
% \begin{macrocode} |
| 995 |
\newcounter{LT@tables} |
| 996 |
\providecommand\theHLT@tables{\theLT@tables} |
| 997 |
% \end{macrocode} |
| 998 |
% \end{macro} |
| 999 |
% |
| 1000 |
% \begin{macro}{\c@LT@chunks} |
| 1001 |
% \changes{v4.00}{1996/04/08} |
| 1002 |
% {(DK) Chunk counter added} |
| 1003 |
% We need to count through the chunks of our tables from Version~4 on. |
| 1004 |
% \begin{macrocode} |
| 1005 |
\newcounter{LT@chunks}[LT@tables] |
| 1006 |
% \end{macrocode} |
| 1007 |
% \end{macro} |
| 1008 |
% |
| 1009 |
% \begin{macro}{\c@table} |
| 1010 |
% \begin{macro}{\fnum@table} |
| 1011 |
% \begin{macro}{\tablename} |
| 1012 |
% \begin{macro}{\ext@table} |
| 1013 |
% \changes{v4.17}{2021/09/01} |
| 1014 |
% {ensure \cs{ext@table} is defined gh/637} |
| 1015 |
% If the "table" counter is not defined (eg in "letter" style), define |
| 1016 |
% it. (Added in V3.06.) |
| 1017 |
% \begin{macrocode} |
| 1018 |
\ifx\c@table\undefined |
| 1019 |
\newcounter{table} |
| 1020 |
\def\fnum@table{\tablename~\thetable} |
| 1021 |
\fi |
| 1022 |
\ifx\tablename\undefined |
| 1023 |
\def\tablename{Table} |
| 1024 |
\fi |
| 1025 |
\ifx\ext@table\undefined |
| 1026 |
\def\ext@table{lot} |
| 1027 |
\fi |
| 1028 |
% \end{macrocode} |
| 1029 |
% \end{macro} |
| 1030 |
% \end{macro} |
| 1031 |
% \end{macro} |
| 1032 |
% \end{macro} |
| 1033 |
% |
| 1034 |
% \begin{macro}{\LT@out} |
| 1035 |
% In a normal style, "longtable" uses the ".aux" file to record the |
| 1036 |
% column widths. With "letter.sty", use a separate ".lta" file. |
| 1037 |
% (Added in V3.06.) |
| 1038 |
% |
| 1039 |
% Not needed for new letter class. |
| 1040 |
%\begin{verbatim} |
| 1041 |
%\ifx\startlabels\undefined |
| 1042 |
% \let\@auxout\@auxout |
| 1043 |
%\else |
| 1044 |
% {\@input{\jobname.lta}}% |
| 1045 |
% \newwrite\@auxout |
| 1046 |
% \immediate\openout\@auxout=\jobname.lta |
| 1047 |
%\fi |
| 1048 |
%\end{verbatim} |
| 1049 |
% \end{macro} |
| 1050 |
% |
| 1051 |
% \begin{macro}{\LT@p@ftn} |
| 1052 |
% Temporary storage for footnote text in a `p' column. |
| 1053 |
% \begin{macrocode} |
| 1054 |
\newtoks\LT@p@ftn |
| 1055 |
% \end{macrocode} |
| 1056 |
% \end{macro} |
| 1057 |
% |
| 1058 |
% \begin{macro}{\LT@end@pen} |
| 1059 |
% Special penalty for the end of the table. Done this way to save using |
| 1060 |
% up a count register. |
| 1061 |
% \begin{macrocode} |
| 1062 |
\mathchardef\LT@end@pen=30000 |
| 1063 |
% \end{macrocode} |
| 1064 |
% \end{macro} |
| 1065 |
% |
| 1066 |
% \subsection{The \env{longtable} environment} |
| 1067 |
% |
| 1068 |
% \begin{macro}{\longtable} |
| 1069 |
% \changes{v4.17}{2021/09/01} |
| 1070 |
% {\cs{@nobreakfalse} gh/173 \cs{ifnoskipsec} test for gh/131} |
| 1071 |
% Called by "\begin{longtable}". This implementation does not work in |
| 1072 |
% multiple column formats. "\par" added at V3.04. |
| 1073 |
% \begin{macrocode} |
| 1074 |
\def\longtable{% |
| 1075 |
\par |
| 1076 |
\if@noskipsec\mbox{}\par\fi |
| 1077 |
\@nobreakfalse |
| 1078 |
\ifx\multicols\@undefined |
| 1079 |
\else |
| 1080 |
\ifnum\col@number>\@ne |
| 1081 |
\@twocolumntrue |
| 1082 |
\fi |
| 1083 |
\fi |
| 1084 |
\if@twocolumn |
| 1085 |
\LT@err{longtable not in 1-column mode}\@ehc |
| 1086 |
\fi |
| 1087 |
% \end{macrocode} |
| 1088 |
% |
| 1089 |
% \changes{v4.19}{2023/12/16}{Support for tagged PDF} |
| 1090 |
% \begin{macrocode} |
| 1091 |
\UseTaggingSocket{tbl/vmode/begin}% |
| 1092 |
% \end{macrocode} |
| 1093 |
% |
| 1094 |
% \begin{macrocode} |
| 1095 |
\begingroup |
| 1096 |
% \end{macrocode} |
| 1097 |
% Check for an optional argument. |
| 1098 |
% \begin{macrocode} |
| 1099 |
\@ifnextchar[\LT@array{\LT@array[x]}} |
| 1100 |
% \end{macrocode} |
| 1101 |
% \end{macro} |
| 1102 |
% |
| 1103 |
% |
| 1104 |
% |
| 1105 |
% \begin{macro}{\LT@array} |
| 1106 |
% \begin{macrocode} |
| 1107 |
%<@@=tbl> |
| 1108 |
\ExplSyntaxOn |
| 1109 |
% \end{macrocode} |
| 1110 |
% |
| 1111 |
% Start setting the alignment. |
| 1112 |
% Based on "\@array" from the \LaTeX\ kernel |
| 1113 |
% and the \package{array} package. |
| 1114 |
% |
| 1115 |
% Since Version 3.02, \package{longtable} has used the internal counter |
| 1116 |
% "\c@LT@tables". The \LaTeX\ counter "table" is still incremented |
| 1117 |
% so that "\caption" works correctly. |
| 1118 |
% \changes{v4.21}{2024/07/04} |
| 1119 |
% {Use \cs{LTcaptype} instead of \texttt{table} in various places |
| 1120 |
% to support other types beside table.} |
| 1121 |
% \begin{macrocode} |
| 1122 |
\def\LT@array[#1]#2{% |
| 1123 |
% \end{macrocode} |
| 1124 |
% |
| 1125 |
% With respect to tagging we have a complicated situation with |
| 1126 |
% longtable. When at the begin the \cs{endhead}, |
| 1127 |
% \cs{endfirsthead}, \cs{endfoot} and \cs{endlastfoot} are used to |
| 1128 |
% setup head and foot they create each a structure subtree with one or |
| 1129 |
% more rows. From these structures we want to keep at most two (head |
| 1130 |
% and foot) and move the foot to the end of the table. When the head |
| 1131 |
% and foot boxes are (re)inserted on following pages we want to mark |
| 1132 |
% them up as artifact with the exception of the head at the begin and |
| 1133 |
% the foot box at the end. |
| 1134 |
% |
| 1135 |
% TODO: When a line is killed the structure subtree is there already |
| 1136 |
% too and must be removed. If hard to do, then maybe at first warn if the |
| 1137 |
% construction is used. |
| 1138 |
% |
| 1139 |
% \cs{LT@array} is executed in a group, so we can disable para-tagging here. |
| 1140 |
% \changes{v4.19}{2023/12/16}{Support for tagged PDF} |
| 1141 |
% \begin{macrocode} |
| 1142 |
\UseTaggingSocket{tbl/init} |
| 1143 |
\tl_if_empty:eTF { \LTcaptype } |
| 1144 |
{ |
| 1145 |
\tl_gset:Ne \@currentHref {LT@tables.\theHLT@tables} |
| 1146 |
} |
| 1147 |
{ |
| 1148 |
\@kernel@refstepcounter{\LTcaptype}\stepcounter{LT@tables} |
| 1149 |
% \end{macrocode} |
| 1150 |
% The target is created rather late and a \cs{label} can come earlier, |
| 1151 |
% so we have to define \cs{@currentHref} explicitly. We can't currently |
| 1152 |
% assume that \cs{theHtable} is defined always. |
| 1153 |
% \begin{macrocode} |
| 1154 |
\tl_gset:Ne \@currentHref {\LTcaptype.\cs_if_exist_use:c {theH\LTcaptype}} |
| 1155 |
} |
| 1156 |
% \end{macrocode} |
| 1157 |
% |
| 1158 |
% \changes{v4.19}{2023/12/16}{Managing cell indexes} |
| 1159 |
% \begin{macrocode} |
| 1160 |
\tbl_gzero_row_count: |
| 1161 |
% \end{macrocode} |
| 1162 |
% |
| 1163 |
% \changes{v4.19}{2023/12/16}{Support for tagged PDF} |
| 1164 |
% \begin{macrocode} |
| 1165 |
\UseTaggingSocket{tbl/longtable/init} |
| 1166 |
% \end{macrocode} |
| 1167 |
% Set up the glue around the table if an optional argument given. |
| 1168 |
% \begin{macrocode} |
| 1169 |
\if l#1% |
| 1170 |
\LTleft\z@ \LTright\fill |
| 1171 |
\else\if r#1% |
| 1172 |
\LTleft\fill \LTright\z@ |
| 1173 |
\else\if c#1% |
| 1174 |
\LTleft\fill \LTright\fill |
| 1175 |
\fi\fi\fi |
| 1176 |
% \end{macrocode} |
| 1177 |
% Set up these internal commands for \env{longtable}. |
| 1178 |
% \changes{v3.13}{1994/12/08} |
| 1179 |
% {add \cs{tabularnewline}} |
| 1180 |
% \changes{v3.14}{1995/04/25} |
| 1181 |
% {(Mike Van Geest) rename \cs{LT@mc} to |
| 1182 |
% \cs{LT@mcol} to allow 1100 tables} |
| 1183 |
% \changes{v4.01}{1996/04/11} |
| 1184 |
% {(DPC) don't need multicolumn warning} |
| 1185 |
%\begin{verbatim} |
| 1186 |
% \global\let\LT@mcw@rn\relax |
| 1187 |
%\end{verbatim} |
| 1188 |
% \begin{macrocode} |
| 1189 |
\let\LT@mcol\multicolumn |
| 1190 |
% \end{macrocode} |
| 1191 |
% \changes{v3.17}{1996/01/31} |
| 1192 |
% {Reset \cs{hline} and \cs{multicolumn} in nested tabular |
| 1193 |
% and array, for tools/2068} |
| 1194 |
% Now redefine "\@tabarray" to restore "\hline" and "\multicolumn" so |
| 1195 |
% that arrays and tabulars nested in longtable (or in page headings on |
| 1196 |
% longtable pages) work out OK. Saving the original definitions done |
| 1197 |
% here so that you can load the \package{array} package before or after |
| 1198 |
% \package{longtable}. |
| 1199 |
% \begin{macrocode} |
| 1200 |
\let\LT@@@@tabarray\@tabarray |
| 1201 |
\let\LT@@@@hl\hline |
| 1202 |
\def\@tabarray{% |
| 1203 |
\let\hline\LT@@@@hl |
| 1204 |
% \end{macrocode} |
| 1205 |
%\begin{verbatim} |
| 1206 |
% \let\multicolumn\LT@mcol |
| 1207 |
%\end{verbatim} |
| 1208 |
% \begin{macrocode} |
| 1209 |
\LT@@@@tabarray}% |
| 1210 |
\let\\\LT@tabularcr |
| 1211 |
\let\tabularnewline\\% |
| 1212 |
\def\newpage{\noalign{\break}}% |
| 1213 |
% \end{macrocode} |
| 1214 |
% \changes{v4.05}{1996/11/12} |
| 1215 |
% {\cs{nopagebreak} and \cs{pagebreak} added} |
| 1216 |
% More or less standard definitions, but first start a "\noalign". |
| 1217 |
% \begin{macrocode} |
| 1218 |
\def\pagebreak{\noalign{\ifnum`}=0\fi\@testopt{\LT@no@pgbk-}4}% |
| 1219 |
\def\nopagebreak{\noalign{\ifnum`}=0\fi\@testopt\LT@no@pgbk4}% |
| 1220 |
% \end{macrocode} |
| 1221 |
% |
| 1222 |
% \begin{macrocode} |
| 1223 |
\let\hline\LT@hline \let\kill\LT@kill\let\caption\LT@caption |
| 1224 |
\@tempdima\ht\strutbox |
| 1225 |
% \end{macrocode} |
| 1226 |
% |
| 1227 |
% \changes{v4.08}{1998/01/20} |
| 1228 |
% {Move \cs{@endpbox} definition earlier and define \cs{@@@@endpbox} |
| 1229 |
% and \cs{@@@@startpbox} for non-array case. tools/2736} |
| 1230 |
% \begin{macrocode} |
| 1231 |
\let\@endpbox\LT@endpbox |
| 1232 |
% \end{macrocode} |
| 1233 |
% Set up internal commands according to Lamport or Mittelbach. |
| 1234 |
% \begin{macrocode} |
| 1235 |
\ifx\extrarowheight\@undefined |
| 1236 |
% \end{macrocode} |
| 1237 |
% Initialise these commands as in \env{tabular} from the \LaTeX\ kernel. |
| 1238 |
% \begin{macrocode} |
| 1239 |
\let\@acol\@tabacol |
| 1240 |
\let\@classz\@tabclassz \let\@classiv\@tabclassiv |
| 1241 |
\def\@startpbox{\vtop\LT@startpbox}% |
| 1242 |
\let\@@@@startpbox\@startpbox |
| 1243 |
\let\@@@@endpbox\@endpbox |
| 1244 |
\let\LT@LL@FM@cr\@tabularcr |
| 1245 |
\else |
| 1246 |
% \end{macrocode} |
| 1247 |
% Initialise these commands as in \package{array}. "\d@llar" |
| 1248 |
% replaced by "\d@llarbegin" "\d@llarend" in V3.03 to match |
| 1249 |
% \package{array} V2.0h. We do not need to set "\d@llarbegin" and |
| 1250 |
% "\d@llarend" as the \package{array} package gives them the correct |
| 1251 |
% values at the top level. |
| 1252 |
% \changes{v4.23}{2024/12/17}{Initialize \cs{@startpbox@action} instead |
| 1253 |
% of \cs{@startpbox} to match array change (gh/1585)} |
| 1254 |
% \begin{macrocode} |
| 1255 |
\advance\@tempdima\extrarowheight |
| 1256 |
\col@sep\tabcolsep |
| 1257 |
\let\@startpbox@action\LT@startpbox |
| 1258 |
\let\LT@LL@FM@cr\@arraycr |
| 1259 |
\fi |
| 1260 |
% \end{macrocode} |
| 1261 |
% The rest of this macro is mainly based on \package{array} package, but |
| 1262 |
% should work for the standard \env{tabular} too. |
| 1263 |
% \begin{macrocode} |
| 1264 |
\setbox\@arstrutbox\hbox{\vrule |
| 1265 |
\@height \arraystretch \@tempdima |
| 1266 |
\@depth \arraystretch \dp \strutbox |
| 1267 |
\@width \z@}% |
| 1268 |
\let\@sharp##\let\protect\relax |
| 1269 |
% \end{macrocode} |
| 1270 |
% Interpret the preamble argument. |
| 1271 |
% \begin{macrocode} |
| 1272 |
\begingroup |
| 1273 |
\@mkpream{#2}% |
| 1274 |
% \end{macrocode} |
| 1275 |
% |
| 1276 |
% \changes{v4.19}{2023/12/16}{Managing cell indexes} |
| 1277 |
% \begin{macrocode} |
| 1278 |
\tbl_count_table_cols: |
| 1279 |
% \end{macrocode} |
| 1280 |
% We need to rename "\@preamble" here as F.M.'s scheme uses |
| 1281 |
% "\global", and we may need to nest "\@mkpream", eg for |
| 1282 |
% "\multicolumn" |
| 1283 |
% or an \env{array}. |
| 1284 |
% We do not need to worry about nested \env{longtable}s though! |
| 1285 |
% \begin{macrocode} |
| 1286 |
\xdef\LT@bchunk{% |
| 1287 |
% \end{macrocode} |
| 1288 |
% We aren't inside any row when a chunk starts. |
| 1289 |
% \changes{v4.19}{2023/12/16}{Managing cell indexes} |
| 1290 |
% \begin{macrocode} |
| 1291 |
\tbl_inbetween_rows: |
| 1292 |
% \end{macrocode} |
| 1293 |
% \changes{v4.00}{1996/04/08} |
| 1294 |
% {(DK) Increment Chunk counter} |
| 1295 |
% \begin{macrocode} |
| 1296 |
\global\advance\c@LT@chunks\@ne |
| 1297 |
\global\LT@rows\z@\setbox\z@\vbox\bgroup |
| 1298 |
% \end{macrocode} |
| 1299 |
% \changes{v4.05}{1996/11/12} |
| 1300 |
% {\cs{LT@setprevdepth} added} |
| 1301 |
% The following line was added in v4.05. |
| 1302 |
% In order to get the "\penalties" to work at chunk boundaries, |
| 1303 |
% we need to take more care about where and when "\lineskip" glue |
| 1304 |
% is added. The following does nothing at top of table, and in |
| 1305 |
% header chunks, but in normal body chunks it sets "\prevdepth" |
| 1306 |
% (to 0pt, but any value would do) so that "\lineskip" glue will |
| 1307 |
% be added. The important thing to note is that the glue will be |
| 1308 |
% added \emph{after} any vertical material coming from "\noalign". |
| 1309 |
% \begin{macrocode} |
| 1310 |
\LT@setprevdepth |
| 1311 |
% \end{macrocode} |
| 1312 |
% |
| 1313 |
% \changes{v4.10}{2000/10/22} |
| 1314 |
% {\cs{noexpand} added (as in array.sty) for mathtext.sty, CAR} |
| 1315 |
% \begin{macrocode} |
| 1316 |
\tabskip\LTleft \noexpand\halign to\hsize\bgroup |
| 1317 |
% \tabskip\LTleft\halign to\hsize\bgroup |
| 1318 |
\tabskip\z@ \@arstrut |
| 1319 |
% \end{macrocode} |
| 1320 |
% Insert the tagging socket to start the row and initialize the cell |
| 1321 |
% data for the row. |
| 1322 |
% \changes{v4.19}{2023/12/16}{Support for tagged PDF} |
| 1323 |
% \begin{macrocode} |
| 1324 |
\UseTaggingSocket{tbl/row/begin}% |
| 1325 |
% \end{macrocode} |
| 1326 |
% |
| 1327 |
% \changes{v4.19}{2023/12/16}{Managing cell indexes} |
| 1328 |
% \begin{macrocode} |
| 1329 |
\tbl_init_cell_data_for_row: |
| 1330 |
% \end{macrocode} |
| 1331 |
% \begin{macrocode} |
| 1332 |
\@preamble \tabskip\LTright \cr}% |
| 1333 |
\endgroup |
| 1334 |
% \end{macrocode} |
| 1335 |
% Find out how many columns we have (store in "\LT@cols"). |
| 1336 |
% \begin{macrocode} |
| 1337 |
\expandafter\LT@nofcols\LT@bchunk&\LT@nofcols |
| 1338 |
% \end{macrocode} |
| 1339 |
% Get the saved row from "\LT@i"\ldots"\LT@ix" (from the |
| 1340 |
% ".aux" file), or make a new blank row. |
| 1341 |
% \begin{macrocode} |
| 1342 |
\LT@make@row |
| 1343 |
% \end{macrocode} |
| 1344 |
% A few more internal commands for \env{longtable}. |
| 1345 |
% \begin{macrocode} |
| 1346 |
\m@th\let\par\@empty |
| 1347 |
% \end{macrocode} |
| 1348 |
% Tagging socket and conditional |
| 1349 |
% \begin{macrocode} |
| 1350 |
\everycr{% |
| 1351 |
\noalign{% |
| 1352 |
% \end{macrocode} |
| 1353 |
% In \pkg{longtable} we have a bunch of extra \cs{cr}s that are |
| 1354 |
% executed whenever a chunk ends. In that case they should not |
| 1355 |
% increment the main row counter, sigh. |
| 1356 |
% |
| 1357 |
% TODO: At the moment this tracing still exposes the internal row counter! |
| 1358 |
% \begin{macrocode} |
| 1359 |
\@@_trace:n {--longtable-->~chunk~row:~ \the\LT@rows \space |
| 1360 |
row:~ \the\g_@@_row_int \space |
| 1361 |
column:~ \the\g_@@_col_int |
| 1362 |
} |
| 1363 |
% \end{macrocode} |
| 1364 |
% |
| 1365 |
% \changes{v4.19}{2023/12/16}{Support for tagged PDF} |
| 1366 |
% \begin{macrocode} |
| 1367 |
\tbl_if_row_was_started:T |
| 1368 |
{ |
| 1369 |
\UseTaggingSocket{tbl/row/end} |
| 1370 |
% \end{macrocode} |
| 1371 |
% The next setting prevents any of the additional \cs{cr}s at the end of the |
| 1372 |
% chunk to add another /TR. Then once we really start a new chunk |
| 1373 |
% it gets incremented so\ldots |
| 1374 |
% \changes{v4.19}{2023/12/16}{Managing cell indexes} |
| 1375 |
% \begin{macrocode} |
| 1376 |
\tbl_inbetween_rows: |
| 1377 |
} |
| 1378 |
% \end{macrocode} |
| 1379 |
% And for the same reason such \cs{cr}s should not increment the |
| 1380 |
% main row counter (but it has to be incremented after the preamble |
| 1381 |
% of a chunk), so here we test against \cs{LT@rows} which is |
| 1382 |
% \cs{LTchunksize} at the end of a chunk. |
| 1383 |
% \changes{v4.19}{2023/12/16}{Managing cell indexes} |
| 1384 |
% \begin{macrocode} |
| 1385 |
\int_compare:nNnT \LT@rows < \LTchunksize |
| 1386 |
{ \tbl_gincr_row_count: } % next is row about to start |
| 1387 |
}% |
| 1388 |
}% |
| 1389 |
% \end{macrocode} |
| 1390 |
% \begin{macrocode} |
| 1391 |
\lineskip\z@\baselineskip\z@ |
| 1392 |
% \end{macrocode} |
| 1393 |
% Start the first chunk. |
| 1394 |
% \begin{macrocode} |
| 1395 |
\LT@bchunk} |
| 1396 |
\ExplSyntaxOff |
| 1397 |
%<@@=> |
| 1398 |
% \end{macrocode} |
| 1399 |
% \end{macro} |
| 1400 |
% |
| 1401 |
% \begin{macro}{\LT@no@pgbk} |
| 1402 |
% \changes{v4.05}{1996/11/12} |
| 1403 |
% {Macro added} |
| 1404 |
% Can simplify the standard "\@no@pgbk" as this is vmode only |
| 1405 |
% but then need to close the "\noalign". |
| 1406 |
% \begin{macrocode} |
| 1407 |
\def\LT@no@pgbk#1[#2]{\penalty #1\@getpen{#2}\ifnum`{=0\fi}} |
| 1408 |
% \end{macrocode} |
| 1409 |
% \end{macro} |
| 1410 |
% |
| 1411 |
% \begin{macro}{\LT@start} |
| 1412 |
% \changes{v4.13}{2020/01/07} |
| 1413 |
% {fix issue https://github.com/davidcarlisle/dpctex/issues/8} |
| 1414 |
% This macro starts the process of putting the table on the current |
| 1415 |
% page. It is not called until either a "\\" or "\endlongtable" command |
| 1416 |
% ends a chunk, as we do not know until that point which of the four |
| 1417 |
% possible head or foot sections have been specified. |
| 1418 |
% |
| 1419 |
% It begins by redefining itself, so that the table is only started |
| 1420 |
% once! Until V3.04, was redefined to "\relax", now use "\endgraf" to |
| 1421 |
% force the page-breaker to wake up. The second "\endgraf" is there so |
| 1422 |
% that "\pagetotal" is updated and so takes "\LTpre" into account. |
| 1423 |
% \begin{macrocode} |
| 1424 |
%<@@=tbl> |
| 1425 |
\ExplSyntaxOn |
| 1426 |
% \end{macrocode} |
| 1427 |
% |
| 1428 |
% \begin{macrocode} |
| 1429 |
\def\LT@start{% |
| 1430 |
\let\LT@start\endgraf |
| 1431 |
\endgraf\penalty\z@\vskip\LTpre\endgraf |
| 1432 |
% \end{macrocode} |
| 1433 |
% \changes{v4.14}{2020/02/07} |
| 1434 |
% {Guard against shrink glue on current page tools/3396 and github 183} |
| 1435 |
% This next block was suggested by Lars Hellström in pr tools/3396. |
| 1436 |
% He documents it as: |
| 1437 |
% |
| 1438 |
% The original problem occurs because TeX has not yet found an awfully bad |
| 1439 |
% "(b=*)" breakpoint and is therefore still collecting material to see if there |
| 1440 |
% is a really good break somewhere just ahead. As we know there aren't, we |
| 1441 |
% want to make it stop looking and break the page, so that "\pagetotal" will be |
| 1442 |
% for the page where the table will actually end up. To achieve this, we |
| 1443 |
% need to give \TeX\ an awfully bad, but legal, breakpoint. The simplest way of |
| 1444 |
% doing this seems to be to insert a "\kern" that counters the "\pageshrink" for |
| 1445 |
% the page, followed by a "\penalty" and a "\par" (to exercise the page builder). |
| 1446 |
% We also have to make sure that this breakpoint doesn't affect how the next |
| 1447 |
% page is broken, so we make the penalty 9999 (10000 is infinite and thus not |
| 1448 |
% a legal breakpoint) and cancel out the "\kern" with a new "\kern". |
| 1449 |
% |
| 1450 |
% I don't think this is the \emph{right} solution to the problem (that would be |
| 1451 |
% that the standard output routine has a feature for syncronizing with |
| 1452 |
% typesetting, as part of the preparations for switching output routine), but |
| 1453 |
% it's OK. Perhaps XOR will make it better. |
| 1454 |
% \begin{macrocode} |
| 1455 |
\ifdim \pagetotal<\pagegoal \else |
| 1456 |
\dimen@=\pageshrink |
| 1457 |
\advance \dimen@ 1sp % |
| 1458 |
\kern\dimen@\penalty 9999\endgraf \kern-\dimen@ |
| 1459 |
\fi |
| 1460 |
% \end{macrocode} |
| 1461 |
% Start a new page if there is not enough room for the table head, foot, |
| 1462 |
% and one extra line. |
| 1463 |
% \begin{macrocode} |
| 1464 |
\dimen@\pagetotal |
| 1465 |
\advance\dimen@ \ht\ifvoid\LT@firsthead\LT@head\else\LT@firsthead\fi |
| 1466 |
\advance\dimen@ \dp\ifvoid\LT@firsthead\LT@head\else\LT@firsthead\fi |
| 1467 |
\advance\dimen@ \ht\LT@foot |
| 1468 |
% \end{macrocode} |
| 1469 |
% \changes{v3.16}{1995/11/09} |
| 1470 |
% {Measure the first line of the table} |
| 1471 |
% \changes{v4.15}{2021/04/18} |
| 1472 |
% {silence \cs{vbadness}} |
| 1473 |
% At this point I used to add "\ht\@arstrutbox" and "\dp\@arstrutbox" |
| 1474 |
% as a measure of a row size. However this can fail spectacularly |
| 1475 |
% for "p" columns which might be much larger. Previous versions could |
| 1476 |
% end up with the table starting with a foot, then a page break then |
| 1477 |
% a head \emph{then} a `first head'! So now measure the first line of |
| 1478 |
% the table accurately by "\vsplit"ting it out of the first chunk. |
| 1479 |
% \begin{macrocode} |
| 1480 |
\edef\LT@reset@vfuzz{\vfuzz\the\vfuzz\vbadness\the\vbadness\relax}% |
| 1481 |
\vfuzz\maxdimen |
| 1482 |
\vbadness\@M |
| 1483 |
\setbox\tw@\copy\z@ |
| 1484 |
\setbox\tw@\vsplit\tw@ to \ht\@arstrutbox |
| 1485 |
\setbox\tw@\vbox{\unvbox\tw@}% |
| 1486 |
\LT@reset@vfuzz |
| 1487 |
\advance\dimen@ \ht |
| 1488 |
\ifdim\ht\@arstrutbox>\ht\tw@\@arstrutbox\else\tw@\fi |
| 1489 |
\advance\dimen@\dp |
| 1490 |
\ifdim\dp\@arstrutbox>\dp\tw@\@arstrutbox\else\tw@\fi |
| 1491 |
% \end{macrocode} |
| 1492 |
% |
| 1493 |
% \begin{macrocode} |
| 1494 |
\advance\dimen@ -\pagegoal |
| 1495 |
\ifdim \dimen@>\z@ |
| 1496 |
\vfil\break |
| 1497 |
\else |
| 1498 |
% \end{macrocode} |
| 1499 |
% |
| 1500 |
% \changes{v4.14}{2020/02/07} |
| 1501 |
% {Guard against shrink glue on current page see github 183} |
| 1502 |
% The LT output routine does not handle shrink on the page, which can cause |
| 1503 |
% the first page to be over-long, so forget it is there. |
| 1504 |
% \begin{macrocode} |
| 1505 |
\ifdim\pageshrink>\z@\pageshrink\z@\fi |
| 1506 |
\fi |
| 1507 |
% \end{macrocode} |
| 1508 |
% Store height of page minus table foot in "\@colroom". |
| 1509 |
% \changes{v3.14}{1995/05/02} |
| 1510 |
% {Set \cs{@colroom}, for tools/1584} |
| 1511 |
% \begin{macrocode} |
| 1512 |
\global\@colroom\@colht |
| 1513 |
% \end{macrocode} |
| 1514 |
% If the foot is non empty, reduce the "\vsize" and "\@colroom" |
| 1515 |
% accordingly. |
| 1516 |
% \changes{v4.14}{2020/02/07} |
| 1517 |
% {Rearrange vertical space tests for tools/3512 (floats on same page)} |
| 1518 |
% \begin{macrocode} |
| 1519 |
\ifvoid\LT@foot\else |
| 1520 |
\global\advance\vsize-\ht\LT@foot |
| 1521 |
\global\advance\@colroom-\ht\LT@foot |
| 1522 |
\dimen@\pagegoal\advance\dimen@-\ht\LT@foot\pagegoal\dimen@ |
| 1523 |
\maxdepth\z@ |
| 1524 |
\fi |
| 1525 |
% \end{macrocode} |
| 1526 |
% \changes{v4.21}{2024/07/04} |
| 1527 |
% {Use \cs{LTcaptype} to support other types beside table and handle |
| 1528 |
% the case if it is empty.} |
| 1529 |
% \begin{macrocode} |
| 1530 |
\tl_if_empty:eTF{\LTcaptype} |
| 1531 |
{ |
| 1532 |
\MakeLinkTarget{LT@tables} |
| 1533 |
} |
| 1534 |
{ |
| 1535 |
\MakeLinkTarget{\LTcaptype} |
| 1536 |
} |
| 1537 |
% \end{macrocode} |
| 1538 |
% Put the table head on the page, and then switch to the new output |
| 1539 |
% routine. |
| 1540 |
% \changes{v4.11}{2004/02/01} |
| 1541 |
% {\cs{nobreak}, for tools/3484} |
| 1542 |
% \begin{macrocode} |
| 1543 |
\ifvoid\LT@firsthead\copy\LT@head\else\box\LT@firsthead\fi\nobreak |
| 1544 |
% \end{macrocode} |
| 1545 |
% |
| 1546 |
% \changes{v4.19}{2023/12/16}{Support for tagged PDF} |
| 1547 |
% \begin{macrocode} |
| 1548 |
\UseTaggingSocket{tbl/longtable/head} |
| 1549 |
% \end{macrocode} |
| 1550 |
% |
| 1551 |
% \begin{macrocode} |
| 1552 |
\output{\LT@output}} |
| 1553 |
\ExplSyntaxOff |
| 1554 |
%<@@=> |
| 1555 |
% \end{macrocode} |
| 1556 |
% \end{macro} |
| 1557 |
% |
| 1558 |
% |
| 1559 |
% |
| 1560 |
% |
| 1561 |
% \begin{macro}{\endlongtable} |
| 1562 |
% |
| 1563 |
% \begin{macrocode} |
| 1564 |
%<@@=tbl> |
| 1565 |
\ExplSyntaxOn |
| 1566 |
% \end{macrocode} |
| 1567 |
% |
| 1568 |
% Called by "\end{longtable}". |
| 1569 |
% \begin{macrocode} |
| 1570 |
\def\endlongtable{% |
| 1571 |
% \end{macrocode} |
| 1572 |
% Essentially add a final "\\". But as we now know the number of |
| 1573 |
% actual chunks, we first strip away all entries referring to a |
| 1574 |
% maximum entry beyond the table (this can only happen if a table has |
| 1575 |
% been shortened, or the table numbering has gone awry). In that case |
| 1576 |
% we at least start collecting valid new information with the last |
| 1577 |
% chunk of this table, by removing the width constraint. |
| 1578 |
% \changes{v4.19}{2023/12/16}{Support for tagged PDF} |
| 1579 |
% \begin{macrocode} |
| 1580 |
\tbl_crcr:n {endlongtable} |
| 1581 |
% \end{macrocode} |
| 1582 |
% |
| 1583 |
% \changes{v4.01}{1996/04/11} |
| 1584 |
% {(DPC) use \cs{noalign} to sneak in \cs{LT@entry@chop}} |
| 1585 |
% \begin{macrocode} |
| 1586 |
\noalign{% |
| 1587 |
% \end{macrocode} |
| 1588 |
% |
| 1589 |
% \changes{v4.19}{2023/12/16}{Support for tagged PDF} |
| 1590 |
% \begin{macrocode} |
| 1591 |
\UseTaggingSocket{tbl/longtable/finalize} |
| 1592 |
% \end{macrocode} |
| 1593 |
% |
| 1594 |
% \begin{macrocode} |
| 1595 |
\let\LT@entry\LT@entry@chop |
| 1596 |
\xdef\LT@save@row{\LT@save@row}}% |
| 1597 |
\LT@echunk |
| 1598 |
\LT@start |
| 1599 |
\unvbox\z@ |
| 1600 |
\LT@get@widths |
| 1601 |
% \end{macrocode} |
| 1602 |
% Write the dummy row to the ".aux" file. |
| 1603 |
% Since V3.06, use ".lta" for "letter.sty". |
| 1604 |
% \changes{v3.12}{1994/06/30} |
| 1605 |
% {Do not write if \cs{nofiles} in operation.} |
| 1606 |
% \begin{macrocode} |
| 1607 |
\if@filesw |
| 1608 |
{\let\LT@entry\LT@entry@write\immediate\write\@auxout{% |
| 1609 |
% \end{macrocode} |
| 1610 |
% Since Version 3.02, \package{longtable} has used the internal counter |
| 1611 |
% "\c@LT@tables" rather than the \LaTeX\ counter \textsf{table}. This |
| 1612 |
% information looks entirely different from version~3 |
| 1613 |
% information. Still, we don't need to rename the macro name because |
| 1614 |
% later code will consider the information to have no columns, and |
| 1615 |
% thus will throw the old data away. |
| 1616 |
% \begin{macrocode} |
| 1617 |
\gdef\expandafter\noexpand |
| 1618 |
\csname LT@\romannumeral\c@LT@tables\endcsname |
| 1619 |
{\LT@save@row}}}% |
| 1620 |
\fi |
| 1621 |
% \end{macrocode} |
| 1622 |
% At this point used to |
| 1623 |
% issue a warning if a "\multicolumn" has been set in draft mode. |
| 1624 |
% \changes{v4.01}{1996/04/11} |
| 1625 |
% {(DPC) No need for multicolumn warnings} |
| 1626 |
%\begin{verbatim} |
| 1627 |
% \LT@mcw@rn |
| 1628 |
%\end{verbatim} |
| 1629 |
% If the last chunk has different widths than the first, warn the user. |
| 1630 |
% Also trigger a warning to rerun \LaTeX\ at the end of the document. |
| 1631 |
% \changes{v4.04}{1996/05/24} |
| 1632 |
% {Use \cs{LT@final@warn}} |
| 1633 |
% \begin{macrocode} |
| 1634 |
\ifx\LT@save@row\LT@@@@save@row |
| 1635 |
\else |
| 1636 |
\LT@warn{Column~ widths~ have~ changed\MessageBreak |
| 1637 |
in~ |
| 1638 |
\tl_if_empty:eTF{\LTcaptype} |
| 1639 |
{longtable~ \theLT@tables} |
| 1640 |
{\LTcaptype\c_space_tl\use:c{the\LTcaptype}} |
| 1641 |
} |
| 1642 |
\LT@final@warn |
| 1643 |
\fi |
| 1644 |
% \end{macrocode} |
| 1645 |
% Force one more go with the \env{longtable} output routine. |
| 1646 |
% Guard the special start of page value of "\pagegoal". |
| 1647 |
% \changes{v4.14}{2020/02/07} |
| 1648 |
% {Rearrange vertical space tests for tools/3512 (floats on same page)} |
| 1649 |
% \changes{v4.22}{2024/10/27} |
| 1650 |
% {Keep \cs{pagegoal} below \cs{maxdimen} gh1495} |
| 1651 |
% \begin{macrocode} |
| 1652 |
\endgraf\penalty -\LT@end@pen |
| 1653 |
\ifvoid\LT@foot\else |
| 1654 |
\global\advance\vsize\ht\LT@foot |
| 1655 |
\global\advance\@colroom\ht\LT@foot |
| 1656 |
\ifdim\pagegoal<\maxdimen |
| 1657 |
\dimen@\pagegoal\advance\dimen@\ht\LT@foot\pagegoal\dimen@ |
| 1658 |
\fi |
| 1659 |
\fi |
| 1660 |
% \end{macrocode} |
| 1661 |
% Now close the group to return to the standard routine. |
| 1662 |
% \begin{macrocode} |
| 1663 |
\endgroup |
| 1664 |
% \end{macrocode} |
| 1665 |
% Reset "\@mparbottom" to allow marginpars close to the end of the |
| 1666 |
% table.\footnote{This can not be the correct. However if it is omitted, |
| 1667 |
% there is a problem with marginpars, for example on page~3 of this |
| 1668 |
% document. Any Output Routine Gurus out there?} |
| 1669 |
% \changes{v4.14}{2020/02/07} |
| 1670 |
% {Rearrange vertical space tests for tools/3512 (floats on same page)} |
| 1671 |
% \begin{macrocode} |
| 1672 |
\global\@mparbottom\z@ |
| 1673 |
% \pagegoal\vsize |
| 1674 |
\endgraf\penalty\z@\addvspace\LTpost |
| 1675 |
% \end{macrocode} |
| 1676 |
% Footnotes. As done in the \package{multicol} package. |
| 1677 |
% \begin{macrocode} |
| 1678 |
\ifvoid\footins\else\insert\footins{}\fi |
| 1679 |
% \end{macrocode} |
| 1680 |
% |
| 1681 |
% \changes{v4.19}{2023/12/16}{Support for tagged PDF} |
| 1682 |
% \begin{macrocode} |
| 1683 |
\UseTaggingSocket{tbl/vmode/end}% |
| 1684 |
} |
| 1685 |
\ExplSyntaxOff |
| 1686 |
%<@@=> |
| 1687 |
% \end{macrocode} |
| 1688 |
% \end{macro} |
| 1689 |
% |
| 1690 |
% \subsection{Counting Columns} |
| 1691 |
% |
| 1692 |
% Columns are counted by examining "\@preamble", rather than simply |
| 1693 |
% getting "\@mkpream" to increment the counter as it builds the |
| 1694 |
% preamble so that this package works with many of the packages which |
| 1695 |
% add extra column specifiers to \LaTeX's standard ones. |
| 1696 |
% |
| 1697 |
% Version~1 counted "\@sharp"'s to calculate the number of columns, |
| 1698 |
% this was changed for Version~2 as it does not work with the NFSS. Now |
| 1699 |
% count "&"'s. ("lfonts.new" (and now the Standard \LaTeX\ definition) |
| 1700 |
% defines "\@tabclassz" so that "\@sharp" is inside a group.) |
| 1701 |
% |
| 1702 |
% \begin{macro}{\LT@nofcols} |
| 1703 |
% Find the next "&", then look ahead to see what is next. |
| 1704 |
% \begin{macrocode} |
| 1705 |
\def\LT@nofcols#1&{% |
| 1706 |
\futurelet\@let@token\LT@n@fcols} |
| 1707 |
% \end{macrocode} |
| 1708 |
% \end{macro} |
| 1709 |
% |
| 1710 |
% \begin{macro}{\LT@n@fcols} |
| 1711 |
% Add one, then stop at an "\LT@nofcols" or look for the next |
| 1712 |
% "&". The "\expandafter" trick was added in Version~3, also the |
| 1713 |
% name changed from "\@LT@nofcols" to preserve the "\LT@" naming |
| 1714 |
% convention. |
| 1715 |
% \begin{macrocode} |
| 1716 |
\def\LT@n@fcols{% |
| 1717 |
\advance\LT@cols\@ne |
| 1718 |
\ifx\@let@token\LT@nofcols |
| 1719 |
\expandafter\@gobble |
| 1720 |
\else |
| 1721 |
\expandafter\LT@nofcols |
| 1722 |
\fi} |
| 1723 |
% \end{macrocode} |
| 1724 |
% \end{macro} |
| 1725 |
% |
| 1726 |
% \subsection{The {\ttfamily\bslash\bslash} and \cs{kill} Commands} |
| 1727 |
% |
| 1728 |
% \begin{macro}{\LT@tabularcr} |
| 1729 |
% \changes{v4.05}{1996/11/12} |
| 1730 |
% {Code re-organised for the *-form processing.} |
| 1731 |
% The internal definition of "\\". |
| 1732 |
% In the "*" form, insert a "\nobreak" after the next "\cr" (or "\crcr"). |
| 1733 |
% |
| 1734 |
% This star form processing was finally added in v4.05. For the previous |
| 1735 |
% six or seven years the comment at this point said |
| 1736 |
% \begin{quote}\small |
| 1737 |
% This definition also accepts "\\*", which acts in the same way as |
| 1738 |
% "\\". \env{tabular} does this, but \env{longtable} probably ought to |
| 1739 |
% make "\\*" prevent page breaking. |
| 1740 |
% \end{quote} |
| 1741 |
% |
| 1742 |
% "{\ifnum0=`}\fi" added in version 3.01, required if the first entry |
| 1743 |
% is empty. |
| 1744 |
% The above in fact is not good enough, as with \package{array} package |
| 1745 |
% it can introduce a "{}" group in math mode, which changes the spacing. |
| 1746 |
% So use the following variant. Added in v3.14. |
| 1747 |
% \changes{v3.14}{1995/04/25} |
| 1748 |
% {More fun with \cs{ifnum} cf tools/1571} |
| 1749 |
% \changes{v4.15}{2021/04/21} |
| 1750 |
% {protected (gh/584)} |
| 1751 |
% \begin{macrocode} |
| 1752 |
\protected\def\LT@tabularcr{% |
| 1753 |
\relax\iffalse{\fi\ifnum0=`}\fi |
| 1754 |
\@ifstar |
| 1755 |
% \end{macrocode} |
| 1756 |
% TODO: as we replace crcr later in one case, we probably have to |
| 1757 |
% implement some further logic there! |
| 1758 |
% \begin{macrocode} |
| 1759 |
{\def\crcr{\LT@crcr\noalign{\nobreak}}\let\cr\crcr |
| 1760 |
\LT@t@bularcr}% |
| 1761 |
{\LT@t@bularcr}} |
| 1762 |
% \end{macrocode} |
| 1763 |
% \end{macro} |
| 1764 |
% |
| 1765 |
% \begin{macro}{\LT@crcr} |
| 1766 |
% \changes{v4.05}{1996/11/12} |
| 1767 |
% {Macro added} |
| 1768 |
% \begin{macrocode} |
| 1769 |
\let\LT@crcr\crcr |
| 1770 |
% \end{macrocode} |
| 1771 |
% \end{macro} |
| 1772 |
% |
| 1773 |
% \begin{macro}{\LT@setprevdepth} |
| 1774 |
% \changes{v4.05}{1996/11/12} |
| 1775 |
% {Macro added} |
| 1776 |
% \changes{v4.14}{2020/02/07} |
| 1777 |
% {spurious \cs{global} removed} |
| 1778 |
% This will be redefined to set the "\prevdepth" |
| 1779 |
% at the start of a chunk. |
| 1780 |
% \begin{macrocode} |
| 1781 |
\let\LT@setprevdepth\relax |
| 1782 |
% \end{macrocode} |
| 1783 |
% \end{macro} |
| 1784 |
% |
| 1785 |
% |
| 1786 |
% |
| 1787 |
% |
| 1788 |
% \begin{macro}{\LT@t@bularcr} |
| 1789 |
% \begin{macrocode} |
| 1790 |
%<@@=tbl> |
| 1791 |
\ExplSyntaxOn |
| 1792 |
\def\LT@t@bularcr{% |
| 1793 |
% \end{macrocode} |
| 1794 |
% Increment the counter, and do \env{tabular}'s "\\" or finish the |
| 1795 |
% chunk.\\ The "\expandafter" trick was added in Version~3. |
| 1796 |
% Set the "\prevdepth" at the start of a new chunk. (Done here |
| 1797 |
% so not set in header chunks.) |
| 1798 |
% \begin{macrocode} |
| 1799 |
\global\advance\LT@rows\@ne |
| 1800 |
\ifnum\LT@rows=\LTchunksize |
| 1801 |
% \end{macrocode} |
| 1802 |
% At the end of the chunk \verb=\\= is doing something special and |
| 1803 |
% so we lose \verb=\tbl_count_missing_cells:n=. Below is about the |
| 1804 |
% right place to add it do this code branch. |
| 1805 |
% \changes{v4.19}{2023/12/16}{Managing cell indexes} |
| 1806 |
% \begin{macrocode} |
| 1807 |
\tbl_count_missing_cells:n {echunk} |
| 1808 |
\gdef\LT@setprevdepth{% |
| 1809 |
\prevdepth\z@ |
| 1810 |
\global\let\LT@setprevdepth\relax}% |
| 1811 |
\expandafter\LT@xtabularcr |
| 1812 |
\else |
| 1813 |
\ifnum0=`{}\fi |
| 1814 |
\expandafter\LT@LL@FM@cr |
| 1815 |
\fi} |
| 1816 |
\ExplSyntaxOff |
| 1817 |
%<@@=> |
| 1818 |
% \end{macrocode} |
| 1819 |
% \end{macro} |
| 1820 |
% |
| 1821 |
% \begin{macro}{\LT@xtabularcr} |
| 1822 |
% This just looks for an optional argument. |
| 1823 |
% \begin{macrocode} |
| 1824 |
\def\LT@xtabularcr{% |
| 1825 |
\@ifnextchar[\LT@argtabularcr\LT@ntabularcr} |
| 1826 |
% \end{macrocode} |
| 1827 |
% \end{macro} |
| 1828 |
% |
| 1829 |
% \begin{macro}{\LT@ntabularcr} |
| 1830 |
% The version with no optional argument. |
| 1831 |
% "\ifnum0=`{\fi}" added in version 3.01. Changed in 3.14. |
| 1832 |
% \begin{macrocode} |
| 1833 |
\def\LT@ntabularcr{% |
| 1834 |
\ifnum0=`{}\fi |
| 1835 |
\LT@echunk |
| 1836 |
\LT@start |
| 1837 |
\unvbox\z@ |
| 1838 |
\LT@get@widths |
| 1839 |
\LT@bchunk} |
| 1840 |
% \end{macrocode} |
| 1841 |
% \end{macro} |
| 1842 |
% |
| 1843 |
% \begin{macro}{\LT@argtabularcr} |
| 1844 |
% The version with an optional argument. |
| 1845 |
% "\ifnum0=`{\fi}" added in version 3.01. Changed in 3.14. |
| 1846 |
% \begin{macrocode} |
| 1847 |
\def\LT@argtabularcr[#1]{% |
| 1848 |
\ifnum0=`{}\fi |
| 1849 |
\ifdim #1>\z@ |
| 1850 |
\unskip\@xargarraycr{#1}% |
| 1851 |
\else |
| 1852 |
\@yargarraycr{#1}% |
| 1853 |
\fi |
| 1854 |
% \end{macrocode} |
| 1855 |
% Add the dummy row, and finish the "\halign". |
| 1856 |
% \begin{macrocode} |
| 1857 |
\LT@echunk |
| 1858 |
\LT@start |
| 1859 |
\unvbox\z@ |
| 1860 |
\LT@get@widths |
| 1861 |
\LT@bchunk} |
| 1862 |
% \end{macrocode} |
| 1863 |
% \end{macro} |
| 1864 |
% |
| 1865 |
% \begin{macro}{\LT@echunk} |
| 1866 |
% \changes{v4.05}{1996/11/12} |
| 1867 |
% {\cs{unskip} added for pagebreak support} |
| 1868 |
% \changes{v4.14}{2020/02/07} |
| 1869 |
% {allocated global box (tools/2914)} |
| 1870 |
% This ends the current chunk, and removes the dummy row. |
| 1871 |
% \begin{macrocode} |
| 1872 |
\def\LT@echunk{% |
| 1873 |
\crcr\LT@save@row\cr\egroup |
| 1874 |
\global\setbox\LT@gbox\lastbox |
| 1875 |
% \end{macrocode} |
| 1876 |
% The following line was added in v4.05. |
| 1877 |
% \package{longtable} relies on "\lineskip" glue (which is 0pt) to |
| 1878 |
% provide break points between each row so the table may be split |
| 1879 |
% into pages. |
| 1880 |
% |
| 1881 |
% Previous releases left the "\lineskip" glue at the end of each chunk |
| 1882 |
% that had been added when the dummy row was added. There was no glue |
| 1883 |
% at the start of the next chunk as \TeX\ normally does not put |
| 1884 |
% "\lineskip" glue at the top of a box. This meant that normally the |
| 1885 |
% chunks fitted together perfectly, however "\noalign" material at a |
| 1886 |
% chunk boundary came before the first row of the next chunk |
| 1887 |
% but after the lineskip glue at the end of this chunk. This is the |
| 1888 |
% wrong place, e.g., it means even a "\penalty10000" does not stop a |
| 1889 |
% break as the "\lineskip" glue in the previous item on the list |
| 1890 |
% provides a legal breakpoint. So now remove the "\lineskip" glue that |
| 1891 |
% was before the dummy row and introduce "\LT@setprevdepth" to set the |
| 1892 |
% "\prevdepth" at the start of the next chunk, to make sure "\lineskip" |
| 1893 |
% glue is added later. |
| 1894 |
% \begin{macrocode} |
| 1895 |
\unskip |
| 1896 |
\egroup} |
| 1897 |
% \end{macrocode} |
| 1898 |
% \end{macro} |
| 1899 |
% |
| 1900 |
% \begin{macro}{\LT@entry} |
| 1901 |
% \changes{v4.00}{1996/04/08} |
| 1902 |
% {(DK) Macro added} |
| 1903 |
% \changes{v4.01}{1996/04/11} |
| 1904 |
% {(DPC) Use \cs{ifhmode} trick to determine first entry} |
| 1905 |
% We here give the `basic' definition of "\LT@entry", namely that used |
| 1906 |
% in alignment templates. It has a "\kern" only if the maximum is |
| 1907 |
% imposed from a different chunk. |
| 1908 |
% The "\ifhmode" test reveals the first entry, when we don't want to add |
| 1909 |
% an "&". |
| 1910 |
% \begin{macrocode} |
| 1911 |
\def\LT@entry#1#2{% |
| 1912 |
\ifhmode\@firstofone{&}\fi\omit |
| 1913 |
\ifnum#1=\c@LT@chunks |
| 1914 |
\else |
| 1915 |
\kern#2\relax |
| 1916 |
\fi} |
| 1917 |
% \end{macrocode} |
| 1918 |
% \end{macro} |
| 1919 |
% |
| 1920 |
% \begin{macro}{\LT@entry@chop} |
| 1921 |
% \changes{v4.00}{1996/04/08} |
| 1922 |
% {(DK) Macro added} |
| 1923 |
% This definition for the argument of "\LT@save@row" is used to scrap |
| 1924 |
% all those maxima which could not be verified because they occur |
| 1925 |
% after the end of the table. This can happen only if a table has been |
| 1926 |
% shortened (or the sequencing got mixed up) since the |
| 1927 |
% previous run. |
| 1928 |
% Note that this is premature: the last chunk still is going to be |
| 1929 |
% set, and with the chopped limits. |
| 1930 |
% \begin{macrocode} |
| 1931 |
\def\LT@entry@chop#1#2{% |
| 1932 |
\noexpand\LT@entry |
| 1933 |
{\ifnum#1>\c@LT@chunks |
| 1934 |
1}{0pt% |
| 1935 |
\else |
| 1936 |
#1}{#2% |
| 1937 |
\fi}} |
| 1938 |
% \end{macrocode} |
| 1939 |
% \end{macro} |
| 1940 |
% |
| 1941 |
% \begin{macro}{\LT@entry@write} |
| 1942 |
% \changes{v4.07}{1997/10/16} |
| 1943 |
% {Avoid use of percent. tools/2631} |
| 1944 |
% To write an entry for the "aux" file, we use a slightly |
| 1945 |
% surprising definition which has the sole purpose of avoiding |
| 1946 |
% overfull lines (which might break \TeX{}'s limits when reading the |
| 1947 |
% "aux" file, probably you'd need to have a few hundred columns before |
| 1948 |
% this happened but\ldots). |
| 1949 |
% \begin{macrocode} |
| 1950 |
\def\LT@entry@write{% |
| 1951 |
\noexpand\LT@entry^^J% |
| 1952 |
\@spaces} |
| 1953 |
% \end{macrocode} |
| 1954 |
% \end{macro} |
| 1955 |
% |
| 1956 |
% \begin{macro}{\LT@kill} |
| 1957 |
% This ends the current chunk as above, but strips off two rows, the |
| 1958 |
% `dummy row' and the `killed row' before starting the next chunk. |
| 1959 |
% Since V3.04, the old chunk is reboxed at the start of the box |
| 1960 |
% containing the next chunk. This allows "\kill" to be used in headers, |
| 1961 |
% which must be processed in a single box. |
| 1962 |
% \begin{macrocode} |
| 1963 |
\def\LT@kill{% |
| 1964 |
\LT@echunk |
| 1965 |
\LT@get@widths |
| 1966 |
\expandafter\LT@rebox\LT@bchunk} |
| 1967 |
% \end{macrocode} |
| 1968 |
% \end{macro} |
| 1969 |
% |
| 1970 |
% \begin{macro}{\LT@rebox} |
| 1971 |
% Drop the old chunk (box0) back at the top of the new chunk, removing |
| 1972 |
% the killed row. This macro added at V3.04. |
| 1973 |
% \begin{macrocode} |
| 1974 |
\def\LT@rebox#1\bgroup{% |
| 1975 |
#1\bgroup |
| 1976 |
\unvbox\z@ |
| 1977 |
\unskip |
| 1978 |
\setbox\z@\lastbox} |
| 1979 |
% \end{macrocode} |
| 1980 |
% \end{macro} |
| 1981 |
% |
| 1982 |
% \subsection{The Dummy Row} |
| 1983 |
% |
| 1984 |
% The dummy row is kept inside of the macro "\LT@save@row". |
| 1985 |
% |
| 1986 |
% \begin{macro}{\LT@blank@row} |
| 1987 |
% \begin{macro}{\LT@build@blank} |
| 1988 |
% \changes{v4.00}{1996/04/08} |
| 1989 |
% {(DK) Macro added} |
| 1990 |
% \changes{v4.01}{1996/04/11} |
| 1991 |
% {(DPC) Don't mess with \cs{multicolumn} on draft passes} |
| 1992 |
% Create a blank row if we are not using the info in the ".aux" file. |
| 1993 |
% \begin{macrocode} |
| 1994 |
\def\LT@blank@row{% |
| 1995 |
\xdef\LT@save@row{\expandafter\LT@build@blank |
| 1996 |
\romannumeral\number\LT@cols 001 }} |
| 1997 |
% \end{macrocode} |
| 1998 |
% Whoops! What's that supposed to be? A drop-in replacement for the |
| 1999 |
% first task of Appendix~D in the \TeX book. The "\romannumeral" |
| 2000 |
% produces "\LT@cols" instances of "m" followed by "i". The below |
| 2001 |
% macro then replaces the "m"s by appropriate entries. |
| 2002 |
% \begin{macrocode} |
| 2003 |
\def\LT@build@blank#1{% |
| 2004 |
\if#1m% |
| 2005 |
\noexpand\LT@entry{1}{0pt}% |
| 2006 |
\expandafter\LT@build@blank |
| 2007 |
\fi} |
| 2008 |
% \end{macrocode} |
| 2009 |
% \end{macro} |
| 2010 |
% \end{macro} |
| 2011 |
% |
| 2012 |
% \begin{macro}{\LT@make@row} |
| 2013 |
% \changes{v4.00}{1996/04/08} |
| 2014 |
% {(DK) New implementation} |
| 2015 |
% \changes{v4.01}{1996/04/11} |
| 2016 |
% {(DPC) Make this the default behaviour, not needing |
| 2017 |
% \cs{setlongtables}} |
| 2018 |
% |
| 2019 |
% Prior to version 4, by default did not use information in the |
| 2020 |
% ".aux" file but now we can define "\LT@make@row" to use the ".aux" |
| 2021 |
% file, even on the `draft' passes. |
| 2022 |
% \begin{macrocode} |
| 2023 |
\def\LT@make@row{% |
| 2024 |
\global\expandafter\let\expandafter\LT@save@row |
| 2025 |
\csname LT@\romannumeral\c@LT@tables\endcsname |
| 2026 |
\ifx\LT@save@row\relax |
| 2027 |
\LT@blank@row |
| 2028 |
% \end{macrocode} |
| 2029 |
% Now a slightly difficult part comes. Before we decide making the |
| 2030 |
% template from the ".aux" file info we check that the number of |
| 2031 |
% fields has remained the same. If it hasn't, either the table format |
| 2032 |
% has changed, or we have the wrong table altogether. In both cases, |
| 2033 |
% we decide to better drop all gathered information and start over. |
| 2034 |
% \changes{v4.01}{1996/04/11} |
| 2035 |
% {(DPC) Use \cs{if} test rather than \cs{ifx}\cs{@empty}} |
| 2036 |
% |
| 2037 |
% The expansion between "!"\ldots"!" below will be empty if the number |
| 2038 |
% of "\LT@entry" macros |
| 2039 |
% including arguments in "\LT@save@row" is equal to "\LT@cols". If it |
| 2040 |
% is not empty, we throw the row away and start from scratch. |
| 2041 |
% \begin{macrocode} |
| 2042 |
\else |
| 2043 |
{\let\LT@entry\or |
| 2044 |
\if!% |
| 2045 |
\ifcase\expandafter\expandafter\expandafter\LT@cols |
| 2046 |
\expandafter\@gobble\LT@save@row |
| 2047 |
\or |
| 2048 |
\else |
| 2049 |
\relax |
| 2050 |
\fi |
| 2051 |
!% |
| 2052 |
\else |
| 2053 |
\aftergroup\LT@blank@row |
| 2054 |
\fi}% |
| 2055 |
\fi} |
| 2056 |
% \end{macrocode} |
| 2057 |
% \end{macro} |
| 2058 |
% |
| 2059 |
% \begin{macro}{\setlongtables} |
| 2060 |
% Redefine "\LT@make@row" to use information in the ".aux" file, |
| 2061 |
% if there is a saved row for this table with the right number of |
| 2062 |
% columns. |
| 2063 |
% |
| 2064 |
% Since Version 3.02, \package{longtable} has used the internal counter |
| 2065 |
% "\c@LT@tables" rather than the \LaTeX\ counter \textsf{table}. |
| 2066 |
% The warning message was added at V3.04, as was the "\global", to stop |
| 2067 |
% save-stack overflow. |
| 2068 |
% |
| 2069 |
% Since Version 4.01 "\setlongtables" does nothing as it is not |
| 2070 |
% needed, but is defined as "\relax" for the benefit of old documents. |
| 2071 |
% \changes{v3.12}{1994/06/30} |
| 2072 |
% {Warning altered to fit line on terminal.} |
| 2073 |
% \changes{v4.01}{1996/04/11} |
| 2074 |
% {(DPC) make into no op} |
| 2075 |
% \begin{macrocode} |
| 2076 |
\let\setlongtables\relax |
| 2077 |
% \end{macrocode} |
| 2078 |
% \end{macro} |
| 2079 |
% |
| 2080 |
% \begin{macro}{\LT@get@widths} |
| 2081 |
% This is the heart of \package{longtable}. If it were not for the table |
| 2082 |
% head and foot, this macro together with the modified "\\" command |
| 2083 |
% would form the basis of quite a simple little package file for long |
| 2084 |
% tables. It is closely modelled on the "\endvrulealign" macro of |
| 2085 |
% appendix D of the \TeX book. |
| 2086 |
% \begin{macrocode} |
| 2087 |
\def\LT@get@widths{% |
| 2088 |
% \end{macrocode} |
| 2089 |
% "\global" added at V3.04, to stop save-stack overflow. |
| 2090 |
% \begin{macrocode} |
| 2091 |
% \end{macrocode} |
| 2092 |
% Loop through the last row, discarding glue, and saving box widths. At |
| 2093 |
% V3.04 changed the scratch box to 2, as the new "\kill" requires that |
| 2094 |
% "\box0" be preserved. |
| 2095 |
% \changes{v4.14}{2020/02/07} |
| 2096 |
% {allocated global box (tools/2914)} |
| 2097 |
% \begin{macrocode} |
| 2098 |
\setbox\tw@\hbox{% |
| 2099 |
\unhbox\LT@gbox |
| 2100 |
\let\LT@old@row\LT@save@row |
| 2101 |
\global\let\LT@save@row\@empty |
| 2102 |
\count@\LT@cols |
| 2103 |
\loop |
| 2104 |
\unskip |
| 2105 |
\setbox\tw@\lastbox |
| 2106 |
\ifhbox\tw@ |
| 2107 |
\LT@def@row |
| 2108 |
\advance\count@\m@ne |
| 2109 |
\repeat}% |
| 2110 |
% \end{macrocode} |
| 2111 |
% Remember the widths if we are in the first chunk. |
| 2112 |
% \begin{macrocode} |
| 2113 |
\ifx\LT@@save@row\@undefined |
| 2114 |
\let\LT@@save@row\LT@save@row |
| 2115 |
\fi} |
| 2116 |
% \end{macrocode} |
| 2117 |
% \end{macro} |
| 2118 |
% |
| 2119 |
% \begin{macro}{\LT@def@row} |
| 2120 |
% \changes{v4.00}{1996/04/08} |
| 2121 |
% {(DK) New implementation} |
| 2122 |
% Add a column to the dummy row. Name changed from "\defLT@save@row" |
| 2123 |
% in Version~3, to preserve the "\LT@" naming convention. |
| 2124 |
% \begin{macrocode} |
| 2125 |
\def\LT@def@row{% |
| 2126 |
% \end{macrocode} |
| 2127 |
% We start by picking the respective entry from our old row. |
| 2128 |
% These redefinitions of "\LT@entry" are local to the group started |
| 2129 |
% in "\LT@get@widths". |
| 2130 |
% \begin{macrocode} |
| 2131 |
\let\LT@entry\or |
| 2132 |
\edef\@tempa{% |
| 2133 |
\ifcase\expandafter\count@\LT@old@row |
| 2134 |
\else |
| 2135 |
{1}{0pt}% |
| 2136 |
\fi}% |
| 2137 |
% \end{macrocode} |
| 2138 |
% Now we tack the right combination in front of "\LT@save@row": |
| 2139 |
% \begin{macrocode} |
| 2140 |
\let\LT@entry\relax |
| 2141 |
\xdef\LT@save@row{% |
| 2142 |
\LT@entry |
| 2143 |
\expandafter\LT@max@sel\@tempa |
| 2144 |
\LT@save@row}} |
| 2145 |
% \end{macrocode} |
| 2146 |
% \end{macro} |
| 2147 |
% |
| 2148 |
% \begin{macro}{\LT@max@sel} |
| 2149 |
% \changes{v4.00}{1996/04/08} |
| 2150 |
% {(DK) macro added} |
| 2151 |
% \changes{v4.01}{1996/04/11} |
| 2152 |
% {(DPC) minor modifications} |
| 2153 |
% And this is how to select the right combination. Note that we take |
| 2154 |
% the old maximum information only if the size does not change in |
| 2155 |
% \emph{either} direction. If the size has grown, we of course have a |
| 2156 |
% new maximum. If the size has shrunk, the old maximum (which was |
| 2157 |
% explicitly not enforced because of being in the current chunk) is |
| 2158 |
% invalid, and we start with this chunk as the new size. Note that |
| 2159 |
% even in the case of equality we \emph{must} use the "\the\wd\tw@" |
| 2160 |
% construct instead of "#2" because "#2" might be read in from the |
| 2161 |
% file, and so could have "\catcode"~11 versions of "p" and~"t" in~it |
| 2162 |
% which we want to be replaced by their `proper' "\catcode"~12 versions. |
| 2163 |
% \begin{macrocode} |
| 2164 |
\def\LT@max@sel#1#2{% |
| 2165 |
{\ifdim#2=\wd\tw@ |
| 2166 |
#1% |
| 2167 |
\else |
| 2168 |
\number\c@LT@chunks |
| 2169 |
\fi}% |
| 2170 |
{\the\wd\tw@}} |
| 2171 |
% \end{macrocode} |
| 2172 |
% \end{macro} |
| 2173 |
% |
| 2174 |
% \subsection{The \cs{hline} Command} |
| 2175 |
% |
| 2176 |
% \begin{macro}{\LT@hline} |
| 2177 |
% "\hline" and "\hline\hline" both produce \emph{two} lines. |
| 2178 |
% The only difference being the glue and penalties between them. |
| 2179 |
% This is so that a page break at a "\hline" produces a line on both |
| 2180 |
% pages.\footnote |
| 2181 |
% {\env{longtable} has always done this, but perhaps it would be |
| 2182 |
% better if hlines were \emph{omitted} at a page break, as the head and |
| 2183 |
% foot usually put a hline here anyway.} |
| 2184 |
% Also this "\hline" is more like a "\cline{1-\LT@cols}". |
| 2185 |
% \env{tabular}'s "\hline" would draw lines the full width of the page. |
| 2186 |
% \begin{macrocode} |
| 2187 |
\def\LT@hline{% |
| 2188 |
\noalign{\ifnum0=`}\fi |
| 2189 |
\penalty\@M |
| 2190 |
\futurelet\@let@token\LT@@hline} |
| 2191 |
% \end{macrocode} |
| 2192 |
% \end{macro} |
| 2193 |
% |
| 2194 |
% \begin{macro}{\LT@@hline} |
| 2195 |
% This code is based on "\cline". Two copies of the line are produced, |
| 2196 |
% as described above. |
| 2197 |
% \begin{macrocode} |
| 2198 |
%<@@=tbl> |
| 2199 |
\ExplSyntaxOn |
| 2200 |
\def\LT@@@@hline{% |
| 2201 |
\ifx\@let@token\hline |
| 2202 |
\global\let\@gtempa\@gobble |
| 2203 |
\gdef\LT@sep{\penalty-\@medpenalty\vskip\doublerulesep}% |
| 2204 |
\else |
| 2205 |
\global\let\@gtempa\@empty |
| 2206 |
\gdef\LT@sep{\penalty-\@lowpenalty\vskip-\arrayrulewidth}% |
| 2207 |
\fi |
| 2208 |
\ifnum0=`{\fi}% |
| 2209 |
\multispan\LT@cols |
| 2210 |
\unskip\leaders\hrule\@height\arrayrulewidth\hfill\cr |
| 2211 |
% \end{macrocode} |
| 2212 |
% Don't update the row counter, or rather undo the update done in \cs{everycr}: |
| 2213 |
% \changes{v4.19}{2023/12/16}{Managing cell indexes} |
| 2214 |
% \begin{macrocode} |
| 2215 |
\noalign{ |
| 2216 |
\tbl_gdecr_row_count: |
| 2217 |
\LT@sep} |
| 2218 |
\multispan\LT@cols |
| 2219 |
\unskip\leaders\hrule\@height\arrayrulewidth\hfill\cr |
| 2220 |
% \end{macrocode} |
| 2221 |
% Same here. |
| 2222 |
% \changes{v4.19}{2023/12/16}{Managing cell indexes} |
| 2223 |
% \begin{macrocode} |
| 2224 |
\noalign{ |
| 2225 |
\tbl_gdecr_row_count: |
| 2226 |
\penalty\@M} |
| 2227 |
\@gtempa} |
| 2228 |
%<@@=> |
| 2229 |
% \end{macrocode} |
| 2230 |
% \end{macro} |
| 2231 |
% |
| 2232 |
% \subsection{Captions} |
| 2233 |
% |
| 2234 |
% \begin{macro}{\LT@caption} |
| 2235 |
% The caption is "\multicolumn{\LT@cols}{c}{"\meta{a parbox with the |
| 2236 |
% table's caption}"}" |
| 2237 |
% \begin{macrocode} |
| 2238 |
\def\LT@caption{% |
| 2239 |
\noalign\bgroup |
| 2240 |
\@ifnextchar[{\egroup\LT@c@ption\@firstofone}\LT@capti@n} |
| 2241 |
% \end{macrocode} |
| 2242 |
% \end{macro} |
| 2243 |
% |
| 2244 |
% \begin{macro}{\LT@c@ption} |
| 2245 |
% Caption command (with [optional argument]). "\protect" added in |
| 2246 |
% Version~3. "\fnum@table" added at V3.05. |
| 2247 |
% \changes{v3.14}{1995/05/02} |
| 2248 |
% {Call \cs{LT@makecaption} not \cs{LT@mkcaption}} |
| 2249 |
% \changes{v3.14}{1995/05/24} |
| 2250 |
% {Add new control argument} |
| 2251 |
% \changes{v4.16}{2021/05/07} |
| 2252 |
% {use \cs{ext@table} gh/561} |
| 2253 |
% \changes{v4.21}{2024/07/04} |
| 2254 |
% {Use \cs{LTcaptype} to support other types beside table.} |
| 2255 |
% \begin{macrocode} |
| 2256 |
\def\LT@c@ption#1[#2]#3{ |
| 2257 |
\tl_if_empty:eTF{\LTcaptype} |
| 2258 |
{\LT@makecaption\@gobble{}{#3}} |
| 2259 |
{\LT@makecaption#1{\csname fnum@\LTcaptype\endcsname}{#3} |
| 2260 |
\def\@tempa{#2} |
| 2261 |
\ifx\@tempa\@empty\else |
| 2262 |
{\let\\\space |
| 2263 |
\addcontentsline |
| 2264 |
{\@nameuse{ext@\LTcaptype}} |
| 2265 |
{\LTcaptype} |
| 2266 |
{\protect\numberline{\@nameuse{the\LTcaptype}}{#2}}} |
| 2267 |
\fi}} |
| 2268 |
\ExplSyntaxOff |
| 2269 |
% \end{macrocode} |
| 2270 |
% \end{macro} |
| 2271 |
% |
| 2272 |
% \begin{macro}{\LT@capti@n} |
| 2273 |
% Caption command (no [optional argument]) |
| 2274 |
% \changes{v3.14}{1995/05/02} |
| 2275 |
% {Call \cs{LT@makecaptionx} not \cs{LT@mkcaption}} |
| 2276 |
% \changes{v3.14}{1995/05/24} |
| 2277 |
% {Call \cs{LT@makecaption} with \cs{@gobble} or \cs{@firstofone}} |
| 2278 |
% \begin{macrocode} |
| 2279 |
\def\LT@capti@n{% |
| 2280 |
\@ifstar |
| 2281 |
{\egroup\LT@c@ption\@gobble[]}% |
| 2282 |
{\egroup\@xdblarg{\LT@c@ption\@firstofone}}} |
| 2283 |
% \end{macrocode} |
| 2284 |
% \end{macro} |
| 2285 |
% |
| 2286 |
% |
| 2287 |
% \begin{macro}{\LT@makecaption} |
| 2288 |
% Put the caption in a box of width 0pt, so that it never affects the |
| 2289 |
% column widths. Inside that is a "\parbox" of width |
| 2290 |
% "\LTcapwidth". |
| 2291 |
% \changes{v3.14}{1995/05/02} |
| 2292 |
% {Renamed from \cs{LT@mkcaption}, |
| 2293 |
% and modified to call \cs{@makecaption}} |
| 2294 |
% \changes{v3.14}{1995/05/02} |
| 2295 |
% {Use the first arg to remove counter for star form} |
| 2296 |
% \changes{v4.15}{2021/03/28} |
| 2297 |
% {\cs{reset@font} for gh/133} |
| 2298 |
% \begin{macrocode} |
| 2299 |
\def\LT@makecaption#1#2#3{% |
| 2300 |
\LT@mcol\LT@cols c{\hbox to\z@{\hss\parbox[t]\LTcapwidth{% |
| 2301 |
% \end{macrocode} |
| 2302 |
% Based on article class "\@makecaption", "#1" is "\@gobble" in star |
| 2303 |
% form, and "\@firstofone" otherwise. |
| 2304 |
% \begin{macrocode} |
| 2305 |
\reset@font |
| 2306 |
\sbox\@tempboxa{#1{#2: }#3}% |
| 2307 |
\ifdim\wd\@tempboxa>\hsize |
| 2308 |
#1{#2: }#3% |
| 2309 |
\else |
| 2310 |
\hbox to\hsize{\hfil\box\@tempboxa\hfil}% |
| 2311 |
\fi |
| 2312 |
\endgraf\vskip\baselineskip}% |
| 2313 |
\hss}}} |
| 2314 |
% \end{macrocode} |
| 2315 |
% \end{macro} |
| 2316 |
% |
| 2317 |
% |
| 2318 |
% \subsection{The Output Routine} |
| 2319 |
% |
| 2320 |
% The method used here for interfacing a special purpose output routine |
| 2321 |
% to the standard \LaTeX\ routine is lifted straight out of |
| 2322 |
% F.~Mittelbach's \package{multicol} package. |
| 2323 |
% |
| 2324 |
% \begin{macro}{\LT@output} |
| 2325 |
% Actually this is not so bad, with FM leading the way. |
| 2326 |
% \begin{macrocode} |
| 2327 |
\ExplSyntaxOn |
| 2328 |
\def\LT@output{% |
| 2329 |
\ifnum\outputpenalty <-\@Mi |
| 2330 |
\ifnum\outputpenalty > -\LT@end@pen |
| 2331 |
% \end{macrocode} |
| 2332 |
% If this was a float or a marginpar we complain. |
| 2333 |
% \begin{macrocode} |
| 2334 |
\LT@err{floats~ and~ marginpars~ not~ allowed~ in~ a~ longtable}\@ehc |
| 2335 |
\else |
| 2336 |
% \end{macrocode} |
| 2337 |
% We have reached the end of the table, on the scroll at least, |
| 2338 |
% \begin{macrocode} |
| 2339 |
\setbox\z@\vbox{\unvbox\@cclv}% |
| 2340 |
\ifdim \ht\LT@lastfoot>\ht\LT@foot |
| 2341 |
% \end{macrocode} |
| 2342 |
% The last foot might not fit, so:\footnote{An alternative would be to |
| 2343 |
% vsplit off a bit of the last chunk, so that the last page did not just |
| 2344 |
% have head and foot sections, but it is hard to do this in a consistent |
| 2345 |
% manner.} |
| 2346 |
% \changes{v4.14}{2020/02/07} |
| 2347 |
% {Rearrange vertical space tests for tools/3512 (floats on same page)} |
| 2348 |
% \changes{v4.24}{2024-10-13} |
| 2349 |
% {New mark update call gh/1814} |
| 2350 |
% \begin{macrocode} |
| 2351 |
\dimen@\pagegoal |
| 2352 |
\advance\dimen@\ht\LT@foot |
| 2353 |
\advance\dimen@-\ht\LT@lastfoot |
| 2354 |
\ifdim\dimen@<\ht\z@ |
| 2355 |
\setbox\@cclv\vbox{\unvbox\z@\copy\LT@foot\vss}% |
| 2356 |
\@makecol |
| 2357 |
\@expl@@@mark@update@singlecol@structures@@ |
| 2358 |
\@outputpage |
| 2359 |
\global\vsize\@colroom |
| 2360 |
\setbox\z@\vbox{\box\LT@head}% |
| 2361 |
% \end{macrocode} |
| 2362 |
% End of "\ifdim\dimen@<\ht\@cclc". |
| 2363 |
% \begin{macrocode} |
| 2364 |
\fi |
| 2365 |
% \end{macrocode} |
| 2366 |
% End of "\ifdim \ht\LT@lastfoot > \ht\LT@foot". |
| 2367 |
% \begin{macrocode} |
| 2368 |
\fi |
| 2369 |
% \end{macrocode} |
| 2370 |
% Reset "\@colroom". |
| 2371 |
% \changes{v3.14}{1995/05/02} |
| 2372 |
% {Reset \cs{@colroom}, for tools/1584} |
| 2373 |
% \changes{v4.14}{2020/02/07} |
| 2374 |
% {Rearrange vertical space tests for tools/3512 (floats on same page)} |
| 2375 |
% \begin{macrocode} |
| 2376 |
% \global\@colroom\@colht |
| 2377 |
% \global\vsize\@colht |
| 2378 |
% \end{macrocode} |
| 2379 |
% Put the last page of the table on to the main vertical list. |
| 2380 |
% \changes{v4.14}{2020/02/07} |
| 2381 |
% {Remove box from final page tools/3512} |
| 2382 |
% \begin{macrocode} |
| 2383 |
\unvbox\z@\box\ifvoid\LT@lastfoot\LT@foot\else\LT@lastfoot\fi |
| 2384 |
% \end{macrocode} |
| 2385 |
% Handle foot box when tagging: |
| 2386 |
% |
| 2387 |
% \changes{v4.19}{2023/12/16}{Support for tagged PDF} |
| 2388 |
% \begin{macrocode} |
| 2389 |
\UseTaggingSocket{tbl/longtable/foot} |
| 2390 |
% \end{macrocode} |
| 2391 |
% |
| 2392 |
% End of "\ifnum\outputpenalty > -\LT@end@pen". |
| 2393 |
% \begin{macrocode} |
| 2394 |
\fi |
| 2395 |
% \end{macrocode} |
| 2396 |
% Else "\outputpenalty > -\@Mi". |
| 2397 |
% \begin{macrocode} |
| 2398 |
\else |
| 2399 |
% \end{macrocode} |
| 2400 |
% If we have not reached the end of the table, |
| 2401 |
% \begin{macrocode} |
| 2402 |
\setbox\@cclv\vbox{\unvbox\@cclv\copy\LT@foot\vss}% |
| 2403 |
% \end{macrocode} |
| 2404 |
% |
| 2405 |
% Handle foot box when tagging: |
| 2406 |
% \changes{v4.19}{2023/12/16}{Support for tagged PDF} |
| 2407 |
% \begin{macrocode} |
| 2408 |
\UseTaggingSocket{tbl/longtable/foot} |
| 2409 |
% \end{macrocode} |
| 2410 |
% |
| 2411 |
% \begin{macrocode} |
| 2412 |
\@makecol |
| 2413 |
\@expl@@@mark@update@singlecol@structures@@ |
| 2414 |
\@outputpage |
| 2415 |
% \end{macrocode} |
| 2416 |
% Reset "\vsize". |
| 2417 |
% \changes{v3.14}{1995/05/02} |
| 2418 |
% {Reset \cs{vsize}, for tools/1584} |
| 2419 |
% \begin{macrocode} |
| 2420 |
\global\vsize\@colroom |
| 2421 |
% \end{macrocode} |
| 2422 |
% Put the head at the top of the next page. |
| 2423 |
% \changes{v4.11}{2004/02/01} |
| 2424 |
% {\cs{nobreak}, for tools/3484} |
| 2425 |
% \begin{macrocode} |
| 2426 |
\copy\LT@head\nobreak |
| 2427 |
% \end{macrocode} |
| 2428 |
% End of "\ifnum\outputpenalty <-\@Mi". |
| 2429 |
% \begin{macrocode} |
| 2430 |
\fi} |
| 2431 |
% \end{macrocode} |
| 2432 |
% |
| 2433 |
% \begin{macrocode} |
| 2434 |
\ExplSyntaxOff |
| 2435 |
%<@@=> |
| 2436 |
% \end{macrocode} |
| 2437 |
% \end{macro} |
| 2438 |
% |
| 2439 |
% |
| 2440 |
% |
| 2441 |
% \subsection{Commands for the table head and foot} |
| 2442 |
% |
| 2443 |
% \begin{macro}{\LT@end@hd@ft} |
| 2444 |
% The core of "\endhead" and friends. Store the current chunk in the |
| 2445 |
% box specified by "#1". Issue an error if the table has already |
| 2446 |
% started. Then start a new chunk. |
| 2447 |
% \begin{macrocode} |
| 2448 |
%<@@=tbl> |
| 2449 |
\ExplSyntaxOn |
| 2450 |
\def\LT@end@hd@ft#1{% |
| 2451 |
% \end{macrocode} |
| 2452 |
% |
| 2453 |
% This command is used to store the head and foot boxes. |
| 2454 |
% We need to retrieve and store the row so that we can clean |
| 2455 |
% up the structure in the finalize code. |
| 2456 |
% |
| 2457 |
% To handle missing columns in the header we need this: |
| 2458 |
% \changes{v4.19}{2023/12/16}{Managing cell indexes} |
| 2459 |
% \begin{macrocode} |
| 2460 |
\tbl_if_row_was_started:TF |
| 2461 |
{ |
| 2462 |
% \end{macrocode} |
| 2463 |
% TODO: This is exposing internal counters, so it should be encapsulated |
| 2464 |
% in some interface command (but I'm not sure what that should be |
| 2465 |
% called, so not done yet. |
| 2466 |
% \changes{v4.19}{2023/12/16}{Managing cell indexes} |
| 2467 |
% \begin{macrocode} |
| 2468 |
\tbl_count_missing_cells:n {head/foot} |
| 2469 |
\int_step_inline:nn |
| 2470 |
{ \LT@rows + 1 } |
| 2471 |
{ |
| 2472 |
\seq_gput_left:ce |
| 2473 |
{g_@@_\cs_to_str:N #1 _rows_seq } |
| 2474 |
{ \int_eval:n {\g_@@_row_int + 1 - ##1 } } |
| 2475 |
} |
| 2476 |
% \end{macrocode} |
| 2477 |
% We also have to set the chunk rows to its max value before |
| 2478 |
% calling \cs{LTechunk} so that we don't get extra increments of |
| 2479 |
% the main row counter due to \cs{everycr}. |
| 2480 |
% \begin{macrocode} |
| 2481 |
\int_gset:Nn \LT@rows { \LTchunksize } |
| 2482 |
} |
| 2483 |
% \end{macrocode} |
| 2484 |
|
| 2485 |
% If we are still in column zero then we had an empty \cs{endhead} |
| 2486 |
% and so making any assignment, etc., would start a row --- something we don't want. |
| 2487 |
% To get out of this trap we run \cs{crcr} (which would normally |
| 2488 |
% come inside \cs{LT@echunk}. That will then trigger \cs{everycr} |
| 2489 |
% and update row counter unnecessarily, but now we have a defined state, so |
| 2490 |
% we can use \cs{noalign} to undo that. |
| 2491 |
% We also change \cs{LT@rows} so that further \cs{cr}s do not do |
| 2492 |
% any harm (as explained above. |
| 2493 |
% |
| 2494 |
% The \cs{crcr} inside \cs{LT@echunk} will be bypassed in that case |
| 2495 |
% as we have just executed a \cs{crcr} and are still in scanning modus for |
| 2496 |
% \cs{omit} or \cs{noalign}. |
| 2497 |
% \begin{macrocode} |
| 2498 |
{ |
| 2499 |
\crcr |
| 2500 |
\noalign{ |
| 2501 |
% \end{macrocode} |
| 2502 |
% \changes{v4.22}{2024/08/13}{Store header row numbers} |
| 2503 |
% \begin{macrocode} |
| 2504 |
\int_step_inline:nn |
| 2505 |
{ \LT@rows } |
| 2506 |
{ |
| 2507 |
\seq_gput_left:ce |
| 2508 |
{g_@@_\cs_to_str:N #1 _rows_seq } |
| 2509 |
{ \int_eval:n {\g_@@_row_int - ##1 } } |
| 2510 |
} |
| 2511 |
% \end{macrocode} |
| 2512 |
% \changes{v4.19}{2023/12/16}{Managing cell indexes} |
| 2513 |
% \begin{macrocode} |
| 2514 |
\tbl_gdecr_row_count: % undo the increment |
| 2515 |
\int_gset:Nn \LT@rows { \LTchunksize } |
| 2516 |
} |
| 2517 |
} |
| 2518 |
\LT@echunk |
| 2519 |
% \end{macrocode} |
| 2520 |
% Changed from "\relax" to "\endgraf" at V3.04, see "\LT@start". |
| 2521 |
% \begin{macrocode} |
| 2522 |
\ifx\LT@start\endgraf |
| 2523 |
\LT@err |
| 2524 |
{Longtable~ head~ or~ foot~ not~ at~ start~ of~ table}% |
| 2525 |
{Increase~ LTchunksize}% |
| 2526 |
\fi |
| 2527 |
\setbox#1\box\z@ |
| 2528 |
\@@_trace:n {-->>~ Saving~\noexpand#1} |
| 2529 |
\LT@get@widths |
| 2530 |
\LT@bchunk} |
| 2531 |
% \end{macrocode} |
| 2532 |
% |
| 2533 |
% \begin{macrocode} |
| 2534 |
\ExplSyntaxOff |
| 2535 |
%<@@=> |
| 2536 |
% \end{macrocode} |
| 2537 |
% \end{macro} |
| 2538 |
% |
| 2539 |
% \begin{macro}{\endfirsthead} |
| 2540 |
% \begin{macro}{\endhead} |
| 2541 |
% \begin{macro}{\endfoot} |
| 2542 |
% \begin{macro}{\endlastfoot} |
| 2543 |
% Call "\LT@end@hd@ft" with the appropriate box. |
| 2544 |
% \begin{macrocode} |
| 2545 |
\def\endfirsthead{\LT@end@hd@ft\LT@firsthead} |
| 2546 |
\def\endhead{\LT@end@hd@ft\LT@head} |
| 2547 |
\def\endfoot{\LT@end@hd@ft\LT@foot} |
| 2548 |
\def\endlastfoot{\LT@end@hd@ft\LT@lastfoot} |
| 2549 |
% \end{macrocode} |
| 2550 |
% \end{macro} |
| 2551 |
% \end{macro} |
| 2552 |
% \end{macro} |
| 2553 |
% \end{macro} |
| 2554 |
% |
| 2555 |
% \subsection{The \cs{multicolumn} command} |
| 2556 |
% |
| 2557 |
% Earlier versions needed a special `draft' form of "\multicolumn". |
| 2558 |
% This is not needed in version~4, and so these commands have been |
| 2559 |
% removed. |
| 2560 |
% |
| 2561 |
% \begin{macro}{\LTmulticolumn} |
| 2562 |
% \changes{v4.01}{1996/04/11} |
| 2563 |
% {(DPC) macro removed} |
| 2564 |
% \end{macro} |
| 2565 |
% |
| 2566 |
% \begin{macro}{\LT@mcwarn} |
| 2567 |
% \changes{v4.01}{1996/04/11} |
| 2568 |
% {(DPC) macro removed} |
| 2569 |
% \end{macro} |
| 2570 |
% |
| 2571 |
% \subsection{Footnotes} |
| 2572 |
% |
| 2573 |
% The standard "\footnote" command works in a "c" column, but we |
| 2574 |
% need to modify the definition in a "p" column to overcome the |
| 2575 |
% extra level of boxing. These macros are based on the \package{array} |
| 2576 |
% package, but should be OK for the standard \env{tabular}. |
| 2577 |
% |
| 2578 |
% \begin{macro}{\LT@startpbox} |
| 2579 |
% \changes{v4.09}{1998/05/13} |
| 2580 |
% {Use \cs{setlength}, so that calc extensions apply. tools/2793} |
| 2581 |
% Add extra code to switch the definition of "\@footnotetext". |
| 2582 |
% \begin{macrocode} |
| 2583 |
\def\LT@startpbox#1{% |
| 2584 |
\bgroup |
| 2585 |
% \end{macrocode} |
| 2586 |
% \changes{v4.12}{2019/02/06}{Color group to match array package} |
| 2587 |
% \changes{v4.18}{2023/08/25}{Use \cs{everypar} to match array package, github 1128} |
| 2588 |
% \begin{macrocode} |
| 2589 |
\color@begingroup |
| 2590 |
\let\@footnotetext\LT@p@ftntext |
| 2591 |
\setlength\hsize{#1}% |
| 2592 |
\@arrayparboxrestore |
| 2593 |
\everypar{% |
| 2594 |
\vrule \@height \ht\@arstrutbox \@width \z@ |
| 2595 |
\everypar{}}% |
| 2596 |
} |
| 2597 |
% \end{macrocode} |
| 2598 |
% \end{macro} |
| 2599 |
% |
| 2600 |
% \begin{macro}{\LT@endpbox} |
| 2601 |
% After the parbox is closed, expand "\LT@p@ftn" which will execute a |
| 2602 |
% series of\\ |
| 2603 |
% "\footnotetext["\meta{num}"]{"\meta{note}"}"\\ |
| 2604 |
% commands. After being lifted out of the parbox, they can migrate on |
| 2605 |
% their own from here. |
| 2606 |
% \changes{v3.10}{1994/05/15} |
| 2607 |
% {Use \cs{@finalstrut}} |
| 2608 |
% \changes{v4.03}{1996/05/07} |
| 2609 |
% {Use \cs{hfil} for tools/2120} |
| 2610 |
% \begin{macrocode} |
| 2611 |
\def\LT@endpbox{% |
| 2612 |
\@finalstrut\@arstrutbox |
| 2613 |
% \end{macrocode} |
| 2614 |
% \changes{v4.12}{2019/02/06}{Color group to match array package} |
| 2615 |
% \begin{macrocode} |
| 2616 |
\color@endgroup |
| 2617 |
\egroup |
| 2618 |
\the\LT@p@ftn |
| 2619 |
\global\LT@p@ftn{}% |
| 2620 |
\hfil} |
| 2621 |
% \end{macrocode} |
| 2622 |
% \end{macro} |
| 2623 |
% |
| 2624 |
% \begin{macro}{\LT@p@ftntext} |
| 2625 |
% \changes{v4.15}{2021/03/28} |
| 2626 |
% {make long for gh/364} |
| 2627 |
% Inside the `p' column, just save up the footnote text in a token |
| 2628 |
% register. |
| 2629 |
% \begin{macrocode} |
| 2630 |
\long\def\LT@p@ftntext#1{% |
| 2631 |
\edef\@tempa{\the\LT@p@ftn\noexpand\footnotetext[\the\c@footnote]}% |
| 2632 |
\global\LT@p@ftn\expandafter{\@tempa{#1}}}% |
| 2633 |
% \end{macrocode} |
| 2634 |
% \end{macro} |
| 2635 |
% |
| 2636 |
% |
| 2637 |
% |
| 2638 |
% |
| 2639 |
% |
| 2640 |
% Some variables need for the tagging support. |
| 2641 |
% \begin{macrocode} |
| 2642 |
%<@@=tbl> |
| 2643 |
\ExplSyntaxOn |
| 2644 |
\seq_new:N \g_@@_LT@firsthead_rows_seq |
| 2645 |
\seq_new:N \g_@@_LT@head_rows_seq |
| 2646 |
\seq_new:N \g_@@_LT@lastfoot_rows_seq |
| 2647 |
\seq_new:N \g_@@_LT@foot_rows_seq |
| 2648 |
\ExplSyntaxOff |
| 2649 |
%<@@=> |
| 2650 |
% \end{macrocode} |
| 2651 |
% |
| 2652 |
% |
| 2653 |
% |
| 2654 |
% \begin{macrocode} |
| 2655 |
%</package> |
| 2656 |
% \end{macrocode} |
| 2657 |
% |
| 2658 |
% \Finale |
| 2659 |
\endinput |