summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/caption/subcaption.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/caption/subcaption.dtx')
-rw-r--r--macros/latex/contrib/caption/subcaption.dtx325
1 files changed, 228 insertions, 97 deletions
diff --git a/macros/latex/contrib/caption/subcaption.dtx b/macros/latex/contrib/caption/subcaption.dtx
index 31b76d94fd..0283d91eef 100644
--- a/macros/latex/contrib/caption/subcaption.dtx
+++ b/macros/latex/contrib/caption/subcaption.dtx
@@ -2,7 +2,7 @@
%
% This is file `subcaption.dtx'.
%
-% Copyright (C) 2007-2022 Axel Sommerfeldt (axel.sommerfeldt@f-m.fm)
+% Copyright (C) 2007-2023 Axel Sommerfeldt (axel.sommerfeldt@f-m.fm)
%
% --------------------------------------------------------------------------
%
@@ -31,12 +31,12 @@
%
% \fi
%
-% \CheckSum{468}
+% \CheckSum{513}
%
% \iffalse
%<*driver>
\NeedsTeXFormat{LaTeX2e}[1994/12/01]
-\ProvidesFile{subcaption.drv}[2022/02/20 v1.5 Adds a sub-caption feature to the caption package]
+\ProvidesFile{subcaption.drv}[2023/02/19 v1.6 Adds a sub-caption feature to the caption package]
\hbadness=9999 \newcount\hbadness \hfuzz=74pt % Make TeX shut up.
%\errorcontextlines=3
%
@@ -67,7 +67,7 @@
\newcommand*\purerm[1]{{\upshape\mdseries\rmfamily #1}}
\newcommand*\puresf[1]{{\upshape\mdseries\sffamily #1}}
\newcommand*\purett[1]{{\upshape\mdseries\ttfamily #1}}
-\let\pkg\puresf
+\let\cls\puresf \let\pkg\puresf
\let\env\purett \let\opt\purett
%
\newcommand*\csmarg[1]{\texttt{\char`\{#1\char`\}}}
@@ -148,11 +148,6 @@
% This package demonstrates its usage by offering a high-level user interface additionally.
% \end{background*}
%
-% \bigskip
-% \INFO
-% \emph{Please note:}
-% This package is incompatible with the \pkg{subfigure} and \pkg{subfig} packages.
-%
% \clearpage
% \setcounter{tocdepth}{2}
% \tableofcontents
@@ -178,7 +173,7 @@
% is identical to
% \begin{quote}
% |\usepackage{subcaption}|\\
-% |\captionsetup[sub]|\marg{options}\quad.
+% |\subcaptionsetup|\marg{options}\quad.
% \end{quote}
%
% \bigskip
@@ -193,10 +188,57 @@
% specifying the option \texttt{list=true}.}
% \end{quote}
%
+% \iffalse
+% --------------------------------------------------------------------------- %
+% \fi
+%
+% \PageBreak
+% \section{Setting options}
+% \label{sec:options}
+%
+% \DescribeMacro\subcaptionsetup
+% \NEWfeature*{v1.6}
+% The |\subcaptionsetup| command sets options specifically for sub-captions.
+%
+% \begin{quote}
+% |\subcaptionsetup|\marg{options}
+% \end{quote}
+% sets options valid for all sub-captions.
+%
+% \pagebreak[3]
+% An example:
+% \begin{quote}
+% |\subcaptionsetup{font=it}|
+% \end{quote}
+% sets the font to ``italic'' for all sub-captions.
+%
+% \medskip
+%
+% \begin{quote}
+% |\subcaptionsetup|\oarg{environment}\marg{options}
+% \end{quote}
+% is an alternative syntax to
+% \begin{quote}
+% |\caption|\-|setup[sub|\meta{environment}|]|\marg{options}\quad.
+% \end{quote}
+%
+% \pagebreak[3]
+% An example:
+% \begin{quote}
+% |\subcaptionsetup[table]{labelformat=simple}|
+% \end{quote}
+% is identical to
+% \begin{quote}
+% |\captionsetup[subtable]{labelformat=simple}|
+% \end{quote}
+% and sets the labelformat to ``simple'' for all sub-captions inside tables.
+%
+% \bigskip
+%
% Options specified with |\usepackage[|\ldots|]{sub|\-|caption}| and
-% |\caption|\-|setup[sub]{|\ldots|}| will override the ones specified by
+% |\sub|\-|caption|\-|setup{|\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|}|
+% but are again overwritten by |\subcaption|\-|setup[figure]{|\ldots|}|
% (same for `table'). So finally we have the following order how
% settings for sub-captions are applied:
% \begin{enumerate}
@@ -209,9 +251,9 @@
% \item Default `sub' settings
% {\small(|margin=0pt,font+=smaller,|\ldots, see above)}
% \item Custom `sub' settings
-% {\small(|\usepackage[|\ldots|]{subcaption}| and |\captionsetup[sub]{|\ldots|}|)}
+% {\small(|\usepackage[|\ldots|]{subcaption}| and |\subcaptionsetup{|\ldots|}|)}
% \item Environmental `sub' settings
-% {\small(|\captionsetup[subfigure|\emph{ -or- }|subtable]{|\ldots|}|)}
+% {\small(|\subcaptionsetup[figure|\emph{ -or- }|table]{|\ldots|}|)}
% \item Local `sub' settings
% {\small(|\captionsetup{|\ldots|}| inside |sub|\-|figure| or |sub|\-|table|)}
% \end{enumerate}
@@ -222,9 +264,9 @@
% |\usepackage[labelsep=quad,indention=10pt]{caption}|\\
% |\usepackage[labelfont=bf,list=true]{subcaption}|\\
% |\captionsetup[table]{textfont=it,position=top}|\\
-% |\captionsetup[subtable]{textfont=sf}|
+% |\subcaptionsetup[table]{textfont=sf}|
% \end{quote}
-% causes the captions inside |sub|\-|table| environments to be typeset with
+% causes sub-captions inside |table| environments to be typeset with
% the settings
% \begin{quote}
% |indention=10pt,position=top,margin=0pt,font=small,|\\
@@ -258,8 +300,8 @@
% \meta{width} is the width of the resulting |\par|\-|box|; the default value is the width of the contents.
%
% \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).
+% it can be either `c' (centered, using |\centering|), `l' (left-justified, using |\ragged|\-|right|),
+% `r' (right-justified, using |\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,
@@ -401,13 +443,13 @@
% \end{quote}
% \endgroup
%
-% The default value for \meta{outer-pos} is `b' and the default value for \meta{inner-pos} is `s'.
-% (Note that the default value for \meta{outer-pos} has changed from `c' to `b' in version $1.5$ of \thispackage.)
+% The default value for \meta{outer-pos} is either `b' (if no main caption was typeset so far) or `t' (if a main caption was already typeset),
+% and the default value for \meta{inner-pos} is `s'.
%
% \NEWfeature{v1.2}
% Beside the \meta{outer-pos} values of `c', `t', and `b', \thispackage\ also offers the
-% values `T' and `B' additionally which align the |sub|\-|figure| at the
-% very top resp.~bottom. (In contrast `t' and `b' align the |sub|\-|figure| at the
+% values `T' and `B' additionally which align the contents at the
+% very top resp.~bottom. (In contrast `t' and `b' align the contents at the
% top resp.~bottom \textit{baseline}.)
%
% \bigskip
@@ -494,6 +536,8 @@
% So if in doubt, or when writing own \LaTeX\ commands which should work in every floating environment,
% using |sub|\-|caption|\-|block| is the correct choice.
%
+% (Note that the default value for \meta{outer-pos} has changed from `c' to either `b' or `t' in version $1.5$ of \thispackage.)
+%
% \smallskip
%
% \begin{background}
@@ -657,7 +701,7 @@
% \leftmargini=12pt
% \begin{quote}
% |\DeclareCaptionSubType*[arabic]{table}|\\
-% |\captionsetup[subtable]{labelformat=simple,labelsep=colon}|
+% |\subcaptionsetup[table]{labelformat=simple,labelsep=colon}|
% \end{quote}
% \endgroup
% \pagebreak[2]
@@ -698,8 +742,8 @@
% \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}|
+% |\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| $=$
@@ -708,8 +752,8 @@
% 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{}|
+% |\renewcommand\thesubfigure{\thefigure.\arabic{subfigure}}|\\
+% |\renewcommand\p@subfigure{}|
% \end{quote}
%
% But if you want detailed control on how the references will look like,
@@ -720,8 +764,8 @@
% 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})}|
+% |\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|.)}
@@ -730,10 +774,10 @@
% 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}|
+% |\usepackage{subcaption}|\\
+% |\renewcommand\thesubfigure{\alph{subfigure})}|\\
+% |\DeclareCaptionLabelFormat{opening}{(#2}|\\
+% |\subcaptionsetup[figure]{labelformat=opening}|
% \end{quote}
%
% \bigskip
@@ -1253,11 +1297,11 @@
% \begin{quote}
% |\begin{figure}|\\
% | \centering|\\
-% | \captionsetup[subfigure]|\\
+% | \subcaptionsetup[figure]|\\
% | {skip=-28pt,slc=off,margin={25pt,0pt}}|\\
% | \subcaptionbox{\label{cat}}|\\
% | {\includegraphics[width=60pt]{cat}}|\\
-% | \captionsetup[subfigure]|\\
+% | \subcaptionsetup[figure]|\\
% | {skip=-60pt,slc=off,margin={80pt,0pt}}|\\
% | \subcaptionbox{\label{elephant}}|\\
% | {\includegraphics[width=140pt]{elephant}}|\\
@@ -1512,12 +1556,12 @@
% \begin{minipage}{\textwidth}
% \centering
% \begin{tabular}{l|l|l}
-% Regular command & with \cs{setcaptionsubtype*} & available since \\
+% Regular command & using \cs{setcaptionsubtype*} & available since \\
% \hline
-% |\caption| & |\subcaption| & \version{1.0} \\
-% |\phantomcaption| & |\phantomsubcaption| & \version{1.1} \\
-% |\captionlistentry| & |\subcaptionlistentry| & \version{1.5} \\
-% |\captiontext| & |\subcaptiontext| & \version{1.5} \\
+% |\caption| & |\subcaption| & \version{1.0} \\
+% |\phantomcaption| & |\phantomsubcaption| & \version{1.1} \\
+% |\captionlistentry| & |\subcaptionlistentry| & \version{1.5} \\
+% |\captiontext| & |\subcaptiontext| & \version{1.5} \\
% \end{tabular}
% \end{minipage}
%
@@ -1597,6 +1641,52 @@
% --------------------------------------------------------------------------- %
% \fi
%
+% \section{Other packages with similar offerings}
+% \label{sec:otherpackages}
+%
+% The \pkg{subcaption} package is not the only one defining sub-figure counters and offering commands or environments to typeset sub-figures.
+% The most established are:
+% \begin{itemize}
+% \item The \cls{memoir} document class
+% \item The \pkg{subfigure} package and its successor, the \pkg{subfig} package
+% \end{itemize}
+%
+% \NEWfeature{v1.6}
+% Prior subcaption version $1.6$ an error message was issued if the `subfigure' or `subtable' counter was already defined by any of them.
+% Since subcaption version $1.6$ the `subfigure' and `subtable' counters will only be defined by the \pkg{subcaption} package if they are not defined yet,
+% but the usage of any of the commands or environments described in this document will result in an error message ``The counter sub\ldots was defined by \ldots''
+% if the corresponding counter was not defined by the \pkg{subcaption} package.
+% Equally the commands or environments offered by the above document classes or packages should not be used with counters defined by the \pkg{subcaption} package,
+% this will result in either \LaTeX\ errors or unwanted behaviour.
+%
+% So the rule of thumb is:
+% If the counter `subfigure' or `subtable' is defined by document class or package \textit{xyz},
+% then the corresponding commands and environments offered by the document class or package \textit{xyz} should be used.
+%
+% \pagebreak[3]
+% An example document:
+% \begingroup\small\leftmargini=12pt\relax
+% \begin{quote}
+% |\documentclass{memoir}|\\
+% |\newsubfloat{table} % defines the `subtable' counter|\\
+% |\usepackage{subcaption} % defines the `subfigure' counter|\\
+% |\begin{document}|\\
+% |\begin{figure}|\\
+% |\subcaptionbox{...}{...} % <- This is fine|\\
+% |\caption{...}|\\
+% |\end{figure}|\\
+% |\begin{table}|\\
+% |\caption{...}|\\
+% |\subcaptionbox{...}{...} % <- This results in an error,|\\
+% |\end{table} \subtop should be used instead|\\
+% |\end{document}|\\
+% \end{quote}
+% \endgroup
+%
+% \iffalse
+% --------------------------------------------------------------------------- %
+% \fi
+%
% \PageBreak
% \section{Beyond this package}
% \label{keyfloat}\label{floatrow}
@@ -1783,7 +1873,7 @@
%
% Identify the current version of the package.
% \begin{macrocode}
-\ProvidesPackage{subcaption}[2022/01/07 v1.5 Sub-captions (AR)]
+\ProvidesPackage{subcaption}[2023/02/19 v1.6 Sub-captions (AR)]
% \end{macrocode}
%
% Since we base on the \pkg{caption} package we load it here.
@@ -1793,6 +1883,16 @@
%
% \subsection{Initial code}
%
+% \begin{macro}{\subcaption@Info}
+% \changes{v1.6}{2022/04/07}{This macro added}
+% |\subcaption@Info|\marg{message}\\
+% issues an info message (with code line indication).
+% \begin{macrocode}
+\newcommand*\subcaption@Info{%
+ \PackageInfo{subcaption}}
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macro}{\subcaption@Warning}
% \changes{v1.5}{2022/01/06}{This macro added}
% |\subcaption@Warning|\marg{message}\\
@@ -1828,43 +1928,19 @@
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\subcaption@CheckCompatibility}
-% \changes{v1.1}{2011/09/01}{Compatibility error added}
-% \changes{v1.1}{2016/05/22}{The presence of \pkg{subfigure} or \pkg{subfig} will be checked \cs{AtBeginDocument}, too}
-% \changes{v1.3g}{2020/08/01}{Error text adapted to \pkg{caption} package~\version{4.0}}
-% \changes{v1.4}{2020/12/22}{Adapted to fallback concept}
-% Since we are incompatible to them an error message will be issued when
-% the \pkg{subfigure} or \pkg{subfig} package is loaded.
-% \begin{macrocode}
-\newcommand*\subcaption@CheckCompatibility{%
-% \end{macrocode}
-% \begin{macrocode}
- \@ifpackageloaded{subfigure}{%
- \subcaption@Error
- {This package can't be used in cooperation\MessageBreak
- with the subfigure package}%
- \endinput}{}%
-% \end{macrocode}
-% \begin{macrocode}
- \@ifpackageloaded{subfig}{%
- \subcaption@Error
- {This package can't be used in cooperation\MessageBreak
- with the subfig package}%
- \endinput}{}%
-% \end{macrocode}
-% \begin{macrocode}
-}
-% \end{macrocode}
+% \subsection{Main code}
+%
+% \begin{macro}{\subcaptionsetup}
+% \changes{v1.6}{2023/02/19}{This macro definition added}
+% |\subcaptionsetup*|\oarg{environment}\marg{options}
+% is an abbreviation for |\caption|\-|setup*[sub|\meta{environment}|]|\marg{options},
+% especially |\sub|\-|caption|\-|setup|\marg{options} sets options valid for all sub-captions.
% \begin{macrocode}
-\subcaption@CheckCompatibility
-\caption@AtBeginDocument{%
- \subcaption@CheckCompatibility
- \let\subcaption@CheckCompatibility\@undefined}
+\newcommand*\subcaptionsetup[1][]{%
+ \@ifstar{\captionsetup*[{sub#1}]}{\captionsetup[{sub#1}]}}
% \end{macrocode}
% \end{macro}
%
-% \subsection{Main code}
-%
% \begin{macro}{\setcaptionsubtype}
% \changes{v1.4}{2020/12/24}{This macro definition added}
% \changes{v1.5}{2022/01/07}{Check added if used inside a floating environment}
@@ -1908,11 +1984,14 @@
% \changes{v1.3d}{2020/01/22}{Definition and usage of \cs{@subfloatboxreset} added}
% \changes{v1.5}{2022/01/07}{This macro definition out-sourced from \cs{subcaption@newminipage}}
% \changes{v1.5}{2022/01/07}{Usage of \cs{@ifnextchar} replaced by \cs{@testopt}}
-% \changes{v1.5}{2022/01/07}{Default value of \meta{outer-pos} changes from `c' to `b'}
+% \changes{v1.5}{2022/01/07}{Default value of \meta{outer-pos} changed from `c' to `b'}
+% \changes{v1.5a}{2022/04/16}{Default value of \meta{outer-pos} changed from `b' to either `b' or `t'}
% This is a \env{minipage} with |\set|\-|caption|\-|sub|\-|type| as first contents line.
% \begin{macrocode}
\newcommand*\subcaption@minipage{%
- \@testopt\subcaption@iminipage b}
+ \kernel@ifnextchar[%]
+ \subcaption@iminipage
+ {\caption@ifcaption{\subcaption@iminipage[t]}{\subcaption@iminipage[b]}}}
% \end{macrocode}
% We pass all other optional arguments using the generic helper macro
% |\caption@with|\-|opt|\-|args| offered by the \pkg{caption} kernel).
@@ -1947,6 +2026,10 @@
% \begin{macrocode}
\providecommand*\@subfloatboxreset{}
% \end{macrocode}
+% \begin{macrocode}
+\providecommand*\caption@ifcaption{\caption@ifflag2} % caption >= v3.3 < v3.6
+\providecommand*\caption@ifflag[1]{\@secondoftwo} % caption < v3.3
+% \end{macrocode}
% \end{macro}
%
% \begin{environment}{subcaptionblock}
@@ -2232,8 +2315,8 @@
% \begin{macrocode}
\let\caption@setkeys@ORI\caption@setkeys
\@ifundefined{caption@SetupOptions} % caption3 v1.3
- {\renewcommand\caption@setkeys[2]{\captionsetup[sub]{#2}}}
- {\caption@SetupOptions{subcaption}{\captionsetup[sub]{#2}}}
+ {\renewcommand\caption@setkeys[2]{\subcaptionsetup{#2}}}
+ {\caption@SetupOptions{subcaption}{\subcaptionsetup{#2}}}
% \end{macrocode}
% \begin{macrocode}
\@ifundefined{caption@smaller} % caption3 v1.7-169
@@ -2250,16 +2333,32 @@
\let\caption@setkeys@ORI\@undefined
% \end{macrocode}
%
+% \begin{macro}{\subcaption@DeclareType}
+% \changes{v1.6}{2022/04/07}{This macro added}
+% |\subcaption@DeclareType|\marg{type}\\
+% defines the sub-counter via |\Declare|\-|Caption|\-|Sub|\-|Type| offered by the \pkg{caption} package.
+% \begin{macrocode}
+\newcommand*\subcaption@DeclareType[1]{%
+ \@ifundefined{c@sub#1}%
+ {\DeclareCaptionSubType{#1}}%
+ {\caption@subtypesource\caption@subtype@source{sub#1}%
+ \subcaption@Info{The counter `sub#1' was already defined by\MessageBreak\caption@subtype@source}}}
+% \end{macrocode}
+% \begin{macrocode}
+\providecommand*\caption@subtypesource[2]{\def#1{a different package}} % caption3 v2.4
+% \end{macrocode}
+% \end{macro}
+%
% We call |\Declare|\-|Caption|\-|Sub|\-|Type| for |figure| and |table|,
% and each floating environment declared with |\Declare|\-|Floating|\-|Environment| here.
% \begin{macrocode}
\@ifundefined{ForEachCaptionType} % caption3 v1.13
{\@ifundefined{caption@ForEachType} % caption3 v1.4a
- {\@ifundefined{c@figure}{}{\DeclareCaptionSubType{figure}}%
- \@ifundefined{c@table}{}{\DeclareCaptionSubType{table}}%
- \caption@For{typelist}{\DeclareCaptionSubType{#1}}}
- {\caption@ForEachType{\DeclareCaptionSubType{#1}}}}
- {\ForEachCaptionType{\DeclareCaptionSubType{#1}}}
+ {\@ifundefined{c@figure}{}{\subcaption@DeclareType{figure}}%
+ \@ifundefined{c@table}{}{\subcaption@DeclareType{table}}%
+ \caption@For{typelist}{\subcaption@DeclareType{#1}}}
+ {\caption@ForEachType{\subcaption@DeclareType{#1}}}}
+ {\ForEachCaptionType{\subcaption@DeclareType{#1}}}
% \end{macrocode}
%
% \subsection{Bonus material}
@@ -2340,6 +2439,22 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\caption@subfloatrow@hook}
+% \changes{v1.6}{2022/04/17}{Support of this hook added}
+% Inside the |sub|\-|float|\-|row| environment offered by the \pkg{floatrow} package
+% the usage of |\caption| etc.~needs to be mapped to |\sub|\-|caption| etc.
+% \begin{macrocode}
+\providecommand*\caption@subfloatrow@hook{} % caption < v3.7
+% \end{macrocode}
+% \begin{macrocode}
+\g@addto@macro\caption@subfloatrow@hook{%
+ \let\caption\subcaption
+ \let\phantomcaption\phantomsubcaption
+ \let\captionlistentry\subcaptionlistentry
+ \let\captiontext\subcaptiontext}
+% \end{macrocode}
+% \end{macro}
+%
% \subsubsection{The \cs{subfloat} command}
%
% \begin{macro}{\subfloat}
@@ -2353,34 +2468,50 @@
% \changes{v1.4}{2020/12/24}{Usage of \cs{caption@getlabel} replaced by \cs{subcaption@getlabel}}
% \changes{v1.4a}{2020/12/26}{Clearance of \cs{caption@thelabel} replaced by \cs{subcaption@clrlabel}}
% \changes{v1.5}{2022/01/07}{Usage of \cs{@ifnextchar} replaced by \cs{kernel@ifnextchar}}
-% \changes{v1.5}{2022/01/07}{Overwrites the definition defined by the \pkg{memoir} document class}
+% \changes{v1.5}{2022/01/07}{Overwrites the definition done by the \cls{memoir} document class}
+% \changes{v1.6}{2022/04/16}{Emulates the definition done by the \cls{memoir} document class}
% |\subfloat|\oarg{list\_entry}\oarg{sub-caption}\marg{body}\par
% If \meta{sub-caption} is given, we map this to |\sub|\-|caption|\-|box|
% but transfer the |\label| from \meta{body} to \meta{sub-caption}.
% If not, we do the same as |\sub|\-|caption|\-|box| does, but use |\phantom|\-|caption| instead of |\caption|.
% In both cases we do a |\ignore|\-|spaces| at the end since the original implementation of |\sub|\-|float| does this, too.
% \begin{macrocode}
-\@ifclassloaded{memoir}{\let\subfloat\undefined\let\endsubfloat\undefined}{}
-% \end{macrocode}
-% \begin{macrocode}
\caption@AtBeginDocument{%
- \providecommand*\subfloat{%
- \kernel@ifnextchar[%]
- \subcaption@subfloat
- \subcaption@subfloat@}}
+ \begingroup
+ \newenvironment{subcaption@memoir@subfloat}{}{}%
+ \ifx\subfloat\subcaption@memoir@subfloat
+ \endgroup
+ % "subfloat" = empty environment, defined by memoir
+ \renewcommand*\subfloat{%
+ \def\subcaption@currenvir{subfloat}%
+ \ifx\@currenvir\subcaption@currenvir
+ % emulate (empty) subfloat environment
+ \else
+ \expandafter\subcaption@subfloat
+ \fi}%
+ \else
+ \endgroup
+ \providecommand*\subfloat{\subcaption@subfloat}%
+ \fi}
+% \end{macrocode}
+% \begin{macrocode}
+\newcommand*\subcaption@subfloat{%
+ \kernel@ifnextchar[%]
+ \subcaption@@subfloat
+ \subcaption@subfloat@}
% \end{macrocode}
% \begin{macrocode}
-\long\def\subcaption@subfloat[#1]{%
+\long\def\subcaption@@subfloat[#1]{%
\kernel@ifnextchar[%]
- {\subcaption@@subfloat{#1}}%
- {\subcaption@@@subfloat\subcaptionbox{#1}}}
+ {\subcaption@@@subfloat{#1}}%
+ {\subcaption@@subfloat@\subcaptionbox{#1}}}
% \end{macrocode}
% \begin{macrocode}
-\long\def\subcaption@@subfloat#1[#2]{%
- \subcaption@@@subfloat{\subcaptionbox[{#1}]}{#2}}
+\long\def\subcaption@@@subfloat#1[#2]{%
+ \subcaption@@subfloat@{\subcaptionbox[{#1}]}{#2}}
% \end{macrocode}
% \begin{macrocode}
-\long\def\subcaption@@@subfloat#1#2#3{%
+\long\def\subcaption@@subfloat@#1#2#3{%
\subcaption@getlabel{#3}%
#1{#2\caption@thelabel}{\let\label\caption@gobble#3}%
\subcaption@clrlabel