Debian Codegraph @

texmf-dist/tex/latex/tools/longtable.sty

raw
1 %%
2 %% This is file `longtable.sty',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% longtable.dtx (with options: `package')
8 %%
9 %% This is a generated file.
10 %%
11 %% The source is maintained by the LaTeX Project team and bug
12 %% reports for it can be opened at https://latex-project.org/bugs/
13 %% (but please observe conditions on bug reports sent to that address!)
14 %%
15 %% Copyright (C) 1993-2025
16 %% The LaTeX Project and any individual authors listed elsewhere
17 %% in this file.
18 %%
19 %% This file was generated from file(s) of the Standard LaTeX `Tools Bundle'.
20 %% --------------------------------------------------------------------------
21 %%
22 %% It may be distributed and/or modified under the
23 %% conditions of the LaTeX Project Public License, either version 1.3c
24 %% of this license or (at your option) any later version.
25 %% The latest version of this license is in
26 %% https://www.latex-project.org/lppl.txt
27 %% and version 1.3c or later is part of all distributions of LaTeX
28 %% version 2005/12/01 or later.
29 %%
30 %% This file may only be distributed together with a copy of the LaTeX
31 %% `Tools Bundle'. You may however distribute the LaTeX `Tools Bundle'
32 %% without such generated files.
33 %%
34 %% The list of all files belonging to the LaTeX `Tools Bundle' is
35 %% given in the file `manifest.txt'.
36 %%
37 %% File: longtable.dtx Copyright (C) 1990-2020 David Carlisle
38 \NeedsTeXFormat{LaTeX2e}[1995/06/01]
39
40 \DeclareRelease{}{1994-06-01}{longtable-2020-01-07.sty}
41
42 \DeclareRelease{v4.13}{2020-01-02}{longtable-2020-01-07.sty}
43 \DeclareCurrentRelease{}{2020-02-07}
44
45 \ProvidesPackage{longtable}
46 [2025-10-13 v4.24 Multi-page Table package (DPC)]
47 \def\LT@err{\PackageError{longtable}}
48 \def\LT@warn{\PackageWarning{longtable}}
49 \def\LT@final@warn{%
50 \AtEndDocument{%
51 \LT@warn{Table \@width s have changed. Rerun LaTeX.\@gobbletwo}}%
52 \global\let\LT@final@warn\relax}
53 \DeclareOption{errorshow}{%
54 \def\LT@warn{\PackageInfo{longtable}}}
55 \DeclareOption{pausing}{%
56 \def\LT@warn#1{%
57 \LT@err{#1}{This is not really an error}}}
58 \DeclareOption{set}{}
59 \DeclareOption{final}{}
60 \ProcessOptions
61 \newskip\LTleft \LTleft=\fill
62 \newskip\LTright \LTright=\fill
63 \newskip\LTpre \LTpre=\bigskipamount
64 \newskip\LTpost \LTpost=\bigskipamount
65 \newcount\LTchunksize \LTchunksize=200
66 \let\c@LTchunksize\LTchunksize
67 \newdimen\LTcapwidth \LTcapwidth=4in
68 \providecommand\LTcaptype{table}
69 \newbox\LT@head
70 \newbox\LT@firsthead
71 \newbox\LT@foot
72 \newbox\LT@lastfoot
73 \newbox\LT@gbox
74 \newcount\LT@cols
75 \newcount\LT@rows
76 \newcounter{LT@tables}
77 \providecommand\theHLT@tables{\theLT@tables}
78 \newcounter{LT@chunks}[LT@tables]
79 \ifx\c@table\undefined
80 \newcounter{table}
81 \def\fnum@table{\tablename~\thetable}
82 \fi
83 \ifx\tablename\undefined
84 \def\tablename{Table}
85 \fi
86 \ifx\ext@table\undefined
87 \def\ext@table{lot}
88 \fi
89 \newtoks\LT@p@ftn
90 \mathchardef\LT@end@pen=30000
91 \def\longtable{%
92 \par
93 \if@noskipsec\mbox{}\par\fi
94 \@nobreakfalse
95 \ifx\multicols\@undefined
96 \else
97 \ifnum\col@number>\@ne
98 \@twocolumntrue
99 \fi
100 \fi
101 \if@twocolumn
102 \LT@err{longtable not in 1-column mode}\@ehc
103 \fi
104 \UseTaggingSocket{tbl/vmode/begin}%
105 \begingroup
106 \@ifnextchar[\LT@array{\LT@array[x]}}
107 \ExplSyntaxOn
108 \def\LT@array[#1]#2{%
109 \UseTaggingSocket{tbl/init}
110 \tl_if_empty:eTF { \LTcaptype }
111 {
112 \tl_gset:Ne \@currentHref {LT@tables.\theHLT@tables}
113 }
114 {
115 \@kernel@refstepcounter{\LTcaptype}\stepcounter{LT@tables}
116 \tl_gset:Ne \@currentHref {\LTcaptype.\cs_if_exist_use:c {theH\LTcaptype}}
117 }
118 \tbl_gzero_row_count:
119 \UseTaggingSocket{tbl/longtable/init}
120 \if l#1%
121 \LTleft\z@ \LTright\fill
122 \else\if r#1%
123 \LTleft\fill \LTright\z@
124 \else\if c#1%
125 \LTleft\fill \LTright\fill
126 \fi\fi\fi
127 \let\LT@mcol\multicolumn
128 \let\LT@@tabarray\@tabarray
129 \let\LT@@hl\hline
130 \def\@tabarray{%
131 \let\hline\LT@@hl
132 \LT@@tabarray}%
133 \let\\\LT@tabularcr
134 \let\tabularnewline\\%
135 \def\newpage{\noalign{\break}}%
136 \def\pagebreak{\noalign{\ifnum`}=0\fi\@testopt{\LT@no@pgbk-}4}%
137 \def\nopagebreak{\noalign{\ifnum`}=0\fi\@testopt\LT@no@pgbk4}%
138 \let\hline\LT@hline \let\kill\LT@kill\let\caption\LT@caption
139 \@tempdima\ht\strutbox
140 \let\@endpbox\LT@endpbox
141 \ifx\extrarowheight\@undefined
142 \let\@acol\@tabacol
143 \let\@classz\@tabclassz \let\@classiv\@tabclassiv
144 \def\@startpbox{\vtop\LT@startpbox}%
145 \let\@@startpbox\@startpbox
146 \let\@@endpbox\@endpbox
147 \let\LT@LL@FM@cr\@tabularcr
148 \else
149 \advance\@tempdima\extrarowheight
150 \col@sep\tabcolsep
151 \let\@startpbox@action\LT@startpbox
152 \let\LT@LL@FM@cr\@arraycr
153 \fi
154 \setbox\@arstrutbox\hbox{\vrule
155 \@height \arraystretch \@tempdima
156 \@depth \arraystretch \dp \strutbox
157 \@width \z@}%
158 \let\@sharp##\let\protect\relax
159 \begingroup
160 \@mkpream{#2}%
161 \tbl_count_table_cols:
162 \xdef\LT@bchunk{%
163 \tbl_inbetween_rows:
164 \global\advance\c@LT@chunks\@ne
165 \global\LT@rows\z@\setbox\z@\vbox\bgroup
166 \LT@setprevdepth
167 \tabskip\LTleft \noexpand\halign to\hsize\bgroup
168 \tabskip\z@ \@arstrut
169 \UseTaggingSocket{tbl/row/begin}%
170 \tbl_init_cell_data_for_row:
171 \@preamble \tabskip\LTright \cr}%
172 \endgroup
173 \expandafter\LT@nofcols\LT@bchunk&\LT@nofcols
174 \LT@make@row
175 \m@th\let\par\@empty
176 \everycr{%
177 \noalign{%
178 \__tbl_trace:n {--longtable-->~chunk~row:~ \the\LT@rows \space
179 row:~ \the\g__tbl_row_int \space
180 column:~ \the\g__tbl_col_int
181 }
182 \tbl_if_row_was_started:T
183 {
184 \UseTaggingSocket{tbl/row/end}
185 \tbl_inbetween_rows:
186 }
187 \int_compare:nNnT \LT@rows < \LTchunksize
188 { \tbl_gincr_row_count: } % next is row about to start
189 }%
190 }%
191 \lineskip\z@\baselineskip\z@
192 \LT@bchunk}
193 \ExplSyntaxOff
194 \def\LT@no@pgbk#1[#2]{\penalty #1\@getpen{#2}\ifnum`{=0\fi}}
195 \ExplSyntaxOn
196 \def\LT@start{%
197 \let\LT@start\endgraf
198 \endgraf\penalty\z@\vskip\LTpre\endgraf
199 \ifdim \pagetotal<\pagegoal \else
200 \dimen@=\pageshrink
201 \advance \dimen@ 1sp %
202 \kern\dimen@\penalty 9999\endgraf \kern-\dimen@
203 \fi
204 \dimen@\pagetotal
205 \advance\dimen@ \ht\ifvoid\LT@firsthead\LT@head\else\LT@firsthead\fi
206 \advance\dimen@ \dp\ifvoid\LT@firsthead\LT@head\else\LT@firsthead\fi
207 \advance\dimen@ \ht\LT@foot
208 \edef\LT@reset@vfuzz{\vfuzz\the\vfuzz\vbadness\the\vbadness\relax}%
209 \vfuzz\maxdimen
210 \vbadness\@M
211 \setbox\tw@\copy\z@
212 \setbox\tw@\vsplit\tw@ to \ht\@arstrutbox
213 \setbox\tw@\vbox{\unvbox\tw@}%
214 \LT@reset@vfuzz
215 \advance\dimen@ \ht
216 \ifdim\ht\@arstrutbox>\ht\tw@\@arstrutbox\else\tw@\fi
217 \advance\dimen@\dp
218 \ifdim\dp\@arstrutbox>\dp\tw@\@arstrutbox\else\tw@\fi
219 \advance\dimen@ -\pagegoal
220 \ifdim \dimen@>\z@
221 \vfil\break
222 \else
223 \ifdim\pageshrink>\z@\pageshrink\z@\fi
224 \fi
225 \global\@colroom\@colht
226 \ifvoid\LT@foot\else
227 \global\advance\vsize-\ht\LT@foot
228 \global\advance\@colroom-\ht\LT@foot
229 \dimen@\pagegoal\advance\dimen@-\ht\LT@foot\pagegoal\dimen@
230 \maxdepth\z@
231 \fi
232 \tl_if_empty:eTF{\LTcaptype}
233 {
234 \MakeLinkTarget{LT@tables}
235 }
236 {
237 \MakeLinkTarget{\LTcaptype}
238 }
239 \ifvoid\LT@firsthead\copy\LT@head\else\box\LT@firsthead\fi\nobreak
240 \UseTaggingSocket{tbl/longtable/head}
241 \output{\LT@output}}
242 \ExplSyntaxOff
243 \ExplSyntaxOn
244 \def\endlongtable{%
245 \tbl_crcr:n {endlongtable}
246 \noalign{%
247 \UseTaggingSocket{tbl/longtable/finalize}
248 \let\LT@entry\LT@entry@chop
249 \xdef\LT@save@row{\LT@save@row}}%
250 \LT@echunk
251 \LT@start
252 \unvbox\z@
253 \LT@get@widths
254 \if@filesw
255 {\let\LT@entry\LT@entry@write\immediate\write\@auxout{%
256 \gdef\expandafter\noexpand
257 \csname LT@\romannumeral\c@LT@tables\endcsname
258 {\LT@save@row}}}%
259 \fi
260 \ifx\LT@save@row\LT@@save@row
261 \else
262 \LT@warn{Column~ widths~ have~ changed\MessageBreak
263 in~
264 \tl_if_empty:eTF{\LTcaptype}
265 {longtable~ \theLT@tables}
266 {\LTcaptype\c_space_tl\use:c{the\LTcaptype}}
267 }
268 \LT@final@warn
269 \fi
270 \endgraf\penalty -\LT@end@pen
271 \ifvoid\LT@foot\else
272 \global\advance\vsize\ht\LT@foot
273 \global\advance\@colroom\ht\LT@foot
274 \ifdim\pagegoal<\maxdimen
275 \dimen@\pagegoal\advance\dimen@\ht\LT@foot\pagegoal\dimen@
276 \fi
277 \fi
278 \endgroup
279 \global\@mparbottom\z@
280 \endgraf\penalty\z@\addvspace\LTpost
281 \ifvoid\footins\else\insert\footins{}\fi
282 \UseTaggingSocket{tbl/vmode/end}%
283 }
284 \ExplSyntaxOff
285 \def\LT@nofcols#1&{%
286 \futurelet\@let@token\LT@n@fcols}
287 \def\LT@n@fcols{%
288 \advance\LT@cols\@ne
289 \ifx\@let@token\LT@nofcols
290 \expandafter\@gobble
291 \else
292 \expandafter\LT@nofcols
293 \fi}
294 \protected\def\LT@tabularcr{%
295 \relax\iffalse{\fi\ifnum0=`}\fi
296 \@ifstar
297 {\def\crcr{\LT@crcr\noalign{\nobreak}}\let\cr\crcr
298 \LT@t@bularcr}%
299 {\LT@t@bularcr}}
300 \let\LT@crcr\crcr
301 \let\LT@setprevdepth\relax
302 \ExplSyntaxOn
303 \def\LT@t@bularcr{%
304 \global\advance\LT@rows\@ne
305 \ifnum\LT@rows=\LTchunksize
306 \tbl_count_missing_cells:n {echunk}
307 \gdef\LT@setprevdepth{%
308 \prevdepth\z@
309 \global\let\LT@setprevdepth\relax}%
310 \expandafter\LT@xtabularcr
311 \else
312 \ifnum0=`{}\fi
313 \expandafter\LT@LL@FM@cr
314 \fi}
315 \ExplSyntaxOff
316 \def\LT@xtabularcr{%
317 \@ifnextchar[\LT@argtabularcr\LT@ntabularcr}
318 \def\LT@ntabularcr{%
319 \ifnum0=`{}\fi
320 \LT@echunk
321 \LT@start
322 \unvbox\z@
323 \LT@get@widths
324 \LT@bchunk}
325 \def\LT@argtabularcr[#1]{%
326 \ifnum0=`{}\fi
327 \ifdim #1>\z@
328 \unskip\@xargarraycr{#1}%
329 \else
330 \@yargarraycr{#1}%
331 \fi
332 \LT@echunk
333 \LT@start
334 \unvbox\z@
335 \LT@get@widths
336 \LT@bchunk}
337 \def\LT@echunk{%
338 \crcr\LT@save@row\cr\egroup
339 \global\setbox\LT@gbox\lastbox
340 \unskip
341 \egroup}
342 \def\LT@entry#1#2{%
343 \ifhmode\@firstofone{&}\fi\omit
344 \ifnum#1=\c@LT@chunks
345 \else
346 \kern#2\relax
347 \fi}
348 \def\LT@entry@chop#1#2{%
349 \noexpand\LT@entry
350 {\ifnum#1>\c@LT@chunks
351 1}{0pt%
352 \else
353 #1}{#2%
354 \fi}}
355 \def\LT@entry@write{%
356 \noexpand\LT@entry^^J%
357 \@spaces}
358 \def\LT@kill{%
359 \LT@echunk
360 \LT@get@widths
361 \expandafter\LT@rebox\LT@bchunk}
362 \def\LT@rebox#1\bgroup{%
363 #1\bgroup
364 \unvbox\z@
365 \unskip
366 \setbox\z@\lastbox}
367 \def\LT@blank@row{%
368 \xdef\LT@save@row{\expandafter\LT@build@blank
369 \romannumeral\number\LT@cols 001 }}
370 \def\LT@build@blank#1{%
371 \if#1m%
372 \noexpand\LT@entry{1}{0pt}%
373 \expandafter\LT@build@blank
374 \fi}
375 \def\LT@make@row{%
376 \global\expandafter\let\expandafter\LT@save@row
377 \csname LT@\romannumeral\c@LT@tables\endcsname
378 \ifx\LT@save@row\relax
379 \LT@blank@row
380 \else
381 {\let\LT@entry\or
382 \if!%
383 \ifcase\expandafter\expandafter\expandafter\LT@cols
384 \expandafter\@gobble\LT@save@row
385 \or
386 \else
387 \relax
388 \fi
389 !%
390 \else
391 \aftergroup\LT@blank@row
392 \fi}%
393 \fi}
394 \let\setlongtables\relax
395 \def\LT@get@widths{%
396 \setbox\tw@\hbox{%
397 \unhbox\LT@gbox
398 \let\LT@old@row\LT@save@row
399 \global\let\LT@save@row\@empty
400 \count@\LT@cols
401 \loop
402 \unskip
403 \setbox\tw@\lastbox
404 \ifhbox\tw@
405 \LT@def@row
406 \advance\count@\m@ne
407 \repeat}%
408 \ifx\LT@@save@row\@undefined
409 \let\LT@@save@row\LT@save@row
410 \fi}
411 \def\LT@def@row{%
412 \let\LT@entry\or
413 \edef\@tempa{%
414 \ifcase\expandafter\count@\LT@old@row
415 \else
416 {1}{0pt}%
417 \fi}%
418 \let\LT@entry\relax
419 \xdef\LT@save@row{%
420 \LT@entry
421 \expandafter\LT@max@sel\@tempa
422 \LT@save@row}}
423 \def\LT@max@sel#1#2{%
424 {\ifdim#2=\wd\tw@
425 #1%
426 \else
427 \number\c@LT@chunks
428 \fi}%
429 {\the\wd\tw@}}
430 \def\LT@hline{%
431 \noalign{\ifnum0=`}\fi
432 \penalty\@M
433 \futurelet\@let@token\LT@@hline}
434 \ExplSyntaxOn
435 \def\LT@@hline{%
436 \ifx\@let@token\hline
437 \global\let\@gtempa\@gobble
438 \gdef\LT@sep{\penalty-\@medpenalty\vskip\doublerulesep}%
439 \else
440 \global\let\@gtempa\@empty
441 \gdef\LT@sep{\penalty-\@lowpenalty\vskip-\arrayrulewidth}%
442 \fi
443 \ifnum0=`{\fi}%
444 \multispan\LT@cols
445 \unskip\leaders\hrule\@height\arrayrulewidth\hfill\cr
446 \noalign{
447 \tbl_gdecr_row_count:
448 \LT@sep}
449 \multispan\LT@cols
450 \unskip\leaders\hrule\@height\arrayrulewidth\hfill\cr
451 \noalign{
452 \tbl_gdecr_row_count:
453 \penalty\@M}
454 \@gtempa}
455 \def\LT@caption{%
456 \noalign\bgroup
457 \@ifnextchar[{\egroup\LT@c@ption\@firstofone}\LT@capti@n}
458 \def\LT@c@ption#1[#2]#3{
459 \tl_if_empty:eTF{\LTcaptype}
460 {\LT@makecaption\@gobble{}{#3}}
461 {\LT@makecaption#1{\csname fnum@\LTcaptype\endcsname}{#3}
462 \def\@tempa{#2}
463 \ifx\@tempa\@empty\else
464 {\let\\\space
465 \addcontentsline
466 {\@nameuse{ext@\LTcaptype}}
467 {\LTcaptype}
468 {\protect\numberline{\@nameuse{the\LTcaptype}}{#2}}}
469 \fi}}
470 \ExplSyntaxOff
471 \def\LT@capti@n{%
472 \@ifstar
473 {\egroup\LT@c@ption\@gobble[]}%
474 {\egroup\@xdblarg{\LT@c@ption\@firstofone}}}
475 \def\LT@makecaption#1#2#3{%
476 \LT@mcol\LT@cols c{\hbox to\z@{\hss\parbox[t]\LTcapwidth{%
477 \reset@font
478 \sbox\@tempboxa{#1{#2: }#3}%
479 \ifdim\wd\@tempboxa>\hsize
480 #1{#2: }#3%
481 \else
482 \hbox to\hsize{\hfil\box\@tempboxa\hfil}%
483 \fi
484 \endgraf\vskip\baselineskip}%
485 \hss}}}
486 \ExplSyntaxOn
487 \def\LT@output{%
488 \ifnum\outputpenalty <-\@Mi
489 \ifnum\outputpenalty > -\LT@end@pen
490 \LT@err{floats~ and~ marginpars~ not~ allowed~ in~ a~ longtable}\@ehc
491 \else
492 \setbox\z@\vbox{\unvbox\@cclv}%
493 \ifdim \ht\LT@lastfoot>\ht\LT@foot
494 \dimen@\pagegoal
495 \advance\dimen@\ht\LT@foot
496 \advance\dimen@-\ht\LT@lastfoot
497 \ifdim\dimen@<\ht\z@
498 \setbox\@cclv\vbox{\unvbox\z@\copy\LT@foot\vss}%
499 \@makecol
500 \@expl@@@mark@update@singlecol@structures@@
501 \@outputpage
502 \global\vsize\@colroom
503 \setbox\z@\vbox{\box\LT@head}%
504 \fi
505 \fi
506 \unvbox\z@\box\ifvoid\LT@lastfoot\LT@foot\else\LT@lastfoot\fi
507 \UseTaggingSocket{tbl/longtable/foot}
508 \fi
509 \else
510 \setbox\@cclv\vbox{\unvbox\@cclv\copy\LT@foot\vss}%
511 \UseTaggingSocket{tbl/longtable/foot}
512 \@makecol
513 \@expl@@@mark@update@singlecol@structures@@
514 \@outputpage
515 \global\vsize\@colroom
516 \copy\LT@head\nobreak
517 \fi}
518 \ExplSyntaxOff
519 \ExplSyntaxOn
520 \def\LT@end@hd@ft#1{%
521 \tbl_if_row_was_started:TF
522 {
523 \tbl_count_missing_cells:n {head/foot}
524 \int_step_inline:nn
525 { \LT@rows + 1 }
526 {
527 \seq_gput_left:ce
528 {g__tbl_\cs_to_str:N #1 _rows_seq }
529 { \int_eval:n {\g__tbl_row_int + 1 - ##1 } }
530 }
531 \int_gset:Nn \LT@rows { \LTchunksize }
532 }
533
534 {
535 \crcr
536 \noalign{
537 \int_step_inline:nn
538 { \LT@rows }
539 {
540 \seq_gput_left:ce
541 {g__tbl_\cs_to_str:N #1 _rows_seq }
542 { \int_eval:n {\g__tbl_row_int - ##1 } }
543 }
544 \tbl_gdecr_row_count: % undo the increment
545 \int_gset:Nn \LT@rows { \LTchunksize }
546 }
547 }
548 \LT@echunk
549 \ifx\LT@start\endgraf
550 \LT@err
551 {Longtable~ head~ or~ foot~ not~ at~ start~ of~ table}%
552 {Increase~ LTchunksize}%
553 \fi
554 \setbox#1\box\z@
555 \__tbl_trace:n {-->>~ Saving~\noexpand#1}
556 \LT@get@widths
557 \LT@bchunk}
558 \ExplSyntaxOff
559 \def\endfirsthead{\LT@end@hd@ft\LT@firsthead}
560 \def\endhead{\LT@end@hd@ft\LT@head}
561 \def\endfoot{\LT@end@hd@ft\LT@foot}
562 \def\endlastfoot{\LT@end@hd@ft\LT@lastfoot}
563 \def\LT@startpbox#1{%
564 \bgroup
565 \color@begingroup
566 \let\@footnotetext\LT@p@ftntext
567 \setlength\hsize{#1}%
568 \@arrayparboxrestore
569 \everypar{%
570 \vrule \@height \ht\@arstrutbox \@width \z@
571 \everypar{}}%
572 }
573 \def\LT@endpbox{%
574 \@finalstrut\@arstrutbox
575 \color@endgroup
576 \egroup
577 \the\LT@p@ftn
578 \global\LT@p@ftn{}%
579 \hfil}
580 \long\def\LT@p@ftntext#1{%
581 \edef\@tempa{\the\LT@p@ftn\noexpand\footnotetext[\the\c@footnote]}%
582 \global\LT@p@ftn\expandafter{\@tempa{#1}}}%
583 \ExplSyntaxOn
584 \seq_new:N \g__tbl_LT@firsthead_rows_seq
585 \seq_new:N \g__tbl_LT@head_rows_seq
586 \seq_new:N \g__tbl_LT@lastfoot_rows_seq
587 \seq_new:N \g__tbl_LT@foot_rows_seq
588 \ExplSyntaxOff
589 \endinput
590 %%
591 %% End of file `longtable.sty'.