The supertabular environment^{∗}

Johannes Braams and Theo Jurriens

1997/02/20

1 Introduction

The package supertabular offers a new environment, the supertabular environment. As the name indicates it is an extension of the normal tabular environment.

With the original tabular environment a tabular must always fit on one page. If the tabular becomes too large the text overwrites the page’s bottom margin and you get an Overfull vbox message.

The supertabular environment uses the tabular environment internally, but it evaluates the used space every time it gets a \\ command. If the tabular reaches the textheight, it automatically inserts an optional tabletail, an \end{tabular} command, starts a new page, a new tabular environment and inserts the optional tablehead on the new page continuing the tabular.

2 User interface

The package supertabular has three options, they control the amount of information that is written to the .log file.

1. The option errorshow (the default) doens’t write any extra information.

2. The option pageshow writes information about when and why supertabular decides to break the tabular environment in order to produce a new page.

3. The option debugshow also adds information about each line that is added to the tabular.

Below is a description of the new commands and environments that this package provides.

\tablefirsthead The command \tablefirsthead takes one argument, it defines the contents of the first occurence of the tabular head. The use of this command is optional. Don’t forget to close the head by a \\.

\tablehead The command \tablehead takes one argument, it defines the contents of all subsequent ocurrences of the tabular head. Don’t forget to close the head by a \\

\tabletail The command \tabletail takes one argument, it defines something which

should be inserted before each \end{tabular}, except the last.

\tablelasttail The command \tablelasttail takes one argument, it defines something which should be inserted before the last \end{tabular}. The use of this command is optional.

∗This file has version number v4.0c, last revised 1997/02/20.

\topcaption These commands all take the same arguments as L^{A}TEX’s standard \caption

\bottomcaption
\tablecaption

command. They provide a caption for the super-table, either at the top or at the bottom of the table. When \tablecaption is used the caption will be placed at the default location, which is at the top.

supertabular The environments supertabular and supertabular* can be used much like the supertabular* standard L^{A}TEX environments tabular and tabular*. \shrinkheight The allowed maximimum height of a part of the supertabular on a page can be

adjusted using the command \shrinkheight. It takes one argument, the length with which to shrink (positive value) or grow (negative value) the allowed height.

3 Weak points

• When the material of a normal entry (not a p-arg) becomes larger than the estimated \ST@lineht, overfull \vboxes will be produced at all.

• When the last p-arg on a page gets more than 4 lines (probably even more than 3 lines) it will result in an overfull \vbox. Also some combinations of

\baselinestretch \arraystretch and a large font may lead to one line

too much.

• if accidentally the last line of the tabular produces a newpage, on the next page the tabletail will be written immediately after the tablehead. Depending on the contents this may result in an error message regarding misplaced

\noalign.

A quick but not very elegant solution: shrink the allowed height of the table with the command \shrinkheight{...pt} after the first \\ of the supertabular.

4 Examples

Here is an example of a supertabular. You will find the definitions after of the supertabular.

Number Number^{2} Number^{4} Number!
1  1  1  1
2  4  16  2
3  9  81  6
4  16  256  24
5  25  625  120
6  36  1296  720
7  49  2401  5040
8  64  4096  40320
9  81  6561  362880
10  100  10000 3628800

continued on next page

continued from previous page

Number Number^{2} Number^{4}  Number!
11  121  14641  39916800
12  144  20736  479001600

13  169  28561 6.22702080E+9

14  196  38416 8.71782912E+10
15  225  50625 1.30767437E+12
16  256  65536 2.09227899E+13
17  289  83521 3.55687428E+14
18  324  104976 6.40237370E+15
19  361  130321 1.21645100E+17
20  400  160000 2.43290200E+18

Table 1: This table is split across pages

And here is (part of) the user input for the table above:

