[comp.text.tex] multipage \begin{tabular} environment in LaTeX and footnotes

det@hawkmoon.MN.ORG (Derek E. Terveer) (07/30/90)

I have a (relatively) large table set up in LaTeX that runs about 50 or 60
lines of information, split into 3 columns.  It is pretty simple and starts out
like this:


\documentstyle{article}
\setlength{\topmargin}{-1in}
\pagestyle{empty}
\begin{document}
\renewcommand{\arraystretch}{1.32}
\begin{tabular}{||l|l|l||}
\hline\hline
\multicolumn{3}{||c||}{\bf\huge Minnesota Field Hockey Association} \\
\multicolumn{3}{||c||}{\bf\LARGE North Central Section} \\
\hline\hline
{\em Name} & {\em Address} & {\em Phone\footnote{All phone numbers are in the
(612) area code unless otherwise noted.}} \\ \hline

Lastname1, Firstname & Some address is here & (h) home-phone \\ \hline
Lastname2, Firstname & Some address is here & (h) home-phone \\ \hline
Lastname3, Firstname & Some address is here & (h) home-phone \\ \hline
   :
   :


I have experienced a number of problems with this:

	1)  The very first thing that is done is eject a blank page.  I can't
	figure out why this should be.  Although not fatal, it is annoying.

	2)  Originally, I had all the rows of the table in one big table, but
	found that the bottom two thirds of the table would go off the bottom
	of the page.  So, I split the table into three smaller tables.  Is this
	necessary?  Is there a way for LaTeX to automatically compute how much
	of a table will fit on to a page and continue the table on the next
	page?

	3)  I tried adding footnotes and, although the footnote superscripts
	are being correctly generated in the printed matter within the table,
	the actual footnote is no where to be seen.  Is there any way to get
	footnotes in tables?

	4)  The two vertical bars seperating columns of the table extend upwards
	into the second line of the title area (\multicolumn), but not the
	first line.  I don't see anything different about the two \multicolumn
	lines that would cause this problem except for the font difference.  Is
	this a bug in LaTeX or in the particular driver i'm using?  (dvie24)


Any help would be appreciated,

derek
-- 
Derek Terveer						det@hawkmoon.MN.ORG
Minnesota Field Hockey Association, North Central Section
University of Minnesota Women's Lacrosse

duchier@cs.yale.edu (Denys Duchier) (07/31/90)

In article <1990Jul30.001214.3578@hawkmoon.MN.ORG> det@hawkmoon.MN.ORG (Derek E. Terveer) writes:
 >  I have a (relatively) large table set up in LaTeX that runs about 50 or 60
 >  lines of information, split into 3 columns.  It is pretty simple and starts out
 >  like this:
 >[...]
 > 3)  I tried adding footnotes and, although the footnote superscripts
 > are being correctly generated in the printed matter within the table,
 > the actual footnote is no where to be seen.  Is there any way to get
 > footnotes in tables?

I just posted the code for a \Tabular environment which solves both
your problems with the size of the table (it is automatically split
across pages) and with footnotes.

I am reposting the code here because I had forgotten to skip
\doublerulesep between two consecutive \hline.

--Denys

%  Tabular.sty
%  Denys Duchier, Yale University, July 1990
%
%  This file defines a \Tabular environment which is essentially
%  similar to the \tabular environment but is able to handle very
%  large tables which have to be split across pages.
%
%  The major distinction is that \Tabular doesn't take an optional
%  argument.  It behaves much like \begin{tabular*}{\linewidth} with
%  \Tabularleftskip and \Tabularrightskip used as the stretchable glue
%  on either side.  Also, instead of contributing the table as a large
%  box, it performs a \unvbox so that individual rows are contributed
%  instead and page breaks can occur between them.
%
%              \begin{Tabular}{...} ... \end{Tabular}
%
%  has essentially the same effect as:
%
%  \begin{center}\begin{tabular}{...} ... \end{tabular}\end{center}
%
%  but may be split across pages.
%
%      {\Tabularleftskip  = 0pt
%       \Tabularrightskip = 0pt
%       \begin{Tabular}{@{}l@{\extracolsep{\fill}}cr@{}}
%           ...
%       \end{Tabular}}
%
%  will produce a 3 column table with the left column flushed left,
%  the right column flushed right, and equal spacing between the
%  columns.

