summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/caption/subcaption.dtx
blob: 6a8d6b6e17ff37122c8cbc3e01b5e49f1a681f49 (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
% \iffalse meta-comment
% 
% This is file `subcaption.dtx'.
% 
% Copyright (C) 2007-2008 Axel Sommerfeldt (caption@sommerfee.de)
% 
% --------------------------------------------------------------------------
% 
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2003/12/01 or later.
% 
% This work has the LPPL maintenance status "maintained".
% 
% This Current Maintainer of this work is Axel Sommerfeldt.
% 
% This work consists of the files caption.ins, caption.dtx, caption2.dtx,
% ltcaption.dtx, and subcaption.dtx, the derived files caption.sty,
% caption2.sty, caption3.sty, ltcaption.sty, and subcaption.sty, and the
% user manuals caption-deu.tex, caption-eng.tex, and caption-rus.tex.
% 
% \fi
% \CheckSum{144}
%
% \iffalse
%<*driver>
\NeedsTeXFormat{LaTeX2e}[1994/12/01]
\ProvidesFile{subcaption.drv}[2008/01/12 v0.3 Adds a sub-caption feature to the caption package]
\hbadness=9999 \newcount\hbadness \hfuzz=74pt % Make TeX shut up.
%\errorcontextlines=3
%
\documentclass{ltxdoc}
\setlength\parindent{0pt}
\setlength\parskip{\smallskipamount}
%
\newcommand\LineBreak{\linebreak[3]}
\newcommand\PageBreak{\pagebreak[3]}
\usepackage{ifpdf}
\ifpdf
  \usepackage{mathptmx,courier}
  \usepackage[scaled=0.90]{helvet}
  \addtolength\marginparwidth{15pt}
  \ifdim\paperheight=297mm % a4paper
    \renewcommand\LineBreak{\\}
    \renewcommand\PageBreak{\clearpage}
  \fi
\fi
%
\usepackage[bottom]{footmisc}
\usepackage{array,graphicx,pict2e,slashbox}
\IfFileExists{test/tlc2/cat.eps}{\graphicspath{{test/tlc2/}}}{}%
%
\usepackage{hypdoc}
\ifpdf\usepackage{hypdestopt}\fi
\hypersetup{pdfkeywords={LaTeX, package, subcaption},pdfstartpage={},pdfstartview={}}
%
\usepackage{caption}[2007/12/06] % needs v3.1f or newer
\usepackage{subcaption}[2007/12/06]
\DeclareCaptionSubType*[arabic]{table}
\captionsetup[subtable]{labelformat=simple,labelsep=colon}
%
\newcommand*\purerm[1]{{\upshape\mdseries\rmfamily #1}}
\newcommand*\puresf[1]{{\upshape\mdseries\sffamily #1}}
\newcommand*\purett[1]{{\upshape\mdseries\ttfamily #1}}
\let\package\puresf
\let\env\purett \let\opt\purett
%
\newcommand*\csmarg[1]{\texttt{\char`\{#1\char`\}}}
\newcommand*\csoarg[1]{\texttt{\char`\[#1\char`\]}}
\newcommand*\version[2][]{$v#2$}
\newcommand*\x{\discretionary{}{}{}}
%
\usepackage{marvosym}
\newcommand*\MARGINSYM[1]{\hskip 1sp \marginpar{\raggedleft\textcolor{blue}{{#1}}}}
\newenvironment{info}{\par\bigskip\csname info*\endcsname}{\csname endinfo*\endcsname}
\newenvironment{info*}%
  {\small
   \MARGINSYM{\vbox to \ht\strutbox{\LARGE\Info}}%
   \ignorespaces}%
  {\par}
%
\begin{document}
  \DocInput{subcaption.dtx}
\end{document}
%</driver>
% \fi
%
% \let\subsectionautorefname\sectionautorefname
% \let\subsubsectionautorefname\sectionautorefname
%
% \def\thispackage{the \package{subcaption} package}
% \def\Thispackage{The \package{subcaption} package}
%
% \newcommand\NEWfeature{\NEW{New feature}}
% \newcommand\NEWdescription{\NEW{New description}}
%
% \makeatletter
% \newcommand*\Ref{\@ifstar{\@Ref\ref}{\@Ref\autoref}}
% \newcommand*\@Ref[2]{#1{#2}: \textit{\nameref{#2}}}
% \makeatother
% \newcommand*\See[1]{\nopagebreak{\small (See #1)}}
%
% \GetFileInfo{subcaption.drv}
% \let\docdate\filedate
% \GetFileInfo{subcaption.sty}
%
% \title{\texorpdfstring{\Thispackage\thanks{%^^A
%          This package has version number \fileversion, last revised \filedate.}}%^^A
%        {The subcaption package}}
% \author{Axel Sommerfeldt\\
%         \href{mailto:caption@sommerfee.de}{\texttt{caption@sommerfee.de}}}
% \date{\docdate}
% \maketitle
% 
% \begin{abstract}
% This tiny package demonstrates the sub-caption feature of the
% \package{caption} package.
% \end{abstract}
%
% \subsection*{Introduction}
% \begin{info*}
% Prepared with either |\Declare|\-|Caption|\-|Sub|\-|Type| (offered by the
% \package{caption} package) or |\new|\-|sub|\-|float| (offered by the
% \package{subfig} package), the caption package option |subtype| becames
% available, causing |\caption| to typeset a sub-caption instead of an
% ordinary one.\par
% This package demonstrates the usage of |\Declare|\-|Caption|\-|Sub|\-|Type|,
% |\caption|\-|setup{sub|\-|type}|, and the internal hook
% |\caption@sub|\-|type|\-|hook|.
% \end{info*}
% 
% \setcounter{tocdepth}{2}
% \tableofcontents
%
% \vfill
% \emph{Please note:}
% This package is incompatible with the \package{subfigure} and \package{subfig}
% packages.
% \medskip
%
% \clearpage
% \section{The user interface}
%
% Just load this package after the \package{caption} package, e.g.:
% \begin{quote}
%   |\usepackage|\oarg{options}|{caption}|\\
%   |\usepackage|\oarg{options}|{subcaption}|
% \end{quote}
% The options for \thispackage\ are the same ones as for the \package{caption}
% package, but specify settings which are used for sub-captions
% \emph{additionally}.
% In fact
% \begin{quote}
%   |\usepackage|\oarg{options}|{subcaption}|
% \end{quote}
% is identical to
% \begin{quote}
%   |\usepackage{subcaption}|\\
%   |\captionsetup[sub]|\marg{options}
% \end{quote}
%
% \bigskip
%
% The default settings for |sub|captions are:
% \begin{quote}
%   |margin=0pt,font+=small,labelformat=parens,labelsep=space,|\\
%   |skip=6pt,list=false,hypcap=false|~\footnote{%^^A
%     This means that sub-captions are not listed in the List of Figures
%     or Tables by default, but (of course) you can enable that by
%     specifying the option \texttt{list=true}.}
% \end{quote}
%
% Options specified with |\usepackage[|\ldots|]{sub|\-|caption}| and
% |\caption|\-|setup[sub]{|\ldots|}| will override the ones specified by
% |\caption|\-|setup{|\ldots|}| and |\caption|\-|setup[figure]{|\ldots|}|,
% but are again overwritten by |\caption|\-|setup[sub|\-|figure]{|\ldots|}|
% (same for `table'). So finally we have the following order how
% settings for sub-captions are applied:
% \begin{enumerate}
% \item global settings
%  {\small(|\usepackage[|\ldots|]{caption}| and |\captionsetup{|\ldots|}|)}
% \item environmental settings
%  {\small(|\captionsetup[figure|\emph{ -or- }|table]{|\ldots|}|)}
% \item local settings
%  {\small(|\captionsetup{|\ldots|}| inside |figure| or |table| environment)}
% \item default `sub' settings
%  {\small(|margin=0pt,font+=small,|\ldots, see above)}
% \item custom `sub' settings
%  {\small(|\usepackage[|\ldots|]{subcaption}| and |\captionsetup[sub]{|\ldots|}|)}
% \item environmental `sub' settings
%  {\small(|\captionsetup[subfigure|\emph{ -or- }|subtable]{|\ldots|}|)}
% \item local `sub' settings
%  {\small(|\captionsetup{|\ldots|}| inside |subfigure| or |subtable|)}
% \end{enumerate}
% An example:
% \begin{quote}
%   |\usepackage[labelsep=quad,indention=10pt]{caption}|\\
%   |\usepackage[labelfont=bf,list=true]{subcaption}|\\
%   |\captionsetup[table]{textfont=it,position=top}|\\
%   |\captionsetup[subtable]{textfont=sf}|
% \end{quote}
% causes the captions inside |subtable| environments to be typeset with
% the settings
% \begin{quote}
%   |indention=10pt,position=top,margin=0pt,font=small,|\\
%   |labelformat=parens,labelsep=space,skip=6pt,hypcap=false,|\\
%   |labelfont=bf,list=true,textfont=sf|\quad.
% \end{quote}
%
% \PageBreak
% \subsection{The \cs{subcaption} command}
%
% \DescribeMacro\subcaption
% The easiest and most flexible method to apply a sub-caption is by using the
% |\subcaption| command. Its syntax is analogous to the one of the |\caption|
% command and shares its features:
% \begin{quote}
%   |\subcaption|\oarg{list entry}\marg{heading}\\
%   |\subcaption*|\marg{heading}
% \end{quote}
% Please note that the |\subcaption| command \emph{must} be applied inside
% its own box or environment.
%
% An example:
% \begin{quote}
%   |\begin{figure}|\\
%   |  \begin{minipage}[b]{.5\linewidth}|\\
%   |    \centering\large A|\\
%   |    \subcaption{A subfigure}\label{fig:1a}|\\
%   |  \end{minipage}%|\\
%   |  \begin{minipage}[b]{.5\linewidth}|\\
%   |    \centering\large B|\\
%   |    \subcaption{Another subfigure}\label{fig:1b}|\\
%   |  \end{minipage}|\\
%   |  \caption{A figure}\label{fig:1}|\\
%   |\end{figure}|
% \end{quote}
% gives the result:
% \par\bigskip
% \noindent\begin{minipage}{\linewidth}
%   \captionsetup{type=figure}
%   \begin{minipage}[b]{.5\linewidth}
%     \centering\large A
%     \subcaption{A subfigure}\label{fig:1a}
%   \end{minipage}%^^A
%   \begin{minipage}[b]{.5\linewidth}
%     \centering\large B
%     \subcaption{Another subfigure}\label{fig:1b}
%   \end{minipage}
%   \caption{A figure}\label{fig:1}
% \end{minipage}
%
% \bigskip
%
% \begin{info}
% Actually the |\subcaption| command is just a simple combination of
% |\caption|\-|setup{sub|\-|type*}| and |\caption|.
% Analogous to the |type| option, the |subtype| option (both offered by the
% \package{caption} package) sets the sub-type of the box or environment
% (so |\caption| will typeset a sub-caption instead of an ordinary one),
% places a proper hyperlink anchor (non-starred variant only),
% executes options associated with the sub-type etc.\iffalse~\footnote{\emph{Note:}
% Since \cs{captionsetup}\csmarg{subtype} is part of the \package{caption}
% package, it works in coorparation with the \package{subfig} package as
% well.}\fi
% \end{info}
%
% \PageBreak
% \subsection{The subfigure \& subtable environments}
%
% \DescribeEnv{subfigure}
% \DescribeEnv{subtable}
% After loading \thispackage\ the new environments |subfigure| and
% |subtable| are available, which have the same (optional \& mandatory)
% arguments as the |minipage| environment.
% Inside these environments you use the ordinary |\caption| command
% for typesetting captions. So this example is identical to the
% last one, but uses the |subfigure| environment:
% \begin{quote}
%   |\begin{figure}|\\
%   |  \begin{|\textcolor{blue}{\texttt{subfigure}}|}[b]{.5\linewidth}|\\
%   |    \centering\large A|\\
%   |    |\textcolor{blue}{\cs{caption}}|{A subfigure}\label{fig:1a}|\\
%   |  \end{|\textcolor{blue}{\texttt{subfigure}}|}%|\\
%   |  \begin{|\textcolor{blue}{\texttt{subfigure}}|}[b]{.5\linewidth}|\\
%   |    \centering\large B|\\
%   |    |\textcolor{blue}{\cs{caption}}|{Another subfigure}\label{fig:1b}|\\
%   |  \end{|\textcolor{blue}{\texttt{subfigure}}|}|\\
%   |  \caption{A figure}\label{fig:1}|\\
%   |\end{figure}|
% \end{quote}
% Using the |subfigure| or |subtable| environment instead of |\subcaption|
% has two (little) advantages:
% \begin{itemize}
% \item You can override the setttings for a specific subcaption
% with a |\captionsetup| inside the |subfigure| or |subtable| environment, e.g.:
% \begin{quote}
%   \ldots\\
%   |\begin{subfigure}[b]{.5\linewidth}|\\
%   |  \centering\large A|\\
%   |  |\textcolor{blue}{\cs{captionsetup}\csmarg{skip=3pt}}\\
%   |  \caption{A subfigure}\label{fig:1a}|\\
%   |\end{subfigure}|\\
%   \ldots
% \end{quote}
% \item Hyperlinks pointing to this subfigure will jump to the beginning
% of the subfigure, and not to the caption of the subfigure
% (if |hypcap=true| is set for sub-captions).
% \See{\Ref{hypcap}}
% \end{itemize}
%
% \bigskip
%
% \begin{info}
% The |subfigure| \& |subtable| environments are just simple minipage
% environments with |\caption|\-|setup|\x|{subtype}| as first contents line.
% These environments are defined with the help of
% |\caption@For{subtypelist}|, which executes code for every sub-type
% declared with |\DeclareCaptionSubType|.
% \end{info}
%
% \PageBreak
% \subsection{The \cs{subcaptionbox} command}
%
% \DescribeMacro\subcaptionbox
% A more powerful (but less flexible) way of setting sub-figures is
% offered by the |\sub|\-|caption|\-|box| command. Its syntax is:
% \begingroup
% \leftmargini=12pt
% \begin{quote}
%   |\subcaptionbox|\oarg{list entry}\marg{heading}\oarg{width}\oarg{inner-pos}\marg{contents}\\
%   |\subcaptionbox*|\marg{heading}\oarg{width}\oarg{inner-pos}\marg{contents}
% \end{quote}
% \endgroup
% \begin{small}
% The arguments \meta{list entry} \& \meta{heading} will be used for
% typesetting the |\caption|.\par
% \meta{width} is the width of the resulting |\par|\-|box|; the default value is
% the width of the contents.\par
% \meta{inner-pos} specifies how the contents will be justified inside the
% resulting |\parbox|;
% it can be either `c' (for |\centering|), `l' (for |\ragged|\-|right|),
% `r' (for |\ragged|\-|left|), or `s' (for no special justification).
% The default is `c'.
% (But you can use any justification defined with
% |\Declare|\-|Caption|\-|Jus|\-|ti|\-|fi|\-|ca|\-|tion| as well,
% e.g.~`|center|\-|last|'.)
% \end{small}
%
% \bigskip
%
% Using |\sub|\-|caption|\-|box|, the baseline of the resulting box will be placed
% right between contents and heading, so usually you don't have to care about the
% vertical alignment of the sub-figures for yourself.
% Also the hyperlink anchor is placed properly with respect to the |hypcap=|
% setting.
%
% One example:
% \begin{quote}
%   |\begin{figure}|\\
%   |  \centering|\\
%   |  \subcaptionbox{A cat\label{cat}}|\\
%   |    {\includegraphics{cat}}|\\
%   |  \subcaptionbox{An elephant\label{elephant}}|\\
%   |    {\includegraphics{elephant}}|\\
%   |  \caption{Two animals}\label{animals}|\\
%   |\end{figure}|
% \end{quote}
% gives the result:\par
% \noindent\begin{minipage}{\linewidth}
%   \captionsetup{type=figure}
%   \centering
%   \subcaptionbox{A cat\label{cat}}
%     {\includegraphics[width=30pt]{cat}}
%   \subcaptionbox{An elephant\label{elephant}}
%     {\includegraphics[width=.4\textwidth]{elephant}}
%   \caption[Two animals]{Two animals~\footnotemark}\label{animals}
% \end{minipage}
% \footnotetext{The pictures were taken with permission from the
%   \LaTeX\ Companion\cite{TLC2} examples.}
%
% \bigskip
%
% As you see the result is not satisfying;
% the caption below the cat looks ugly because of the small width of the
% graphic. This can be solved by using the optional arguments of
% |\caption|\-|box|, increasing the width of the resulting box:
% \begin{quote}
%   |  |\ldots\\
%   |  \subcaptionbox{A cat\label{cat}}|\\
%   |    [2.5cm]{\includegraphics{cat}}|\\
%   |  |\ldots
% \end{quote}
% \noindent\begin{minipage}{\linewidth}
%   \captionsetup{type=figure}
%   \centering
%   \subcaptionbox{A cat\label{cat2}}
%     [2.5cm]{\includegraphics[width=30pt]{cat}}
%   \subcaptionbox{An elephant\label{elephant2}}
%     {\includegraphics[width=.4\textwidth]{elephant}}
%   \caption{Two animals}\label{animals2}
% \end{minipage}
%
% \bigskip
%
% Furthermore the main caption, which is centered with respect to the
% |\text|\-|width|, looks mis-aligned with respect to the sub-captions.
% This can (again) be solved by using the optional arguments of
% |\caption|\-|box|, giving both boxes the same width, for example:
% \begin{quote}
%   |  |\ldots\\
%   |  \subcaptionbox{A cat\label{cat}}|\\
%   |    [.4\linewidth]{\includegraphics{cat}}%|\\
%   |  \subcaptionbox{An elephant\label{elephant}}|\\
%   |    [.4\linewidth]{\includegraphics{elephant}}|\\
%   |  |\ldots
% \end{quote}
% \noindent\begin{minipage}{\linewidth}
%   \captionsetup{type=figure}
%   \centering
%   \subcaptionbox{A cat\label{cat3}}
%     [.4\linewidth]{\includegraphics[width=39.34724pt]{cat}}%^^A
%   \subcaptionbox{An elephant\label{elephant3}}
%     [.4\linewidth]{\includegraphics[width=.4\textwidth]{elephant}}
%   \caption{Two animals}\label{animals3}
% \end{minipage}
%
% \bigskip
%
% \begin{info}
% The |\sub|\-|caption|\-|box| is a |\par|\-|box| with
% |\caption|\-|setup{sub|\-|type}| as first contents line.
% \iffalse See implementation for details.\fi
% \end{info}
%
% \PageBreak
% \subsection{The \cs{subref} command}
%
% While |\ref|\marg{key} (and |\ref*|\marg{key}, if the \package{hyperref}
% package is used) usually gives a combined result representing the main
% caption counter and the sub-caption one, it is sometimes useful to have
% a reference to the sub-caption only. For this purpose you can use
% \begin{quote}
%   |\subref|\marg{key}\\
%   |\subref*|\marg{key}~\footnote{%^^A
%     Like \cs{ref*}, \cs{subref*} is only available if the \package{hyperref}
%     package\cite{hyperref} is used.}%^^A
%     \qquad.
% \end{quote}
% So for example |\ref{cat}| gives the result `\ref{cat}' but |\subref{cat}|
% gives `\subref{cat}'.
%
% \begin{small}
% \emph{Note:} If the sub-caption was defined with the starred variant
% |\Declare|\-|Caption|\-|Sub|\-|Type*|, both |\ref| and |\sub|\-|ref| gives
% the same result.
% \end{small}
%
% \begin{info}
% The |\sub|\-|ref| command demonstrates the usage of |\caption@sub|\-|type|\-|hook|
% which will be called during |\caption|\-|setup{sub|\-|type}|.
% \end{info}
%
% \pagebreak[3]
% \subsection{The \cs{DeclareCaptionSubType} command}
%
% \DescribeMacro\DeclareCaptionSubType
% For using the sub-caption feature of the \package{caption} package some
% commands and counters must be prepared. This is done with~\footnote{%^^A
% \cs{newsubfloat} offered by the \package{subfig} package\cite{subfig}
% could be used for this purpose as well.}
% \begin{quote}
%  |\DeclareCaptionSubType|\oarg{numbering scheme}\marg{type}\\
%  |\DeclareCaptionSubType*|\oarg{numbering scheme}\marg{type}
% \end{quote}
% For the environments |figure| \& |table| (and all the ones
% defined with |\Declare|\-|Caption|\-|Type|) this will be done automatically
% by this package, but for others (e.g.~defined with |\newfloat| offered by the
% \package{float} package or |\Declare|\-|New|\-|Float|\-|Type| offered by the
% \package{floatrow} package) this has to be done manually.
%
% \medskip
%
% The starred variant provides the sub-caption numbering format
% \meta{type}|.|\meta{subtype} (e.g.~`|1.2|') while the non-starred variant
% simply uses \meta{subtype} (e.g.~`|a|').
%
% \begin{small}
% Own numbering formats can be created by redefining |\thesub|\meta{type}, e.g.
% \begin{quote}|\DeclareCaptionSubType*{figure}|\\
% |\renewcommand\thesubfigure{\thefigure\alph{subfigure}}|\end{quote}
% would give you sub-caption numbers like `|1b|'.
% \end{small}
%
% The default numbering scheme is |alph|, but you can use any \LaTeX\ command
% name here which converts a counter to a text value, e.g. |arabic|, |roman|,
% |Roman|, |alph|, |Alph|, |fnsymbol|, \ldots
%
% But |\DeclareCaptionSubType| is not for defining new sub-caption types only,
% you can use this command for re-definitions as well, e.g.
% \begingroup
% \leftmargini=12pt
% \begin{quote}
%   |\DeclareCaptionSubType*[arabic]{table}|\\
%   |\captionsetup[subtable]{labelformat=simple,labelsep=colon}|
% \end{quote}
% \endgroup
% \pagebreak[3]
% will give you sub-captions in |table|s like these ones:
% \par\bigskip
% \noindent\begin{minipage}{\linewidth}
%   \captionsetup{type=table}
%   \centering
%   \caption{Two tables}
%   \subcaptionbox{Table one}[3cm][c]{\begin{tabular}{cc}A & B\\ C & D\\ \end{tabular}}
%   \subcaptionbox{Table two}[3cm][c]{\begin{tabular}{cc}E & F\\ G & H\\ \end{tabular}}
% \end{minipage}
%
% \begin{info}
% |\Declare|\-|Caption|\-|Sub|\-|Type| is an integral part of the \package{caption}
% package kernel.
% \end{info}
%
% \pagebreak[3]
% \subsection{Where do hyperlinks jump?}
% \label{hypcap}
%
% For the |subfigure| \& |subtable| environments and |\subcaptionbox| boxes
% (and own constructs which use |\captionsetup{subtype}|) the
% hyperlink anchors will be placed in respect to the |hypcap=| setting.
% While usage of this option is straight-forward ordinary captions,
% the usage for sub-captions depends on the setting for the main captions.
% This table gives you an overview where the hyperlinks will jump:\par
%
% \bigskip
% \begin{small}
% \centering
% \DeleteShortVerb{\|}
% \renewcommand\arraystretch{1.5}
% \begin{tabular}{|l|p{3cm}p{3cm}|}
% \hline
% \backslashbox{subcaption}{caption} &
%   \multicolumn{1}{c}{\texttt{hypcap=false}} &
%   \multicolumn{1}{c|}{\texttt{hypcap=true}} \\
% \hline
% \raisebox{-1.5ex}[1.5ex]{\texttt{hypcap=false}} &
%   sub-caption & figure or table\par\hfill\textit{(default setting)}\\
% \raisebox{-1.5ex}[1.5ex]{\texttt{hypcap=true}} &
%   sub-figure or\par sub-table & sub-figure or\par sub-table \\
% \hline
% \end{tabular}\par
% \MakeShortVerb{\|}
% \end{small}
% \bigskip
%
% But if |\subcaption| is used and |hypcap=true| is set for sub-captions,
% \thispackage\ does not know where the sub-figure or sub-table actually
% begins, so it will jump to the sub-caption instead.
%
% \medskip
% \emph{Remember:} If you use the \package{hypcap} package\cite{hypcap},
% it controls the placement of the hyperlink anchors, making the rules
% above invalid.
%
% \bigskip
% {\small(See also the documentation of the \package{caption} package,
% sections about \package{hyperref} \& \package{hypcap}.)}
%
% \iffalse
% --------------------------------------------------------------------------- %
% \fi
%
% \pagebreak[3]
% \section{Beyond this package}
% \label{floatrow}
%
% For a more advanced usage of the sub-caption feature of the
% \package{caption} package, please take a look at the \package{floatrow}
% package\cite{floatrow} which provides the powerful \texttt{subfloatrow}
% environment for typesetting sub-figures.
%
% \iffalse
% --------------------------------------------------------------------------- %
% \fi
%
% \pagebreak[2]
% \section{Thanks}
%
% I would like to thank
% Stephen Dalton
% who helped to make this package a better one.
%
% \iffalse
% --------------------------------------------------------------------------- %
% \fi
%
% \StopEventually{%^^A
% \begin{thebibliography}{9}
%   \bibitem{TLC2}
%   Frank Mittelbach and Michel Goossens:\\
%   \newblock {\em The {\LaTeX} Companion (2nd.~Ed.)},
%   \newblock Addison-Wesley, 2004.
%   \bibitem{floatrow}
%   Olga Lapko:\\
%   \href{http://tug.ctan.org/tex-archive/macros/latex/contrib/floatrow/}%
%        {\emph{The floatrow package documentation}},
%   2007/12/24
%   \bibitem{hyperref}
%   Sebastian Rahtz \& Heiko Oberdiek:\\
%   \href{http://tug.ctan.org/tex-archive/macros/latex/contrib/hyperref/}%
%        {\emph{Hypertext marks in \LaTeX}},
%   November 12, 2007
%   \bibitem{hypcap}
%   Heiko Oberdiek:\\
%   \href{http://tug.ctan.org/tex-archive/macros/latex/contrib/oberdiek/}%
%        {\emph{The hypcap package -- Adjusting anchors of captions}},
%   2007/04/09
%   \bibitem{subfig}
%   Steven D. Cochran:\\
%   \href{http://tug.ctan.org/tex-archive/macros/latex/contrib/subfig/}%
%        {\emph{The subfig package}},
%   2005/07/05
% \end{thebibliography}
% }
%
% \iffalse
% --------------------------------------------------------------------------- %
% \fi
%
% \DoNotIndex{\\,\_,\ ,\@@par}
% \DoNotIndex{\@bsphack}
% \DoNotIndex{\@car,\@cdr,\@classoptionslist,\@cons,\@currext,\@currname}
% \DoNotIndex{\@ehc,\@ehd,\@empty,\@esphack,\@expandtwoargs}
% \DoNotIndex{\@for,\@firstofone,\@firstoftwo}
% \DoNotIndex{\@gobble,\@gobblefour,\@gobbletwo,\@hangfrom}
% \DoNotIndex{\@ifnextchar,\@ifpackagelater,\@ifpackageloaded}
% \DoNotIndex{\@ifstar,\@ifundefined,\@latex@error,\@namedef,\@nameuse}
% \DoNotIndex{\@onlypreamble,\@parboxrestore,\@plus,\@ptionlist}
% \DoNotIndex{\@removeelement,\@restorepar,\@secondoftwo,\@setpar}
% \DoNotIndex{\@tempa,\@tempboxa,\@tempdima,\@tempdimb,\@tempdimc,\@tempb,\@tempc}
% \DoNotIndex{\@testopt}
% \DoNotIndex{\@undefined,\@unprocessedoptions,\@unusedoptionlist}
% \DoNotIndex{\p@,\z@}
% \DoNotIndex{\active,\addtocounter,\addtolength,\advance,\aftergroup}
% \DoNotIndex{\baselineskip,\begin,\begingroup,\bfseries,\box}
% \DoNotIndex{\catcode,\centering,\changes,\csname,\def,\divide,\do,\downarrow}
% \DoNotIndex{\edef,\else,\empty,\end,\endcsname,\endgraf,\endgroup,\expandafter}
% \DoNotIndex{\fi,\footnotesize,\global}
% \DoNotIndex{\hangindent,\hbox,\hfil,\hsize,\hskip,\hspace,\hss}
% \DoNotIndex{\ifcase,\ifdim,\ifnum,\ifodd,\ifvoid,\ifvmode}
% \DoNotIndex{\ifx,\ignorespaces,\itshape}
% \DoNotIndex{\Large,\large,\leavevmode,\leftmargini,\leftskip,\let,\linewidth}
% \DoNotIndex{\llap,\long,\m@ne,\margin,\mdseries,\message}
% \DoNotIndex{\newcommand,\newdimen,\newlength,\newline,\newif,\newsavebox}
% \DoNotIndex{\next,\nobreak,\nobreakspace,\noexpand,\noindent,\numberline}
% \DoNotIndex{\normalcolor,\normalfont,\normalsize,\or,\par,\parbox,\parfillskip}
% \DoNotIndex{\parindent,\parskip,\prevdepth,\protect,\protected@edef,\protected@write}
% \DoNotIndex{\providecommand,\quad}
% \DoNotIndex{\raggedleft,\raggedright,\relax,\renewcommand,\RequirePackage}
% \DoNotIndex{\rightskip,\rmfamily}
% \DoNotIndex{\sbox,\scriptsize,\scshape,\setbox,\setlength,\sffamily,\slshape}
% \DoNotIndex{\small,\string,\space,\strut}
% \DoNotIndex{\textheight,\the,\toks@,\typeout,\ttfamily}
% \DoNotIndex{\unvbox,\uparrow,\upshape,\usebox,\usepackage}
% \DoNotIndex{\value,\vbox,\vsize,\vskip,\wd,\width,\z@skip}
% \DoNotIndex{\AtBeginDocument,\AtEndOfPackage,\CurrentOption,\DeclareOption}
% \DoNotIndex{\ExecuteOptions,\GenericWarning,\IfFileExists,\InputIfFileExists}
% \DoNotIndex{\NeedsTeXFormat,\MessageBreak}
% \DoNotIndex{\PackageError,\PackageInfo,\PackageWarning,\PackageWarningNoLine}
% \DoNotIndex{\PassOptionsToPackage,\ProcessOptions,\ProvidesPackage}
%
% \iffalse
% --------------------------------------------------------------------------- %
% \fi
%
% \setlength{\parskip}{0pt plus 1pt}
% \changes{v0.1}{2007/09/01}{First demo}
% \changes{v0.2}{2007/11/11}{\cs{subcaptionbox} added}
% \changes{v0.3}{2007/12/06}{Adapted to \package{caption} package \version{3.1f}}
%
% \newcommand*\Note[2][Note]{\par{\small\emph{#1:} #2}}
%
% \iffalse
% --------------------------------------------------------------------------- %
% \fi
%
% \clearpage
% \section{The implementation}
% \iffalse
%<*package>
% \fi
%
% \subsection{Identification}
%
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}[1994/12/01]
\ProvidesPackage{subcaption}[2007/12/06 v0.3 Adding subcaptions (AR)]
%    \end{macrocode}
%
% \subsection{Initial code}
%
% We need the \package{caption} package, so we issue an error here if it's
% not loaded yet.
%    \begin{macrocode}
\@ifundefined{caption@subtypehook}{% we need caption v3.1f or newer
  \PackageError{subcaption}{`caption' package not loaded\MessageBreak
    (which is needed by this package)\@gobble}{%
    If you do not understand this error, please take a closer look\MessageBreak
    at the documentation of the `subcaption' package.\MessageBreak
    \@ehc}%
  \endinput}{}
%    \end{macrocode}
%
% \iffalse
% \subsection{Declaration of options}
% We do not have own options.
% \fi
%
% \subsection{Execution of options}
%
% We map |\caption@setkeys| to |\captionsetup[sub]| so |\caption@ExecuteOptions|
% \& |\caption@ProcessOptions| adds the options to the `|sub|' option list
% instead of executing them immediately.
%    \begin{macrocode}
\let\caption@setkeys@ORI\caption@setkeys
\renewcommand\caption@setkeys[2]{\captionsetup[sub]{#2}}
%    \end{macrocode}
%    \begin{macrocode}
\caption@ExecuteOptions{subcaption}{%
  font+=small,labelformat=parens,labelsep=space,skip=6pt,list=0,hypcap=0}
\caption@ProcessOptions*{subcaption}
%    \end{macrocode}
%    \begin{macrocode}
\let\caption@setkeys\caption@setkeys@ORI
\let\caption@setkeys@ORI\@undefined
%    \end{macrocode}
%
% \subsection{Main code}
%
% We call |\DeclareCaptionSubType| for |figure|, |table|,
% and every caption type declared with |\DeclareCaptionType| here.
%    \begin{macrocode}
\@ifundefined{c@figure}{}{\DeclareCaptionSubType{figure}}
\@ifundefined{c@table}{}{\DeclareCaptionSubType{table}}
\caption@For{typelist}{\DeclareCaptionSubType{#1}}
%    \end{macrocode}
%
% \pagebreak[3]
% \subsubsection{The \cs{subcaption} command}
%
% \begin{macro}{\subcaption}
% Without a prefacing |\captionsetup{subtype}|, \cs{subcaption} is some kind
% of |\captionof{sub\@captype}|.
% \Note{Like \cs{captionof}, this command is designed to be used inside an
% own group!}
%    \begin{macrocode}
\newcommand*\subcaption{\captionsetup{subtype*}\caption}
%    \end{macrocode}
% But with a prefacing |\captionsetup{subtype}|, \cs{subcaption} is simply
% |\caption|.
%    \begin{macrocode}
\g@addto@macro\caption@subtypehook{\let\subcaption\caption}
%    \end{macrocode}
% \end{macro}
%
% \pagebreak[3]
% \subsubsection{The subfigure \& subtable environments}
%
% \begin{macro}{subfigure}
% \begin{macro}{subtable}
% This is just an ordinary \env{minipage} environment with
% |\captionsetup{subtype}| as first contents line.
% It will be defined using the helper macro |\caption@For{sub|\-|type|\-|list}|
% offered by the \package{caption} kernel, so for every caption type
% declared with |\Declare|\-|Caption|\-|Type| a corresponding `sub' environment
% will be defined automatically.
%    \begin{macrocode}
\caption@For{subtypelist}{%
  \newenvironment{sub#1}%
    {\caption@withoptargs\subcaption@minipage}%
    {\endminipage}}%
%    \end{macrocode}
%    \begin{macrocode}
\newcommand*\subcaption@minipage[2]{%
  \minipage#1{#2}%
  \captionsetup{subtype}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \pagebreak[3]
% \subsubsection{The \cs{subcaptionbox} command}
%
% \begin{macro}{\subcaptionbox}
% A |\parbox| with contents and sub-caption, separated by an invisible |\hrule|.
%    \begin{macrocode}
\newcommand*\subcaptionbox{\caption@withoptargs\subcaption@box}
%    \end{macrocode}
%    \begin{macrocode}
\newcommand\subcaption@box[2]{%
  \@testopt{\subcaption@ibox{#1}{#2}}{\wd\@tempboxa}}
%    \end{macrocode}
%    \begin{macrocode}
\long\def\subcaption@ibox#1#2[#3]{%
  \@testopt{\subcaption@iibox{#1}{#2}{#3}}\subcaptionbox@hj@default}
%    \end{macrocode}
%    \begin{macrocode}
\long\def\subcaption@iibox#1#2#3[#4]#5{%
  \setbox\@tempboxa\hbox{#5}%
  \begingroup
  \captionsetup{subtype*}% set \caption@position
  \caption@iftop{%
    \endgroup
    \parbox[t]{#3}{%
      \captionsetup{subtype,position=t}%
      \vbox{\caption#1{#2}}%
      \hrule\@height\z@
      \csname caption@hj@#4\endcsname
      \unhbox\@tempboxa}%
  }{%
    \endgroup
    \parbox[b]{#3}{%
      \captionsetup{subtype,position=b}%
      \csname caption@hj@#4\endcsname
      \unhbox\@tempboxa
      \hrule\@height\z@
      \vtop{\caption#1{#2}}}%
  }}
%    \end{macrocode}
%    \begin{macrocode}
\providecommand*\caption@hj@c{\centering}
\providecommand*\caption@hj@l{\raggedright}
\providecommand*\caption@hj@r{\raggedleft}
\providecommand*\caption@hj@s{}
\newcommand*\subcaptionbox@hj@default{c}
%    \end{macrocode}
% \end{macro}
%
% \pagebreak[3]
% \subsubsection{The \cs{subref} command}
%
% At |\captionsetup{subtype}|, we redefine |\label|.
%    \begin{macrocode}
\g@addto@macro\caption@subtypehook{%
  \ifx\label\subcaption@label \else
    \let\subcaption@ORI@label\label
    \let\label\subcaption@label
  \fi}
%    \end{macrocode}
%
% \begin{macro}{\subcaption@label}
% When a label will be placed for a sub-caption, we automatically place
% a second one for |\subref|, too. This second label will contain
% the sub-type counter only.
%    \begin{macrocode}
\newcommand*\subcaption@label[1]{%
  \@bsphack\begingroup
    \subcaption@ORI@label{#1}%
    \protected@edef\@currentlabel{\csname thesub\@captype\endcsname}%
    \subcaption@ORI@label{sub@#1}%
  \endgroup\@esphack}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\subref}
% This simply calls |\ref| with the second label. (see |\subcaption@label|)
%    \begin{macrocode}
\DeclareRobustCommand*\subref{\caption@withoptargs\subcaption@ref}
\newcommand*\subcaption@ref[2]{\ref#1{sub@#2}}
%    \end{macrocode}
% \end{macro}
%
% \iffalse
%</package>
% \fi
%
% \iffalse
% --------------------------------------------------------------------------- %
% \fi
%
% \Finale
%
\endinput