\begin{center}
\tablefirsthead{%
\hline
\multicolumn{1}{|c}{\tbsp Number} &
\multicolumn{1}{c}{Number$^2$} &
Number$^4$ &
\multicolumn{1}{c|}{Number!} \\
\hline}
\tablehead{%
\hline
\multicolumn{4}{|l|}{\small\sl continued from previous page}\\
\hline
\multicolumn{1}{|c}{\tbsp Number} &
\multicolumn{1}{c}{Number$^2$} &
Number$^4$ &
\multicolumn{1}{c|}{Number!} \\
\hline}
\tabletail{%
\hline
\multicolumn{4}{|r|}{\small\sl continued on next page}\\
\hline}
\tablelasttail{\hline}
\bottomcaption{This table is split across pages}
\begin{supertabular}{|r@{\hspace{6.5mm}}|r@{\hspace{5.5mm}}|r|r|}
1   &     1  &        1  &           1    \\
2   &     4  &       16  &           2    \\
3   &     9  &       81  &           6    \\
4   &    16  &      256  &          24    \\[5mm]
...

    19  &   361  &   130321  &  1.21645100E+17\\
    20  &   400  &   160000  &  2.43290200E+18\\
    \end{supertabular}
    \end{center}

Here is another example whith a p column-definition. The tablehead is the same as above. The tabletail is a double \hline; \arraystretch is set to 1.5 and the font size is \small.

Table 2: This table should also be split accross pages.

Number Number^{2} Number^{4}  Number!
1  1  1 here is a relative short entry
2  1  1 and here is a long entry, where

line breaks and line breaks and line breaks have to occur

3  1  1 and here is a long entry, where

line breaks and line breaks and line breaks have to occur

4  1  1 and here is a long entry, where

line breaks and line breaks and line breaks have to occur

5  1  1 here is a relative short entry
6  1  1 and here is a long entry, where

line breaks and line breaks and line breaks have to occur

7  1  1 and here is a long entry, where

line breaks and line breaks and line breaks have to occur

8  1  1 and here is a long entry, where

line breaks and line breaks and line breaks have to occur

9  1  1 and here is a long entry, where

line breaks and line breaks and line breaks have to occur

10  1  1 and here is a long entry, where

line breaks and line breaks and line breaks have to occur

11  1  1 and here is a long entry, where

line breaks and line breaks and line breaks have to occur

12  1  1 here is a relative short entry
13  1  1 and here is a long entry, where

line breaks and line breaks and line breaks have to occur

14  1  1 and here is a long entry, where

line breaks and line breaks and line breaks have to occur

continued on next page

Number Number^{2} Number^{4}  Number!
15  1  1 and here is a long entry, where

line breaks and line breaks and line breaks have to occur

16  1  1 and here is a long entry, where

line breaks and line breaks and line breaks have to occur

17  1  1 and here is a long entry, where

line breaks and line breaks and line breaks have to occur

18  1  1 and here is a long entry, where

line breaks and line breaks and line breaks have to occur

Here is the same table again, but this time using the supertabular* environment and stretching the table to the full width of the text.

Table 3: This table should also be split accross pages.

Number  Number^{2}  Number^{4}  Number!
1  1  1 here is a relative short entry
2  1  1 and here is a long entry, where

line breaks and line breaks and line breaks have to occur

3  1  1 and here is a long entry, where

line breaks and line breaks and line breaks have to occur

4  1  1 and here is a long entry, where

line breaks and line breaks and line breaks have to occur

5  1  1 here is a relative short entry
6  1  1 and here is a long entry, where

line breaks and line breaks and line breaks have to occur

7  1  1 and here is a long entry, where

line breaks and line breaks and line breaks have to occur

8  1  1 and here is a long entry, where

line breaks and line breaks and line breaks have to occur

9  1  1 and here is a long entry, where

line breaks and line breaks and line breaks have to occur

continued on next page

Number  Number^{2}  Number^{4}  Number!
10  1  1 and here is a long entry, where

line breaks and line breaks and line breaks have to occur

11  1  1 and here is a long entry, where

line breaks and line breaks and line breaks have to occur

12  1  1 here is a relative short entry
13  1  1 and here is a long entry, where

line breaks and line breaks and line breaks have to occur

14  1  1 and here is a long entry, where

line breaks and line breaks and line breaks have to occur

15  1  1 and here is a long entry, where

line breaks and line breaks and line breaks have to occur

16  1  1 and here is a long entry, where

