1%% This is file `longtable-patched.sty'.
2%%
3%% It is the file `longtable.sty' (from the Standard LaTeX `Tools Bundle')
4%% with a patch from
5%%
6%%   https://www.latex-project.org/cgi-bin/ltxbugs2html?pr=tools/3512
7%%
8%% to fix a serious layout issue with floats.  This is a legal modification
9%% based on the LPPL license since the file name has been changed.
10%%
11%% The original source code file `longtable.dtx' can be found at
12%%
13%%   https://ctan.org/pkg/longtable
14%%
15%%
16%% For reference, here the original copyright notice.
17%%
18%% This is file `longtable.sty',
19%% generated with the docstrip utility.
20%%
21%%
22%% The original source files were:
23%%
24%% longtable.dtx  (with options: `package')
25%%
26%% This is a generated file.
27%%
28%% Copyright 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005
29%% 2006 2008 2009
30%% The LaTeX3 Project and any individual authors listed elsewhere
31%% in this file.
32%%
33%% This file was generated from file(s) of the Standard LaTeX `Tools Bundle'.
34%% --------------------------------------------------------------------------
35%%
36%% It may be distributed and/or modified under the
37%% conditions of the LaTeX Project Public License, either version 1.3c
38%% of this license or (at your option) any later version.
39%% The latest version of this license is in
40%%    http://www.latex-project.org/lppl.txt
41%% and version 1.3c or later is part of all distributions of LaTeX
42%% version 2005/12/01 or later.
43%%
44%% This file may only be distributed together with a copy of the LaTeX
45%% `Tools Bundle'. You may however distribute the LaTeX `Tools Bundle'
46%% without such generated files.
47%%
48%% The list of all files belonging to the LaTeX `Tools Bundle' is
49%% given in the file `manifest.txt'.
50%%
51%% File: longtable.dtx Copyright (C) 1990-2001 David Carlisle
52\NeedsTeXFormat{LaTeX2e}[1995/06/01]
53\ProvidesPackage{longtable-patched}
54          [2014/01/29 v4.11-patched Multi-page Table package (DPC)]
55\def\LT@err{\PackageError{longtable-patched}}
56\def\LT@warn{\PackageWarning{longtable-patched}}
57\def\LT@final@warn{%
58  \AtEndDocument{%
59    \LT@warn{Table \@width s have changed. Rerun LaTeX.\@gobbletwo}}%
60  \global\let\LT@final@warn\relax}
61\DeclareOption{errorshow}{%
62  \def\LT@warn{\PackageInfo{longtable-patched}}}
63\DeclareOption{pausing}{%
64  \def\LT@warn#1{%
65    \LT@err{#1}{This is not really an error}}}
66\DeclareOption{set}{}
67\DeclareOption{final}{}
68\ProcessOptions
69\newskip\LTleft       \LTleft=\fill
70\newskip\LTright      \LTright=\fill
71\newskip\LTpre        \LTpre=\bigskipamount
72\newskip\LTpost       \LTpost=\bigskipamount
73\newcount\LTchunksize \LTchunksize=20
74\let\c@LTchunksize\LTchunksize
75\newdimen\LTcapwidth  \LTcapwidth=4in
76\newbox\LT@head
77\newbox\LT@firsthead
78\newbox\LT@foot
79\newbox\LT@lastfoot
80\newcount\LT@cols
81\newcount\LT@rows
82\newcounter{LT@tables}
83\newcounter{LT@chunks}[LT@tables]
84\ifx\c@table\undefined
85  \newcounter{table}
86  \def\fnum@table{\tablename~\thetable}
87\fi
88\ifx\tablename\undefined
89  \def\tablename{Table}
90\fi
91\newtoks\LT@p@ftn
92\mathchardef\LT@end@pen=30000
93\def\longtable{%
94  \par
95  \ifx\multicols\@undefined
96  \else
97     \ifnum\col@number>\@ne
98       \@twocolumntrue
99     \fi
100  \fi
101  \if@twocolumn
102    \LT@err{longtable not in 1-column mode}\@ehc
103  \fi
104  \begingroup
105  \@ifnextchar[\LT@array{\LT@array[x]}}
106\def\LT@array[#1]#2{%
107  \refstepcounter{table}\stepcounter{LT@tables}%
108  \if l#1%
109    \LTleft\z@ \LTright\fill
110  \else\if r#1%
111    \LTleft\fill \LTright\z@
112  \else\if c#1%
113    \LTleft\fill \LTright\fill
114  \fi\fi\fi
115  \let\LT@mcol\multicolumn
116  \let\LT@@tabarray\@tabarray
117  \let\LT@@hl\hline
118  \def\@tabarray{%
119    \let\hline\LT@@hl
120    \LT@@tabarray}%
121  \let\\\LT@tabularcr\let\tabularnewline\\%
122  \def\newpage{\noalign{\break}}%
123  \def\pagebreak{\noalign{\ifnum`}=0\fi\@testopt{\LT@no@pgbk-}4}%
124  \def\nopagebreak{\noalign{\ifnum`}=0\fi\@testopt\LT@no@pgbk4}%
125  \let\hline\LT@hline \let\kill\LT@kill\let\caption\LT@caption
126  \@tempdima\ht\strutbox
127  \let\@endpbox\LT@endpbox
128  \ifx\extrarowheight\@undefined
129    \let\@acol\@tabacol
130    \let\@classz\@tabclassz \let\@classiv\@tabclassiv
131    \def\@startpbox{\vtop\LT@startpbox}%
132    \let\@@startpbox\@startpbox
133    \let\@@endpbox\@endpbox
134    \let\LT@LL@FM@cr\@tabularcr
135  \else
136    \advance\@tempdima\extrarowheight
137    \col@sep\tabcolsep
138    \let\@startpbox\LT@startpbox\let\LT@LL@FM@cr\@arraycr
139  \fi
140  \setbox\@arstrutbox\hbox{\vrule
141    \@height \arraystretch \@tempdima
142    \@depth \arraystretch \dp \strutbox
143    \@width \z@}%
144  \let\@sharp##\let\protect\relax
145   \begingroup
146    \@mkpream{#2}%
147    \xdef\LT@bchunk{%
148       \global\advance\c@LT@chunks\@ne
149       \global\LT@rows\z@\setbox\z@\vbox\bgroup
150       \LT@setprevdepth
151       \tabskip\LTleft \noexpand\halign to\hsize\bgroup
152      \tabskip\z@ \@arstrut \@preamble \tabskip\LTright \cr}%
153  \endgroup
154  \expandafter\LT@nofcols\LT@bchunk&\LT@nofcols
155  \LT@make@row
156  \m@th\let\par\@empty
157  \everycr{}\lineskip\z@\baselineskip\z@
158  \LT@bchunk}
159\def\LT@no@pgbk#1[#2]{\penalty #1\@getpen{#2}\ifnum`{=0\fi}}
160\def\LT@start{%
161  \let\LT@start\endgraf
162  \endgraf\penalty\z@\vskip\LTpre
163  \dimen@\pagetotal
164  \advance\dimen@ \ht\ifvoid\LT@firsthead\LT@head\else\LT@firsthead\fi
165  \advance\dimen@ \dp\ifvoid\LT@firsthead\LT@head\else\LT@firsthead\fi
166  \advance\dimen@ \ht\LT@foot
167  \dimen@ii\vfuzz
168  \vfuzz\maxdimen
169    \setbox\tw@\copy\z@
170    \setbox\tw@\vsplit\tw@ to \ht\@arstrutbox
171    \setbox\tw@\vbox{\unvbox\tw@}%
172  \vfuzz\dimen@ii
173  \advance\dimen@ \ht
174        \ifdim\ht\@arstrutbox>\ht\tw@\@arstrutbox\else\tw@\fi
175  \advance\dimen@\dp
176        \ifdim\dp\@arstrutbox>\dp\tw@\@arstrutbox\else\tw@\fi
177  \advance\dimen@ -\pagegoal
178  \ifdim \dimen@>\z@\vfil\break\fi
179      \global\@colroom\@colht
180  \ifvoid\LT@foot\else
181    \global\advance\vsize-\ht\LT@foot
182    \global\advance\@colroom-\ht\LT@foot
183    \dimen@\pagegoal\advance\dimen@-\ht\LT@foot\pagegoal\dimen@
184    \maxdepth\z@
185  \fi
186  \ifvoid\LT@firsthead\copy\LT@head\else\box\LT@firsthead\fi\nobreak
187  \output{\LT@output}}
188\def\endlongtable{%
189  \crcr
190  \noalign{%
191    \let\LT@entry\LT@entry@chop
192    \xdef\LT@save@row{\LT@save@row}}%
193  \LT@echunk
194  \LT@start
195  \unvbox\z@
196  \LT@get@widths
197  \if@filesw
198    {\let\LT@entry\LT@entry@write\immediate\write\@auxout{%
199      \gdef\expandafter\noexpand
200        \csname LT@\romannumeral\c@LT@tables\endcsname
201          {\LT@save@row}}}%
202  \fi
203  \ifx\LT@save@row\LT@@save@row
204  \else
205    \LT@warn{Column \@width s have changed\MessageBreak
206             in table \thetable}%
207    \LT@final@warn
208  \fi
209  \endgraf\penalty -\LT@end@pen
210  \ifvoid\LT@foot\else
211    \global\advance\vsize\ht\LT@foot
212    \global\advance\@colroom\ht\LT@foot
213    \dimen@\pagegoal\advance\dimen@\ht\LT@foot\pagegoal\dimen@
214  \fi
215  \endgroup
216  \global\@mparbottom\z@
217  \endgraf\penalty\z@\addvspace\LTpost
218  \ifvoid\footins\else\insert\footins{}\fi}
219\def\LT@nofcols#1&{%
220  \futurelet\@let@token\LT@n@fcols}
221\def\LT@n@fcols{%
222  \advance\LT@cols\@ne
223  \ifx\@let@token\LT@nofcols
224    \expandafter\@gobble
225  \else
226    \expandafter\LT@nofcols
227  \fi}
228\def\LT@tabularcr{%
229  \relax\iffalse{\fi\ifnum0=`}\fi
230  \@ifstar
231    {\def\crcr{\LT@crcr\noalign{\nobreak}}\let\cr\crcr
232     \LT@t@bularcr}%
233    {\LT@t@bularcr}}
234\let\LT@crcr\crcr
235\let\LT@setprevdepth\relax
236\def\LT@t@bularcr{%
237  \global\advance\LT@rows\@ne
238  \ifnum\LT@rows=\LTchunksize
239    \gdef\LT@setprevdepth{%
240      \prevdepth\z@\global
241      \global\let\LT@setprevdepth\relax}%
242    \expandafter\LT@xtabularcr
243  \else
244    \ifnum0=`{}\fi
245    \expandafter\LT@LL@FM@cr
246  \fi}
247\def\LT@xtabularcr{%
248  \@ifnextchar[\LT@argtabularcr\LT@ntabularcr}
249\def\LT@ntabularcr{%
250  \ifnum0=`{}\fi
251  \LT@echunk
252  \LT@start
253  \unvbox\z@
254  \LT@get@widths
255  \LT@bchunk}
256\def\LT@argtabularcr[#1]{%
257  \ifnum0=`{}\fi
258  \ifdim #1>\z@
259    \unskip\@xargarraycr{#1}%
260  \else
261    \@yargarraycr{#1}%
262  \fi
263  \LT@echunk
264  \LT@start
265  \unvbox\z@
266  \LT@get@widths
267  \LT@bchunk}
268\def\LT@echunk{%
269  \crcr\LT@save@row\cr\egroup
270  \global\setbox\@ne\lastbox
271    \unskip
272  \egroup}
273\def\LT@entry#1#2{%
274  \ifhmode\@firstofone{&}\fi\omit
275  \ifnum#1=\c@LT@chunks
276  \else
277    \kern#2\relax
278  \fi}
279\def\LT@entry@chop#1#2{%
280  \noexpand\LT@entry
281    {\ifnum#1>\c@LT@chunks
282       1}{0pt%
283     \else
284       #1}{#2%
285     \fi}}
286\def\LT@entry@write{%
287  \noexpand\LT@entry^^J%
288  \@spaces}
289\def\LT@kill{%
290  \LT@echunk
291  \LT@get@widths
292  \expandafter\LT@rebox\LT@bchunk}
293\def\LT@rebox#1\bgroup{%
294  #1\bgroup
295  \unvbox\z@
296  \unskip
297  \setbox\z@\lastbox}
298\def\LT@blank@row{%
299  \xdef\LT@save@row{\expandafter\LT@build@blank
300    \romannumeral\number\LT@cols 001 }}
301\def\LT@build@blank#1{%
302  \if#1m%
303    \noexpand\LT@entry{1}{0pt}%
304    \expandafter\LT@build@blank
305  \fi}
306\def\LT@make@row{%
307  \global\expandafter\let\expandafter\LT@save@row
308    \csname LT@\romannumeral\c@LT@tables\endcsname
309  \ifx\LT@save@row\relax
310    \LT@blank@row
311  \else
312    {\let\LT@entry\or
313     \if!%
314         \ifcase\expandafter\expandafter\expandafter\LT@cols
315         \expandafter\@gobble\LT@save@row
316         \or
317         \else
318           \relax
319         \fi
320        !%
321     \else
322       \aftergroup\LT@blank@row
323     \fi}%
324  \fi}
325\let\setlongtables\relax
326\def\LT@get@widths{%
327  \setbox\tw@\hbox{%
328    \unhbox\@ne
329    \let\LT@old@row\LT@save@row
330    \global\let\LT@save@row\@empty
331    \count@\LT@cols
332    \loop
333      \unskip
334      \setbox\tw@\lastbox
335    \ifhbox\tw@
336      \LT@def@row
337      \advance\count@\m@ne
338    \repeat}%
339  \ifx\LT@@save@row\@undefined
340    \let\LT@@save@row\LT@save@row
341  \fi}
342\def\LT@def@row{%
343  \let\LT@entry\or
344  \edef\@tempa{%
345    \ifcase\expandafter\count@\LT@old@row
346    \else
347      {1}{0pt}%
348    \fi}%
349  \let\LT@entry\relax
350  \xdef\LT@save@row{%
351    \LT@entry
352    \expandafter\LT@max@sel\@tempa
353    \LT@save@row}}
354\def\LT@max@sel#1#2{%
355  {\ifdim#2=\wd\tw@
356     #1%
357   \else
358     \number\c@LT@chunks
359   \fi}%
360  {\the\wd\tw@}}
361\def\LT@hline{%
362  \noalign{\ifnum0=`}\fi
363    \penalty\@M
364    \futurelet\@let@token\LT@@hline}
365\def\LT@@hline{%
366  \ifx\@let@token\hline
367    \global\let\@gtempa\@gobble
368    \gdef\LT@sep{\penalty-\@medpenalty\vskip\doublerulesep}%
369  \else
370    \global\let\@gtempa\@empty
371    \gdef\LT@sep{\penalty-\@lowpenalty\vskip-\arrayrulewidth}%
372  \fi
373  \ifnum0=`{\fi}%
374  \multispan\LT@cols
375     \unskip\leaders\hrule\@height\arrayrulewidth\hfill\cr
376  \noalign{\LT@sep}%
377  \multispan\LT@cols
378     \unskip\leaders\hrule\@height\arrayrulewidth\hfill\cr
379  \noalign{\penalty\@M}%
380  \@gtempa}
381\def\LT@caption{%
382  \noalign\bgroup
383    \@ifnextchar[{\egroup\LT@c@ption\@firstofone}\LT@capti@n}
384\def\LT@c@ption#1[#2]#3{%
385  \LT@makecaption#1\fnum@table{#3}%
386  \def\@tempa{#2}%
387  \ifx\@tempa\@empty\else
388     {\let\\\space
389     \addcontentsline{lot}{table}{\protect\numberline{\thetable}{#2}}}%
390  \fi}
391\def\LT@capti@n{%
392  \@ifstar
393    {\egroup\LT@c@ption\@gobble[]}%
394    {\egroup\@xdblarg{\LT@c@ption\@firstofone}}}
395\def\LT@makecaption#1#2#3{%
396  \LT@mcol\LT@cols c{\hbox to\z@{\hss\parbox[t]\LTcapwidth{%
397    \sbox\@tempboxa{#1{#2: }#3}%
398    \ifdim\wd\@tempboxa>\hsize
399      #1{#2: }#3%
400    \else
401      \hbox to\hsize{\hfil\box\@tempboxa\hfil}%
402    \fi
403    \endgraf\vskip\baselineskip}%
404  \hss}}}
405\def\LT@output{%
406  \ifnum\outputpenalty <-\@Mi
407    \ifnum\outputpenalty > -\LT@end@pen
408      \LT@err{floats and marginpars not allowed in a longtable}\@ehc
409    \else
410      \setbox\z@\vbox{\unvbox\@cclv}%
411      \ifdim \ht\LT@lastfoot>\ht\LT@foot
412        \dimen@\pagegoal
413        \advance\dimen@\ht\LT@foot
414        \advance\dimen@-\ht\LT@lastfoot
415        \ifdim\dimen@<\ht\z@
416          \setbox\@cclv\vbox{\unvbox\z@\copy\LT@foot\vss}%
417          \@makecol
418          \@outputpage
419            \global\vsize\@colroom
420          \setbox\z@\vbox{\box\LT@head}%
421        \fi
422      \fi
423      \unvbox\z@\ifvoid\LT@lastfoot\copy\LT@foot\else\box\LT@lastfoot\fi
424    \fi
425  \else
426    \setbox\@cclv\vbox{\unvbox\@cclv\copy\LT@foot\vss}%
427    \@makecol
428    \@outputpage
429      \global\vsize\@colroom
430    \copy\LT@head\nobreak
431  \fi}
432\def\LT@end@hd@ft#1{%
433  \LT@echunk
434  \ifx\LT@start\endgraf
435    \LT@err
436     {Longtable head or foot not at start of table}%
437     {Increase LTchunksize}%
438  \fi
439  \setbox#1\box\z@
440  \LT@get@widths
441  \LT@bchunk}
442\def\endfirsthead{\LT@end@hd@ft\LT@firsthead}
443\def\endhead{\LT@end@hd@ft\LT@head}
444\def\endfoot{\LT@end@hd@ft\LT@foot}
445\def\endlastfoot{\LT@end@hd@ft\LT@lastfoot}
446\def\LT@startpbox#1{%
447  \bgroup
448    \let\@footnotetext\LT@p@ftntext
449    \setlength\hsize{#1}%
450    \@arrayparboxrestore
451    \vrule \@height \ht\@arstrutbox \@width \z@}
452\def\LT@endpbox{%
453  \@finalstrut\@arstrutbox
454  \egroup
455  \the\LT@p@ftn
456  \global\LT@p@ftn{}%
457  \hfil}
458\def\LT@p@ftntext#1{%
459  \edef\@tempa{\the\LT@p@ftn\noexpand\footnotetext[\the\c@footnote]}%
460  \global\LT@p@ftn\expandafter{\@tempa{#1}}}%
461\endinput
462%%
463%% End of file `longtable-patched.sty'.
464