diff options
author | Karl Berry <karl@freefriends.org> | 2011-08-21 23:25:38 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2011-08-21 23:25:38 +0000 |
commit | 4bf6d40e1871037aeeadbc08a3aaadf63bd5afc6 (patch) | |
tree | b449d37a95705baa0f91a85a60cfc32120fffdc2 /Master/texmf-dist/source/latex/caption/subcaption.dtx | |
parent | 4a9457dbad19d024d5327f667ed95f5cae64d41c (diff) |
caption (21aug11 and earlier)
git-svn-id: svn://tug.org/texlive/trunk@23635 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/caption/subcaption.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/caption/subcaption.dtx | 413 |
1 files changed, 316 insertions, 97 deletions
diff --git a/Master/texmf-dist/source/latex/caption/subcaption.dtx b/Master/texmf-dist/source/latex/caption/subcaption.dtx index 413d66da4ec..27226210f65 100644 --- a/Master/texmf-dist/source/latex/caption/subcaption.dtx +++ b/Master/texmf-dist/source/latex/caption/subcaption.dtx @@ -2,7 +2,7 @@ % % This is file `subcaption.dtx'. % -% Copyright (C) 2007-2010 Axel Sommerfeldt (axel.sommerfeldt@f-m.fm) +% Copyright (C) 2007-2011 Axel Sommerfeldt (axel.sommerfeldt@f-m.fm) % % -------------------------------------------------------------------------- % @@ -25,12 +25,12 @@ % caption-eng.tex, and caption-rus.tex. % % \fi -% \CheckSum{78} +% \CheckSum{139} % % \iffalse %<*driver> \NeedsTeXFormat{LaTeX2e}[1994/12/01] -\ProvidesFile{subcaption.drv}[2010/09/04 v1.0 Adds a sub-caption feature to the caption package] +\ProvidesFile{subcaption.drv}[2011/08/17 v1.1 Adds a sub-caption feature to the caption package] \hbadness=9999 \newcount\hbadness \hfuzz=74pt % Make TeX shut up. %\errorcontextlines=3 % @@ -47,19 +47,20 @@ \addtolength\marginparwidth{15pt} \ifdim\paperheight=297mm % a4paper \renewcommand\LineBreak{\\} - \renewcommand\PageBreak{\clearpage} + \renewcommand\PageBreak{\clearpage} \fi \fi % \usepackage[bottom]{footmisc} -\usepackage{array,graphicx,pict2e,slashbox} +\usepackage{array,graphicx,overpic,pict2e,slashbox} \IfFileExists{test/tlc2/cat.eps}{\graphicspath{{test/tlc2/}}}{}% % +\PassOptionsToPackage{breaklinks=true}{hyperref} \usepackage{hypdoc} \ifpdf\usepackage{hypdestopt}\fi \hypersetup{pdfkeywords={LaTeX, package, subcaption},pdfstartpage={},pdfstartview={}} % -\usepackage{subcaption}[2010/09/01] +\usepackage{subcaption}[2011/08/01] % needs v1.1 or newer \DeclareCaptionSubType*[arabic]{table} \captionsetup[subtable]{labelformat=simple,labelsep=colon} % @@ -139,21 +140,18 @@ % |\caption@sub|\-|type|\-|hook| (offered by the \package{caption} package). % \end{background*} % -% \setcounter{tocdepth}{2} -% \tableofcontents -% -% \iffalse -% \vfill +% \bigskip % \INFO* % \emph{Please note:} % This package is incompatible with the \package{subfigure} and \package{subfig} % packages. -% \fi % % \clearpage -% \section{The user interface} +% \setcounter{tocdepth}{2} +% \tableofcontents % -% \subsection{Loading the package} +% \clearpage +% \section{Loading the package} % % Load this package using % \begin{quote} @@ -221,7 +219,7 @@ % \end{quote} % % \PageBreak -% \subsection{The \cs{subcaption} command} +% \section{The \cs{subcaption} command} % % \DescribeMacro\subcaption % The easiest and most flexible method to apply a sub-caption is by using the @@ -251,7 +249,7 @@ % gives the result: % \par\bigskip % \noindent\begin{minipage}{\linewidth} -% \captionsetup{type=figure} +% \setcaptiontype{figure} % \begin{minipage}[b]{.5\linewidth} % \centering\large A % \subcaption{A subfigure}\label{fig:1a} @@ -266,21 +264,20 @@ % \bigskip % % \begin{background} -% 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. -% Analogous to the |type| option of the \package{caption} package, -% the |subtype| option sets the sub-type of the box or environment +% 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 -% |\caption|\-|setup{sub|\-|type*}| and |\caption|. +% |\set|\-|caption|\-|sub|\-|type*| and |\caption|. % \end{background} % % \PageBreak -% \subsection{The subfigure \& subtable environments} +% \section{The subfigure \& subtable environments} % % \DescribeEnv{subfigure} % \DescribeEnv{subtable} @@ -327,14 +324,14 @@ % % \begin{background} % The |subfigure| \& |subtable| environments are just simple minipage -% environments with |\caption|\-|setup|\x|{subtype}| as first contents line. +% 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 |\DeclareCaptionSubType|. % \end{background} % % \PageBreak -% \subsection{The \cs{subcaptionbox} command} +% \section{The \cs{subcaptionbox} command} % % \DescribeMacro\subcaptionbox % A more powerful (but less flexible) way of setting sub-figures is @@ -382,7 +379,7 @@ % \end{quote} % gives the result:\par % \noindent\begin{minipage}{\linewidth} -% \captionsetup{type=figure} +% \setcaptiontype{figure} % \centering % \subcaptionbox{A cat\label{cat}} % {\includegraphics[width=30pt]{cat}} @@ -406,7 +403,7 @@ % | |\ldots % \end{quote} % \noindent\begin{minipage}{\linewidth} -% \captionsetup{type=figure} +% \setcaptiontype{figure} % \centering % \subcaptionbox{A cat\label{cat2}} % [2.5cm]{\includegraphics[width=30pt]{cat}} @@ -430,7 +427,7 @@ % | |\ldots % \end{quote} % \noindent\begin{minipage}{\linewidth} -% \captionsetup{type=figure} +% \setcaptiontype{figure} % \centering % \subcaptionbox{A cat\label{cat3}} % [.4\linewidth]{\includegraphics[width=39.34724pt]{cat}}%^^A @@ -443,7 +440,7 @@ % % \iffalse % \noindent\begin{minipage}{\linewidth} -% \captionsetup{type=figure} +% \setcaptiontype{figure} % \centering % \hbox{\subcaptionbox{An elephant\label{elephant4}} % {\includegraphics[width=.4\textwidth]{elephant}}%^^A @@ -458,46 +455,19 @@ % % \begin{background} % The |\sub|\-|caption|\-|box| is a |\par|\-|box| with -% |\caption|\-|setup{sub|\-|type}| as first contents line. +% |\set|\-|caption|\-|sub|\-|type| as first contents line. % \iffalse See implementation for details.\fi % \end{background} % % \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{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 \cs{DeclareCaptionSubType} command} +% \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~\footnote{%^^A +% 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.} +% could be used for this purpose as well.}\fi % \begin{quote} % |\DeclareCaptionSubType|\oarg{numbering scheme}\marg{type}\\ % |\DeclareCaptionSubType*|\oarg{numbering scheme}\marg{type} @@ -521,11 +491,11 @@ % 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|, +% 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 for defining new sub-caption types only, +% 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 @@ -534,11 +504,11 @@ % |\captionsetup[subtable]{labelformat=simple,labelsep=colon}| % \end{quote} % \endgroup -% \pagebreak[3] +% \pagebreak[2] % will give you sub-captions in |table|s like these ones: % \par\bigskip % \noindent\begin{minipage}{\linewidth} -% \captionsetup{type=table} +% \setcaptiontype{table} % \centering % \caption{Two tables} % \subcaptionbox{Table one}[3cm][c]{\begin{tabular}{cc}A & B\\ C & D\\ \end{tabular}} @@ -550,15 +520,201 @@ % 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} +% +% 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} +% itstead 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 |\captionsetup{subtype}|) the +% (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 ordinary captions, -% the usage for sub-captions depends on the setting for the main captions. +% 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 @@ -600,7 +756,7 @@ % \fi % % \pagebreak[3] -% \subsection{Beyond this package} +% \section{Beyond this package} % \label{floatrow} % % For a more advanced usage of the sub-caption feature of the @@ -612,7 +768,7 @@ % --------------------------------------------------------------------------- % % \fi % -% \pagebreak[2] +% \pagebreak[3] % \section{Thanks} % % I would like to thank @@ -644,11 +800,13 @@ % \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} % } % @@ -725,33 +883,33 @@ % \subsection{Identification} % \begin{macrocode} \NeedsTeXFormat{LaTeX2e}[1994/12/01] -\ProvidesPackage{subcaption}[2011/01/22 v1.0c Adding subcaptions (AR)] +\ProvidesPackage{subcaption}[2011/08/18 v1.1a Adding subcaptions (AR)] % \end{macrocode} % % \subsection{Initial code} % +% Since we base on the \package{caption} package we load it here. +% \begin{macrocode} +\RequirePackage{caption}[2011/08/18] % needs v3.2b or newer +% \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} -\@ifundefined{subfigure}{}{% +\caption@ifundefined\subfigure{}{% \PackageError{subcaption}{% This package can't be used in cooperation\MessageBreak - with the subfigure package}% + with the subfigure package}{RTFM}% \endinput} % \end{macrocode} % \begin{macrocode} -\@ifundefined{subfloat}{}{% +\caption@ifundefined\subfloat{}{% \PackageError{subcaption}{% This package can't be used in cooperation\MessageBreak - with the subfig package}% + with the subfig package}{RTFM}% \endinput} % \end{macrocode} % -% Since we base on the \package{caption} package we load it here. -% \begin{macrocode} -\RequirePackage{caption}[2010/12/01] % needs v3.2 or newer -% \end{macrocode} -% % \iffalse % \subsection{Declaration of options} % We do not have own options. @@ -770,11 +928,11 @@ % % \subsection{Main code} % -% We call |\DeclareCaptionSubType| for |figure|, |table|, -% and every caption type declared with |\DeclareCaptionType| here. +% We call |\Declare|\-|Caption|\-|Sub|\-|Type| for |figure|, |table|, +% and every caption type declared with |\Declare|\-|Caption|\-|Type| here. % \begin{macrocode} -\@ifundefined{c@figure}{}{\DeclareCaptionSubType{figure}} -\@ifundefined{c@table}{}{\DeclareCaptionSubType{table}} +\caption@ifundefined\c@figure{}{\DeclareCaptionSubType{figure}} +\caption@ifundefined\c@table{}{\DeclareCaptionSubType{table}} \caption@For{typelist}{\DeclareCaptionSubType{#1}} % \end{macrocode} % @@ -782,17 +940,40 @@ % \subsubsection{The \cs{subcaption} command} % % \begin{macro}{\subcaption} -% Without a prefacing |\captionsetup{subtype}|, \cs{subcaption} is some kind -% of |\captionof{sub\@captype}|. +% 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} -\newcommand*\subcaption{\captionsetup{subtype*}\caption} +\newcommand*\subcaption{% + \caption@iftype + {\setcaptionsubtype*\caption}% + {\caption@Error{\noexpand\subcaption outside float}% + \caption@withoptargs\@gobbletwo}}% % \end{macrocode} -% But with a prefacing |\captionsetup{subtype}|, \cs{subcaption} is simply +% But with a prefacing |\set|\-|caption|\-|sub|\-|type|, |\sub|\-|caption| is simply % |\caption|. % \begin{macrocode} -\g@addto@macro\caption@subtypehook{\let\subcaption\caption} +\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} % @@ -802,7 +983,7 @@ % \begin{macro}{subfigure} % \begin{macro}{subtable} % This is just an ordinary \env{minipage} environment with -% |\captionsetup{subtype}| as first contents line. +% |\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|\-|Caption|\-|Type| a corresponding `sub' environment @@ -816,7 +997,7 @@ % \begin{macrocode} \newcommand*\subcaption@minipage[2]{% \minipage#1{#2}% - \captionsetup{subtype}} + \setcaptionsubtype\relax} % \end{macrocode} % \end{macro} % \end{macro} @@ -828,10 +1009,11 @@ % \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}} % A |\parbox| with contents and sub-caption, separated by an invisible |\hrule|. % \begin{macrocode} \newcommand*\subcaptionbox{% - \def\captionbox@type{subtype}% + \let\captionbox@settype\setcaptionsubtype \caption@withoptargs\caption@box} % \end{macrocode} % \end{macro} @@ -863,10 +1045,47 @@ % \end{macro} % % \begin{macro}{\subref} -% This simply calls |\ref| with the second label. (see |\subcaption@label|) +% \changes{v1.1}{2011/08/14}{Caption option \opt{subrefformat=} added} +% \changes{v1.1a}{2011/08/18}{Uses \cs{caption@setoptions} now} +% This one calls |\ref| with the second label. (see |\subcaption@label|) +% \begin{macrocode} +\DeclareRobustCommand*\subref{\@ifstar{\subcaption@ref*}\@subref} +\newcommand*\@subref{% + \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{% + \caption@withoptargs\subcaption@@ref} +\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} -\DeclareRobustCommand*\subref{\caption@withoptargs\subcaption@ref} -\newcommand*\subcaption@ref[2]{\ref#1{sub@#2}} +\subcaption@setrefformat{simple} % \end{macrocode} % \end{macro} % |