line breaks and line breaks and line breaks have to occur

17  1  1 and here is a long entry, where

line breaks and line breaks and line breaks have to occur

18  1  1 and here is a long entry, where

line breaks and line breaks and line breaks have to occur

5 Known problems

• When a float occurs on the same page as the start of a supertabular you can expect unexpected results.

When the float was defined on the same page you might end up with the first part of the supertabular on a page by its own.

• You should not use the supertabular inside a floating-environment such as table as this will result in TEX trying to put the whole supertabular on one page.

• In some instances you might still end up with overfull \vbox messages.

• Sometimes the last page of the supertabular contains just an empty head an tail.

6 The Implementation

1 ⟨∗package⟩

 2 \newcount\c@tracingst
 3 \DeclareOption{errorshow}{\c@tracingst\z@}
 4 \DeclareOption{pageshow}{\c@tracingst\tw@}
 5 \DeclareOption{debugshow}{\c@tracingst5\relax}
 6 \ProcessOptions
\topcaption \bottomcaption The user-commands \topcaption and \bottomcaption set the flag @topcaption

to determine where to put the tablecaption. The default is to put the caption on the top of the table

 7 \newif\if@topcaption \@topcaptiontrue
 8 \def\topcaption{\@topcaptiontrue\tablecaption}
 9 \def\bottomcaption{\@topcaptionfalse\tablecaption}

\tablecaption This command has to function exactly like \caption does, except it has to store its argument (and the optional argument) for later processing within the supertabular environment.

