1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
|
% \iffalse meta-comment
%
% Copyright 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005
% 2006 2008 2009
% The LaTeX3 Project and any individual authors listed elsewhere
% in this file.
%
% This file is part of the Standard LaTeX `Tools Bundle'.
% -------------------------------------------------------
%
% It may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3c
% of this license or (at your option) any later version.
% The latest version of this license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% The list of all files belonging to the LaTeX `Tools Bundle' is
% given in the file `manifest.txt'.
%
% \fi
% \iffalse
%% File: longtable.dtx Copyright (C) 1990-2001 David Carlisle
%
%<*dtx>
\ProvidesFile{longtable.dtx}
%</dtx>
%<package>\NeedsTeXFormat{LaTeX2e}[1995/06/01]
%<package>\ProvidesPackage{longtable}
%<driver> \ProvidesFile{longtable.drv}
% \fi
% \ProvidesFile{longtable.dtx}
[2004/02/01 v4.11 Multi-page Table package (DPC)]
%
% \iffalse
%<*driver>
\documentclass{ltxdoc}
\usepackage{longtable}
\begin{document}
\DocInput{longtable.dtx}
\end{document}
%</driver>
% \fi
%
% \GetFileInfo{longtable.dtx}
% \title{The \textsf{longtable} package\thanks{This file
% has version number \fileversion, last
% revised \filedate.}}
% \author{David Carlisle\thanks{The new algorithm for aligning `chunks'
% of a table used in version 4 of this package was devised coded
% and documented by David Kastrup,
% \texttt{dak@neuroinformatik.ruhr-uni-bochum.de}.}}
% \date{\filedate}
%
% \let\package\textsf
% \let\env\textsf
% \providecommand\finalclearpage{\clearpage}
%
% \maketitle
%
% \begin{abstract}
% This package defines the \env{longtable} environment, a multi-page
% version of \env{tabular}.
% \end{abstract}
%
% \DeleteShortVerb{\|}
% \MakeShortVerb{\"}
%
% \changes{v0.00}{1989/11/06}
% {`Version 0' distributed as longtab.sty
% always used just one chunk for the whole table}
%
% \changes{v1.00}{1990/12/20}
% {Initial version}
%
% \changes{v2.00}{1991/06/17}
% {Support NFSS and array.sty}
%
% \changes{v3.00}{1992/03/16}
% {New implementation. tables may now start anywhere on the page.}
%
% \changes{v3.01}{1992/04/06}
% {(Michel Goossens) If a chunk ends on a line in which the first
% entry is empty, wierd errors occur. Added special begin and end
% groups, (\cs{ifnum}0 ) stuff as explained in Appendix D.}
%
% \changes{v3.02}{1992/04/09}
% {(Michel Goossens) Longtable fails if the table counter is reset
% during a document. Now use an internal counter, but still
% increment table so \cs{caption} and \cs{label} work out right.}
%
% \changes{v3.03}{1992/06/25}
% {Add \cs{@ifundefined\{reset@font\}} so that the documentation may
% be processed with old versions of \LaTeX.}
% \changes{v3.03}{1992/06/25}
% {Modify the treatment of \cs{d@llar} to match the new versions of
% Mittelbach's array.sty (array.sty v2.0h)}
%
% \changes{v3.04}{1992/11/12}
% {(Jean-Pierre Drucbert) Longtable failed when used with
% \cs{includeonly}.}
% \changes{v3.04}{1992/11/12}
% {Fix bug which stopped \cs{kill} working correctly in headings.}
% \changes{v3.04}{1992/11/12}
% {(Graham Gough) Made \cs{setlongtables} issue a warning message.}
% \changes{v3.04}{1992/11/12}
% {(Sebastian Rahtz) longtable ran out of memory on really long
% tables. Another bug introduced in V3.}
%
% \changes{v3.05}{1992/11/20}
% {(Juergen Peus) Table was hard coded into the captions, Now the
% captions use \cs{fnum@table}, so \cs{tablename} will be used.}
%
% \changes{v3.06}{1993/01/21}
% {(Ingo Hoffmann) longtable fails with letter style.
% The table counter is not defined, and the .aux file is not used in
% the same way. This version will use a .lta file for letter style.}
%
% \changes{v3.07}{1993/06/09}
% {Allow the \LaTeX\ syntax \cs{setcounter}\{LTchunksize\}\{10\}}
%
% \changes{v3.08}{1993/06/09}
% {Update for \LaTeXe}
%
% \changes{v3.09}{1994/03/15}
% {New ltxdoc style}
%
% \changes{v3.11}{1994/05/22}
% {Option handling added, new style errors and warnings}
%
% \changes{v3.12}{1994/06/30}
% {Remove special letter class handling from v3.06, not needed for
% new letter class}
%
% \changes{v4.00}{1996/04/08}
% {(DK) New algorithm to align chunks devised and coded by David
% Kastrup}
%
% \changes{v4.02}{1996/04/16}
% {(DPC/DK) documentation improvements}
%
% \changes{v4.06}{1997/06/28}
% {(DK) new email address}
%
% \CheckSum{1045}
%
%
% \makeatletter
% \def\@oddfoot{\normalfont\rmfamily\dotfill Page \thepage\dotfill}
% \def\@oddhead{\dotfill{\normalfont\ttfamily longtable.sty}\dotfill}
% \def\ps@titlepage{\let\@oddhead\@empty}
% \makeatother
%
%
% \setlength\LTleft\parindent
% \setlength\LTright\fill
% \setcounter{LTchunksize}{10}
%
% \def\v{\char`}
%
% ^^A \vbox to 100pt makes the page breaks the same on the first run.
% \changes{v3.08}{1993/06/09}
% {No need to use \cs{vbox} with \LaTeXe\ minipage}
% \noindent\begin{minipage}[t][130pt]{\textwidth}
% \listoftables
% \end{minipage}
%
% \section{Introduction}
%
% The \package{longtable} package defines a new environment,
% \DescribeEnv{longtable}
% \env{longtable}, which has most of the features of the \env{tabular}
% environment, but produces tables which may be broken by \TeX's
% standard page-breaking algorithm. It also shares some features with
% the \env{table} environment. In particular it uses the same counter,
% \texttt{table}, and has a similar "\caption" command. Also, the
% standard "\listoftables" command lists tables produced by either the
% \env{table} or \env{longtable} environments.
%
% The following example uses most of the features of the \env{longtable}
% environment. An edited listing of the input for this example appears
% in Section~\ref{listing}.
%
% \textbf{Note:} Various parts of the following table will
% \textbf{not} line up correctly until this document has been run
% through \LaTeX\ several times. This is a characteristic feature of
% this package, as described below.
%
% \begin{longtable}{@{*}r||p{1in}@{*}}
% KILLED & LINE!!!! \kill
% \caption
% [An optional table caption (used in the list of tables)]
% {A long table\label{long}}\\
% \hline\hline
% \multicolumn{2}{@{*}c@{*}}%
% {This part appears at the top of the table}\\
% \textsc{First}&\textsc{Second}\\
% \hline\hline
% \endfirsthead
% \caption[]{(continued)}\\
% \hline\hline
% \multicolumn{2}{@{*}c@{*}}%
% {This part appears at the top of every other page}\\
% \textbf{First}&\textbf{Second}\\
% \hline\hline
% \endhead
% \hline
% This goes at the&bottom.\\
% \hline
% \endfoot
% \hline
% These lines will&appear\\
% in place of the & usual foot\\
% at the end& of the table\\
% \hline
% \endlastfoot
% \env{longtable} columns are specified& in the \\
% same way as in the \env{tabular}& environment.\\
% "@{*}r||p{1in}@{*}"& in this case.\\
% Each row ends with a& "\\" command.\\
% The "\\" command has an& optional\\
% argument, just as in& the\\
% \env{tabular}&environment.\\[10pt]
% See the effect of "\\[10pt]"&?\\
% Lots of lines& like this.\\
% Lots of lines& like this.\\
% Lots of lines& like this.\\
% Lots of lines& like this.\\
% Also "\hline" may be used,& as in \env{tabular}.\\
% \hline
% That was a "\hline"&.\\
% \hline\hline
% That was "\hline\hline"&.\\
% \multicolumn{2}{||c||}%
% {This is a \ttfamily\v\\multicolumn\v{2\v}\v{||c||\v}}\\
% If a page break occurs at a "\hline" then& a line is drawn\\
% at the bottom of one page and at the& top of the next.\\
% \hline
% The "[t] [b] [c]" argument of \env{tabular}& can not be used.\\
% The optional argument may be one of& "[l] [r] [c]"\\
% to specify whether the table should be& adjusted\\
% to the left, right& or centrally.\\
% \hline\hline
% Lots of lines& like this.\\
% Lots of lines& like this.\\
% Lots of lines& like this.\\
% Lots of lines& like this.\\
% Lots of lines& like this.\\
% Lots of lines& like this.\\
% Lots of lines& like this.\\
% Lots of lines& like this.\\
% Lots of lines& like this.\\
% Lots of lines& like this.\\
% Lots of lines& like this.\\
% Lots of lines& like this.\\
% Lots of lines& like this.\\
% Lots of lines& like this.\\
% Lots of lines& like this.\\
% Lots of lines& like this.\\
% Lots of lines& like this.\\
% Lots of lines& like this.\\
% Lots of lines& like this.\\
% Lots of lines& like this.\\
% Some lines may take up a lot of space, like this: &
% \raggedleft This last column is a ``p'' column so this
% ``row'' of the table can take up several lines. Note however that
% \TeX\ will never break a page within such a row. Page breaks only
% occur between rows of the table or at "\hline" commands.
% \tabularnewline
% Lots of lines& like this.\\
% Lots of lines& like this.\\
% Lots of lines& like this.\\
% Lots of lines& like this.\\
% Lots of lines& like this.\\
% Lots of lines& like this.\\
% Lots of lines& like this.\\
% \hline
% Lots\footnote{This is a footnote.} of lines& like this.\\
% Lots of lines& like this\footnote{\env{longtable} takes special
% precautions, so that footnotes may also be used in `p' columns.}\\
% \hline
% Lots of lines& like this.\\
% Lots of lines& like this.
% \end{longtable}
%
% \section{Chunk Size}
%
% \DescribeMacro{LTchunksize}
% In order to \TeX\ multi-page tables, it is necessary to break up the
% table into smaller chunks, so that \TeX\ does not have to keep
% everything in memory at one time. By default \env{longtable} uses 20
% rows per chunk, but this can be set by the user, with e.g.,
% "\setcounter{LTchunksize}{10}".\footnote
% {You can also use the plain \TeX\ syntax
% {\ttfamily\v\\LTchunksize=10.}}
% These chunks do not affect page breaking,
% thus if you are using a \TeX\ with a lot of memory, you can set
% "LTchunksize" to be several pages of the table. \TeX\ will run
% faster with a large "LTchunksize". However, if necessary,
% \env{longtable} can work with "LTchunksize" set to 1, in which case
% the memory taken up is negligible.
% Note that if you use the commands for setting the table head or foot
% (see below), the "LTchunksize" must be at least as large as the
% number of rows in each of the head or foot sections.
%
% This document specifies "\setcounter{LTchunksize}{10}". If you look
% at the previous table, after the \emph{first} run of \LaTeX\ you will
% see that various parts of the table do not line up.
% \LaTeX\ will also have printed a warning that the column
% widths had changed. \env{longtable} writes information onto the
% ".aux" file, so that it can line up the different chunks.
% Prior to version~4 of this package, this information was not used
% unless a "\setlongtables" command was issued, however, now the
% information is always used, using a new algorithm\footnote{Due to
% David Kastrup.} and so "\setlongtables" is no longer needed. It is
% defined (but does nothing) for the benefit of old documents that
% use it.
%
% \begin{table}
% \centering
% \begin{tabular}{||l|l|l||}
% \hline\hline
% A&\env{tabular}& environment\\
% \hline
% within&a floating&\env{table}\\
% \hline\hline
% \end{tabular}
% \caption{A floating table}
% \end{table}
%
% \section{Captions and Headings}
%
% At the start of the table one may specify lines which are to appear at
% the top of every page (under the headline, but before the other lines
% of the table).
% \DescribeMacro{\endhead}
% The lines are entered as normal, but the last "\\" command is
% replaced by a "\endhead" command.
% \DescribeMacro{\endfirsthead}
% If the first page should have a different heading, then this should be
% entered in the same way, and terminated with the "\endfirsthead"
% command. The "LTchunksize" should be at least as large as the
% number of rows in the heading.
% \DescribeMacro{\endfoot}
% There are also "\endfoot" and "\endlastfoot"
%\DescribeMacro{\endlastfoot}
% commands which are used in the same way (at the \emph{start} of the
% table) to specify rows (or an "\hline") to appear at the bottom of
% each page. In certain situations, you may want to place lines which
% logically belong in the table body at the end of the \env{firsthead},
% or the beginning of the \env{lastfoot}. This helps to control which
% lines appear on the first and last page of the table.
%
% \DescribeMacro{\caption}%
% The "\caption{...}" command is essentially equivalent to\\
% "\multicolumn{n}{c}{\parbox{\LTcapwidth}{...}}"\\
% where \texttt{n} is the number of columns of the table. You may set
% the width of the caption with a command such as
% "\setlength{\LTcapwidth}{2in}"
% in the preamble of your document. The default is 4in. "\caption" also
% writes the information to produce an entry in the list of tables. As
% with the "\caption" command in the \env{figure} and \env{table}
% environments, an optional argument specifies the text to appear in the
% list of tables if this is different from the text to appear in the
% caption. Thus the caption for table \ref{long} was specified as
% {\ttfamily
% "\caption"[An optional table caption
% (used in the list of tables)]\v{A long
% table"\label{long}"\v}}.
%
% You may wish the caption on later pages to be different to that on the
% first page. In this case put the "\caption" command in the first
% heading, and put a subsidiary caption in a "\caption[]" command in
% the main heading. If the optional argument to "\caption" is empty,
% no entry is made in the list of tables. Alternatively, if you do not
% want the table number to be printed each time, use the "\caption*"
% command.
%
% The captions are set based on the code for the \package{article}
% class.
% If you have redefined the standard "\@makecaption" command to produce
% a different format for the captions, you may
% need to make similar changes to the \package{longtable} version,
% "\LT@makecaption". See the code section for more details.
%
% A more convenient method of customising captions is given by the
% \package{caption(2)} package, which provides commands for customising
% captions, and arranges that the captions in standard environments, and
% many environments provided by packages (including \package{longtable})
% are modified in a compatible manner.
%
% You may use the "\label" command so that you can cross reference
% \env{longtable}s with "\ref". Note however, that the "\label" command
% should not be used in a heading that may appear more than once. Place
% it either in the \env{firsthead}, or in the body of the table. It
% should not be the \emph{first} command in any entry.
%
% \section{Multicolumn entries}
%
% The "\multicolumn" command may be used in \env{longtable} in exactly
% the same way as for \env{tabular}. So you may want to skip this
% section, which is rather technical, however coping with "\multicolumn"
% is one of the main problems for an environment such as
% \env{longtable}. The main effect that a user will see is that
% certain combinations of "\multicolumn" entries will result in a
% document needing more runs of \LaTeX\ before the various `chunks' of
% a table align.
%
% The examples in this section are set with "LTchunksize" set to the
% minimum value of one, to demonstrate the effects when "\multicolumn"
% entries occur in different chunks.
%
% \begin{table}[!htp]
% \begin{center}
% \LTchunksize=1
% \makeatletter
%
% \global\let\LT@save@row\relax
% \let\LT@warn\@gobble
% \let\LT@final@warn\relax
%
% \newcommand\ltexample[1]{
% \stepcounter{LT@tables}
% \expandafter\let\csname LT@\romannumeral\c@LT@tables\endcsname
% \LT@save@row
% \addtocounter{LT@tables}{-1}
% \begin{longtable}{|c|c|c|}
% \caption{A difficult {\cs{multicolumn}} combination:
% pass #1\label{pass#1}}\\
% \hline
% 1&2&3\\
% \multicolumn{3}{|c|}{wide multicolumn spanning 1--3}\\
% \multicolumn{2}{|c|}{multicolumn 1--2}&3\\
% wide 1&2&3\\
% \hline
% \end{longtable}
% }
%
% \ltexample{1}
%
% \ltexample{2}
%
% \ltexample{3}
%
% \ltexample{4}
%
% \end{center}
% \end{table}
%
% Consider Table~\ref{pass1}.
% In the second chunk, \env{longtable} sees the wide
% multicolumn entry. At this point it thinks that the first two
% columns are very narrow. All
% the width of the multicolumn entry is assumed to be in the
% third column. (This is a `feature' of \TeX's primitive "\halign"
% command.) \env{longtable} then passes the information that there
% is a wide third column to the later chunks, with the result that the
% first pass over the table is too wide.
%
% If the `saved row' from this first pass was re-inserted into the
% table on the next pass, the table would line up in two passes, but
% would be much two wide.
%
% \DescribeMacro{\kill}%
% The solution to this problem used in Versions 1~and~2, was to use a
% "\kill" line. If a line is "\kill"ed, by using "\kill" rather than
% "\\" at the end of the line, it is used in calculating
% column widths, but removed from the final table. Thus entering
% "\kill"ed copies of the last two rows before the wide multicolumn
% entry would mean that "\halign" `saw' the wide entries in the first
% two columns, and so would not widen the third column by so much to
% make room for the multicolumn entry.
%
% In Version~3, a new solution was introduced. If the saved row in
% the ".aux" file was not being used, \env{longtable} used a special
% `draft' form of "\multicolumn", this modified the definition, so the
% spanning entry was never considered to be wider than the columns it
% spanned. So after the first pass, the ".aux" file stored the
% widest normal entry for each column, no column was widened due to
% "\span"ned columns. By default \env{longtable} ignored the ".aux"
% file, and so each run of \LaTeX\ was considered a first pass. Once the
% "\setlongtables" declaration was given, the saved row in the ".aux"
% file, and the proper definition of "\multicolumn" were used. If any
% "\multicolumn" entry caused one of the columns to be widened, this
% information could not be passed back to earlier chunks, and so the
% table would not correctly line up until the third pass. This algorithm
% always converged in three passes as described above, but in examples
% such as the ones in Tables \ref{pass1}--\ref{pass4}, the final
% widths were not optimal as the width of column~2, which is
% determined by a "\multicolumn" entry was not known when the final
% width for column~3 was fixed, due to the fact that \emph{both}
% "\multicolumn" commands were switched from `draft' mode to `normal'
% mode at the same time.
%
% Version~4 alleviates the problem considerably.
% The first pass of the table will
% indeed have the third column much too wide. However, on the next pass
% \env{longtable} will notice the error and reduce the column width
% accordingly. If this has to propagate to chunks before the
% "\multicolumn" one, an additional pass will, of course, be
% needed. It is possible to construct tables where this rippling up of
% the correct widths taks several passes to `converge' and produce a
% table with all chunks aligned. However in
% order to need many passes one needs to construct a table with
% many overlapping "\multicolumn" entries, all being wider than the
% natural widths of the columns they span, and all occuring in
% different chunks. In the typical case the algorithm will converge
% after three or four passes, and, the benefits of not needing to edit
% the document before the final run to add "\setlongtables", and the
% better choice of final column widths in the case of multiple
% "\multicolumn" entries will hopefully more than pay for the extra
% passes that may possibly be needed.
%
% So Table~\ref{pass1} converges after 4~passes, as seen in
% Table~\ref{pass4}.
%
% You can still speed the convergence by introducing judicious "\kill"
% lines, if you happen to have constellations like the above.
%
% If you object even to \LaTeX-ing a file twice, you should
% make the first line of
% every \env{longtable} a "\kill" line that contains the widest entry
% to be used in each column. All chunks will then line up on the first
% pass.
%
% \section{Adjustment}
%
% The optional argument of \env{longtable} controls the
% horizontal alignment of the table. The possible options are "[c]",
% "[r]" and "[l]", for centring,
% right and left adjustment, respectively.
% \DescribeMacro{\LTleft}
% Normally centring is the default, but this document specifies
% \DescribeMacro{\LTright}
%\begin{verbatim}
% \setlength\LTleft\parindent
% \setlength\LTright\fill
%\end{verbatim}
% in the preamble,
% which means that the tables are set flush left, but
% indented by the usual paragraph indentation. Any lengths can be
% specified for these two parameters, but at least one of them should be
% a rubber length so that it fills up the width of the page, unless
% rubber lengths are added between the columns using the
% "\extracolsep" command.
% For instance
%\begin{verbatim}
% \begin{tabular*}{\textwidth}{@{\extracolsep{...}}...}
%\end{verbatim}
% produces a full width table, to get a similar effect with
% \env{longtable} specify
%\begin{verbatim}
% \setlength\LTleft{0pt}
% \setlength\LTright{0pt}
% \begin{longtable}{@{\extracolsep{...}}...}
%\end{verbatim}
%
% \section{Changes}
%
% This section highlights the major changes since version~2. A more
% detailed change log may be produced at the end of the code listing
% if the "ltxdoc.cfg" file specifies
%\begin{verbatim}
% \AtBeginDocument{\RecordChanges}
% \AtEndDocument{\PrintChanges}
%\end{verbatim}
%
% Changes made between versions 2 and 3.
% \begin{itemize}
% \item The mechanism for adding the head and foot of the table has been
% completely rewritten. With this new mechanism, \env{longtable} does
% not need to issue a "\clearpage" at the start of the table, and so the
% table may start half way down a page. Also the "\endlastfoot" command
% which could not safely be implemented under the old scheme, has been
% added.
% \item \env{longtable} now issues an error if started in the scope of
% "\twocolumn", or the \env{multicols} environment.
% \item The separate documentation file "longtable.tex" has been
% merged with the package file, "longtable.dtx" using Mittelbach's
% \package{doc} package.
% \item Support for footnotes has been added. Note however that
% "\footnote" will not work in the `head' or `foot' sections of the
% table. In order to put a footnote in those sections (e.g., inside a
% caption), use "\footnotemark" at that point, and "\footnotetext"
% anywhere in the table \emph{body} that will fall on the same page.
% \item The treatment of "\multicolumn" has changed, making
% "\kill" lines unnecessary, at the price of sometimes requiring a
% third pass through \LaTeX.
% \item The "\newpage" command now works inside a \env{longtable}.
% \end{itemize}
%
% Changes made between versions 3 and 4.
% \begin{itemize}
% \item A new algorithm is used for aligning chunks. As well as the
% widest width in each column, \package{longtable} remembers which
% chunk produced this maximum. This allows it to check that the
% maximum is still achieved in later runs. As \package{longtable} can
% now deal with columns shrinking as the file is edited, the
% "\setlongtables" system is no longer needed and is disabled.
%
% \item An extra benefit of the new algorithm's ability to deal with
% `shrinking' columns is that it can give better (narrower) column
% widths in the case of overlapping "\multicolumn" entries in
% different chunks than the previous algorithm produced.
%
% \item The `draft' multicolumn system has been removed, along with
% related commands such as "\LTmulticolumn".
%
% \item The disadvantage of the new algorithm is that it can take more
% passes. The theoretical maximum is approximately twice the length
% of a `chain' of columns with overlapping "\multicolumn" entries,
% although in practice it usually converges as fast as the old
% version. (Which always converged in three passes once
% "\setlongtables" was activated.)
%
% \item "\\*" and "\nopagebreak" commands may be used to control page
% breaking.
%
% \end{itemize}
%
%
% \section{Summary}
%
% ^^A Allow the table to stick into the left margin.
% \setlength{\LTleft}{0pt plus 1fill minus 1fill}
% \setlength{\LTright}{0pt}
%
% \begin{longtable}{@{}l@{\hspace{10pt}}p{.8\linewidth}@{}}
% \caption[A summary of \env{longtable} commands]%
% {\normalsize A summary of \env{longtable} commands}\\
% \multicolumn{2}{c}{\textbf{Parameters}}\\*
% \hline
% "\LTleft"&
% Glue to the left of the table. \hfill("\fill")\\
% "\LTright"&
% Glue to the right of the table. \hfill("\fill")\\
% "\LTpre"&
% Glue before the the table. \hfill("\bigskipamount")\\
% "\LTpost"&
% Glue after the the table. \hfill("\bigskipamount")\\
% "\LTcapwidth"&
% The width of a parbox containing the caption.\hfill(4in)\\
% "LTchunksize"&
% The number of rows per chunk. \hfill(20)\\[5pt]
% \multicolumn{2}{c}{\textbf{Optional
% arguments to} \ttfamily\v\\begin\v{longtable\v}}\\*
% \hline
% \it none& Position as specified by "\LTleft" and "\LTright".\\
% "[c]"& Centre the table.\\
% "[l]"& Place the table flush left.\\
% "[r]"& Place the table flush right.\\[5pt]
% \pagebreak[2]
% \multicolumn{2}{c}{\textbf{Commands
% to end table rows}}\\*
% \hline
% "\\"&
% Specifies the end of a row\\
% "\\"\oarg{dim}& Ends row, then adds vertical space
% (as in the \env{tabular} environment).\\
% "\\*"&
% The same as "\\" but disallows a page break after the row.\\
% "\tabularnewline"&
% Alternative to "\\" for use in the scope of "\raggedright" and
% similar commands that redefine "\\".\\
% "\kill"&
% Row is `killed', but is used in calculating widths.\\
% "\endhead"&
% Specifies rows to appear at the top of every page.\\
% "\endfirsthead"&
% Specifies rows to appear at the top the first page.\\
% "\endfoot"&
% Specifies rows to appear at the bottom of every page.\\
% "\endlastfoot"&
% Specifies rows to appear at the bottom of the last page.\\[5pt]
% \multicolumn{2}{c}{\textbf{\env{longtable} caption commands}}\\*
% \hline
% "\caption"\marg{caption}&
% Caption `Table ?: \meta{caption}', and a `\meta{caption}'
% entry in the list of tables.\\
% "\caption"\oarg{lot}\marg{caption}&
% Caption `Table ?: \meta{caption}', and a `\meta{lot}'
% entry in the list of tables.\\
% "\caption[]"\marg{caption}&
% Caption `Table ?: \meta{caption}',
% but no entry in the list of tables.\\
% "\caption*"\marg{caption}&
% Caption `\meta{caption}', but no entry in the list of tables.\\[5pt]
% \multicolumn{2}{c}{%^^A
% \textbf{Commands available at the start of a row}}\\*
% \hline
% "\pagebreak"&
% Force a page break.\\*
% "\pagebreak"\oarg{val}& A `hint' between 0 and 4
% of the desirability of a break.\\
% "\nopagebreak"& Prohibit a page break.\\*
% "\nopagebreak"\oarg{val}& A `hint' between 0 and 4 of the undesirability
% of a break.\\
% "\newpage"&
% Force a page break.\\[5pt]
% \multicolumn{2}{c}{\textbf{Footnote commands
% available inside \env{longtable}}}\\*
% \hline
% "\footnote"&
% Footnotes, but may not be used in the table head \& foot.\\*
% "\footnotemark"&
% Footnotemark, may be used in the table head \& foot.\\*
% "\footnotetext"&
% Footnote text, use in the table body.\\[5pt]
% \multicolumn{2}{c}{\textbf{Setlongtables}}\\
% \hline
% "\setlongtables"& Obsolete command. Does nothing now.
% \end{longtable}
%
%
% \finalclearpage
% \section{Verbatim highlights from Table \protect\ref{long}}
% \label{listing}
% \begingroup\catcode`\/=0
% \begin{verbatim}
% \begin{longtable}{@{*}r||p{1in}@{*}}
% KILLED & LINE!!!! \kill
% \caption[An optional table caption /ldots]{A long table\label{long}}\\
% \hline\hline
% \multicolumn{2}{@{*}c@{*}}%
% {This part appears at the top of the table}\\
% \textsc{First}&\textsc{Second}\\
% \hline\hline
% \endfirsthead
% \caption[]{(continued)}\\
% \hline\hline
% \multicolumn{2}{@{*}c@{*}}%
% {This part appears at the top of every other page}\\
% \textbf{First}&\textbf{Second}\\
% \hline\hline
% \endhead
% \hline
% This goes at the&bottom.\\
% \hline
% \endfoot
% \hline
% These lines will&appear\\
% in place of the & usual foot\\
% at the end& of the table\\
% \hline
% \endlastfoot
% \env{longtable} columns are specified& in the \\
% same way as in the \env{tabular}& environment.\\
% /ldots
% \multicolumn{2}{||c||}{This is a /ldots}\\
% /ldots
% Some lines may take/ldots&
% \raggedleft This last column is a ``p'' column/ldots
% \tabularnewline
% /ldots
% Lots of lines& like this.\\
% /ldots
% \hline
% Lots\footnote{/ldots} of lines& like this.\\
% Lots of lines& like this\footnote{/ldots}\\
% \hline
% Lots of lines& like this.\\
% /ldots
% \end{longtable}
% \end{verbatim}
% \endgroup
%
% \StopEventually{}
%
% \finalclearpage
% \section{The Macros}
%
% \begin{macrocode}
%<*package>
% \end{macrocode}
%
% \subsection{Initial code}
%
% Before declaring the package options, we must define some defaults
% here.
%
% \begin{macro}{\LT@err}
% The error generating command
% \begin{macrocode}
\def\LT@err{\PackageError{longtable}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LT@warn}
% The warning generating command
% \begin{macrocode}
\def\LT@warn{\PackageWarning{longtable}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LT@final@warn}
% \changes{v4.04}{1996/05/24}
% {Macro added}
% If any \env{longtable}s have not aligned, generate a warning at the
% end of the run at "\AtEndDocument".
% \begin{macrocode}
\def\LT@final@warn{%
\AtEndDocument{%
\LT@warn{Table \@width s have changed. Rerun LaTeX.\@gobbletwo}}%
\global\let\LT@final@warn\relax}
% \end{macrocode}
% \end{macro}
%
% \subsection{Options}
%
% The first two options deal with error handling. They are compatible
% with the options used by the \texttt{tracefnt} package.
%
% \begin{macro}{errorshow}
% \emph{Only} show errors on the terminal. `warnings' are just sent to
% the log file.
% \changes{v3.14}{1995/04/25}
% {Change string from LT to longtable}
% \begin{macrocode}
\DeclareOption{errorshow}{%
\def\LT@warn{\PackageInfo{longtable}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{pausing}
% \changes{v3.14}{1995/04/25}
% {Change string from LT to longtable}
% \changes{v3.15}{1995/06/15}
% {Use single hash for latex/1557}
% Make every warning message into an error so \TeX\ stops.
% May be useful for debugging.
% \begin{macrocode}
\DeclareOption{pausing}{%
\def\LT@warn#1{%
\LT@err{#1}{This is not really an error}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{set}
% \begin{macro}{final}
% \changes{v4.01}{1996/04/11}
% {(DPC) make set and final options no op}
% The next options are just alternative syntax for the
% "\setlongtables" declaration.
% \begin{macrocode}
\DeclareOption{set}{}
\DeclareOption{final}{}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macrocode}
\ProcessOptions
% \end{macrocode}
%
% \subsection{User Setable Parameters}
%
% \begin{macro}{\LTleft}
% \begin{macro}{\LTright}
% Glue to the left and right of the table, default "\fill" (ie
% centred).
% \begin{macrocode}
\newskip\LTleft \LTleft=\fill
\newskip\LTright \LTright=\fill
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\LTpre}
% \begin{macro}{\LTpost}
% Glue before and after the \env{longtable}. "\bigskip" by default.
% \begin{macrocode}
\newskip\LTpre \LTpre=\bigskipamount
\newskip\LTpost \LTpost=\bigskipamount
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\LTchunksize}
% Chunk size (The number of rows taken per "\halign"). Default 20.
% \begin{macrocode}
\newcount\LTchunksize \LTchunksize=20
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\c@LTchunksize}
% Added in V3.07 to allow the \LaTeX\ syntax
% "\setcounter{LTchunksize}{10}".
% \begin{macrocode}
\let\c@LTchunksize\LTchunksize
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LTcapwidth}
% Width of the "\parbox" containing the caption. Default 4in.
% \begin{macrocode}
\newdimen\LTcapwidth \LTcapwidth=4in
% \end{macrocode}
% \end{macro}
%
% \subsection{Internal Parameters}
%
% \begin{macro}{\LT@head}
% \begin{macro}{\LT@firsthead}
% \begin{macro}{\LT@foot}
% \begin{macro}{\LT@lastfoot}
% Boxes for the table head and foot.
% \begin{macrocode}
\newbox\LT@head
\newbox\LT@firsthead
\newbox\LT@foot
\newbox\LT@lastfoot
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\LT@cols}
% Counter for number of columns.
% \begin{macrocode}
\newcount\LT@cols
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LT@rows}
% Counter for rows up to chunksize.
% \begin{macrocode}
\newcount\LT@rows
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\c@LT@tables}
% Counter for the tables, added in V3.02. Previous versions just used
% the \LaTeX\ counter "table", but this fails if "table" is
% reset during a document, eg \package{report} class resets it every
% chapter.
%
% This was changed from "\newcount\LT@tables" in V3.04. \LaTeX\ counters
% are preserved correctly when "\includeonly" is used. In the rest of
% the file "\LT@tables" has been replaced by "\c@LT@tables" without
% further comment.
% \begin{macrocode}
\newcounter{LT@tables}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\c@LT@chunks}
% \changes{v4.00}{1996/04/08}
% {(DK) Chunk counter added}
% We need to count through the chunks of our tables from Version~4 on.
% \begin{macrocode}
\newcounter{LT@chunks}[LT@tables]
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\c@table}
% \begin{macro}{\fnum@table}
% \begin{macro}{\tablename}
% If the "table" counter is not defined (eg in "letter" style), define
% it. (Added in V3.06.)
% \begin{macrocode}
\ifx\c@table\undefined
\newcounter{table}
\def\fnum@table{\tablename~\thetable}
\fi
\ifx\tablename\undefined
\def\tablename{Table}
\fi
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\LT@out}
% In a normal style, "longtable" uses the ".aux" file to record the
% column widths. With "letter.sty", use a separate ".lta" file.
% (Added in V3.06.)
%
% Not needed for new letter class.
%\begin{verbatim}
%\ifx\startlabels\undefined
% \let\@auxout\@auxout
%\else
% {\@input{\jobname.lta}}%
% \newwrite\@auxout
% \immediate\openout\@auxout=\jobname.lta
%\fi
%\end{verbatim}
% \end{macro}
%
% \begin{macro}{\LT@p@ftn}
% Temporary storage for footnote text in a `p' column.
% \begin{macrocode}
\newtoks\LT@p@ftn
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LT@end@pen}
% Special penalty for the end of the table. Done this way to save using
% up a count register.
% \begin{macrocode}
\mathchardef\LT@end@pen=30000
% \end{macrocode}
% \end{macro}
%
% \subsection{The \env{longtable} environment}
%
% \begin{macro}{\longtable}
% Called by "\begin{longtable}". This implementation does not work in
% multiple column formats. "\par" added at V3.04.
% \begin{macrocode}
\def\longtable{%
\par
\ifx\multicols\@undefined
\else
\ifnum\col@number>\@ne
\@twocolumntrue
\fi
\fi
\if@twocolumn
\LT@err{longtable not in 1-column mode}\@ehc
\fi
\begingroup
% \end{macrocode}
% Check for an optional argument.
% \begin{macrocode}
\@ifnextchar[\LT@array{\LT@array[x]}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LT@array}
% Start setting the alignment.
% Based on "\@array" from the \LaTeX\ kernel
% and the \package{array} package.
%
% Since Version 3.02, \package{longtable} has used the internal counter
% "\c@LT@tables". The \LaTeX\ counter "table" is still incremented
% so that "\caption" works correctly.
% \begin{macrocode}
\def\LT@array[#1]#2{%
\refstepcounter{table}\stepcounter{LT@tables}%
% \end{macrocode}
% Set up the glue around the table if an optional argument given.
% \begin{macrocode}
\if l#1%
\LTleft\z@ \LTright\fill
\else\if r#1%
\LTleft\fill \LTright\z@
\else\if c#1%
\LTleft\fill \LTright\fill
\fi\fi\fi
% \end{macrocode}
% Set up these internal commands for \env{longtable}.
% \changes{v3.13}{1994/12/08}
% {add \cs{tabularnewline}}
% \changes{v3.14}{1995/04/25}
% {(Mike Van Geest) rename \cs{LT@mc} to
% \cs{LT@mcol} to allow 1100 tables}
% \changes{v4.01}{1996/04/11}
% {(DPC) dont need multicolumn warning}
%\begin{verbatim}
% \global\let\LT@mcw@rn\relax
%\end{verbatim}
% \begin{macrocode}
\let\LT@mcol\multicolumn
% \end{macrocode}
% \changes{v3.17}{1996/01/31}
% {Reset \cs{hline} and \cs{multicolumn} in nested tabular
% and array, for tools/2068}
% Now redefine "\@tabarray" to restore "\hline" and "\multicolumn" so
% that arrays and tabulars nested in longtable (or in page headings on
% longtable pages) work out OK. Saving the original definitions done
% here so that you can load the \package{array} package before or after
% \package{longtable}.
% \begin{macrocode}
\let\LT@@tabarray\@tabarray
\let\LT@@hl\hline
\def\@tabarray{%
\let\hline\LT@@hl
% \end{macrocode}
%\begin{verbatim}
% \let\multicolumn\LT@mcol
%\end{verbatim}
% \begin{macrocode}
\LT@@tabarray}%
\let\\\LT@tabularcr\let\tabularnewline\\%
\def\newpage{\noalign{\break}}%
% \end{macrocode}
% \changes{v4.05}{1996/11/12}
% {\cs{nopagebreak} and \cs{pagebreak} added}
% More or less standard definitions, but first start a "\noalign".
% \begin{macrocode}
\def\pagebreak{\noalign{\ifnum`}=0\fi\@testopt{\LT@no@pgbk-}4}%
\def\nopagebreak{\noalign{\ifnum`}=0\fi\@testopt\LT@no@pgbk4}%
% \end{macrocode}
%
% \begin{macrocode}
\let\hline\LT@hline \let\kill\LT@kill\let\caption\LT@caption
\@tempdima\ht\strutbox
% \end{macrocode}
%
% \changes{v4.08}{1998/01/20}
% {Move \cs{@endpbox} definition earlier and define \cs{@@endpbox}
% and \cs{@@startpbox} for non-array case. tools/2736}
% \begin{macrocode}
\let\@endpbox\LT@endpbox
% \end{macrocode}
% Set up internal commands according to Lamport or Mittelbach.
% \begin{macrocode}
\ifx\extrarowheight\@undefined
% \end{macrocode}
% Initialise these commands as in \env{tabular} from the \LaTeX\ kernel.
% \begin{macrocode}
\let\@acol\@tabacol
\let\@classz\@tabclassz \let\@classiv\@tabclassiv
\def\@startpbox{\vtop\LT@startpbox}%
\let\@@startpbox\@startpbox
\let\@@endpbox\@endpbox
\let\LT@LL@FM@cr\@tabularcr
\else
% \end{macrocode}
% Initialise these commands as in \package{array}. "\d@llar"
% replaced by "\d@llarbegin" "\d@llarend" in V3.03 to match
% \package{array} V2.0h. We do not need to set "\d@llarbegin" and
% "\d@llarend" as the \package{array} package gives them the correct
% values at the top level.
% \begin{macrocode}
\advance\@tempdima\extrarowheight
\col@sep\tabcolsep
\let\@startpbox\LT@startpbox\let\LT@LL@FM@cr\@arraycr
\fi
% \end{macrocode}
% The rest of this macro is mainly based on \package{array} package, but
% should work for the standard \env{tabular} too.
% \begin{macrocode}
\setbox\@arstrutbox\hbox{\vrule
\@height \arraystretch \@tempdima
\@depth \arraystretch \dp \strutbox
\@width \z@}%
\let\@sharp##\let\protect\relax
% \end{macrocode}
% Interpret the preamble argument.
% \begin{macrocode}
\begingroup
\@mkpream{#2}%
% \end{macrocode}
% We need to rename "\@preamble" here as F.M.'s scheme uses
% "\global", and we may need to nest "\@mkpream", eg for
% "\multicolumn"
% or an \env{array}.
% We do not need to worry about nested \env{longtable}s though!
% \begin{macrocode}
\xdef\LT@bchunk{%
% \end{macrocode}
% \changes{v4.00}{1996/04/08}
% {(DK) Increment Chunk counter}
% \begin{macrocode}
\global\advance\c@LT@chunks\@ne
\global\LT@rows\z@\setbox\z@\vbox\bgroup
% \end{macrocode}
% \changes{v4.05}{1996/11/12}
% {\cs{LT@setprevdepth} added}
% The following line was added in v4.05.
% In order to get the "\penalties" to work at chunk boundaries
% Need to take more care about where and when "\lineskip" glue
% is added. The following does nothing at top of table, and in
% header chunks, but in normal body chunks it sets "\prevdepth"
% (to 0pt, but any value would do) so that "\lineskip" glue will
% be added. the important thing to note is that the glue will be
% added \emph{after} any vertical material coming from "\noalign".
% \begin{macrocode}
\LT@setprevdepth
% \end{macrocode}
%
% \changes{v4.10}{2000/10/22}
% {\cs{noexpand} added (as in array.sty) for mathtext.sty, CAR}
% \begin{macrocode}
\tabskip\LTleft \noexpand\halign to\hsize\bgroup
% \tabskip\LTleft\halign to\hsize\bgroup
\tabskip\z@ \@arstrut \@preamble \tabskip\LTright \cr}%
\endgroup
% \end{macrocode}
% Find out how many columns we have (store in "\LT@cols").
% \begin{macrocode}
\expandafter\LT@nofcols\LT@bchunk&\LT@nofcols
% \end{macrocode}
% Get the saved row from "\LT@i"\ldots"\LT@ix" (from the
% ".aux" file), or make a new blank row.
% \begin{macrocode}
\LT@make@row
% \end{macrocode}
% A few more internal commands for \env{longtable}.
% \begin{macrocode}
\m@th\let\par\@empty
\everycr{}\lineskip\z@\baselineskip\z@
% \end{macrocode}
% Start the first chunk.
% \begin{macrocode}
\LT@bchunk}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LT@no@pgbk}
% \changes{v4.05}{1996/11/12}
% {Macro added}
% Can simplify the standard "\@no@pgbk" as this is vmode only
% but then need to close the "\noalign".
% \begin{macrocode}
\def\LT@no@pgbk#1[#2]{\penalty #1\@getpen{#2}\ifnum`{=0\fi}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LT@start}
% This macro starts the process of putting the table on the current
% page. It is not called until either a "\\" or "\endlongtable" command
% ends a chunk, as we do not know until that point which of the four
% possible head or foot sections have been specified.
%
% It begins by redefining itself, so that the table is only started
% once! Until V3.04, was redefined to "\relax", now use "\endgraf" to
% force the page-breaker to wake up.
% \begin{macrocode}
\def\LT@start{%
\let\LT@start\endgraf
\endgraf\penalty\z@\vskip\LTpre
% \end{macrocode}
% Start a new page if there is not enough room for the table head, foot,
% and one extra line.
% \begin{macrocode}
\dimen@\pagetotal
\advance\dimen@ \ht\ifvoid\LT@firsthead\LT@head\else\LT@firsthead\fi
\advance\dimen@ \dp\ifvoid\LT@firsthead\LT@head\else\LT@firsthead\fi
\advance\dimen@ \ht\LT@foot
% \end{macrocode}
% \changes{v3.16}{1995/11/09}
% {Measure the first line of the table}
% At this point I used to add "\ht\@arstrutbox" and "\dp\@arstrutbox"
% as a measure of a row size. However this can fail spectacularly
% for "p" columns which might be much larger. Previous versions could
% end up with the table starting with a foot, then a page break then
% a head \emph{then} a `first head'! So now measure the first line of
% the table accurately by "\vsplit"ting it out of the first chunk.
% \begin{macrocode}
\dimen@ii\vfuzz
\vfuzz\maxdimen
\setbox\tw@\copy\z@
\setbox\tw@\vsplit\tw@ to \ht\@arstrutbox
\setbox\tw@\vbox{\unvbox\tw@}%
\vfuzz\dimen@ii
\advance\dimen@ \ht
\ifdim\ht\@arstrutbox>\ht\tw@\@arstrutbox\else\tw@\fi
\advance\dimen@\dp
\ifdim\dp\@arstrutbox>\dp\tw@\@arstrutbox\else\tw@\fi
% \end{macrocode}
%
% \begin{macrocode}
\advance\dimen@ -\pagegoal
\ifdim \dimen@>\z@\vfil\break\fi
% \end{macrocode}
% Store height of page minus table foot in "\@colroom".
% \changes{v3.14}{1995/05/02}
% {Set \cs{@colroom}, for tools/1584}
% \begin{macrocode}
\global\@colroom\@colht
% \end{macrocode}
% If the foot is non empty, reduce the "\vsize" and "\@colroom"
% accordingly.
% \begin{macrocode}
\ifvoid\LT@foot\else
\advance\vsize-\ht\LT@foot
\global\advance\@colroom-\ht\LT@foot
\dimen@\pagegoal\advance\dimen@-\ht\LT@foot\pagegoal\dimen@
\maxdepth\z@
\fi
% \end{macrocode}
% Put the table head on the page, and then switch to the new output
% routine.
% \changes{v4.11}{2004/02/01}
% {\cs{nobreak}, for tools/3484}
% \begin{macrocode}
\ifvoid\LT@firsthead\copy\LT@head\else\box\LT@firsthead\fi\nobreak
\output{\LT@output}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\endlongtable}
% Called by "\end{longtable}".
% \begin{macrocode}
\def\endlongtable{%
% \end{macrocode}
% Essentially add a final "\\". But as we now know the number of
% actual chunks, we first strip away all entries referring to a
% maximum entry beyond the table (this can only happen if a table has
% been shortened, or the table numbering has gone awry). In that case
% we at least start collecting valid new information with the last
% chunk of this table, by removing the width constraint.
% \changes{v4.01}{1996/04/11}
% {(DPC) use \cs{noalign} to sneak in \cs{LT@entry@chop}}
% \begin{macrocode}
\crcr
\noalign{%
\let\LT@entry\LT@entry@chop
\xdef\LT@save@row{\LT@save@row}}%
\LT@echunk
\LT@start
\unvbox\z@
\LT@get@widths
% \end{macrocode}
% Write the dummy row to the ".aux" file.
% Since V3.06, use ".lta" for "letter.sty".
% \changes{v3.12}{1994/06/30}
% {Do not write if \cs{nofiles} in operation.}
% \begin{macrocode}
\if@filesw
{\let\LT@entry\LT@entry@write\immediate\write\@auxout{%
% \end{macrocode}
% Since Version 3.02, \package{longtable} has used the internal counter
% "\c@LT@tables" rather than the \LaTeX\ counter \textsf{table}. This
% information looks entirely different from version~3
% information. Still, we don't need to rename the macro name because
% later code will consider the information to have no columns, and
% thus will throw the old data away.
% \begin{macrocode}
\gdef\expandafter\noexpand
\csname LT@\romannumeral\c@LT@tables\endcsname
{\LT@save@row}}}%
\fi
% \end{macrocode}
% At this point used to
% issue a warning if a "\multicolumn" has been set in draft mode.
% \changes{v4.01}{1996/04/11}
% {(DPC) No need for multicolumn warnings}
%\begin{verbatim}
% \LT@mcw@rn
%\end{verbatim}
% If the last chunk has different widths than the first, warn the user.
% Also trigger a warning to rerun \LaTeX\ at the end of the document.
% \changes{v4.04}{1996/05/24}
% {Use \cs{LT@final@warn}}
% \begin{macrocode}
\ifx\LT@save@row\LT@@save@row
\else
\LT@warn{Column \@width s have changed\MessageBreak
in table \thetable}%
\LT@final@warn
\fi
% \end{macrocode}
% Force one more go with the \env{longtable} output routine.
% \begin{macrocode}
\endgraf\penalty -\LT@end@pen
% \end{macrocode}
% Now close the group to return to the standard routine.
% \begin{macrocode}
\endgroup
% \end{macrocode}
% Reset "\@mparbottom" to allow marginpars close to the end of the
% table.\footnote{This can not be the correct. However if it is omitted,
% there is a problem with marginpars, for example on page~3 of this
% document. Any Output Routine Gurus out there?}
% \begin{macrocode}
\global\@mparbottom\z@
\pagegoal\vsize
\endgraf\penalty\z@\addvspace\LTpost
% \end{macrocode}
% Footnotes. As done in the \package{multicol} package.
% \begin{macrocode}
\ifvoid\footins\else\insert\footins{}\fi}
% \end{macrocode}
% \end{macro}
%
% \subsection{Counting Columns}
%
% Columns are counted by examining "\@preamble", rather than simply
% getting "\@mkpream" to increment the counter as it builds the
% preamble so that this package works with many of the packages which
% add extra column specifiers to \LaTeX's standard ones.
%
% Version~1 counted "\@sharp"'s to calculate the number of columns,
% this was changed for Version~2 as it does not work with the NFSS. Now
% count "&"'s. ("lfonts.new" (and now the Standard \LaTeX\ definition)
% defines "\@tabclassz" so that "\@sharp" is inside a group.)
%
% \begin{macro}{\LT@nofcols}
% Find the next "&", then look ahead to see what is next.
% \begin{macrocode}
\def\LT@nofcols#1&{%
\futurelet\@let@token\LT@n@fcols}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LT@n@fcols}
% Add one, then stop at an "\LT@nofcols" or look for the next
% "&". The "\expandafter" trick was added in Version~3, also the
% name changed from "\@LT@nofcols" to preserve the "\LT@" naming
% convention.
% \begin{macrocode}
\def\LT@n@fcols{%
\advance\LT@cols\@ne
\ifx\@let@token\LT@nofcols
\expandafter\@gobble
\else
\expandafter\LT@nofcols
\fi}
% \end{macrocode}
% \end{macro}
%
% \subsection{The {\ttfamily\bslash\bslash} and \cs{kill} Commands}
%
% \begin{macro}{\LT@tabularcr}
% \changes{v4.05}{1996/11/12}
% {Code re-organised for the *-form processing.}
% The internal definition of "\\".
% In the "*" form, insert a "\nobreak" after the next "\cr" (or "\crcr").
%
% This star form processing was finally added in v4.05. For the previous
% six or seven years the comment at this point said
% \begin{quote}\small
% This definition also accepts "\\*", which acts in the same way as
% "\\". \env{tabular} does this, but \env{longtable} probably ought to
% make "\\*" prevent page breaking.
% \end{quote}
%
% "{\ifnum0=`}\fi" added in version 3.01, required if the first entry
% is empty.
% The above in fact is not good enough, as with \package{array} package
% it can introduce a "{}" group in math mode, which changes the spacing.
% So use the following variant. Added in v3.14.
% \changes{v3.14}{1995/04/25}
% {More fun with \cs{ifnum} cf tools/1571}
% \begin{macrocode}
\def\LT@tabularcr{%
\relax\iffalse{\fi\ifnum0=`}\fi
\@ifstar
{\def\crcr{\LT@crcr\noalign{\nobreak}}\let\cr\crcr
\LT@t@bularcr}%
{\LT@t@bularcr}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LT@crcr}
% \changes{v4.05}{1996/11/12}
% {Macro added}
% \begin{macrocode}
\let\LT@crcr\crcr
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LT@setprevdepth}
% \changes{v4.05}{1996/11/12}
% {Macro added}
% This will be redefined to set the "\prevdepth"
% at the start of a chunk.
% \begin{macrocode}
\let\LT@setprevdepth\relax
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LT@t@bularcr}
% \begin{macrocode}
\def\LT@t@bularcr{%
% \end{macrocode}
% Increment the counter, and do \env{tabular}'s "\\" or finish the
% chunk.\\ The "\expandafter" trick was added in Version~3.
% Set the "\prevdepth" at the start of a new chunk. (Done here
% so not set in header chunks).
% \begin{macrocode}
\global\advance\LT@rows\@ne
\ifnum\LT@rows=\LTchunksize
\gdef\LT@setprevdepth{%
\prevdepth\z@\global
\global\let\LT@setprevdepth\relax}%
\expandafter\LT@xtabularcr
\else
\ifnum0=`{}\fi
\expandafter\LT@LL@FM@cr
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LT@xtabularcr}
% This justs looks for an optional argument.
% \begin{macrocode}
\def\LT@xtabularcr{%
\@ifnextchar[\LT@argtabularcr\LT@ntabularcr}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LT@ntabularcr}
% The version with no optional argument.
% "\ifnum0=`{\fi}" added in version 3.01. Changed in 3.14.
% \begin{macrocode}
\def\LT@ntabularcr{%
\ifnum0=`{}\fi
\LT@echunk
\LT@start
\unvbox\z@
\LT@get@widths
\LT@bchunk}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LT@argtabularcr}
% The version with an optional argument.
% "\ifnum0=`{\fi}" added in version 3.01. Changed in 3.14.
% \begin{macrocode}
\def\LT@argtabularcr[#1]{%
\ifnum0=`{}\fi
\ifdim #1>\z@
\unskip\@xargarraycr{#1}%
\else
\@yargarraycr{#1}%
\fi
% \end{macrocode}
% Add the dummy row, and finish the "\halign".
% \begin{macrocode}
\LT@echunk
\LT@start
\unvbox\z@
\LT@get@widths
\LT@bchunk}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LT@echunk}
% \changes{v4.05}{1996/11/12}
% {\cs{unskip} added for pagebreak support}
% This ends the current chunk, and removes the dummy row.
% \begin{macrocode}
\def\LT@echunk{%
\crcr\LT@save@row\cr\egroup
\global\setbox\@ne\lastbox
% \end{macrocode}
% The following line was added in v4.05.
% \package{longtable} relies on "\lineskip" glue (which is 0pt) to
% provide break points between each row so the table may be split
% into pages.
%
% Previous releases left the "\lineskip" glue at the end of each chunk
% that had been added when the dummy row was added. There was no glue
% at the start of the next chunk as \TeX\ normally dooes not put
% "\lineskip" glue at the top of a box. This meant that normally the
% chunks fitted together perfectly, however "\noalign" material at a
% chunk boundary came before the first row of the next chunk
% but after the lineskip glue at the end of this chunk. This is the
% wrong place, e.g., it means even a "\penalty10000" does not stop a
% break as the "\lineskip" glue in the previous item on the list
% provides a legal breakpoint. So now remove the "\lineskip" glue that
% was before the dummy row and introduce "\LT@setprevdepth" to set the
% "\prevdepth" at the start of the next chunk, to make sure "\lineskip"
% glue is added later.
% \begin{macrocode}
\unskip
\egroup}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LT@entry}
% \changes{v4.00}{1996/04/08}
% {(DK) Macro added}
% \changes{v4.01}{1996/04/11}
% {(DPC) Use \cs{ifhmode} trick to determine first entry}
% We here give the `basic' definition of "\LT@entry", namely that used
% in alignment templates. It has a "\kern" only if the maximum is
% imposed from a different chunk.
% The "\ifhmode" test reveals the first entry, when we don't want to add
% an "&".
% \begin{macrocode}
\def\LT@entry#1#2{%
\ifhmode\@firstofone{&}\fi\omit
\ifnum#1=\c@LT@chunks
\else
\kern#2\relax
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LT@entry@chop}
% \changes{v4.00}{1996/04/08}
% {(DK) Macro added}
% This definition for the argument of "\LT@save@row" is used to scrap
% all those maxima which could not be verified because they occur
% after the end of the table. This can happen only if a table has been
% shortened (or the sequencing got mixed up) since the
% previous run.
% Note that this is premature: the last chunk still is going to be
% set, and with the chopped limits.
% \begin{macrocode}
\def\LT@entry@chop#1#2{%
\noexpand\LT@entry
{\ifnum#1>\c@LT@chunks
1}{0pt%
\else
#1}{#2%
\fi}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LT@entry@write}
% \changes{v4.07}{1997/10/16}
% {Avoid use of percent. tools/2631}
% To write an entry for the "aux" file, we use a slightly
% surprising definition which has the sole purpose of avoiding
% overfull lines (which might break \TeX{}'s limits when reading the
% "aux" file, probably you'd need to have a few hundred columns before
% this happened but\ldots).
% \begin{macrocode}
\def\LT@entry@write{%
\noexpand\LT@entry^^J%
\@spaces}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LT@kill}
% This ends the current chunk as above, but strips off two rows, the
% `dummy row' and the `killed row' before starting the next chunk.
% Since V3.04, the old chunk is reboxed at the start of the box
% containing the next chunk. This allows "\kill" to be used in headers,
% which must be processed in a single box.
% \begin{macrocode}
\def\LT@kill{%
\LT@echunk
\LT@get@widths
\expandafter\LT@rebox\LT@bchunk}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LT@rebox}
% Drop the old chunk (box0) back at the top of the new chunk, removing
% the killed row. This macro added at V3.04.
% \begin{macrocode}
\def\LT@rebox#1\bgroup{%
#1\bgroup
\unvbox\z@
\unskip
\setbox\z@\lastbox}
% \end{macrocode}
% \end{macro}
%
% \subsection{The Dummy Row}
%
% The dummy row is kept inside of the macro "\LT@save@row".
%
% \begin{macro}{\LT@blank@row}
% \begin{macro}{\LT@build@blank}
% \changes{v4.00}{1996/04/08}
% {(DK) Macro added}
% \changes{v4.01}{1996/04/11}
% {(DPC) Dont mess with \cs{multicolumn} on draft passes}
% Create a blank row if we are not using the info in the ".aux" file.
% \begin{macrocode}
\def\LT@blank@row{%
\xdef\LT@save@row{\expandafter\LT@build@blank
\romannumeral\number\LT@cols 001 }}
% \end{macrocode}
% Whoops! What's that supposed to be? A drop-in replacement for the
% first task of Appendix~D in the \TeX book. The "\romannumeral"
% produces "\LT@cols" instances of "m" followed by "i". The below
% macro then replaces the "m"s by appropriate entries.
% \begin{macrocode}
\def\LT@build@blank#1{%
\if#1m%
\noexpand\LT@entry{1}{0pt}%
\expandafter\LT@build@blank
\fi}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\LT@make@row}
% \changes{v4.00}{1996/04/08}
% {(DK) New implementation}
% \changes{v4.01}{1996/04/11}
% {(DPC) Make this the default behaviour, not needing
% \cs{setlongtables}}
%
% Prior to version 4, by default did not use information in the
% ".aux" file but now we can define "\LT@make@row" to use the ".aux"
% file, even on the `draft' passes.
% \begin{macrocode}
\def\LT@make@row{%
\global\expandafter\let\expandafter\LT@save@row
\csname LT@\romannumeral\c@LT@tables\endcsname
\ifx\LT@save@row\relax
\LT@blank@row
% \end{macrocode}
% Now a slightly difficult part comes. Before we decide making the
% template from the ".aux" file info we check that the number of
% fields has remained the same. If it hasn't, either the table format
% has changed, or we have the wrong table altogether. In both cases,
% we decide to better drop all gathered information and start over.
% \changes{v4.01}{1996/04/11}
% {(DPC) Use \cs{if} test rather than \cs{ifx}\cs{@empty}}
%
% The expansion between "!"\ldots"!" below will be empty if the number
% of "\LT@entry" macros
% including arguments in "\LT@save@row" is equal to "\LT@cols". If it
% is not empty, we throw the row away and start from scratch.
% \begin{macrocode}
\else
{\let\LT@entry\or
\if!%
\ifcase\expandafter\expandafter\expandafter\LT@cols
\expandafter\@gobble\LT@save@row
\or
\else
\relax
\fi
!%
\else
\aftergroup\LT@blank@row
\fi}%
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\setlongtables}
% Redefine "\LT@make@row" to use information in the ".aux" file,
% if there is a saved row for this table with the right number of
% columns.
%
% Since Version 3.02, \package{longtable} has used the internal counter
% "\c@LT@tables" rather than the \LaTeX\ counter \textsf{table}.
% The warning message was added at V3.04, as was the "\global", to stop
% save-stack overflow.
%
% Since Version 4.01 "\setlongtables" does nothing as it is not
% needed, but is defined as "\relax" for the benefit of old documents.
% \changes{v3.12}{1994/06/30}
% {Warning altered to fit line on terminal.}
% \changes{v4.01}{1996/04/11}
% {(DPC) make into no op}
% \begin{macrocode}
\let\setlongtables\relax
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LT@get@widths}
% This is the heart of \package{longtable}. If it were not for the table
% head and foot, this macro together with the modified "\\" command
% would form the basis of quite a simple little package file for long
% tables. It is closely modelled on the "\endvrulealign" macro of
% appendix D of the \TeX book.
% \begin{macrocode}
\def\LT@get@widths{%
% \end{macrocode}
% "\global" added at V3.04, to stop save-stack overflow.
% \begin{macrocode}
% \end{macrocode}
% Loop through the last row, discarding glue, and saving box widths. At
% V3.04 changed the scratch box to 2, as the new "\kill" requires that
% "\box0" be preserved.
% \begin{macrocode}
\setbox\tw@\hbox{%
\unhbox\@ne
\let\LT@old@row\LT@save@row
\global\let\LT@save@row\@empty
\count@\LT@cols
\loop
\unskip
\setbox\tw@\lastbox
\ifhbox\tw@
\LT@def@row
\advance\count@\m@ne
\repeat}%
% \end{macrocode}
% Remember the widths if we are in the first chunk.
% \begin{macrocode}
\ifx\LT@@save@row\@undefined
\let\LT@@save@row\LT@save@row
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LT@def@row}
% \changes{v4.00}{1996/04/08}
% {(DK) New implementation}
% Add a column to the dummy row. Name changed from "\defLT@save@row"
% in Version~3, to preserve the "\LT@" naming convention.
% \begin{macrocode}
\def\LT@def@row{%
% \end{macrocode}
% We start by picking the respective entry from our old row.
% These redefinitions of "\LT@entry" are local to the group started
% in "\LT@get@widths".
% \begin{macrocode}
\let\LT@entry\or
\edef\@tempa{%
\ifcase\expandafter\count@\LT@old@row
\else
{1}{0pt}%
\fi}%
% \end{macrocode}
% Now we tack the right combination in front of "\LT@save@row":
% \begin{macrocode}
\let\LT@entry\relax
\xdef\LT@save@row{%
\LT@entry
\expandafter\LT@max@sel\@tempa
\LT@save@row}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LT@max@sel}
% \changes{v4.00}{1996/04/08}
% {(DK) macro added}
% \changes{v4.01}{1996/04/11}
% {(DPC) minor modifications}
% And this is how to select the right combination. Note that we take
% the old maximum information only if the size does not change in
% \emph{either} direction. If the size has grown, we of course have a
% new maximum. If the size has shrunk, the old maximum (which was
% explicitly not enforced because of being in the current chunk) is
% invalid, and we start with this chunk as the new size. Note that
% even in the case of equality we \emph{must} use the "\the\wd\tw@"
% construct instead of "#2" because "#2" might be read in from the
% file, and so could have "\catcode"~11 versions of "p" and~"t" in~it
% which we want to be replaced by their `proper' "\catcode"~12 versions.
% \begin{macrocode}
\def\LT@max@sel#1#2{%
{\ifdim#2=\wd\tw@
#1%
\else
\number\c@LT@chunks
\fi}%
{\the\wd\tw@}}
% \end{macrocode}
% \end{macro}
%
% \subsection{The \cs{hline} Command}
%
% \begin{macro}{\LT@hline}
% "\hline" and "\hline\hline" both produce \emph{two} lines.
% The only difference being the glue and penalties between them.
% This is so that a page break at a "\hline" produces a line on both
% pages.\footnote
% {\env{longtable} has always done this, but perhaps it would be
% better if hlines were \emph{omitted} at a page break, as the head and
% foot usually put a hline here anyway.}
% Also this "\hline" is more like a "\cline{1-\LT@cols}".
% \env{tabular}'s "\hline" would draw lines the full width of the page.
% \begin{macrocode}
\def\LT@hline{%
\noalign{\ifnum0=`}\fi
\penalty\@M
\futurelet\@let@token\LT@@hline}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LT@@hline}
% This code is based on "\cline". Two copies of the line are produced,
% as described above.
% \begin{macrocode}
\def\LT@@hline{%
\ifx\@let@token\hline
\global\let\@gtempa\@gobble
\gdef\LT@sep{\penalty-\@medpenalty\vskip\doublerulesep}%
\else
\global\let\@gtempa\@empty
\gdef\LT@sep{\penalty-\@lowpenalty\vskip-\arrayrulewidth}%
\fi
\ifnum0=`{\fi}%
\multispan\LT@cols
\unskip\leaders\hrule\@height\arrayrulewidth\hfill\cr
\noalign{\LT@sep}%
\multispan\LT@cols
\unskip\leaders\hrule\@height\arrayrulewidth\hfill\cr
\noalign{\penalty\@M}%
\@gtempa}
% \end{macrocode}
% \end{macro}
%
% \subsection{Captions}
%
% \begin{macro}{\LT@caption}
% The caption is "\multicolumn{\LT@cols}{c}{"\meta{a parbox with the
% table's caption}"}"
% \begin{macrocode}
\def\LT@caption{%
\noalign\bgroup
\@ifnextchar[{\egroup\LT@c@ption\@firstofone}\LT@capti@n}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LT@c@ption}
% Caption command (with [optional argument]). "\protect" added in
% Version~3. "\fnum@table" added at V3.05.
% \changes{v3.14}{1995/05/02}
% {Call \cs{LT@makecaption} not \cs{LT@mkcaption}}
% \changes{v3.14}{1995/05/24}
% {Add new control argument}
% \begin{macrocode}
\def\LT@c@ption#1[#2]#3{%
\LT@makecaption#1\fnum@table{#3}%
\def\@tempa{#2}%
\ifx\@tempa\@empty\else
{\let\\\space
\addcontentsline{lot}{table}{\protect\numberline{\thetable}{#2}}}%
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LT@capti@n}
% Caption command (no [optional argument])
% \changes{v3.14}{1995/05/02}
% {Call \cs{LT@makecaptionx} not \cs{LT@mkcaption}}
% \changes{v3.14}{1995/05/24}
% {Call \cs{LT@makecaption} with \cs{@gobble} or \cs{@firstofone}}
% \begin{macrocode}
\def\LT@capti@n{%
\@ifstar
{\egroup\LT@c@ption\@gobble[]}%
{\egroup\@xdblarg{\LT@c@ption\@firstofone}}}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\LT@makecaption}
% Put the caption in a box of width 0pt, so that it never affects the
% column widths. Inside that is a "\parbox" of width
% "\LTcapwidth".
% \changes{v3.14}{1995/05/02}
% {Renamed from \cs{LT@mkcaption},
% and modified to call \cs{@makecaption}}
% \changes{v3.14}{1995/05/02}
% {Use the first arg to remove counter for star form}
% \begin{macrocode}
\def\LT@makecaption#1#2#3{%
\LT@mcol\LT@cols c{\hbox to\z@{\hss\parbox[t]\LTcapwidth{%
% \end{macrocode}
% Based on article class "\@makecaption", "#1" is "\@gobble" in star
% form, and "\@firstofone" otherwise.
% \begin{macrocode}
\sbox\@tempboxa{#1{#2: }#3}%
\ifdim\wd\@tempboxa>\hsize
#1{#2: }#3%
\else
\hbox to\hsize{\hfil\box\@tempboxa\hfil}%
\fi
\endgraf\vskip\baselineskip}%
\hss}}}
% \end{macrocode}
% \end{macro}
%
%
% \subsection{The Output Routine}
%
% The method used here for interfacing a special purpose output routine
% to the standard \LaTeX\ routine is lifted straight out of
% F.~Mittelbach's \package{multicol} package.
%
% \begin{macro}{\LT@output}
% Actually this is not so bad, with FM leading the way.
% \begin{macrocode}
\def\LT@output{%
\ifnum\outputpenalty <-\@Mi
\ifnum\outputpenalty > -\LT@end@pen
% \end{macrocode}
% If this was a float or a marginpar we complain.
% \begin{macrocode}
\LT@err{floats and marginpars not allowed in a longtable}\@ehc
\else
% \end{macrocode}
% We have reached the end of the table, on the scroll at least,
% \begin{macrocode}
\setbox\z@\vbox{\unvbox\@cclv}%
\ifdim \ht\LT@lastfoot>\ht\LT@foot
% \end{macrocode}
% The last foot might not fit, so:\footnote{An alternative would be to
% vsplit off a bit of the last chunk, so that the last page did not just
% have head and foot sections, but it is hard to do this in a consistent
% manner.}
% \begin{macrocode}
\dimen@\pagegoal
\advance\dimen@-\ht\LT@lastfoot
\ifdim\dimen@<\ht\z@
\setbox\@cclv\vbox{\unvbox\z@\copy\LT@foot\vss}%
\@makecol
\@outputpage
\setbox\z@\vbox{\box\LT@head}%
% \end{macrocode}
% End of "\ifdim\dimen@<\ht\@cclc".
% \begin{macrocode}
\fi
% \end{macrocode}
% End of "\ifdim \ht\LT@lastfoot > \ht\LT@foot".
% \begin{macrocode}
\fi
% \end{macrocode}
% Reset "\@colroom".
% \changes{v3.14}{1995/05/02}
% {Reset \cs{@colroom}, for tools/1584}
% \begin{macrocode}
\global\@colroom\@colht
\global\vsize\@colht
% \end{macrocode}
% Put the last page of the table on to the main vertical list.
% \begin{macrocode}
\vbox
{\unvbox\z@\box\ifvoid\LT@lastfoot\LT@foot\else\LT@lastfoot\fi}%
% \end{macrocode}
% End of "\ifnum\outputpenalty > -\LT@end@pen".
% \begin{macrocode}
\fi
% \end{macrocode}
% Else "\outputpenalty > -\@Mi".
% \begin{macrocode}
\else
% \end{macrocode}
% If we have not reached the end of the table,
% \begin{macrocode}
\setbox\@cclv\vbox{\unvbox\@cclv\copy\LT@foot\vss}%
\@makecol
\@outputpage
% \end{macrocode}
% Reset "\vsize".
% \changes{v3.14}{1995/05/02}
% {Reset \cs{vsize}, for tools/1584}
% \begin{macrocode}
\global\vsize\@colroom
% \end{macrocode}
% Put the head at the top of the next page.
% \changes{v4.11}{2004/02/01}
% {\cs{nobreak}, for tools/3484}
% \begin{macrocode}
\copy\LT@head\nobreak
% \end{macrocode}
% End of "\ifnum\outputpenalty <-\@Mi".
% \begin{macrocode}
\fi}
% \end{macrocode}
% \end{macro}
%
% \subsection{Commands for the the table head and foot}
%
% \begin{macro}{\LT@end@hd@ft}
% The core of "\endhead" and friends. Store the current chunk in the
% box specified by "#1". Issue an error if the table has already
% started. Then start a new chunk.
% \begin{macrocode}
\def\LT@end@hd@ft#1{%
\LT@echunk
% \end{macrocode}
% Changed from "\relax" to "\endgraf" at V3.04, see "\LT@start".
% \begin{macrocode}
\ifx\LT@start\endgraf
\LT@err
{Longtable head or foot not at start of table}%
{Increase LTchunksize}%
\fi
\setbox#1\box\z@
\LT@get@widths
\LT@bchunk}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\endfirsthead}
% \begin{macro}{\endhead}
% \begin{macro}{\endfoot}
% \begin{macro}{\endlastfoot}
% Call "\LT@end@hd@ft" with the appropriate box.
% \begin{macrocode}
\def\endfirsthead{\LT@end@hd@ft\LT@firsthead}
\def\endhead{\LT@end@hd@ft\LT@head}
\def\endfoot{\LT@end@hd@ft\LT@foot}
\def\endlastfoot{\LT@end@hd@ft\LT@lastfoot}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsection{The \cs{multicolumn} command}
%
% Earlier versions needed a special `draft' form of "\multicolumn".
% This is not needed in version~4, and so these commands have been
% removed.
%
% \begin{macro}{\LTmulticolumn}
% \changes{v4.01}{1996/04/11}
% {(DPC) macro removed}
% \end{macro}
%
% \begin{macro}{\LT@mcwarn}
% \changes{v4.01}{1996/04/11}
% {(DPC) macro removed}
% \end{macro}
%
% \subsection{Footnotes}
%
% The standard "\footnote" command works in a "c" column, but we
% need to modify the definition in a "p" column to overcome the
% extra level of boxing. These macros are based on the \package{array}
% package, but should be OK for the standard \env{tabular}.
%
% \begin{macro}{\LT@startpbox}
% \changes{v4.09}{1998/05/13}
% {Use \cs{setlength}, so that calc extensions apply. tools/2793}
% Add extra code to switch the definition of "\@footnotetext".
% \begin{macrocode}
\def\LT@startpbox#1{%
\bgroup
\let\@footnotetext\LT@p@ftntext
\setlength\hsize{#1}%
\@arrayparboxrestore
\vrule \@height \ht\@arstrutbox \@width \z@}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LT@endpbox}
% After the parbox is closed, expand "\LT@p@ftn" which will execute a
% series of\\
% "\footnotetext["\meta{num}"]{"\meta{note}"}"\\
% commands. After being lifted out of the parbox, they can migrate on
% their own from here.
% \changes{v3.10}{1994/05/15}
% {Use \cs{@finalstrut}}
% \changes{v4.03}{1996/05/07}
% {Use \cs{hfil} for tools/2120}
% \begin{macrocode}
\def\LT@endpbox{%
\@finalstrut\@arstrutbox
\egroup
\the\LT@p@ftn
\global\LT@p@ftn{}%
\hfil}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LT@p@ftntext}
% Inside the `p' column, just save up the footnote text in a token
% register.
% \begin{macrocode}
\def\LT@p@ftntext#1{%
\edef\@tempa{\the\LT@p@ftn\noexpand\footnotetext[\the\c@footnote]}%
\global\LT@p@ftn\expandafter{\@tempa{#1}}}%
% \end{macrocode}
% \end{macro}
%
% \begin{macrocode}
%</package>
% \end{macrocode}
%
% \Finale
\endinput
|