Debian Codegraph @

texmf-dist/source/latex/longfigure/longfigure.dtx

raw
1 % \iffalse meta-comment
2 %<*internal>
3 \iffalse
4 %</internal>
5 %<*readme>
6 ----------------------------------------------------------------
7 longfigure --- A LaTeX package providing a table-like environment
8 that can display a stream of subfigures as a single
9 figure that can be broken by \TeX's
10 standard page-breaking algorithm.
11
12 Nearly identical to David Carlisle's |longtable| package,
13 but with some obvious changes to use figures instead of
14 tables. All credit goes to David Carlisle; this package
15 represents small changes to his code and logic.
16 I am responsible for the changes.
17
18 E-mail: [email protected]
19 Released under the LaTeX Project Public License v1.3c or later
20 See http://www.latex-project.org/lppl.txt
21 ----------------------------------------------------------------
22
23 This work consists of the file longfigure.dtx
24 and the derived files:
25 README (this file)
26 longfigure.ins
27 longfigure.pdf
28 longfigure.sty
29 %</readme>
30 %<*internal>
31 \fi
32 \def\nameofplainTeX{plain}
33 \ifx\fmtname\nameofplainTeX\else
34 \expandafter\begingroup
35 \fi
36 %</internal>
37 %<*install>
38 \input docstrip.tex
39 \keepsilent
40 \askforoverwritefalse
41 \preamble
42 ----------------------------------------------------------------
43 longfigure --- A LaTeX package providing a table-like environment
44 that can display a stream of subfigures as a single
45 figure that can be broken by \TeX's
46 standard page-breaking algorithm.
47
48 E-mail: [email protected]
49 ----------------------------------------------------------------
50 \endpreamble
51 \postamble
52 Copyright (C) 2014 by SAS Institute Inc. <[email protected]>
53
54 This work may be distributed and/or modified under the
55 conditions of the LaTeX Project Public License (LPPL), either
56 version 1.3c of this license or any later version.
57 The latest version of this license is in the file:
58 http://www.latex-project.org/lppl.txt
59
60 This work is "maintained" (as per LPPL maintenance status) by
61 Tim Arnold.
62
63 This work consists of the file longfigure.dtx
64 and the derived files:
65 README (this file)
66 longfigure.ins
67 longfigure.pdf
68 longfigure.sty
69 \endpostamble
70 \generate{\file{longfigure.sty}{\from{longfigure.dtx}{longfigure}}}
71 %</install>
72 %<install>\endbatchfile
73 %<*internal>
74 \generate{\file{longfigure.ins}{\from{longfigure.dtx}{install}}}
75 \nopreamble\nopostamble
76 \generate{\file{README}{\from{longfigure.dtx}{readme}}}
77 \ifx\fmtname\nameofplainTeX
78 \expandafter\endbatchfile
79 \else
80 \expandafter\endgroup
81 \fi
82 %</internal>
83 %<*longfigure>
84 \NeedsTeXFormat{LaTeX2e}
85 \ProvidesPackage{longfigure}[2014/1/06 v1.0]
86 %</longfigure>
87 %<*driver>
88 \documentclass{ltxdoc}
89 \usepackage[T1]{fontenc}
90 \usepackage{lmodern}
91 \usepackage{\jobname}
92 \usepackage[numbered]{hypdoc}
93 \EnableCrossrefs
94 \CodelineIndex
95 \RecordChanges
96 \begin{document}
97 \DocInput{\jobname.dtx}
98 \end{document}
99 %</driver>
100 % \fi
101 %\GetFileInfo{\jobname.sty}
102 % \def\fileversion{v1.0}
103 %
104 %\title{^^A
105 % The \textsf{longfigure} Package\thanks{^^A
106 % This file describes version \fileversion, last revised \filedate.^^A
107 % }^^A
108 %}
109 %\author{^^A
110 % Tim Arnold\thanks{E-mail: [email protected]}^^A
111 %}
112 %\date{Released \filedate}
113 %
114 %\maketitle
115 %
116 %\changes{v1.0}{2014/1/06}{First public release}
117 % \section{Usage}
118 % \label{longfigure}
119 % \index{longfigure package|usage}
120 %
121 % The |longfigure| package uses and relabels components of the
122 % well-known |longtable| package, written by David Carlisle, to
123 % provide a table-like environment that can display a stream
124 % of subfigures as a single figure that can break across pages.
125 %
126 % The |longtable| package defines a |longtable| environment,
127 % which produces tables that can be broken by \TeX's standard page-breaking algorithm.
128 % Similarly, the |longfigure| package defines a |longfigure| environment, which produces
129 % figures that can be broken by \TeX's standard page-breaking algorithm.
130 % The internal structure of a long figure is similar to a long table.
131 % Rows might contain (for example) tables or graphics. Page breaks
132 % can occur only between rows.
133 %
134 % The |longfigure| package differs from the |longtable| package in the following ways:
135 % \begin{itemize}
136 % \item The |longfigure| package supports two additional key-value options:
137 % \begin{itemize}
138 % \item The |figname=| option specifies the counter for numbering |longfigure| environments.
139 % You can specify any string; the default is |figure|.
140 % When you specify a |figname=| value for which no counter already exists, the
141 % |longfigure| package loads the |tocloft| package and creates the counter.
142 % \index{figname option|usage}
143 %
144 % \item The |resetby=| option specifies a counter (for example, |resetby=chapter|) such
145 % that output numbering is reset each time the counter value changes.
146 % If a counter is specified that does not exist, the |tocloft| package is
147 % loaded to create the new counter.
148 % \index{tocloft package|usage}%
149 % For information about how the lists are typeset,
150 % \index{list of outputs, creating|usage}%
151 % see the |tocloft| package documentation.
152 % \end{itemize}
153 % \item The counters and macros that start with \cs{LT} in the |longtable| package
154 % are renamed to start with \cs{LF} in the |longfigure| pacakge to avoid
155 % namespace conflicts when the two packages are used together.
156 % The generic macros that are defined in the |longtable| package
157 % (\cs{endfirsthead}, \cs{endhead}, \cs{endfoot}, and \cs{endlastfoot}) are
158 % also renamed with \cs{LF} as a prefix in the |longfigure| package.
159 %
160 % \item The \cs{LF@name} macro is based on the \cs{fnum@table} macro from
161 % the |longtable| package. The \cs{LF@name} macro returns the capitalized
162 % counter name and value. For example, if the counter is |figure| and the
163 % macro is processing the second |longfigure|, the \cs{LF@name} macro
164 % would contain the value ``Figure 2.''
165 %
166 % \end{itemize}
167 % You can use the |longfigure| package defaults to produce a \emph{List of Figures}
168 % by inserting the following tag in your document at the point where you want
169 % the list to appear:
170 % \iffalse
171 %<*example>
172 % \fi
173 \begin{verbatim}
174 \listoffigures
175 \end{verbatim}
176 % \iffalse
177 %</example>
178 % \fi
179 %
180 % The default counter used to display figures is the |figure| counter,
181 % but you can specify a different counter. For example, if you want your
182 % figures to be labeled as ``Display,'' specify |figname=display| when you
183 % load the |longfigure| package; to display a \emph{List of Displays}, insert the following
184 % command in your document at the point where you want the list to appear:
185 % \iffalse
186 %<*example>
187 % \fi
188 \begin{verbatim}
189 \listofdisplay
190 \end{verbatim}
191 % \iffalse
192 %</example>
193 % \fi
194 % \textbf{Note:} If you specify a counter that does not exist,
195 % an auxiliary file with extension |.lft| is created to contain the information
196 % needed to create the list.
197 %
198 % If you want to use more advanced features of the |tocloft| package,
199 % load it before you load the |longfigure| package so that the |longfigure|
200 % package sees that the counters specified by the |figname=| and |resetby=|
201 % options are already defined and does not attempt to create them.
202 %
203 %
204 %\subsection{Example}
205 % The following lines produce a single figure that contains three images and
206 % one tabular environment. Each element is a row of the |longfigure| environment.
207 % Page breaks can occur between rows.
208 %
209 %\begin{verbatim}
210 %\documentclass{book}
211 %\usepackage{graphicx}
212 %\usepackage{longfigure}
213 %
214 %\begin{document}
215 % \begin{longfigure}{c}
216 % \caption{My Long Figure}\label{mlfig}\\
217 % \includegraphics[width=3in]{myfig1}\\
218 % \includegraphics[width=3in]{myfig2}\\
219 % \includegraphics[width=3in]{myfig3}\\
220 % \begin{tabular}{ll}
221 % one & two \\
222 % three & four\\
223 % \end{tabular}
224 % \end{longfigure}
225 %\end{document}
226 %\end{verbatim}
227 %
228 % In this example, the |{c}| argument in the |\begin{longfigure}| command
229 % specifies only a single centered column. You can also specify multiple columns and,
230 % if needed, use the \cs{multicolumn} command for more flexibility.
231 %
232 % The following lines display another example that specifies a 'continued' heading
233 % when the figure breaks over a page. It also displays a double horizontal line at the
234 % end of the figure.
235 %\begin{verbatim}
236 %\documentclass{book}
237 %\usepackage{graphicx}
238 %\usepackage{longfigure}
239 %
240 %\begin{document}
241 % \begin{longfigure}{c}
242 % \caption{My Long Figure}\label{mlfig2}\\
243 % \hline\endLFfirsthead
244 % \caption{continued}\\
245 % \hline\endLFhead
246 % \hline\endLFfoot
247 % \hline\hline\endLFlastfoot
248 % \includegraphics[width=3in]{myfig1}\\
249 % \includegraphics[width=3in]{myfig2}\\
250 % \includegraphics[width=3in]{myfig3}\\
251 % \begin{tabular}{ll}
252 % one & two \\
253 % three & four\\
254 % \end{tabular}
255 % \end{longfigure}
256 %\end{document}
257 %\end{verbatim}
258 %
259 % \section{Implementation}
260 %
261 % This section describes the implementation of the |longfigure| package.
262 % The comments describe only the changes from the |longtable| package code.
263 % For complete details about the logic and usage of the |longtable| environment,
264 % see Carlisle (2004).
265 %\iffalse
266 %<*longfigure>
267 %\fi
268 % \begin{macrocode}
269 \ProvidesPackage{longfigure}[2014/01/06 longfigure]
270 % \end{macrocode}
271 % The following statement loads the |xkeyval| package for declaring
272 % and processing package options:
273 % \begin{macrocode}
274 \RequirePackage{xkeyval}
275 % \end{macrocode}
276 % The following statement defines a new command, \cs{LFcounter}, to
277 % contain the string |figure|.
278 % Later code tests whether a counter with that name exists.
279 % \begin{macrocode}
280 \newcommand*{\LFcounter}{figure}
281 % \end{macrocode}
282 %
283 % The following statement defines a new command, \cs{LFreset}, to contain
284 % the name of the counter within which the |longfigure| number should reset.
285 % If no value is specified, the long figures are numbered consecutively
286 % through the document.
287 % \begin{macrocode}
288 \newcommand*{\LFreset}{\@empty}
289 % \end{macrocode}
290 % \subsection{Options}
291 % The \cs{LFcounter} and \cs{LFreset} commands support the
292 % package options |figname=| and |resetby=| as follows:
293 % \begin{macrocode}
294 \DeclareOptionX{figname}[figure]{\renewcommand*{\LFcounter}{#1}}
295 \DeclareOptionX{resetby}{\renewcommand*{\LFreset}{#1}}
296 % \end{macrocode}
297 % The following statements further define the options
298 % that the |longtable| package defines:
299 % \begin{macrocode}
300 \DeclareOptionX{set}{}
301 \DeclareOptionX{final}{}
302 \DeclareOptionX{errorshow}{\def\LF@warn{\PackageInfo{longfigure}}}
303 \DeclareOptionX{pausing}{\def\LF@warn#1{\LF@err{#1}{This is not really an error}}}
304 \ProcessOptionsX
305 % \end{macrocode}
306 % The following statements process the options:
307 % \begin{macrocode}
308 \def\LFProcessOptions#1{
309 \@ifundefined{c@#1}{%
310 \RequirePackage{tocloft}
311 \def\LFuc##1##2{\MakeUppercase{##1}{##2}}
312 \expandafter\def\csname list#1name\endcsname{List of \LFuc#1s}
313 \ifx\@empty\LFreset%
314 \newlistof{#1}{lft}{\csname list#1name\endcsname}
315 \else
316 \newlistof[\LFreset]{#1}{lft}{\csname list#1name\endcsname}
317 \fi
318 }{}%
319 }
320 \expandafter\LFProcessOptions\expandafter{\LFcounter}
321 % \end{macrocode}
322 % If a counter is specified that does not exist, its name (\cs{c@}\textit{countername})
323 % is undefined and the |longfigure| package loads the |tocloft| package in order to
324 % use its commands to create the new counters and list.
325 %
326 % Thus, the |tocloft| package is required only when a new counter
327 % is specified,
328 % \index{tocloft package|usage}%
329 % and this automatic loading takes place only if the counter that is specified
330 % in the package options is not defined.
331 %
332 % You can load the |tocloft| package before loading the |longfigure| package
333 % and retain all of the flexibility that the |tocloft| package offers.
334 % However, you must define the new counters yourself by using the
335 % \cs{newlistof} command in the |tocloft| package,
336 % and you must define the new list to use an auxiliary |lft| file where
337 % its auxiliary information is written.
338 % \index{tocloft package|usage}%
339 %
340 % \subsection{Utilities}
341 % \DescribeMacro{\strcfstr}
342 % The following macro, \cs{strcfstr}, checks whether two strings, which are
343 % provided as arguments, are equal (Wilson, 2001).
344 % A new boolean \cs{ifLF@same} contains the result of the test.
345 % \begin{macrocode}
346 \newif\ifLF@same
347 \newcommand{\strcfstr}[2]{%
348 \LF@samefalse
349 \begingroup\def\2{#2}
350 \ifx\2#1\endgroup\LF@sametrue
351 \else\endgroup
352 \fi
353 }
354 % \end{macrocode}
355 % \DescribeMacro{\LFupcase}
356 % The following macro, \cs{LFupcase}, uppercases the first letter of
357 % a string (Lazarides, 2010):
358 % \begin{macrocode}
359 \def\LFupcase#1{%
360 \def\x##1##2{%
361 \MakeUppercase{##1}{##2}}\x#1%
362 }
363 % \end{macrocode}
364 % The following macro, \cs{LF@name}, creates a string to provide a label and number for
365 % an output. Analogous to the \cs{fnum@table} macro in the |longtable| package,
366 % it contains the capitalized version of the counter name and the counter
367 % number (for example, |Figure~3|).
368 % \begin{macrocode}
369 \def\LF@name{\expandafter\LFupcase%
370 \expandafter{\LFcounter}~%
371 \expandafter\csname the\LFcounter\endcsname}%
372 % \end{macrocode}
373 % The remainder of this package follows the |longtable| package
374 % almost identically, except that macros, skips, counters, and so on
375 % use an \cs{LF} prefix instead of the \cs{LT} prefix that the |longtable| package uses.
376 %
377 % \begin{macrocode}
378 \def\LF@err{\PackageError{longfigure}}
379 \def\LF@warn{\PackageWarning{longfigure}}
380 \def\LF@final@warn{%
381 \AtEndDocument{%
382 \LF@warn{\LFcounter \@width s have changed. Rerun \LaTeX\.\@gobbletwo}}%
383 \global\let\LF@final@warn\relax}
384 %
385 \newskip\LFleft \LFleft=\fill
386 \newskip\LFright \LFright=\fill
387 \newskip\LFpre \LFpre=\bigskipamount
388 \newskip\LFpost \LFpost=\bigskipamount
389 \newcount\LFchunksize \LFchunksize=20
390 \let\c@LFchunksize\LFchunksize
391 \newdimen\LFcapwidth \LFcapwidth=4in
392 \newbox\LF@head
393 \newbox\LF@firsthead
394 \newbox\LF@foot
395 \newbox\LF@lastfoot
396 \newcount\LF@cols
397 \newcount\LF@rows
398 \newcounter{LF@tables}
399 \newcounter{LF@chunks}[LF@tables]
400 %
401 \newtoks\LF@p@ftn
402 \mathchardef\LF@end@pen=30000
403 \def\longfigure{%
404 \par
405 \ifx\multicols\@undefined
406 \else
407 \ifnum\col@number>\@ne
408 \@twocolumntrue
409 \fi
410 \fi
411 \if@twocolumn
412 \LF@err{longfigure not in 1-column mode}\@ehc
413 \fi
414 \begingroup
415 \@ifnextchar[\LF@array{\LF@array[x]}}
416 \def\LF@array[#1]#2{%
417 \refstepcounter{\LFcounter}\stepcounter{LF@tables}%
418 \if l#1%
419 \LFleft\z@ \LFright\fill
420 \else\if r#1%
421 \LFleft\fill \LFright\z@
422 \else\if c#1%
423 \LFleft\fill \LFright\fill
424 \fi\fi\fi
425 \let\LF@mcol\multicolumn
426 \let\LF@@tabarray\@tabarray
427 \let\LF@@hl\hline
428 \def\@tabarray{%
429 \let\hline\LF@@hl
430 \LF@@tabarray}%
431 \let\\\LF@tabularcr\let\tabularnewline\\%
432 \def\newpage{\noalign{\break}}%
433 \def\pagebreak{\noalign{\ifnum`}=0\fi\@testopt{\LF@no@pgbk-}4}%
434 \def\nopagebreak{\noalign{\ifnum`}=0\fi\@testopt\LF@no@pgbk4}%
435 \let\hline\LF@hline \let\kill\LF@kill\let\caption\LF@caption
436 \@tempdima\ht\strutbox
437 \let\@endpbox\LF@endpbox
438 \ifx\extrarowheight\@undefined
439 \let\@acol\@tabacol
440 \let\@classz\@tabclassz \let\@classiv\@tabclassiv
441 \def\@startpbox{\vtop\LF@startpbox}%
442 \let\@@startpbox\@startpbox
443 \let\@@endpbox\@endpbox
444 \let\LF@LL@FM@cr\@tabularcr
445 \else
446 \advance\@tempdima\extrarowheight
447 \col@sep\tabcolsep
448 \let\@startpbox\LF@startpbox\let\LF@LL@FM@cr\@arraycr
449 \fi
450 \setbox\@arstrutbox\hbox{\vrule
451 \@height \arraystretch \@tempdima
452 \@depth \arraystretch \dp \strutbox
453 \@width \z@}%
454 \let\@sharp##\let\protect\relax
455 \begingroup
456 \@mkpream{#2}%
457 \xdef\LF@bchunk{%
458 \global\advance\c@LF@chunks\@ne
459 \global\LF@rows\z@\setbox\z@\vbox\bgroup
460 \LF@setprevdepth
461 \tabskip\LFleft \noexpand\halign to\hsize\bgroup
462 \tabskip\z@ \@arstrut \@preamble \tabskip\LFright \cr}%
463 \endgroup
464 \expandafter\LF@nofcols\LF@bchunk&\LF@nofcols
465 \LF@make@row
466 \m@th\let\par\@empty
467 \everycr{}\lineskip\z@\baselineskip\z@
468 \LF@bchunk}
469 \def\LF@no@pgbk#1[#2]{\penalty #1\@getpen{#2}\ifnum`{=0\fi}}
470 \def\LF@start{%
471 \let\LF@start\endgraf
472 \endgraf\penalty\z@\vskip\LFpre
473 \dimen@\pagetotal
474 \advance\dimen@ \ht\ifvoid\LF@firsthead\LF@head\else\LF@firsthead\fi
475 \advance\dimen@ \dp\ifvoid\LF@firsthead\LF@head\else\LF@firsthead\fi
476 \advance\dimen@ \ht\LF@foot
477 \dimen@ii\vfuzz
478 \vfuzz\maxdimen
479 \setbox\tw@\copy\z@
480 \setbox\tw@\vsplit\tw@ to \ht\@arstrutbox
481 \setbox\tw@\vbox{\unvbox\tw@}%
482 \vfuzz\dimen@ii
483 \advance\dimen@ \ht
484 \ifdim\ht\@arstrutbox>\ht\tw@\@arstrutbox\else\tw@\fi
485 \advance\dimen@\dp
486 \ifdim\dp\@arstrutbox>\dp\tw@\@arstrutbox\else\tw@\fi
487 \advance\dimen@ -\pagegoal
488 \ifdim \dimen@>\z@\vfil\break\fi
489 \global\@colroom\@colht
490 \ifvoid\LF@foot\else
491 \advance\vsize-\ht\LF@foot
492 \global\advance\@colroom-\ht\LF@foot
493 \dimen@\pagegoal\advance\dimen@-\ht\LF@foot\pagegoal\dimen@
494 \maxdepth\z@
495 \fi
496 \ifvoid\LF@firsthead\copy\LF@head\else\box\LF@firsthead\fi\nobreak
497 \output{\LF@output}}
498 \def\endlongfigure{%
499 \crcr
500 \noalign{%
501 \let\LF@entry\LF@entry@chop
502 \xdef\LF@save@row{\LF@save@row}}%
503 \LF@echunk
504 \LF@start
505 \unvbox\z@
506 \LF@get@widths
507 \if@filesw
508 {\let\LF@entry\LF@entry@write\immediate\write\@auxout{%
509 \gdef\expandafter\noexpand
510 \csname LF@\romannumeral\c@LF@tables\endcsname
511 {\LF@save@row}}}%
512 \fi
513 \ifx\LF@save@row\LF@@save@row
514 \else
515 \LF@warn{Column \@width s have changed\MessageBreak
516 in table \thetable}%
517 \LF@final@warn
518 \fi
519 \endgraf\penalty -\LF@end@pen
520 \endgroup
521 \global\@mparbottom\z@
522 \pagegoal\vsize
523 \endgraf\penalty\z@\addvspace\LFpost
524 \ifvoid\footins\else\insert\footins{}\fi}
525 \def\LF@nofcols#1&{%
526 \futurelet\@let@token\LF@n@fcols}
527 \def\LF@n@fcols{%
528 \advance\LF@cols\@ne
529 \ifx\@let@token\LF@nofcols
530 \expandafter\@gobble
531 \else
532 \expandafter\LF@nofcols
533 \fi}
534 \def\LF@tabularcr{%
535 \relax\iffalse{\fi\ifnum0=`}\fi
536 \@ifstar
537 {\def\crcr{\LF@crcr\noalign{\nobreak}}\let\cr\crcr
538 \LF@t@bularcr}%
539 {\LF@t@bularcr}}
540 \let\LF@crcr\crcr
541 \let\LF@setprevdepth\relax
542 \def\LF@t@bularcr{%
543 \global\advance\LF@rows\@ne
544 \ifnum\LF@rows=\LFchunksize
545 \gdef\LF@setprevdepth{%
546 \prevdepth\z@\global
547 \global\let\LF@setprevdepth\relax}%
548 \expandafter\LF@xtabularcr
549 \else
550 \ifnum0=`{}\fi
551 \expandafter\LF@LL@FM@cr
552 \fi}
553 \def\LF@xtabularcr{%
554 \@ifnextchar[\LF@argtabularcr\LF@ntabularcr}
555 \def\LF@ntabularcr{%
556 \ifnum0=`{}\fi
557 \LF@echunk
558 \LF@start
559 \unvbox\z@
560 \LF@get@widths
561 \LF@bchunk}
562 \def\LF@argtabularcr[#1]{%
563 \ifnum0=`{}\fi
564 \ifdim #1>\z@
565 \unskip\@xargarraycr{#1}%
566 \else
567 \@yargarraycr{#1}%
568 \fi
569 \LF@echunk
570 \LF@start
571 \unvbox\z@
572 \LF@get@widths
573 \LF@bchunk}
574 \def\LF@echunk{%
575 \crcr\LF@save@row\cr\egroup
576 \global\setbox\@ne\lastbox
577 \unskip
578 \egroup}
579 \def\LF@entry#1#2{%
580 \ifhmode\@firstofone{&}\fi\omit
581 \ifnum#1=\c@LF@chunks
582 \else
583 \kern#2\relax
584 \fi}
585 \def\LF@entry@chop#1#2{%
586 \noexpand\LF@entry
587 {\ifnum#1>\c@LF@chunks
588 1}{0pt%
589 \else
590 #1}{#2%
591 \fi}}
592 \def\LF@entry@write{%
593 \noexpand\LF@entry^^J%
594 \@spaces}
595 \def\LF@kill{%
596 \LF@echunk
597 \LF@get@widths
598 \expandafter\LF@rebox\LF@bchunk}
599 \def\LF@rebox#1\bgroup{%
600 #1\bgroup
601 \unvbox\z@
602 \unskip
603 \setbox\z@\lastbox}
604 \def\LF@blank@row{%
605 \xdef\LF@save@row{\expandafter\LF@build@blank
606 \romannumeral\number\LF@cols 001 }}
607 \def\LF@build@blank#1{%
608 \if#1m%
609 \noexpand\LF@entry{1}{0pt}%
610 \expandafter\LF@build@blank
611 \fi}
612 \def\LF@make@row{%
613 \global\expandafter\let\expandafter\LF@save@row
614 \csname LF@\romannumeral\c@LF@tables\endcsname
615 \ifx\LF@save@row\relax
616 \LF@blank@row
617 \else
618 {\let\LF@entry\or
619 \if!%
620 \ifcase\expandafter\expandafter\expandafter\LF@cols
621 \expandafter\@gobble\LF@save@row
622 \or
623 \else
624 \relax
625 \fi
626 !%
627 \else
628 \aftergroup\LF@blank@row
629 \fi}%
630 \fi}
631 \let\setlongfigures\relax
632 \def\LF@get@widths{%
633 \setbox\tw@\hbox{%
634 \unhbox\@ne
635 \let\LF@old@row\LF@save@row
636 \global\let\LF@save@row\@empty
637 \count@\LF@cols
638 \loop
639 \unskip
640 \setbox\tw@\lastbox
641 \ifhbox\tw@
642 \LF@def@row
643 \advance\count@\m@ne
644 \repeat}%
645 \ifx\LF@@save@row\@undefined
646 \let\LF@@save@row\LF@save@row
647 \fi}
648 \def\LF@def@row{%
649 \let\LF@entry\or
650 \edef\@tempa{%
651 \ifcase\expandafter\count@\LF@old@row
652 \else
653 {1}{0pt}%
654 \fi}%
655 \let\LF@entry\relax
656 \xdef\LF@save@row{%
657 \LF@entry
658 \expandafter\LF@max@sel\@tempa
659 \LF@save@row}}
660 \def\LF@max@sel#1#2{%
661 {\ifdim#2=\wd\tw@
662 #1%
663 \else
664 \number\c@LF@chunks
665 \fi}%
666 {\the\wd\tw@}}
667 \def\LF@hline{%
668 \noalign{\ifnum0=`}\fi
669 \penalty\@M
670 \futurelet\@let@token\LF@@hline}
671 \def\LF@@hline{%
672 \ifx\@let@token\hline
673 \global\let\@gtempa\@gobble
674 \gdef\LF@sep{\penalty-\@medpenalty\vskip\doublerulesep}%
675 \else
676 \global\let\@gtempa\@empty
677 \gdef\LF@sep{\penalty-\@lowpenalty\vskip-\arrayrulewidth}%
678 \fi
679 \ifnum0=`{\fi}%
680 \multispan\LF@cols
681 \unskip\leaders\hrule\@height\arrayrulewidth\hfill\cr
682 \noalign{\LF@sep}%
683 \multispan\LF@cols
684 \unskip\leaders\hrule\@height\arrayrulewidth\hfill\cr
685 \noalign{\penalty\@M}%
686 \@gtempa}
687 % \end{macrocode}
688 % \subsection{Captioning}
689 % You can easily change how a long figure is captioned by
690 % redefining the \cs{LF@makecaption} macro after loading the |longfigure| package.
691 % The following statements show the default definition of the
692 % \cs{LF@makecaption}:
693 %
694 % \begin{macrocode}
695 \def\LF@caption{%
696 \noalign\bgroup
697 \@ifnextchar[{\egroup\LF@c@ption\@firstofone}\LF@capti@n}
698 % \end{macrocode}
699 % The \cs{LF@caption} command begins the process.
700 % If it includes an optional argument, it calls \cs{LF@c@ption}; otherwise
701 % it calls \cs{LF@capti@n}, which then calls \cs{LF@c@ption}.
702 % \begin{macrocode}
703 \def\LF@c@ption#1[#2]#3{%
704 \LF@makecaption#1\LF@name{#3}%
705 \def\@tempa{#2}%
706 \ifx\@tempa\@empty\else
707 % \end{macrocode}
708 % If a list of long figures is requested, the following code uses the
709 % previously defined \cs{strcfstr} macro and \cs{ifLF@same} boolean
710 % to determine the name of the counter and set the output file to
711 % contain the |longfigure| information.
712 %
713 % The code writes to one of the following files.
714 % \begin{itemize}
715 % \item If the counter is |figure|, write to the |lof| file.
716 % \item If the counter is |table|, write to the |lot| file.
717 % \item Otherwise, write to |lft|, a file created here for this purpose.
718 % \end{itemize}
719 %
720 % \begin{macrocode}
721 {\let\\\space
722 \strcfstr{\LFcounter}{figure}
723 \ifLF@same\def\LFoutfile{lof}\else
724 \strcfstr{\LFcounter}{table}
725 \ifLF@same\def\LFoutfile{lot}\else
726 \def\LFoutfile{lft}\fi\fi
727 \addcontentsline{\LFoutfile}{\LFcounter}
728 {\expandafter\protect\expandafter\numberline\expandafter%
729 {\expandafter\csname the\LFcounter\endcsname}{#2}}}%
730 \fi
731 }
732 % \end{macrocode}
733 % The \cs{LF@c@ption} macro ends the process when it calls the
734 % \cs{LF@makecaption} macro, which typesets the caption.
735 % \begin{macrocode}
736 \def\LF@capti@n{%
737 \@ifstar
738 {\egroup\LF@c@ption\@gobble[]}%
739 {\egroup\@xdblarg{\LF@c@ption\@firstofone}}}
740 % \end{macrocode}
741 %
742 % If you want to redefine how the |longfigure| is captioned,
743 % you need to override the following macro.
744 % The first argument is the name of the counter
745 % (for example, |Figure|), the second argument is the number of the counter, and the
746 % third argument is the caption itself.
747 % \begin{macrocode}
748 \def\LF@makecaption#1#2#3{%
749 \LF@mcol\LF@cols c{\hbox to\z@{\hss\parbox[t]\LFcapwidth{%
750 \sbox\@tempboxa{#1{#2: }#3}%
751 \ifdim\wd\@tempboxa>\hsize
752 #1{#2: }#3%
753 \else
754 \hbox to\hsize{\hfil\box\@tempboxa\hfil}%
755 \fi
756 \endgraf\vskip\baselineskip}%
757 \hss}}}
758 \def\LF@output{%
759 \ifnum\outputpenalty <-\@Mi
760 \ifnum\outputpenalty > -\LF@end@pen
761 \LF@err{floats and marginpars not allowed in a longfigure}\@ehc
762 \else
763 \setbox\z@\vbox{\unvbox\@cclv}%
764 \ifdim \ht\LF@lastfoot>\ht\LF@foot
765 \dimen@\pagegoal
766 \advance\dimen@-\ht\LF@lastfoot
767 \ifdim\dimen@<\ht\z@
768 \setbox\@cclv\vbox{\unvbox\z@\copy\LF@foot\vss}%
769 \@makecol
770 \@outputpage
771 \setbox\z@\vbox{\box\LF@head}%
772 \fi
773 \fi
774 \global\@colroom\@colht
775 \global\vsize\@colht
776 \vbox
777 {\unvbox\z@\box\ifvoid\LF@lastfoot\LF@foot\else
778 \LF@lastfoot\fi}%
779 \fi
780 \else
781 \setbox\@cclv\vbox{\unvbox\@cclv\copy\LF@foot\vss}%
782 \@makecol
783 \@outputpage
784 \global\vsize\@colroom
785 \copy\LF@head\nobreak
786 \fi}
787 \def\LF@end@hd@ft#1{%
788 \LF@echunk
789 \ifx\LF@start\endgraf
790 \LF@err
791 {Longfigure head or foot not at start of table}%
792 {Increase LFchunksize}%
793 \fi
794 \setbox#1\box\z@
795 \LF@get@widths
796 \LF@bchunk}
797 % \end{macrocode}
798 % The following four macros do not have an \cs{LT} prefix in the |longtable| package,
799 % but they must be redefined to have an \cs{LF} prefix in order to avoid a namespace clash;
800 % \begin{macrocode}
801 \def\endLFfirsthead{\LF@end@hd@ft\LF@firsthead}
802 \def\endLFhead{\LF@end@hd@ft\LF@head}
803 \def\endLFfoot{\LF@end@hd@ft\LF@foot}
804 \def\endLFlastfoot{\LF@end@hd@ft\LF@lastfoot}
805 %
806 \def\LF@startpbox#1{%
807 \bgroup
808 \let\@footnotetext\LF@p@ftntext
809 \setlength\hsize{#1}%
810 \@arrayparboxrestore
811 \vrule \@height \ht\@arstrutbox \@width \z@}
812 \def\LF@endpbox{%
813 \@finalstrut\@arstrutbox
814 \egroup
815 \the\LF@p@ftn
816 \global\LF@p@ftn{}%
817 \hfil}
818 \def\LF@p@ftntext#1{%
819 \edef\@tempa{\the\LF@p@ftn\noexpand\footnotetext[\the\c@footnote]}%
820 \global\LF@p@ftn\expandafter{\@tempa{#1}}}%
821 % \end{macrocode}
822 % \subsection{References}
823 % \begin{description}
824 % \item[\textmd{Carlisle, D. 2004.}]
825 % \emph{The longtable Package}.
826 % Included in the ``Comprehensive \TeX\ Archive Network.'' \url{http://ctan.org}.
827 %
828 % \item[\textmd{Lazarides, Y. 2010.}]
829 % \TeX stackexchange, online forum. \url{http://tex.stackexchange.com/questions/7992}.
830 %
831 % \item[\textmd{Sch\"opf, R., B. Raichle, and C. Rowley. 2001.}]
832 % \emph{A New Implementation of \LaTeX's \texttt{verbatim} and \texttt{verbatim*} Environments}.
833 % Originally appeared in TUGboat 1990, 11(2), 284--296.
834 %
835 % \item[\textmd{Thanh, H., S. Rahtz, H. Hagen, and H. Henkel. 2009.}]
836 % ``The pdf\TeX\ User's Manual'' Revision 655, corresponding to pdf\TeX\ 1.40.11.
837 % \url{www.tug.org/applications/pdftex}
838 %
839 % \item[\textmd{Wilson, Peter. 2001.}]
840 % \emph{Glisterings} in TUGboat 22(4), 339--340.
841 % \end{description}
842 %
843 %\StopEventually{^^A
844 % \PrintChanges
845 % \PrintIndex
846 %}
847 %
848 % \begin{macrocode}
849 %</longfigure>
850 % \end{macrocode}
851 %\Finale