Debian Codegraph @

texmf-dist/source/latex/supertabular/supertabular.dtx

raw
1 % \iffalse meta-comment
2 %
3 % Copyright 1989-2026 Johannes L. Braams. All rights reserved.
4 %
5 % This file is part of the supertabular package.
6 % ---------------------------------------------
7 %
8 % It may be distributed and/or modified under the
9 % conditions of the LaTeX Project Public License, either version 1.3c
10 % of this license or (at your option) any later version.
11 % The latest version of this license is in
12 % http://www.latex-project.org/lppl.txt
13 % and version 1.3c or later is part of all distributions of LaTeX
14 % version 2005/12/01 or later.
15 %
16 % This work has the LPPL maintenance status "maintained".
17 %
18 % The Current Maintainer of this work is Johannes Braams.
19 %
20 % The list of all files belonging to the supertabular package is
21 % given in the file `MANIFEST.
22 %
23 % The list of derived (unpacked) files belonging to the distribution
24 % and covered by LPPL is defined by the unpacking scripts (with
25 % extension .ins) which are part of the distribution.
26 % \fi
27 %
28 % \CheckSum{1210}
29 % \iffalse
30 %% Sourcefile `supertabular.dtx'.
31 %%
32 %% Copyright (C) 1988 by Theo Jurriens
33 %% Copyright (C) 1990-2026 by Johannes Braams texniek at texniek.nl
34 %% The Netherlands
35 %% all rights reserved.
36 %%
37 %%
38 %<*dtx>
39 \ProvidesFile{supertabular.dtx}
40 %</dtx>
41 %<package>\NeedsTeXFormat{LaTeX2e}
42 %<package>\ProvidesPackage{supertabular}
43 %<driver>\ProvidesFile{supertabular.drv}
44 %\ProvidesFile{supertabular.dtx}
45 [2025/06/26 v4.2d the supertabular environment]
46 %
47 %<*driver>
48 \documentclass{ltxdoc}
49 \usepackage[debugshow,calculate]{supertabular}
50 \newcommand{\tbsp}{\rule{0pt}{18pt}}
51 \begin{document}
52 \providecommand{\Lenv}[1]{\textsf{#1}}
53 \providecommand{\pkg}[1]{\texttt{#1}}
54 \providecommand{\cls}[1]{\texttt{#1}}
55 \providecommand{\file}[1]{\texttt{#1}}
56 \DocInput{supertabular.dtx}
57 \end{document}
58 %</driver>
59 % \fi
60 %
61 % \changes{v4.0a}{1996/11/28}{Cleanup of the code, now a \file{.dtx}
62 % source file}
63 % \changes{v4.0c}{1997/02/20}{Replace \cs{tableformat} by
64 % \cs{ST@tableformat} to prevent a clash with the \pkg{KOMA}
65 % pacakage}
66 % \changes{v4.0f}{1997/04/10}{Repaired a few typos in the
67 % documentation}
68 % \changes{v4.1a}{1997/09/18}{Repaired a number of typos and added
69 % contributed mpsupertabular environemnts}
70 % \changes{v4.1b}{1997/10/08}{Renamed \cs{@@tabularcr} to
71 % \cs{org@tabularcr}}
72 % \changes{v4.2a}{2020-06-27}{renamed \cs{ST@lineht} to \cs{ST@rowht}}
73 % \changes{v4.2c}{2024/07/20}{A few documentation changes}
74 %
75 % \GetFileInfo{supertabular.dtx}
76 % \title{The \texttt{supertabular} environment\thanks{This file
77 % has version number \fileversion, last
78 % revised \filedate.}}
79 % \author{Johannes Braams and Theo Jurriens}
80 % \date{\filedate}
81 % \maketitle
82 %
83 % \section{Introduction}
84 %
85 % The package \pkg{supertabular} offers a new environment, the
86 % \Lenv{supertabular} environment. As the name indicates it is an
87 % extension of the normal \Lenv{tabular} environment.
88 %
89 % With the original \Lenv{tabular} environment a tabular must
90 % always fit on \emph{one} page. If the tabular becomes too large
91 % the text overwrites the page's bottom margin and you get an
92 % \texttt{Overfull vbox} message.
93 %
94 % The \Lenv{supertabular} environment uses the \Lenv{tabular}
95 % environment internally, but it evaluates the used space every
96 % time it gets a |\\| command. If the tabular reaches the
97 % textheight, it automatically inserts an optional tabletail, an
98 % |\end{tabular}| command, starts a new page, a new
99 % \Lenv{tabular} environment and inserts the optional tablehead on
100 % the new page continuing the tabular.
101 %
102 % \section{User interface}
103 %
104 % The package \pkg{supertabular} has three options, they control
105 % the amount of information that is written to the \file{.log}
106 % file.
107 % \begin{enumerate}
108 % \item The option \textsf{errorshow} (the default) doens't write
109 % any extra information.
110 % \item The option \textsf{pageshow} writes information about when
111 % and why \pkg{supertabular} decides to break the tabular
112 % environment in order to produce a new page.
113 % \item The option \textsf{debugshow} also adds information about
114 % each row that is added to the tabular.
115 % \item The option \textsf{estimate} (the default) has the package
116 % use the old estimation-based algortihm to establish the height
117 % of individual rows.
118 % \item The option \textsf{calculate} has the package use the new
119 % calculation-based algortihm to establish the height
120 % of individual rows.
121 % \end{enumerate}
122 %
123 % Below is a description of the new commands and environments that
124 % this package provides.
125 %
126 % \DescribeMacro{\tablefirsthead}
127 % The command |\tablefirsthead| takes one argument, it defines the
128 % contents of the first occurence of the tabular head.\\
129 % The use of this command is optional. Don't forget to close the
130 % head by a |\\|.
131 %
132 % \DescribeMacro{\tablehead}
133 % The command |\tablehead| takes one argument, it defines the
134 % contents of all subsequent ocurrences of the tabular head.\\
135 % Don't forget to close the head by a |\\|
136 %
137 % \DescribeMacro{\tabletail}
138 % The command |\tabletail| takes one argument, it defines something
139 % which should be inserted before each |\end{tabular}|, except
140 % the last.
141 %
142 % \DescribeMacro{\tablelasttail}
143 % The command |\tablelasttail| takes one argument, it defines
144 % something which should be inserted before the last
145 % |\end{tabular}|.\\
146 % The use of this command is optional.
147 %
148 % \DescribeMacro{\topcaption}
149 % \DescribeMacro{\bottomcaption}
150 % \DescribeMacro{\tablecaption}
151 % These commands all take the same arguments as \LaTeX's standard
152 % |\caption| command. They provide a caption for the super-table,
153 % either at the top or at the bottom of the table. When
154 % |\tablecaption| is used the caption will be placed at the
155 % default location, which is at the top.
156 %
157 % \DescribeEnv{supertabular}
158 % \DescribeEnv{supertabular*}
159 % The environments \Lenv{supertabular} and \Lenv{supertabular*}
160 % can be used much like the standard \LaTeX\ environments
161 % \Lenv{tabular} and \Lenv{tabular*}.
162 %
163 % \DescribeEnv{mpsupertabular}
164 % \DescribeEnv{mpsupertabular*}
165 % The environments \Lenv{mpsupertabular} and
166 % \Lenv{mpsupertabular*} work like the \Lenv{supertabular} and
167 % \Lenv{supertabular*} environments but put each page into a
168 % \Lenv{minipage} first. Thus it is possible to have footnotes
169 % inside a \Lenv{mpsupertabular}. The footnotetext is printed at
170 % the end of each page.
171 %
172 % \DescribeMacro{\shrinkheight}
173 % The allowed maximimum height of a part of the supertabular on a
174 % page can be adjusted using the command |\shrinkheight|. It takes
175 % one argument, the length with which to shrink (positive value) or
176 % grow (negative value) the allowed height.
177 %
178 % \section{Weak points}
179 %
180 % \begin{itemize}
181 % \item When the material of a normal entry (not a p-arg) becomes
182 % larger than the estimated |\ST@rowht|, overfull |\vbox|es
183 % will be produced.
184 % \item When the last p-arg on a page gets more than 4 lines
185 % (probably even more than 3 lines) it will result in an overfull
186 % |\vbox|. Also some combinations of |\baselinestretch|
187 % |\arraystretch| and a large font may lead to one row too much.
188 % \item if accidentally the last row of the tabular produces a
189 % newpage, on the next page the tabletail will be written
190 % immediately after the tablehead. Depending on the contents, this
191 % may result in an error message regarding misplaced |\noalign|.
192 %
193 % A quick but not very elegant solution: shrink the allowed height
194 % of the table with the command |\shrinkheight{...pt}| after the
195 % first |\\| of the supertabular.
196 % \item The \Lenv{mpsupertabular} environment sometimes has problems
197 % with pagebreaks when footnotes appear in the lower part of the
198 % tabular.
199 % \end{itemize}
200 %
201 % \section{Examples}
202 %
203 % \DeleteShortVerb{\|}
204 % Here is an example of a \Lenv{supertabular}.
205 % First, here is (part of) the user input for the table below:
206 %\begin{verbatim}
207 % \begin{center}
208 % \tablefirsthead{%
209 % \hline
210 % \multicolumn{1}{|c}{\tbsp Number} &
211 % \multicolumn{1}{c}{Number$^2$} &
212 % Number$^4$ &
213 % \multicolumn{1}{c|}{Number!} \\
214 % \hline}
215 % \tablehead{%
216 % \hline
217 % \multicolumn{4}{|l|}{\small\sl continued from previous page}\\
218 % \hline
219 % \multicolumn{1}{|c}{\tbsp Number} &
220 % \multicolumn{1}{c}{Number$^2$} &
221 % Number$^4$ &
222 % \multicolumn{1}{c|}{Number!} \\
223 % \hline}
224 % \tabletail{%
225 % \hline
226 % \multicolumn{4}{|r|}{\small\sl continued on next page}\\
227 % \hline}
228 % \tablelasttail{\hline}
229 % \bottomcaption{This table is split across pages}
230 %
231 % \begin{supertabular}{|r@{\hspace{6.5mm}}|r@{\hspace{5.5mm}}|r|r|}
232 % 1 & 1 & 1 & 1 \\
233 % 2 & 4 & 16 & 2 \\
234 % 3 & 9 & 81 & 6 \\
235 % 4 & 16 & 256 & 24 \\[5mm]
236 % ...
237 % 19 & 361 & 130321 & 1.21645100E+17\\
238 % 20 & 400 & 160000 & 2.43290200E+18\\
239 % \end{supertabular}
240 % \end{center}
241 %\end{verbatim}
242 %
243 % Then the table should be split across the page boundary:
244 % \begin{center}
245 % \tablefirsthead{%
246 % \hline
247 % \multicolumn{1}{|c}{\tbsp Number} &
248 % \multicolumn{1}{c}{Number$^2$} &
249 % Number$^4$ &
250 % \multicolumn{1}{c|}{Number!} \\
251 % \hline}
252 % \tablehead{%
253 % \hline
254 % \multicolumn{4}{|l|}{\small\sl continued from previous page}\\
255 % \hline
256 % \multicolumn{1}{|c}{\tbsp Number} &
257 % \multicolumn{1}{c}{Number$^2$} &
258 % Number$^4$ &
259 % \multicolumn{1}{c|}{Number!} \\
260 % \hline}
261 % \tabletail{%
262 % \hline
263 % \multicolumn{4}{|r|}{\small\sl continued on next page}\\
264 % \hline}
265 % \tablelasttail{\hline}
266 % \bottomcaption{This table is split across pages}
267 %
268 % \begin{supertabular}{|r@{\hspace{6.5mm}}|r@{\hspace{5.5mm}}|r|r|}
269 % 1\tbsp & 1 & 1 & 1 \\
270 % 2 & 4 & 16 & 2 \\
271 % 3 & 9 & 81 & 6 \\
272 % 4 & 16 & 256 & 24 \\[5mm]
273 % 5 & 25 & 625 & 120 \\
274 % 6 & 36 & 1296 & 720 \\
275 % 7 & 49 & 2401 & 5040 \\
276 % 8 & 64 & 4096 & 40320 \\
277 % 9 & 81 & 6561 & 362880 \\
278 % 10 & 100 & 10000 & 3628800 \\
279 % 11 & 121 & 14641 & 39916800 \\
280 % 12 & 144 & 20736 & 479001600 \\[.5cm]
281 % \hline & & & \\
282 % 13 & 169 & 28561 & 6.22702080E+9 \\[1cm]
283 % 14 & 196 & 38416 & 8.71782912E+10\\
284 % 15 & 225 & 50625 & 1.30767437E+12\\
285 % 16 & 256 & 65536 & 2.09227899E+13\\
286 % 17 & 289 & 83521 & 3.55687428E+14\\[5mm]
287 % 18 & 324 & 104976 & 6.40237370E+15\\
288 % 19 & 361 & 130321 & 1.21645100E+17\\
289 % 20 & 400 & 160000 & 2.43290200E+18\\
290 % \end{supertabular}
291 % \end{center}
292 %
293 % Here is another example whith a \texttt{p} column-definition. The
294 % tablehead is the same as above. The tabletail is a double
295 % \verb|\hline|; \verb|\arraystretch| is set to \texttt{1.5} and
296 % the font size is \verb|\small|.
297 %
298 % \begin{center}
299 % \tablefirsthead{%
300 % \hline
301 % \multicolumn{1}{|c}{\tbsp Number} &
302 % \multicolumn{1}{c}{Number$^2$} &
303 % Number$^4$ &
304 % \multicolumn{1}{c|}{Number!} \\
305 % \hline}
306 % \tablelasttail{\hline\hline}
307 % \topcaption{This table should also be split accross pages.}
308 % \renewcommand{\arraystretch}{1.5}
309 % \small
310 % \begin{supertabular}{| r@{\hspace{6.5mm}}|%
311 % r@{\hspace{5.5mm}}| r p{5cm}|}
312 % 1 & 1 & 1 & \tbsp here is a relative short entry \\
313 % 2 & 1 & 1 & and here is a long entry, where line breaks
314 % and line breaks and line breaks have to occur\\
315 % 3 & 1 & 1 & and here is a long entry, where line breaks
316 % and line breaks and line breaks have to occur\\
317 % 4 & 1 & 1 & and here is a long entry, where line breaks
318 % and line breaks and line breaks have to occur\\
319 % 5 & 1 & 1 & here is a relative short entry \\
320 % 6 & 1 & 1 & and here is a long entry, where line breaks
321 % and line breaks and line breaks have to occur\\
322 % 7 & 1 & 1 & and here is a long entry, where line breaks
323 % and line breaks and line breaks have to occur\\
324 % 8 & 1 & 1 & and here is a long entry, where line breaks
325 % and line breaks and line breaks have to occur\\
326 % 9 & 1 & 1 & and here is a long entry, where line breaks
327 % and line breaks and line breaks have to occur\\
328 % 10 & 1 & 1 & and here is a long entry, where line breaks
329 % and line breaks and line breaks have to occur\\
330 % 11 & 1 & 1 & and here is a long entry, where line breaks
331 % and line breaks and line breaks have to occur\\
332 % 12 & 1 & 1 & here is a relative short entry \\
333 % 13 & 1 & 1 & and here is a long entry, where line breaks
334 % and line breaks and line breaks have to occur\\
335 % 14 & 1 & 1 & and here is a long entry, where line breaks
336 % and line breaks and line breaks have to occur\\
337 % 15 & 1 & 1 & and here is a long entry, where line breaks
338 % and line breaks and line breaks have to occur\\
339 % 16 & 1 & 1 & and here is a long entry, where line breaks
340 % and line breaks and line breaks have to occur\\
341 % 17 & 1 & 1 & and here is a long entry, where line breaks
342 % and line breaks and line breaks have to occur\\
343 % 18 & 1 & 1 & and here is a long entry, where line breaks
344 % and line breaks and line breaks have to occur\\
345 % \end{supertabular}
346 % \end{center}
347 %
348 % Here is the same table again, but this time using the
349 % \Lenv{supertabular*} environment and stretching the table to the
350 % full width of the text.
351 %
352 % \begin{center}
353 % \tablefirsthead{%
354 % \hline
355 % \multicolumn{1}{|c}{\tbsp Number} &
356 % \multicolumn{1}{c}{Number$^2$} &
357 % Number$^4$ &
358 % \multicolumn{1}{c|}{Number!} \\
359 % \hline}
360 % \tablelasttail{\hline\hline}
361 % \topcaption{This table should also be split accross pages.}
362 % \renewcommand{\arraystretch}{1.5}
363 % \small
364 % \begin{supertabular*}{\textwidth}%
365 % {| r@{\extracolsep{6.5mm plus 1fil}}|%
366 % r@{\extracolsep{5.5mm plus 0.5fil}}|%
367 % r@{\extracolsep{0mm plus 0.1fil}}%
368 % p{5cm}|}
369 % 1 & 1 & 1 & \tbsp here is a relative short entry \\
370 % 2 & 1 & 1 & and here is a long entry, where line breaks
371 % and line breaks and line breaks have to occur\\
372 % 3 & 1 & 1 & and here is a long entry, where line breaks
373 % and line breaks and line breaks have to occur\\
374 % 4 & 1 & 1 & and here is a long entry, where line breaks
375 % and line breaks and line breaks have to occur\\
376 % 5 & 1 & 1 & here is a relative short entry \\
377 % 6 & 1 & 1 & and here is a long entry, where line breaks
378 % and line breaks and line breaks have to occur\\
379 % 7 & 1 & 1 & and here is a long entry, where line breaks
380 % and line breaks and line breaks have to occur\\
381 % 8 & 1 & 1 & and here is a long entry, where line breaks
382 % and line breaks and line breaks have to occur\\
383 % 9 & 1 & 1 & and here is a long entry, where line breaks
384 % and line breaks and line breaks have to occur\\
385 % 10 & 1 & 1 & and here is a long entry, where line breaks
386 % and line breaks and line breaks have to occur\\
387 % 11 & 1 & 1 & and here is a long entry, where line breaks
388 % and line breaks and line breaks have to occur\\
389 % 12 & 1 & 1 & here is a relative short entry \\
390 % 13 & 1 & 1 & and here is a long entry, where line breaks
391 % and line breaks and line breaks have to occur\\
392 % 14 & 1 & 1 & and here is a long entry, where line breaks
393 % and line breaks and line breaks have to occur\\
394 % 15 & 1 & 1 & and here is a long entry, where line breaks
395 % and line breaks and line breaks have to occur\\
396 % 16 & 1 & 1 & and here is a long entry, where line breaks
397 % and line breaks and line breaks have to occur\\
398 % 17 & 1 & 1 & and here is a long entry, where line breaks
399 % and line breaks and line breaks have to occur\\
400 % 18 & 1 & 1 & and here is a long entry, where line breaks
401 % and line breaks and line breaks have to occur\\
402 % \end{supertabular*}
403 % \end{center}
404 %
405 % \MakeShortVerb{\|}
406 %
407 % \section{Known problems}
408 %
409 % \begin{itemize}
410 % \item When a float occurs on the same page as the start of a
411 % supertabular you can expect unexpected results.
412 %
413 % When the float was defined on the same page you might end up
414 % with the first part of the supertabular on a page by its own.
415 %
416 % \item You should not use the supertabular \emph{inside} a
417 % floating-environment such as \texttt{table} as this will result
418 % in \TeX\ trying to put the whole supertabular on \emph{one}
419 % page.
420 %
421 % \item In some instances you might still end up with overfull
422 % |\vbox| messages.
423 %
424 % \item Sometimes the last page of the supertabular contains just
425 % an empty head an tail.
426 % \end{itemize}
427 % \StopEventually{}
428 %
429 % \section{The Implementation}
430 % First we define a few options that control the level of tracing
431 % output this package delivers. the option \textsf{errorshow} is the
432 % default situation.
433 % \changes{v4.1f}{2019/01/16}{The value for \cs{C@tracingst} needs to
434 % be 3 instead of 2}
435 % \begin{macrocode}
436 %<*package>
437 \newcount\c@tracingst
438 \DeclareOption{errorshow}{\c@tracingst\z@}
439 \DeclareOption{pageshow}{\c@tracingst\thr@@}
440 \DeclareOption{debugshow}{\c@tracingst5\relax}
441 % \end{macrocode}
442 % In version 4.1g a new way of determining the height of the
443 % average row was introduced. Instead of using an estimation, based
444 % on the value of |\baselineskip| a computation was introduced,
445 % based on the size of the |\strutbox|. The effect of this new
446 % method was that the parial tabulars fill the page better, so less
447 % \texttt{underfull vbox} message would appear. Unfortunately this
448 % had a negative effect on existing documents (that don;t come out
449 % like they used to) and especially when a very small font
450 % (|\tiny| or |\scriptsize| was chosen for the tabular and the
451 % cells contain subscripts or superscripts. It turned out that the
452 % heigth and depth of a formula like $5^5_5$ exceeds the size of
453 % |\strutbox|. The result is that the rows have more height (and/or
454 % depth) thatn what the algorithm computed. Hence, when more rows
455 % are added to the partial tabular than fit on the page. Especially
456 % on the first part thisis a probem as the partial tabular becomes
457 % too high and doesn't fit in the avialbale space. \TeX\ then
458 % decides to move it to the next page, resulting in two
459 % consecutive pages that have a lot of white space on them.
460 % \changes{v4.2a}{2020-06-27}{Two new options to choose the
461 % computation algorithhm}
462 % \begin{macrocode}
463 \DeclareOption{calculate}{\def\ST@calculate@rowht{\ST@compute@rowht}}
464 \DeclareOption{estimate}{\def\ST@calculate@rowht{\ST@estimate@rowht}}
465 %\def\ST@calculate@rowht{\ST@estimate@rowht}
466 % \end{macrocode}
467 % The default for the options is to only show errors and use the
468 % old estmation algorithm (so as not to break old documents).
469 % \begin{macrocode}
470 \ExecuteOptions{errorshow,estimate}
471 \ProcessOptions
472 % \end{macrocode}
473 %
474 % \begin{macro}{\topcaption}
475 % \begin{macro}{\bottomcaption}
476 % The user-commands |\topcaption| and |\bottomcaption| set the
477 % flag |@topcaption| to determine where to put the
478 % tablecaption. The default is to put the caption on the top of
479 % the table
480 % \begin{macrocode}
481 \newif\if@topcaption \@topcaptiontrue
482 \def\topcaption{\@topcaptiontrue\tablecaption}
483 \def\bottomcaption{\@topcaptionfalse\tablecaption}
484 % \end{macrocode}
485 % \end{macro}
486 % \end{macro}
487 %
488 % \begin{macro}{\tablecaption}
489 % This command has to function exactly like |\caption| does, except
490 % it has to store its argument (and the optional argument) for
491 % later processing \emph{within} the supertabular environment.
492 %
493 % \begin{macrocode}
494 \long\def\tablecaption{%
495 \refstepcounter{table}\@dblarg{\@xtablecaption}}
496 \long\def\@xtablecaption[#1]#2{%
497 \long\gdef\@process@tablecaption{\ST@caption{table}[#1]{#2}}}
498 \global\let\@process@tablecaption\relax
499 % \end{macrocode}
500 % \end{macro}
501 %
502 % \begin{macro}{\ifST@star}
503 % This switch is used in the internal macros to remember which
504 % kind of environment was started.
505 % \begin{macrocode}
506 \newif\ifST@star
507 % \end{macrocode}
508 % \end{macro}
509 %
510 % \begin{macro}{\ifST@mp}
511 % This switch is used in the internal macros to remember if the
512 % tabular should be put into a minipage.
513 % \changes{v4.1a}{1997/09/18}{Added \cs{ifST@mp} switch}
514 % \begin{macrocode}
515 \newif\ifST@mp
516 % \end{macrocode}
517 % \end{macro}
518 %
519 % \begin{macro}{\ST@wd}
520 % For the \Lenv{supertabular*} environment it is necessary to
521 % store the intended width of the tabular.
522 % \begin{macrocode}
523 \newdimen\ST@wd
524 % \end{macrocode}
525 % \end{macro}
526 %
527 % \begin{macro}{\ST@rightskip}
528 % \changes{v4.1a}{1997/09/18}{Dimen register added}
529 % \begin{macro}{\ST@leftskip}
530 % \changes{v4.1a}{1997/09/18}{Dimen register added}
531 % \begin{macro}{\ST@parfillskip}
532 % \changes{v4.1a}{1997/09/18}{Dimen register added}
533 % For the \Lenv{mpsupertabular} environments we need special
534 % versions of |\leftskip|, |\rightskip| and |\parfillskip|.
535 % \begin{macrocode}
536 \newskip\ST@rightskip
537 \newskip\ST@leftskip
538 \newskip\ST@parfillskip
539 % \end{macrocode}
540 % \end{macro}
541 % \end{macro}
542 % \end{macro}
543 %
544 % \begin{macro}{\ST@captionroom}
545 % \changes{v4.1g}{2020/02/02}{New macro}
546 % When a supertabular is preceded by a caption that fact might not
547 % yet be visible in the amount of space occupoed on the page
548 % sofar. Therefore we include the possibility to reduce the height
549 % of the first part of the supertabular. In order to this we need a
550 % macro that indicates a caption has been put in front of the
551 % table. We do this to reduce the risk that the first part of the
552 % table is too high after all and is pushed onto the next page due
553 % to an overfull |\vbox| condition.
554 % \begin{macrocode}
555 \def\ST@captionroom{\z@}
556 % \end{macrocode}
557 % \end{macro}
558 %
559 %
560 % \begin{macro}{\ST@caption}
561 % This is a redefinition of LaTeX's |\@caption|, |\@makecaption| is
562 % called within a group so as not to return to |\normalsize|
563 % globally. Also a fix is made for the `feature' of the
564 % |\@makecaption| of the document class \cls{article} and friends
565 % that a caption \textbf{always} gets a |\vskip 10pt| at the top
566 % and \textbf{none} at the bottom. If a user wants to precede his
567 % table with a caption this results in a collision.
568 %
569 % \changes{v4.1g}{2020/02/02}{Record the fact that a caption has
570 % preceeded the table by setting \cs{ST@captionroom}}
571 % \begin{macrocode}
572 \long\def\ST@caption#1[#2]#3{\par%
573 \addcontentsline{\csname ext@#1\endcsname}{#1}%
574 {\protect\numberline{%
575 \csname the#1\endcsname}{\ignorespaces #2}}
576 \begingroup
577 \@parboxrestore
578 \normalsize
579 \if@topcaption \vskip -10\p@ \fi
580 \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
581 \if@topcaption \vskip 10\p@ \gdef\ST@captionroom{20\p@}\fi
582 \endgroup}
583 % \end{macrocode}
584 % \end{macro}
585 %
586 % \begin{macro}{\tablehead}
587 % \changes{v4.0a}{1996/11/28}{Locally reset \cs{}\cs{} to \cs{cr}}
588 % \begin{macro}{\tablefirsthead}
589 % |\tablehead| activates the new tabular |\cr| commands.
590 % \changes{v4.0i}{1997/09/18}{Don't reset \cs{}\cs{} to \cs{cr}, but
591 % to \cs{@tabularcr}}
592 % \changes{v4.1b}{1997/10/08}{Not \cs{@tabularcr} but
593 % \cs{org@tabularcr}}
594 % \changes{v4.2b}{2021-02-14}{When the argument is empty the internal
595 % macro \cs{@tablehead} needs to be empty as well.}
596 % \begin{macrocode}
597 \newcommand\tablehead[1]{%
598 \def\@ST@arg{#1}%
599 \ifx\@ST@arg\@empty\gdef\@tablehead{}\else
600 \gdef\@tablehead{%
601 \noalign{%
602 \global\let\@savcr=\\
603 \global\let\\=\org@tabularcr}%
604 #1%
605 \noalign{\global\let\\=\@savcr}}%
606 \fi}
607 \tablehead{}
608 % \end{macrocode}
609 % It's possible to specify a different tablehead for the first
610 % `part' of the table. That only needs to be used once so it
611 % `undefines' itself at the end. That way we make sure that it
612 % doesn't accidentally get used for a second supertabular in the
613 % document.
614 % \changes{v4.1f}{2019/01/12}{\cs{\@table@first@head} needs the same
615 % definition as \cs{\@tablehead} (found by FMi)}
616 % \changes{v4.2b}{2021-02-14}{When the argument is empty the internal
617 % macro \cs{@table@first@head} needs to be empty as well.}
618 % \begin{macrocode}
619 \newcommand\tablefirsthead[1]{%
620 \def\@ST@arg{#1}%
621 \ifx\@ST@arg\@empty\gdef\@table@first@head{}\else
622 \gdef\@table@first@head{%
623 \noalign{%
624 \global\let\@savcr=\\
625 \global\let\\=\org@tabularcr}%
626 #1%
627 \noalign{%
628 \global\let\\=\@savcr
629 \global\let\@table@first@head\undefined
630 }}%
631 \fi}
632 % \end{macrocode}
633 % \end{macro}
634 % \end{macro}
635 %
636 % \begin{macro}{\tabletail}
637 % \begin{macro}{\tablelasttail}
638 % If the user uses an extra amount of tabular-data (like
639 % |\multicolumn|) in |\tabletail| \TeX\ starts looping because of
640 % the definition of |\ST@cr|. So make |\\| act just like a
641 % |\@tabularcr| inside this tail to prevent the loop. Save and
642 % restore the value of |\\|.
643 %
644 % \changes{v4.0i}{1997/09/18}{Don't reset \cs{}\cs{} to \cs{cr}, but
645 % to \cs{@tabularcr}}
646 % \changes{v4.1b}{1997/10/08}{Not \cs{@tabularcr} but
647 % \cs{org@tabularcr}}
648 % \changes{v4.2b}{2021-02-14}{When the argument is empty the internal
649 % macro \cs{@tabletail} needs to be empty as well.}
650 % \begin{macrocode}
651 \newcommand\tabletail[1]{%
652 \def\@ST@arg{#1}%
653 \ifx\@ST@arg\@empty\gdef\@tabletail{}\else
654 \gdef\@tabletail{%
655 \noalign{%
656 \global\let\@savcr=\\
657 \global\let\\=\org@tabularcr}%
658 #1%
659 \noalign{\global\let\\=\@savcr}}%
660 \fi}
661 \tabletail{}
662 % \end{macrocode}
663 % It's possible to specify a different tabletail for the last
664 % `part' of the table. That only needs to be used once so it
665 % `undefines' itself at the end. That way we make sure that it
666 % doesn't accidentally get used for a second supertabular in the
667 % document.
668 % \changes{v4.1f}{2019/01/12}{\cs{\@table@last@tail} needs the same
669 % definition as \cs{\@tabletail}}
670 % \changes{v4.2b}{2021-02-14}{When the argument is empty the internal
671 % macro \cs{@tabletail} needs to be empty as well.}
672 % \begin{macrocode}
673 \newcommand\tablelasttail[1]{%
674 \def\@ST@arg{#1}%
675 \ifx\@ST@arg\@empty\gdef\@table@last@tail{}\else
676 \gdef\@table@last@tail{%
677 \noalign{%
678 \global\let\@savcr=\\
679 \global\let\\=\org@tabularcr}%
680 #1%
681 \noalign{%
682 \global\let\\=\@savcr
683 \global\let\@table@last@tail\undefined
684 }}%
685 \fi}
686 % \end{macrocode}
687 % \end{macro}
688 % \end{macro}
689 %
690 % \begin{macro}{\sttraceon}
691 % \changes{v3.7b}{1994/05/16}{Added macro}
692 % \begin{macro}{\sttraceoff}
693 % \changes{v3.7b}{1994/05/16}{Added macro}
694 % There now is a possiblity to follow the decisions supertabular
695 % makes about breaking the tabular. This has to be enabled when
696 % converting this file with \texttt{docstrip} to a \texttt{.sty}
697 % file.
698 % \begin{macrocode}
699 \newcommand\sttraceon{\c@tracingst5\relax}
700 \newcommand\sttraceoff{\c@tracingst\z@}
701 % \end{macrocode}
702 % \end{macro}
703 % \end{macro}
704 %
705 % \begin{macro}{\ST@trace}
706 % A macro that gets the trace message as its argument
707 % \begin{macrocode}
708 \newcommand\ST@trace[2]{%
709 \ifnum\c@tracingst>#1\relax
710 \GenericWarning
711 {(supertabular)\@spaces\@spaces}
712 {Package supertabular: #2}%
713 \fi
714 }
715 % \end{macrocode}
716 % \end{macro}
717 %
718 % \begin{macro}{\ST@trace@cr}
719 % A variant of |\ST@trace| that can be called from within |\\| as
720 % that command is looking for an optional argument and will end up
721 % scanning the next line.
722 % \begin{macro}{\ST@save@lineno}
723 % \changes{v4.1f}{2019/01/18}{Added a macro to save the current input
724 % linenumber}
725 % But because this variant is called from within |\\| we need to
726 % save the current input linenumber before \TeX\ starts scanning
727 % for the optional argument. If we don't, the reported linenumber
728 % depends on whether or not the optional argument is present...
729 % \begin{macrocode}
730 \newcommand\ST@save@lineno{%
731 \expandafter\gdef\expandafter\ST@LineNo\expandafter{%
732 \the\inputlineno}}
733 % \end{macrocode}
734 % Within |\ST@trace@cr| we can than locally modify |\on@line| to
735 % use this saved line number.
736 % \begin{macrocode}
737 \newcommand\ST@trace@cr[2]{%
738 \ifnum\c@tracingst>#1\relax
739 \begingroup
740 \edef\on@line{ on input line \ST@LineNo}%
741 \GenericWarning
742 {(supertabular)\@spaces\@spaces}
743 {Package supertabular: #2}%
744 \endgroup
745 \fi
746 }
747 % \end{macrocode}
748 % \end{macro}
749 % \end{macro}
750 %
751 % \begin{macro}{\ST@pageleft}
752 % \changes{v3.7b}{1994/05/16}{Renamed from \cs{maxsize}}
753 % \changes{v4.0a}{1996/11/28}{Renamed from \cs{page@left}}
754 % This register holds the estimate of the amount of space left over
755 % on the current page. This is used in the decision when to start a
756 % new page.
757 % \begin{macrocode}
758 \newdimen\ST@pageleft
759 % \end{macrocode}
760 % \end{macro}
761 %
762 % \begin{macro}{\shrinkheight}
763 % \changes{v4.0a}{1996/11/28}{New command}
764 % \changes{v4.0h}{1997/05/20}{This command should use \cs{advance} but
765 % didn't...}
766 % A command to diminish the value of |\ST@pageleft| if necessary.
767 % \begin{macrocode}
768 \newcommand*\shrinkheight[1]{%
769 \noalign{\global\advance\ST@pageleft-#1\relax}}
770 % \end{macrocode}
771 % \end{macro}
772 %
773 % \begin{macro}{\setSTheight}
774 % \changes{v4.0h}{1997/05/10}{New command}
775 % A command to set the value of |\ST@pageleft| if necessary.
776 % \begin{macrocode}
777 \newcommand*\setSTheight[1]{%
778 \noalign{\global\ST@pageleft=#1\relax}}
779 % \end{macrocode}
780 % \end{macro}
781 %
782 % \begin{macro}{\ST@headht}
783 % \begin{macro}{\ST@tailht}
784 % The register |ST@headht| will hold the height of the first head
785 % of a \Lenv{supertabular} environment; the register |\ST@tailht|
786 % will hold the height of table tail (if any)
787 % \begin{macrocode}
788 \newdimen\ST@headht
789 \newdimen\ST@tailht
790 % \end{macrocode}
791 % \end{macro}
792 % \end{macro}
793 %
794 % \begin{macro}{\ST@pagesofar}
795 % The register |\ST@pagesofar| is used to store the estimate of the
796 % amount of page already filled up.
797 % \begin{macrocode}
798 \newdimen\ST@pagesofar
799 % \end{macrocode}
800 % \end{macro}
801 %
802 % \begin{macro}{\ST@pboxht}
803 % The measured (total) height of a parbox-argument
804 % \begin{macrocode}
805 \newdimen\ST@pboxht
806 % \end{macrocode}
807 % \end{macro}
808 %
809 % \changes{v4.0b}{1997/02/04}{Removed the use of \cs{ST@pboxcorr},
810 % correction seems to be no longer necessary}
811 %
812 % \begin{macro}{\ST@rowht}
813 % \begin{macro}{\ST@stretchht}
814 % \changes{v4.0g}{1997/04/12}{Dimension register added}
815 % \begin{macro}{\ST@prevht}
816 % \changes{v4.0g}{1997/04/12}{Dimension register added}
817 % The estimated height of a normal row is stored in
818 % |\ST@rowht|. The dimension register |\ST@stretchht| was used to
819 % store the difference between the `normal' row height and the
820 % row height when |\arraystretch| has a non-standard value. This
821 % was used in the case where p-box entries are added to the
822 % tabular. The dimension register |\ST@prevht| is used to store the
823 % height of the previous row, to use it as an estimate for the
824 % height of the next row. This is needed for a better estimate of
825 % when to break the tabular.
826 % \begin{macrocode}
827 \newdimen\ST@rowht
828 \newdimen\ST@prevht
829 % \end{macrocode}
830 % \end{macro}
831 % \end{macro}
832 % \end{macro}
833 %
834 % \begin{macro}{\ST@toadd}
835 % When a tabular row is ended with |\\[...]| we need to temporarily
836 % store the optional argument in |\ST@toadd|.
837 % \begin{macrocode}
838 \newdimen\ST@toadd
839 % \end{macrocode}
840 % \end{macro}
841 %
842 % \begin{macro}{\ST@dimen}
843 % A private scratch dimension register.
844 % \begin{macrocode}
845 \newdimen\ST@dimen
846 % \end{macrocode}
847 % \end{macro}
848 %
849 % \begin{macro}{\ST@pbox}
850 % A box register to temporarily store the contents of a parbox.
851 % \begin{macrocode}
852 \newbox\ST@pbox
853 % \end{macrocode}
854 % \end{macro}
855 %
856 % \begin{macro}{\ST@tabularcr}
857 % \begin{macro}{\ST@xtabularcr}
858 % \begin{macro}{\ST@argtabularcr}
859 % These are redefinitions of |\@tabularcr| and |\@xtabularcr|. This
860 % is needed to include |\ST@cr| in the definition of
861 % |\@xtabularcr|.
862 %
863 % All redefined macros have names that are similar to the original
864 % names, except with a leading 'ST'.
865 % \begin{macrocode}
866 % \changes{v4.1f}{2019/01/18}{Save the input linenumber before \TeX\
867 % scans for an optional argument}
868 \def\ST@tabularcr{%
869 {\ifnum0=`}\fi
870 \ST@save@lineno
871 \@ifstar{\ST@xtabularcr}{\ST@xtabularcr}}
872 \def\ST@xtabularcr{%
873 \@ifnextchar[%]
874 {\ST@argtabularcr}%
875 {\ifnum0=`{\fi}\cr\ST@cr}}
876 % \end{macrocode}
877 % \end{macro}
878 % \end{macro}
879 %
880 % \begin{macrocode}
881 \def\ST@argtabularcr[#1]{%
882 \ifnum0=`{\fi}%
883 \ifdim #1>\z@
884 \unskip\ST@xargarraycr{#1}
885 \else
886 \ST@yargarraycr{#1}%
887 \fi}
888 % \end{macrocode}
889 % \end{macro}
890 %
891 % \begin{macro}{\ST@xargarraycr}
892 % \begin{macro}{\ST@yargarraycr}
893 % In this case we need to copy the value of the optional argument
894 % of |\\| in our private register |\ST@toadd|.
895 % \begin{macrocode}
896 \def\ST@xargarraycr#1{%
897 \@tempdima #1\advance\@tempdima \dp \@arstrutbox
898 \vrule \@height\z@ \@depth\@tempdima \@width\z@ \cr
899 \noalign{\global\ST@toadd=#1}\ST@cr}
900 % \end{macrocode}
901 % \end{macro}
902 %
903 % Here we need to insert |\ST@cr|
904 % \begin{macrocode}
905 \def\ST@yargarraycr#1{%
906 \cr\noalign{\vskip #1\global\ST@toadd=#1}\ST@cr}
907 % \end{macrocode}
908 % \end{macro}
909 %
910 % \begin{macro}{\ST@startpbox}
911 % The macros that deal with parbox columns need to be redefined,
912 % because we need to know the size of the parbox.
913 % \changes{v4.0b}{1997/02/04}{Removed use of \cs{ST@pboxcorr}}
914 % \begin{macrocode}
915 \def\ST@startpbox#1{%
916 % \end{macrocode}
917 % To achieve our goal we need to save the text in box.
918 % \begin{macrocode}
919 \setbox\ST@pbox\vtop\bgroup\hsize#1\@arrayparboxrestore}
920 % \end{macrocode}
921 % \end{macro}
922 %
923 % \begin{macro}{\ST@astartpbox}
924 % Our version of |\@astartpbox| for \pkg{array}.
925 % \changes{v4.0b}{1997/02/04}{Removed use of \cs{ST@pboxcorr}}
926 % \begin{macrocode}
927 \def\ST@astartpbox#1{%
928 \bgroup\hsize#1%
929 \setbox\ST@pbox\vtop\bgroup\hsize#1\@arrayparboxrestore}
930 % \end{macrocode}
931 % \end{macro}
932 %
933 % \begin{macro}{\ST@endpbox}
934 % \begin{macro}{\ST@aendpbox}
935 % \changes{v4.0a}{1996/11/30}{Made definitions up to date with
936 % \file{latex.ltx} (1996/06/01)}
937 % Our version of |\@endpbox| and |\@aendpbox|.
938 % \begin{macrocode}
939 \def\ST@endpbox{%
940 \@finalstrut\@arstrutbox\par\egroup
941 \ST@dimen=\ht\ST@pbox
942 \advance\ST@dimen by \dp\ST@pbox
943 \ifnum\ST@pboxht<\ST@dimen
944 \global\ST@pboxht=\ST@dimen
945 \fi
946 \ST@dimen=\z@
947 \box\ST@pbox\hfil}
948 % \end{macrocode}
949 % The version for \pkg{array}
950 % \begin{macrocode}
951 \def\ST@aendpbox{%
952 \@finalstrut\@arstrutbox\par\egroup
953 \ST@dimen=\ht\ST@pbox
954 \advance\ST@dimen by \dp\ST@pbox
955 \ifnum\ST@pboxht<\ST@dimen
956 \global\ST@pboxht=\ST@dimen
957 \fi
958 \ST@dimen=\z@
959 \unvbox\ST@pbox\egroup\hfil}
960 % \end{macrocode}
961 % \end{macro}
962 % \end{macro}
963 %
964 % \begin{macro}{\ST@compute@rowht}
965 % \changes{v4.1g}{2020/02/02}{New macro \cs{ST@compute@rowht} to
966 % replace \cs{ST@estimate@rowht}}
967 % \changes{v4.2a}{2020-06-27}{Make sure that \cs{ST@rowht} is large
968 % enough to take subscripts and superscripts into account}
969 % The height of a row in an array environemnt can be computed as:
970 % \begin{itemize}
971 % \item the height of the strutbox |\ht\strutbox| (plus
972 % |\extrarowheight| when the \pkg{array} package is loaded),
973 % \item multiplied by arraystretch,
974 % \item plus the depth of the strutbox (|\dp\strutbox|) mulitplied
975 % by |\arraystretch|.
976 % \end{itemize}
977 % \begin{macrocode}
978 \def\ST@compute@rowht{%
979 % \end{macrocode}
980 % Temporarily store a formula with superscript and subscript in a
981 % box in order to be able to measure its height and depth.
982 % \begin{macrocode}
983 \setbox\@tempboxa=\vbox{\@arrayparboxrestore $5^5_5$}
984 % \end{macrocode}
985 % Use the largest height of either |\@tempboxa| or |\strutbox|.
986 % \begin{macrocode}
987 \ifnum\ht\@tempboxa>\ht\strutbox
988 \ST@rowht=\ht\@tempboxa
989 \else
990 \ST@rowht=\ht\strutbox
991 \fi
992 % \end{macrocode}
993 % If the \textsf{array} pacakge is used we need to add the
994 % value of |\extrarowheight|.
995 % \begin{macrocode}
996 \ifx\extrarowheight\undefined\else
997 \advance \ST@rowht by \extrarowheight
998 \fi
999 % \end{macrocode}
1000 % Also use the largest depth of either |\@tempboxa| or |\strutbox|.
1001 % \begin{macrocode}
1002 \ifnum\dp\@tempboxa>\dp\strutbox
1003 \advance\ST@rowht \dp\@tempboxa
1004 \else
1005 \advance\ST@rowht \dp\strutbox
1006 \fi
1007 % \end{macrocode}
1008 % And finally multiply by |\arraystretch|.
1009 % \begin{macrocode}
1010 \ST@rowht = \arraystretch\ST@rowht
1011 % \end{macrocode}
1012 % \begin{macrocode}
1013 \ST@trace\tw@{Normal Row height: \the\ST@rowht}%
1014 }
1015 % \end{macrocode}
1016 % \end{macro}
1017 %
1018 % \begin{macro}{\ST@estimate@rowht}
1019 % Estimates the height of normal line taking |\arraystretch| into
1020 % account. Also computes the difference between a normal line and a
1021 % `stretched' one.
1022 % \changes{v4.0b}{1997/02/04}{Removed use of \cs{ST@pboxcorr}}
1023 % \changes{v4.0g}{1997/04/12}{Added the computation of
1024 % \cs{ST@stretchht}}
1025 % \changes{v4.2a}{2020-06-27}{removed the computation of
1026 % \cs{ST@stretchht} as it is no longer used}
1027 % \begin{macrocode}
1028 \def\ST@estimate@rowht{%
1029 \ST@rowht=\arraystretch \baslineskp
1030 \global\advance\ST@rowht by 1\p@
1031 \ST@trace\tw@{Average Row height: \the\ST@rowht}%
1032 }
1033 % \end{macrocode}
1034 % \end{macro}
1035 %
1036 % \begin{macro}{\@calfirstpageht}
1037 % \changes{v3.7a}{1993/04/05}{Renamed from \cmd\calpage}
1038 % Estimates the space left on the current page and decides whether
1039 % the tabular can be started on this page or on a new page.
1040 % \begin{macrocode}
1041 \def\@calfirstpageht{%
1042 \ST@trace\tw@{Calculating height of tabular on first page}%
1043 % \end{macrocode}
1044 % The \TeX\ register |\pagetotal| contains the height of the page
1045 % sofar, the \LaTeX\ register |\@colroom| contains the height of
1046 % the column.
1047 % \begin{macrocode}
1048 \global\ST@pagesofar\pagetotal
1049 \global\ST@pageleft\@colroom
1050 \ST@trace\tw@{Height of text = \the\pagetotal; \MessageBreak
1051 Height of page = \the\ST@pageleft}%
1052 % \end{macrocode}
1053 % When we are in twocolumn mode \TeX\ may still be collecting
1054 % material for the first column although there seems to be no space
1055 % left. In this case we have to check against two times |\ST@pageleft|.
1056 % \begin{macrocode}
1057 \if@twocolumn
1058 \ST@trace\tw@{two column mode}%
1059 \if@firstcolumn
1060 \ST@trace\tw@{First column}%
1061 \ifnum\ST@pagesofar > \ST@pageleft
1062 \global\ST@pageleft=2\ST@pageleft
1063 \ifnum\ST@pagesofar > \ST@pageleft
1064 \newpage\@calnextpageht
1065 \ST@trace\tw@{starting new page}%
1066 \else
1067 % \end{macrocode}
1068 % In this case we're in the second column, so we have to compensate
1069 % for the material in the first column.
1070 % \begin{macrocode}
1071 \ST@trace\tw@{Second column}%
1072 \global\advance\ST@pageleft -\ST@pagesofar
1073 \global\advance\ST@pageleft -\@colroom
1074 \fi
1075 % \end{macrocode}
1076 % When |\ST@pagesofar| is smaller than |\ST@pageleft| \TeX\ is
1077 % still collecting material for the first column, so we can start a
1078 % new tabular environment like we do on a single column page.
1079 % \changes{v4.0i}{1997/09/17}{Added initialisation for the case where
1080 % the first column isn't full yet}
1081 % \begin{macrocode}
1082 \else
1083 \global\advance\ST@pageleft by -\ST@pagesofar
1084 \global\ST@pagesofar\z@
1085 \fi
1086 \else
1087 % \end{macrocode}
1088 % When we end up here, \TeX\ has already decided it had enough
1089 % material for the first column and is building the second column.
1090 % \changes{v4.1a}{1997/09/27}{Added initialisation for 2nd column of
1091 % twocolumn mode}
1092 % \begin{macrocode}
1093 \ST@trace\tw@{Second column}
1094 \ifnum\ST@pagesofar > \ST@pageleft
1095 \ST@trace\tw@{starting new page}%
1096 \newpage\@calnextpageht
1097 \else
1098 \global\advance\ST@pageleft by -\ST@pagesofar
1099 \global\ST@pagesofar\z@
1100 \fi
1101 \fi
1102 \else
1103 % \end{macrocode}
1104 % In one column mode there is a simple decision.
1105 % \begin{macrocode}
1106 \ST@trace\tw@{one column mode}%
1107 \ifnum\ST@pagesofar > \ST@pageleft
1108 \ST@trace\tw@{starting new page}%
1109 \newpage\@calnextpageht
1110 % \end{macrocode}
1111 % When we are not starting a new page subtract the size of the
1112 % material already on it from the available space.
1113 % \begin{macrocode}
1114 \else
1115 \global\advance\ST@pageleft by -\ST@pagesofar
1116 \global\ST@pagesofar\z@
1117 \fi
1118 \fi
1119 % \end{macrocode}
1120 % When a caption preceeds the first part of the tabular we need to
1121 % reduce the available height on the page by |\ST@captionroom|.
1122 % \changes{v4.1g}{2020/02/02}{Reduce the available height left on the
1123 % page when a caption preceeded the table}
1124 % \begin{macrocode}
1125 \if@topcaption\advance\ST@pageleft-\ST@captionroom\fi
1126 \ST@trace\tw@{Available height: \the\ST@pageleft}%
1127 % \end{macrocode}
1128 % Now we need to know the height of the head of the table. In order
1129 % to measure this we typeset it in a normal \Lenv{tabular}
1130 % environment.
1131 % \begin{macrocode}
1132 \ifx\@@tablehead\@empty
1133 \ST@headht=\z@
1134 \else
1135 \setbox\@tempboxa=\vbox{\@arrayparboxrestore
1136 \ST@restore
1137 \expandafter\tabular\expandafter{\ST@tableformat}%
1138 \@@tablehead\endtabular}%
1139 \ST@headht=\ht\@tempboxa\advance\ST@headht\dp\@tempboxa
1140 \fi
1141 \ST@trace\tw@{Height of head: \the\ST@headht}%
1142 % \end{macrocode}
1143 % To decide when to start a new page, we need to know the vertical
1144 % size of the tail of the table.
1145 % \begin{macrocode}
1146 \ifx\@tabletail\@empty
1147 \ST@tailht=\z@
1148 \else
1149 \setbox\@tempboxa=\vbox{\@arrayparboxrestore
1150 \ST@restore
1151 \expandafter\tabular\expandafter{\ST@tableformat}
1152 \@tabletail\endtabular}
1153 \ST@tailht=\ht\@tempboxa\advance\ST@tailht\dp\@tempboxa
1154 \fi
1155 % \end{macrocode}
1156 % We add the average height of a row to this because when we
1157 % decide to continue the tabular we need to have enough space left
1158 % for one row \emph{and} the tail.
1159 % \begin{macrocode}
1160 \advance\ST@tailht by \ST@rowht
1161 \ST@trace\tw@{Height of tail: \the\ST@tailht}%
1162 \ST@trace\tw@{Maximum height of tabular: \the\ST@pageleft}%
1163 \@tempdima\ST@headht
1164 % \end{macrocode}
1165 % \changes{v4.0b}{1997/02/04}{Base the decision whether to start on a
1166 % new page on the total of headheight, tailht and rowht}
1167 % Now we decide whether we can continue on the current page or
1168 % whether we need to start on a new page. We assume that the
1169 % minimum height of a tabular is the height of the head, the tail
1170 % and one row of data. If that doesn't fit a new page is started.
1171 % \begin{macrocode}
1172 \advance\@tempdima\ST@rowht
1173 \advance\@tempdima\ST@tailht
1174 \ST@trace\tw@{Minimum height of tabular: \the\@tempdima}%
1175 \ifnum\@tempdima>\ST@pageleft
1176 \ST@trace\tw@{starting new page}%
1177 \newpage\@calnextpageht
1178 \fi
1179 % \end{macrocode}
1180 % Take the height of the table into account,sosubstract it from the
1181 % available height. We need to do it like this because the |\\|
1182 % inside the definition of |\@@tablehead| have their normal
1183 % definition.
1184 % \changes{v4.1g}{2020/02/02}{Subtract the height of the tablehead
1185 % from the available space}
1186 % \begin{macrocode}
1187 \advance\ST@pageleft-\ST@headht
1188 }
1189 % \end{macrocode}
1190 % \end{macro}
1191 %
1192 % \begin{macro}{\@calnextpageht}
1193 % \changes{v3.7a}{1993/04/05}{Macro added}
1194 % \changes{v4.0b}{1997/02/04}{Removed use of \cs{ST@pboxcorr}}
1195 % This calculates the maximum height of the tabular on all
1196 % subsequent pages of the supertabular environment.
1197 % \begin{macrocode}
1198 \def\@calnextpageht{%
1199 \ST@trace\tw@{Calculating height of tabular on next page}%
1200 \global\ST@pageleft\@colroom
1201 \global\ST@pagesofar=\z@
1202 \ST@trace\tw@{Maximum height of tabular: \the\ST@pageleft}%
1203 % \end{macrocode}
1204 % Take the height of the head into account by subtracting it from
1205 % the avalable space.
1206 % \changes{v4.1g}{2020/02/02}{Subtract \cs{ST@headht} from
1207 % \cs{ST@pageleft}}
1208 % \begin{macrocode}
1209 \advance\ST@pageleft-\ST@headht
1210 }
1211 % \end{macrocode}
1212 % \end{macro}
1213 %
1214 % \begin{macro}{\x@supertabular}
1215 % The body of the beginning of both environments is stored in a
1216 % single macro as the code is shared.
1217 % \begin{macrocode}
1218 \def\x@supertabular{%
1219 % \end{macrocode}
1220 % First save the original definition of |\tabular| and then make it
1221 % point to |\inner@tabular|. This is done to enable supertabular
1222 % cells to contain a \Lenv{tabular} environment without getting
1223 % unexpected results when the \Lenv{supertabular} would be split
1224 % accross this inner \Lenv{tabular} environment.
1225 % \changes{v4.0d}{1997/03/06}{Save definition of \cs{tabular} and
1226 % \cs{tabular*}}
1227 % \begin{macrocode}
1228 \let\org@tabular\tabular
1229 \let\tabular\inner@tabular
1230 % \end{macrocode}
1231 % The same needs to be done for the \Lenv{tabular*}
1232 % environment. The coding is slightly more verbose.
1233 % \begin{macrocode}
1234 \expandafter\let
1235 \csname org@tabular*\expandafter\endcsname
1236 \csname tabular*\endcsname
1237 \expandafter\let\csname tabular*\expandafter\endcsname
1238 \csname inner@tabular*\endcsname
1239 % \end{macrocode}
1240 % If the caption should come at the top we insert it here.
1241 % \begin{macrocode}
1242 \if@topcaption \@process@tablecaption \fi
1243 % \end{macrocode}
1244 % Save the original definition of |\\|.
1245 % \begin{macrocode}
1246 \global\let\@oldcr=\\
1247 % \end{macrocode}
1248 % Save the current value of |\baselineskip|, as we need it in the
1249 % calculation of the average height of a row.
1250 % \begin{macrocode}
1251 \def\baslineskp{\baselineskip}%
1252 % \end{macrocode}
1253 % We have to check whether \texttt{array.sty} was loaded, because
1254 % some of the internal macros have different names.
1255 % \begin{macrocode}
1256 \ifx\undefined\@classix
1257 % \end{macrocode}
1258 % Save old |\@tabularcr| and insert the definition of
1259 % |\ST@tabularcr|.
1260 % \changes{v4.1c}{1997/11/07}{For standard \LaTeX\ we need to change
1261 % \cs{@@startpbox}, \emph{not} \cs{@startpbox}}
1262 % \begin{macrocode}
1263 \let\org@tabularcr\@tabularcr
1264 \let\@tabularcr\ST@tabularcr
1265 % \end{macrocode}
1266 % Activate the new parbox algorithm.
1267 % \begin{macrocode}
1268 \let\org@startpbox=\@startpbox
1269 \let\org@endpbox=\@endpbox
1270 \let\@@startpbox=\ST@startpbox
1271 \let\@@endpbox=\ST@endpbox
1272 \else
1273 % \end{macrocode}
1274 % When \texttt{array.sty} was loaded things are a bit different.
1275 % \begin{macrocode}
1276 \let\org@tabularcr\@arraycr
1277 \let\@arraycr\ST@tabularcr
1278 % \end{macrocode}
1279 % The macro |\@startpbox| needs to be treated carefully for
1280 % \pkg{array} as it has been renamed to |\@startpbox@action| in
1281 % version 2.6i.
1282 % \changes{v4.2d}{2025/06/26}{\pkg{array.sty} uses
1283 % \cs{@startpbox@action} as of V2.6h}
1284 % \begin{macrocode}
1285 \ifx\undefined\@startpbox@action
1286 \let\org@startpbox=\@startpbox
1287 \let\@startpbox=\ST@astartpbox
1288 \else
1289 \let\org@startpbox@action=\@startpbox@action
1290 \let\@startpbox@action=\ST@astartpbox
1291 \fi
1292 \let\org@endpbox=\@endpbox
1293 \let\@endpbox=\ST@aendpbox
1294 \fi
1295 % \end{macrocode}
1296 %
1297 % Check if the head of the table should be different for the first
1298 % and subsequent pages.
1299 % \begin{macrocode}
1300 \ifx\@table@first@head\undefined
1301 \let\@@tablehead=\@tablehead
1302 \else
1303 \let\@@tablehead=\@table@first@head
1304 \fi
1305 % \end{macrocode}
1306 % The first part of a supertabular may be moved on to the next page
1307 % if it doesn't fit on the current page after all. Subsequent parts
1308 % can not be moved; therefor we will have to switch the definition
1309 % of |\ST@skippage| around.
1310 % \changes{v4.0e}{1997/04/09}{Make sure that only the first part of a
1311 % supertabular can be moved to the next page.}
1312 % \begin{macrocode}
1313 \let\ST@skippage\ST@skipfirstpart
1314 % \end{macrocode}
1315 % Now we can estimate the average row height and the height of the
1316 % first page of the \Lenv{supertabular}.
1317 % \changes{v4.0i}{1997/09/18}{Added \cs{noindent}}
1318 % \changes{v4.1g}{2020/02/02}{Now call \cs{ST@calculate@rowht}}
1319 % \begin{macrocode}
1320 \ST@calculate@rowht
1321 \@calfirstpageht
1322 \noindent
1323 }
1324 % \end{macrocode}
1325 % \end{macro}
1326 %
1327 % \begin{macro}{\supertabular}
1328 % We start by looking for an optional argument, which will be duly
1329 % ignored as it seems to make no sense to try to align a multipage
1330 % table in the middle...
1331 % \begin{macrocode}
1332 \def\supertabular{%
1333 \@ifnextchar[{\@supertabular}%]
1334 {\@supertabular[]}}
1335 % \end{macrocode}
1336 % We can now save the preamble of the tabular in a macro.
1337 % \begin{macrocode}
1338 \def\@supertabular[#1]#2{%
1339 \def\ST@tableformat{#2}%
1340 \ST@trace\tw@{Starting a new supertabular}%
1341 % \end{macrocode}
1342 % Then remember that this is not a \textsf{supertabular*}
1343 % environment.
1344 % \begin{macrocode}
1345 \global\ST@starfalse
1346 % \end{macrocode}
1347 % Don't use minipages.
1348 % \changes{v4.1a}{1997/09/18}{Added setting of \cs{ST@mp}}
1349 % \begin{macrocode}
1350 \global\ST@mpfalse
1351 % \end{macrocode}
1352 %
1353 % Most of the following code is shared between the
1354 % \Lenv{supertabular} and \Lenv{supertabular*} environments. So to
1355 % avoid duplication it is stored in a macro.
1356 % \begin{macrocode}
1357 \x@supertabular
1358 % \end{macrocode}
1359 % Finally start a normal \textsf{tabular} environment.
1360 % \changes{v4.0d}{1997/03/06}{Use \cs{org@tabular} instead of
1361 % \cs{tabular}}
1362 % \begin{macrocode}
1363 \expandafter\org@tabular\expandafter{\ST@tableformat}%
1364 \@@tablehead}
1365 % \end{macrocode}
1366 % \end{macro}
1367 %
1368 % \begin{macro}{\supertabular*}
1369 % We start by looking for the optional argument of the tabular
1370 % environment.
1371 % \begin{macrocode}
1372 \@namedef{supertabular*}#1{%
1373 \@ifnextchar[{\@nameuse{@supertabular*}{#1}}%
1374 {\@nameuse{@supertabular*}{#1}[]}%]
1375 }
1376 % \end{macrocode}
1377 % We start by saving the intended width and the preamble of the
1378 % \textsf{tabular*}.
1379 % \begin{macrocode}
1380 \@namedef{@supertabular*}#1[#2]#3{%
1381 \ST@trace\tw@{Starting a new supertabular*}%
1382 \def\ST@tableformat{#3}%
1383 \ST@wd=#1\relax
1384 \global\ST@startrue
1385 \global\ST@mpfalse
1386 % \end{macrocode}
1387 % Now we can call the common code for both environments.
1388 % \begin{macrocode}
1389 \x@supertabular
1390 % \end{macrocode}
1391 % And we can start a normal \textsf{tabular*} environment.
1392 % \changes{v4.0f}{1997/04/11}{Use \cs{org@tabular*} instead of
1393 % \cs{tabular*}}
1394 % \begin{macrocode}
1395 \expandafter\csname org@tabular*\expandafter\endcsname
1396 \expandafter{\expandafter\ST@wd\expandafter}%
1397 \expandafter{\ST@tableformat}%
1398 \@@tablehead}%
1399 % \end{macrocode}
1400 % \end{macro}
1401 %
1402 % \begin{macro}{\mpsupertabular}
1403 % \changes{v4.1a}{1997/09/18}{Added \cs{mpsupertabular}}
1404 %
1405 % This version of the supertabular environment puts each tabular
1406 % into a minipage, thus making footnotes possible.
1407 % We start by looking for an optional argument, which will be duly
1408 % ignored as it seems to make no sense to try to align a multipage
1409 % table in the middle\dots
1410 % \begin{macrocode}
1411 \def\mpsupertabular{%
1412 \@ifnextchar[{\@mpsupertabular}%]
1413 {\@mpsupertabular[]}}
1414 % \end{macrocode}
1415 % We can now save the preamble of the tabular in a macro.
1416 % \begin{macrocode}
1417 \def\@mpsupertabular[#1]#2{%
1418 \def\ST@tableformat{#2}%
1419 \ST@trace\tw@{Starting a new mpsupertabular}%
1420 % \end{macrocode}
1421 % Then remember that this is not a \textsf{mpsupertabular*}
1422 % environment.
1423 % \begin{macrocode}
1424 \global\ST@starfalse
1425 % \end{macrocode}
1426 %
1427 % And remember to close the minipage later.
1428 % \begin{macrocode}
1429 \global\ST@mptrue
1430 % \end{macrocode}
1431 %
1432 % Since we are about to start a minipage of |\columnwidth| the
1433 % horizontal alignment will no longer work. We have to remember the
1434 % values and restore them inside the minipage.
1435 % \begin{macrocode}
1436 \ST@rightskip \rightskip
1437 \ST@leftskip \leftskip
1438 \ST@parfillskip \parfillskip
1439 % \end{macrocode}
1440 %
1441 % Most of the following code is shared between the
1442 % \Lenv{mpsupertabular} and \Lenv{mpsupertabular*} environments. So
1443 % to avoid duplication it is stored in a macro.
1444 % \begin{macrocode}
1445 \x@supertabular
1446 % \end{macrocode}
1447 % Finally start a normal \textsf{tabular} environment.
1448 % \changes{v4.1a}{1997/09/18}{Open minipage and adjust skips}
1449 % \begin{macrocode}
1450 \minipage{\columnwidth}%
1451 \parfillskip\ST@parfillskip
1452 \rightskip \ST@rightskip
1453 \leftskip \ST@leftskip
1454 \noindent\expandafter\org@tabular\expandafter{\ST@tableformat}%
1455 \@@tablehead}
1456 % \end{macrocode}
1457 % \end{macro}
1458 %
1459 % \begin{macro}{\mpsupertabular*}
1460 % \changes{v4.1a}{1997/09/18}{Added \cs{mpsupertabular*}}
1461 %
1462 % We start by looking for the optional argument of the tabular
1463 % environment.
1464 % \begin{macrocode}
1465 \@namedef{mpsupertabular*}#1{%
1466 \@ifnextchar[{\@nameuse{@mpsupertabular*}{#1}}%
1467 {\@nameuse{@mpsupertabular*}{#1}[]}%]
1468 }
1469 % \end{macrocode}
1470 % Now we can save the intended width and the preamble of the
1471 % \textsf{tabular*}.
1472 % \begin{macrocode}
1473 \@namedef{@mpsupertabular*}#1[#2]#3{%
1474 \ST@trace\tw@{Starting a new mpsupertabular*}%
1475 \def\ST@tableformat{#3}%
1476 \ST@wd=#1\relax
1477 \global\ST@startrue
1478 \global\ST@mptrue
1479 \ST@rightskip \rightskip
1480 \ST@leftskip \leftskip
1481 \ST@parfillskip \parfillskip
1482 % \end{macrocode}
1483 %
1484 % Then we can call the common code for both environments.
1485 % \begin{macrocode}
1486 \x@supertabular
1487 % And we can start a normal \textsf{tabular*} environment.
1488 % \begin{macrocode}
1489 \minipage{\columnwidth}%
1490 \parfillskip\ST@parfillskip
1491 \rightskip \ST@rightskip
1492 \leftskip \ST@leftskip
1493 \noindent\expandafter\csname org@tabular*\expandafter\endcsname
1494 \expandafter{\expandafter\ST@wd\expandafter}%
1495 \expandafter{\ST@tableformat}%
1496 \@@tablehead}%
1497 % \end{macrocode}
1498 % \end{macro}
1499 %
1500 % \begin{macro}{\endsupertabular}
1501 % \begin{macro}{\endsupertabular*}
1502 % This closes the environments \Lenv{supertabular} and
1503 % \Lenv{supertabular*}.
1504 % \begin{macrocode}
1505 \def\endsupertabular{%
1506 \ifx\@table@last@tail\undefined
1507 \@tabletail
1508 \else
1509 \@table@last@tail
1510 \fi
1511 \csname endtabular\ifST@star*\fi\endcsname
1512 % \end{macrocode}
1513 % Restore the original definition of |\@tabularcr|
1514 % \begin{macrocode}
1515 \ST@restore
1516 % \end{macrocode}
1517 % Check if we have to insert a caption and restore to default
1518 % behaviour of putting captions at the top.
1519 % \begin{macrocode}
1520 \if@topcaption
1521 \else
1522 \@process@tablecaption
1523 \@topcaptiontrue
1524 \fi
1525 % \end{macrocode}
1526 %
1527 % Restore the meaning of |\\| to the one it had before the start
1528 % of this environment. Also re-initialize some control-sequences
1529 %
1530 % \changes{v4.0h}{1997/05/20}{Added missing \cs{global} commands}
1531 % \changes{v4.1d}{1999/08/07}{No longer make \cs{@table@first@head}
1532 % and \cs{@table@last@tail} undefined}
1533 % \begin{macrocode}
1534 \global\let\\\@oldcr
1535 \global\let\@process@tablecaption\relax
1536 \ST@trace\tw@{Ended a supertabular\ifST@star*\fi}%
1537 }
1538 % \end{macrocode}
1539 %
1540 % The definition of the ending of the \Lenv{supertabular*}
1541 % environment is simple:
1542 % \begin{macrocode}
1543 \expandafter\let\csname endsupertabular*\endcsname\endsupertabular
1544 % \end{macrocode}
1545 % \end{macro}
1546 % \end{macro}
1547 %
1548 % \begin{macro}{\endmpsupertabular}
1549 % \begin{macro}{\endmpsupertabular*}
1550 % This closes the environments \Lenv{mpsupertabular} and
1551 % \Lenv{mpsupertabular*}.
1552 % \begin{macrocode}
1553 \def\endmpsupertabular{%
1554 \ifx\@table@last@tail\undefined
1555 \@tabletail
1556 \else
1557 \@table@last@tail
1558 \fi
1559 \csname endtabular\ifST@star*\fi\endcsname
1560 \endminipage
1561 % \end{macrocode}
1562 % Restore the original definition of |\@tabularcr|
1563 % \begin{macrocode}
1564 \ST@restore
1565 % \end{macrocode}
1566 % Check if we have to insert a caption and restore to default
1567 % behaviour of putting captions at the top.
1568 % \begin{macrocode}
1569 \if@topcaption
1570 \else
1571 \@process@tablecaption
1572 \@topcaptiontrue
1573 \fi
1574 % \end{macrocode}
1575 %
1576 % Restore the meaning of |\\| to the one it had before the start
1577 % of this environment. Also re-initialize some control-sequences
1578 % \changes{v4.1d}{1999/08/07}{No longer make \cs{@table@first@head}
1579 % and \cs{@table@last@tail} undefined}
1580 % \begin{macrocode}
1581 \global\let\\\@oldcr
1582 \global\let\@process@tablecaption\relax
1583 \ST@trace\tw@{Ended a mpsupertabular\ifST@star*\fi}%
1584 }
1585 % \end{macrocode}
1586 %
1587 % The definition of the ending of the \Lenv{supertabular*}
1588 % environment is simple:
1589 % \begin{macrocode}
1590 \expandafter\let\csname endmpsupertabular*\endcsname\endmpsupertabular
1591 % \end{macrocode}
1592 % \end{macro}
1593 % \end{macro}
1594 % \begin{macro}{\ST@restore}
1595 % This macro restores the original definitions of the macros that
1596 % handle parbox entries and the macros that handle the end of the
1597 % row.
1598 % \changes{v4.2d}{2025/06/26}{\texttt{array.sty} uses
1599 % \cs{@startpbox@action} as of v2.6i}
1600 % \changes{v4.2d}{2025/08/09}{Fixed a typo \cs{ifxundefined}}
1601 % \begin{macrocode}
1602 \def\ST@restore{%
1603 \ifx\undefined\@classix
1604 \let\@tabularcr\org@tabularcr
1605 \let\@startpbox\org@startpbox
1606 \else
1607 \let\@arraycr\org@tabularcr
1608 \ifx\undefined\@startpbox@action
1609 \let\@startpbox\org@startpbox
1610 \else
1611 \let\@startpbox@action\org@startpbox@action
1612 \fi
1613 \fi
1614 \let\@endpbox\org@endpbox
1615 }
1616 % \end{macrocode}
1617 % \end{macro}
1618 %
1619 % \begin{macro}{\inner@tabular}
1620 % \begin{macro}{\inner@tabular*}
1621 % In order to facilitate complete \Lenv{tabular} environments to be
1622 % in a cell of a \Lenv{supertabular} environment we need to adapt
1623 % the definition of the orginal environments somewhat. For the
1624 % inner \Lenv{tabular} a number of definitions need to be
1625 % restored.
1626 % \changes{v4.0i}{1997/09/18}{Added \cs{noindent}}
1627 % \begin{macrocode}
1628 \def\inner@tabular{%
1629 \ST@restore
1630 \let\\\@oldcr
1631 \noindent
1632 \org@tabular}
1633 \@namedef{inner@tabular*}{%
1634 \ST@restore
1635 \let\\\@oldcr
1636 \noindent
1637 \csname org@tabular*\endcsname}
1638 % \end{macrocode}
1639 % \end{macro}
1640 % \end{macro}
1641 %
1642 % \begin{macro}{\ST@cr}
1643 % This macro is called by each |\\| inside the tabular environment.
1644 % It updates the estimate of the amount of space left on the
1645 % current page and starts a new page if necessary.
1646 % \begin{macrocode}
1647 \def\ST@cr{%
1648 \noalign{%
1649 \ifnum\ST@pboxht<\ST@rowht
1650 % \end{macrocode}
1651 % If there is a non-empty row, but an empty parbox, then
1652 % |\ST@pboxht| might be non-zero, but too small, thereby breaking
1653 % the algorithm. Therefor we estimate the height of the row to be
1654 % |\ST@rowht| in this case.
1655 % \begin{macrocode}
1656 \global\advance\ST@pageleft -\ST@rowht
1657 % \end{macrocode}
1658 % And we store that fact in |\ST@prevht|.
1659 % \changes{v4.0g}{1997/04/12}{store the height of the previous row in
1660 % \cs{ST@prevht}}
1661 % \begin{macrocode}
1662 \global\ST@prevht\ST@rowht
1663 \else
1664 % \end{macrocode}
1665 % When the parbox was not empty we take into account its height
1666 % (plus a bit extra).
1667 % \changes{v4.0g}{1997/04/12}{Also take \cs{ST@stretchht} into
1668 % account and store the height of the parbox in \cs{ST@prevht}}
1669 % \changes{v4.1f}{2019/03/01}{Use \cs{ST@trace@cr} instead of
1670 % \cs{ST@trace}}
1671 % \changes{v4.1g}{2020/02/02}{\cs{ST@stretchht} is no longer needed}
1672 % \begin{macrocode}
1673 \ST@trace@cr\thr@@{Added par box with height \the\ST@pboxht}%
1674 \global\advance\ST@pageleft -\ST@pboxht
1675 \global\advance\ST@pageleft -0.1\ST@pboxht
1676 \global\ST@prevht\ST@pboxht
1677 \global\ST@pboxht\z@
1678 \fi
1679 % \end{macrocode}
1680 % |\ST@toadd| is the value of the optional argument of |\\|.
1681 % \begin{macrocode}
1682 \global\advance\ST@pageleft -\ST@toadd
1683 \global\ST@toadd=\z@
1684 \ST@trace@cr\thr@@{Space left for tabular: \the\ST@pageleft}%
1685 }
1686 % \end{macrocode}
1687 % This line is necessary because the tablehead has to be inserted
1688 % *after* the following |\if\else\fi|-clause. For this purpose
1689 % |\ST@next| is used by |\ST@newpage|. But we need to make sure
1690 % that |\ST@next| is not undefined when |\ST@newpage| is \emph{not}
1691 % called. In the middle of tableprocessing it shoud be an *empty*
1692 % macro (*not* |\relax|).% (15.2.91)
1693 % \changes{v4.1e}{2001/08/21}{Moved the default definition of
1694 % \cs{ST@next} out of the \cs{if} clause}
1695 % \begin{macrocode}
1696 \noalign{\global\let\ST@next\@empty}%
1697 % \end{macrocode}
1698 % When the |\ST@pageleft| has become negative, the last row was so
1699 % high that the supertabular doesn't fit on the current page after
1700 % all. In this case we will skip the current page and start at the
1701 % top of the next one; otherwise \TeX\ will move this part of the
1702 % table to a new page anyway, probably with a message about an
1703 % overfull |\vbox|.
1704 % \begin{macrocode}
1705 \ifnum\ST@pageleft<\z@
1706 \ST@skippage
1707 \else
1708 % \end{macrocode}
1709 % When there is not enough space left on the current page, we start
1710 % a new page. To compute the amount of space needed we use the
1711 % height of the previous row (|\ST@prevht|) as an estimation of
1712 % the height of the next row. If we are processing a
1713 % \Lenv{mpsupertabular} we need to take the height of the footnotes
1714 % into account as well.
1715 % \changes{v4.0g}{1997/04/12}{Leave room for both \cs{ST@tailht}
1716 % \emph{and} \cs{ST@prevht}}
1717 % \changes{v4.1a}{1997/09/19}{Take care of space needed for
1718 % footnotes and footnoterule}
1719 % \begin{macrocode}
1720 \noalign{\global\@tempdima\ST@tailht
1721 \global\advance\@tempdima\ST@prevht
1722 \ifST@mp
1723 \ifvoid\@mpfootins\else
1724 \global\advance\@tempdima\ht\@mpfootins
1725 \global\advance\@tempdima 3pt
1726 \fi
1727 \fi}
1728 \ifnum\ST@pageleft<\@tempdima
1729 \ST@newpage
1730 \fi
1731 \fi
1732 \ST@next}
1733 % \end{macrocode}
1734 % \end{macro}
1735 %
1736 % \begin{macro}{\ST@skipfirstpart}
1737 % \changes{v4.0d}{1997/03/06}{Added new macro.}
1738 % \changes{v4.0e}{1997/04/09}{Renamed from \cs{ST@skippage}}
1739 % This macro skips the current page and moves the entire
1740 % supertabular that has been built up sofar to the next page.
1741 % \begin{macrocode}
1742 \def\ST@skipfirstpart{%
1743 \noalign{%
1744 \ST@trace\tw@{Tabular too high, moving to next page}%
1745 % \end{macrocode}
1746 % In order for this to work properly we need to adapt the value of
1747 % |\ST@pageleft|. When this macro is called it has a negative
1748 % value. We should add the height of the next page to that
1749 % (|\@colroom|). From the result the `normal' height of the
1750 % supertabular should be substracted (|\@colroom| -
1751 % |\pagetotal|). This could be coded as follows:
1752 %\begin{verbatim}
1753 % \ST@dimen\@colroom
1754 % \advance\ST@dimen-\pagetotal
1755 % \global\advance\ST@pageleft\@colroom
1756 % \global\advance\ST@pageleft-\ST@dimen
1757 %\end{verbatim}
1758 % When you examine the code you will note that |\@colroom| is added
1759 % \emph{and} subtracted. Therefor the code above can be simplified
1760 % to:
1761 % \begin{macrocode}
1762 \global\advance\ST@pageleft\pagetotal
1763 % \end{macrocode}
1764 % Then we can set |\ST@pagesofar| to $0$...
1765 % \begin{macrocode}
1766 \global\ST@pagesofar\z@
1767 % \end{macrocode}
1768 % ... and start the new page, but in this special case we need to
1769 % trigger the output routine directly by issuing a |\penalty|
1770 % rather than calling |\newpage| as that macro effectively issues a
1771 % |\vskip-\maxdepth| which makes the first two rows of the tabular
1772 % overlap.
1773 % \changes{v4.2b}{2021-02-14}{Issue a \cs{penalty} instead of
1774 % \cs{newpage} to trigger the output routine.}
1775 % \begin{macrocode}
1776 \penalty -\@M
1777 % \end{macrocode}
1778 %
1779 % Finally we make sure that this macro can only be executed once
1780 % for each supertabular by changing the definition of
1781 % |\ST@skippage|.
1782 % \changes{v4.0e}{1997/04/09}{Make sure that only the first part of a
1783 % supertabular can be moved to the next page.}
1784 % \begin{macrocode}
1785 \global\let\ST@skippage\ST@newpage
1786 }}
1787 % \end{macrocode}
1788 % \end{macro}
1789 %
1790 % \begin{macro}{\ST@newpage}
1791 % \changes{v3.7b}{1994/05/16}{Added macro, split off from
1792 % \cmd\ST@cr}
1793 % This macro performs the actions necessary to start a new page.
1794 % \begin{macrocode}
1795 \def\ST@newpage{%
1796 \noalign{\ST@trace\tw@{Starting new page, writing tail}}%
1797 % \end{macrocode}
1798 % Output |\tabletail|, close the tabular environment, close a
1799 % \Lenv{mnipage} if necessary, output all material and start a
1800 % fresh new page.
1801 % \changes{v4.1a}{1997/09/19}{Close minipage if we are in
1802 % \Lenv{mpsupertabular}}
1803 % \begin{macrocode}
1804 \@tabletail
1805 \ifST@star
1806 \csname endtabular*\endcsname
1807 \else
1808 \endtabular
1809 \fi
1810 \ifST@mp
1811 \endminipage
1812 \fi
1813 % \end{macrocode}
1814 %
1815 % Then we make sure that the macro |\ST@skippage| can no longer be
1816 % executed for this supertabular by changing the definition of it.
1817 % \changes{v4.0d}{1997/03/06}{Use \cs{org@tabular} instead of
1818 % \cs{tabular}}
1819 % \changes{v4.0e}{1997/04/09}{Make sure that only the first part of a
1820 % supertabular can be moved to the next page.}
1821 % \changes{v4.0f}{1997/04/11}{Use \cs{org@tabular*} instead of
1822 % \cs{tabular*}}
1823 % \changes{v4.0i}{1997/09/18}{Added \cs{noindent}}
1824 % \changes{v4.1a}{1997/09/19}{Open new minipage if we are in
1825 % \Lenv{mpsupertabular}}
1826 % \begin{macrocode}
1827 \global\let\ST@skippage\ST@newpage
1828 \newpage\@calnextpageht
1829 \let\ST@next\@tablehead
1830 \ST@trace\tw@{writing head}%
1831 \ifST@mp
1832 \noindent\minipage{\columnwidth}%
1833 \parfillskip\ST@parfillskip
1834 \rightskip \ST@rightskip
1835 \leftskip \ST@leftskip
1836 \fi
1837 \noindent
1838 \ifST@star
1839 \expandafter\csname org@tabular*\expandafter\endcsname
1840 \expandafter{\expandafter\ST@wd\expandafter}%
1841 \expandafter{\ST@tableformat}%
1842 \else
1843 \expandafter\org@tabular\expandafter{\ST@tableformat}%
1844 \fi}
1845 % \end{macrocode}
1846 % \end{macro}
1847 %
1848 % \begin{macrocode}
1849 %</package>
1850 % \end{macrocode}
1851 %
1852 % \Finale
1853 \endinput