\newskip\Tabularleftskip  \Tabularleftskip\@flushglue
\newskip\Tabularrightskip \Tabularrightskip\@flushglue

\newbox\Tabularbox

%  let's count the number of columns so that we know how many columns
%  hlines must span.

\newcount\Tabularcount
\newcount\Tabularcolumns
\def\@Tabclassz{\global\advance\Tabularcount\@ne\@tabclassz}
\let\@latexclassiii\@classiii
\def\@Tabclassiii{\global\advance\Tabularcount\@ne\@latexclassiii}

%  allow page breaks between rows

\def\@Tabularcr{{\ifnum0=`}\fi\@ifstar{\@xTabularcr}{\@xTabularcr}}
\def\@xTabularcr{\@ifnextchar[{\@argTabularcr}{\ifnum0=`{\fi}\cr
  \noalign{\pagebreak[1]}}}

\def\@argTabularcr[#1]{\ifnum0=`{\fi}\ifdim #1>\z@ 
   \unskip\@xargarraycr{#1}\else \@yargarraycr{#1}\fi
 \noalign{\pagebreak[1]}}

%  \hline is redefined to output 2 lines one on top of the other, with
%  a slightly more encouraging \pagebreak than between normal rows.
%  Thus, if a page break must occur, there will a line at the bottom,
%  and it will be repeated at the top of the next page too.  This is
%  visually much more appealing.

\let\@latexhline\hline
\let\@latextabarray\@tabarray
\def\@tabarray{\let\hline\@latexhline\@latextabarray}
\def\Tabularhline{\noalign{\ifnum0=`}\fi\futurelet\@tempa\@Tabularhline}
\let\@Tabularhlineskip\relax
\def\@Tabularhline{\ifx\@tempa\hline
    \global\let\@Tabularhlineskip\doublerulesep
  \else
    \global\let\@Tabularhlineskip\z@
  \fi
  \nopagebreak
  \ifnum0=`{\fi}
  \multispan{\Tabularcolumns}{\unskip\leaders\hrule
    height\arrayrulewidth\hfill}\cr
  \noalign{\vskip-\arrayrulewidth\pagebreak[2]}%
  \multispan{\Tabularcolumns}{\unskip\leaders\hrule
    height\arrayrulewidth\hfill}\cr
  \noalign{\nopagebreak\vskip\@Tabularhlineskip}}

\def\Tabular#1{\trivlist\item[]\noindent
  \setbox\Tabularbox\vbox\bgroup
    \let\@acol\@tabacol
    \let\@classz\@Tabclassz
    \let\@classiii\@Tabclassiii
    \let\@classiv\@tabclassiv
    \let\\\@Tabularcr
    \setbox\@arstrutbox=\hbox{\vrule
        height\arraystretch \ht\strutbox
        depth\arraystretch  \dp\strutbox
        width\z@}%
    \global\Tabularcount\z@
    \@mkpream{#1}%
    \Tabularcolumns\Tabularcount
    \let\hline\Tabularhline
    \let\@classiii\@latexclassiii
    \tabskip\Tabularleftskip
    \edef\@preamble{\halign to\linewidth\bgroup
      \tabskip\z@ \@arstrut \@preamble
      \tabskip\Tabularrightskip \cr}%
    \let\@starpbox\@@startpbox
    \let\@endpbox\@@endpbox
    \let\@sharp##\let\protect\relax
    \lineskip\z@\baselineskip\z@
    \@preamble}

\def\endTabular{\crcr\egroup\egroup\unvbox\Tabularbox\endtrivlist}