summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/longfigure/longfigure.dtx
blob: 60d4b1dae0b5dedf5e60ee44661ade535c7ccf8a (plain)
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
% \iffalse meta-comment
%<*internal>
\iffalse
%</internal>
%<*readme>
----------------------------------------------------------------
longfigure --- A LaTeX package providing a table-like environment
               that can display a stream of subfigures as a single
               figure that can be broken by \TeX's
               standard page-breaking algorithm.

               Nearly identical to David Carlisle's |longtable| package,
               but with some obvious changes to use figures instead of
               tables. All credit goes to David Carlisle; this package
               represents small changes to his code and logic.
               I am responsible for the changes.

E-mail: tim.arnold@sas.com
Released under the LaTeX Project Public License v1.3c or later
See http://www.latex-project.org/lppl.txt
----------------------------------------------------------------

This work consists of the file longfigure.dtx
and the derived files:
   README (this file)
   longfigure.ins
   longfigure.pdf
   longfigure.sty
%</readme>
%<*internal>
\fi
\def\nameofplainTeX{plain}
\ifx\fmtname\nameofplainTeX\else
  \expandafter\begingroup
\fi
%</internal>
%<*install>
\input docstrip.tex
\keepsilent
\askforoverwritefalse
\preamble
----------------------------------------------------------------
longfigure --- A LaTeX package providing a table-like environment
               that can display a stream of subfigures as a single
               figure that can be broken by \TeX's
               standard page-breaking algorithm.

E-mail: tim.arnold@sas.com
----------------------------------------------------------------
\endpreamble
\postamble
Copyright (C) 2014 by SAS Institute Inc. <tim.arnold@sas.com>

This work may be distributed and/or modified under the
conditions of the LaTeX Project Public License (LPPL), either
version 1.3c of this license or any later version.
The latest version of this license is in the file:
http://www.latex-project.org/lppl.txt

This work is "maintained" (as per LPPL maintenance status) by
Tim Arnold.

This work consists of the file longfigure.dtx
and the derived files:
   README (this file)
   longfigure.ins
   longfigure.pdf
   longfigure.sty
\endpostamble
\generate{\file{longfigure.sty}{\from{longfigure.dtx}{longfigure}}}
%</install>
%<install>\endbatchfile
%<*internal>
\generate{\file{longfigure.ins}{\from{longfigure.dtx}{install}}}
\nopreamble\nopostamble
\generate{\file{README}{\from{longfigure.dtx}{readme}}}
\ifx\fmtname\nameofplainTeX
  \expandafter\endbatchfile
\else
  \expandafter\endgroup
