% \iffalse meta-comment % % This is file `subcaption.dtx'. % % $Id: subcaption.dtx 75 2013-04-16 17:57:13Z sommerfeldt $ % $HeadURL: svn+ssh://sommerfeldt@svn.code.sf.net/p/latex-caption/code/trunk/source/subcaption.dtx $ % % Copyright (C) 2007-2012 Axel Sommerfeldt (axel.sommerfeldt@f-m.fm) % % -------------------------------------------------------------------------- % % 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, % caption3.dtx, bicaption.dtx, ltcaption.dtx, subcaption.dtx, and newfloat.dtx, % the derived files caption.sty, caption2.sty, caption3.sty, % bicaption.sty, ltcaption.sty, subcaption.sty, and newfloat.sty, % and the user manuals caption-deu.tex, caption-eng.tex, and caption-rus.tex. % % \fi % \CheckSum{142} % % \iffalse %<*driver> \NeedsTeXFormat{LaTeX2e}[1994/12/01] \ProvidesFile{subcaption.drv}[2013/04/16 v1.1 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,overpic,pict2e,diagbox} % \PassOptionsToPackage{breaklinks=true}{hyperref} \usepackage{hypdoc} \ifpdf\usepackage{hypdestopt}\fi \hypersetup{pdfkeywords={LaTeX, package, subcaption},pdfstartpage={},pdfstartview={}} % \usepackage{subcaption}[2011/08/01] % needs v1.1 or newer \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$} % \usepackage{marvosym} \makeatletter \newcommand*\INFO{\@ifstar{\@INFO{}}{\@INFO{\vbox to \ht\strutbox}}} \newcommand*\@INFO[1]{\MARGINSYM{#1{\LARGE\Info}}} \makeatother % \usepackage[alpine]{ifsym} \newenvironment{background}{\par\bigskip\csname background*\endcsname}{\csname endbackground*\endcsname} \newenvironment{background*}{\small\MARGINSYM{\Mountain}\ignorespaces}{\par} % \newcommand*\MARGINSYM[1]{\hskip 1sp \marginpar{\raggedleft\textcolor{blue}{{#1}}}} %\newcommand*\NEW[2]{}%\hskip 1sp \marginpar{\footnotesize\sffamily\raggedleft#1\\#2}} % \begin{document} \DocInput{subcaption.dtx} \end{document} % % \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\\ % \url{http://sourceforge.net/projects/latex-caption/}} % \date{\docdate} % \maketitle % % \begin{abstract} % This package supports typesetting of sub-captions % (by using the the sub-caption feature of the \package{caption} package). % \end{abstract} % % \begin{background} % At the end of each section, text marked with the mountain symbol % will contain background knowledge on how the particular command or % environment is actually implemented. % If you just want to use this package as it is, you don't have to read or % understand them. % \end{background} % % \begin{background*} % This package demonstrates the usage of |\Declare|\-|Caption|\-|Sub|\-|Type|, % |\caption|\-|setup{sub|\-|type}|, and the internal hook % |\caption@sub|\-|type|\-|hook| (offered by the \package{caption} package). % \end{background*} % % \bigskip % \INFO* % \emph{Please note:} % This package is incompatible with the \package{subfigure} and \package{subfig} % packages. % % \clearpage % \setcounter{tocdepth}{2} % \tableofcontents % % \clearpage % \section{Loading the package} % % Load this package using % \begin{quote} % |\usepackage|\oarg{options}|{subcaption}|\quad. % \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}\quad. % \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 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[fig|\-|ure]{|\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 |sub|\-|figure| or |sub|\-|table|)} % \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 |sub|\-|table| 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 % \section{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} % \setcaptiontype{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{background} % Prepared with |\Declare|\-|Caption|\-|Sub|\-|Type| (offered by the % \package{caption} package), the caption package command |\set|\-|caption|\-|sub|\-|type| % becames available. % Analogous to the |\set|\-|caption|\-|type| command of the \package{caption} package, % the |\set|\-|caption|\-|sub|\-|type| command 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.\par % The |\subcaption| command is just a simple combination of % |\set|\-|caption|\-|sub|\-|type*| and |\caption|. % \end{background} % % \PageBreak % \section{The subfigure \& subtable environments} % % \DescribeEnv{subfigure} % \DescribeEnv{subtable} % After loading \thispackage\ the new environments |sub|\-|figure| and % |sub|\-|table| are available, which have the same (optional \& mandatory) % arguments as the |mini|\-|page| environment: % \begin{quote} % |\begin{subfigure}|\oarg{pos}\marg{width}\\ % \ldots\\ % |\end{subfigure}| % \end{quote} % and % \begin{quote} % |\begin{subtable}|\oarg{pos}\marg{width}\\ % \ldots\\ % |\end{subtable}| % \end{quote} % Inside these environments you use the ordinary |\caption| command % for typesetting captions. So this example is the same as the last one, % but uses the |sub|\-|figure| 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 |sub|\-|figure| or |sub|\-|table| environment instead of |\subcaption| % has two advantages: % \begin{itemize} % \item You can override the setttings for a specific subcaption % with a |\caption|\-|setup| inside the |sub|\-|figure| or |sub|\-|table| environment, e.g.: % \begin{quote} % |\begin{subfigure}[b]{.5\linewidth}|\\ % | \centering\large A|\\ % | |\textcolor{blue}{\cs{captionsetup}\csmarg{skip=3pt}}\\ % | \caption{A subfigure}\label{fig:1a}|\\ % |\end{subfigure}|\\ % \end{quote} % \item Hyperlinks targeted 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{background} % The |subfigure| \& |subtable| environments are just simple minipage % environments with |\set|\-|caption|\-|sub|\-|type| as first contents line. % These environments are defined with the help of % |\caption@For{subtypelist}|, which executes code for every sub-type % declared with |\Declare|\-|Caption|\-|Sub|\-|Type|. % \end{background} % % \PageBreak % \section{The \cs{subcaptionbox} command} % % \DescribeMacro\subcaptionbox % A different way of setting sub-figures is % offered by the |\sub|\-|caption|\-|box| command, which automatically % aligns the sub-figures resp.~sub-tables by their very first caption line. % % 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 |hyp|\-|cap=| % 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} % \setcaptiontype{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 % |\sub|\-|caption|\-|box|, increasing the width of the resulting box: % \begin{quote} % | |\ldots\\ % | \subcaptionbox{A cat\label{cat}}|\\ % | |\textcolor{blue}{\csoarg{2.5cm}}|{\includegraphics{cat}}|\\ % | |\ldots % \end{quote} % \noindent\begin{minipage}{\linewidth} % \setcaptiontype{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 % |\sub|\-|caption|\-|box|, giving both boxes the same width, for example: % \begin{quote} % | |\ldots\\ % | \subcaptionbox{A cat\label{cat}}|\\ % | |\textcolor{blue}{\csoarg{.4\cs{linewidth}}}|{\includegraphics{cat}}%|\\ % | \subcaptionbox{An elephant\label{elephant}}|\\ % | |\textcolor{blue}{\csoarg{.4\cs{linewidth}}}|{\includegraphics{elephant}}|\\ % | |\ldots % \end{quote} % \noindent\begin{minipage}{\linewidth} % \setcaptiontype{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 % % \iffalse % \noindent\begin{minipage}{\linewidth} % \setcaptiontype{figure} % \centering % \hbox{\subcaptionbox{An elephant\label{elephant4}} % {\includegraphics[width=.4\textwidth]{elephant}}%^^A % \vbox{\subcaptionbox{Cat 1\label{cat4.1}} % {\includegraphics[width=30pt]{cat}}\par % \subcaptionbox{Cat 2\label{cat4.2}} % {\includegraphics[width=30pt]{cat}}}}%^^A % \caption{Two animals}\label{animals4} % \end{minipage} % \bigskip % \fi % % \begin{background} % The |\sub|\-|caption|\-|box| is a |\par|\-|box| with % |\set|\-|caption|\-|sub|\-|type| as first contents line. % \iffalse See implementation for details.\fi % \end{background} % % \PageBreak % \section{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 % \iffalse\footnote{%^^A % \cs{newsubfloat} offered by the \package{subfig} package\cite{subfig} % could be used for this purpose as well.}\fi % \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|\-|Floating|\-|Environment| offered by the % \package{newfloat} package, this will be done automatically, % but for other environments (e.g.~the ones 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\ (or self-defined) % command name here which converts a counter to a text value, e.g. |arabic|, |roman|, % |Roman|, |alph|, |Alph|, |fnsymbol|, \ldots % % But |\DeclareCaptionSubType| is not only for defining new sub-caption types, % 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[2] % will give you sub-captions in |table|s like these ones: % \par\bigskip % \noindent\begin{minipage}{\linewidth} % \setcaptiontype{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{background} % |\Declare|\-|Caption|\-|Sub|\-|Type| is an integral part of the \package{caption} % package kernel. % \end{background} % % \PageBreak % \section{References} % % The macro |\the|\-\meta{counter} is not only responsible for the look of the \meta{counter}, % but for the look of the references typeset with |\ref|, too. References will be prefixed by % \LaTeX{} with the internal macro |\p@|\-\meta{counter}. % % |\Declare|\-|Caption|\-|Sub|\-|Type| will define both of them for sub-captions % (e.g. |sub|\-|figure| and |sub|\-|table|), and as you have seen in the last section % |\Declare|\-|Caption|\-|Sub|\-|Type| will give you some options to control the % internal (re-)definition of |\the|\-\meta{counter} and |\p@|\-\meta{counter}. % % \DescribeMacro\thesubfigure % \DescribeMacro\p@subfigure % For example |\thesubfigure| and |\p@subfigure| are (as default) internally defined as % \begin{quote} % |\newcommand\thesubfigure{\alph{subfigure}}|\\ % |\newcommand\p@subfigure{\thefigure}| % \end{quote} % so the label of sub-captions will look like `|a|' (decorated by the selected label format), % while references will look like `|1a|' since they are prefixed by |\p@sub|\-|figure| $=$ % |\the|\-|figure|. % % After |\Declare|\-|Caption|\-|Sub|\-|Type*[arabic]{figure}|, |\the|\-|sub|\-|figure| and % |\p@sub|\-|figure| will look like % \begin{quote} % |\renewcommand\thesubfigure{\thefigure.\arabic{subfigure}}|\\ % |\renewcommand\p@subfigure{}| % \end{quote} % % But if you want detailed control on how the references will look like, % the options of |\Declare|\-|Caption|\-|Sub|\-|Type| are potentially not sufficient. % In this case one need to redefine these two macros on his/her own. % Some examples: % % If you want parentheses around the sub-figure part of the reference, % so they will look like `|1(a)|', you may get them this way: % \begin{quote} % |\usepackage[labelformat=simple]{subcaption}|\\ % |\renewcommand\thesubfigure{(\alph{subfigure})}| % \end{quote} % {\small (\emph{Note:} Since |parens| is the default label format you will get double % parentheses in sub-captions when not specifiying a different label format, e.g. |simple|.)} % % But if you want only a closing parenthesis, so references will look like `|1a)|', % but the sub-captions itself should still look like `|(a)|', % this would be a possible solution: % \begin{quote} % |\usepackage{subcaption}|\\ % |\renewcommand\thesubfigure{\alph{subfigure})}|\\ % |\DeclareCaptionLabelFormat{opening}{(#2}|\\ % |\captionsetup[subfigure]{labelformat=opening}| % \end{quote} % % {\small(Please note that you need to surround redefinitions of |\p@|\-\meta{counter} % with |\makeatletter| and |\makeatother|. See % \url{http://tex.stackexchange.com/questions/8351/} % for details.)} % % \pagebreak[3] % \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 (re-)defined with the starred variant % |\Declare|\-|Caption|\-|Sub|\-|Type*|, both |\ref| and |\sub|\-|ref| usually gives % the same result. % \end{small} % % \begin{background} % The |\sub|\-|ref| command demonstrates the usage of |\caption@sub|\-|type|\-|hook| % which will be called during |\caption|\-|setup{sub|\-|type}|. % \end{background} % % \pagebreak[3] % \subsection{The \opt{subrefformat=} option} % % \DescribeMacro{subrefformat=} % By applying |\Declare|\-|Caption|\-|Sub|\-|Type|, or by redefining |\the|\-\meta{counter} % and |\p@|\-\meta{counter}, you will change the look of references typeset with |\ref| % \emph{and} |\sub|\-|ref|. % But maybe you only want to change the output of |\sub|\-|ref| without % affecting the references typeset with |\ref|? % This is possible, too, by using the option \opt{subrefformat}: % \begin{quote} % |\captionsetup{subrefformat=|\meta{label format}|}| % \end{quote} % This one will choose a label format (either a pre-defined one, or a one defined with % |\Declare|\-|Caption|\-|Label|\-|Format|) as decorative element to sub-references. % The default one is |simple| which has no decorative elements but simply typeset % the reference as it is. % % For example % \begin{quote} % |\captionsetup{subrefformat=parens}| % \end{quote} % will result in references (typeset with |\ref|) like `|1a|' but sub-references % (typeset with |\subref|) like `|(a)|'. % % \subsection{Referencing sub-figures without sub-captions} % % \DescribeMacro\phantomsubcaption % \DescribeMacro\phantomcaption % If you don't want to give a sub-figure a caption, because the picture itself % already contains the caption, or for some other reason, you can use the command % \begin{quote} % |\phantomsubcaption| % \end{quote} % instead of |\sub|\-|caption|, or % -- when inside a |sub|\-|figure| or |sub|\-|table| environment -- % |\phantom|\-|caption| instead of |\caption|. % |\phantom|\-|sub|\-|caption| and |\phantom|\-|caption| do not have any arguments, and % they do not generate any output, but give you an anchor for a |\label| command % which can be placed afterwards. % Furthermore it increases the sub-figure resp. sub-table counter. % % Please note that -- just like |\sub|\-|caption| -- the |\phantom|\-|sub|\-|caption| % command \emph{must} be applied inside its own group, box, or environment. % % \pagebreak[3] % An example: % \begin{quote} % |\begin{figure}|\\ % | \centering|\\ % | {\includegraphics{cat_with_a}|\\ % | \phantomsubcaption\label{cat}}|\\ % | {\includegraphics{elephant_with_b}|\\ % | \phantomsubcaption\label{elephant}}|\\ % | \caption{Two animals: \subref{cat} a huge cat,|\\ % | and \subref{elephant} an elephant}|\\ % |\end{figure}| % \end{quote} % % \noindent\begin{minipage}{\linewidth} % \setcaptiontype{figure} % \centering % {\begin{overpic}[width=60pt]{cat} % \put(40,34){(a)} % \end{overpic} % \phantomsubcaption\label{cat6.3}} % {\begin{overpic}[width=.4\textwidth]{elephant} % \put(60,50){(b)} % \end{overpic} % \phantomsubcaption\label{elephant6.3}} % \captionsetup{subrefformat=parens} % \caption{Two animals: \subref{cat6.3} a huge cat, and \subref{elephant6.3} an elephant} % \end{minipage} % % \pagebreak[3] % \subsection{Where to place the \cs{label} command?} % \label{label} % % When using |\sub|\-|caption| or |\phantom|\-|sub|\-|caption|, % or |\caption| or |\phantom|\-|caption| inside a |sub|\-|figure| or |sub|\-|table| environment, % the |\label| can be either placed inside the caption text or right after the |\sub|\-|caption| or % |\caption| command, e.g: % \begin{quote} % |\subcaption{Some text here\label{label1}}|\\ % \ldots\\ % |\subcaption{Some other text}\label{label2}}|\\ % \ldots\\ % |\subcaption{Something different}|\\ % |\label{label3}| % \end{quote} % % When using the |\sub|\-|caption|\-|box| command, the |\label| should be placed inside % the caption text, e.g.: % \begin{quote} % |\subcaptionbox{A description here\label{label4}}|\\ % | {Some content here}|\\ % \ldots\\ % |\subcaptionbox[List-of-Figures entry]|\\ % | {A description here\label{label5}}|\\ % | {Some content here}| % \end{quote} % % \pagebreak[3] % \subsection{Where do hyperlinks jump?} % \label{hypcap} % % For the |subfigure| \& |subtable| environments and |\subcaptionbox| boxes % (and own constructs which use |\set|\-|caption|\-|sub|\-|type|) the % hyperlink anchors will be placed in respect to the |hypcap=| setting. % While usage of this option is straight-forward for ordinary captions, % the usage for sub-captions depends on the setting regarding 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[3] % \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 % \iffalse % \bibitem{subfig} % Steven D. Cochran:\\ % \href{http://tug.ctan.org/tex-archive/macros/latex/contrib/subfig/}% % {\emph{The subfig package}}, % 2005/07/05 % \fi % \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}} % \changes{v1.0}{2008/03/16}{\cs{subfloat} added} % \changes{v1.0c}{2010/10/27}{An error message will be issued when the subfigure or subfig package is loaded} % \changes{v1.0c}{2011/01/22}{Undocumented command \cs{subfloat} removed} % % \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] \def\caption@tempa$Id: #1 #2 #3-#4-#5 #6${% \def\caption@tempa{#3/#4/#5 }\def\caption@tempb{#2 }} \caption@tempa $Id: subcaption.dtx 75 2013-04-16 17:57:13Z sommerfeldt $ \ProvidesPackage{subcaption}[\caption@tempa v1.1-\caption@tempb Sub-captions (AR)] % \end{macrocode} % % \subsection{Initial code} % % Since we base on the \package{caption} package we load it here. % \begin{macrocode} \RequirePackage{caption}[2012/03/25] % needs v3.3 or newer % \end{macrocode} % \changes{v1.1b}{2011/09/01}{Compatibility error added} % \begin{macrocode} \caption@AtBeginDocument{\caption@ifcompatibility{% \caption@Error{% The `subcaption' package does not work correctly\MessageBreak in compatibility mode}}{}} % \end{macrocode} % % Since we are incompatible to them an error message will be issued when % the \package{subfigure} or \package{subfig} package is loaded. % \begin{macrocode} \@ifpackageloaded{subfigure}{% \PackageError{subcaption}% {This package can't be used in cooperation\MessageBreak with the subfigure package}% {RTFM}% \endinput}{}% % \end{macrocode} % \begin{macrocode} \@ifpackageloaded{subfig}{% \PackageError{subcaption}% {This package can't be used in cooperation\MessageBreak with the subfig package}% {RTFM}% \endinput}{}% % \end{macrocode} % % \iffalse % \subsection{Declaration of options} % We do not have own options. % \fi % % \subsection{Execution of options} % % We use |\caption@ExecuteOptions| and |\caption@ProcessOptions| here to add % the options to the `|sub|' option list instead of executing them immediately. % \begin{macrocode} \caption@SetupOptions{subcaption}{\captionsetup[sub]{#2}}% \caption@ExecuteOptions{subcaption}{% font+=small,labelformat=parens,labelsep=space,skip=6pt,list=0,hypcap=0} \caption@ProcessOptions*{subcaption} % \end{macrocode} % % \subsection{Main code} % % \changes{v1.1c}{2011/10/30}{Adapted to the newfloat package} % We call |\Declare|\-|Caption|\-|Sub|\-|Type| for |figure|, |table|, % and each caption type declared with |\Declare|\-|Floating|\-|Environment| here. % \begin{macrocode} \caption@ForEachType{\DeclareCaptionSubType{#1}} % \end{macrocode} % % \pagebreak[3] % \subsubsection{The \cs{subcaption} command} % % \begin{macro}{\subcaption} % \changes{v1.1f}{2012/04/06}{\cs{newcommand} changed to \cs{def} % so it works with the \puresf{memoir} document class, too} % Without a prefacing |\set|\-|caption|\-|sub|\-|type|, |\sub|\-|caption| is some kind % of |\caption|\-|of{sub|\-|\@cap|\-|type}|. % \Note{Like \cs{captionof}, this command is designed to be used inside an % own group!} % \begin{macrocode} \def\subcaption{% \caption@iftype {\setcaptionsubtype*\caption}% {\caption@Error{\noexpand\subcaption outside float}% \caption@gobble}}% % \end{macrocode} % But with a prefacing |\set|\-|caption|\-|sub|\-|type|, |\sub|\-|caption| is simply % |\caption|. % \begin{macrocode} \g@addto@macro\caption@subtypehook{% \let\subcaption\caption} % \end{macrocode} % \end{macro} % % \pagebreak[3] % \subsubsection{The \cs{phantomsubcaption} command} % % \begin{macro}{\phantomsubcaption} % \changes{v1.1}{2011/08/17}{This macro added} % Same as |\phantom|\-|caption|, but for subfigures. % \begin{macrocode} \newcommand*\phantomsubcaption{% \caption@iftype {\setcaptionsubtype*\phantomcaption}% {\caption@Error{\noexpand\phantomsubcaption outside float}}}% % \end{macrocode} % \begin{macrocode} \g@addto@macro\caption@subtypehook{% \let\phantomsubcaption\phantomcaption} % \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 % |\setcaptionsubtype| 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|\-|Floating|\-|Environment| 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}% \setcaptionsubtype\relax} % \end{macrocode} % \end{macro} % \end{macro} % % \pagebreak[3] % \subsubsection{The \cs{subcaptionbox} command} % % \begin{macro}{\subcaptionbox} % \changes{v1.0a}{2008/05/06}{Adapted to the \opt{rule} option of the \package{caption} package} % \changes{v1.0b}{2008/08/31}{Definition and usage of \cs{subcaption@hrule} added} % \changes{v1.0c}{2010/12/17}{Uses \cs{caption@box} now} % \changes{v1.1}{2011/08/16}{Adapted to actual version of \cs{caption@box}} % \changes{v1.1f}{2012/04/09}{Adapted to actual version of \cs{caption@ibox}} % A |\parbox| with contents and sub-caption, separated by an invisible |\hrule|. % \begin{macrocode} \newcommand*\subcaptionbox{% \caption@withoptargs{\caption@ibox\setcaptionsubtype}} % \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} % \changes{v1.1b}{2011/09/12}{Redefinition of \cs{SK@} added} % \changes{v1.1b}{2011/09/12}{Uses \cs{caption@withoptargs} now} % 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{ \caption@withoptargs\subcaption@@label} % \end{macrocode} % \begin{macrocode} \newcommand*\subcaption@@label[2]{% \@bsphack\begingroup \subcaption@ORI@label#1{#2}% \let\SK@\@gobbletwo \protected@edef\@currentlabel{\csname thesub\@captype\endcsname}% \subcaption@ORI@label#1{sub@#2}% \endgroup\@esphack} % \end{macrocode} % \end{macro} % % \begin{macro}{\subref} % \changes{v1.1}{2011/08/14}{Caption option \opt{subrefformat=} added} % \changes{v1.1a}{2011/08/18}{Uses \cs{caption@setoptions*} now} % \changes{v1.1d}{2012/01/12}{Usage of \cs{caption@setoptions*} replaced by \cs{caption@setoptions}} % \changes{v1.1f}{2012/04/09}{Revised} % This one calls |\ref| with the second label. (see |\subcaption@label|) % \begin{macrocode} \DeclareRobustCommand*\subref{% \@ifstar {\caption@withoptargs\subcaption@ref*}% {\caption@withoptargs\@subref}} \newcommand*\@subref[2]{% \caption@ifundefined\hyperref {\subcaption@ref{#1}{#2}}% {\hyperref[#2]{\subcaption@ref{*#1}{#2}}}} % \end{macrocode} % \begin{macrocode} \newcommand*\subcaption@ref[2]{% \begingroup \caption@setoptions{sub}% \subcaption@reffmt\p@subref{\ref#1{sub@#2}}% \endgroup} % \end{macrocode} % \begin{macrocode} \newcommand*\p@subref{} % \end{macrocode} % \end{macro} % % \begin{macrocode} \DeclareCaptionOption{subrefformat}{\subcaption@setrefformat{#1}} % \end{macrocode} % % \begin{macro}{\subcaption@setrefformat} % |\subcaption@setrefformat|\marg{name}\par % Selecting a subref format simply means saving the code (in |\subcaption@reffmt|). % \begin{macrocode} \newcommand*\subcaption@setrefformat[1]{% \@ifundefined{caption@lfmt@#1}% {\caption@Error{Undefined label format `#1'}}% {\expandafter\let\expandafter\subcaption@reffmt\csname caption@lfmt@#1\endcsname}} % \end{macrocode} % \begin{macrocode} \subcaption@setrefformat{simple} % \end{macrocode} % \end{macro} % % \iffalse % % \fi % % \iffalse % --------------------------------------------------------------------------- % % \fi % % \Finale % \endinput