summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/subfloat/subfloat.dtx
blob: 37d6c9af67a6df066a18a574dc95077d36d7f80a (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
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
% \iffalse meta comment
% File: subfloat.dtx Copyright (C) 1999 Harald Harders
% \fi
%
% \iffalse
%
%<*package>
\def\packagename{subfloat}
\def\fileversion{2.14}
\def\filedate{2003/08/21}
\def\docdate{2003/08/21}
%</package>
%<*driver>
\documentclass{ltxdoc}
\IfFileExists{subfloat.sty}{\usepackage{subfloat}
 \let\subfloatSTYfound\active}{\GenericWarning{subfloat.dtx}{Package
 file subfloat.sty not found (Documentation will be messed up!^^J^^A
 Generate subfloat.sty by (La)TeXing subfloat.ins, process
 subfloat.dtx again)^^J}\stop}
\usepackage{longtable}
\title{The \texttt{subfloat} package\thanks{This file has version 
    \fileversion\ last revised \filedate, documentation dated \docdate.}}
\author{Harald Harders\\\texttt{h.harders@tu-bs.de}}
\date{File Date \filedate, Printed \today}
\newlength{\tempdima}%
\makeatletter
\renewenvironment{table}[1][]{%
  \@float{table}[#1]%
  \centering%
  \setlength{\tempdima}{\abovecaptionskip}%
  \setlength{\abovecaptionskip}{\belowcaptionskip}%
  \setlength{\belowcaptionskip}{\tempdima}%
  }{%
\end@float
}
\makeatother
\EnableCrossrefs
\CodelineIndex
\DoNotIndex{\def,\edef,\let,\newcommand,\newenvironment,\newcounter}
\DoNotIndex{\setcounter,\space,\endinput,\@auxout,\@bsphack,\@esphack}
\DoNotIndex{\@firstoftwo,\if,\else,\fi,\ifnum,\fi,\ifx,\fi,\MessageBreak}
\DoNotIndex{\relax,\string,\thepage,\@ifpackageloaded,\expandafter}
\DoNotIndex{\message,\newif,\protect,\protected@write}
\CodelineNumbered
\RecordChanges
\CheckSum{280}
\setcounter{topnumber}{5}
\setcounter{bottomnumber}{1}
\setcounter{totalnumber}{6}
\begin{document}
 \DocInput{subfloat.dtx}
\end{document}
%</driver>
% \fi
%
% \changes{1.01}{1999/06/08}{Documentation improved}
% \changes{1.02}{1999/06/08}{Error in change history corrected}
% \changes{1.03}{1999/10/08}{email address changed}
% \changes{1.04}{2002/08/18}{Suggestions made by Frank Mittelbach 
%   implemented: Changes in implementation, macros to change label format}
% \changes{2.00}{2002/09/06}{Total new implementation of the package
%   with help of Frank Mittelbach}
% \changes{2.12}{2002/10/30}{Correct a typo (thanks to Michael M\"uller)}%
% \maketitle
% \begin{abstract}
% \noindent This package enables subnumbering of floats (figures and
% tables) similar to the subequations environment of the amsmath
% package. It does not the same as the subfigure package which
% generates subfigures within one normal figure.
% \end{abstract}
%
% \tableofcontents
%
% \section*{Copyright}
% Copyright  1999, 2002 Harald Harders.
%
% This program can be redistributed and/or modified under the terms
% of the LaTeX Project Public License Distributed from CTAN
% archives in directory macros/latex/base/lppl.txt; either
% version 1 of the License, or any later version.
%
% \section{Introduction}
% Sometimes two or more floats (figures or tables) belong together in a
% way you should not use different caption numbers for them. 
% With a subnumbering like that of the amsmath package for equations
% it is possible to point out the connection of the floats.
% This package provides two environments and four macros to achive
% subnumbering of floats.
% It is possible to change the caption labels.
%
% In case of problems or bugs please send an email to my address
% printed on the title page.
%
% \section{The user interface}
%
% To use this package place
% \begin{verbatim}
% \usepackage{subfloat}
% \end{verbatim}
% in the preamble of your document.
% No options are necessary.
%
% \changes{2.10}{2002/09/06}{Add counting of subfloats}%
% If you want to be able to count the number of subfloats with the
% same main number you have to add the package option |countmax|:
% \begin{verbatim}
% \usepackage[countmax]{subfloat}
% \end{verbatim}
% For more description to counting see section~\ref{sec:count}.
%
% \subsection{Environments}
% \DescribeEnv{subfigures}
% Put
% \begin{verbatim}
% \begin{subfigures}
% \end{subfigures}
% \end{verbatim}
% around the figures which belong together.
% By default, they get the same figure number with an increasing
% lowercase character added. 
% \DescribeEnv{subtables}
% In the same way you can put
% \begin{verbatim}
% \begin{subtables}
% \end{subtables}
% \end{verbatim}
% around tables. The macros for the environments have to be placed outside
% the picture or table environments.
%
% \subsection{Macros}
% \DescribeMacro{\subfiguresbegin}
% \DescribeMacro{\subfiguresend}
% Instead using of the environments it is possible to use adequate macros:
% \begin{verbatim}
% \subfiguresbegin
% \subfiguresend
% \end{verbatim}
% \DescribeMacro{\subtablesbegin}
% \DescribeMacro{\subtablesend}
% or
% \begin{verbatim}
% \subtablesbegin
% \subtablesend
% \end{verbatim}
%
% Put these macros in place of the environment macros. The macros are
% necessary to be able to nest subnumbered figures and tables.
%
% If you put labels inside the figure and table environments the subfloat
% label numberes are referenced. 
% If you want a reference to the common figure or table number place a 
% label right after the |\begin{subfigures}|, |\subfiguresbegin|, 
% |\begin{subtables}|, or |\subtablesbegin| command.
% 
% \section{Examples}
% \subsection{Using the environments}
%
% \DescribeEnv{subfigures}
% The code
% \begin{verbatim}
% \begin{subfigures}
% \label{fig:fig1a2}
% %
% \begin{figure}\centering
%   \fbox{fig. 1}
%   \caption{This is the first figure}\label{fig:fig1}
% \end{figure}
% %
% \begin{figure}\centering
%   \fbox{fig. 2}
%   \caption{This is the second figure}\label{fig:fig2}
% \end{figure}
% %
% \end{subfigures}
% \end{verbatim}
% produces the output of the figures~\ref{fig:fig1a2} 
% (figure~\ref{fig:fig1} and figure~\ref{fig:fig2}).
% References are made as usual with
% e.\,g. |\ref{fig:fig1}|.
% %
% \begin{subfigures}
% \label{fig:fig1a2}
% %
% \begin{figure}\centering
%   \fbox{fig. 1}
%   \caption{This is the first figure}\label{fig:fig1}
% \end{figure}
% %
% \begin{figure}\centering
%   \fbox{fig. 2}
%   \caption{This is the second figure}\label{fig:fig2}
% \end{figure}
% %
% \end{subfigures}
%
% \DescribeEnv{subtables}
% The output of the tables~\ref{tab:tab1} and \ref{tab:tab1} is
% generated similarly:
% \begin{verbatim}
% \begin{subtables}
% %
% \begin{table}\centering
%   \caption{This is the first table}\label{tab:tab1}
%   \begin{tabular}{l} \hline
%   table 1\\ \hline
%   \end{tabular}
% \end{table}
% %
% \begin{table}\centering
%   \caption{This is the second table}\label{tab:tab2}
%   \begin{tabular}{l} \hline
%   table 2\\ \hline
%   \end{tabular}
% \end{table}
% %
% \end{subtables}
% \end{verbatim}
% %
% \begin{subtables}
% %
% \begin{table}\centering
%   \caption{This is the first table}\label{tab:tab1}
%   \begin{tabular}{l} \hline
%   table 1\\ \hline
%   \end{tabular}
% \end{table}
% %
% \begin{table}\centering
%   \caption{This is the second table}\label{tab:tab2}
%   \begin{tabular}{l} \hline
%   table 2\\ \hline
%   \end{tabular}
% \end{table}
% %
% \end{subtables}
%
% The environment names |subfigures| and |subtables| were
% chosen to be similar to the |subequations| environment of the
% amsmath package. But what is to do when both environments have to be
% nested? This case is handled in the next section.
% 
% \subsection{Using the macros}
% \DescribeMacro{\subfiguresbegin}
% \DescribeMacro{\subfiguresend}
% \DescribeMacro{\subtablesbegin}
% \DescribeMacro{\subtablesend}
% The usage of the macros is shown in the example below:
% \begin{verbatim}
% \subfiguresbegin
% \begin{figure}
% [...]
% \begin{table}
% [...]
% \subtablesbegin
% \begin{table}
% [...]
% \begin{figure}
% [...]
% \subfiguresend
% \begin{figure}
% [...]
% \begin{table}
% [...]
% \subtablesend
% \end{verbatim}
% %
% \subfiguresbegin
% %
% \begin{figure}\centering
%   \fbox{fig. 3}
%   \caption{This is the third figure}\label{fig:fig3}
% \end{figure}
% %
% \begin{table}\centering
%   \caption{This is the third table}\label{tab:tab3}
%   \begin{tabular}{l} \hline
%   table 3\\ \hline
%   \end{tabular}
% \end{table}
%
% \subtablesbegin
% %
% \begin{table}\centering
%   \caption{This is the forth table}\label{tab:tab4}
%   \begin{tabular}{l} \hline
%   table 4\\ \hline
%   \end{tabular}
% \end{table}
% %
% \begin{figure}\centering
%   \fbox{fig. 4}
%   \caption{This is the forth figure}\label{fig:fig4}
% \end{figure}
% %
% \subfiguresend
% %
% \begin{figure}\centering
%   \fbox{fig. 5}
%   \caption{This is the fifth figure}\label{fig:fig5}
% \end{figure}
% %
% \begin{table}\centering
%   \caption{This is the fifth table}\label{tab:tab5}
%   \begin{tabular}{l} \hline
%   table 5\\ \hline
%   \end{tabular}
% \end{table}
% %
% \subtablesend
% 
% With these macros it is possible to realise nested subnumbers of
% figures and tables. Even nested subnumbers of figures or tables and
% equations made with the subequations environment of the amsmath
% package are possible.
% 
% \section{Change the label format}
%
% The standard label format is the global float number followed by a
% lowercase alphanumerical subfloat number.
% This can be changed by redefining the commands |\thesubfloatfigure|
% and |\thesubfloattable|.
% Both define the whole float number including the main number. 
% The main number is referred by |\themainfigure| resp.\
% |\themaintable|. 
% The counters of the subfloats are |subfloatfigure| resp.\
% |subfloattable|.
% The default values are:
% \begin{verbatim}
% \newcommand*\thesubfloatfigure{\themainfigure\alph{subfloatfigure}}
% \newcommand*\thesubfloattable{\themaintable\alph{subfloattable}}
% \end{verbatim}
% If you want to print the subnumber of figures in brackets, you may
% define this:
% \begin{verbatim}
% \renewcommand*\thesubfloatfigure{\themainfigure(\alph{subfloatfigure})}
% \end{verbatim}
% If you want a sublabel in the format 1--1, 1--2, \dots\ you can
% get it by the following command sequence:
% \begin{verbatim}
% \renewcommand*\thesubfloatfigure{\themainfigure--\arabic{subfloatfigure}}
% \end{verbatim}
%
% Since it is done the same for tables this it not described again.
%
% \section{Count subfloats}%
% \label{sec:count}%
% \changes{2.10}{2002/09/06}{Add counting of subfloats}%
%
% If the package option |countmax| is used the package counts the
% number of all subfloats with the same main float number. This number
% is stored in the counters |subfloatfiguremax| resp.\
% |subfloattablemax| and can be used for changeing the labels, e.g.:
% \begin{verbatim}
% \renewcommand*\thesubfloatfigure{%
%     \themainfigure(\arabic{subfloatfigure}/\arabic{subfloatfiguremax})}
% \end{verbatim}
% \changes{2.13}{2002/12/16}{Remove generation of error message
%   because of incompatibility with tabularx}%
% If the package option is not set but |subfloatfiguremax| used an
% error messages is produced by \LaTeX. Normally there should be an
% error message of the following types:
% \begin{verbatim}
% ! Missing number, treated as zero.
% <to be read again> 
%                    \c@subfloatfiguremax 
% l.64        }
%              
% ? 
% \end{verbatim}
% or
% \begin{verbatim}
% ! Undefined control sequence.
% <write> ...abel{ressim2}{{I(b/\c@subfloattablemax 
%                                                   )}{\thepage }{Estimation o...
% l.105 \end{document}
%                     
% ? 
% \end{verbatim}
% There may be |\c@subfloatfiguremax| or |\c@subfloattablemax|.
% In a former version, |subfloat| has generated a nice error
% message. But unfortunately this code has been incompatible to
% |tabularx|.
%
% In order to get the numbers right \LaTeX\ has to be run twice or
% three times.\footnote{Internally, this is implemented using labels.
%   After the first \LaTeX\ run, the counter is zero end thus not
%   displayed for alpha or roman numbering.}
%
% \section{Command reference}
% This sections gives a short list of the main commands and environments 
% of this package.
%
% \begin{longtable}[l]{@{}p{0.3\linewidth}@{}p{0.7\linewidth}@{}}
% \hline
% \textbf{environment}&\textbf{description}\\
% \hline
% \texttt{subfigures}&Increases the figure number by one and starts
% subnumbering by appending a, b, c, \dots to the fixed figure number\\
% \texttt{subtables}&Increases the table number by one and starts
% subnumbering by appending a, b, c, \dots to the fixed table number\\
% \hline
% \end{longtable}
% \begin{longtable}[l]{@{}p{0.3\linewidth}@{}p{0.7\linewidth}@{}}
% \hline
% \textbf{macro}&\textbf{description}\\
% \hline
% \texttt{\bslash subfiguresbegin}&Increases the figure number by one
% and starts subnumbering by appending a, b, c, \dots to the fixed figure
% number\\
% \texttt{\bslash subfiguresend}&Returns to ordinary figure numbering\\
% \texttt{\bslash subtablesbegin}&Increases the table number by one and starts
% subnumbering by appending a, b, c, \dots to the fixed table number\\
% \texttt{\bslash subtablesend}&Returns to ordinary table numbering\\
% \hline
% \texttt{\bslash thesubfloatfigure}& Defines the output format of the
% main and subfigure number.\\
% \texttt{\bslash themainfigure}& Number of the main figure\\
% \texttt{\bslash thesubfloattable}& Defines the output format of the
% main and subtable number.\\
% \texttt{\bslash themaintable}& Number of the main table\\
% \hline
% \end{longtable}
%
%
% \section*{To do}
%
% At the moment, I don't know anything.
%
% \section*{Acknowledgements}
% 
% Thanks to Frank Mittelbach who had the idea to make the label
% changeable. Furthermore, he helped to develop a user friendly
% interface to do this.
%
% \StopEventually{\PrintChanges \PrintIndex}
%
% \section{The implementation}
% \iffalse
%<*package>
% \fi
% Heading of the package:
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{subfloat}
         [\filedate\space version \fileversion]
\message{Package `subfloat', Version \fileversion\space of \filedate.}
%    \end{macrocode}
%
% \subsection{Options}%
% \changes{2.10}{2002/09/06}{Add counting of subfloats}%
%
%    \begin{macrocode}
\newif\ifsubfloat@countmax
%    \end{macrocode}
% Option to count the floats.
% \changes{2.13}{2002/12/16}{Remove generation of error message
%   because of incompatibility with tabularx}%
% \changes{2.14}{2003/08/21}{Moved warning outside options}%
%    \begin{macrocode}
\DeclareOption{countmax}{\subfloat@countmaxtrue}
\DeclareOption{nocountmax}{\subfloat@countmaxfalse}%
%    \end{macrocode}
%    \begin{macrocode}
\ExecuteOptions{nocountmax}
%    \end{macrocode}
%    \begin{macrocode}
\ProcessOptions\relax
%    \end{macrocode}
%
% \subsection{Figures}
%
% \begin{macro}{\thesubfloatfigure}%
% Defining the output format of captions:
%    \begin{macrocode}
\newcommand*\thesubfloatfigure{\themainfigure\alph{subfloatfigure}}
%    \end{macrocode}
% \end{macro}
%
% \begin{environment}{subfigures}%
% Defining the environment |subfigures|:
%    \begin{macrocode}
\newenvironment{subfigures}{%
%    \end{macrocode}
% Call start command for subnumbering:
%    \begin{macrocode}
  \subfiguresbegin
}{%
%    \end{macrocode}
% Call end command for subnumbering:
%    \begin{macrocode}
  \subfiguresend
  \global\@ignoretrue
}
%    \end{macrocode}
% \end{environment}
%
% Make a copy of |\c@figure| in |\c@subfloatfigure| in order to be
% able to use the counter |subfloatfigure| in the defintion of 
% |\thesubfloatfigure|:
%    \begin{macrocode}
\let\c@subfloatfigure=\c@figure
%    \end{macrocode}
% Define the boolean |\ifinsubfloatfigures| to determine if we are
% inside a subfloatfigures area:
% \changes{2.11}{2002/09/10}{Test for nesting of subfloatfigure areas}%
%    \begin{macrocode}
\newif\ifinsubfloatfigures
%    \end{macrocode}
% \begin{macro}{\thefiguresbegin}%
% Defining the macro |\thefiguresbegin|:
%    \begin{macrocode}
\newcommand{\subfiguresbegin}{%
%    \end{macrocode}
% Check if |\subfiguresbegin| may be called here:
% \changes{2.11}{2002/09/10}{Test for nesting of subfloatfigure areas}%
%    \begin{macrocode}
\ifinsubfloatfigures
  \PackageError{subfloat}{Cannot start subfloatfigures inside
    a\MessageBreak subfloatfigure area}{You probably have used
    \string\subfiguresbegin\space or \string\begin{subfigures} inside
      the^^Jsame environment or after \string\subfiguresbegin.}%
\fi
%    \end{macrocode}
% Set testing boolean to true:
% \changes{2.11}{2002/09/10}{Test for nesting of subfloatfigure areas}%
%    \begin{macrocode}
\global\insubfloatfigurestrue
%    \end{macrocode}
% Increase figure number:
%    \begin{macrocode}
  \refstepcounter{figure}%
%    \end{macrocode}
% Save value of counter |figure|:
%    \begin{macrocode}
  \protected@xdef\figure@value{\the\c@figure}%
%    \end{macrocode}
% Save counter |figure| in printed format:
%    \begin{macrocode}
  \protected@xdef\themainfigure{\thefigure}%
%    \end{macrocode}
% Save the original macro |\thefigure|:
%    \begin{macrocode}
  \global\let\thefigure@original=\thefigure
%    \end{macrocode}
% Reset counter |figure| to zero.
% It functions as subfloat counter until |\subfiguresend|.
%    \begin{macrocode}
  \setcounter{figure}{0}%
%    \end{macrocode}
% Redefine macro |\thefigure| to use subnumbering:
%    \begin{macrocode}
  \gdef\thefigure{\thesubfloatfigure}%
%    \end{macrocode}
% Set counter to maximal number of subfloatfigures. Therefore local
% redefinition of |\@setref| in order to change the warning and to set
% the counter |subfloatfiguremax| correct. Thereafter call |\@setref|
% using the |\ref| command:
% \changes{2.10}{2002/09/06}{Add counting of subfloats}%
%    \begin{macrocode}
  \ifsubfloat@countmax
    {\def\@setref##1##2##3{%
      \ifx##1\relax
        \protect\G@refundefinedtrue
        \setcounter{subfloatfiguremax}{0}%
        \PackageWarningNoLine{subfloat}{Reference `##3' on page
          \thepage \space undefined\MessageBreak
          (count subfloatfigures)}%
      \else
        \setcounter{subfloatfiguremax}{\expandafter\@firstoftwo##1}%
      \fi}%
    \ref{subfloat@@figure\figure@value}}%
  \fi
%    \end{macrocode}
% Redefine the macro |\p@subfigure| (from |subfigure.sty|) in order to
% generate correct labels for subfigures:
% \changes{2.01}{2002/09/06}{Add support for subfigure.sty}%
%    \begin{macrocode}
%%  \@ifpackageloaded{subfigure}{%
    \let\p@subfigure=\thesubfloatfigure
%%  }{}%
%    \end{macrocode}
% Ignore spaces:
%    \begin{macrocode}
  \ignorespaces
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\thefiguresend}
% Defining the macro |\thefiguresend|:
%    \begin{macrocode}
\newcommand{\subfiguresend}{%
%    \end{macrocode}
% Check if |\subfiguresend| may be called here:
% \changes{2.11}{2002/09/10}{Test for nesting of subfloatfigure areas}%
%    \begin{macrocode}
\ifinsubfloatfigures
\else
  \PackageError{subfloat}{Cannot stop subfloatfigures outside
    a\MessageBreak subfloatfigure area}{You probably have used
    \string\subfiguresend\space or \string\end{subfigures} without
      starting a^^Jsubfloatfigure area using the same environment or
      \string\subfiguresbegin.}%
\fi
%    \end{macrocode}
% Set testing boolean to false:
% \changes{2.11}{2002/09/10}{Test for nesting of subfloatfigure areas}%
%    \begin{macrocode}
\global\insubfloatfiguresfalse
%    \end{macrocode}
% Write the number of subfloatfigures into the |aux| file:
% \changes{2.10}{2002/09/06}{Add counting of subfloats}%
%    \begin{macrocode}
  \ifsubfloat@countmax
    \subfloat@figurelabel{subfloat@@figure\figure@value}%
  \fi
%    \end{macrocode}
% Set counter |figure| back to original value:
%    \begin{macrocode}
  \setcounter{figure}{\figure@value}%
%    \end{macrocode}
% Restore the original macro |\thefigure|:
%    \begin{macrocode}
  \global\let\thefigure=\thefigure@original
%    \end{macrocode}
% Restore the original macro |\p@subfigure| (from |subfigure.sty|):
% \changes{2.01}{2002/09/06}{Add support for subfigure.sty}%
%    \begin{macrocode}
%%  \@ifpackageloaded{subfigure}{%
    \let\p@subfigure=\thefigure
%%  }{}%
%    \end{macrocode}
% Ignore spaces:
%    \begin{macrocode}
  \ignorespaces
}
%%
%    \end{macrocode}
% \end{macro}
%
% Introduce the counter for the number of subfloatfigures. 
% If both the option |countmax| is not used and this counter is tried
% to be used, an not understandable error message is generated (e.g.\
% ``! Missing number, treated as zero''. There has been code that
% produced a nice error message, but it was incompatible to tabularx
% (namely the command |\cl@@ckpt|).
% \changes{2.10}{2002/09/06}{Add counting of subfloats}%
% \changes{2.13}{2002/12/16}{Remove generation of error message
%   because of incompatibility with tabularx}%
%    \begin{macrocode}
\ifsubfloat@countmax
  \newcounter{subfloatfiguremax}
\else
%    \end{macrocode}
% \changes{2.14}{2003/08/21}{Moved warning outside options}%
% Warning if countmax is off.
%    \begin{macrocode}
  \PackageWarningNoLine{subfloat}{Numbers of floats not
    counted:\MessageBreak
    If you use one of the counters subfloatfiguremax or\MessageBreak
    subfloattablemax you will get strange error messages\MessageBreak
    containing \string\c@subfloatfiguremax\space or\MessageBreak
    \string\c@subfloattablemax:\MessageBreak
    Please switch on countmax or
    remove the code using\MessageBreak
    the counter then.}
\fi
%    \end{macrocode}
% \begin{macro}{\subfloat@figurelabel}
% This command makes a label for the current figure, always with an
% arabic number:
% \changes{2.10}{2002/09/06}{Add counting of subfloats}%
%    \begin{macrocode}
\ifsubfloat@countmax
  \newcommand*\subfloat@figurelabel[1]{\@bsphack
    \protected@write\@auxout{}%
           {\string\newlabel{#1}{{\the\c@figure}{\thepage}}}%
    \@esphack}
\fi
%    \end{macrocode}
% \end{macro}
%
% \subsection{Tables}
%
% \begin{macro}{\thesubfloattable}%
% Defining the output format of captions:
%    \begin{macrocode}
\newcommand*\thesubfloattable{\themaintable\alph{subfloattable}}
%    \end{macrocode}
% \end{macro}
%
% \begin{environment}{subtables}%
% Defining the environment |subtables|:
%    \begin{macrocode}
\newenvironment{subtables}{%
%    \end{macrocode}
% Call start command for subnumbering:
%    \begin{macrocode}
  \subtablesbegin
}{%
%    \end{macrocode}
% Call end command for subnumbering:
%    \begin{macrocode}
  \subtablesend
  \global\@ignoretrue
}
%    \end{macrocode}
% \end{environment}
%
% Make a copy of |\c@table| in |\c@subfloattable| in order to be
% able to use the counter |subfloattable| in the defintion of 
% |\thesubfloattable|:
%    \begin{macrocode}
\let\c@subfloattable=\c@table
%    \end{macrocode}
% Define the boolean |\ifinsubfloattables| to determine if we are
% inside a subfloattables area:
% \changes{2.11}{2002/09/10}{Test for nesting of subfloattable areas}%
%    \begin{macrocode}
\newif\ifinsubfloattables
%    \end{macrocode}
% \begin{macro}{\thetablesbegin}%
% Defining the macro |\thetablesbegin|:
%    \begin{macrocode}
\newcommand{\subtablesbegin}{%
%    \end{macrocode}
% Check if |\subtablesbegin| may be called here:
% \changes{2.11}{2002/09/10}{Test for nesting of subfloattable areas}%
%    \begin{macrocode}
\ifinsubfloattables
  \PackageError{subfloat}{Cannot start subfloattables inside
    a\MessageBreak subfloatfigure area}{You probably have used
    \string\subtablesbegin\space or \string\begin{subtables} inside
      the^^Jsame environment or after \string\subtablesbegin.}%
\fi
%    \end{macrocode}
% Set testing boolean to true:
% \changes{2.11}{2002/09/10}{Test for nesting of subfloattable areas}%
%    \begin{macrocode}
\global\insubfloattablestrue
%    \end{macrocode}
% Increase table number:
%    \begin{macrocode}
  \refstepcounter{table}%
%    \end{macrocode}
% Save value of counter |table|:
%    \begin{macrocode}
  \protected@xdef\table@value{\the\c@table}%
%    \end{macrocode}
% Save counter |table| in printed format:
%    \begin{macrocode}
  \protected@xdef\themaintable{\thetable}%
%    \end{macrocode}
% Save the original macro |\thetable|:
%    \begin{macrocode}
  \global\let\thetable@original=\thetable
%    \end{macrocode}
% Reset counter |table| to zero. It functions as subfloat counter
% until |\subtablesend|.
%    \begin{macrocode}
  \setcounter{table}{0}%
%    \end{macrocode}
% Redefine macro |\thetable| to use subnumbering:
%    \begin{macrocode}
  \gdef\thetable{\thesubfloattable}%
%    \end{macrocode}
% Set counter to maximal number of subfloattables. Therefore local
% redefinition of |\@setref| in order to change the warning and to set
% the counter |subfloattablemax| correct. Thereafter call |\@setref|
% using the |\ref| command:
% \changes{2.10}{2002/09/06}{Add counting of subfloats}%
%    \begin{macrocode}
  \ifsubfloat@countmax
    {\def\@setref##1##2##3{%
      \ifx##1\relax
        \protect\G@refundefinedtrue
        \setcounter{subfloattablemax}{0}%
        \PackageWarningNoLine{subfloat}{Reference `##3' on page
          \thepage \space undefined\MessageBreak
          (count subfloattables)}%
      \else
        \setcounter{subfloattablemax}{\expandafter\@firstoftwo##1}%
      \fi}%
    \ref{subfloat@@table\table@value}}%
  \fi
%    \end{macrocode}
% Redefine the macro |\p@subtable| (from |subfigure.sty|) in order to
% generate correct labels for subtables:
% \changes{2.01}{2002/09/06}{Add support for subfigure.sty}%
%    \begin{macrocode}
%%  \@ifpackageloaded{subfigure}{%
    \let\p@subtable=\thesubfloattable
%%  }{}%
%    \end{macrocode}
% Ignore spaces:
%    \begin{macrocode}
  \ignorespaces
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\subtablesend}
% \changes{2.12}{2002/10/30}{Remove the corrupt greater sign}%
% Defining the macro |\thetablesend|:
%    \begin{macrocode}
\newcommand{\subtablesend}{%
%    \end{macrocode}
% Check if |\subtablesend| may be called here:
% \changes{2.11}{2002/09/10}{Test for nesting of subfloatfigure areas}%
%    \begin{macrocode}
\ifinsubfloattables
\else
  \PackageError{subfloat}{Cannot stop subfloattables outside
    a\MessageBreak subfloatfigure area}{You probably have used
    \string\subtablesend\space or \string\end{subtables} without
      starting a^^Jsubfloatfigure area using the same environment or
      \string\subtablesbegin.}%
\fi
%    \end{macrocode}
% Set testing boolean to false:
% \changes{2.11}{2002/09/10}{Test for nesting of subfloatfigure areas}%
%    \begin{macrocode}
\global\insubfloattablesfalse
%    \end{macrocode}
% Write the number of subfloattables into the |aux| file:
% \changes{2.10}{2002/09/06}{Add counting of subfloats}%
%    \begin{macrocode}
  \ifsubfloat@countmax
    \subfloat@tablelabel{subfloat@@table\table@value}%
  \fi
%    \end{macrocode}
% Set counter |table| back to original value:
%    \begin{macrocode}
  \setcounter{table}{\table@value}%
%    \end{macrocode}
% Restore the original macro |\thetable|:
%    \begin{macrocode}
  \global\let\thetable=\thetable@original
%    \end{macrocode}
% Restore the original macro |\p@subtable| (from |subfigure.sty|):
% \changes{2.01}{2002/09/06}{Add support for subfigure.sty}%
%    \begin{macrocode}
%%  \@ifpackageloaded{subfigure}{%
    \let\p@subtable=\thetable
%%  }{}%
%    \end{macrocode}
% Ignore spaces:
%    \begin{macrocode}
  \ignorespaces
}
%%
%    \end{macrocode}
% \end{macro}
%
% Introduce the counter for the number of subfloattables. 
% If both the option |countmax| is not used and this counter is tried
% to be used, an not understandable error message is generated (e.g.\
% ``! Missing number, treated as zero''. There has been code that
% produced a nice error message, but it was incompatible to tabularx
% (namely the command |\cl@@ckpt|).
% \changes{2.10}{2002/09/06}{Add counting of subfloats}%
% \changes{2.13}{2002/12/16}{Remove generation of error message
%   because of incompatibility with tabularx}%
%    \begin{macrocode}
\ifsubfloat@countmax
  \newcounter{subfloattablemax}
%\else
%  \newcounter{subfloattablemax}
%  \let\orig@c@subfloattablemax=\c@subfloattablemax
%  \def\c@subfloattablemax{\orig@c@subfloattablemax
%    \PackageError{subfloat}{Counter subfloattablemax used
%      without\MessageBreak
%      package option countmax}{The counter subfloattablemax may
%      only be used with the package option\MessageBreak
%      countmax. Normally this error happens when
%      \string\thesubfloattable\space is redefined.}} 
\fi
%    \end{macrocode}
% \begin{macro}{\subfloat@tablelabel}
% This command makes a label for the current table, always with an
% arabic number:
% \changes{2.10}{2002/09/06}{Add counting of subfloats}%
%    \begin{macrocode}
\ifsubfloat@countmax
  \newcommand*\subfloat@tablelabel[1]{\@bsphack
    \protected@write\@auxout{}%
           {\string\newlabel{#1}{{\the\c@table}{\thepage}}}%
    \@esphack}
\fi
%    \end{macrocode}
% \end{macro}
%
% The end of the package:
%    \begin{macrocode}
\endinput
%    \end{macrocode}
% \iffalse
%</package>
% \fi
% \Finale