% \CheckSum{739} % \iffalse %% File `supertabular.dtx'. %% Copyright (C) 1988 by Theo Jurriens %% P.O Box 800, 9700 AV Groningen %% Copyright (C) 1990-1997 by Johannes Braams %% Kooienswater 62 %% 2715 AJ Zoetermeer NL %% all rights reserved. %% %<*dtx> \ProvidesFile{supertabular.dtx} % %\NeedsTeXFormat{LaTeX2e} %\ProvidesPackage{supertabular} %\ProvidesFile{supertabular.drv} %\ProvidesFile{supertabular.dtx} [1997/02/04 v4.0b the supertabular environment] % %<*driver> \documentclass{ltxdoc} \usepackage{supertabular} \newcommand{\tbsp}{\rule{0pt}{18pt}} \begin{document} \providecommand{\Lenv}[1]{\textsf{#1}} \providecommand{\pkg}[1]{\texttt{#1}} \providecommand{\file}[1]{\texttt{#1}} \DocInput{supertabular.dtx} \end{document} % % \fi % % \changes{v4.0a}{1996/11/28}{Cleanup of the code, now a \file{.dtx} % source file} % % \GetFileInfo{supertabular.dtx} % \title{The \texttt{supertabular} environment\thanks{This file % has version number \fileversion, last % revised \filedate.}} % \author{Johannes Braams and Theo Jurriens} % \date{\filedate} % \maketitle % % \section{Introduction} % % The package \pkg{supertabular} offers a new environment, the % \Lenv{supertabular} environment. As the name indicates it is an % extension of the normal \Lenv{tabular} environment. % % With the original \Lenv{tabular} environment a tabular must % always fit on \emph{one} page. If the tabular becomes too large % the text overwrites the page's bottom margin and you get an % \texttt{Overfull vbox} message. % % The \Lenv{supertabular} environment uses the \Lenv{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 % \Lenv{tabular} environment and inserts the optional tablehead on % the new page continuing the tabular. % % \section{User interface} % % The package \pkg{supertabular} has three options, they control % the amount of information that is written to the \file{.log} % file. % \begin{enumerate} % \item The option \textsf{errorshow} (the default) doens't write % any extra information. % \item The option \textsf{pageshow} writes information about when % and why \pkg{supertabular} decides to break the tabular % environment in order to produce a new page. % \item The option \textsf{debugshow} also adds information about % each line that is added to the tabular. % \end{enumerate} % % Below is a description of the new commands and environments that % this package provides. % % \DescribeMacro{\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 |\\|. % % \DescribeMacro{\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 |\\| % % \DescribeMacro{\tabletail} % The command |\tabletail| takes one argument, it defines something % which should be inserted before each |\end{tabular}|, except % the last. % % \DescribeMacro{\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. % % \DescribeMacro{\topcaption} % \DescribeMacro{\bottomcaption} % \DescribeMacro{\tablecaption} % These commands all take the same arguments as \LaTeX's standard % |\caption| 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. % % \DescribeEnv{supertabular} % \DescribeEnv{supertabular*} % The environments \Lenv{supertabular} and \Lenv{supertabular*} % can be used much like the standard \LaTeX\ environments % \Lenv{tabular} and \Lenv{tabular*}. % % \DescribeMacro{\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. % % \section{Weak points} % % \begin{itemize} % \item When the material of a normal entry (not a p-arg) becomes % larger than the estimated |\ST@lineht|, overfull |\vbox|es % will be produced at all. % \item 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. % \item 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. % \end{itemize} % % \section{Examples} % % \DeleteShortVerb{\|} % Here is an example of a supertabular. You will find the % definitions after of the supertabular. % % \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\tbsp & 1 & 1 & 1 \\ % 2 & 4 & 16 & 2 \\ % 3 & 9 & 81 & 6 \\ % 4 & 16 & 256 & 24 \\[5mm] % 5 & 25 & 625 & 120 \\ % 6 & 36 & 1296 & 720 \\ % 7 & 49 & 2401 & 5040 \\ % 8 & 64 & 4096 & 40320 \\ % 9 & 81 & 6561 & 362880 \\ % 10 & 100 & 10000 & 3628800 \\ % 11 & 121 & 14641 & 39916800 \\ % 12 & 144 & 20736 & 479001600 \\[.5cm] % \hline & & & \\ % 13 & 169 & 28561 & 6.22702080E+9 \\[1cm] % 14 & 196 & 38416 & 8.71782912E+10\\ % 15 & 225 & 50625 & 1.30767437E+12\\ % 16 & 256 & 65536 & 2.09227899E+13\\ % 17 & 289 & 83521 & 3.55687428E+14\\[5mm] % 18 & 324 & 104976 & 6.40237370E+15\\ % 19 & 361 & 130321 & 1.21645100E+17\\ % 20 & 400 & 160000 & 2.43290200E+18\\ % \end{supertabular} % \end{center} % % And here is (part of) the user input for the table above: %\begin{verbatim} % \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} %\end{verbatim} % % Here is another example whith a \texttt{p} column-definition. The % tablehead is the same as above. The tabletail is a double % \verb|\hline|; \verb|\arraystretch| is set to \texttt{1.5} and % the font size is \verb|\small|. % % \begin{center} % \tablelasttail{\hline\hline} % \topcaption{This table should also be split accross pages.} % \renewcommand{\arraystretch}{1.5} % \small % \begin{supertabular}{| r@{\hspace{6.5mm}}|% % r@{\hspace{5.5mm}}| r p{5cm}|} % 1 & 1 & 1 & \tbsp 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\\ % 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\\ % \end{supertabular} % \end{center} % % Here is the same table again, but this time using the % \Lenv{supertabular*} environment and stretching the table to the % full width of the text. % % \begin{center} % \tablelasttail{\hline\hline} % \topcaption{This table should also be split accross pages.} % \renewcommand{\arraystretch}{1.5} % \small % \begin{supertabular*}{\textwidth}% % {| r@{\extracolsep{6.5mm plus 1fil}}|% % r@{\extracolsep{5.5mm plus 0.5fil}}|% % r@{\extracolsep{0mm plus 0.1fil}}% % p{5cm}|} % 1 & 1 & 1 & \tbsp 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\\ % 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\\ % \end{supertabular*} % \end{center} % % \MakeShortVerb{\|} % % \section{Known problems} % % \begin{itemize} % \item 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. % % \item You should not use the supertabular \emph{inside} a % floating-environment such as \texttt{table} as this will result % in \TeX\ trying to put the whole supertabular on \emph{one} % page. % % \item In some instances you might still end up with overfull % |\vbox| messages. % % \item Sometimes the last page of the supertabular contains just % an empty head an tail. % \end{itemize} % \StopEventually{} % % \section{The Implementation} % % \begin{macrocode} %<*package> \newcount\c@tracingst \DeclareOption{errorshow}{\c@tracingst\z@} \DeclareOption{pageshow}{\c@tracingst\tw@} \DeclareOption{debugshow}{\c@tracingst5\relax} \ProcessOptions % \end{macrocode} % % \begin{macro}{\topcaption} % \begin{macro}{\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 % \begin{macrocode} \newif\if@topcaption \@topcaptiontrue \def\topcaption{\@topcaptiontrue\tablecaption} \def\bottomcaption{\@topcaptionfalse\tablecaption} % \end{macrocode} % \end{macro} % \end{macro} % % \begin{macro}{\tablecaption} % This command has to function exactly like |\caption| does, except % it has to store its argument (and the optional argument) for % later processing \emph{within} the supertabular environment. % % \begin{macrocode} \long\def\tablecaption{% \refstepcounter{table}\@dblarg{\@xtablecaption}} \long\def\@xtablecaption[#1]#2{% \long\gdef\@process@tablecaption{\ST@caption{table}[#1]{#2}}} \global\let\@process@tablecaption\relax % \end{macrocode} % \end{macro} % % \begin{macro}{\ifST@star} % This switch is used in the internal macros to remember which % kind of environment was started. % \begin{macrocode} \newif\ifST@star % \end{macrocode} % \end{macro} % % \begin{macro}{\ST@wd} % For the \Lenv{supertabular*} environment it is necessary to % store the intended width of the tabular. % \begin{macrocode} \newdimen\ST@wd % \end{macrocode} % \end{macro} % % \begin{macro}{\ST@caption} % This is a redefinition of LaTeX's \@caption, \@makecaption is % called within a group so as not to return to \normalsize % globally. also a fix is made for the `feature' of the % \@makecaption of article.sty and friends that a caption ALWAYS % gets a \vskip 10pt at the top and NONE at the bottom. If a user % wants to precede his table with a caption this results in a % collision. % % \begin{macrocode} \long\def\ST@caption#1[#2]#3{\par% \addcontentsline{\csname ext@#1\endcsname}{#1}% {\protect\numberline{% \csname the#1\endcsname}{\ignorespaces #2}} \begingroup \@parboxrestore \normalsize \if@topcaption \vskip -10\p@ \fi \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par \if@topcaption \vskip 10\p@ \fi \endgroup} % \end{macrocode} % \end{macro} % % \begin{macro}{\tablehead} % \changes{v4.0a}{1996/11/28}{Locally reset \cs{}\cs{} to \cs{cr}} % \begin{macro}{\tablefirsthead} % |\tablehead| activates the new tabular |\cr| commands. % \begin{macrocode} \newcommand\tablehead[1]{% \gdef\@tablehead{% \noalign{% \global\let\@savcr=\\ \global\let\\=\cr}% #1% \noalign{\global\let\\=\@savcr}}} \tablehead{} \newcommand\tablefirsthead[1]{\gdef\@table@first@head{#1}} % \end{macrocode} % \end{macro} % \end{macro} % % \begin{macro}{\tabletail} % \begin{macro}{\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 |\\| % % \begin{macrocode} \newcommand\tabletail[1]{% \gdef\@tabletail{% \noalign{% \global\let\@savcr=\\ \global\let\\=\cr}% #1% \noalign{\global\let\\=\@savcr}}} \tabletail{} \newcommand\tablelasttail[1]{\gdef\@table@last@tail{#1}} % \end{macrocode} % \end{macro} % \end{macro} % % \begin{macro}{\sttraceon} % \changes{v3.7b}{1994/05/16}{Added macro} % \begin{macro}{\sttraceoff} % \changes{v3.7b}{1994/05/16}{Added macro} % 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 \texttt{docstrip} to a \texttt{.sty} % file. % \begin{macrocode} \newcommand\sttraceon{\c@tracingst5\relax} \newcommand\sttraceoff{\c@tracingst\z@} % \end{macrocode} % \end{macro} % \end{macro} % % \begin{macro}{\ST@trace} % A macro that gets the trace message as its argument % \begin{macrocode} \newcommand\ST@trace[2]{% \ifnum\c@tracingst>#1\relax \GenericWarning {(supertabular)\@spaces\@spaces} {Package supertabular: #2}% \fi } % \end{macrocode} % \end{macro} % % \begin{macro}{\ST@pageleft} % \changes{v3.7b}{1994/05/16}{Renamed from \cs{maxsize}} % \changes{v4.0a}{1996/11/28}{Renamed from \cs{page@left}} % 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. % \begin{macrocode} \newdimen\ST@pageleft % \end{macrocode} % \end{macro} % % \begin{macro}{\shrinkheight} % \changes{v4.0a}{1996/11/28}{New command} % A command to diminish the value of |\ST@pageleft| if necessary. % \begin{macrocode} \newcommand*\shrinkheight[1]{% \noalign{\global\ST@pageleft=#1\relax}} % \end{macrocode} % \end{macro} % % \begin{macro}{\ST@headht} % \begin{macro}{\ST@tailht} % The register |ST@headht| will hold the height of the first head % of a \Lenv{supertabular} environment; the register |\ST@tailht| % will hold the height of table tail (if any) % \begin{macrocode} \newdimen\ST@headht \newdimen\ST@tailht % \end{macrocode} % \end{macro} % \end{macro} % % \begin{macro}{\ST@pagesofar} % The register |\ST@pagesofar| is used to store the estimate of the % amount of page already filled up. % \begin{macrocode} \newdimen\ST@pagesofar % \end{macrocode} % \end{macro} % % \begin{macro}{\ST@pboxht} % The measured (total) height of a parbox-argument % \begin{macrocode} \newdimen\ST@pboxht % \end{macrocode} % \end{macro} % % \changes{v4.0b}{1997/02/04}{Removed the use of \cs{ST@pboxcorr}, % correction seems to be no longer necessary} % % \begin{macro}{\ST@lineht} % The estimated height of a normal line. % \begin{macrocode} \newdimen\ST@lineht % \end{macrocode} % \end{macro} % % \begin{macro}{\ST@toadd} % When a tabular row is ended with |\\[...]| we need to temporarily % store the optional argument in |\ST@toadd|. % \begin{macrocode} \newdimen\ST@toadd % \end{macrocode} % \end{macro} % % \begin{macro}{\ST@dimen} % A private scratch dimension register. % \begin{macrocode} \newdimen\ST@dimen % \end{macrocode} % \end{macro} % % \begin{macro}{\ST@pbox} % A box register to temporarily store the contents of a parbox. % \begin{macrocode} \newbox\ST@pbox % \end{macrocode} % \end{macro} % % \begin{macro}{\ST@tabularcr} % \begin{macro}{\ST@xtabularcr} % \begin{macro}{\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' % \begin{macrocode} \def\ST@tabularcr{% {\ifnum0=`}\fi \@ifstar{\ST@xtabularcr}{\ST@xtabularcr}} \def\ST@xtabularcr{% \@ifnextchar[{\ST@argtabularcr}{\ifnum0=`{\fi}\cr\ST@cr}} % \end{macrocode} % \end{macro} % \end{macro} % % \begin{macrocode} \def\ST@argtabularcr[#1]{% \ifnum0=`{\fi}% \ifdim #1>\z@ \unskip\ST@xargarraycr{#1} \else \ST@yargarraycr{#1}% \fi} % \end{macrocode} % \end{macro} % % \begin{macro}{\ST@xargarraycr} % \begin{macro}{\ST@yargarraycr} % In this case we need to copy the value of the optional argument % of |\\| in our private register |\ST@toadd|. % \begin{macrocode} \def\ST@xargarraycr#1{% \@tempdima #1\advance\@tempdima \dp \@arstrutbox \vrule \@height\z@ \@depth\@tempdima \@width\z@ \cr \noalign{\global\ST@toadd=#1}\ST@cr} % \end{macrocode} % \end{macro} % % Here we need to insert |\ST@cr| % \begin{macrocode} \def\ST@yargarraycr#1{% \cr\noalign{\vskip #1\global\ST@toadd=#1}\ST@cr} % \end{macrocode} % \end{macro} % % \begin{macro}{\ST@startpbox} % The macros that deal with parbox columns need to be redefined, % because we need to know the size of the parbox. % \changes{v4.0b}{1997/02/04}{Removed use of \cs{ST@pboxcorr}} % \begin{macrocode} \def\ST@startpbox#1{% % \end{macrocode} % To achieve our goal we need to save the text in box. % \begin{macrocode} \setbox\ST@pbox\vtop\bgroup\hsize#1\@arrayparboxrestore} % \end{macrocode} % \end{macro} % % \begin{macro}{\ST@astartpbox} % Our version of |\@astartpbox|. % \changes{v4.0b}{1997/02/04}{Removed use of \cs{ST@pboxcorr}} % \begin{macrocode} \def\ST@astartpbox#1{% \bgroup\hsize#1% \setbox\ST@pbox\vtop\bgroup\hsize#1\@arrayparboxrestore} % \end{macrocode} % \end{macro} % % \begin{macro}{\ST@endpbox} % \begin{macro}{\ST@aendpbox} % \changes{v4.0a}{1996/11/30}{Made definitions up to date with % \file{latex.ltx} (1996/06/01)} % Our version of |\@endpbox| and |\@aendpbox|. % \begin{macrocode} \def\ST@endpbox{% \@finalstrut\@arstrutbox\par\egroup \ST@dimen=\ht\ST@pbox \advance\ST@dimen by \dp\ST@pbox \ifnum\ST@pboxht<\ST@dimen \global\ST@pboxht=\ST@dimen \fi \ST@dimen=\z@ \box\ST@pbox\hfil} % \end{macrocode} % % \begin{macrocode} \def\ST@aendpbox{% \@finalstrut\@arstrutbox\par\egroup \ST@dimen=\ht\ST@pbox \advance\ST@dimen by \dp\ST@pbox \ifnum\ST@pboxht<\ST@dimen \global\ST@pboxht=\ST@dimen \fi \ST@dimen=\z@ \unvbox\ST@pbox\egroup\hfil} % \end{macrocode} % \end{macro} % \end{macro} % % \begin{macro}{\estimate@lineht} % Estimates the height of normal line taking |\arraystretch| into % account. % \changes{v4.0b}{1997/02/04}{Removed use of \cs{ST@pboxcorr}} % \begin{macrocode} \def\estimate@lineht{% \ST@lineht=\arraystretch \baslineskp \global\advance\ST@lineht by 1\p@ \ST@trace\tw@{Average line height:\the\ST@lineht}% } % \end{macrocode} % \end{macro} % % \begin{macro}{\@calfirstpageht} % \changes{v3.7a}{1993/04/05}{Renamed from \cmd\calpage} % Estimates the space left on the current page and decides whether % the tabular can be started on this page or on a new page. % \begin{macrocode} \def\@calfirstpageht{% \ST@trace\tw@{Calculating height of tabular on first page}% % \end{macrocode} % The \TeX\ register |\pagetotal| contains the height of the page % sofar, the \LaTeX\ register |\@colroom| contains the height of % the column. % \begin{macrocode} \global\ST@pagesofar\pagetotal \global\ST@pageleft\@colroom \ST@trace\tw@{Height of text = \the\pagetotal; \MessageBreak Heigth of page = \the\ST@pageleft}% % \end{macrocode} % 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|. % \begin{macrocode} \if@twocolumn \ST@trace\tw@{two column mode}% \if@firstcolumn \ST@trace\tw@{First column}% \ifnum\ST@pagesofar > \ST@pageleft \global\ST@pageleft=2\ST@pageleft \ifnum\ST@pagesofar > \ST@pageleft \newpage\@calnextpageht \ST@trace\tw@{starting new page}% \else % \end{macrocode} % In this case we're in the second column, so we have to compensate % for the material in the first column. % \begin{macrocode} \ST@trace\tw@{Second column}% \global\advance\ST@pageleft -\ST@pagesofar \global\advance\ST@pageleft -\@colroom \fi \fi \fi \else % \end{macrocode} % In one column mode there is a simple decision. % \begin{macrocode} \ST@trace\tw@{one column mode}% \ifnum\ST@pagesofar > \ST@pageleft \ST@trace\tw@{starting new page}% \newpage\@calnextpageht % \end{macrocode} % When we are not starting a new page subtract the size of the % material already on it from the available space. % \begin{macrocode} \else \global\advance\ST@pageleft by -\ST@pagesofar \global\ST@pagesofar\z@ \fi \fi \ST@trace\tw@{Available height: \the\ST@pageleft}% % \end{macrocode} % Now we need to know the height of the head of the table. In order % to measure this we typeset it in a normal \Lenv{tabular} % environment. % \begin{macrocode} \ifx\@@tablehead\@empty \ST@headht=\z@ \else \setbox\@tempboxa=\vbox{\@arrayparboxrestore \ST@restore \expandafter\tabular\expandafter{\tableformat}% \@@tablehead\endtabular}% \ST@headht=\ht\@tempboxa\advance\ST@headht\dp\@tempboxa \fi \ST@trace\tw@{Height of head: \the\ST@headht}% % \end{macrocode} % To decide when to start a new page, we need to know the vertical % size of the tail of the table. % \begin{macrocode} \ifx\@tabletail\@empty \ST@tailht=\z@ \else \setbox\@tempboxa=\vbox{\@arrayparboxrestore \ST@restore \expandafter\tabular\expandafter{\tableformat} \@tabletail\endtabular} \ST@tailht=\ht\@tempboxa\advance\ST@tailht\dp\@tempboxa \fi % \end{macrocode} % 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. % \begin{macrocode} \advance\ST@tailht by \ST@lineht \ST@trace\tw@{Height of tail: \the\ST@tailht}% \ST@trace\tw@{Maximum height of tabular: \the\ST@pageleft}% \@tempdima\ST@headht % \end{macrocode} % \changes{v4.0b}{1997/02/04}{Base the decision whether to start on a % new page on the total of headheight, tailht and lineht} % 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. % \begin{macrocode} \advance\@tempdima\ST@lineht \advance\@tempdima\ST@tailht \ST@trace\tw@{Minimum height of tabular: \the\@tempdima}% \ifnum\@tempdima>\ST@pageleft \ST@trace\tw@{starting new page}% \newpage\@calnextpageht \fi } % \end{macrocode} % \end{macro} % % \begin{macro}{\@calnextpageht} % \changes{v3.7a}{1993/04/05}{Macro added} % \changes{v4.0b}{1997/02/04}{Removed use of \cs{ST@pboxcorr}} % This calculates the maximum height of the tabular on all % subsequent pages of the supertabular environment. % \begin{macrocode} \def\@calnextpageht{% \ST@trace\tw@{Calculating height of tabular on next page}% \global\ST@pageleft\@colroom \global\ST@pagesofar=\z@ \ST@trace\tw@{Maximum height of tabular: \the\ST@pageleft}% } % \end{macrocode} % \end{macro} % % \begin{macro}{\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. % \begin{macrocode} \def\x@supertabular{% \if@topcaption \@process@tablecaption \fi % \end{macrocode} % Save the original definition of |\\|. % \begin{macrocode} \global\let\@oldcr=\\ % \end{macrocode} % Save the current value of |\baselineskip|, as we need it in the % calculation of the average height of a line. % \begin{macrocode} \def\baslineskp{\baselineskip}% % \end{macrocode} % We have to check whether \texttt{array.sty} was loaded, because % some of the internal macros have different names. % \begin{macrocode} \ifx\undefined\@classix % \end{macrocode} % Save old |\@tabularcr| and insert the definition of % |\@stabularcr|. % \begin{macrocode} \let\@@tabularcr\@tabularcr \let\@tabularcr\ST@tabularcr % \end{macrocode} % Activate the new parbox algorithm. % \begin{macrocode} \let\org@startpbox=\@startpbox \let\org@endpbox=\@endpbox \let\@@startpbox=\ST@startpbox \let\@@endpbox=\ST@endpbox \else % \end{macrocode} % When \texttt{array.sty} was loaded things are a bit different. % \begin{macrocode} \let\@@tabularcr\@arraycr \let\@arraycr\ST@tabularcr \let\org@startpbox=\@startpbox \let\org@endpbox=\@endpbox \let\@startpbox=\ST@astartpbox \let\@endpbox=\ST@aendpbox \fi % \end{macrocode} % % Check if the head of the table should be different for the first % and subsequent pages. % \begin{macrocode} \ifx\@table@first@head\undefined \let\@@tablehead=\@tablehead \else \let\@@tablehead=\@table@first@head \fi % \end{macrocode} % Now we can estimate the average line height and the height of the % first page of the \Lenv{supertabular}. % \begin{macrocode} \estimate@lineht \@calfirstpageht } % \end{macrocode} % \end{macro} % % \begin{macro}{\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... % \begin{macrocode} \def\supertabular{% \@ifnextchar[{\@supertabular}%] {\@supertabular[]}} % \end{macrocode} % We can now save the preamble of the tabular in a macro. % \begin{macrocode} \def\@supertabular[#1]#2{% \def\tableformat{#2}% \ST@trace\tw@{Starting a new supertabular}% % \end{macrocode} % Then remember that this is not a \textsf{supertabular*} % environment. % \begin{macrocode} \global\ST@starfalse % \end{macrocode} % Most of the following code is shared between the % \Lenv{supertabular} and \Lenv{supertabular*} environments. So to % avoid duplication it is stored in a macro. % \begin{macrocode} \x@supertabular % \end{macrocode} % Finally start a normal \textsf{tabular} environment. % \begin{macrocode} \expandafter\tabular\expandafter{\tableformat}% \@@tablehead} % \end{macrocode} % \end{macro} % % \begin{macro}{\supertabular*} % We start by looking for the optional argument of the tabular % environment. % \begin{macrocode} \@namedef{supertabular*}#1{% \@ifnextchar[{\@nameuse{@supertabular*}{#1}}% {\@nameuse{@supertabular*}{#1}[]}%] } % \end{macrocode} % We start by saving the intended width and the preamble of the % \textsf{tabular*}. % \begin{macrocode} \@namedef{@supertabular*}#1[#2]#3{% \ST@trace\tw@{Starting a new supertabular*}% \def\tableformat{#3}% \ST@wd=#1\relax \global\ST@startrue % \end{macrocode} % Now we can call the common code for both environments. % \begin{macrocode} \x@supertabular % \end{macrocode} % And we can start a normal \textsf{tabular*} environment. % \begin{macrocode} \expandafter\csname tabular*\expandafter\endcsname \expandafter{\expandafter\ST@wd\expandafter}% \expandafter{\tableformat}% \@@tablehead}% % \end{macrocode} % \end{macro} % % \begin{macro}{\endsupertabular} % \begin{macro}{\endsupertabular*} % This closes both environments. % \begin{macrocode} \def\endsupertabular{% \ifx\@table@last@tail\undefined \@tabletail \else \@table@last@tail \fi \csname endtabular\ifST@star*\fi\endcsname % \end{macrocode} % Restore the original definition of |\@tabularcr| % \begin{macrocode} \ST@restore % \end{macrocode} % Check if we have to insert a caption and restore to default % behaviour of putting captions at the top. % \begin{macrocode} \if@topcaption \else \@process@tablecaption \@topcaptiontrue \fi % \end{macrocode} % % Restore the meaning of |\\| to the one it had before the start % of this environment. Also re-initialize some control-sequences % % \begin{macrocode} \global\let\\\@oldcr \let\@table@first@head\undefined \let\@table@last@tail\undefined \global\let\@process@tablecaption\relax \ST@trace\tw@{Ended a supertabular\ifST@star*\fi}% } % \end{macrocode} % % The definition of the ending of the \Lenv{supertabular*} % environment is simple: % \begin{macrocode} \expandafter\let\csname endsupertabular*\endcsname\endsupertabular % \end{macrocode} % \end{macro} % \end{macro} % % \begin{macro}{\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. % \begin{macrocode} \def\ST@restore{% \ifx\undefined\@classix \let\@tabularcr\@@tabularcr \let\@@startpbox\org@startpbox \let\@@endpbox\org@endpbox \else \let\@arraycr\@@tabularcr \let\@startpbox\org@startpbox \let\@endpbox\org@endpbox \fi } % \end{macrocode} % \end{macro} % % \begin{macro}{\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. % \begin{macrocode} \def\ST@cr{% \noalign{% \ifnum\ST@pboxht<\ST@lineht % \end{macrocode} % 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. % \begin{macrocode} \global\advance\ST@pageleft -\ST@lineht \else % \end{macrocode} % When the parbox was not empty we take into account its height % (plus a bit extra). % \begin{macrocode} \ST@trace\thr@@{Added par box with height \the\ST@pboxht}% \global\advance\ST@pageleft -\ST@pboxht \global\advance\ST@pageleft -0.1\ST@pboxht \global\ST@pboxht\z@ \fi % \end{macrocode} % |\ST@toadd| is the value of the optional argument of |\\|. % \begin{macrocode} \global\advance\ST@pageleft -\ST@toadd \global\ST@toadd=\z@ \ST@trace\thr@@{Space left for tabular: \the\ST@pageleft}% } % \end{macrocode} % When there is not enough space left we start a new page. % \begin{macrocode} \ifnum\ST@pageleft<\ST@tailht \ST@newpage \else % \end{macrocode} % % 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) % \begin{macrocode} \noalign{\global\let\ST@next\@empty}% \fi\ST@next} % \end{macrocode} % \end{macro} % % \begin{macro}{\ST@newpage} % \changes{v3.7b}{1994/05/16}{Added macro, split off from % \cmd\ST@cr} % This macro performs the actions necessary to start a new page. % \begin{macrocode} \def\ST@newpage{% \noalign{\ST@trace\tw@{Starting new page, writing tail}}% % \end{macrocode} % Output |\tabletail|, close the tabular environment, output all % material and start a fresh new page. % \begin{macrocode} \@tabletail \ifST@star \csname endtabular*\endcsname \else \endtabular \fi \newpage\@calnextpageht \let\ST@next\@tablehead \ST@trace\tw@{writing head}% \ifST@star \expandafter\csname tabular*\expandafter\endcsname \expandafter{\expandafter\ST@wd\expandafter}% \expandafter{\tableformat}% \else \expandafter\tabular\expandafter{\tableformat}% \fi} % \end{macrocode} % \end{macro} % % \begin{macrocode} % % \end{macrocode} % % \Finale \endinput