diff options
Diffstat (limited to 'macros/latex/contrib/caption/caption3.dtx')
-rw-r--r-- | macros/latex/contrib/caption/caption3.dtx | 162 |
1 files changed, 100 insertions, 62 deletions
diff --git a/macros/latex/contrib/caption/caption3.dtx b/macros/latex/contrib/caption/caption3.dtx index 8e4506202a..5011e0d0b3 100644 --- a/macros/latex/contrib/caption/caption3.dtx +++ b/macros/latex/contrib/caption/caption3.dtx @@ -31,12 +31,12 @@ % % \fi % -% \CheckSum{3813} +% \CheckSum{3830} % % \iffalse %<*driver> \NeedsTeXFormat{LaTeX2e}[1994/12/01] -\ProvidesFile{caption3.drv}[2021/01/02 v2.3 Implementation of the caption kernel] +\ProvidesFile{caption3.drv}[2021/01/02 v2.4 Implementation of the caption kernel] \hbadness=9999 \newcount\hbadness \hfuzz=100pt % Make TeX shut up. %\errorcontextlines=3 % @@ -79,6 +79,7 @@ % \newcommand*\puresf[1]{{\upshape\mdseries\sffamily #1}} % \newcommand*\purett[1]{{\upshape\mdseries\ttfamily #1}} % \let\class\puresf \let\package\puresf +% \let\cls\puresf \let\pkg\puresf % \let\env\purett \let\opt\purett % % \newcommand*\csmarg[1]{\texttt{\char`\{#1\char`\}}} @@ -264,11 +265,19 @@ % % Identify the current version of the package. % \begin{macrocode} -\ProvidesPackage{caption3}[2022/03/17 v2.3b caption3 kernel (AR)] +\ProvidesPackage{caption3}[2023/03/12 v2.4 caption3 kernel (AR)] % \end{macrocode} % % \section{Generic helpers} % +% \begin{macro}{\kernel@ifnextchar} +% \changes{v1.1f}{2007/12/06}{Bugfix 07-12-06: This macro definition added (\cs{kernel@ifnextchar} was introduced in \LaTeXe\ 2004/01/23)} +% \changes{v2.4}{2022/04/18}{This macro moved from package to kernel} +% \begin{macrocode} +\@ifundefined{kernel@ifnextchar}{\let\kernel@ifnextchar\@ifnextchar}{} +% \end{macrocode} +% \end{macro} +% % \begin{macro}{\@nameundef} % |\@nameundef|\marg{command name}\\ % is the opposite to |\@name|\-|def| which is offered by the \LaTeX\ kernel. @@ -572,6 +581,7 @@ % \begin{macro}{\caption@withoptargs} % \changes{v1.1}{2007/08/12}{This macro added} % \changes{v1.5}{2012/04/09}{This macro revised} +% \changes{v2.4}{2022/04/18}{\cs{@ifnextchar} replaced by \cs{kernel@ifnextchar}} % |\caption@withoptargs|\marg{cmd}\\ % collects a star and all optional arguments, and expands \meta{cmd} % afterwards with the collected stuff as first argument. @@ -583,7 +593,7 @@ % \end{macrocode} % \begin{macrocode} \def\caption@@withoptargs#1{% - \@ifnextchar[%] + \kernel@ifnextchar[%] {\caption@@@withoptargs{#1}}% {\caption@@@@withoptargs{#1}}} % \end{macrocode} @@ -815,15 +825,6 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}{\ifcaptionsetup@star} -% \changes{v1.2a}{2008/01/12}{This macro added} -% If the starred form of |\caption|\-|setup| is used, this will be set to |true|. -% (It will be reset to |false| at the end of |\caption@set|\-|keys|.) -% \begin{macrocode} -\newif\ifcaptionsetup@star -% \end{macrocode} -% \end{macro} -% % \begin{macro}{\captionsetup} % \changes{v1.0a}{2004/01/17}{Bugfix: Missing \% added} % \changes{v1.1}{2007/07/22}{Starred-variant added} @@ -833,7 +834,9 @@ % \changes{v1.5}{2012/04/09}{Support of multiple optional arguments added} % \changes{v1.8h}{2020/01/03}{Syntax check of saved options added} % \changes{v2.3b}{2022/03/17}{Usage of \cs{captionsetup} inside \cs{caption@setup@options@@} replaced by \cs{caption@setup@options@}} -% |\captionsetup*|\oarg{type}\ldots\marg{keyval-list of options}\\ +% \changes{v2.4}{2022/04/18}{\cs{@ifnextchar} replaced by \cs{kernel@ifnextchar}} +% \changes{v2.4}{2022/04/18}{Usage of \cs{ifcaptionsetup@star} removed} +% |\captionsetup*|\oarg{type}\marg{keyval-list of options}\\ % applies the given list of options. % If the optional argument `type' is specified, we simply save or append % the option list, otherwise we `execute' it with |\set|\-|keys|. @@ -846,32 +849,32 @@ % \end{macrocode} % \begin{macrocode} \newcommand*\@captionsetup[1]{% - \captionsetup@startrue#1\captionsetup@starfalse - \@ifnextchar[%] - \caption@setup@options\caption@setup} + \kernel@ifnextchar[%] + {\caption@setup@options#1}% + {\caption@setup}} % \end{macrocode} % \begin{macrocode} \newcommand*\caption@setup{% \caption@setkeys{caption}} % \end{macrocode} % \begin{macrocode} -\def\caption@setup@options[#1]{% - \@ifnextchar[%] +\def\caption@setup@options#1[#2]{% + \kernel@ifnextchar[%] {\caption@stepthecounter - \@expandtwoargs\caption@setup@options@@{#1}{@\caption@thecounter}}% - {\caption@setup@options@{#1}}} + \@expandtwoargs\caption@setup@options@@{#2}{@\caption@thecounter}#1}% + {\caption@setup@options@#1{#2}}} % \end{macrocode} % \begin{macrocode} -\def\caption@setup@options@@#1#2[#3]#4{% - \caption@declare@option{#2}[]{\caption@setup@options@{#3}{#4}}% - \caption@setup@options@{#1}{#2}} +\def\caption@setup@options@@#1#2#3[#4]#5{% + \caption@declare@option{#2}[]{\caption@setup@options@\@gobble{#4}{#5}}% + \caption@setup@options@#3{#1}{#2}} % \end{macrocode} % \begin{macrocode} -\newcommand*\caption@setup@options@[2]{% +\newcommand*\caption@setup@options@[3]{% \@bsphack - \ifcaptionsetup@star\captionsetup@starfalse\else\caption@addtooptlist{#1}\fi - \caption@checkoptions{#2}% - \expandafter\caption@l@addto@list\csname caption@opt@#1\endcsname{#2}% + #1{\caption@addtooptlist{#2}}% + \caption@checkoptions{#3}% + \expandafter\caption@l@addto@list\csname caption@opt@#2\endcsname{#3}% \@esphack} % \end{macrocode} % \end{macro} @@ -1075,6 +1078,7 @@ % \changes{v1.2a}{2008/01/12}{\cs{captionsetup@starfalse} added} % \changes{v1.2d}{2009/09/30}{Bugfix 09-09-29: Missing error handler will be defined automatically} % \changes{v1.4}{2011/08/24}{Redefinition of \cs{XKV@err} added} +% \changes{v2.4}{2022/04/18}{\cs{captionsetup@starfalse} removed} % |\caption@setkeys|\oarg{package}\marg{family}\marg{key-values}\\ % expands to |\setkeys|\marg{family}\marg{key-values}, % but lets the error messages not refer to the \package{keyval} package @@ -1112,9 +1116,6 @@ \expandafter\let\expandafter\XKV@err\csname ORI@XKV@err\caption@keydepth\endcsname % \end{macrocode} % \begin{macrocode} - \ifx\caption@keydepth\@empty \captionsetup@starfalse \fi -% \end{macrocode} -% \begin{macrocode} \@esphack} % \end{macrocode} % \begin{macrocode} @@ -1408,6 +1409,7 @@ % % \begin{macro}{\caption@decl@package} % \changes{v2.0}{2020/07/26}{This macro added} +% \changes{v2.4}{2022/04/18}{\cs{@ifnextchar} replaced by \cs{kernel@ifnextchar}} % |\caption@decl@package|\marg{option}\marg{cmd}\oarg{package}\marg{name}\ldots\\ % Helper command to declare a caption package option value which is dependent % on the existence of a specific package, for example the |font| value @@ -1415,7 +1417,7 @@ % package. % \begin{macrocode} \newcommand*\caption@decl@package[2]{% - \@ifnextchar[%] + \kernel@ifnextchar[%] {\caption@declare@package{#1}{#2}}% {\caption@declarepackage{#1}{#2}}} \@onlypreamble\caption@decl@package @@ -1690,6 +1692,7 @@ % \changes{v1.0n}{2007/04/03}{This counter added} % \changes{v1.1e}{2007/10/28}{Renamed from \cs{caption@counter} to \cs{caption@thecounter}; \cs{caption@stepcounter} added} % \changes{v1.5}{2012/04/09}{\cs{caption@stepcounter} renamed to \cs{caption@stepthecounter}} +% \changes{v2.4}{2023/03/12}{Definition of \cs{caption@ifoddpage} added to \cs{caption@stepthecounter}} % Internal counter. % At the moment it will be used inside |\caption@if|\-|odd|\-|page| only. % \begin{macrocode} @@ -1699,7 +1702,8 @@ \newcommand*\caption@stepthecounter{% \@tempcnta\caption@thecounter \advance\@tempcnta\@ne\relax - \xdef\caption@thecounter{\the\@tempcnta}} + \xdef\caption@thecounter{\the\@tempcnta}% + \global\let\caption@ifoddpage\caption@ifoddpage@} % \end{macrocode} % \end{macro} % @@ -1746,7 +1750,8 @@ % % \begin{macro}{\caption@pageref} % \changes{v1.1}{2007/09/01}{This macro added} -% \changes{v1.2d}{2009/10/09}{Uses \cs{@latex@warning} instead of \cs{caption@Warning} now} +% \changes{v1.2d}{2009/10/09}{Uses \cs{@latex@warning} instead of \cs{caption@Warning}} +% \changes{v2.4}{2023/03/12}{The warning refers to \texttt{caption@NUM} instead of \texttt{NUM}} % |\caption@pageref|\marg{name}\\ % This command is a modified version of |\page|\-|ref| from \LaTeX2e. % It will be used inside |\caption@if|\-|odd|\-|page| and |\FP@help|\-|Note|. @@ -1754,7 +1759,7 @@ \newcommand*\caption@pageref[1]{% \expandafter\ifx\csname caption@r@#1\endcsname\relax \G@refundefinedtrue % => 'There are undefined references.' - \@latex@warning{Reference `#1' on page \thepage \space undefined}% + \@latex@warning{Reference `caption@#1' on page \thepage \space undefined}% \else \expandafter\let\expandafter\caption@thepage\csname caption@r@#1\endcsname \fi} @@ -1764,24 +1769,25 @@ % \begin{macro}{\caption@ifoddpage} % \changes{v1.0n}{2007/04/03}{This macro added} % \changes{v1.1e}{2007/10/28}{Incrementation of counter moved to \cs{caption@@make}} +% \changes{v2.4}{2023/03/12}{Multiple use for the same counter will be handled correctly} % Currently this macro uses an own label\ldots ref mechanism, % but an alternative implementation method would use the % \package{refcount} package\cite{refcount} and % |\ifodd\get|\-|page|\-|ref|\-|number{|\ldots|}|. % Maybe we will change that in a later release. -% \Note{This macro re-defines itself so the \texttt{.aux} file will -% only be used once per group.} +% \Note{This macro re-defines itself so the \texttt{.aux} file will only be used once per group. +% This re-definition will be reset in \cs{caption@stepthecounter}.} % \begin{macrocode} -\newcommand*\caption@ifoddpage{% +\newcommand*\caption@ifoddpage@{% \caption@iftwoside{% \caption@label\caption@thecounter \caption@pageref\caption@thecounter \ifodd\caption@thepage - \let\caption@ifoddpage\@firstoftwo + \global\let\caption@ifoddpage\@firstoftwo \else - \let\caption@ifoddpage\@secondoftwo + \global\let\caption@ifoddpage\@secondoftwo \fi - }{\let\caption@ifoddpage\@firstoftwo}% + }{\global\let\caption@ifoddpage\@firstoftwo}% % \end{macrocode} % \begin{macrocode} \caption@ifoddpage} @@ -2281,7 +2287,7 @@ % \begin{quote} % |\renewcommand\fnum@figure[1]{\ignorespaces}|\quad % \end{quote} -% (taken from \url{http://compgroups.net/comp.text.tex/figure-without-caption/1915079}). +% (taken from \url{https://comp.text.tex.narkive.com/XkJnYryR/figure-without-caption}). % % We emulate the behaviour of |\@make|\-|caption| of the base document classes % \class{article}, \class{report}, and \class{book} in this regard (in |\caption@@@make|) @@ -4387,6 +4393,7 @@ % \changes{v1.3}{2011/07/07}{This macro added} % \changes{v1.4a}{2011/10/22}{This macro revised} % \changes{v2.3}{2021/07/03}{This macro re-written} +% \changes{v2.4}{2022/04/18}{\cs{@ifnextchar} replaced by \cs{kernel@ifnextchar}} % The following code was taken from |base/ltfloat.dtx| but |\step|\-|counter| % is replaced by |\caption@l@step|\-|counter| so the footnote counter will % only be incremented temporarily for the single-line-check. @@ -4397,7 +4404,7 @@ % be sufficient for the single-line-check.)) % \begin{macrocode} \newcommand*\caption@footnote{% - \@ifnextchar[%] + \kernel@ifnextchar[%] \@xfootnote {\caption@l@stepcounter\@mpfn \protected@xdef\@thefnmark{\thempfn}% @@ -4408,12 +4415,13 @@ % \begin{macro}{\caption@footnotemark} % \changes{v1.3}{2011/07/07}{This macro added} % \changes{v2.3}{2021/07/03}{This macro re-written} +% \changes{v2.4}{2022/04/18}{\cs{@ifnextchar} replaced by \cs{kernel@ifnextchar}} % The following code was taken from |base/ltfloat.dtx| but |\step|\-|counter| % is replaced by |\caption@l@step|\-|counter| so the footnote counter will % only be incremented temporarily for the single-line-check. % \begin{macrocode} \newcommand*\caption@footnotemark{% - \@ifnextchar[%] + \kernel@ifnextchar[%] \@xfootnotemark {\caption@l@stepcounter{footnote}% \protected@xdef\@thefnmark{\thefootnote}% @@ -4423,10 +4431,11 @@ % % \begin{macro}{\caption@footnotetext} % \changes{v2.3}{2021/07/03}{This macro added} +% \changes{v2.4}{2022/04/18}{\cs{@ifnextchar} replaced by \cs{kernel@ifnextchar}} % The following code was taken from |base/ltfloat.dtx|. % \begin{macrocode} \newcommand*\caption@footnotetext{% - \@ifnextchar[%] + \kernel@ifnextchar[%] \@xfootnotenext {\protected@xdef\@thefnmark{\thempfn}% \@footnotetext}} @@ -4436,6 +4445,7 @@ % \begin{macro}{\caption@endnote} % \changes{v1.8}{2018/01/21}{This macro added} % \changes{v2.3}{2021/07/03}{This macro re-written} +% \changes{v2.4}{2022/04/18}{\cs{@ifnextchar} replaced by \cs{kernel@ifnextchar}} % The following code was taken from |endnotes/endnotes.sty| but |\step|\-|counter| % is replaced by |\caption@l@step|\-|counter| so the footnote counter will % only be incremented temporarily for the single-line-check. @@ -4443,7 +4453,7 @@ % |\step|\-|counter|.) % \begin{macrocode} \newcommand*\caption@endnote{% - \@ifnextchar[%] + \kernel@ifnextchar[%] \@xendnote {\caption@l@stepcounter{endnote}% \protected@xdef\@theenmark{\theendnote}% @@ -4454,12 +4464,13 @@ % \begin{macro}{\caption@endnotemark} % \changes{v1.8}{2018/01/21}{This macro added} % \changes{v2.3}{2021/07/03}{This macro re-written} +% \changes{v2.4}{2022/04/18}{\cs{@ifnextchar} replaced by \cs{kernel@ifnextchar}} % The following code was taken from |endnotes/endnotes.sty| but |\step|\-|counter| % is replaced by |\caption@l@step|\-|counter| so the footnote counter will % only be incremented temporarily for the single-line-check. % \begin{macrocode} \newcommand*\caption@endnotemark{% - \@ifnextchar[%] + \kernel@ifnextchar[%] \@xendnotemark {\caption@l@stepcounter{endnote}% \protected@xdef\@theenmark{\theendnote}% @@ -4469,10 +4480,11 @@ % % \begin{macro}{\caption@endnotetext} % \changes{v2.3}{2021/07/03}{This macro added} +% \changes{v2.4}{2022/04/18}{\cs{@ifnextchar} replaced by \cs{kernel@ifnextchar}} % The following code was taken from |endnotes/endnotes.sty|. % \begin{macrocode} \newcommand*\caption@endnotetext{% - \@ifnextchar[%] + \kernel@ifnextchar[%] \@xendnotenext {\protected@xdef\@theenmark{\theendnote}% \@endnotetext}} @@ -4753,6 +4765,8 @@ % \changes{v1.13}{2020/07/28}{Uses \cs{caption@l@addto@list} instead of \cs{@cons} now} % \changes{v1.13}{2020/07/29}{Usage of \cs{caption@subtype@hook} added} % \changes{v1.13}{2020/07/29}{We don't re-use existing counters anymore (This was a bad idea anyway)} +% \changes{v1.13b}{2022/04/06}{We don't re-use existing counters anymore (Part 2)} +% \changes{v2.4}{2022/04/06}{If a counter is already defined the counter source will be included in the resulting error message} % |\DeclareCaptionSubType*|\oarg{numbering scheme}\marg{type}\\ % The starred variant provides the numbering format % \meta{type}|.|\meta{subtype} while the non-starred variant simply uses @@ -4764,7 +4778,7 @@ % \end{macrocode} % \begin{macrocode} \newcommand*\caption@declaresubtype[1]{% - \@testopt{\caption@@declaresubtype{#1}}{alph}} + \@testopt{\caption@@declaresubtype#1}{alph}} \@onlypreamble\caption@declaresubtype % \end{macrocode} % \begin{macrocode} @@ -4782,28 +4796,37 @@ % If not, define the counter and list entry. % \begin{macrocode} \caption@ifdefined@subtype{#4}% - {\caption@Debug{Modify subtype `#4'}}% - {\caption@Debug{New subtype `#4'}% - \newcounter{#4}[{#3}]% - \@namedef{ext@#4}{\csname ext@#3\endcsname}% - \caption@declaresublistentry{#3}% - \caption@l@addto@list\caption@subtypelist{#4}% - \caption@subtype@hook{#4}}% + {\caption@Info{Modify subtype `#4'}}% + {\caption@Info{New subtype `#4'}% + \@ifundefined{c@#4}% + {\newcounter{#4}[#3]% + \@namedef{#4name}{}% + \@namedef{#4autorefname}{\csname #3autorefname\endcsname}% +% \end{macrocode} +% \begin{macrocode} + \@namedef{ext@#4}{\csname ext@#3\endcsname}% + \caption@declaresublistentry{#3}% % \end{macrocode} % Support of \package{titletoc} package % \begin{macrocode} - \caption@ifdefined\contentsuse{% - \contentsuse{#4}{\csname ext@#4\endcsname}}{}% + \caption@ifdefined\contentsuse{% + \contentsuse{#4}{\csname ext@#4\endcsname}}{}% % \end{macrocode} % \begin{macrocode} - \@namedef{#4name}{}% - \@namedef{#4autorefname}{\csname #3autorefname\endcsname}% - #1% is \@firstoftwo in star form, and \@secondoftwo otherwise + \caption@l@addto@list\caption@subtypelist{#4}% + \caption@subtype@hook{#4}}% +% \end{macrocode} +% \begin{macrocode} + {\caption@subtypesource\caption@subtype@source{#4}% + \caption@Error{The counter `#4' was already defined by\MessageBreak\caption@subtype@source}}}% +% \end{macrocode} +% \begin{macrocode} + #1% is \@firstoftwo in star form, and \@secondoftwo otherwise {\@namedef{p@#4}{}% \@namedef{the#4}{\csname the#3\endcsname.\@nameuse{#2}{#4}}}% {\@namedef{p@#4}{\csname the#3\endcsname}% \@namedef{the#4}{\@nameuse{#2}{#4}}}% - \@namedef{theH#4}{\csname theH#3\endcsname.\arabic{#4}}} + \@namedef{theH#4}{\csname theH#3\endcsname.\arabic{#4}}} % \end{macrocode} % \begin{macrocode} \@onlypreamble\caption@@@declaresubtype @@ -4887,6 +4910,21 @@ % \end{macrocode} % \end{macro} % +% \begin{macro}{\caption@subtypesource} +% \changes{v2.4}{2022/04/06}{This macro definition added} +% |\caption@subtypesource|\marg{cmd}\marg{sub-type}\\ +% is used by |\Declare|\-|Caption|\-|Sub|\-|Type| to indicate what command and package +% has defined the given sub-type. +% \begin{macrocode} +\newcommand*\caption@subtypesource[2]{% + \caption@ifdefined@subtype{#2}% + {\def#1{\noexpand\DeclareCaptionSubType (offered by the caption package)}}% + {\caption@ifin@list\sf@counterlist{#2}% + {\def#1{\noexpand\newsubfloat (offered by the subfig package)}}% + {\def#1{an unknown document class or package}}}} +% \end{macrocode} +% \end{macro} +% % \begin{macro}{\ForEachCaptionSubType} % \changes{v1.13}{2020/07/29}{This macro added as replacement for \cs{caption@For}} % |\ForEachCaptionSubType*|\marg{code with \#1}\\ |