[comp.text.tex] New version of supertab.sty

tli@castor.usc.edu (Tony Li) (07/06/90)

I looked at supertab.sty as a way of doing large tables.  It is far
from perfect.  In fact, it's a hack.  I found a number of things that
could be improved easily, and I've done those.  Here's the new version.

Tony

------------------------------cut here------------------------------
% supertab.sty 						-*-LaTeX-*-
%
% Originally by:
% 	Theo Jurriens 1988
% 	TAJ@hgrrug5        P.O Box 800, 9700 AV Groningen
%
% Description:
%	A LaTeX style file which creates a new environment "supertabular".
%	The new environment is similar to the normal LaTeX "tabular"
%	environment with the following differences:
%		The supertabular environment will wrap around pages.
%		A heading can be placed at the start of each page by using
%		\tablehead. 
%		Similarly, a footer can be placed at the end of each page
%		by using \tabletail.
%		If the figure starts on a non-blank page, then set the
%		counter \startline to be the number of lines already on the
%		page. 
%
% Example:
%	\documentstyle[supertab]{article}
%	\begin{document}
%	\tablehead{\hline
%	Ster&Harvardnr&max&periode&\multicolumn{3}{l|}{Datum}\\
%	\hline}
%	\tabletail{\hline}
%
%	\begin{supertabular}{|llrrrrc|}
%	SS Cas &000451 &  8.8&140.57&30&jan&1989\nextline
%	SS Cas &000451 &  8.8&140.57& 7&nov&1989\nextline
%	T And  &001726 &  7.7&280.76&10&aug&1989\nextline
%	.
%	.
%	.
%	RW Peg &225914 &  8.8&208.43&23&aug&1989\nextline
%	V Cas  &230759 &  6.9&228.83&18&feb&1989\nextline
%	W Peg  &231425 &  7.9&344.92&27&apr&1989\nextline
%	S Peg  &231508 &  7.1&319.22& 4&dec&1989\nextline
%	Z Peg  &235525 &  7.7&325.47&23&jun&1989\\
%	\end{supertabular}
%	\end{document}
%
% Fixes:
%	7/5/90	Tony Li tli@usc.edu
%	Reformatted code, added instructions.
%	Hacked so that \\ is now the normal line terminator.
%	Changed \\ so that it now generates a \par instead of a \clearpage.
%	Added another counter \startline which initializes \numline.  This
%	allows us to start a table on a page which already contains text.
%	\startline needs to estimate the number of lines already used on
%	the page.
%
\def\@tablehead{\ }
\def\tablehead#1{\gdef\@tablehead{#1}}
\def\@tabletail{\ }
\def\tabletail#1{\gdef\@tabletail{#1}}
\newcount\startline
\startline=0
\newcount\numline
\newcount\maxline
%
\def\calmaxline{\global\maxline=\textheight
	\global\divide\maxline by \baselineskip
}
%
\def\@supertab{	\def\@halignto{}\leavevmode \hbox \bgroup
	$\let\@acol\@tabacol \let\@classz\@tabclassz
	\let\@classiv\@tabclassiv \let\\=\@supertabcr\@tabarray}
\def\@endsupertab{\crcr\egroup\egroup $\egroup}
%
\newenvironment{supertabular}[1]{
	\edef\tableformat{\string#1} 
	\calmaxline
	\numline=\startline
	\@supertab{\tableformat}\@tablehead%
}%
{%
	\@tabletail \@endsupertab%
}%
%
%
\def\@supertabcr{\global\advance\numline by 1 \@tabularcr%
	\ifnum\numline=\maxline%
	        \@tabletail%
	        \@endsupertab%
		\par%
        	\@supertab{\tableformat}%
	        \global\numline=0%
	        \@tablehead%
	\fi%
}
Tony Li - USC Computer Science Department
Internet: tli@usc.edu Uucp: usc!tli
Thus spake the master programmer: "A well written program is its own
heaven; a poorly-written program its own hell."