1 % \iffalse meta-comment
5 % The LaTeX3 Project and any individual authors listed elsewhere
8 % This file is part of the Standard LaTeX `Tools Bundle'.
9 % -------------------------------------------------------
11 % It may be distributed and/or modified under the
12 % conditions of the LaTeX Project Public License, either version 1.3c
13 % of this license or (at your option) any later version.
14 % The latest version of this license is in
15 % http://www.latex-project.org/lppl.txt
16 % and version 1.3c or later is part of all distributions of LaTeX
17 % version 2005/12/01 or later.
19 % The list of all files belonging to the LaTeX `Tools Bundle' is
20 % given in the file `manifest.txt'.
24 %% File: longtable.dtx Copyright (C) 1990-2001 David Carlisle
27 \ProvidesFile{longtable.dtx}
29 %<package>\NeedsTeXFormat{LaTeX2e}[1995/06/01]
30 %<package>\ProvidesPackage{longtable}
31 %<driver> \ProvidesFile{longtable.drv}
33 % \ProvidesFile{longtable.dtx}
34 [2014/10/28 v4.11 Multi-page Table package (DPC)]
38 \documentclass{ltxdoc}
39 \usepackage{longtable}
41 \DocInput{longtable.dtx}
46 % \GetFileInfo{longtable.dtx}
47 % \title{The \textsf{longtable} package\thanks{This file
48 % has version number \fileversion, last
49 % revised \filedate.}}
50 % \author{David Carlisle\thanks{The new algorithm for aligning `chunks'
51 % of a table used in version 4 of this package was devised coded
52 % and documented by David Kastrup.}}
57 % \providecommand\finalclearpage{\clearpage}
59 % \MaintainedByLaTeXTeam{tools}
63 % This package defines the \env{longtable} environment, a multi-page
64 % version of \env{tabular}.
67 % \DeleteShortVerb{\|}
70 % \changes{v0.00}{1989/11/06}
71 % {`Version 0' distributed as longtab.sty
72 % always used just one chunk for the whole table}
74 % \changes{v1.00}{1990/12/20}
77 % \changes{v2.00}{1991/06/17}
78 % {Support NFSS and array.sty}
80 % \changes{v3.00}{1992/03/16}
81 % {New implementation. tables may now start anywhere on the page.}
83 % \changes{v3.01}{1992/04/06}
84 % {(Michel Goossens) If a chunk ends on a line in which the first
85 % entry is empty, weird errors occur. Added special begin and end
86 % groups, (\cs{ifnum}0 ) stuff as explained in Appendix D.}
88 % \changes{v3.02}{1992/04/09}
89 % {(Michel Goossens) Longtable fails if the table counter is reset
90 % during a document. Now use an internal counter, but still
91 % increment table so \cs{caption} and \cs{label} work out right.}
93 % \changes{v3.03}{1992/06/25}
94 % {Add \cs{@ifundefined\{reset@font\}} so that the documentation may
95 % be processed with old versions of \LaTeX.}
96 % \changes{v3.03}{1992/06/25}
97 % {Modify the treatment of \cs{d@llar} to match the new versions of
98 % Mittelbach's array.sty (array.sty v2.0h)}
100 % \changes{v3.04}{1992/11/12}
101 % {(Jean-Pierre Drucbert) Longtable failed when used with
103 % \changes{v3.04}{1992/11/12}
104 % {Fix bug which stopped \cs{kill} working correctly in headings.}
105 % \changes{v3.04}{1992/11/12}
106 % {(Graham Gough) Made \cs{setlongtables} issue a warning message.}
107 % \changes{v3.04}{1992/11/12}
108 % {(Sebastian Rahtz) longtable ran out of memory on really long
109 % tables. Another bug introduced in V3.}
111 % \changes{v3.05}{1992/11/20}
112 % {(Juergen Peus) Table was hard coded into the captions, Now the
113 % captions use \cs{fnum@table}, so \cs{tablename} will be used.}
115 % \changes{v3.06}{1993/01/21}
116 % {(Ingo Hoffmann) longtable fails with letter style.
117 % The table counter is not defined, and the .aux file is not used in
118 % the same way. This version will use a .lta file for letter style.}
120 % \changes{v3.07}{1993/06/09}
121 % {Allow the \LaTeX\ syntax \cs{setcounter}\{LTchunksize\}\{10\}}
123 % \changes{v3.08}{1993/06/09}
124 % {Update for \LaTeXe}
126 % \changes{v3.09}{1994/03/15}
129 % \changes{v3.11}{1994/05/22}
130 % {Option handling added, new style errors and warnings}
132 % \changes{v3.12}{1994/06/30}
133 % {Remove special letter class handling from v3.06, not needed for
136 % \changes{v4.00}{1996/04/08}
137 % {(DK) New algorithm to align chunks devised and coded by David
140 % \changes{v4.02}{1996/04/16}
141 % {(DPC/DK) documentation improvements}
143 % \changes{v4.06}{1997/06/28}
144 % {(DK) new email address}
149 % \def\@oddfoot{\normalfont\rmfamily\dotfill Page \thepage\dotfill}
150 % \def\@oddhead{\dotfill{\normalfont\ttfamily longtable.sty}\dotfill}
151 % \def\ps@titlepage{\let\@oddhead\@empty}
155 % \setlength\LTleft\parindent
156 % \setlength\LTright\fill
157 % \setcounter{LTchunksize}{10}
161 % ^^A \vbox to 100pt makes the page breaks the same on the first run.
162 % \changes{v3.08}{1993/06/09}
163 % {No need to use \cs{vbox} with \LaTeXe\ minipage}
164 % \noindent\begin{minipage}[t][130pt]{\textwidth}
168 % \section{Introduction}
170 % The \package{longtable} package defines a new environment,
171 % \DescribeEnv{longtable}
172 % \env{longtable}, which has most of the features of the \env{tabular}
173 % environment, but produces tables which may be broken by \TeX's
174 % standard page-breaking algorithm. It also shares some features with
175 % the \env{table} environment. In particular it uses the same counter,
176 % \texttt{table}, and has a similar "\caption" command. Also, the
177 % standard "\listoftables" command lists tables produced by either the
178 % \env{table} or \env{longtable} environments.
180 % The following example uses most of the features of the \env{longtable}
181 % environment. An edited listing of the input for this example appears
182 % in Section~\ref{listing}.
184 % \textbf{Note:} Various parts of the following table will
185 % \textbf{not} line up correctly until this document has been run
186 % through \LaTeX\ several times. This is a characteristic feature of
187 % this package, as described below.
189 % \begin{longtable}{@{*}r||p{1in}@{*}}
190 % KILLED & LINE!!!! \kill
192 % [An optional table caption (used in the list of tables)]
193 % {A long table\label{long}}\\
195 % \multicolumn{2}{@{*}c@{*}}%
196 % {This part appears at the top of the table}\\
197 % \textsc{First}&\textsc{Second}\\
200 % \caption[]{(continued)}\\
202 % \multicolumn{2}{@{*}c@{*}}%
203 % {This part appears at the top of every other page}\\
204 % \textbf{First}&\textbf{Second}\\
208 % This goes at the&bottom.\\
212 % These lines will&appear\\
213 % in place of the & usual foot\\
214 % at the end& of the table\\
217 % \env{longtable} columns are specified& in the \\
218 % same way as in the \env{tabular}& environment.\\
219 % "@{*}r||p{1in}@{*}"& in this case.\\
220 % Each row ends with a& "\\" command.\\
221 % The "\\" command has an& optional\\
222 % argument, just as in& the\\
223 % \env{tabular}&environment.\\[10pt]
224 % See the effect of "\\[10pt]"&?\\
225 % Lots of lines& like this.\\
226 % Lots of lines& like this.\\
227 % Lots of lines& like this.\\
228 % Lots of lines& like this.\\
229 % Also "\hline" may be used,& as in \env{tabular}.\\
231 % That was a "\hline"&.\\
233 % That was "\hline\hline"&.\\
234 % \multicolumn{2}{||c||}%
235 % {This is a \ttfamily\v\\multicolumn\v{2\v}\v{||c||\v}}\\
236 % If a page break occurs at a "\hline" then& a line is drawn\\
237 % at the bottom of one page and at the& top of the next.\\
239 % The "[t] [b] [c]" argument of \env{tabular}& can not be used.\\
240 % The optional argument may be one of& "[l] [r] [c]"\\
241 % to specify whether the table should be& adjusted\\
242 % to the left, right& or centrally.\\
244 % Lots of lines& like this.\\
245 % Lots of lines& like this.\\
246 % Lots of lines& like this.\\
247 % Lots of lines& like this.\\
248 % Lots of lines& like this.\\
249 % Lots of lines& like this.\\
250 % Lots of lines& like this.\\
251 % Lots of lines& like this.\\
252 % Lots of lines& like this.\\
253 % Lots of lines& like this.\\
254 % Lots of lines& like this.\\
255 % Lots of lines& like this.\\
256 % Lots of lines& like this.\\
257 % Lots of lines& like this.\\
258 % Lots of lines& like this.\\
259 % Lots of lines& like this.\\
260 % Lots of lines& like this.\\
261 % Lots of lines& like this.\\
262 % Lots of lines& like this.\\
263 % Lots of lines& like this.\\
264 % Some lines may take up a lot of space, like this: &
265 % \raggedleft This last column is a ``p'' column so this
266 % ``row'' of the table can take up several lines. Note however that
267 % \TeX\ will never break a page within such a row. Page breaks only
268 % occur between rows of the table or at "\hline" commands.
270 % Lots of lines& like this.\\
271 % Lots of lines& like this.\\
272 % Lots of lines& like this.\\
273 % Lots of lines& like this.\\
274 % Lots of lines& like this.\\
275 % Lots of lines& like this.\\
276 % Lots of lines& like this.\\
278 % Lots\footnote{This is a footnote.} of lines& like this.\\
279 % Lots of lines& like this\footnote{\env{longtable} takes special
280 % precautions, so that footnotes may also be used in `p' columns.}\\
282 % Lots of lines& like this.\\
283 % Lots of lines& like this.
286 % \section{Chunk Size}
288 % \DescribeMacro{LTchunksize}
289 % In order to \TeX\ multi-page tables, it is necessary to break up the
290 % table into smaller chunks, so that \TeX\ does not have to keep
291 % everything in memory at one time. By default \env{longtable} uses 20
292 % rows per chunk, but this can be set by the user, with e.g.,
293 % "\setcounter{LTchunksize}{10}".\footnote
294 % {You can also use the plain \TeX\ syntax
295 % {\ttfamily\v\\LTchunksize=10.}}
296 % These chunks do not affect page breaking,
297 % thus if you are using a \TeX\ with a lot of memory, you can set
298 % "LTchunksize" to be several pages of the table. \TeX\ will run
299 % faster with a large "LTchunksize". However, if necessary,
300 % \env{longtable} can work with "LTchunksize" set to 1, in which case
301 % the memory taken up is negligible.
302 % Note that if you use the commands for setting the table head or foot
303 % (see below), the "LTchunksize" must be at least as large as the
304 % number of rows in each of the head or foot sections.
306 % This document specifies "\setcounter{LTchunksize}{10}". If you look
307 % at the previous table, after the \emph{first} run of \LaTeX\ you will
308 % see that various parts of the table do not line up.
309 % \LaTeX\ will also have printed a warning that the column
310 % widths had changed. \env{longtable} writes information onto the
311 % ".aux" file, so that it can line up the different chunks.
312 % Prior to version~4 of this package, this information was not used
313 % unless a "\setlongtables" command was issued, however, now the
314 % information is always used, using a new algorithm\footnote{Due to
315 % David Kastrup.} and so "\setlongtables" is no longer needed. It is
316 % defined (but does nothing) for the benefit of old documents that
321 % \begin{tabular}{||l|l|l||}
323 % A&\env{tabular}& environment\\
325 % within&a floating&\env{table}\\
328 % \caption{A floating table}
331 % \section{Captions and Headings}
333 % At the start of the table one may specify lines which are to appear at
334 % the top of every page (under the headline, but before the other lines
336 % \DescribeMacro{\endhead}
337 % The lines are entered as normal, but the last "\\" command is
338 % replaced by a "\endhead" command.
339 % \DescribeMacro{\endfirsthead}
340 % If the first page should have a different heading, then this should be
341 % entered in the same way, and terminated with the "\endfirsthead"
342 % command. The "LTchunksize" should be at least as large as the
343 % number of rows in the heading.
344 % \DescribeMacro{\endfoot}
345 % There are also "\endfoot" and "\endlastfoot"
346 %\DescribeMacro{\endlastfoot}
347 % commands which are used in the same way (at the \emph{start} of the
348 % table) to specify rows (or an "\hline") to appear at the bottom of
349 % each page. In certain situations, you may want to place lines which
350 % logically belong in the table body at the end of the \env{firsthead},
351 % or the beginning of the \env{lastfoot}. This helps to control which
352 % lines appear on the first and last page of the table.
354 % \DescribeMacro{\caption}%
355 % The "\caption{...}" command is essentially equivalent to\\
356 % "\multicolumn{n}{c}{\parbox{\LTcapwidth}{...}}"\\
357 % where \texttt{n} is the number of columns of the table. You may set
358 % the width of the caption with a command such as
359 % "\setlength{\LTcapwidth}{2in}"
360 % in the preamble of your document. The default is 4in. "\caption" also
361 % writes the information to produce an entry in the list of tables. As
362 % with the "\caption" command in the \env{figure} and \env{table}
363 % environments, an optional argument specifies the text to appear in the
364 % list of tables if this is different from the text to appear in the
365 % caption. Thus the caption for table \ref{long} was specified as
367 % "\caption"[An optional table caption
368 % (used in the list of tables)]\v{A long
369 % table"\label{long}"\v}}.
371 % You may wish the caption on later pages to be different to that on the
372 % first page. In this case put the "\caption" command in the first
373 % heading, and put a subsidiary caption in a "\caption[]" command in
374 % the main heading. If the optional argument to "\caption" is empty,
375 % no entry is made in the list of tables. Alternatively, if you do not
376 % want the table number to be printed each time, use the "\caption*"
379 % The captions are set based on the code for the \package{article}
381 % If you have redefined the standard "\@makecaption" command to produce
382 % a different format for the captions, you may
383 % need to make similar changes to the \package{longtable} version,
384 % "\LT@makecaption". See the code section for more details.
386 % A more convenient method of customising captions is given by the
387 % \package{caption(2)} package, which provides commands for customising
388 % captions, and arranges that the captions in standard environments, and
389 % many environments provided by packages (including \package{longtable})
390 % are modified in a compatible manner.
392 % You may use the "\label" command so that you can cross reference
393 % \env{longtable}s with "\ref". Note however, that the "\label" command
394 % should not be used in a heading that may appear more than once. Place
395 % it either in the \env{firsthead}, or in the body of the table. It
396 % should not be the \emph{first} command in any entry.
398 % \section{Multicolumn entries}
400 % The "\multicolumn" command may be used in \env{longtable} in exactly
401 % the same way as for \env{tabular}. So you may want to skip this
402 % section, which is rather technical, however coping with "\multicolumn"
403 % is one of the main problems for an environment such as
404 % \env{longtable}. The main effect that a user will see is that
405 % certain combinations of "\multicolumn" entries will result in a
406 % document needing more runs of \LaTeX\ before the various `chunks' of
409 % The examples in this section are set with "LTchunksize" set to the
410 % minimum value of one, to demonstrate the effects when "\multicolumn"
411 % entries occur in different chunks.
413 % \begin{table}[!htp]
418 % \global\let\LT@save@row\relax
419 % \let\LT@warn\@gobble
420 % \let\LT@final@warn\relax
422 % \newcommand\ltexample[1]{
423 % \stepcounter{LT@tables}
424 % \expandafter\let\csname LT@\romannumeral\c@LT@tables\endcsname
426 % \addtocounter{LT@tables}{-1}
427 % \begin{longtable}{|c|c|c|}
428 % \caption{A difficult {\cs{multicolumn}} combination:
429 % pass #1\label{pass#1}}\\
432 % \multicolumn{3}{|c|}{wide multicolumn spanning 1--3}\\
433 % \multicolumn{2}{|c|}{multicolumn 1--2}&3\\
450 % Consider Table~\ref{pass1}.
451 % In the second chunk, \env{longtable} sees the wide
452 % multicolumn entry. At this point it thinks that the first two
453 % columns are very narrow. All
454 % the width of the multicolumn entry is assumed to be in the
455 % third column. (This is a `feature' of \TeX's primitive "\halign"
456 % command.) \env{longtable} then passes the information that there
457 % is a wide third column to the later chunks, with the result that the
458 % first pass over the table is too wide.
460 % If the `saved row' from this first pass was re-inserted into the
461 % table on the next pass, the table would line up in two passes, but
462 % would be much two wide.
464 % \DescribeMacro{\kill}%
465 % The solution to this problem used in Versions 1~and~2, was to use a
466 % "\kill" line. If a line is "\kill"ed, by using "\kill" rather than
467 % "\\" at the end of the line, it is used in calculating
468 % column widths, but removed from the final table. Thus entering
469 % "\kill"ed copies of the last two rows before the wide multicolumn
470 % entry would mean that "\halign" `saw' the wide entries in the first
471 % two columns, and so would not widen the third column by so much to
472 % make room for the multicolumn entry.
474 % In Version~3, a new solution was introduced. If the saved row in
475 % the ".aux" file was not being used, \env{longtable} used a special
476 % `draft' form of "\multicolumn", this modified the definition, so the
477 % spanning entry was never considered to be wider than the columns it
478 % spanned. So after the first pass, the ".aux" file stored the
479 % widest normal entry for each column, no column was widened due to
480 % "\span"ned columns. By default \env{longtable} ignored the ".aux"
481 % file, and so each run of \LaTeX\ was considered a first pass. Once the
482 % "\setlongtables" declaration was given, the saved row in the ".aux"
483 % file, and the proper definition of "\multicolumn" were used. If any
484 % "\multicolumn" entry caused one of the columns to be widened, this
485 % information could not be passed back to earlier chunks, and so the
486 % table would not correctly line up until the third pass. This algorithm
487 % always converged in three passes as described above, but in examples
488 % such as the ones in Tables \ref{pass1}--\ref{pass4}, the final
489 % widths were not optimal as the width of column~2, which is
490 % determined by a "\multicolumn" entry was not known when the final
491 % width for column~3 was fixed, due to the fact that \emph{both}
492 % "\multicolumn" commands were switched from `draft' mode to `normal'
493 % mode at the same time.
495 % Version~4 alleviates the problem considerably.
496 % The first pass of the table will
497 % indeed have the third column much too wide. However, on the next pass
498 % \env{longtable} will notice the error and reduce the column width
499 % accordingly. If this has to propagate to chunks before the
500 % "\multicolumn" one, an additional pass will, of course, be
501 % needed. It is possible to construct tables where this rippling up of
502 % the correct widths takes several passes to `converge' and produce a
503 % table with all chunks aligned. However in
504 % order to need many passes one needs to construct a table with
505 % many overlapping "\multicolumn" entries, all being wider than the
506 % natural widths of the columns they span, and all occurring in
507 % different chunks. In the typical case the algorithm will converge
508 % after three or four passes, and, the benefits of not needing to edit
509 % the document before the final run to add "\setlongtables", and the
510 % better choice of final column widths in the case of multiple
511 % "\multicolumn" entries will hopefully more than pay for the extra
512 % passes that may possibly be needed.
514 % So Table~\ref{pass1} converges after 4~passes, as seen in
517 % You can still speed the convergence by introducing judicious "\kill"
518 % lines, if you happen to have constellations like the above.
520 % If you object even to \LaTeX-ing a file twice, you should
521 % make the first line of
522 % every \env{longtable} a "\kill" line that contains the widest entry
523 % to be used in each column. All chunks will then line up on the first
526 % \section{Adjustment}
528 % The optional argument of \env{longtable} controls the
529 % horizontal alignment of the table. The possible options are "[c]",
530 % "[r]" and "[l]", for centring,
531 % right and left adjustment, respectively.
532 % \DescribeMacro{\LTleft}
533 % Normally centring is the default, but this document specifies
534 % \DescribeMacro{\LTright}
536 % \setlength\LTleft\parindent
537 % \setlength\LTright\fill
540 % which means that the tables are set flush left, but
541 % indented by the usual paragraph indentation. Any lengths can be
542 % specified for these two parameters, but at least one of them should be
543 % a rubber length so that it fills up the width of the page, unless
544 % rubber lengths are added between the columns using the
545 % "\extracolsep" command.
548 % \begin{tabular*}{\textwidth}{@{\extracolsep{...}}...}
550 % produces a full width table, to get a similar effect with
551 % \env{longtable} specify
553 % \setlength\LTleft{0pt}
554 % \setlength\LTright{0pt}
555 % \begin{longtable}{@{\extracolsep{...}}...}
560 % This section highlights the major changes since version~2. A more
561 % detailed change log may be produced at the end of the code listing
562 % if the "ltxdoc.cfg" file specifies
564 % \AtBeginDocument{\RecordChanges}
565 % \AtEndDocument{\PrintChanges}
568 % Changes made between versions 2 and 3.
570 % \item The mechanism for adding the head and foot of the table has been
571 % completely rewritten. With this new mechanism, \env{longtable} does
572 % not need to issue a "\clearpage" at the start of the table, and so the
573 % table may start half way down a page. Also the "\endlastfoot" command
574 % which could not safely be implemented under the old scheme, has been
576 % \item \env{longtable} now issues an error if started in the scope of
577 % "\twocolumn", or the \env{multicols} environment.
578 % \item The separate documentation file "longtable.tex" has been
579 % merged with the package file, "longtable.dtx" using Mittelbach's
580 % \package{doc} package.
581 % \item Support for footnotes has been added. Note however that
582 % "\footnote" will not work in the `head' or `foot' sections of the
583 % table. In order to put a footnote in those sections (e.g., inside a
584 % caption), use "\footnotemark" at that point, and "\footnotetext"
585 % anywhere in the table \emph{body} that will fall on the same page.
586 % \item The treatment of "\multicolumn" has changed, making
587 % "\kill" lines unnecessary, at the price of sometimes requiring a
588 % third pass through \LaTeX.
589 % \item The "\newpage" command now works inside a \env{longtable}.
592 % Changes made between versions 3 and 4.
594 % \item A new algorithm is used for aligning chunks. As well as the
595 % widest width in each column, \package{longtable} remembers which
596 % chunk produced this maximum. This allows it to check that the
597 % maximum is still achieved in later runs. As \package{longtable} can
598 % now deal with columns shrinking as the file is edited, the
599 % "\setlongtables" system is no longer needed and is disabled.
601 % \item An extra benefit of the new algorithm's ability to deal with
602 % `shrinking' columns is that it can give better (narrower) column
603 % widths in the case of overlapping "\multicolumn" entries in
604 % different chunks than the previous algorithm produced.
606 % \item The `draft' multicolumn system has been removed, along with
607 % related commands such as "\LTmulticolumn".
609 % \item The disadvantage of the new algorithm is that it can take more
610 % passes. The theoretical maximum is approximately twice the length
611 % of a `chain' of columns with overlapping "\multicolumn" entries,
612 % although in practice it usually converges as fast as the old
613 % version. (Which always converged in three passes once
614 % "\setlongtables" was activated.)
616 % \item "\\*" and "\nopagebreak" commands may be used to control page
624 % ^^A Allow the table to stick into the left margin.
625 % \setlength{\LTleft}{0pt plus 1fill minus 1fill}
626 % \setlength{\LTright}{0pt}
628 % \begin{longtable}{@{}l@{\hspace{10pt}}p{.8\linewidth}@{}}
629 % \caption[A summary of \env{longtable} commands]%
630 % {\normalsize A summary of \env{longtable} commands}\\
631 % \multicolumn{2}{c}{\textbf{Parameters}}\\*
634 % Glue to the left of the table. \hfill("\fill")\\
636 % Glue to the right of the table. \hfill("\fill")\\
638 % Glue before the the table. \hfill("\bigskipamount")\\
640 % Glue after the the table. \hfill("\bigskipamount")\\
642 % The width of a parbox containing the caption.\hfill(4in)\\
644 % The number of rows per chunk. \hfill(20)\\[5pt]
645 % \multicolumn{2}{c}{\textbf{Optional
646 % arguments to} \ttfamily\v\\begin\v{longtable\v}}\\*
648 % \it none& Position as specified by "\LTleft" and "\LTright".\\
649 % "[c]"& Centre the table.\\
650 % "[l]"& Place the table flush left.\\
651 % "[r]"& Place the table flush right.\\[5pt]
653 % \multicolumn{2}{c}{\textbf{Commands
654 % to end table rows}}\\*
657 % Specifies the end of a row\\
658 % "\\"\oarg{dim}& Ends row, then adds vertical space
659 % (as in the \env{tabular} environment).\\
661 % The same as "\\" but disallows a page break after the row.\\
663 % Alternative to "\\" for use in the scope of "\raggedright" and
664 % similar commands that redefine "\\".\\
666 % Row is `killed', but is used in calculating widths.\\
668 % Specifies rows to appear at the top of every page.\\
670 % Specifies rows to appear at the top the first page.\\
672 % Specifies rows to appear at the bottom of every page.\\
674 % Specifies rows to appear at the bottom of the last page.\\[5pt]
675 % \multicolumn{2}{c}{\textbf{\env{longtable} caption commands}}\\*
677 % "\caption"\marg{caption}&
678 % Caption `Table ?: \meta{caption}', and a `\meta{caption}'
679 % entry in the list of tables.\\
680 % "\caption"\oarg{lot}\marg{caption}&
681 % Caption `Table ?: \meta{caption}', and a `\meta{lot}'
682 % entry in the list of tables.\\
683 % "\caption[]"\marg{caption}&
684 % Caption `Table ?: \meta{caption}',
685 % but no entry in the list of tables.\\
686 % "\caption*"\marg{caption}&
687 % Caption `\meta{caption}', but no entry in the list of tables.\\[5pt]
688 % \multicolumn{2}{c}{%^^A
689 % \textbf{Commands available at the start of a row}}\\*
692 % Force a page break.\\*
693 % "\pagebreak"\oarg{val}& A `hint' between 0 and 4
694 % of the desirability of a break.\\
695 % "\nopagebreak"& Prohibit a page break.\\*
696 % "\nopagebreak"\oarg{val}& A `hint' between 0 and 4 of the undesirability
699 % Force a page break.\\[5pt]
700 % \multicolumn{2}{c}{\textbf{Footnote commands
701 % available inside \env{longtable}}}\\*
704 % Footnotes, but may not be used in the table head \& foot.\\*
706 % Footnotemark, may be used in the table head \& foot.\\*
708 % Footnote text, use in the table body.\\[5pt]
709 % \multicolumn{2}{c}{\textbf{Setlongtables}}\\
711 % "\setlongtables"& Obsolete command. Does nothing now.
716 % \section{Verbatim highlights from Table \protect\ref{long}}
718 % \begingroup\catcode`\/=0
720 % \begin{longtable}{@{*}r||p{1in}@{*}}
721 % KILLED & LINE!!!! \kill
722 % \caption[An optional table caption /ldots]{A long table\label{long}}\\
724 % \multicolumn{2}{@{*}c@{*}}%
725 % {This part appears at the top of the table}\\
726 % \textsc{First}&\textsc{Second}\\
729 % \caption[]{(continued)}\\
731 % \multicolumn{2}{@{*}c@{*}}%
732 % {This part appears at the top of every other page}\\
733 % \textbf{First}&\textbf{Second}\\
737 % This goes at the&bottom.\\
741 % These lines will&appear\\
742 % in place of the & usual foot\\
743 % at the end& of the table\\
746 % \env{longtable} columns are specified& in the \\
747 % same way as in the \env{tabular}& environment.\\
749 % \multicolumn{2}{||c||}{This is a /ldots}\\
751 % Some lines may take/ldots&
752 % \raggedleft This last column is a ``p'' column/ldots
755 % Lots of lines& like this.\\
758 % Lots\footnote{/ldots} of lines& like this.\\
759 % Lots of lines& like this\footnote{/ldots}\\
761 % Lots of lines& like this.\\
770 % \section{The Macros}
776 % \subsection{Initial code}
778 % Before declaring the package options, we must define some defaults
781 % \begin{macro}{\LT@err}
782 % The error generating command
784 \def\LT@err{\PackageError{longtable}}
788 % \begin{macro}{\LT@warn}
789 % The warning generating command
791 \def\LT@warn{\PackageWarning{longtable}}
795 % \begin{macro}{\LT@final@warn}
796 % \changes{v4.04}{1996/05/24}
798 % If any \env{longtable}s have not aligned, generate a warning at the
799 % end of the run at "\AtEndDocument".
803 \LT@warn{Table \@width s have changed. Rerun LaTeX.\@gobbletwo}}%
804 \global\let\LT@final@warn\relax}
808 % \subsection{Options}
810 % The first two options deal with error handling. They are compatible
811 % with the options used by the \texttt{tracefnt} package.
813 % \begin{macro}{errorshow}
814 % \emph{Only} show errors on the terminal. `warnings' are just sent to
816 % \changes{v3.14}{1995/04/25}
817 % {Change string from LT to longtable}
819 \DeclareOption{errorshow}{%
820 \def\LT@warn{\PackageInfo{longtable}}}
824 % \begin{macro}{pausing}
825 % \changes{v3.14}{1995/04/25}
826 % {Change string from LT to longtable}
827 % \changes{v3.15}{1995/06/15}
828 % {Use single hash for latex/1557}
829 % Make every warning message into an error so \TeX\ stops.
830 % May be useful for debugging.
832 \DeclareOption{pausing}{%
834 \LT@err{#1}{This is not really an error}}}
839 % \begin{macro}{final}
840 % \changes{v4.01}{1996/04/11}
841 % {(DPC) make set and final options no op}
842 % The next options are just alternative syntax for the
843 % "\setlongtables" declaration.
845 \DeclareOption{set}{}
846 \DeclareOption{final}{}
856 % \subsection{User Settable Parameters}
858 % \begin{macro}{\LTleft}
859 % \begin{macro}{\LTright}
860 % Glue to the left and right of the table, default "\fill" (ie
863 \newskip\LTleft \LTleft=\fill
864 \newskip\LTright \LTright=\fill
869 % \begin{macro}{\LTpre}
870 % \begin{macro}{\LTpost}
871 % Glue before and after the \env{longtable}. "\bigskip" by default.
873 \newskip\LTpre \LTpre=\bigskipamount
874 \newskip\LTpost \LTpost=\bigskipamount
879 % \begin{macro}{\LTchunksize}
880 % Chunk size (The number of rows taken per "\halign"). Default 20.
882 \newcount\LTchunksize \LTchunksize=20
886 % \begin{macro}{\c@LTchunksize}
887 % Added in V3.07 to allow the \LaTeX\ syntax
888 % "\setcounter{LTchunksize}{10}".
890 \let\c@LTchunksize\LTchunksize
894 % \begin{macro}{\LTcapwidth}
895 % Width of the "\parbox" containing the caption. Default 4in.
897 \newdimen\LTcapwidth \LTcapwidth=4in
901 % \subsection{Internal Parameters}
903 % \begin{macro}{\LT@head}
904 % \begin{macro}{\LT@firsthead}
905 % \begin{macro}{\LT@foot}
906 % \begin{macro}{\LT@lastfoot}
907 % Boxes for the table head and foot.
919 % \begin{macro}{\LT@cols}
920 % Counter for number of columns.
926 % \begin{macro}{\LT@rows}
927 % Counter for rows up to chunksize.
933 % \begin{macro}{\c@LT@tables}
934 % Counter for the tables, added in V3.02. Previous versions just used
935 % the \LaTeX\ counter "table", but this fails if "table" is
936 % reset during a document, eg \package{report} class resets it every
939 % This was changed from "\newcount\LT@tables" in V3.04. \LaTeX\ counters
940 % are preserved correctly when "\includeonly" is used. In the rest of
941 % the file "\LT@tables" has been replaced by "\c@LT@tables" without
944 \newcounter{LT@tables}
948 % \begin{macro}{\c@LT@chunks}
949 % \changes{v4.00}{1996/04/08}
950 % {(DK) Chunk counter added}
951 % We need to count through the chunks of our tables from Version~4 on.
953 \newcounter{LT@chunks}[LT@tables]
957 % \begin{macro}{\c@table}
958 % \begin{macro}{\fnum@table}
959 % \begin{macro}{\tablename}
960 % If the "table" counter is not defined (eg in "letter" style), define
961 % it. (Added in V3.06.)
963 \ifx\c@table\undefined
965 \def\fnum@table{\tablename~\thetable}
967 \ifx\tablename\undefined
968 \def\tablename{Table}
975 % \begin{macro}{\LT@out}
976 % In a normal style, "longtable" uses the ".aux" file to record the
977 % column widths. With "letter.sty", use a separate ".lta" file.
980 % Not needed for new letter class.
982 %\ifx\startlabels\undefined
983 % \let\@auxout\@auxout
985 % {\@input{\jobname.lta}}%
987 % \immediate\openout\@auxout=\jobname.lta
992 % \begin{macro}{\LT@p@ftn}
993 % Temporary storage for footnote text in a `p' column.
999 % \begin{macro}{\LT@end@pen}
1000 % Special penalty for the end of the table. Done this way to save using
1001 % up a count register.
1003 \mathchardef\LT@end@pen=30000
1007 % \subsection{The \env{longtable} environment}
1009 % \begin{macro}{\longtable}
1010 % Called by "\begin{longtable}". This implementation does not work in
1011 % multiple column formats. "\par" added at V3.04.
1015 \ifx\multicols\@undefined
1017 \ifnum\col@number>\@ne
1022 \LT@err{longtable not in 1-column mode}\@ehc
1026 % Check for an optional argument.
1028 \@ifnextchar[\LT@array{\LT@array[x]}}
1032 % \begin{macro}{\LT@array}
1033 % Start setting the alignment.
1034 % Based on "\@array" from the \LaTeX\ kernel
1035 % and the \package{array} package.
1037 % Since Version 3.02, \package{longtable} has used the internal counter
1038 % "\c@LT@tables". The \LaTeX\ counter "table" is still incremented
1039 % so that "\caption" works correctly.
1041 \def\LT@array[#1]#2{%
1042 \refstepcounter{table}\stepcounter{LT@tables}%
1044 % Set up the glue around the table if an optional argument given.
1047 \LTleft\z@ \LTright\fill
1049 \LTleft\fill \LTright\z@
1051 \LTleft\fill \LTright\fill
1054 % Set up these internal commands for \env{longtable}.
1055 % \changes{v3.13}{1994/12/08}
1056 % {add \cs{tabularnewline}}
1057 % \changes{v3.14}{1995/04/25}
1058 % {(Mike Van Geest) rename \cs{LT@mc} to
1059 % \cs{LT@mcol} to allow 1100 tables}
1060 % \changes{v4.01}{1996/04/11}
1061 % {(DPC) don't need multicolumn warning}
1063 % \global\let\LT@mcw@rn\relax
1066 \let\LT@mcol\multicolumn
1068 % \changes{v3.17}{1996/01/31}
1069 % {Reset \cs{hline} and \cs{multicolumn} in nested tabular
1070 % and array, for tools/2068}
1071 % Now redefine "\@tabarray" to restore "\hline" and "\multicolumn" so
1072 % that arrays and tabulars nested in longtable (or in page headings on
1073 % longtable pages) work out OK. Saving the original definitions done
1074 % here so that you can load the \package{array} package before or after
1075 % \package{longtable}.
1077 \let\LT@@tabarray\@tabarray
1083 % \let\multicolumn\LT@mcol
1087 \let\\\LT@tabularcr\let\tabularnewline\\%
1088 \def\newpage{\noalign{\break}}%
1090 % \changes{v4.05}{1996/11/12}
1091 % {\cs{nopagebreak} and \cs{pagebreak} added}
1092 % More or less standard definitions, but first start a "\noalign".
1094 \def\pagebreak{\noalign{\ifnum`}=0\fi\@testopt{\LT@no@pgbk-}4}%
1095 \def\nopagebreak{\noalign{\ifnum`}=0\fi\@testopt\LT@no@pgbk4}%
1099 \let\hline\LT@hline \let\kill\LT@kill\let\caption\LT@caption
1100 \@tempdima\ht\strutbox
1103 % \changes{v4.08}{1998/01/20}
1104 % {Move \cs{@endpbox} definition earlier and define \cs{@@endpbox}
1105 % and \cs{@@startpbox} for non-array case. tools/2736}
1107 \let\@endpbox\LT@endpbox
1109 % Set up internal commands according to Lamport or Mittelbach.
1111 \ifx\extrarowheight\@undefined
1113 % Initialise these commands as in \env{tabular} from the \LaTeX\ kernel.
1116 \let\@classz\@tabclassz \let\@classiv\@tabclassiv
1117 \def\@startpbox{\vtop\LT@startpbox}%
1118 \let\@@startpbox\@startpbox
1119 \let\@@endpbox\@endpbox
1120 \let\LT@LL@FM@cr\@tabularcr
1123 % Initialise these commands as in \package{array}. "\d@llar"
1124 % replaced by "\d@llarbegin" "\d@llarend" in V3.03 to match
1125 % \package{array} V2.0h. We do not need to set "\d@llarbegin" and
1126 % "\d@llarend" as the \package{array} package gives them the correct
1127 % values at the top level.
1129 \advance\@tempdima\extrarowheight
1131 \let\@startpbox\LT@startpbox\let\LT@LL@FM@cr\@arraycr
1134 % The rest of this macro is mainly based on \package{array} package, but
1135 % should work for the standard \env{tabular} too.
1137 \setbox\@arstrutbox\hbox{\vrule
1138 \@height \arraystretch \@tempdima
1139 \@depth \arraystretch \dp \strutbox
1141 \let\@sharp##\let\protect\relax
1143 % Interpret the preamble argument.
1148 % We need to rename "\@preamble" here as F.M.'s scheme uses
1149 % "\global", and we may need to nest "\@mkpream", eg for
1151 % or an \env{array}.
1152 % We do not need to worry about nested \env{longtable}s though!
1156 % \changes{v4.00}{1996/04/08}
1157 % {(DK) Increment Chunk counter}
1159 \global\advance\c@LT@chunks\@ne
1160 \global\LT@rows\z@\setbox\z@\vbox\bgroup
1162 % \changes{v4.05}{1996/11/12}
1163 % {\cs{LT@setprevdepth} added}
1164 % The following line was added in v4.05.
1165 % In order to get the "\penalties" to work at chunk boundaries
1166 % Need to take more care about where and when "\lineskip" glue
1167 % is added. The following does nothing at top of table, and in
1168 % header chunks, but in normal body chunks it sets "\prevdepth"
1169 % (to 0pt, but any value would do) so that "\lineskip" glue will
1170 % be added. the important thing to note is that the glue will be
1171 % added \emph{after} any vertical material coming from "\noalign".
1176 % \changes{v4.10}{2000/10/22}
1177 % {\cs{noexpand} added (as in array.sty) for mathtext.sty, CAR}
1179 \tabskip\LTleft \noexpand\halign to\hsize\bgroup
1180 % \tabskip\LTleft\halign to\hsize\bgroup
1181 \tabskip\z@ \@arstrut \@preamble \tabskip\LTright \cr}%
1184 % Find out how many columns we have (store in "\LT@cols").
1186 \expandafter\LT@nofcols\LT@bchunk&\LT@nofcols
1188 % Get the saved row from "\LT@i"\ldots"\LT@ix" (from the
1189 % ".aux" file), or make a new blank row.
1193 % A few more internal commands for \env{longtable}.
1195 \m@th\let\par\@empty
1196 \everycr{}\lineskip\z@\baselineskip\z@
1198 % Start the first chunk.
1204 % \begin{macro}{\LT@no@pgbk}
1205 % \changes{v4.05}{1996/11/12}
1207 % Can simplify the standard "\@no@pgbk" as this is vmode only
1208 % but then need to close the "\noalign".
1210 \def\LT@no@pgbk#1[#2]{\penalty #1\@getpen{#2}\ifnum`{=0\fi}}
1214 % \begin{macro}{\LT@start}
1215 % This macro starts the process of putting the table on the current
1216 % page. It is not called until either a "\\" or "\endlongtable" command
1217 % ends a chunk, as we do not know until that point which of the four
1218 % possible head or foot sections have been specified.
1220 % It begins by redefining itself, so that the table is only started
1221 % once! Until V3.04, was redefined to "\relax", now use "\endgraf" to
1222 % force the page-breaker to wake up.
1225 \let\LT@start\endgraf
1226 \endgraf\penalty\z@\vskip\LTpre
1228 % Start a new page if there is not enough room for the table head, foot,
1229 % and one extra line.
1232 \advance\dimen@ \ht\ifvoid\LT@firsthead\LT@head\else\LT@firsthead\fi
1233 \advance\dimen@ \dp\ifvoid\LT@firsthead\LT@head\else\LT@firsthead\fi
1234 \advance\dimen@ \ht\LT@foot
1236 % \changes{v3.16}{1995/11/09}
1237 % {Measure the first line of the table}
1238 % At this point I used to add "\ht\@arstrutbox" and "\dp\@arstrutbox"
1239 % as a measure of a row size. However this can fail spectacularly
1240 % for "p" columns which might be much larger. Previous versions could
1241 % end up with the table starting with a foot, then a page break then
1242 % a head \emph{then} a `first head'! So now measure the first line of
1243 % the table accurately by "\vsplit"ting it out of the first chunk.
1248 \setbox\tw@\vsplit\tw@ to \ht\@arstrutbox
1249 \setbox\tw@\vbox{\unvbox\tw@}%
1252 \ifdim\ht\@arstrutbox>\ht\tw@\@arstrutbox\else\tw@\fi
1254 \ifdim\dp\@arstrutbox>\dp\tw@\@arstrutbox\else\tw@\fi
1258 \advance\dimen@ -\pagegoal
1259 \ifdim \dimen@>\z@\vfil\break\fi
1261 % Store height of page minus table foot in "\@colroom".
1262 % \changes{v3.14}{1995/05/02}
1263 % {Set \cs{@colroom}, for tools/1584}
1265 \global\@colroom\@colht
1267 % If the foot is non empty, reduce the "\vsize" and "\@colroom"
1270 \ifvoid\LT@foot\else
1271 \advance\vsize-\ht\LT@foot
1272 \global\advance\@colroom-\ht\LT@foot
1273 \dimen@\pagegoal\advance\dimen@-\ht\LT@foot\pagegoal\dimen@
1277 % Put the table head on the page, and then switch to the new output
1279 % \changes{v4.11}{2004/02/01}
1280 % {\cs{nobreak}, for tools/3484}
1282 \ifvoid\LT@firsthead\copy\LT@head\else\box\LT@firsthead\fi\nobreak
1283 \output{\LT@output}}
1287 % \begin{macro}{\endlongtable}
1288 % Called by "\end{longtable}".
1292 % Essentially add a final "\\". But as we now know the number of
1293 % actual chunks, we first strip away all entries referring to a
1294 % maximum entry beyond the table (this can only happen if a table has
1295 % been shortened, or the table numbering has gone awry). In that case
1296 % we at least start collecting valid new information with the last
1297 % chunk of this table, by removing the width constraint.
1298 % \changes{v4.01}{1996/04/11}
1299 % {(DPC) use \cs{noalign} to sneak in \cs{LT@entry@chop}}
1303 \let\LT@entry\LT@entry@chop
1304 \xdef\LT@save@row{\LT@save@row}}%
1310 % Write the dummy row to the ".aux" file.
1311 % Since V3.06, use ".lta" for "letter.sty".
1312 % \changes{v3.12}{1994/06/30}
1313 % {Do not write if \cs{nofiles} in operation.}
1316 {\let\LT@entry\LT@entry@write\immediate\write\@auxout{%
1318 % Since Version 3.02, \package{longtable} has used the internal counter
1319 % "\c@LT@tables" rather than the \LaTeX\ counter \textsf{table}. This
1320 % information looks entirely different from version~3
1321 % information. Still, we don't need to rename the macro name because
1322 % later code will consider the information to have no columns, and
1323 % thus will throw the old data away.
1325 \gdef\expandafter\noexpand
1326 \csname LT@\romannumeral\c@LT@tables\endcsname
1330 % At this point used to
1331 % issue a warning if a "\multicolumn" has been set in draft mode.
1332 % \changes{v4.01}{1996/04/11}
1333 % {(DPC) No need for multicolumn warnings}
1337 % If the last chunk has different widths than the first, warn the user.
1338 % Also trigger a warning to rerun \LaTeX\ at the end of the document.
1339 % \changes{v4.04}{1996/05/24}
1340 % {Use \cs{LT@final@warn}}
1342 \ifx\LT@save@row\LT@@save@row
1344 \LT@warn{Column \@width s have changed\MessageBreak
1345 in table \thetable}%
1349 % Force one more go with the \env{longtable} output routine.
1351 \endgraf\penalty -\LT@end@pen
1353 % Now close the group to return to the standard routine.
1357 % Reset "\@mparbottom" to allow marginpars close to the end of the
1358 % table.\footnote{This can not be the correct. However if it is omitted,
1359 % there is a problem with marginpars, for example on page~3 of this
1360 % document. Any Output Routine Gurus out there?}
1362 \global\@mparbottom\z@
1364 \endgraf\penalty\z@\addvspace\LTpost
1366 % Footnotes. As done in the \package{multicol} package.
1368 \ifvoid\footins\else\insert\footins{}\fi}
1372 % \subsection{Counting Columns}
1374 % Columns are counted by examining "\@preamble", rather than simply
1375 % getting "\@mkpream" to increment the counter as it builds the
1376 % preamble so that this package works with many of the packages which
1377 % add extra column specifiers to \LaTeX's standard ones.
1379 % Version~1 counted "\@sharp"'s to calculate the number of columns,
1380 % this was changed for Version~2 as it does not work with the NFSS. Now
1381 % count "&"'s. ("lfonts.new" (and now the Standard \LaTeX\ definition)
1382 % defines "\@tabclassz" so that "\@sharp" is inside a group.)
1384 % \begin{macro}{\LT@nofcols}
1385 % Find the next "&", then look ahead to see what is next.
1387 \def\LT@nofcols#1&{%
1388 \futurelet\@let@token\LT@n@fcols}
1392 % \begin{macro}{\LT@n@fcols}
1393 % Add one, then stop at an "\LT@nofcols" or look for the next
1394 % "&". The "\expandafter" trick was added in Version~3, also the
1395 % name changed from "\@LT@nofcols" to preserve the "\LT@" naming
1399 \advance\LT@cols\@ne
1400 \ifx\@let@token\LT@nofcols
1401 \expandafter\@gobble
1403 \expandafter\LT@nofcols
1408 % \subsection{The {\ttfamily\bslash\bslash} and \cs{kill} Commands}
1410 % \begin{macro}{\LT@tabularcr}
1411 % \changes{v4.05}{1996/11/12}
1412 % {Code re-organised for the *-form processing.}
1413 % The internal definition of "\\".
1414 % In the "*" form, insert a "\nobreak" after the next "\cr" (or "\crcr").
1416 % This star form processing was finally added in v4.05. For the previous
1417 % six or seven years the comment at this point said
1418 % \begin{quote}\small
1419 % This definition also accepts "\\*", which acts in the same way as
1420 % "\\". \env{tabular} does this, but \env{longtable} probably ought to
1421 % make "\\*" prevent page breaking.
1424 % "{\ifnum0=`}\fi" added in version 3.01, required if the first entry
1426 % The above in fact is not good enough, as with \package{array} package
1427 % it can introduce a "{}" group in math mode, which changes the spacing.
1428 % So use the following variant. Added in v3.14.
1429 % \changes{v3.14}{1995/04/25}
1430 % {More fun with \cs{ifnum} cf tools/1571}
1433 \relax\iffalse{\fi\ifnum0=`}\fi
1435 {\def\crcr{\LT@crcr\noalign{\nobreak}}\let\cr\crcr
1441 % \begin{macro}{\LT@crcr}
1442 % \changes{v4.05}{1996/11/12}
1449 % \begin{macro}{\LT@setprevdepth}
1450 % \changes{v4.05}{1996/11/12}
1452 % This will be redefined to set the "\prevdepth"
1453 % at the start of a chunk.
1455 \let\LT@setprevdepth\relax
1459 % \begin{macro}{\LT@t@bularcr}
1463 % Increment the counter, and do \env{tabular}'s "\\" or finish the
1464 % chunk.\\ The "\expandafter" trick was added in Version~3.
1465 % Set the "\prevdepth" at the start of a new chunk. (Done here
1466 % so not set in header chunks).
1468 \global\advance\LT@rows\@ne
1469 \ifnum\LT@rows=\LTchunksize
1470 \gdef\LT@setprevdepth{%
1471 \prevdepth\z@\global
1472 \global\let\LT@setprevdepth\relax}%
1473 \expandafter\LT@xtabularcr
1476 \expandafter\LT@LL@FM@cr
1481 % \begin{macro}{\LT@xtabularcr}
1482 % This just looks for an optional argument.
1484 \def\LT@xtabularcr{%
1485 \@ifnextchar[\LT@argtabularcr\LT@ntabularcr}
1489 % \begin{macro}{\LT@ntabularcr}
1490 % The version with no optional argument.
1491 % "\ifnum0=`{\fi}" added in version 3.01. Changed in 3.14.
1493 \def\LT@ntabularcr{%
1503 % \begin{macro}{\LT@argtabularcr}
1504 % The version with an optional argument.
1505 % "\ifnum0=`{\fi}" added in version 3.01. Changed in 3.14.
1507 \def\LT@argtabularcr[#1]{%
1510 \unskip\@xargarraycr{#1}%
1515 % Add the dummy row, and finish the "\halign".
1525 % \begin{macro}{\LT@echunk}
1526 % \changes{v4.05}{1996/11/12}
1527 % {\cs{unskip} added for pagebreak support}
1528 % This ends the current chunk, and removes the dummy row.
1531 \crcr\LT@save@row\cr\egroup
1532 \global\setbox\@ne\lastbox
1534 % The following line was added in v4.05.
1535 % \package{longtable} relies on "\lineskip" glue (which is 0pt) to
1536 % provide break points between each row so the table may be split
1539 % Previous releases left the "\lineskip" glue at the end of each chunk
1540 % that had been added when the dummy row was added. There was no glue
1541 % at the start of the next chunk as \TeX\ normally does not put
1542 % "\lineskip" glue at the top of a box. This meant that normally the
1543 % chunks fitted together perfectly, however "\noalign" material at a
1544 % chunk boundary came before the first row of the next chunk
1545 % but after the lineskip glue at the end of this chunk. This is the
1546 % wrong place, e.g., it means even a "\penalty10000" does not stop a
1547 % break as the "\lineskip" glue in the previous item on the list
1548 % provides a legal breakpoint. So now remove the "\lineskip" glue that
1549 % was before the dummy row and introduce "\LT@setprevdepth" to set the
1550 % "\prevdepth" at the start of the next chunk, to make sure "\lineskip"
1551 % glue is added later.
1558 % \begin{macro}{\LT@entry}
1559 % \changes{v4.00}{1996/04/08}
1560 % {(DK) Macro added}
1561 % \changes{v4.01}{1996/04/11}
1562 % {(DPC) Use \cs{ifhmode} trick to determine first entry}
1563 % We here give the `basic' definition of "\LT@entry", namely that used
1564 % in alignment templates. It has a "\kern" only if the maximum is
1565 % imposed from a different chunk.
1566 % The "\ifhmode" test reveals the first entry, when we don't want to add
1570 \ifhmode\@firstofone{&}\fi\omit
1571 \ifnum#1=\c@LT@chunks
1578 % \begin{macro}{\LT@entry@chop}
1579 % \changes{v4.00}{1996/04/08}
1580 % {(DK) Macro added}
1581 % This definition for the argument of "\LT@save@row" is used to scrap
1582 % all those maxima which could not be verified because they occur
1583 % after the end of the table. This can happen only if a table has been
1584 % shortened (or the sequencing got mixed up) since the
1586 % Note that this is premature: the last chunk still is going to be
1587 % set, and with the chopped limits.
1589 \def\LT@entry@chop#1#2{%
1591 {\ifnum#1>\c@LT@chunks
1599 % \begin{macro}{\LT@entry@write}
1600 % \changes{v4.07}{1997/10/16}
1601 % {Avoid use of percent. tools/2631}
1602 % To write an entry for the "aux" file, we use a slightly
1603 % surprising definition which has the sole purpose of avoiding
1604 % overfull lines (which might break \TeX{}'s limits when reading the
1605 % "aux" file, probably you'd need to have a few hundred columns before
1606 % this happened but\ldots).
1608 \def\LT@entry@write{%
1609 \noexpand\LT@entry^^J%
1614 % \begin{macro}{\LT@kill}
1615 % This ends the current chunk as above, but strips off two rows, the
1616 % `dummy row' and the `killed row' before starting the next chunk.
1617 % Since V3.04, the old chunk is reboxed at the start of the box
1618 % containing the next chunk. This allows "\kill" to be used in headers,
1619 % which must be processed in a single box.
1624 \expandafter\LT@rebox\LT@bchunk}
1628 % \begin{macro}{\LT@rebox}
1629 % Drop the old chunk (box0) back at the top of the new chunk, removing
1630 % the killed row. This macro added at V3.04.
1632 \def\LT@rebox#1\bgroup{%
1640 % \subsection{The Dummy Row}
1642 % The dummy row is kept inside of the macro "\LT@save@row".
1644 % \begin{macro}{\LT@blank@row}
1645 % \begin{macro}{\LT@build@blank}
1646 % \changes{v4.00}{1996/04/08}
1647 % {(DK) Macro added}
1648 % \changes{v4.01}{1996/04/11}
1649 % {(DPC) Don't mess with \cs{multicolumn} on draft passes}
1650 % Create a blank row if we are not using the info in the ".aux" file.
1653 \xdef\LT@save@row{\expandafter\LT@build@blank
1654 \romannumeral\number\LT@cols 001 }}
1656 % Whoops! What's that supposed to be? A drop-in replacement for the
1657 % first task of Appendix~D in the \TeX book. The "\romannumeral"
1658 % produces "\LT@cols" instances of "m" followed by "i". The below
1659 % macro then replaces the "m"s by appropriate entries.
1661 \def\LT@build@blank#1{%
1663 \noexpand\LT@entry{1}{0pt}%
1664 \expandafter\LT@build@blank
1670 % \begin{macro}{\LT@make@row}
1671 % \changes{v4.00}{1996/04/08}
1672 % {(DK) New implementation}
1673 % \changes{v4.01}{1996/04/11}
1674 % {(DPC) Make this the default behaviour, not needing
1675 % \cs{setlongtables}}
1677 % Prior to version 4, by default did not use information in the
1678 % ".aux" file but now we can define "\LT@make@row" to use the ".aux"
1679 % file, even on the `draft' passes.
1682 \global\expandafter\let\expandafter\LT@save@row
1683 \csname LT@\romannumeral\c@LT@tables\endcsname
1684 \ifx\LT@save@row\relax
1687 % Now a slightly difficult part comes. Before we decide making the
1688 % template from the ".aux" file info we check that the number of
1689 % fields has remained the same. If it hasn't, either the table format
1690 % has changed, or we have the wrong table altogether. In both cases,
1691 % we decide to better drop all gathered information and start over.
1692 % \changes{v4.01}{1996/04/11}
1693 % {(DPC) Use \cs{if} test rather than \cs{ifx}\cs{@empty}}
1695 % The expansion between "!"\ldots"!" below will be empty if the number
1696 % of "\LT@entry" macros
1697 % including arguments in "\LT@save@row" is equal to "\LT@cols". If it
1698 % is not empty, we throw the row away and start from scratch.
1703 \ifcase\expandafter\expandafter\expandafter\LT@cols
1704 \expandafter\@gobble\LT@save@row
1711 \aftergroup\LT@blank@row
1717 % \begin{macro}{\setlongtables}
1718 % Redefine "\LT@make@row" to use information in the ".aux" file,
1719 % if there is a saved row for this table with the right number of
1722 % Since Version 3.02, \package{longtable} has used the internal counter
1723 % "\c@LT@tables" rather than the \LaTeX\ counter \textsf{table}.
1724 % The warning message was added at V3.04, as was the "\global", to stop
1725 % save-stack overflow.
1727 % Since Version 4.01 "\setlongtables" does nothing as it is not
1728 % needed, but is defined as "\relax" for the benefit of old documents.
1729 % \changes{v3.12}{1994/06/30}
1730 % {Warning altered to fit line on terminal.}
1731 % \changes{v4.01}{1996/04/11}
1732 % {(DPC) make into no op}
1734 \let\setlongtables\relax
1738 % \begin{macro}{\LT@get@widths}
1739 % This is the heart of \package{longtable}. If it were not for the table
1740 % head and foot, this macro together with the modified "\\" command
1741 % would form the basis of quite a simple little package file for long
1742 % tables. It is closely modelled on the "\endvrulealign" macro of
1743 % appendix D of the \TeX book.
1745 \def\LT@get@widths{%
1747 % "\global" added at V3.04, to stop save-stack overflow.
1750 % Loop through the last row, discarding glue, and saving box widths. At
1751 % V3.04 changed the scratch box to 2, as the new "\kill" requires that
1752 % "\box0" be preserved.
1756 \let\LT@old@row\LT@save@row
1757 \global\let\LT@save@row\@empty
1764 \advance\count@\m@ne
1767 % Remember the widths if we are in the first chunk.
1769 \ifx\LT@@save@row\@undefined
1770 \let\LT@@save@row\LT@save@row
1775 % \begin{macro}{\LT@def@row}
1776 % \changes{v4.00}{1996/04/08}
1777 % {(DK) New implementation}
1778 % Add a column to the dummy row. Name changed from "\defLT@save@row"
1779 % in Version~3, to preserve the "\LT@" naming convention.
1783 % We start by picking the respective entry from our old row.
1784 % These redefinitions of "\LT@entry" are local to the group started
1785 % in "\LT@get@widths".
1789 \ifcase\expandafter\count@\LT@old@row
1794 % Now we tack the right combination in front of "\LT@save@row":
1799 \expandafter\LT@max@sel\@tempa
1804 % \begin{macro}{\LT@max@sel}
1805 % \changes{v4.00}{1996/04/08}
1806 % {(DK) macro added}
1807 % \changes{v4.01}{1996/04/11}
1808 % {(DPC) minor modifications}
1809 % And this is how to select the right combination. Note that we take
1810 % the old maximum information only if the size does not change in
1811 % \emph{either} direction. If the size has grown, we of course have a
1812 % new maximum. If the size has shrunk, the old maximum (which was
1813 % explicitly not enforced because of being in the current chunk) is
1814 % invalid, and we start with this chunk as the new size. Note that
1815 % even in the case of equality we \emph{must} use the "\the\wd\tw@"
1816 % construct instead of "#2" because "#2" might be read in from the
1817 % file, and so could have "\catcode"~11 versions of "p" and~"t" in~it
1818 % which we want to be replaced by their `proper' "\catcode"~12 versions.
1820 \def\LT@max@sel#1#2{%
1830 % \subsection{The \cs{hline} Command}
1832 % \begin{macro}{\LT@hline}
1833 % "\hline" and "\hline\hline" both produce \emph{two} lines.
1834 % The only difference being the glue and penalties between them.
1835 % This is so that a page break at a "\hline" produces a line on both
1837 % {\env{longtable} has always done this, but perhaps it would be
1838 % better if hlines were \emph{omitted} at a page break, as the head and
1839 % foot usually put a hline here anyway.}
1840 % Also this "\hline" is more like a "\cline{1-\LT@cols}".
1841 % \env{tabular}'s "\hline" would draw lines the full width of the page.
1844 \noalign{\ifnum0=`}\fi
1846 \futurelet\@let@token\LT@@hline}
1850 % \begin{macro}{\LT@@hline}
1851 % This code is based on "\cline". Two copies of the line are produced,
1852 % as described above.
1855 \ifx\@let@token\hline
1856 \global\let\@gtempa\@gobble
1857 \gdef\LT@sep{\penalty-\@medpenalty\vskip\doublerulesep}%
1859 \global\let\@gtempa\@empty
1860 \gdef\LT@sep{\penalty-\@lowpenalty\vskip-\arrayrulewidth}%
1864 \unskip\leaders\hrule\@height\arrayrulewidth\hfill\cr
1867 \unskip\leaders\hrule\@height\arrayrulewidth\hfill\cr
1868 \noalign{\penalty\@M}%
1873 % \subsection{Captions}
1875 % \begin{macro}{\LT@caption}
1876 % The caption is "\multicolumn{\LT@cols}{c}{"\meta{a parbox with the
1877 % table's caption}"}"
1881 \@ifnextchar[{\egroup\LT@c@ption\@firstofone}\LT@capti@n}
1885 % \begin{macro}{\LT@c@ption}
1886 % Caption command (with [optional argument]). "\protect" added in
1887 % Version~3. "\fnum@table" added at V3.05.
1888 % \changes{v3.14}{1995/05/02}
1889 % {Call \cs{LT@makecaption} not \cs{LT@mkcaption}}
1890 % \changes{v3.14}{1995/05/24}
1891 % {Add new control argument}
1893 \def\LT@c@ption#1[#2]#3{%
1894 \LT@makecaption#1\fnum@table{#3}%
1896 \ifx\@tempa\@empty\else
1898 \addcontentsline{lot}{table}{\protect\numberline{\thetable}{#2}}}%
1903 % \begin{macro}{\LT@capti@n}
1904 % Caption command (no [optional argument])
1905 % \changes{v3.14}{1995/05/02}
1906 % {Call \cs{LT@makecaptionx} not \cs{LT@mkcaption}}
1907 % \changes{v3.14}{1995/05/24}
1908 % {Call \cs{LT@makecaption} with \cs{@gobble} or \cs{@firstofone}}
1912 {\egroup\LT@c@ption\@gobble[]}%
1913 {\egroup\@xdblarg{\LT@c@ption\@firstofone}}}
1918 % \begin{macro}{\LT@makecaption}
1919 % Put the caption in a box of width 0pt, so that it never affects the
1920 % column widths. Inside that is a "\parbox" of width
1922 % \changes{v3.14}{1995/05/02}
1923 % {Renamed from \cs{LT@mkcaption},
1924 % and modified to call \cs{@makecaption}}
1925 % \changes{v3.14}{1995/05/02}
1926 % {Use the first arg to remove counter for star form}
1928 \def\LT@makecaption#1#2#3{%
1929 \LT@mcol\LT@cols c{\hbox to\z@{\hss\parbox[t]\LTcapwidth{%
1931 % Based on article class "\@makecaption", "#1" is "\@gobble" in star
1932 % form, and "\@firstofone" otherwise.
1934 \sbox\@tempboxa{#1{#2: }#3}%
1935 \ifdim\wd\@tempboxa>\hsize
1938 \hbox to\hsize{\hfil\box\@tempboxa\hfil}%
1940 \endgraf\vskip\baselineskip}%
1946 % \subsection{The Output Routine}
1948 % The method used here for interfacing a special purpose output routine
1949 % to the standard \LaTeX\ routine is lifted straight out of
1950 % F.~Mittelbach's \package{multicol} package.
1952 % \begin{macro}{\LT@output}
1953 % Actually this is not so bad, with FM leading the way.
1956 \ifnum\outputpenalty <-\@Mi
1957 \ifnum\outputpenalty > -\LT@end@pen
1959 % If this was a float or a marginpar we complain.
1961 \LT@err{floats and marginpars not allowed in a longtable}\@ehc
1964 % We have reached the end of the table, on the scroll at least,
1966 \setbox\z@\vbox{\unvbox\@cclv}%
1967 \ifdim \ht\LT@lastfoot>\ht\LT@foot
1969 % The last foot might not fit, so:\footnote{An alternative would be to
1970 % vsplit off a bit of the last chunk, so that the last page did not just
1971 % have head and foot sections, but it is hard to do this in a consistent
1975 \advance\dimen@-\ht\LT@lastfoot
1976 \ifdim\dimen@<\ht\z@
1977 \setbox\@cclv\vbox{\unvbox\z@\copy\LT@foot\vss}%
1980 \setbox\z@\vbox{\box\LT@head}%
1982 % End of "\ifdim\dimen@<\ht\@cclc".
1986 % End of "\ifdim \ht\LT@lastfoot > \ht\LT@foot".
1990 % Reset "\@colroom".
1991 % \changes{v3.14}{1995/05/02}
1992 % {Reset \cs{@colroom}, for tools/1584}
1994 \global\@colroom\@colht
1995 \global\vsize\@colht
1997 % Put the last page of the table on to the main vertical list.
2000 {\unvbox\z@\box\ifvoid\LT@lastfoot\LT@foot\else\LT@lastfoot\fi}%
2002 % End of "\ifnum\outputpenalty > -\LT@end@pen".
2006 % Else "\outputpenalty > -\@Mi".
2010 % If we have not reached the end of the table,
2012 \setbox\@cclv\vbox{\unvbox\@cclv\copy\LT@foot\vss}%
2017 % \changes{v3.14}{1995/05/02}
2018 % {Reset \cs{vsize}, for tools/1584}
2020 \global\vsize\@colroom
2022 % Put the head at the top of the next page.
2023 % \changes{v4.11}{2004/02/01}
2024 % {\cs{nobreak}, for tools/3484}
2026 \copy\LT@head\nobreak
2028 % End of "\ifnum\outputpenalty <-\@Mi".
2034 % \subsection{Commands for the the table head and foot}
2036 % \begin{macro}{\LT@end@hd@ft}
2037 % The core of "\endhead" and friends. Store the current chunk in the
2038 % box specified by "#1". Issue an error if the table has already
2039 % started. Then start a new chunk.
2041 \def\LT@end@hd@ft#1{%
2044 % Changed from "\relax" to "\endgraf" at V3.04, see "\LT@start".
2046 \ifx\LT@start\endgraf
2048 {Longtable head or foot not at start of table}%
2049 {Increase LTchunksize}%
2057 % \begin{macro}{\endfirsthead}
2058 % \begin{macro}{\endhead}
2059 % \begin{macro}{\endfoot}
2060 % \begin{macro}{\endlastfoot}
2061 % Call "\LT@end@hd@ft" with the appropriate box.
2063 \def\endfirsthead{\LT@end@hd@ft\LT@firsthead}
2064 \def\endhead{\LT@end@hd@ft\LT@head}
2065 \def\endfoot{\LT@end@hd@ft\LT@foot}
2066 \def\endlastfoot{\LT@end@hd@ft\LT@lastfoot}
2073 % \subsection{The \cs{multicolumn} command}
2075 % Earlier versions needed a special `draft' form of "\multicolumn".
2076 % This is not needed in version~4, and so these commands have been
2079 % \begin{macro}{\LTmulticolumn}
2080 % \changes{v4.01}{1996/04/11}
2081 % {(DPC) macro removed}
2084 % \begin{macro}{\LT@mcwarn}
2085 % \changes{v4.01}{1996/04/11}
2086 % {(DPC) macro removed}
2089 % \subsection{Footnotes}
2091 % The standard "\footnote" command works in a "c" column, but we
2092 % need to modify the definition in a "p" column to overcome the
2093 % extra level of boxing. These macros are based on the \package{array}
2094 % package, but should be OK for the standard \env{tabular}.
2096 % \begin{macro}{\LT@startpbox}
2097 % \changes{v4.09}{1998/05/13}
2098 % {Use \cs{setlength}, so that calc extensions apply. tools/2793}
2099 % Add extra code to switch the definition of "\@footnotetext".
2101 \def\LT@startpbox#1{%
2103 \let\@footnotetext\LT@p@ftntext
2104 \setlength\hsize{#1}%
2105 \@arrayparboxrestore
2106 \vrule \@height \ht\@arstrutbox \@width \z@}
2110 % \begin{macro}{\LT@endpbox}
2111 % After the parbox is closed, expand "\LT@p@ftn" which will execute a
2113 % "\footnotetext["\meta{num}"]{"\meta{note}"}"\\
2114 % commands. After being lifted out of the parbox, they can migrate on
2115 % their own from here.
2116 % \changes{v3.10}{1994/05/15}
2117 % {Use \cs{@finalstrut}}
2118 % \changes{v4.03}{1996/05/07}
2119 % {Use \cs{hfil} for tools/2120}
2122 \@finalstrut\@arstrutbox
2130 % \begin{macro}{\LT@p@ftntext}
2131 % Inside the `p' column, just save up the footnote text in a token
2134 \def\LT@p@ftntext#1{%
2135 \edef\@tempa{\the\LT@p@ftn\noexpand\footnotetext[\the\c@footnote]}%
2136 \global\LT@p@ftn\expandafter{\@tempa{#1}}}%