\fi
%</internal>
%<*longfigure>
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{longfigure}[2014/1/06 v1.0]
%</longfigure>
%<*driver>
\documentclass{ltxdoc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{\jobname}
\usepackage[numbered]{hypdoc}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\begin{document}
  \DocInput{\jobname.dtx}
\end{document}
%</driver>
% \fi
%\GetFileInfo{\jobname.sty}
% \def\fileversion{v1.0}
%
%\title{^^A
%  The \textsf{longfigure} Package\thanks{^^A
%    This file describes version \fileversion, last revised \filedate.^^A
%  }^^A
%}
%\author{^^A
%  Tim Arnold\thanks{E-mail: tim.arnold@sas.com}^^A
%}
%\date{Released \filedate}
%
%\maketitle
%
%\changes{v1.0}{2014/1/06}{First public release}
%    \section{Usage}
%    \label{longfigure}
%    \index{longfigure package|usage}
%
%    The |longfigure| package uses and relabels components of the
%    well-known |longtable| package, written by David Carlisle, to
%    provide a table-like environment that can display a stream
%    of subfigures as a single figure that can break across pages.
%
%    The |longtable| package defines a |longtable| environment,
%    which produces tables that can be broken by \TeX's standard page-breaking algorithm.
%    Similarly, the |longfigure| package defines a |longfigure| environment, which produces
%    figures that can be broken by \TeX's standard page-breaking algorithm.
%    The internal structure of a long figure is similar to a long table.
%    Rows might contain (for example) tables or graphics. Page breaks
%    can occur only between rows.
%
%     The |longfigure| package differs from the |longtable| package in the following ways:
%    \begin{itemize}
%      \item The |longfigure| package supports two additional key-value options:
%      \begin{itemize}
%        \item The |figname=| option specifies the counter for numbering |longfigure| environments.
%              You can specify any string; the default is |figure|.
%              When you specify a |figname=| value for which no counter already exists, the
%              |longfigure| package loads the |tocloft| package and creates the counter.
%              \index{figname option|usage}
%
%       \item The |resetby=| option specifies a counter (for example, |resetby=chapter|) such
%             that output numbering is reset each time the counter value changes.
%             If a counter is specified that does not exist, the |tocloft| package is
%             loaded to create the new counter.
%             \index{tocloft package|usage}%
%             For information about how the lists are typeset,
%             \index{list of outputs, creating|usage}%
%             see the |tocloft| package documentation.
%      \end{itemize}
%      \item The counters and macros that start with \cs{LT} in the |longtable| package
%            are renamed to start with \cs{LF} in the |longfigure| pacakge to avoid
%            namespace conflicts when the two packages are used together.
%            The generic macros that are defined in the |longtable| package
%            (\cs{endfirsthead}, \cs{endhead}, \cs{endfoot}, and \cs{endlastfoot}) are
%            also renamed with \cs{LF} as a prefix in the |longfigure| package.
%
%      \item The \cs{LF@name} macro is based on the \cs{fnum@table} macro from
%            the |longtable| package. The  \cs{LF@name} macro returns the capitalized
%            counter name and value. For example, if the counter is |figure| and the
%            macro is processing the second |longfigure|, the \cs{LF@name} macro
%            would contain the value ``Figure 2.''
%
%  \end{itemize}
%    You can use the |longfigure| package defaults to produce a \emph{List of Figures}
%    by inserting the following tag in your document at the point where you want
%    the list to appear:
% \iffalse
%<*example>
% \fi
\begin{verbatim}
   \listoffigures
\end{verbatim}
% \iffalse
%</example>
% \fi
%
%    The default counter used to display figures is the |figure| counter,
%    but you can specify a different counter. For example, if you want your
%    figures to be labeled as ``Display,'' specify |figname=display| when you
%    load the |longfigure| package; to display a \emph{List of Displays}, insert the following
%    command in your document at the point where you want the list to appear:
% \iffalse
%<*example>
% \fi
\begin{verbatim}
   \listofdisplay
\end{verbatim}
% \iffalse
%</example>
% \fi
%    \textbf{Note:}  If you specify a counter that does not exist,
%    an auxiliary file with extension |.lft| is created to contain the information
%    needed to create the list.
%
%    If you want to use more advanced features of the |tocloft| package,
%    load it before you load the |longfigure| package so that the |longfigure|
%    package sees that the counters specified by the |figname=| and |resetby=|
%    options are already defined and does not attempt to create them.
%
%
%\subsection{Example}
% The following lines produce a single figure that contains three images and
% one tabular environment. Each element is a row of the |longfigure| environment.
% Page breaks can occur between rows.
%
%\begin{verbatim}
%\documentclass{book}
%\usepackage{graphicx}
%\usepackage{longfigure}
%
%\begin{document}
%  \begin{longfigure}{c}
%    \caption{My Long Figure}\label{mlfig}\\
%    \includegraphics[width=3in]{myfig1}\\
%    \includegraphics[width=3in]{myfig2}\\
%    \includegraphics[width=3in]{myfig3}\\
%    \begin{tabular}{ll}
%      one & two \\
%      three & four\\
%    \end{tabular}
%  \end{longfigure}
%\end{document}
%\end{verbatim}
%
%  In this example, the |{c}| argument in the |\begin{longfigure}| command
%  specifies only a single centered column. You can also specify multiple columns and,
%  if needed, use the \cs{multicolumn} command for more flexibility.
%
% The following lines display another example that specifies a 'continued' heading
% when the figure breaks over a page. It also displays a double horizontal line at the
% end of the figure.
%\begin{verbatim}
%\documentclass{book}
%\usepackage{graphicx}
%\usepackage{longfigure}
%
%\begin{document}
%  \begin{longfigure}{c}
%    \caption{My Long Figure}\label{mlfig2}\\
%    \hline\endLFfirsthead
%    \caption{continued}\\
%    \hline\endLFhead
%    \hline\endLFfoot
%    \hline\hline\endLFlastfoot
%    \includegraphics[width=3in]{myfig1}\\
%    \includegraphics[width=3in]{myfig2}\\
%    \includegraphics[width=3in]{myfig3}\\
%    \begin{tabular}{ll}
%      one & two \\
%      three & four\\
%    \end{tabular}
%  \end{longfigure}
%\end{document}
%\end{verbatim}
%
%    \section{Implementation}
%
%    This section describes the implementation of the |longfigure| package.
%    The comments describe only the changes from the |longtable| package code.
%    For complete details about the logic and usage of the |longtable| environment,
%    see Carlisle (2004).
%\iffalse
%<*longfigure>
%\fi
%    \begin{macrocode}
\ProvidesPackage{longfigure}[2014/01/06 longfigure]
%    \end{macrocode}
%    The following statement loads the |xkeyval| package for declaring
%    and processing package options:
%    \begin{macrocode}
\RequirePackage{xkeyval}
%    \end{macrocode}
%    The following statement defines a new command, \cs{LFcounter}, to
%    contain the string |figure|.
%    Later code tests whether a counter with that name exists.
%    \begin{macrocode}
\newcommand*{\LFcounter}{figure}
%    \end{macrocode}
%
%    The following statement defines a new command, \cs{LFreset}, to contain
%    the name of the counter within which the |longfigure| number should reset.
%    If no value is specified, the long figures are numbered consecutively
%    through the document.
%    \begin{macrocode}
\newcommand*{\LFreset}{\@empty}
%    \end{macrocode}
% \subsection{Options}
%    The \cs{LFcounter} and \cs{LFreset} commands support the
%    package options |figname=| and |resetby=| as follows:
%    \begin{macrocode}
\DeclareOptionX{figname}[figure]{\renewcommand*{\LFcounter}{#1}}
\DeclareOptionX{resetby}{\renewcommand*{\LFreset}{#1}}
%    \end{macrocode}
%    The following statements further define the options
%    that the |longtable| package defines:
%    \begin{macrocode}
\DeclareOptionX{set}{}
\DeclareOptionX{final}{}
\DeclareOptionX{errorshow}{\def\LF@warn{\PackageInfo{longfigure}}}
\DeclareOptionX{pausing}{\def\LF@warn#1{\LF@err{#1}{This is not really an error}}}
\ProcessOptionsX
%    \end{macrocode}
%    The following statements process the options:
%    \begin{macrocode}
\def\LFProcessOptions#1{
  \@ifundefined{c@#1}{%
      \RequirePackage{tocloft}
      \def\LFuc##1##2{\MakeUppercase{##1}{##2}}
      \expandafter\def\csname list#1name\endcsname{List of \LFuc#1s}
      \ifx\@empty\LFreset%
        \newlistof{#1}{lft}{\csname list#1name\endcsname}
      \else
        \newlistof[\LFreset]{#1}{lft}{\csname list#1name\endcsname}
      \fi
  }{}%
}
\expandafter\LFProcessOptions\expandafter{\LFcounter}
%    \end{macrocode}
%    If a counter is specified that does not exist, its name (\cs{c@}\textit{countername})
%    is undefined and the |longfigure| package loads the |tocloft| package in order to
%    use its commands to create the new counters and list.
%
%    Thus, the |tocloft| package is required only when a new counter
%    is specified,
%    \index{tocloft package|usage}%
%    and this automatic loading takes place only if the counter that is  specified
%    in the package options is not defined.
%
%    You can load the |tocloft| package before loading the |longfigure| package
%    and retain all of the flexibility that the |tocloft| package offers.
%    However, you must define the new counters yourself by using the
%    \cs{newlistof} command in the |tocloft| package,
%    and you must define the new list to use an auxiliary |lft| file where
%    its auxiliary information is written.
%    \index{tocloft package|usage}%
%
% \subsection{Utilities}
% \DescribeMacro{\strcfstr}
%  The following macro, \cs{strcfstr}, checks whether two strings, which are
%  provided as arguments, are equal (Wilson, 2001).
%  A new boolean \cs{ifLF@same} contains the result of the test.
%    \begin{macrocode}
\newif\ifLF@same
\newcommand{\strcfstr}[2]{%
  \LF@samefalse
  \begingroup\def\2{#2}
    \ifx\2#1\endgroup\LF@sametrue
    \else\endgroup
    \fi
}
%    \end{macrocode}
%  \DescribeMacro{\LFupcase}
%    The following macro, \cs{LFupcase}, uppercases the first letter of
%    a string (Lazarides, 2010):
%    \begin{macrocode}
\def\LFupcase#1{%
  \def\x##1##2{%
    \MakeUppercase{##1}{##2}}\x#1%
}
%    \end{macrocode}
%    The following macro, \cs{LF@name}, creates a string to provide a label and number for
%    an output. Analogous to the \cs{fnum@table} macro in the |longtable| package,
%    it contains the capitalized version of the counter name and the counter
%    number (for example, |Figure~3|).
%    \begin{macrocode}
\def\LF@name{\expandafter\LFupcase%
             \expandafter{\LFcounter}~%
             \expandafter\csname the\LFcounter\endcsname}%
%    \end{macrocode}
%    The remainder of this package follows the |longtable| package
%    almost identically, except that macros, skips, counters, and so on
%    use an \cs{LF} prefix instead of the \cs{LT} prefix that the |longtable| package uses.
%
%    \begin{macrocode}
\def\LF@err{\PackageError{longfigure}}
\def\LF@warn{\PackageWarning{longfigure}}
\def\LF@final@warn{%
  \AtEndDocument{%
    \LF@warn{\LFcounter \@width s have changed. Rerun \LaTeX\.\@gobbletwo}}%
  \global\let\LF@final@warn\relax}
%
\newskip\LFleft       \LFleft=\fill
\newskip\LFright      \LFright=\fill
\newskip\LFpre        \LFpre=\bigskipamount
\newskip\LFpost       \LFpost=\bigskipamount
\newcount\LFchunksize \LFchunksize=20
\let\c@LFchunksize\LFchunksize
\newdimen\LFcapwidth  \LFcapwidth=4in
\newbox\LF@head
\newbox\LF@firsthead
\newbox\LF@foot
\newbox\LF@lastfoot
\newcount\LF@cols
\newcount\LF@rows
\newcounter{LF@tables}
\newcounter{LF@chunks}[LF@tables]
%
\newtoks\LF@p@ftn
\mathchardef\LF@end@pen=30000
\def\longfigure{%
  \par
  \ifx\multicols\@undefined
  \else
     \ifnum\col@number>\@ne
       \@twocolumntrue
     \fi
  \fi
  \if@twocolumn
    \LF@err{longfigure not in 1-column mode}\@ehc
  \fi
  \begingroup
  \@ifnextchar[\LF@array{\LF@array[x]}}
\def\LF@array[#1]#2{%
  \refstepcounter{\LFcounter}\stepcounter{LF@tables}%
  \if l#1%
    \LFleft\z@ \LFright\fill
  \else\if r#1%
    \LFleft\fill \LFright\z@
  \else\if c#1%
    \LFleft\fill \LFright\fill
  \fi\fi\fi
  \let\LF@mcol\multicolumn
  \let\LF@@tabarray\@tabarray
  \let\LF@@hl\hline
  \def\@tabarray{%
    \let\hline\LF@@hl
    \LF@@tabarray}%
  \let\\\LF@tabularcr\let\tabularnewline\\%
  \def\newpage{\noalign{\break}}%
  \def\pagebreak{\noalign{\ifnum`}=0\fi\@testopt{\LF@no@pgbk-}4}%
  \def\nopagebreak{\noalign{\ifnum`}=0\fi\@testopt\LF@no@pgbk4}%
  \let\hline\LF@hline \let\kill\LF@kill\let\caption\LF@caption
  \@tempdima\ht\strutbox
  \let\@endpbox\LF@endpbox
  \ifx\extrarowheight\@undefined
    \let\@acol\@tabacol
    \let\@classz\@tabclassz \let\@classiv\@tabclassiv
    \def\@startpbox{\vtop\LF@startpbox}%
    \let\@@startpbox\@startpbox
    \let\@@endpbox\@endpbox
    \let\LF@LL@FM@cr\@tabularcr
  \else
    \advance\@tempdima\extrarowheight
    \col@sep\tabcolsep
    \let\@startpbox\LF@startpbox\let\LF@LL@FM@cr\@arraycr
  \fi
  \setbox\@arstrutbox\hbox{\vrule
    \@height \arraystretch \@tempdima
    \@depth \arraystretch \dp \strutbox
    \@width \z@}%
  \let\@sharp##\let\protect\relax
   \begingroup
    \@mkpream{#2}%
    \xdef\LF@bchunk{%
       \global\advance\c@LF@chunks\@ne
       \global\LF@rows\z@\setbox\z@\vbox\bgroup
       \LF@setprevdepth
       \tabskip\LFleft \noexpand\halign to\hsize\bgroup
      \tabskip\z@ \@arstrut \@preamble \tabskip\LFright \cr}%
  \endgroup
  \expandafter\LF@nofcols\LF@bchunk&\LF@nofcols
  \LF@make@row
  \m@th\let\par\@empty
  \everycr{}\lineskip\z@\baselineskip\z@
  \LF@bchunk}
\def\LF@no@pgbk#1[#2]{\penalty #1\@getpen{#2}\ifnum`{=0\fi}}
\def\LF@start{%
  \let\LF@start\endgraf
  \endgraf\penalty\z@\vskip\LFpre
  \dimen@\pagetotal
  \advance\dimen@ \ht\ifvoid\LF@firsthead\LF@head\else\LF@firsthead\fi
  \advance\dimen@ \dp\ifvoid\LF@firsthead\LF@head\else\LF@firsthead\fi
  \advance\dimen@ \ht\LF@foot
  \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
  \advance\dimen@ -\pagegoal
  \ifdim \dimen@>\z@\vfil\break\fi
      \global\@colroom\@colht
  \ifvoid\LF@foot\else
    \advance\vsize-\ht\LF@foot
    \global\advance\@colroom-\ht\LF@foot
    \dimen@\pagegoal\advance\dimen@-\ht\LF@foot\pagegoal\dimen@
    \maxdepth\z@
  \fi
  \ifvoid\LF@firsthead\copy\LF@head\else\box\LF@firsthead\fi\nobreak
  \output{\LF@output}}
\def\endlongfigure{%
  \crcr
  \noalign{%
    \let\LF@entry\LF@entry@chop
    \xdef\LF@save@row{\LF@save@row}}%
  \LF@echunk
  \LF@start
  \unvbox\z@
  \LF@get@widths
  \if@filesw
    {\let\LF@entry\LF@entry@write\immediate\write\@auxout{%
      \gdef\expandafter\noexpand
        \csname LF@\romannumeral\c@LF@tables\endcsname
          {\LF@save@row}}}%
  \fi
  \ifx\LF@save@row\LF@@save@row
  \else
    \LF@warn{Column \@width s have changed\MessageBreak
             in table \thetable}%
    \LF@final@warn
  \fi
  \endgraf\penalty -\LF@end@pen
  \endgroup
  \global\@mparbottom\z@
  \pagegoal\vsize
  \endgraf\penalty\z@\addvspace\LFpost
  \ifvoid\footins\else\insert\footins{}\fi}
\def\LF@nofcols#1&{%
  \futurelet\@let@token\LF@n@fcols}
\def\LF@n@fcols{%
  \advance\LF@cols\@ne
  \ifx\@let@token\LF@nofcols
    \expandafter\@gobble
  \else
    \expandafter\LF@nofcols
  \fi}
\def\LF@tabularcr{%
  \relax\iffalse{\fi\ifnum0=`}\fi
  \@ifstar
    {\def\crcr{\LF@crcr\noalign{\nobreak}}\let\cr\crcr
     \LF@t@bularcr}%
    {\LF@t@bularcr}}
\let\LF@crcr\crcr
\let\LF@setprevdepth\relax
\def\LF@t@bularcr{%
  \global\advance\LF@rows\@ne
  \ifnum\LF@rows=\LFchunksize
    \gdef\LF@setprevdepth{%
      \prevdepth\z@\global
      \global\let\LF@setprevdepth\relax}%
    \expandafter\LF@xtabularcr
  \else
    \ifnum0=`{}\fi
    \expandafter\LF@LL@FM@cr
  \fi}
\def\LF@xtabularcr{%
  \@ifnextchar[\LF@argtabularcr\LF@ntabularcr}
\def\LF@ntabularcr{%
  \ifnum0=`{}\fi
  \LF@echunk
  \LF@start
  \unvbox\z@
  \LF@get@widths
  \LF@bchunk}
\def\LF@argtabularcr[#1]{%
  \ifnum0=`{}\fi
  \ifdim #1>\z@
    \unskip\@xargarraycr{#1}%
  \else
    \@yargarraycr{#1}%
  \fi
  \LF@echunk
  \LF@start
  \unvbox\z@
  \LF@get@widths
  \LF@bchunk}
\def\LF@echunk{%
  \crcr\LF@save@row\cr\egroup
  \global\setbox\@ne\lastbox
    \unskip
  \egroup}
\def\LF@entry#1#2{%
  \ifhmode\@firstofone{&}\fi\omit
  \ifnum#1=\c@LF@chunks
  \else
    \kern#2\relax
  \fi}
\def\LF@entry@chop#1#2{%
  \noexpand\LF@entry
    {\ifnum#1>\c@LF@chunks
       1}{0pt%
     \else
       #1}{#2%
     \fi}}
\def\LF@entry@write{%
  \noexpand\LF@entry^^J%
  \@spaces}
\def\LF@kill{%
  \LF@echunk
  \LF@get@widths
  \expandafter\LF@rebox\LF@bchunk}
\def\LF@rebox#1\bgroup{%
  #1\bgroup
  \unvbox\z@
  \unskip
  \setbox\z@\lastbox}
\def\LF@blank@row{%
  \xdef\LF@save@row{\expandafter\LF@build@blank
    \romannumeral\number\LF@cols 001 }}
\def\LF@build@blank#1{%
  \if#1m%
    \noexpand\LF@entry{1}{0pt}%
    \expandafter\LF@build@blank
  \fi}
\def\LF@make@row{%
  \global\expandafter\let\expandafter\LF@save@row
    \csname LF@\romannumeral\c@LF@tables\endcsname
  \ifx\LF@save@row\relax
    \LF@blank@row
  \else
    {\let\LF@entry\or
     \if!%
         \ifcase\expandafter\expandafter\expandafter\LF@cols
         \expandafter\@gobble\LF@save@row
         \or
         \else
           \relax
         \fi
        !%
     \else
       \aftergroup\LF@blank@row
     \fi}%
  \fi}
\let\setlongfigures\relax
\def\LF@get@widths{%
  \setbox\tw@\hbox{%
    \unhbox\@ne
    \let\LF@old@row\LF@save@row
    \global\let\LF@save@row\@empty
    \count@\LF@cols
    \loop
      \unskip
      \setbox\tw@\lastbox
    \ifhbox\tw@
      \LF@def@row
      \advance\count@\m@ne
    \repeat}%
  \ifx\LF@@save@row\@undefined
    \let\LF@@save@row\LF@save@row
  \fi}
\def\LF@def@row{%
  \let\LF@entry\or
  \edef\@tempa{%
    \ifcase\expandafter\count@\LF@old@row
    \else
      {1}{0pt}%
    \fi}%
  \let\LF@entry\relax
  \xdef\LF@save@row{%
    \LF@entry
    \expandafter\LF@max@sel\@tempa
    \LF@save@row}}
\def\LF@max@sel#1#2{%
  {\ifdim#2=\wd\tw@
     #1%
   \else
     \number\c@LF@chunks
   \fi}%
  {\the\wd\tw@}}
\def\LF@hline{%
  \noalign{\ifnum0=`}\fi
    \penalty\@M
    \futurelet\@let@token\LF@@hline}
\def\LF@@hline{%
  \ifx\@let@token\hline
    \global\let\@gtempa\@gobble
    \gdef\LF@sep{\penalty-\@medpenalty\vskip\doublerulesep}%
  \else
    \global\let\@gtempa\@empty
    \gdef\LF@sep{\penalty-\@lowpenalty\vskip-\arrayrulewidth}%
  \fi
  \ifnum0=`{\fi}%
  \multispan\LF@cols
     \unskip\leaders\hrule\@height\arrayrulewidth\hfill\cr
  \noalign{\LF@sep}%
  \multispan\LF@cols
     \unskip\leaders\hrule\@height\arrayrulewidth\hfill\cr
  \noalign{\penalty\@M}%
  \@gtempa}
%    \end{macrocode}
% \subsection{Captioning}
%    You can easily change how a long figure is captioned by
%    redefining the \cs{LF@makecaption} macro after loading the |longfigure| package.
%    The following statements show the default definition of the
%    \cs{LF@makecaption}:
%
%    \begin{macrocode}
\def\LF@caption{%
  \noalign\bgroup
    \@ifnextchar[{\egroup\LF@c@ption\@firstofone}\LF@capti@n}
%    \end{macrocode}
%    The \cs{LF@caption} command begins the process.
%    If it includes an optional argument, it calls \cs{LF@c@ption}; otherwise
%    it calls \cs{LF@capti@n}, which then calls \cs{LF@c@ption}.
%    \begin{macrocode}
\def\LF@c@ption#1[#2]#3{%
  \LF@makecaption#1\LF@name{#3}%
  \def\@tempa{#2}%
  \ifx\@tempa\@empty\else
%    \end{macrocode}
%    If a list of long figures is requested, the following code uses the
%    previously defined \cs{strcfstr} macro and  \cs{ifLF@same} boolean
%    to determine the name of the counter and set the  output file to
%    contain the |longfigure| information.
%
%    The code writes to one of the following files.
%    \begin{itemize}
%     \item If the counter is |figure|, write to the |lof| file.
%     \item If the counter is |table|, write to the |lot| file.
%     \item Otherwise, write to |lft|, a file created here for this purpose.
%    \end{itemize}
%
%    \begin{macrocode}
     {\let\\\space
     \strcfstr{\LFcounter}{figure}
       \ifLF@same\def\LFoutfile{lof}\else
         \strcfstr{\LFcounter}{table}
           \ifLF@same\def\LFoutfile{lot}\else
             \def\LFoutfile{lft}\fi\fi
     \addcontentsline{\LFoutfile}{\LFcounter}
     {\expandafter\protect\expandafter\numberline\expandafter%
  {\expandafter\csname the\LFcounter\endcsname}{#2}}}%
  \fi
}
%    \end{macrocode}
%    The \cs{LF@c@ption} macro ends the process when it calls the
%    \cs{LF@makecaption} macro, which typesets the caption.
%    \begin{macrocode}
\def\LF@capti@n{%
  \@ifstar
    {\egroup\LF@c@ption\@gobble[]}%
    {\egroup\@xdblarg{\LF@c@ption\@firstofone}}}
%    \end{macrocode}
%
%    If you want to redefine how the |longfigure| is captioned,
%    you need to override the following macro.
%    The first argument is the name of the counter
%    (for example, |Figure|), the second argument is the number of the counter, and the
%    third argument is the caption itself.
%    \begin{macrocode}
\def\LF@makecaption#1#2#3{%
  \LF@mcol\LF@cols c{\hbox to\z@{\hss\parbox[t]\LFcapwidth{%
    \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}}}
\def\LF@output{%
  \ifnum\outputpenalty <-\@Mi
    \ifnum\outputpenalty > -\LF@end@pen
      \LF@err{floats and marginpars not allowed in a longfigure}\@ehc
    \else
      \setbox\z@\vbox{\unvbox\@cclv}%
      \ifdim \ht\LF@lastfoot>\ht\LF@foot
        \dimen@\pagegoal
        \advance\dimen@-\ht\LF@lastfoot
        \ifdim\dimen@<\ht\z@
          \setbox\@cclv\vbox{\unvbox\z@\copy\LF@foot\vss}%
          \@makecol
          \@outputpage
          \setbox\z@\vbox{\box\LF@head}%
        \fi
      \fi
      \global\@colroom\@colht
      \global\vsize\@colht
      \vbox
        {\unvbox\z@\box\ifvoid\LF@lastfoot\LF@foot\else
         \LF@lastfoot\fi}%
    \fi
  \else
    \setbox\@cclv\vbox{\unvbox\@cclv\copy\LF@foot\vss}%
    \@makecol
    \@outputpage
      \global\vsize\@colroom
    \copy\LF@head\nobreak
  \fi}
\def\LF@end@hd@ft#1{%
  \LF@echunk
  \ifx\LF@start\endgraf
    \LF@err
     {Longfigure head or foot not at start of table}%
     {Increase LFchunksize}%
  \fi
  \setbox#1\box\z@
  \LF@get@widths
  \LF@bchunk}
%    \end{macrocode}
%    The following four macros do not have an \cs{LT} prefix in the |longtable| package,
%    but they must be redefined to have an \cs{LF} prefix in order to avoid a namespace clash;
%    \begin{macrocode}
\def\endLFfirsthead{\LF@end@hd@ft\LF@firsthead}
\def\endLFhead{\LF@end@hd@ft\LF@head}
\def\endLFfoot{\LF@end@hd@ft\LF@foot}
\def\endLFlastfoot{\LF@end@hd@ft\LF@lastfoot}
 %
\def\LF@startpbox#1{%
  \bgroup
    \let\@footnotetext\LF@p@ftntext
    \setlength\hsize{#1}%
    \@arrayparboxrestore
    \vrule \@height \ht\@arstrutbox \@width \z@}
\def\LF@endpbox{%
  \@finalstrut\@arstrutbox
  \egroup
  \the\LF@p@ftn
  \global\LF@p@ftn{}%
  \hfil}
\def\LF@p@ftntext#1{%
  \edef\@tempa{\the\LF@p@ftn\noexpand\footnotetext[\the\c@footnote]}%
  \global\LF@p@ftn\expandafter{\@tempa{#1}}}%
%    \end{macrocode}
%    \subsection{References}
%    \begin{description}
%    \item[\textmd{Carlisle, D. 2004.}]
%    \emph{The longtable Package}.
%    Included in the ``Comprehensive \TeX\ Archive Network.'' \url{http://ctan.org}.
%
%    \item[\textmd{Lazarides, Y. 2010.}]
%    \TeX stackexchange, online forum. \url{http://tex.stackexchange.com/questions/7992}.
%
%    \item[\textmd{Sch\"opf, R., B. Raichle, and C. Rowley. 2001.}]
%    \emph{A New Implementation of \LaTeX's \texttt{verbatim} and \texttt{verbatim*} Environments}.
%    Originally appeared in TUGboat 1990, 11(2), 284--296.
%
%    \item[\textmd{Thanh, H., S. Rahtz, H. Hagen, and H. Henkel. 2009.}]
%    ``The pdf\TeX\ User's Manual'' Revision 655, corresponding to pdf\TeX\ 1.40.11.
%    \url{www.tug.org/applications/pdftex}
%
%    \item[\textmd{Wilson, Peter. 2001.}]
%    \emph{Glisterings} in TUGboat 22(4), 339--340.
%    \end{description}
%
%\StopEventually{^^A
%  \PrintChanges
%  \PrintIndex
%}
%
%    \begin{macrocode}
%</longfigure>
%    \end{macrocode}
%\Finale