Debian Codegraph @

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

raw
1 % \iffalse meta comment
2 % File: subfloat.dtx Copyright (C) 1999 Harald Harders
3 % \fi
4 %
5 % \iffalse
6 %
7 %<*package>
8 \def\packagename{subfloat}
9 \def\fileversion{2.14}
10 \def\filedate{2003/08/21}
11 \def\docdate{2003/08/21}
12 %</package>
13 %<*driver>
14 \documentclass{ltxdoc}
15 \IfFileExists{subfloat.sty}{\usepackage{subfloat}
16 \let\subfloatSTYfound\active}{\GenericWarning{subfloat.dtx}{Package
17 file subfloat.sty not found (Documentation will be messed up!^^J^^A
18 Generate subfloat.sty by (La)TeXing subfloat.ins, process
19 subfloat.dtx again)^^J}\stop}
20 \usepackage{longtable}
21 \title{The \texttt{subfloat} package\thanks{This file has version
22 \fileversion\ last revised \filedate, documentation dated \docdate.}}
23 \author{Harald Harders\\\texttt{[email protected]}}
24 \date{File Date \filedate, Printed \today}
25 \newlength{\tempdima}%
26 \makeatletter
27 \renewenvironment{table}[1][]{%
28 \@float{table}[#1]%
29 \centering%
30 \setlength{\tempdima}{\abovecaptionskip}%
31 \setlength{\abovecaptionskip}{\belowcaptionskip}%
32 \setlength{\belowcaptionskip}{\tempdima}%
33 }{%
34 \end@float
35 }
36 \makeatother
37 \EnableCrossrefs
38 \CodelineIndex
39 \DoNotIndex{\def,\edef,\let,\newcommand,\newenvironment,\newcounter}
40 \DoNotIndex{\setcounter,\space,\endinput,\@auxout,\@bsphack,\@esphack}
41 \DoNotIndex{\@firstoftwo,\if,\else,\fi,\ifnum,\fi,\ifx,\fi,\MessageBreak}
42 \DoNotIndex{\relax,\string,\thepage,\@ifpackageloaded,\expandafter}
43 \DoNotIndex{\message,\newif,\protect,\protected@write}
44 \CodelineNumbered
45 \RecordChanges
46 \CheckSum{280}
47 \setcounter{topnumber}{5}
48 \setcounter{bottomnumber}{1}
49 \setcounter{totalnumber}{6}
50 \begin{document}
51 \DocInput{subfloat.dtx}
52 \end{document}
53 %</driver>
54 % \fi
55 %
56 % \changes{1.01}{1999/06/08}{Documentation improved}
57 % \changes{1.02}{1999/06/08}{Error in change history corrected}
58 % \changes{1.03}{1999/10/08}{email address changed}
59 % \changes{1.04}{2002/08/18}{Suggestions made by Frank Mittelbach
60 % implemented: Changes in implementation, macros to change label format}
61 % \changes{2.00}{2002/09/06}{Total new implementation of the package
62 % with help of Frank Mittelbach}
63 % \changes{2.12}{2002/10/30}{Correct a typo (thanks to Michael M\"uller)}%
64 % \maketitle
65 % \begin{abstract}
66 % \noindent This package enables subnumbering of floats (figures and
67 % tables) similar to the subequations environment of the amsmath
68 % package. It does not the same as the subfigure package which
69 % generates subfigures within one normal figure.
70 % \end{abstract}
71 %
72 % \tableofcontents
73 %
74 % \section*{Copyright}
75 % Copyright 1999, 2002 Harald Harders.
76 %
77 % This program can be redistributed and/or modified under the terms
78 % of the LaTeX Project Public License Distributed from CTAN
79 % archives in directory macros/latex/base/lppl.txt; either
80 % version 1 of the License, or any later version.
81 %
82 % \section{Introduction}
83 % Sometimes two or more floats (figures or tables) belong together in a
84 % way you should not use different caption numbers for them.
85 % With a subnumbering like that of the amsmath package for equations
86 % it is possible to point out the connection of the floats.
87 % This package provides two environments and four macros to achive
88 % subnumbering of floats.
89 % It is possible to change the caption labels.
90 %
91 % In case of problems or bugs please send an email to my address
92 % printed on the title page.
93 %
94 % \section{The user interface}
95 %
96 % To use this package place
97 % \begin{verbatim}
98 % \usepackage{subfloat}
99 % \end{verbatim}
100 % in the preamble of your document.
101 % No options are necessary.
102 %
103 % \changes{2.10}{2002/09/06}{Add counting of subfloats}%
104 % If you want to be able to count the number of subfloats with the
105 % same main number you have to add the package option |countmax|:
106 % \begin{verbatim}
107 % \usepackage[countmax]{subfloat}
108 % \end{verbatim}
109 % For more description to counting see section~\ref{sec:count}.
110 %
111 % \subsection{Environments}
112 % \DescribeEnv{subfigures}
113 % Put
114 % \begin{verbatim}
115 % \begin{subfigures}
116 % \end{subfigures}
117 % \end{verbatim}
118 % around the figures which belong together.
119 % By default, they get the same figure number with an increasing
120 % lowercase character added.
121 % \DescribeEnv{subtables}
122 % In the same way you can put
123 % \begin{verbatim}
124 % \begin{subtables}
125 % \end{subtables}
126 % \end{verbatim}
127 % around tables. The macros for the environments have to be placed outside
128 % the picture or table environments.
129 %
130 % \subsection{Macros}
131 % \DescribeMacro{\subfiguresbegin}
132 % \DescribeMacro{\subfiguresend}
133 % Instead using of the environments it is possible to use adequate macros:
134 % \begin{verbatim}
135 % \subfiguresbegin
136 % \subfiguresend
137 % \end{verbatim}
138 % \DescribeMacro{\subtablesbegin}
139 % \DescribeMacro{\subtablesend}
140 % or
141 % \begin{verbatim}
142 % \subtablesbegin
143 % \subtablesend
144 % \end{verbatim}
145 %
146 % Put these macros in place of the environment macros. The macros are
147 % necessary to be able to nest subnumbered figures and tables.
148 %
149 % If you put labels inside the figure and table environments the subfloat
150 % label numberes are referenced.
151 % If you want a reference to the common figure or table number place a
152 % label right after the |\begin{subfigures}|, |\subfiguresbegin|,
153 % |\begin{subtables}|, or |\subtablesbegin| command.
154 %
155 % \section{Examples}
156 % \subsection{Using the environments}
157 %
158 % \DescribeEnv{subfigures}
159 % The code
160 % \begin{verbatim}
161 % \begin{subfigures}
162 % \label{fig:fig1a2}
163 % %
164 % \begin{figure}\centering
165 % \fbox{fig. 1}
166 % \caption{This is the first figure}\label{fig:fig1}
167 % \end{figure}
168 % %
169 % \begin{figure}\centering
170 % \fbox{fig. 2}
171 % \caption{This is the second figure}\label{fig:fig2}
172 % \end{figure}
173 % %
174 % \end{subfigures}
175 % \end{verbatim}
176 % produces the output of the figures~\ref{fig:fig1a2}
177 % (figure~\ref{fig:fig1} and figure~\ref{fig:fig2}).
178 % References are made as usual with
179 % e.\,g. |\ref{fig:fig1}|.
180 % %
181 % \begin{subfigures}
182 % \label{fig:fig1a2}
183 % %
184 % \begin{figure}\centering
185 % \fbox{fig. 1}
186 % \caption{This is the first figure}\label{fig:fig1}
187 % \end{figure}
188 % %
189 % \begin{figure}\centering
190 % \fbox{fig. 2}
191 % \caption{This is the second figure}\label{fig:fig2}
192 % \end{figure}
193 % %
194 % \end{subfigures}
195 %
196 % \DescribeEnv{subtables}
197 % The output of the tables~\ref{tab:tab1} and \ref{tab:tab1} is
198 % generated similarly:
199 % \begin{verbatim}
200 % \begin{subtables}
201 % %
202 % \begin{table}\centering
203 % \caption{This is the first table}\label{tab:tab1}
204 % \begin{tabular}{l} \hline
205 % table 1\\ \hline
206 % \end{tabular}
207 % \end{table}
208 % %
209 % \begin{table}\centering
210 % \caption{This is the second table}\label{tab:tab2}
211 % \begin{tabular}{l} \hline
212 % table 2\\ \hline
213 % \end{tabular}
214 % \end{table}
215 % %
216 % \end{subtables}
217 % \end{verbatim}
218 % %
219 % \begin{subtables}
220 % %
221 % \begin{table}\centering
222 % \caption{This is the first table}\label{tab:tab1}
223 % \begin{tabular}{l} \hline
224 % table 1\\ \hline
225 % \end{tabular}
226 % \end{table}
227 % %
228 % \begin{table}\centering
229 % \caption{This is the second table}\label{tab:tab2}
230 % \begin{tabular}{l} \hline
231 % table 2\\ \hline
232 % \end{tabular}
233 % \end{table}
234 % %
235 % \end{subtables}
236 %
237 % The environment names |subfigures| and |subtables| were
238 % chosen to be similar to the |subequations| environment of the
239 % amsmath package. But what is to do when both environments have to be
240 % nested? This case is handled in the next section.
241 %
242 % \subsection{Using the macros}
243 % \DescribeMacro{\subfiguresbegin}
244 % \DescribeMacro{\subfiguresend}
245 % \DescribeMacro{\subtablesbegin}
246 % \DescribeMacro{\subtablesend}
247 % The usage of the macros is shown in the example below:
248 % \begin{verbatim}
249 % \subfiguresbegin
250 % \begin{figure}
251 % [...]
252 % \begin{table}
253 % [...]
254 % \subtablesbegin
255 % \begin{table}
256 % [...]
257 % \begin{figure}
258 % [...]
259 % \subfiguresend
260 % \begin{figure}
261 % [...]
262 % \begin{table}
263 % [...]
264 % \subtablesend
265 % \end{verbatim}
266 % %
267 % \subfiguresbegin
268 % %
269 % \begin{figure}\centering
270 % \fbox{fig. 3}
271 % \caption{This is the third figure}\label{fig:fig3}
272 % \end{figure}
273 % %
274 % \begin{table}\centering
275 % \caption{This is the third table}\label{tab:tab3}
276 % \begin{tabular}{l} \hline
277 % table 3\\ \hline
278 % \end{tabular}
279 % \end{table}
280 %
281 % \subtablesbegin
282 % %
283 % \begin{table}\centering
284 % \caption{This is the forth table}\label{tab:tab4}
285 % \begin{tabular}{l} \hline
286 % table 4\\ \hline
287 % \end{tabular}
288 % \end{table}
289 % %
290 % \begin{figure}\centering
291 % \fbox{fig. 4}
292 % \caption{This is the forth figure}\label{fig:fig4}
293 % \end{figure}
294 % %
295 % \subfiguresend
296 % %
297 % \begin{figure}\centering
298 % \fbox{fig. 5}
299 % \caption{This is the fifth figure}\label{fig:fig5}
300 % \end{figure}
301 % %
302 % \begin{table}\centering
303 % \caption{This is the fifth table}\label{tab:tab5}
304 % \begin{tabular}{l} \hline
305 % table 5\\ \hline
306 % \end{tabular}
307 % \end{table}
308 % %
309 % \subtablesend
310 %
311 % With these macros it is possible to realise nested subnumbers of
312 % figures and tables. Even nested subnumbers of figures or tables and
313 % equations made with the subequations environment of the amsmath
314 % package are possible.
315 %
316 % \section{Change the label format}
317 %
318 % The standard label format is the global float number followed by a
319 % lowercase alphanumerical subfloat number.
320 % This can be changed by redefining the commands |\thesubfloatfigure|
321 % and |\thesubfloattable|.
322 % Both define the whole float number including the main number.
323 % The main number is referred by |\themainfigure| resp.\
324 % |\themaintable|.
325 % The counters of the subfloats are |subfloatfigure| resp.\
326 % |subfloattable|.
327 % The default values are:
328 % \begin{verbatim}
329 % \newcommand*\thesubfloatfigure{\themainfigure\alph{subfloatfigure}}
330 % \newcommand*\thesubfloattable{\themaintable\alph{subfloattable}}
331 % \end{verbatim}
332 % If you want to print the subnumber of figures in brackets, you may
333 % define this:
334 % \begin{verbatim}
335 % \renewcommand*\thesubfloatfigure{\themainfigure(\alph{subfloatfigure})}
336 % \end{verbatim}
337 % If you want a sublabel in the format 1--1, 1--2, \dots\ you can
338 % get it by the following command sequence:
339 % \begin{verbatim}
340 % \renewcommand*\thesubfloatfigure{\themainfigure--\arabic{subfloatfigure}}
341 % \end{verbatim}
342 %
343 % Since it is done the same for tables this it not described again.
344 %
345 % \section{Count subfloats}%
346 % \label{sec:count}%
347 % \changes{2.10}{2002/09/06}{Add counting of subfloats}%
348 %
349 % If the package option |countmax| is used the package counts the
350 % number of all subfloats with the same main float number. This number
351 % is stored in the counters |subfloatfiguremax| resp.\
352 % |subfloattablemax| and can be used for changeing the labels, e.g.:
353 % \begin{verbatim}
354 % \renewcommand*\thesubfloatfigure{%
355 % \themainfigure(\arabic{subfloatfigure}/\arabic{subfloatfiguremax})}
356 % \end{verbatim}
357 % \changes{2.13}{2002/12/16}{Remove generation of error message
358 % because of incompatibility with tabularx}%
359 % If the package option is not set but |subfloatfiguremax| used an
360 % error messages is produced by \LaTeX. Normally there should be an
361 % error message of the following types:
362 % \begin{verbatim}
363 % ! Missing number, treated as zero.
364 % <to be read again>
365 % \c@subfloatfiguremax
366 % l.64 }
367 %
368 % ?
369 % \end{verbatim}
370 % or
371 % \begin{verbatim}
372 % ! Undefined control sequence.
373 % <write> ...abel{ressim2}{{I(b/\c@subfloattablemax
374 % )}{\thepage }{Estimation o...
375 % l.105 \end{document}
376 %
377 % ?
378 % \end{verbatim}
379 % There may be |\c@subfloatfiguremax| or |\c@subfloattablemax|.
380 % In a former version, |subfloat| has generated a nice error
381 % message. But unfortunately this code has been incompatible to
382 % |tabularx|.
383 %
384 % In order to get the numbers right \LaTeX\ has to be run twice or
385 % three times.\footnote{Internally, this is implemented using labels.
386 % After the first \LaTeX\ run, the counter is zero end thus not
387 % displayed for alpha or roman numbering.}
388 %
389 % \section{Command reference}
390 % This sections gives a short list of the main commands and environments
391 % of this package.
392 %
393 % \begin{longtable}[l]{@{}p{0.3\linewidth}@{}p{0.7\linewidth}@{}}
394 % \hline
395 % \textbf{environment}&\textbf{description}\\
396 % \hline
397 % \texttt{subfigures}&Increases the figure number by one and starts
398 % subnumbering by appending a, b, c, \dots to the fixed figure number\\
399 % \texttt{subtables}&Increases the table number by one and starts
400 % subnumbering by appending a, b, c, \dots to the fixed table number\\
401 % \hline
402 % \end{longtable}
403 % \begin{longtable}[l]{@{}p{0.3\linewidth}@{}p{0.7\linewidth}@{}}
404 % \hline
405 % \textbf{macro}&\textbf{description}\\
406 % \hline
407 % \texttt{\bslash subfiguresbegin}&Increases the figure number by one
408 % and starts subnumbering by appending a, b, c, \dots to the fixed figure
409 % number\\
410 % \texttt{\bslash subfiguresend}&Returns to ordinary figure numbering\\
411 % \texttt{\bslash subtablesbegin}&Increases the table number by one and starts
412 % subnumbering by appending a, b, c, \dots to the fixed table number\\
413 % \texttt{\bslash subtablesend}&Returns to ordinary table numbering\\
414 % \hline
415 % \texttt{\bslash thesubfloatfigure}& Defines the output format of the
416 % main and subfigure number.\\
417 % \texttt{\bslash themainfigure}& Number of the main figure\\
418 % \texttt{\bslash thesubfloattable}& Defines the output format of the
419 % main and subtable number.\\
420 % \texttt{\bslash themaintable}& Number of the main table\\
421 % \hline
422 % \end{longtable}
423 %
424 %
425 % \section*{To do}
426 %
427 % At the moment, I don't know anything.
428 %
429 % \section*{Acknowledgements}
430 %
431 % Thanks to Frank Mittelbach who had the idea to make the label
432 % changeable. Furthermore, he helped to develop a user friendly
433 % interface to do this.
434 %
435 % \StopEventually{\PrintChanges \PrintIndex}
436 %
437 % \section{The implementation}
438 % \iffalse
439 %<*package>
440 % \fi
441 % Heading of the package:
442 % \begin{macrocode}
443 \NeedsTeXFormat{LaTeX2e}
444 \ProvidesPackage{subfloat}
445 [\filedate\space version \fileversion]
446 \message{Package `subfloat', Version \fileversion\space of \filedate.}
447 % \end{macrocode}
448 %
449 % \subsection{Options}%
450 % \changes{2.10}{2002/09/06}{Add counting of subfloats}%
451 %
452 % \begin{macrocode}
453 \newif\ifsubfloat@countmax
454 % \end{macrocode}
455 % Option to count the floats.
456 % \changes{2.13}{2002/12/16}{Remove generation of error message
457 % because of incompatibility with tabularx}%
458 % \changes{2.14}{2003/08/21}{Moved warning outside options}%
459 % \begin{macrocode}
460 \DeclareOption{countmax}{\subfloat@countmaxtrue}
461 \DeclareOption{nocountmax}{\subfloat@countmaxfalse}%
462 % \end{macrocode}
463 % \begin{macrocode}
464 \ExecuteOptions{nocountmax}
465 % \end{macrocode}
466 % \begin{macrocode}
467 \ProcessOptions\relax
468 % \end{macrocode}
469 %
470 % \subsection{Figures}
471 %
472 % \begin{macro}{\thesubfloatfigure}%
473 % Defining the output format of captions:
474 % \begin{macrocode}
475 \newcommand*\thesubfloatfigure{\themainfigure\alph{subfloatfigure}}
476 % \end{macrocode}
477 % \end{macro}
478 %
479 % \begin{environment}{subfigures}%
480 % Defining the environment |subfigures|:
481 % \begin{macrocode}
482 \newenvironment{subfigures}{%
483 % \end{macrocode}
484 % Call start command for subnumbering:
485 % \begin{macrocode}
486 \subfiguresbegin
487 }{%
488 % \end{macrocode}
489 % Call end command for subnumbering:
490 % \begin{macrocode}
491 \subfiguresend
492 \global\@ignoretrue
493 }
494 % \end{macrocode}
495 % \end{environment}
496 %
497 % Make a copy of |\c@figure| in |\c@subfloatfigure| in order to be
498 % able to use the counter |subfloatfigure| in the defintion of
499 % |\thesubfloatfigure|:
500 % \begin{macrocode}
501 \let\c@subfloatfigure=\c@figure
502 % \end{macrocode}
503 % Define the boolean |\ifinsubfloatfigures| to determine if we are
504 % inside a subfloatfigures area:
505 % \changes{2.11}{2002/09/10}{Test for nesting of subfloatfigure areas}%
506 % \begin{macrocode}
507 \newif\ifinsubfloatfigures
508 % \end{macrocode}
509 % \begin{macro}{\thefiguresbegin}%
510 % Defining the macro |\thefiguresbegin|:
511 % \begin{macrocode}
512 \newcommand{\subfiguresbegin}{%
513 % \end{macrocode}
514 % Check if |\subfiguresbegin| may be called here:
515 % \changes{2.11}{2002/09/10}{Test for nesting of subfloatfigure areas}%
516 % \begin{macrocode}
517 \ifinsubfloatfigures
518 \PackageError{subfloat}{Cannot start subfloatfigures inside
519 a\MessageBreak subfloatfigure area}{You probably have used
520 \string\subfiguresbegin\space or \string\begin{subfigures} inside
521 the^^Jsame environment or after \string\subfiguresbegin.}%
522 \fi
523 % \end{macrocode}
524 % Set testing boolean to true:
525 % \changes{2.11}{2002/09/10}{Test for nesting of subfloatfigure areas}%
526 % \begin{macrocode}
527 \global\insubfloatfigurestrue
528 % \end{macrocode}
529 % Increase figure number:
530 % \begin{macrocode}
531 \refstepcounter{figure}%
532 % \end{macrocode}
533 % Save value of counter |figure|:
534 % \begin{macrocode}
535 \protected@xdef\figure@value{\the\c@figure}%
536 % \end{macrocode}
537 % Save counter |figure| in printed format:
538 % \begin{macrocode}
539 \protected@xdef\themainfigure{\thefigure}%
540 % \end{macrocode}
541 % Save the original macro |\thefigure|:
542 % \begin{macrocode}
543 \global\let\thefigure@original=\thefigure
544 % \end{macrocode}
545 % Reset counter |figure| to zero.
546 % It functions as subfloat counter until |\subfiguresend|.
547 % \begin{macrocode}
548 \setcounter{figure}{0}%
549 % \end{macrocode}
550 % Redefine macro |\thefigure| to use subnumbering:
551 % \begin{macrocode}
552 \gdef\thefigure{\thesubfloatfigure}%
553 % \end{macrocode}
554 % Set counter to maximal number of subfloatfigures. Therefore local
555 % redefinition of |\@setref| in order to change the warning and to set
556 % the counter |subfloatfiguremax| correct. Thereafter call |\@setref|
557 % using the |\ref| command:
558 % \changes{2.10}{2002/09/06}{Add counting of subfloats}%
559 % \begin{macrocode}
560 \ifsubfloat@countmax
561 {\def\@setref##1##2##3{%
562 \ifx##1\relax
563 \protect\G@refundefinedtrue
564 \setcounter{subfloatfiguremax}{0}%
565 \PackageWarningNoLine{subfloat}{Reference `##3' on page
566 \thepage \space undefined\MessageBreak
567 (count subfloatfigures)}%
568 \else
569 \setcounter{subfloatfiguremax}{\expandafter\@firstoftwo##1}%
570 \fi}%
571 \ref{subfloat@@figure\figure@value}}%
572 \fi
573 % \end{macrocode}
574 % Redefine the macro |\p@subfigure| (from |subfigure.sty|) in order to
575 % generate correct labels for subfigures:
576 % \changes{2.01}{2002/09/06}{Add support for subfigure.sty}%
577 % \begin{macrocode}
578 %% \@ifpackageloaded{subfigure}{%
579 \let\p@subfigure=\thesubfloatfigure
580 %% }{}%
581 % \end{macrocode}
582 % Ignore spaces:
583 % \begin{macrocode}
584 \ignorespaces
585 }
586 % \end{macrocode}
587 % \end{macro}
588 % \begin{macro}{\thefiguresend}
589 % Defining the macro |\thefiguresend|:
590 % \begin{macrocode}
591 \newcommand{\subfiguresend}{%
592 % \end{macrocode}
593 % Check if |\subfiguresend| may be called here:
594 % \changes{2.11}{2002/09/10}{Test for nesting of subfloatfigure areas}%
595 % \begin{macrocode}
596 \ifinsubfloatfigures
597 \else
598 \PackageError{subfloat}{Cannot stop subfloatfigures outside
599 a\MessageBreak subfloatfigure area}{You probably have used
600 \string\subfiguresend\space or \string\end{subfigures} without
601 starting a^^Jsubfloatfigure area using the same environment or
602 \string\subfiguresbegin.}%
603 \fi
604 % \end{macrocode}
605 % Set testing boolean to false:
606 % \changes{2.11}{2002/09/10}{Test for nesting of subfloatfigure areas}%
607 % \begin{macrocode}
608 \global\insubfloatfiguresfalse
609 % \end{macrocode}
610 % Write the number of subfloatfigures into the |aux| file:
611 % \changes{2.10}{2002/09/06}{Add counting of subfloats}%
612 % \begin{macrocode}
613 \ifsubfloat@countmax
614 \subfloat@figurelabel{subfloat@@figure\figure@value}%
615 \fi
616 % \end{macrocode}
617 % Set counter |figure| back to original value:
618 % \begin{macrocode}
619 \setcounter{figure}{\figure@value}%
620 % \end{macrocode}
621 % Restore the original macro |\thefigure|:
622 % \begin{macrocode}
623 \global\let\thefigure=\thefigure@original
624 % \end{macrocode}
625 % Restore the original macro |\p@subfigure| (from |subfigure.sty|):
626 % \changes{2.01}{2002/09/06}{Add support for subfigure.sty}%
627 % \begin{macrocode}
628 %% \@ifpackageloaded{subfigure}{%
629 \let\p@subfigure=\thefigure
630 %% }{}%
631 % \end{macrocode}
632 % Ignore spaces:
633 % \begin{macrocode}
634 \ignorespaces
635 }
636 %%
637 % \end{macrocode}
638 % \end{macro}
639 %
640 % Introduce the counter for the number of subfloatfigures.
641 % If both the option |countmax| is not used and this counter is tried
642 % to be used, an not understandable error message is generated (e.g.\
643 % ``! Missing number, treated as zero''. There has been code that
644 % produced a nice error message, but it was incompatible to tabularx
645 % (namely the command |\cl@@ckpt|).
646 % \changes{2.10}{2002/09/06}{Add counting of subfloats}%
647 % \changes{2.13}{2002/12/16}{Remove generation of error message
648 % because of incompatibility with tabularx}%
649 % \begin{macrocode}
650 \ifsubfloat@countmax
651 \newcounter{subfloatfiguremax}
652 \else
653 % \end{macrocode}
654 % \changes{2.14}{2003/08/21}{Moved warning outside options}%
655 % Warning if countmax is off.
656 % \begin{macrocode}
657 \PackageWarningNoLine{subfloat}{Numbers of floats not
658 counted:\MessageBreak
659 If you use one of the counters subfloatfiguremax or\MessageBreak
660 subfloattablemax you will get strange error messages\MessageBreak
661 containing \string\c@subfloatfiguremax\space or\MessageBreak
662 \string\c@subfloattablemax:\MessageBreak
663 Please switch on countmax or
664 remove the code using\MessageBreak
665 the counter then.}
666 \fi
667 % \end{macrocode}
668 % \begin{macro}{\subfloat@figurelabel}
669 % This command makes a label for the current figure, always with an
670 % arabic number:
671 % \changes{2.10}{2002/09/06}{Add counting of subfloats}%
672 % \begin{macrocode}
673 \ifsubfloat@countmax
674 \newcommand*\subfloat@figurelabel[1]{\@bsphack
675 \protected@write\@auxout{}%
676 {\string\newlabel{#1}{{\the\c@figure}{\thepage}}}%
677 \@esphack}
678 \fi
679 % \end{macrocode}
680 % \end{macro}
681 %
682 % \subsection{Tables}
683 %
684 % \begin{macro}{\thesubfloattable}%
685 % Defining the output format of captions:
686 % \begin{macrocode}
687 \newcommand*\thesubfloattable{\themaintable\alph{subfloattable}}
688 % \end{macrocode}
689 % \end{macro}
690 %
691 % \begin{environment}{subtables}%
692 % Defining the environment |subtables|:
693 % \begin{macrocode}
694 \newenvironment{subtables}{%
695 % \end{macrocode}
696 % Call start command for subnumbering:
697 % \begin{macrocode}
698 \subtablesbegin
699 }{%
700 % \end{macrocode}
701 % Call end command for subnumbering:
702 % \begin{macrocode}
703 \subtablesend
704 \global\@ignoretrue
705 }
706 % \end{macrocode}
707 % \end{environment}
708 %
709 % Make a copy of |\c@table| in |\c@subfloattable| in order to be
710 % able to use the counter |subfloattable| in the defintion of
711 % |\thesubfloattable|:
712 % \begin{macrocode}
713 \let\c@subfloattable=\c@table
714 % \end{macrocode}
715 % Define the boolean |\ifinsubfloattables| to determine if we are
716 % inside a subfloattables area:
717 % \changes{2.11}{2002/09/10}{Test for nesting of subfloattable areas}%
718 % \begin{macrocode}
719 \newif\ifinsubfloattables
720 % \end{macrocode}
721 % \begin{macro}{\thetablesbegin}%
722 % Defining the macro |\thetablesbegin|:
723 % \begin{macrocode}
724 \newcommand{\subtablesbegin}{%
725 % \end{macrocode}
726 % Check if |\subtablesbegin| may be called here:
727 % \changes{2.11}{2002/09/10}{Test for nesting of subfloattable areas}%
728 % \begin{macrocode}
729 \ifinsubfloattables
730 \PackageError{subfloat}{Cannot start subfloattables inside
731 a\MessageBreak subfloatfigure area}{You probably have used
732 \string\subtablesbegin\space or \string\begin{subtables} inside
733 the^^Jsame environment or after \string\subtablesbegin.}%
734 \fi
735 % \end{macrocode}
736 % Set testing boolean to true:
737 % \changes{2.11}{2002/09/10}{Test for nesting of subfloattable areas}%
738 % \begin{macrocode}
739 \global\insubfloattablestrue
740 % \end{macrocode}
741 % Increase table number:
742 % \begin{macrocode}
743 \refstepcounter{table}%
744 % \end{macrocode}
745 % Save value of counter |table|:
746 % \begin{macrocode}
747 \protected@xdef\table@value{\the\c@table}%
748 % \end{macrocode}
749 % Save counter |table| in printed format:
750 % \begin{macrocode}
751 \protected@xdef\themaintable{\thetable}%
752 % \end{macrocode}
753 % Save the original macro |\thetable|:
754 % \begin{macrocode}
755 \global\let\thetable@original=\thetable
756 % \end{macrocode}
757 % Reset counter |table| to zero. It functions as subfloat counter
758 % until |\subtablesend|.
759 % \begin{macrocode}
760 \setcounter{table}{0}%
761 % \end{macrocode}
762 % Redefine macro |\thetable| to use subnumbering:
763 % \begin{macrocode}
764 \gdef\thetable{\thesubfloattable}%
765 % \end{macrocode}
766 % Set counter to maximal number of subfloattables. Therefore local
767 % redefinition of |\@setref| in order to change the warning and to set
768 % the counter |subfloattablemax| correct. Thereafter call |\@setref|
769 % using the |\ref| command:
770 % \changes{2.10}{2002/09/06}{Add counting of subfloats}%
771 % \begin{macrocode}
772 \ifsubfloat@countmax
773 {\def\@setref##1##2##3{%
774 \ifx##1\relax
775 \protect\G@refundefinedtrue
776 \setcounter{subfloattablemax}{0}%
777 \PackageWarningNoLine{subfloat}{Reference `##3' on page
778 \thepage \space undefined\MessageBreak
779 (count subfloattables)}%
780 \else
781 \setcounter{subfloattablemax}{\expandafter\@firstoftwo##1}%
782 \fi}%
783 \ref{subfloat@@table\table@value}}%
784 \fi
785 % \end{macrocode}
786 % Redefine the macro |\p@subtable| (from |subfigure.sty|) in order to
787 % generate correct labels for subtables:
788 % \changes{2.01}{2002/09/06}{Add support for subfigure.sty}%
789 % \begin{macrocode}
790 %% \@ifpackageloaded{subfigure}{%
791 \let\p@subtable=\thesubfloattable
792 %% }{}%
793 % \end{macrocode}
794 % Ignore spaces:
795 % \begin{macrocode}
796 \ignorespaces
797 }
798 % \end{macrocode}
799 % \end{macro}
800 % \begin{macro}{\subtablesend}
801 % \changes{2.12}{2002/10/30}{Remove the corrupt greater sign}%
802 % Defining the macro |\thetablesend|:
803 % \begin{macrocode}
804 \newcommand{\subtablesend}{%
805 % \end{macrocode}
806 % Check if |\subtablesend| may be called here:
807 % \changes{2.11}{2002/09/10}{Test for nesting of subfloatfigure areas}%
808 % \begin{macrocode}
809 \ifinsubfloattables
810 \else
811 \PackageError{subfloat}{Cannot stop subfloattables outside
812 a\MessageBreak subfloatfigure area}{You probably have used
813 \string\subtablesend\space or \string\end{subtables} without
814 starting a^^Jsubfloatfigure area using the same environment or
815 \string\subtablesbegin.}%
816 \fi
817 % \end{macrocode}
818 % Set testing boolean to false:
819 % \changes{2.11}{2002/09/10}{Test for nesting of subfloatfigure areas}%
820 % \begin{macrocode}
821 \global\insubfloattablesfalse
822 % \end{macrocode}
823 % Write the number of subfloattables into the |aux| file:
824 % \changes{2.10}{2002/09/06}{Add counting of subfloats}%
825 % \begin{macrocode}
826 \ifsubfloat@countmax
827 \subfloat@tablelabel{subfloat@@table\table@value}%
828 \fi
829 % \end{macrocode}
830 % Set counter |table| back to original value:
831 % \begin{macrocode}
832 \setcounter{table}{\table@value}%
833 % \end{macrocode}
834 % Restore the original macro |\thetable|:
835 % \begin{macrocode}
836 \global\let\thetable=\thetable@original
837 % \end{macrocode}
838 % Restore the original macro |\p@subtable| (from |subfigure.sty|):
839 % \changes{2.01}{2002/09/06}{Add support for subfigure.sty}%
840 % \begin{macrocode}
841 %% \@ifpackageloaded{subfigure}{%
842 \let\p@subtable=\thetable
843 %% }{}%
844 % \end{macrocode}
845 % Ignore spaces:
846 % \begin{macrocode}
847 \ignorespaces
848 }
849 %%
850 % \end{macrocode}
851 % \end{macro}
852 %
853 % Introduce the counter for the number of subfloattables.
854 % If both the option |countmax| is not used and this counter is tried
855 % to be used, an not understandable error message is generated (e.g.\
856 % ``! Missing number, treated as zero''. There has been code that
857 % produced a nice error message, but it was incompatible to tabularx
858 % (namely the command |\cl@@ckpt|).
859 % \changes{2.10}{2002/09/06}{Add counting of subfloats}%
860 % \changes{2.13}{2002/12/16}{Remove generation of error message
861 % because of incompatibility with tabularx}%
862 % \begin{macrocode}
863 \ifsubfloat@countmax
864 \newcounter{subfloattablemax}
865 %\else
866 % \newcounter{subfloattablemax}
867 % \let\orig@c@subfloattablemax=\c@subfloattablemax
868 % \def\c@subfloattablemax{\orig@c@subfloattablemax
869 % \PackageError{subfloat}{Counter subfloattablemax used
870 % without\MessageBreak
871 % package option countmax}{The counter subfloattablemax may
872 % only be used with the package option\MessageBreak
873 % countmax. Normally this error happens when
874 % \string\thesubfloattable\space is redefined.}}
875 \fi
876 % \end{macrocode}
877 % \begin{macro}{\subfloat@tablelabel}
878 % This command makes a label for the current table, always with an
879 % arabic number:
880 % \changes{2.10}{2002/09/06}{Add counting of subfloats}%
881 % \begin{macrocode}
882 \ifsubfloat@countmax
883 \newcommand*\subfloat@tablelabel[1]{\@bsphack
884 \protected@write\@auxout{}%
885 {\string\newlabel{#1}{{\the\c@table}{\thepage}}}%
886 \@esphack}
887 \fi
888 % \end{macrocode}
889 % \end{macro}
890 %
891 % The end of the package:
892 % \begin{macrocode}
893 \endinput
894 % \end{macrocode}
895 % \iffalse
896 %</package>
897 % \fi
898 % \Finale
899