10 \long\def\tablecaption{%
11 \refstepcounter{table}\@dblarg{\@xtablecaption}}
12 \long\def\@xtablecaption[#1]#2{%
13 \long\gdef\@process@tablecaption{\ST@caption{table}[#1]{#2}}}
14 \global\let\@process@tablecaption\relax

\ifST@star This switch is used in the internal macros to remember which kind of environment was started.

15 \newif\ifST@star

\ST@wd For the supertabular* environment it is necessary to store the intended width of the tabular.

16 \newdimen\ST@wd

\ST@caption This is a redefinition of LaTeX’s caption, makecaption is called within a group so as not to return to globally. also a fix is made for the ‘feature’ of the makecaption of article.sty and friends that a caption ALWAYS gets a

at the top and NONE at the bottom. If a user wants to precede his table with a caption this results in a collision.

17 \long\def\ST@caption#1[#2]#3{\par%
18 \addcontentsline{\csname ext@#1\endcsname}{#1}%
19  {\protect\numberline{%
20  \csname the#1\endcsname}{\ignorespaces #2}}
21 \begingroup
22  \@parboxrestore
23  \normalsize
24  \if@topcaption \vskip -10\p@ \fi
25  \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
26  \if@topcaption \vskip 10\p@ \fi
27 \endgroup}
\tablehead \tablefirsthead  \tablehead activates the new tabular \cr commands.
28 \newcommand\tablehead[1]{%
29 \gdef\@tablehead{%

30 \noalign{%
31  \global\let\@savcr=\\
32  \global\let\\=\cr}%
33  #1%
34  \noalign{\global\let\\=\@savcr}}}
35 \tablehead{}
36 \newcommand\tablefirsthead[1]{\gdef\@table@first@head{#1}}

\tabletail \tablelasttail If the user uses an extra amount of tabular-data (like \multicolumn) in \tabletail TEX starts looping because of the definition of \ST@cr. So make \\ act like just a \cr inside this tail to prevent the loop. Save and restore the value of \\

37 \newcommand\tabletail[1]{%
38 \gdef\@tabletail{%
39  \noalign{%
40  \global\let\@savcr=\\
41  \global\let\\=\cr}%
42  #1%
43  \noalign{\global\let\\=\@savcr}}}
44 \tabletail{}
45 \newcommand\tablelasttail[1]{\gdef\@table@last@tail{#1}}

\sttraceon \sttraceoff There now is a possiblity to follow the decisions supertabular makes about breaking the tabular. This has to be enabled when converting this file with docstrip to a

.sty file.
46 \newcommand\sttraceon{\c@tracingst5\relax}
47 \newcommand\sttraceoff{\c@tracingst\z@}

\ST@trace A macro that gets the trace message as its argument

48 \newcommand\ST@trace[2]{%
49 \ifnum\c@tracingst>#1\relax
50  \GenericWarning
51  {(supertabular)\@spaces\@spaces}
52  {Package supertabular: #2}%
53 \fi

54 }

\ST@pageleft This register holds the estimate of the amount of space left over on the current page. This is used in the decision when to start a new page.

55 \newdimen\ST@pageleft

\shrinkheight A command to diminish the value of \ST@pageleft if necessary.

56 \newcommand*\shrinkheight[1]{%
57 \noalign{\global\ST@pageleft=#1\relax}}

\ST@headht \ST@tailht The register ST@headht will hold the height of the first head of a supertabular environment; the register \ST@tailht will hold the height of table tail (if any)

58 \newdimen\ST@headht
59 \newdimen\ST@tailht

\ST@pagesofar The register \ST@pagesofar is used to store the estimate of the amount of page already filled up.

60 \newdimen\ST@pagesofar

\ST@pboxht The measured (total) height of a parbox-argument

61 \newdimen\ST@pboxht

\ST@lineht The estimated height of a normal line.

62 \newdimen\ST@lineht

\ST@toadd When a tabular row is ended with \\[...] we need to temporarily store the optional argument in \ST@toadd.

63 \newdimen\ST@toadd

\ST@dimen A private scratch dimension register.

64 \newdimen\ST@dimen

\ST@pbox A box register to temporarily store the contents of a parbox.

65 \newbox\ST@pbox
\ST@tabularcr \ST@xtabularcr \ST@argtabularcr These are redefinitions of \@tabularcr and \@xtabularcr. This is needed to

include \ST@cr in the definition of \@xtabularcr.

All redefined macros have names that are similar to the original names, except with a leading ’ST’

66 \def\ST@tabularcr{%
67 {\ifnum0=`}\fi
68 \@ifstar{\ST@xtabularcr}{\ST@xtabularcr}}
69 \def\ST@xtabularcr{%
70 \@ifnextchar[{\ST@argtabularcr}{\ifnum0=`{\fi}\cr\ST@cr}}
71 \def\ST@argtabularcr[#1]{%
72 \ifnum0=`{\fi}%
73 \ifdim #1>\z@
74  \unskip\ST@xargarraycr{#1}
75 \else
76  \ST@yargarraycr{#1}%
77 \fi}

\ST@xargarraycr \ST@yargarraycr In this case we need to copy the value of the optional argument of \\ in our private

register \ST@toadd.
78 \def\ST@xargarraycr#1{%
79 \@tempdima #1\advance\@tempdima \dp \@arstrutbox
80 \vrule \@height\z@ \@depth\@tempdima \@width\z@ \cr
81 \noalign{\global\ST@toadd=#1}\ST@cr}

Here we need to insert \ST@cr

82 \def\ST@yargarraycr#1{%
83 \cr\noalign{\vskip #1\global\ST@toadd=#1}\ST@cr}

\ST@startpbox The macros that deal with parbox columns need to be redefined, because we need to know the size of the parbox.

84 \def\ST@startpbox#1{%

To achieve our goal we need to save the text in box.

85 \setbox\ST@pbox\vtop\bgroup\hsize#1\@arrayparboxrestore}

\ST@astartpbox Our version of \@astartpbox.
 86 \def\ST@astartpbox#1{%
 87 \bgroup\hsize#1%
 88 \setbox\ST@pbox\vtop\bgroup\hsize#1\@arrayparboxrestore}
\ST@endpbox \ST@aendpbox Our version of \@endpbox and \@aendpbox.
 89 \def\ST@endpbox{%
 90 \@finalstrut\@arstrutbox\par\egroup
 91 \ST@dimen=\ht\ST@pbox
 92 \advance\ST@dimen by \dp\ST@pbox
 93 \ifnum\ST@pboxht<\ST@dimen
 94  \global\ST@pboxht=\ST@dimen
 95 \fi
 96 \ST@dimen=\z@
 97 \box\ST@pbox\hfil}
 98 \def\ST@aendpbox{%
 99 \@finalstrut\@arstrutbox\par\egroup
100 \ST@dimen=\ht\ST@pbox
101 \advance\ST@dimen by \dp\ST@pbox
102 \ifnum\ST@pboxht<\ST@dimen
103  \global\ST@pboxht=\ST@dimen
104 \fi
105 \ST@dimen=\z@
106 \unvbox\ST@pbox\egroup\hfil}

\estimate@lineht Estimates the height of normal line taking \arraystretch into account.

107 \def\estimate@lineht{%
108 \ST@lineht=\arraystretch \baslineskp
109 \global\advance\ST@lineht by 1\p@
110 \ST@trace\tw@{Average line height:\the\ST@lineht}%

111 }

\@calfirstpageht Estimates the space left on the current page and decides whether the tabular can be started on this page or on a new page.

112 \def\@calfirstpageht{%
113 \ST@trace\tw@{Calculating height of tabular on first page}%

The TEX register \pagetotal contains the height of the page sofar, the L^{A}TEX register \@colroom contains the height of the column.

114 \global\ST@pagesofar\pagetotal
115 \global\ST@pageleft\@colroom
116 \ST@trace\tw@{Height of text = \the\pagetotal; \MessageBreak
117  Heigth of page = \the\ST@pageleft}%

When we are in twocolumn mode TEX may still be collecting material for the first column although there seems to be no space left. In this case we have to check against two times \ST@pageleft.

118 \if@twocolumn
119  \ST@trace\tw@{two column mode}%
120  \if@firstcolumn
121  \ST@trace\tw@{First column}%
122  \ifnum\ST@pagesofar > \ST@pageleft
123  \global\ST@pageleft=2\ST@pageleft

124  \ifnum\ST@pagesofar > \ST@pageleft
125  \newpage\@calnextpageht
126  \ST@trace\tw@{starting new page}%
127  \else

In this case we’re in the second column, so we have to compensate for the material in the first column.

128  \ST@trace\tw@{Second column}%
129  \global\advance\ST@pageleft -\ST@pagesofar
130  \global\advance\ST@pageleft -\@colroom
131  \fi
132  \fi
133  \fi
134 \else

In one column mode there is a simple decision.

135  \ST@trace\tw@{one column mode}%
136  \ifnum\ST@pagesofar > \ST@pageleft
137  \ST@trace\tw@{starting new page}%
138  \newpage\@calnextpageht

When we are not starting a new page subtract the size of the material already on it from the available space.

139  \else
140  \global\advance\ST@pageleft by -\ST@pagesofar
141  \global\ST@pagesofar\z@
142  \fi
143 \fi
144 \ST@trace\tw@{Available height: \the\ST@pageleft}%

Now we need to know the height of the head of the table. In order to measure this we typeset it in a normal tabular environment.

145 \ifx\@@tablehead\@empty
146  \ST@headht=\z@
147 \else
148  \setbox\@tempboxa=\vbox{\@arrayparboxrestore
149  \ST@restore
150  \expandafter\tabular\expandafter{\ST@tableformat}%
151  \@@tablehead\endtabular}%
152  \ST@headht=\ht\@tempboxa\advance\ST@headht\dp\@tempboxa
153 \fi
154 \ST@trace\tw@{Height of head: \the\ST@headht}%

To decide when to start a new page, we need to know the vertical size of the tail of the table.

155 \ifx\@tabletail\@empty
156  \ST@tailht=\z@
157 \else
158  \setbox\@tempboxa=\vbox{\@arrayparboxrestore
159  \ST@restore
160  \expandafter\tabular\expandafter{\ST@tableformat}
161  \@tabletail\endtabular}
162  \ST@tailht=\ht\@tempboxa\advance\ST@tailht\dp\@tempboxa
163 \fi

We add the average height of a line to this because when we decide to continue the tabular we need to have enough space left for one line and the tail.

164 \advance\ST@tailht by \ST@lineht
165 \ST@trace\tw@{Height of tail: \the\ST@tailht}%
166 \ST@trace\tw@{Maximum height of tabular: \the\ST@pageleft}%
167 \@tempdima\ST@headht

Now we decide whether we can continue on the current page or whether we need to start on a new page. We assume that the minimum height of a tabular is the height of the head, the tail and one line of data. If that doesn’t fit a new page is started.

168 \advance\@tempdima\ST@lineht
169 \advance\@tempdima\ST@tailht
170 \ST@trace\tw@{Minimum height of tabular: \the\@tempdima}%
171 \ifnum\@tempdima>\ST@pageleft
172  \ST@trace\tw@{starting new page}%
173  \newpage\@calnextpageht
174 \fi

175 }

\@calnextpageht This calculates the maximum height of the tabular on all subsequent pages of the supertabular environment.

176 \def\@calnextpageht{%
177 \ST@trace\tw@{Calculating height of tabular on next page}%
178 \global\ST@pageleft\@colroom
179 \global\ST@pagesofar=\z@
180 \ST@trace\tw@{Maximum height of tabular: \the\ST@pageleft}%

181 }

\x@supertabular The body of the beginning of both environments is stored in a single macro as the code is shared. If the caption should come at the top we insert it here.

182 \def\x@supertabular{%
183 \if@topcaption \@process@tablecaption \fi

Save the original definition of \\.

184 \global\let\@oldcr=\\

Save the current value of \baselineskip, as we need it in the calculation of the average height of a line.

185 \def\baslineskp{\baselineskip}%

We have to check whether array.sty was loaded, because some of the internal macros have different names.

186 \ifx\undefined\@classix

Save old \@tabularcr and insert the definition of \@stabularcr.

187  \let\@@tabularcr\@tabularcr
188  \let\@tabularcr\ST@tabularcr

Activate the new parbox algorithm.

189  \let\org@startpbox=\@startpbox
190  \let\org@endpbox=\@endpbox
191  \let\@@startpbox=\ST@startpbox
192  \let\@@endpbox=\ST@endpbox
193 \else

When array.sty was loaded things are a bit different.

194  \let\@@tabularcr\@arraycr
195  \let\@arraycr\ST@tabularcr
196  \let\org@startpbox=\@startpbox
197  \let\org@endpbox=\@endpbox
198  \let\@startpbox=\ST@astartpbox
199  \let\@endpbox=\ST@aendpbox
200 \fi

Check if the head of the table should be different for the first and subsequent pages.

201 \ifx\@table@first@head\undefined
202  \let\@@tablehead=\@tablehead
203 \else
204  \let\@@tablehead=\@table@first@head
205 \fi

Now we can estimate the average line height and the height of the first page of the supertabular.

206 \estimate@lineht
207 \@calfirstpageht

208 }

\supertabular We start by looking for an optional argument, which will be duly ignored as it seems to make no sense to try to align a multipage table in the middle...

209 \def\supertabular{%
210 \@ifnextchar[{\@supertabular}%]
211  {\@supertabular[]}}

We can now save the preamble of the tabular in a macro.

212 \def\@supertabular[#1]#2{%
213 \def\ST@tableformat{#2}%
214 \ST@trace\tw@{Starting a new supertabular}%

Then remember that this is not a supertabular* environment.

215 \global\ST@starfalse

Most of the following code is shared between the supertabular and supertabular* environments. So to avoid duplication it is stored in a macro.

216 \x@supertabular

Finally start a normal tabular environment.

217 \expandafter\tabular\expandafter{\ST@tableformat}%
218 \@@tablehead}

\supertabular* We start by looking for the optional argument of the tabular environment.

219 \@namedef{supertabular*}#1{%
220 \@ifnextchar[{\@nameuse{@supertabular*}{#1}}%
221  {\@nameuse{@supertabular*}{#1}[]}%]

222 }

We start by saving the intended width and the preamble of the tabular*.

223 \@namedef{@supertabular*}#1[#2]#3{%
224 \ST@trace\tw@{Starting a new supertabular*}%
225 \def\ST@tableformat{#3}%
226 \ST@wd=#1\relax
227 \global\ST@startrue

Now we can call the common code for both environments.

228 \x@supertabular

And we can start a normal tabular* environment.

229 \expandafter\csname tabular*\expandafter\endcsname
230 \expandafter{\expandafter\ST@wd\expandafter}%
231 \expandafter{\ST@tableformat}%
232 \@@tablehead}%
\endsupertabular \endsupertabular* This closes both environments.
233 \def\endsupertabular{%
234 \ifx\@table@last@tail\undefined
235  \@tabletail
236 \else
237  \@table@last@tail
238 \fi
239 \csname endtabular\ifST@star*\fi\endcsname

Restore the original definition of \@tabularcr

240 \ST@restore

Check if we have to insert a caption and restore to default behaviour of putting captions at the top.

241 \if@topcaption
242 \else
243  \@process@tablecaption
244  \@topcaptiontrue
245 \fi

Restore the meaning of \\ to the one it had before the start of this environment. Also re-initialize some control-sequences

246 \global\let\\\@oldcr
247 \let\@table@first@head\undefined
248 \let\@table@last@tail\undefined
249 \global\let\@process@tablecaption\relax
250 \ST@trace\tw@{Ended a supertabular\ifST@star*\fi}%

251 }

The definition of the ending of the supertabular* environment is simple:

252 \expandafter\let\csname endsupertabular*\endcsname\endsupertabular

\ST@restore This macro restores the orignal definitions of the macros that handle parbox entries and the macros that handle the end of the row.

253 \def\ST@restore{%
254 \ifx\undefined\@classix
255  \let\@tabularcr\@@tabularcr
256  \let\@@startpbox\org@startpbox
257  \let\@@endpbox\org@endpbox
258 \else
259  \let\@arraycr\@@tabularcr
260  \let\@startpbox\org@startpbox
261  \let\@endpbox\org@endpbox
262 \fi

263 }

\ST@cr This macro is called by each \\ inside the tabular environment. It updates the estimate of the amount of space left on the current page and starts a new page if necessary.

264 \def\ST@cr{%
265 \noalign{%
266  \ifnum\ST@pboxht<\ST@lineht

If there is a non-empty line, but an empty parbox, then \ST@pboxht might be non-zero, but too small thereby breaking the algorithm. Therefore we estimate the height of the line to be \ST@lineht in this case.

267  \global\advance\ST@pageleft -\ST@lineht
268  \else

When the parbox was not empty we take into account its height (plus a bit extra).

269  \ST@trace\thr@@{Added par box with height \the\ST@pboxht}%
270  \global\advance\ST@pageleft -\ST@pboxht
271  \global\advance\ST@pageleft -0.1\ST@pboxht
272  \global\ST@pboxht\z@
273  \fi

\ST@toadd is the value of the optional argument of \\.

274  \global\advance\ST@pageleft -\ST@toadd
275  \global\ST@toadd=\z@
276  \ST@trace\thr@@{Space left for tabular: \the\ST@pageleft}%

277 }

When there is not enough space left we start a new page.

278 \ifnum\ST@pageleft<\ST@tailht
279  \ST@newpage
280 \else

This line is necessary because the tablehead has to be inserted *after* the \if\else\fi-clause. For this purpose \st@next is used. In the middle of tableprocessing it shoud be an *empty* macro (*not* \relax). (15.2.91)

281  \noalign{\global\let\ST@next\@empty}%
282 \fi\ST@next}

\ST@newpage This macro performs the actions necessary to start a new page.

283 \def\ST@newpage{%
284 \noalign{\ST@trace\tw@{Starting new page, writing tail}}%

Output \tabletail, close the tabular environment, output all material and start a fresh new page.

285 \@tabletail
286 \ifST@star
287  \csname endtabular*\endcsname
288 \else
289  \endtabular
290 \fi
291 \newpage\@calnextpageht
292 \let\ST@next\@tablehead
293 \ST@trace\tw@{writing head}%
294 \ifST@star
295  \expandafter\csname tabular*\expandafter\endcsname
296  \expandafter{\expandafter\ST@wd\expandafter}%

297  \expandafter{\ST@tableformat}%
298 \else
299  \expandafter\tabular\expandafter{\ST@tableformat}%
300 \fi}

301 ⟨/package⟩