diff options
author | Norbert Preining <norbert@preining.info> | 2020-10-27 03:02:53 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2020-10-27 03:02:53 +0000 |
commit | 83aaf60600dc0b191bacbaacc786dbda33d7190a (patch) | |
tree | 57482692c8aaf7f19c79919b74e821dbeea5652e /macros/latex/contrib/caption/subcaption.dtx | |
parent | 0ceea51e3c4c2d7364ffacd728497a66f16aa2ed (diff) |
CTAN sync 202010270302
Diffstat (limited to 'macros/latex/contrib/caption/subcaption.dtx')
-rw-r--r-- | macros/latex/contrib/caption/subcaption.dtx | 101 |
1 files changed, 53 insertions, 48 deletions
diff --git a/macros/latex/contrib/caption/subcaption.dtx b/macros/latex/contrib/caption/subcaption.dtx index 90586d10d9..3dc8cca22e 100644 --- a/macros/latex/contrib/caption/subcaption.dtx +++ b/macros/latex/contrib/caption/subcaption.dtx @@ -32,7 +32,7 @@ % caption-deu.tex, caption-eng.tex, caption-rus.tex. % % \fi -% \CheckSum{228} +% \CheckSum{221} % % \iffalse %<*driver> @@ -78,7 +78,7 @@ % \newcommand*\csmarg[1]{\texttt{\char`\{#1\char`\}}} \newcommand*\csoarg[1]{\texttt{\char`\[#1\char`\]}} -\newcommand*\version[2][]{$v#2$} +\newcommand*\version[2][]{v$#2$} % \usepackage{marvosym} \makeatletter @@ -935,16 +935,26 @@ % % \begin{macrocode} \NeedsTeXFormat{LaTeX2e}[1994/12/01] -\ProvidesPackage{subcaption}[2020/08/23 v1.3g Sub-captions (AR)] +\ProvidesPackage{subcaption}[2020/10/07 v1.3j Sub-captions (AR)] % \end{macrocode} % % \subsection{Initial code} % % Since we base on the \package{caption} package we load it here. % \begin{macrocode} -\RequirePackage{caption}[2020/08/23] % needs v3.5 or newer +\RequirePackage{caption}[2020/09/28] % needs v3.5c or newer % \end{macrocode} % +% \begin{macro}{\subcaption@Error} +% \changes{v1.3h}{2020/09/28}{This macro added} +% |\subcaption@Error|\marg{message}\\ +% issues an error message (with code line indication). +% \begin{macrocode} +\newcommand*\subcaption@Error[1]{% + \PackageError{subcaption}{#1}{\caption@@eh{subcaption}}} +% \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 \package{subfigure} or \package{subfig} will be checked \cs{AtBeginDocument}, too} @@ -956,38 +966,29 @@ % \end{macrocode} % \begin{macrocode} \caption@ifcompatibility{% - \PackageError{subcaption}% + \subcaption@Error {This package does not work with\MessageBreak caption option `compatibility=v1'}% - {\subcaption@eh}% \endinput}{}% % \end{macrocode} % \begin{macrocode} \@ifpackageloaded{subfigure}{% - \PackageError{subcaption}% + \subcaption@Error {This package can't be used in cooperation\MessageBreak with the subfigure package}% - {\subcaption@eh}% \endinput}{}% % \end{macrocode} % \begin{macrocode} \@ifpackageloaded{subfig}{% - \PackageError{subcaption}% + \subcaption@Error {This package can't be used in cooperation\MessageBreak with the subfig package}% - {\subcaption@eh}% \endinput}{}% % \end{macrocode} % \begin{macrocode} } % \end{macrocode} % \begin{macrocode} -\newcommand*\subcaption@eh{% - If you do not understand this error, please take a closer look\MessageBreak - at the documentation of the `subcaption' package, especially the\MessageBreak - section about errors.\MessageBreak\@ehc} -% \end{macrocode} -% \begin{macrocode} \subcaption@CheckCompatibility \caption@AtBeginDocument{% \subcaption@CheckCompatibility @@ -997,29 +998,12 @@ % % \subsection{Main code} % -% \changes{v1.1}{2011/10/30}{Adapted to the newfloat package} -% We call |\Declare|\-|Caption|\-|Sub|\-|Type| for |figure|, |table|, -% and each floating environment declared with |\Declare|\-|Floating|\-|Environment| here. -% \begin{macrocode} -\ForEachCaptionType{\DeclareCaptionSubType{#1}} -% \end{macrocode} -% -% \begin{macro}{\newsubfloat} -% \changes{v1.1}{2016/01/31}{Adapted to the memoir document class} -% We re-define |\new|\-|sub|\-|float| (offered by the \package{memoir} document class), -% so our stuff will be used instead. -% \begin{macrocode} -\caption@ifundefined\newsubfloat{}{% - \renewcommand*\newsubfloat{\DeclareCaptionSubType}} -% \end{macrocode} -% \end{macro} -% % \pagebreak[3] % \subsubsection{The \cs{subcaption} command} % % \begin{macro}{\subcaption} -% \changes{v1.1}{2012/04/06}{\cs{newcommand} changed to \cs{def} -% so it works with the \package{memoir} document class, too} +% \changes{v1.1}{2012/04/06}{\cs{newcommand} changed to \cs{def} so it works with the \package{memoir} document class, too} +% \changes{v1.3h}{2020/09/28}{Usage of \cs{caption@Error} replaced by \cs{subcaption@Error}} % 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 @@ -1028,7 +1012,7 @@ \def\subcaption{% \caption@iftype {\setcaptionsubtype*\caption}% - {\caption@Error{\noexpand\subcaption outside float}% + {\subcaption@Error{\noexpand\subcaption outside float}% \caption@gobble}}% % \end{macrocode} % But with a prefacing |\set|\-|caption|\-|sub|\-|type|, |\sub|\-|caption| is simply @@ -1044,12 +1028,13 @@ % % \begin{macro}{\phantomsubcaption} % \changes{v1.1}{2011/08/17}{This macro added} +% \changes{v1.3h}{2020/09/28}{Usage of \cs{caption@Error} replaced by \cs{subcaption@Error}} % Same as |\phantom|\-|caption|, but for subfigures. % \begin{macrocode} \newcommand*\phantomsubcaption{% \caption@iftype {\setcaptionsubtype*\phantomcaption}% - {\caption@Error{\noexpand\phantomsubcaption outside float}}}% + {\subcaption@Error{\noexpand\phantomsubcaption outside float}}}% % \end{macrocode} % \begin{macrocode} \g@addto@macro\caption@subtypehook{% @@ -1194,25 +1179,33 @@ % % \begin{macro}{\subcaption@setrefformat} % \changes{v1.3g}{2020/07/27}{Adapted to \package{caption3} v2.0} +% \changes{v1.3h}{2020/09/28}{Usage of \cs{caption@Error} replaced by \cs{subcaption@Error}} +% \changes{v1.3j}{2020/10/07}{Definition of the label formats \texttt{subsimple} and \texttt{subparens} added} % |\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@labelformat@#1}% - {\caption@Error{Undefined label format `#1'}}% + {\subcaption@Error{Undefined label format `#1'}}% {\expandafter\let\expandafter\subcaption@reffmt\csname caption@labelformat@#1\endcsname}} % \end{macrocode} % \begin{macrocode} \subcaption@setrefformat{simple} % \end{macrocode} +% To offer a smooth transition from the \package{subfig} to the \package{subcaption} package +% we offer the options |sub|\-|ref|\-|format=sub|\-|simple| and |sub|\-|ref|\-|format=sub|\-|parens|, too. +% \begin{macrocode} +\DeclareCaptionLabelFormat{subsimple}{#2} +\DeclareCaptionLabelFormat{subparens}{(#2)} +% \end{macrocode} % \end{macro} % % \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. % \changes{v1.1}{2018/05/01}{Option \texttt{font+=smaller} changed to \texttt{size=smaller}} % \changes{v1.3e}{2020/07/27}{Option \texttt{size=smaller} changed back to \texttt{font+=smaller}} +% We use |\caption@Execute|\-|Options| and |\caption@Process|\-|Options| 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}{% @@ -1220,6 +1213,13 @@ \caption@ProcessOptions*{subcaption} % \end{macrocode} % +% \changes{v1.1}{2011/10/30}{Adapted to the newfloat package} +% We call |\Declare|\-|Caption|\-|Sub|\-|Type| for |figure|, |table|, +% and each floating environment declared with |\Declare|\-|Floating|\-|Environment| here. +% \begin{macrocode} +\ForEachCaptionType{\DeclareCaptionSubType{#1}} +% \end{macrocode} +% % \subsection{Bonus material} % % \subsubsection{The \cs{subfloat} command} @@ -1231,32 +1231,37 @@ % \changes{v1.3a}{2019/09/01}{\cs{ignorespaces} copied from \cs{sf@@@subfloat}} % \changes{v1.3b}{2020/01/03}{Previous definition of \cs{subfloat} will be overwritten} % \changes{v1.3f}{2020/07/29}{Bugfix: Usage of \cs{caption@hj@default} replaced by \cs{captionbox@innerpos@default}} +% \changes{v1.3i}{2020/09/28}{This macro will be defined with \cs{providecommand} now to preserve an original definition} % |\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} -\def\subfloat{% - \@ifnextchar[\@subfloat\subfloat@} +\caption@AtBeginDocument{\providecommand*\subfloat{% + \@ifnextchar[%] + \subcaption@subfloat + \subcaption@subfloat@}} % \end{macrocode} % \begin{macrocode} -\long\def\@subfloat[#1]{% - \@ifnextchar[{\@@subfloat{#1}}{\@@@subfloat\subcaptionbox{#1}}} +\long\def\subcaption@subfloat[#1]{% + \@ifnextchar[%] + {\subcaption@@subfloat{#1}}% + {\subcaption@@@subfloat\subcaptionbox{#1}}} % \end{macrocode} % \begin{macrocode} -\long\def\@@subfloat#1[#2]{% - \@@@subfloat{\subcaptionbox[{#1}]}{#2}} +\long\def\subcaption@@subfloat#1[#2]{% + \subcaption@@@subfloat{\subcaptionbox[{#1}]}{#2}} % \end{macrocode} % \begin{macrocode} -\long\def\@@@subfloat#1#2#3{% +\long\def\subcaption@@@subfloat#1#2#3{% \caption@getlabel{#3}% #1{#2\caption@thelabel}{\let\label\caption@gobble#3}% \global\let\caption@thelabel\relax \ignorespaces} % \end{macrocode} % \begin{macrocode} -\def\subfloat@#1{% +\def\subcaption@subfloat@#1{% \setbox\@tempboxa\hbox{#1}% \caption@iiiibox \setcaptionsubtype |