diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/caption/caption.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/caption/caption.dtx | 479 |
1 files changed, 316 insertions, 163 deletions
diff --git a/Master/texmf-dist/source/latex/caption/caption.dtx b/Master/texmf-dist/source/latex/caption/caption.dtx index 14392efea80..44730c1912f 100644 --- a/Master/texmf-dist/source/latex/caption/caption.dtx +++ b/Master/texmf-dist/source/latex/caption/caption.dtx @@ -2,7 +2,7 @@ % % This is file `caption.dtx'. % -% Copyright (C) 1994-2022 Axel Sommerfeldt (axel.sommerfeldt@f-m.fm) +% Copyright (C) 1994-2023 Axel Sommerfeldt (axel.sommerfeldt@f-m.fm) % % -------------------------------------------------------------------------- % @@ -31,7 +31,7 @@ % % \fi % -% \CheckSum{2836} +% \CheckSum{2920} % % \iffalse %<*driver> @@ -4307,7 +4307,6 @@ % \hline % |\caption@kernel@addcontentsline| & \package{floatrow} \\ % |\caption@settype| & \package{newfloat} \\ -% |\caption@setsubtype| & \package{floatrow} \\ % |\caption@xlabel| & \package{cleveref} \\ % \end{tabular}\end{quote} % @@ -4593,14 +4592,14 @@ % % Identify the current version of the package. % \begin{macrocode} -\ProvidesPackage{caption}[2022/03/01 v3.6b Customizing captions (AR)] +\ProvidesPackage{caption}[2023/03/12 v3.6j Customizing captions (AR)] % \end{macrocode} % % \subsection{Loading the kernel} % % Load a matching version of the \package{caption} kernel. % \begin{macrocode} -\RequirePackage{caption3}[2022/01/07] % needs v2.3 or newer +\RequirePackage{caption3}[2022/04/06] % needs v2.4 or newer % \end{macrocode} % % \subsection{Check against unknown document classes} @@ -4714,6 +4713,7 @@ % \changes{v3.1d}{2007/10/24}{Bugfix 07-10-24 in caption v1.x$ compatibility options} % \changes{v3.5a}{2020/09/02}{caption v1.x compatibility options fixed} % \changes{v3.6}{2020/12/22}{Option `compatibility' adapted to fallback concept} +% \changes{v3.6h}{2022/07/03}{Command \cs{caption@ifcompatibility} re-added} % % We only support boolean values for the |compatibility=| option % since these were the only one which were documented in the past. @@ -4726,10 +4726,12 @@ please use either \string\usepackage{caption}[=v1]\MessageBreak or \string\usepackage{caption-light} instead}% }{\caption@ifinlist{#1}{0,false,no,off}{% - % nothing to do + \let\caption@ifcompatibility\@secondoftwo % not used; for backward compatibility only }{% \caption@Error{Undefined compatibility value `#1'}% }}} +\@onlypreamble@key{caption}{compatibility} +\caption@setbool{compatibility}{0} % default: Try not to be compatible to v1.x % \end{macrocode} % % \subsubsection{caption v1.x compatibility options} @@ -5245,6 +5247,7 @@ \def\caption@xfloat#1[#2]{% \caption@ORI@xfloat{#1}[#2]% \caption@settype{#1}% + \caption@setanchor \caption@xfloat@hook} % \end{macrocode} % Hook, could be extended with |\g@addto@macro\caption@x|\-|float@hook{|\ldots|}|. @@ -5300,100 +5303,77 @@ % % \begin{macro}{\setcaptiontype} % \changes{v3.2}{2010/10/24}{This macro added} -% \changes{v3.4e}{2020/01/02}{Check added if the subtype is defined} % \changes{v3.5}{2020/08/24}{Definition method adapted to the \package{caption-light} package} -% \changes{v3.6}{2021/01/02}{Usage of \cs{caption@initposition} added} -% \changes{v3.6}{2021/01/09}{Usage of \cs{flushsubcaptionlistentries} added} % \changes{v3.6}{2022/02/20}{Optional argument added} -% Like |\captionsetup{type=xxx}|, but also works if |\caption|\-|setup| was redefined. +% \changes{v3.6e}{2022/04/17}{Re-written, task sequence corrected} +% \changes{v3.6f}{2022/04/18}{\cs{@ifnextchar} replaced by \cs{kernel@ifnextchar}} +% |\setcaptiontype*|\oarg{additional options}\marg{type}\\ +% Like |\captionsetup{type=|\meta{type}|}|, but also works if |\caption|\-|setup| was redefined. +% The non-starred version sets a \package{hyperref} anchor additionally +% (if |hypcap=|\-|true| and the \package{hypcap} package is not loaded). % \begin{macrocode} \def\setcaptiontype{% - \caption@parboxrestore@light - \caption@settype} -% \end{macrocode} -% \begin{macrocode} -\newcommand*\caption@settype{% - \caption@initposition - \caption@clrflags - \aftergroup\flushsubcaptionlistentries - \caption@@settype} + \caption@teststar\@setcaptiontype\@gobble\@iden} % \end{macrocode} % \begin{macrocode} -\newcommand*\caption@@settype{% - \caption@teststar\caption@@settype@\@firstoftwo\@secondoftwo} -% \end{macrocode} -% \begin{macrocode} -\newcommand*\caption@@settype@[1]{% - \@ifnextchar[%] - {\caption@@settype@@{#1}}% - {\caption@@@settype{}{#1}}} -% \end{macrocode} -% \begin{macrocode} -\def\caption@@settype@@#1[#2]#3{% - \caption@@@settype{}{#1}{#3}% - \caption@setoptions{#2}} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\setcaptionsubtype} -% \changes{v3.2a}{2011/08/15}{This macro added} -% \changes{v3.5d}{2020/09/28}{This macro revised} -% \changes{v3.6}{2022/01/05}{Usage of \cs{caption@Error} replaced by \cs{caption@OutsideFloat}} -% \changes{v3.6}{2022/01/07}{Multiple use is suppressed now by checking \cs{caption@ifsubtype}} -% Same, but sets the sub-type. -% \begin{macrocode} -\newcommand*\setcaptionsubtype{% - \caption@setsubtype} +\newcommand*\@setcaptiontype[1]{% + \kernel@ifnextchar[%] + {\@setcaptiontype@#1}% + {\@@setcaptiontype#1\relax}} % \end{macrocode} % \begin{macrocode} -\newcommand*\caption@setsubtype{% used by the floatrow package - \caption@teststar\caption@@setsubtype\@firstoftwo\@secondoftwo} +\def\@setcaptiontype@#1[#2]{% + \@@setcaptiontype{#1}{\caption@setoptions{#2}}} % \end{macrocode} % \begin{macrocode} -\newcommand*\caption@@setsubtype[1]{% - \caption@iftype - {\caption@ifsubtype - {\caption@Debug{subtype=\@subcaptype}}% - {\caption@@@settype{sub}{#1}{sub\@captype}}}% - {\caption@OutsideFloat\setcaptionsubtype}} +\newcommand*\@@setcaptiontype[3]{% + \caption@settype{#3}#2% + \caption@parboxrestore@light + #1\caption@setanchor} % \end{macrocode} % \end{macro} % -% \begin{macro}{\caption@@@settype} +% \begin{macro}{\caption@settype} % \changes{v3.1}{2007/05/09}{This macro added} % \changes{v3.1b}{2007/09/22}{Usage of \cs{caption@xlabel} added} % \changes{v3.1d}{2007/10/23}{Error message for \cs{caption@checkgrouplevel} revised} -% \changes{v3.1f}{2007/11/16}{\cs{caption@setsubtype} added} % \changes{v3.1f}{2007/12/03}{Crappy \cs{caption@iftypewarning} replaced} % \changes{v3.1g}{2008/01/12}{Usage of \cs{ifcaptionsetup@star} added} % \changes{v3.2}{2010/10/26}{Error message moved from here to \cs{caption@refstepcounter}} % \changes{v3.3}{2011/12/28}{Resetting of \cs{ifcaption@caption} and \cs{ifcaption@subcaption} added} % \changes{v3.4e}{2020/01/02}{Checks added to prevent misuse regading subtypes} +% \changes{v3.4e}{2020/01/02}{Check added if the subtype is defined} % \changes{v3.5d}{2020/09/28}{This macro revised} % \changes{v3.6}{2020/12/27}{Some code out-sourced to \cs{caption@reset@currentlabel}} -% |\caption@settype*|\marg{type}\par +% \changes{v3.6}{2021/01/02}{Usage of \cs{caption@initposition} added} +% \changes{v3.6}{2021/01/09}{Usage of \cs{flushsubcaptionlistentries} added} +% \changes{v3.6e}{2022/04/17}{Starred variant and optional argument removed} +% \changes{v3.6g}{2022/04/18}{Usage of \cs{ifcaptionsetup@star} removed} +% |\caption@settype|\marg{type}\\ % sets |\@captype| and executes the options associated with it % (using |\caption@set|\-|options|). % Furthermore we check |\current|\-|group|\-|level| (if avail), and % use the macro |\caption@|(|sub|)|type|\-|hook| (which will be used by our % \package{float} package support).\par -% The non-starred version sets a \package{hyperref} anchor additionally -% (if |hypcap=|\-|true| and the \package{hypcap} package is not loaded). % \begin{macrocode} -\newcommand*\caption@@@settype[3]{% +\newcommand*\caption@settype{% + \caption@initposition + \caption@clrflags + \aftergroup\flushsubcaptionlistentries + \caption@@settype{}} +% \end{macrocode} +% \begin{macrocode} +\newcommand*\caption@@settype[2]{% % #1 = "" or "sub" -% #2 = \@firstoftwo in star form, \@secondoftwo otherwise -% #3 = <type>, e.g.: "figure" or "subfigure" - \caption@Debug{#1type:=#3}% - \@nameuse{caption@check#1type}{#3}% - {\caption@checkgrouplevel{#1}{% - \captionsetup{#1type#2*\@empty=...}#2{ or - \@backslashchar#1captionof}{}}% +% #2 = <type>, e.g.: "figure" or "subfigure" + \caption@Debug{#1type:=#2}% + \@nameuse{caption@check#1type}{#2}% + {\caption@checkgrouplevel{#1}{\setcaption#1type}% % \end{macrocode} % \begin{macrocode} - \edef\caption@tempa{#3}% + \edef\caption@tempa{#2}% \expandafter\ifx\csname @#1captype\endcsname\caption@tempa \else - \ifcaptionsetup@star\else\@nameuse{caption@#1type@warning}\fi + \@nameuse{caption@#1type@warning}% \fi \expandafter\let\csname @#1captype\endcsname\caption@tempa % \end{macrocode} @@ -5401,17 +5381,40 @@ \@nameuse{caption@#1typehook}% % \end{macrocode} % \begin{macrocode} - \caption@setoptions{#3}% + \caption@setoptions{#2}% \ifx\caption@opt\relax \@nameundef{caption@#1type@warning}% \else \@namedef{caption@#1type@warning}{\caption@Warning{% The #1type was already set to `\csname @#1captype\endcsname'\MessageBreak}}% - \fi + \fi}} % \end{macrocode} +% \end{macro} +% +% \begin{macro}{\setcaptionsubtype} +% \changes{v3.2a}{2011/08/15}{This macro added} +% \changes{v3.5d}{2020/09/28}{This macro revised} +% \changes{v3.6}{2022/01/05}{Usage of \cs{caption@Error} replaced by \cs{caption@OutsideFloat}} +% \changes{v3.6}{2022/01/07}{Multiple use is suppressed now by checking \cs{caption@ifsubtype}} +% \changes{v3.6e}{2022/04/17}{Re-written} +% |\setcaptionsubtype*|\\ +% Like |\captionsetup{subtype}|, but also works if |\caption|\-|setup| was redefined. +% Sets |\@sub|\-|cap|\-|type| and executes the options associated with it. +% The non-starred version sets a \package{hyperref} anchor additionally +% (if |hypcap=|\-|true| and the \package{hypcap} package is not loaded). % \begin{macrocode} - #2{}{\caption@reset@currentlabel\caption@start}}} +\newcommand*\setcaptionsubtype{% + \caption@teststar\@setcaptionsubtype\@gobble\@iden} +% \end{macrocode} +% \begin{macrocode} +\newcommand*\@setcaptionsubtype[1]{% + \caption@iftype + {\caption@ifsubtype + {\caption@Debug{type=\@captype, subtype=\@subcaptype}}% + {\caption@@settype{sub}{sub\@captype}% + #1\caption@setanchor}}% + {\caption@OutsideFloat\setcaptionsubtype}} % \end{macrocode} % \end{macro} % @@ -5429,6 +5432,17 @@ % \end{macrocode} % \end{macro} % +% \begin{macro}{\caption@setanchor} +% \changes{v3.6e}{2022/04/17}{Code extracted from \cs{caption@settype}} +% |\caption@setanchor|\\ +% sets a \pkg{hyperref} anchor. +% \begin{macrocode} +\newcommand*\caption@setanchor{% + \caption@reset@currentlabel + \caption@start} +% \end{macrocode} +% \end{macro} +% % \begin{macro}{\caption@reset@currentlabel} % \changes{v3.6}{2020/12/27}{This macro out-sourced from \cs{caption@settype}} % Redefine |\@currentlabel| so a |\label| before |\caption| will result @@ -5481,26 +5495,20 @@ % \begin{macro}{\caption@checksubtype} % \changes{v3.4g}{2020/01/02}{This macro definition added} % \changes{v3.4m}{2020/07/29}{Check of \cs{sf@counterlist} from \package{subfig} package added} +% \changes{v3.6c}{2022/04/06}{Check of \cs{sf@counterlist} from \package{subfig} package removed} +% \changes{v3.6c}{2022/04/06}{Usage of \cs{caption@subtypesource} added} % |\caption@checksubtype|\marg{type}\marg{code}\par % is used by |\caption@settype| and should either expand the code or issue an error % if the given type is not a proper sub-type, i.e. not defined by |\Declare|\-|Caption|\-|Sub|\-|Type|. -% Since the |sub|\-|float|\-|row| environment offered by the \package{floatrow} package\cite{floatrow} -% is using |\caption|\-|setup{sub|\-|type}| even if the sub-type was defined by |\new|\-|sub|\-|float| -% offered by \package{subfig}\cite{subfig}, we take a more relaxed view of things here and allow -% those sub-types as well (but not without warning since we do not support this). % \begin{macrocode} \newcommand*\caption@checksubtype[1]{% \caption@ifdefined@subtype{#1}% \@firstofone - {\caption@ifin@list\sf@counterlist{#1}% - {\caption@Warning{% - \noexpand\setcaptionsubtype without \string\DeclareCaptionSubType.\MessageBreak - This is not designed to work; you could try replacing\MessageBreak - the `subfig' package with `subcaption' to resolve\MessageBreak - this problem which occurred}% - \@firstofone}% - {\caption@Error{Undefined subtype `#1'}% - \@gobble}}} + {\@ifundefined{c@#1}% + {\caption@Error{Undefined counter `#1'}}% + {\caption@subtypesource\caption@subtype@source{#1}% + \caption@Error{The counter `#1' was defined by\MessageBreak\caption@subtype@source}}% + \@gobble}} % \end{macrocode} % \end{macro} % @@ -5625,6 +5633,7 @@ % \changes{v3.1l}{2010/01/09}{Adapted to current version of nameref package} % \changes{v3.6}{2020/12/27}{With optional argument \cs{caption@refstepcounter@} is used instead of \cs{caption@refstepcounter}} % \changes{v3.6}{2022/01/05}{Usage of \cs{caption@Error} replaced by \cs{caption@OutsideFloat}} +% \changes{v3.6f}{2022/04/18}{\cs{@ifnextchar} replaced by \cs{kernel@ifnextchar}} % |\captionlistentry|\oarg{float type}\marg{list entry}\\ % |\captionlistentry*|\oarg{float type}\marg{list entry} % \begin{macrocode} @@ -5633,7 +5642,7 @@ % \end{macrocode} % \begin{macrocode} \newcommand*\caption@listentry[1]{% - \@ifnextchar[%] + \kernel@ifnextchar[%] {\caption@listentry@{#1}}% {\caption@@listentry{#1}}} % \end{macrocode} @@ -6142,15 +6151,11 @@ % % \begin{macro}{\caption@dblarg} % \changes{v3.1}{2007/02/05}{This macro added} -% \changes{v3.1f}{2007/12/06}{Bugfix 07-12-06: Changed so it works without \cs{kernel@ifnextchar} (which was introduced in \LaTeXe\ 2004/01/23), too} % \changes{v3.3}{2012/03/25}{Support of option \opt{list-entry} added} % A |\relax| was added compared to |\@dblarg| so |\caption{}| will be % expanded to |\caption[\relax]{}| (and not to |\caption[]{}|). % Furthermore support for option \opt{list-entry} was added. % \begin{macrocode} -\@ifundefined{kernel@ifnextchar}{\let\kernel@ifnextchar\@ifnextchar}{} -% \end{macrocode} -% \begin{macrocode} \newcommand\caption@dblarg[1]{% \kernel@ifnextchar[%] {\caption@ydblarg{#1}}% @@ -6302,6 +6307,7 @@ % \changes{v3.4f}{2020/01/03}{Redefinition of \cs{@caption} added since it was redefined by the \env{threeparttable} environment} % \changes{v3.5}{2020/07/27}{Adapted to \package{caption3} v2.0} % \changes{v3.6}{2020/09/20}{Handling of flags out-sourced to \cs{caption@stepcounter}} +% \changes{v3.6d}{2022/04/17}{Usage of \cs{if@subfloatrow} removed in favour of a re-definition of \env{subfloatrow*}} % Hook, will be used inside \cs{caption@setsubtype}.\par % (Note: If we are inside an |sub|\-|float|\-|row| environment we have to keep % the |\@make|\-|caption| code of the \package{floatrow} package intact.) @@ -6329,14 +6335,8 @@ % \end{macrocode} % \begin{macrocode} % redefine \setcaptiontype - \def\caption@settype{\caption@withoptargs\caption@sub@settype}% - \def\caption@sub@settype##1##2{% - \edef\caption@tempa{##2}% - \ifx\caption@tempa\@captype -%%% \caption@setsubtype##1\relax - \else - \caption@Error{##2 inside \@subcaptype}% - \fi}% + \renewcommand*\caption@settype[1]{% + \caption@Error{##1 inside \@subcaptype}}% % \end{macrocode} % \begin{macrocode} % redefine \caption @@ -6350,32 +6350,11 @@ % \end{macrocode} % \begin{macrocode} % restore \@makecaption - \if@subfloatrow - \caption@Debug{Keeping \string\@makecaption}% - \else - \let\@makecaption\caption@makecaption - \fi + \let\@makecaption\caption@makecaption \fi}% % \end{macrocode} % \end{macro} % -% \begin{macro}{\if@subfloatrow} -% \changes{v3.2c}{2011/09/30}{This macro added} -% This macro tests if we are inside an |sub|\-|float|\-|row| or |sub|\-|float|\-|row*| environment. -% \begin{macrocode} -\caption@AtBeginDocument{% - \caption@ifundefined\@subfloatrowtrue - {\newif\if@subfloatrow - \caption@ifundefined\subfloatrow - {}% - {\caption@Debug{Patching subfloatrow environment}% - \g@addto@macro\capsubrowsettings{\@subfloatrowtrue}% - \g@addto@macro\killfloatstyle{% - \ifx\c@FRobj\c@FRsobj\@subfloatrowtrue\fi}}}% - {\caption@Debug{\string\if@subfloatrow is already defined}}}% -% \end{macrocode} -% \end{macro} -% % \begin{macro}{\caption@subcaption} % Makes a sub-caption. % \begin{macrocode} @@ -6646,7 +6625,7 @@ % Used by the \package{fltpage} \& \package{sidecap} package support. % \begin{macrocode} \newcommand*\caption@freezetype[1]{% - \caption@settype*{#1}% + \caption@settype{#1}% \captionsetup*[sub]{hypcap=true}% Note: This is just a (q&d) workaround! \caption@freeze}% % \end{macrocode} @@ -6735,7 +6714,7 @@ % Prevent resetting the caption flags % \begin{macrocode} \newcommand*\caption@prepare@defrost{% - \let\caption@settype\caption@@settype} + \def\caption@settype{\caption@@settype{}}} % \end{macrocode} % \end{macro} % @@ -6776,48 +6755,46 @@ \caption@IfPackageLoaded{changepage}[2008/07/23 memoir-v3.7k]{% % \end{macrocode} % +% \begin{macro}{\caption@patch@adjustwidth} +% \changes{v3.4k}{2020/05/30}{This macro definition added} +% \changes{v3.6j}{2023/03/12}{\cs{ignorespaces} added to environment re-definition} % Both environments, \env{adjustwidth} and \env{adjustwidth*}, are starting a \env{list} \cs{item}. % But \cs{hsize} isn't set properly inside a \env{list} item, and therefore \cs{@makecaption} % (offered by document classes) doesn't work properly when used inside \env{adjustwidth}. -% Therefore we try to detect the situation ``Are we inside a adjustwidth environment?'' +% Therefore we try to detect the situation ``Are we inside a \env{adjustwidth} environment?'' % inside \cs{@makecaption} and fix this. (Sigh!) +% \begin{macrocode} + \providecommand*\caption@patch@adjustwidth[1]{% + \expandafter\let\csname caption@#1\expandafter\endcsname\csname #1\endcsname + \expandafter\renewcommand\csname #1\endcsname[2]{% + \@nameuse{caption@#1}{##1}{##2}% + \caption@set@adjustwidth + \ignorespaces}}% + \caption@patch@adjustwidth{adjustwidth}% + \caption@patch@adjustwidth{adjustwidth*}% + \let\caption@patch@adjustwidth\relax +% \end{macrocode} +% \end{macro} % +% \begin{macro}{\caption@set@adjustwidth} +% \changes{v3.4k}{2020/05/30}{This macro definition added} +% \changes{v3.5h}{2022/03/01}{Usage of \cs{AtBeginCaption} replaced by \cs{l@addto@macro}\cs{caption@beginex@hook}} % We cannot simply set and test a flag here since our adjustment to \cs{hsize} should -% not be done within a \cs{parbox} within a adjustwidth environment for example, +% not be done within a \cs{parbox} within a \env{adjustwidth} environment for example, % and therefore we store \cs{hsize} and \cs{linewidth}, and test \cs{hsize} and \cs{linewidth} % against the stored values instead. If they are equal we are (hopefully) quite save % to assume that we are now inside a plain \env{adjustwidth} environment and therefore need % to fix \cs{hsize} before typesetting the caption. (Deep sigh!) -% -% \begin{macro}{\caption@adjustwidth@hsize} -% \begin{macro}{\caption@adjustwidth@linewidth} % \begin{macrocode} \newdimen\caption@adjustwidth@hsize \newdimen\caption@adjustwidth@linewidth % \end{macrocode} -% \end{macro} -% \end{macro} -% -% \begin{macro}{\caption@set@adjustwidth} -% \changes{v3.4k}{2020/05/30}{This macro definition added} -% \changes{v3.5h}{2022/03/01}{Usage of \cs{AtBeginCaption} replaced by \cs{l@addto@macro}\cs{caption@beginex@hook}} -% Store the values of \cs{hsize} and \cs{linewidth}. % \begin{macrocode} \providecommand*\caption@set@adjustwidth{% \caption@adjustwidth@hsize\hsize \caption@adjustwidth@linewidth\linewidth \l@addto@macro\caption@beginex@hook\caption@test@adjustwidth}% % \end{macrocode} -% \begin{macrocode} - \providecommand*\caption@patch@changepage[1]{% - \expandafter\let\csname caption@#1\expandafter\endcsname\csname #1\endcsname - \expandafter\renewcommand\csname #1\endcsname[2]{% - \@nameuse{caption@#1}{##1}{##2}% - \caption@set@adjustwidth}}% - \caption@patch@changepage{adjustwidth}% - \caption@patch@changepage{adjustwidth*}% - \let\caption@patch@changepage\relax -% \end{macrocode} % \end{macro} % % \begin{macro}{\caption@test@adjustwidth} @@ -6977,30 +6954,42 @@ % \begin{macro}{\caption@float@setname} % \changes{v3.1}{2007/07/08}{float package hook added} % \changes{v3.4b}{2019/12/16}{Renamed from \cs{caption@typehook} to \cs{caption@float@setname}} +% \changes{v3.6i}{2023/02/19}{Uses \cs{def} instead of \cs{let} now} % \LaTeX\ and almost every other packages use % |\|\meta{type}|name| % to provide a macro for the type resp.~environment name -- for example -% the command |\figurename| will usually contain the name of the floating +% the command |\figure|\-|name| will usually contain the name of the floating % environment |figure|: % \begin{quote} % |\newcommand\figurename{Figure}| % \end{quote} % But the \package{float} package doesn't follow this common naming % convention: -% For floats defined with |\newfloat| it uses |\fname@|\meta{type} instead, -% which breaks with our code (and with |\autoref| and some other things as +% For floats defined with |\new|\-|float| it uses |\fname@|\meta{type} instead, +% which breaks with our code (and with |\auto|\-|ref| and some other things as % well). % So we have to map the \package{float} package name to the common one here.\par % \Note{If the float was not defined with \cs{newfloat} but with % \cs{restylefloat} instead, \cs{fname@}\meta{type} is not defined.} % \begin{macrocode} \newcommand*\caption@float@setname[1]{% - \expandafter\ifx\csname #1name\endcsname\relax - \expandafter\let\csname #1name\expandafter\endcsname\csname fname@#1\endcsname + \expandafter\ifx\csname #1name\endcsname\relax % either undefined or \relax + \@namedef{#1name}{\@nameuse{fname@#1}}% \fi}% % \end{macrocode} % \end{macro} % +% \begin{macro}{\caption@setname} +% \changes{v3.6i}{2023/02/19}{Re-definition of \cs{caption@setname} added to \pkg{float} package support} +% Same problem as in |\caption@float@set|\-|name|, but other direction: +% If the option |name=| is used, we should set |\fname@|\meta{type}, too. +% \begin{macrocode} + \renewcommand*\caption@setname[2]{% + \@ifundefined{fname@#1}{}{\caption@ifdefined\floatname\floatname\@gobbletwo{#1}{#2}}% + \@namedef{#1name}{#2}}% +% \end{macrocode} +% \end{macro} +% % \changes{v3.0f}{2005/06/26}{Skips of \env{plaintop} and \env{boxed} floats corrected} % \begin{macro}{\fs@plaintop} % \begin{macro}{\fs@boxed} @@ -7138,10 +7127,73 @@ \newcommand*\caption@floatflt[1]{% \caption@settype{#1}% \caption@clearmargin - \caption@setoptions{floating#1}}% + \caption@setoptions{floating#1}% + \caption@setanchor}% +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +}{} +% \end{macrocode} +% +% \subsubsection{The floatrow package} +% +% \begin{macrocode} +\caption@IfPackageLoaded{floatrow}[2008/08/02 v0.3b]{% +% \end{macrocode} +% +% \begin{macro}{\captionlabel} +% \changes{v3.6e}{2022/04/17}{This macro re-definition added} +% The original definition of |\caption|\-|label| uses the internal macro +% |\caption@set|\-|sub|\-|type| which does not exist anymore and needs to +% be replaced by |\set|\-|caption|\-|sub|\-|type|. +% \begin{macrocode} + \renewcommand\captionlabel[1]{{\def\FR@tmp{\@captype}\ifnum\floatbox@depth>\@ne + \def\FR@tmp{sub\@captype}\setcaptionsubtype*\stepcounter{\FR@tmp}\fi + \caption@@@make{\caption@fnum\FR@tmp}{#1}}} % \end{macrocode} % \end{macro} % +% \begin{environment}{subfloatrow} +% \changes{v3.6d}{2022/04/17}{This environment re-definition added} +% The original definition of the environment |sub|\-|float|\-|row| +% uses |\caption|\-|setup{sub|\-|type}| to switch caption commands +% like |\caption| to their counterparts offered by the \pkg{subcaption} +% package. +% Since \pkg{caption} \version{3.6} this does not work in coorparation +% with the \pkg{subfig} package anymore, and therefore we replace it +% with a hook which could be filled by the \pkg{subcaption} package. +% \begin{macrocode} + \renewenvironment{subfloatrow}{\capsubrowsettings + \caption@subfloatrow@hook % as replacement for \captionsetup{subtype} + \@nameuse{subfloatrow*}}{\@nameuse{endsubfloatrow*}} +% \end{macrocode} +% \begin{macrocode} + \providecommand*\caption@subfloatrow@hook{} +% \end{macrocode} +% \end{environment} +% +% \begin{environment}{subfloatrow*} +% \changes{v3.6d}{2022/04/17}{This environment re-definition added} +% Some packages (like the \pkg{float} and \pkg{floatrow} package) re-define +% |\@make|\-|caption| for special handling of the main caption. +% Since this usually does not work fine with sub-captions, the command +% |\set|\-|caption|\-|sub|\-|type| will restore the definition +% of |\@make|\-|caption|. But this is not desired here, and therefore +% we make sure that |\flrow@make|\-|caption| will be used for sub-captions, +% too. +% \begin{macrocode} + \renewenvironment{subfloatrow*}[1][2]{\let\flrow@to\empty + \let\Xhsize\sXhsize%\let\Zhsize\sZhsize + \FR@ifunloc{\let\FR@ifcountH\@firstoftwo}\let\c@FRobj\c@FRsobj + \def\FRleftmargin{}\def\FRrightmargin{}\let\floatrowsep\subfloatrowsep + \floatrow[#1]\killfloatstyle + \let\caption@makecaption\flrow@makecaption}% <- This line added + {\ifdim\lastskip>\z@\unskip\fi + \@ifundefined{adjustsubfloats}\relax\adjustsubfloats\endfloatrow} +% \end{macrocode} +% \end{environment} +% % \begin{macrocode} }{} % \end{macrocode} @@ -7768,6 +7820,7 @@ % \changes{v3.3}{2018/10/05}{Definition of \cs{captionlistentry} fixed} % \changes{v3.5}{2018/04/15}{Usage of \cs{caption@AtBeginLongtable} added} % \changes{v3.6}{2022/01/05}{Usage of \cs{caption@Error} replaced by \cs{caption@OutsideFloat}} +% \changes{v3.6g}{2022/04/18}{Adapted to recent version of \pkg{caption3} package} % We redefine |\LT@array| here to get |\captionsetup|\marg{options} working inside |longtable|s. % \Note{Since the \package{hyperref} package patches \cs{LT@array} as well % and since this only works with the original definition of \cs{LT@array}, @@ -7789,7 +7842,7 @@ \@ifstar\@captionsetup\@captionsetup}% gobble * \def\@captionsetup#1{\LT@captionsetup{#1}\egroup}% \def\LT@captionsetup#1{% - \captionsetup@startrue\caption@setup@options[@longtable]{#1}% + \caption@setup@options\@gobble[@longtable]{#1}% \global\let\caption@opt@@longtable\caption@opt@@longtable}% % \end{macrocode} % |\captionlistentry| for longtable: @@ -7967,7 +8020,7 @@ % \changes{v3.6}{2021/01/17}{Adapted to current implementation of \cs{caption@setwidth}} % \begin{macrocode} \newcommand*\caption@LT@settype[1]{% - \caption@settype*{#1}% + \caption@settype{#1}% % \end{macrocode} % If |\LTcapwidth| is not set to its default value |4in| we assume % that it shall overwrite our own setting. @@ -8060,7 +8113,8 @@ \let\@makecaption\caption@@make \caption@setautoposition b% \caption@settype{#1}% - \caption@clearmargin}% + \caption@clearmargin + \caption@setanchor}% % \end{macrocode} % \end{macro} % @@ -8193,6 +8247,7 @@ % \fi \caption@setoptions{parpic}% \caption@setautoposition b% + \caption@setanchor % \end{macrocode} % \begin{macrocode} \expandafter\expandafter\expandafter\caption@ORI @@ -8310,6 +8365,82 @@ }{} % \end{macrocode} % +% \subsubsection{The scrextend package} +% \changes{v3.6j}{2023/03/12}{Patch of the \package{scrextend} package added} +% +% \begin{macro}{\caption@IfKomaPackageLoaded} +% \changes{v3.6j}{2023/03/12}{This macro definition added} +% \begin{macrocode} +\caption@ifdefined\scr@caption{% + \long\def\caption@IfKomaPackageLoaded#1[#2]#3#4{% + \caption@InfoNoLine{KOMA-Script #1 package detected} + #3}}{% + \let\caption@IfKomaPackageLoaded\caption@IfPackageLoaded + } +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +\caption@IfKomaPackageLoaded{scrextend}[2002/07/01 v3.0]{% +% \end{macrocode} +% +% \begin{macro}{\caption@patch@addmargin} +% \changes{v3.6j}{2023/03/12}{This macro definition added} +% Both environments, \env{addmargin} and \env{addmargin*}, are starting a \env{list} \cs{item}. +% But \cs{hsize} isn't set properly inside a \env{list} item, and therefore \cs{@makecaption} +% (offered by document classes) doesn't work properly when used inside \env{addmargin}. +% Therefore we try to detect the situation ``Are we inside a \env{addmargin} environment?'' +% inside \cs{@makecaption} and fix this. (Sigh!) +% \begin{macrocode} + \let\caption@addmargin@env\@addmargin + \renewcommand*\@addmargin{% + \@testopt\caption@@addmargin\@tempa}% + \def\caption@@addmargin[#1]#2{% + \caption@addmargin@env[{#1}]{#2}% + \caption@set@addmargin + \ignorespaces}% +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\caption@set@addmargin} +% \changes{v3.6j}{2023/03/12}{This macro definition added} +% We cannot simply set and test a flag here since our adjustment to \cs{hsize} should +% not be done within a \cs{parbox} within a \env{addmargin} environment for example, +% and therefore we store \cs{hsize} and \cs{linewidth}, and test \cs{hsize} and \cs{linewidth} +% against the stored values instead. If they are equal we are (hopefully) quite save +% to assume that we are now inside a plain \env{addmargin} environment and therefore need +% to fix \cs{hsize} before typesetting the caption. (Deep sigh!) +% \begin{macrocode} + \newdimen\caption@addmargin@hsize + \newdimen\caption@addmargin@linewidth +% \end{macrocode} +% \begin{macrocode} + \providecommand*\caption@set@addmargin{% + \caption@addmargin@hsize\hsize + \caption@addmargin@linewidth\linewidth + \l@addto@macro\caption@beginex@hook\caption@test@addmargin}% +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\caption@test@addmargin} +% \changes{v3.6j}{2023/03/12}{This macro definition added} +% Test if the values of \cs{hsize} and \cs{linewidth} are identical to +% the ones stored in the \env{addmargin} environment. +% If yes, set \cs{hsize} to the correct value. +% \begin{macrocode} + \providecommand\caption@test@addmargin{% + \ifdim\hsize=\caption@addmargin@hsize + \ifdim\linewidth=\caption@addmargin@linewidth + \hsize=\linewidth + \fi + \fi}% +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} + }{}% +% \end{macrocode} +% % \subsubsection{The sidecap package} % % \begin{macrocode} @@ -8323,6 +8454,7 @@ % \changes{v3.1c}{2007/10/06}{\cs{caption} will be saved \& restored now} % \changes{v3.2a}{2011/08/17}{Bugfix: Uses \cs{caption@freeze} instead of \cs{caption@freeze*} now} % \changes{v3.3}{2013/05/01}{Usage of \cs{caption@freeze} replaced by \cs{caption@freezetype}} +% \changes{v3.6i}{2022/07/10}{\cs{ignorespaces} appended} % This macro will be called at the start of the environment, here is a good % opportunity to do some adaptations to |\caption| and |\captionsetup|. % \begin{macrocode} @@ -8336,7 +8468,7 @@ \SC@RestoreCommands % \end{macrocode} % Since the sidecap package uses our |\caption| code outside the -% environment the regular |\captionsetup| will not work. +% environment the regular |\caption|\-|setup| will not work. % So we need a special version here which saves the given argument list % which will be executed later on. % Furthermore we need to make |\caption*| work. @@ -8346,7 +8478,12 @@ % The sidecap package uses |\ifx\label\SC@label| to test if it is just inside a % |SC|\-|figure| or not. So we redefine |\SC@label| here so this test will still work. % \begin{macrocode} - \let\SC@label\label}% + \let\SC@label\label +% \end{macrocode} +% Since the original definition of |\SC@zfloat| ends with |\begin{lrbox}| which ends with |\ignore|\-|spaces|, +% we do have to end our re-definition of |\SC@zfloat| with |\ignore|\-|spaces| as well. +% \begin{macrocode} + \ignorespaces}% % \end{macrocode} % \begin{macrocode} \providecommand*\SC@RestoreCommands{% @@ -8497,7 +8634,7 @@ % \end{verbatim}%^^A % \begin{macrocode} \long\def\ST@caption#1[#2]#3{\par% - \caption@settype*{#1}% + \caption@settype{#1}% \caption@setoptions{supertabular}% % \end{macrocode} % The |position=| setting will be overwritten by the @@ -8566,7 +8703,7 @@ % \end{verbatim}%^^A % \begin{macrocode} \long\def\ST@caption#1[#2]#3{\par% - \caption@settype*{#1}% + \caption@settype{#1}% \caption@setoptions{xtabular}% % \end{macrocode} % \begin{macrocode} @@ -8597,29 +8734,44 @@ % % \begin{macro}{\threeparttable} % \changes{v3.3}{2016/01/31}{Bugfix: \cs{@captype} will be used if already defined} +% \changes{v3.6e}{2022/04/17}{Main code outsourced to \cs{caption@setthreeparttable}} % Unfortunately |\@captype| is not set when |\TPT@common| will be used, % so we have to redefine |\threeparttable| and |\measuredfigure| instead. % \begin{macrocode} \let\caption@ORI@threeparttable\threeparttable \renewcommand*\threeparttable{% - \caption@settype{\@ifundefined{@captype}{table}{\@captype}}% -%%% \caption@setposition{auto}% ? - \caption@clearmargin - \caption@setoptions{threeparttable}% + \caption@setthreeparttabletype{threepart}{table}% \caption@ORI@threeparttable}% % \end{macrocode} % \end{macro} +% % \begin{macro}{\measuredfigure} % \changes{v3.3}{2016/01/31}{Bugfix: \cs{@captype} will be used if already defined} +% \changes{v3.6e}{2022/04/17}{Main code outsourced to \cs{caption@setthreeparttable}} % Same here\ldots % \begin{macrocode} \let\caption@ORI@measuredfigure\measuredfigure \renewcommand*\measuredfigure{% - \caption@settype{\@ifundefined{@captype}{figure}{\@captype}}% + \caption@setthreeparttabletype{measured}{figure}% + \caption@ORI@measuredfigure}% +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\caption@setthreeparttabletype} +% \changes{v3.6e}{2022/04/17}{Extracted from \cs{threeparttable} and \cs{measuredfigure}} +% \changes{v3.6e}{2022/04/17}{Support for usage inside \env{subtable} resp.~\env{subfigure} added} +% |\caption@setthreeparttabletype|\marg{threepart type}\marg{main type} +% \begin{macrocode} + \newcommand*\caption@setthreeparttabletype[2]{% + \caption@ifsubtype + {\def\caption@threeparttabletype{#1sub#2}% + \let\caption@setanchor\relax}% + {\caption@settype{\@ifundefined{@captype}{#2}{\@captype}}% + \def\caption@threeparttabletype{#1#2}}% %%% \caption@setposition{auto}% ? \caption@clearmargin - \caption@setoptions{measuredfigure}% - \caption@ORI@measuredfigure}% + \caption@setoptions\caption@threeparttabletype + \caption@setanchor}% % \end{macrocode} % \end{macro} % @@ -8724,7 +8876,8 @@ \caption@settype{#1}% \caption@clearmargin %%% \caption@setoptions{wrap}% - \caption@setoptions{wrap#1}}% + \caption@setoptions{wrap#1}% + \caption@setanchor}% % \end{macrocode} % \end{macro} % |