summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/caption/caption3.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/caption/caption3.dtx')
-rw-r--r--macros/latex/contrib/caption/caption3.dtx3117
1 files changed, 1759 insertions, 1358 deletions
diff --git a/macros/latex/contrib/caption/caption3.dtx b/macros/latex/contrib/caption/caption3.dtx
index 8edc856461..5f2823ac0b 100644
--- a/macros/latex/contrib/caption/caption3.dtx
+++ b/macros/latex/contrib/caption/caption3.dtx
@@ -19,21 +19,25 @@
% This Current Maintainer of this work is Axel Sommerfeldt.
%
% This work consists of the files
-% caption.ins, caption.dtx, caption2.dtx, caption3.dtx,
-% bicaption.dtx, ltcaption.dtx, subcaption.dtx, totalcount.dtx,
+% caption.ins, caption.dtx, caption-light.dtx, caption2.dtx, caption3.dtx,
+% caption-ams-smf.dtx, caption-beamer.dtx, caption-elsarticle.dtx,
+% caption-koma.dtx, caption-memoir.dtx, caption-ntg.dtx,
+% caption-thesis.dtx, bicaption.dtx, ltcaption.dtx, subcaption.dtx,
% the derived files
-% caption.sty, caption2.sty, caption3.sty,
-% bicaption.sty, ltcaption.sty, subcaption.sty, totalcount.sty,
+% caption.sty, caption-light.sty, caption2.sty, caption3.sty,
+% caption-ams-smf.sto, caption-beamer.sto, caption-elsarticle.sto,
+% caption-koma.sto, caption-memoir.sto, caption-ntg.sto,
+% caption-thesis.sto, bicaption.sty, ltcaption.sty, subcaption.sty,
% and the user manuals
% caption-deu.tex, caption-eng.tex, caption-rus.tex.
%
% \fi
-% \CheckSum{3606}
+% \CheckSum{3636}
%
% \iffalse
%<*driver>
\NeedsTeXFormat{LaTeX2e}[1994/12/01]
-\ProvidesFile{caption3.drv}[2020/05/30 v1.12 Implementation of the caption kernel]
+\ProvidesFile{caption3.drv}[2019/09/10 v2.0 Implementation of the caption kernel]
\hbadness=9999 \newcount\hbadness \hfuzz=100pt % Make TeX shut up.
%\errorcontextlines=3
%
@@ -57,16 +61,11 @@
\ifpdf\usepackage{hypdestopt}\fi
\hypersetup{pdfkeywords={LaTeX, package, caption},pdfstartpage={},pdfstartview={}}
%
-\usepackage{caption3}[2020/05/30]
+\usepackage{caption3}[2020/07/27]
%
-\DeclareRobustCommand*\AmS{\texorpdfstring
- {{\protect\usefont{OMS}{cmsy}{m}{n}A\kern-.1667em\lower.5ex\hbox{M}\kern-.125emS}}%
- {AMS}}
-\DeclareRobustCommand*\KOMAScript{\texorpdfstring
- {\textsf{K\kern.05em O\kern.05em M\kern.05em A\kern.1em-\kern.1em Script}}%
- {KOMA-Script}}
-\DeclareRobustCommand*\NTG{NTG}
-\DeclareRobustCommand*\SmF{SMF}
+\DeclareRobustCommand*\eTeX{\texorpdfstring
+ {\leavevmode\hbox{$\varepsilon$}-\TeX}%
+ {e-TeX}}
%
\begin{document}
\DocInput{caption3.dtx}
@@ -74,28 +73,31 @@
%</driver>
% \fi
%
+% \def\thispackage{the \package{caption} kernel}
+% \def\Thispackage{The \package{caption} kernel}
+%
% \newcommand*\purerm[1]{{\upshape\mdseries\rmfamily #1}}
% \newcommand*\puresf[1]{{\upshape\mdseries\sffamily #1}}
% \newcommand*\purett[1]{{\upshape\mdseries\ttfamily #1}}
% \let\class\puresf \let\package\puresf
% \let\env\purett \let\opt\purett
%
-% \def\thispackage{the \package{caption} kernel}
-% \def\Thispackage{The \package{caption} kernel}
-%
% \newcommand*\csmarg[1]{\texttt{\char`\{#1\char`\}}}
% \newcommand*\csoarg[1]{\texttt{\char`\[#1\char`\]}}
% \newcommand*\version[2][]{\textit{v#2}}
%
+% \GetFileInfo{caption3.drv}
+% \let\docdate\filedate
+% \let\docversion\fileversion
% \GetFileInfo{caption3.sty}
%
% \title{The Implementation of
% \texorpdfstring{\thispackage\thanks{%^^A
-% This package has version number \fileversion, last revised \filedate.}}%^^A
+% This package has version number \docversion.}}%^^A
% {the caption kernel}}
% \author{Axel Sommerfeldt\\
% \url{https://gitlab.com/axelsommerfeldt/caption}}
-% \date{\filedate}
+% \date{\docdate}
% \maketitle
%
% \begin{abstract}
@@ -174,8 +176,7 @@
% \newcommand*\Note[2][Note]{\par{\small\emph{#1:} #2}\par}
%
% \changes{v1.0}{2003/12/20}{Rewritten; many new commands and features}
-% \changes{v1.0c}{2004/11/28}{Split into two packages:
-% \package{caption} \& \package{caption3}}
+% \changes{v1.0c}{2004/11/28}{Split into two packages: \package{caption} \& \package{caption3}}
%
% \iffalse
% --------------------------------------------------------------------------- %
@@ -191,38 +192,17 @@
%
% \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}[1994/12/01]
-\ProvidesPackage{caption3}[2020/07/20 v1.12b caption3 kernel (AR)]
-% \end{macrocode}
-%
-% \section{Workaround for bug in package \package{arabtex}}
-% \package{arabtex} re-defines \cs{@gobble} as not-long so the packages of the
-% \package{caption} package bundle are doomed to fail.
-% Since this fatal bug won't be fixed in \package{arabtex} but we are dependent on a
-% proper definition of \cs{@gobble}, \cs{@firstofone}, \cs{@firstoftwo}, \cs{@secondoftwo},
-% and so on we fix this here. (Sigh!)
-% \begin{macrocode}
-\providecommand\caption@FixArabTeX{%
- \def\caption@tempa##1{}%
- \ifx\caption@tempa\@gobble
- \PackageInfo{caption3}{Fixing ArabTeX}%
- \long\def\@gobble##1{}%
- \fi}
-% \end{macrocode}
-% Do the fix now and at |\begin{document}|, in case \package{arabtex} will be loaded after \package{caption}.
-% \begin{macrocode}
-\caption@FixArabTeX
-\AtBeginDocument{%
- \caption@FixArabTeX
- \let\caption@FixArabTeX\@undefined}
+\ProvidesPackage{caption3}[2020/08/30 v2.0 caption3 kernel (AR)]
% \end{macrocode}
%
% \section{Generic helpers}
%
% \begin{macro}{\@nameundef}
-% This is the opposite to |\@namedef| which is offered by the \LaTeX\ kernel.
-% We use it to remove the definition of some commands and keyval options after
-% |\begin{document}| (to save \TeX\ memory) and to remove caption options defined
-% with |\captionsetup|\oarg{type}.
+% |\@nameundef|\marg{command name}\\
+% is the opposite to |\@namedef| which is offered by the \LaTeX\ kernel.
+% We use it to remove the definition of some commands and keyval options after
+% |\begin{document}| (to save \TeX\ memory) and to remove caption options defined
+% with |\captionsetup|\oarg{type}.
% \begin{macrocode}
\providecommand*\@nameundef[1]{%
\expandafter\let\csname #1\endcsname\@undefined}
@@ -231,34 +211,24 @@
%
% \begin{macro}{\l@addto@macro}
% \changes{v1.5}{2013/04/26}{Revised}
-% The \LaTeXe\ kernel offers the internal helper macro |\g@addto@macro| which
-% globally adds tokens to existing macros, like in |\AtBeginDocument|.
-% This is the same but it works local, not global.
-% \begin{macrocode}
-\begingroup\expandafter\expandafter\expandafter\endgroup
-\expandafter\ifx\csname currentgrouplevel\endcsname\relax
- \PackageInfo{caption3}{TeX engine: TeX}
- \let\caption@ifeTeX\@secondoftwo
- \providecommand\l@addto@macro[2]{%
- \begingroup
- \toks@\expandafter{#1#2}%
- \xdef\caption@addto@temp{\the\toks@}%
- \endgroup
- \let#1\caption@addto@temp}
-\else
- \PackageInfo{caption3}{TeX engine: e-TeX}
- \let\caption@ifeTeX\@firstoftwo
- \providecommand\l@addto@macro[2]{%
- \edef#1{\unexpanded\expandafter{#1#2}}}
-\fi
+% \changes{v2.0}{2019/09/11}{Relies on \eTeX{} now}
+% |\l@addto@macro|\marg{command}\marg{code}\\
+% The \LaTeXe\ kernel offers the internal helper macro |\g@addto@macro| which
+% globally adds tokens to existing macros, like in |\AtBeginDocument|.
+% This one is the same but it works locally, not globally.
+% \begin{macrocode}
+\providecommand\l@addto@macro[2]{%
+ \edef#1{\unexpanded\expandafter{#1#2}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\bothIfFirst}
% \begin{macro}{\bothIfSecond}
-% |\bothIfFirst| tests if the first argument is not empty, |\bothIfSecond|
-% tests if the second argument is not empty. If yes both arguments get
-% typeset, otherwise none of them.
+% |\bothIfFirst|\marg{code no. 1}\marg{code no. 2}\\
+% |\bothIfSecond|\marg{code no. 1}\marg{code no. 2}\\
+% |\bothIfFirst| tests if the first argument is not empty, |\bothIfSecond|
+% tests if the second argument is not empty. If yes both arguments get
+% typeset, otherwise none of them.
% \begin{macrocode}
\def\bothIfFirst#1#2{%
\protected@edef\caption@tempa{#1}%
@@ -279,44 +249,53 @@
% \begin{macro}{\caption@ifundefined}
% \changes{v1.3a}{2011/08/12}{This macro added}
% \changes{v1.3b}{2011/08/18}{Made expandable}
-% Similar to \cs{@ifundefined} offered by the \LaTeX kernel,
-% but takes a macro as argument instead of a macro name.
+% |\caption@ifundefined|\marg{command}\marg{yes-code}\marg{no-code}\\
+% is similar to \cs{@ifundefined} offered by the \LaTeX kernel,
+% but takes a command as argument instead of a command name.
% \begin{macrocode}
\newcommand*\caption@ifundefined[1]{%
- \ifx#1\@undefined
- \expandafter\@firstoftwo
- \else\ifx#1\relax
- \expandafter\expandafter\expandafter\@firstoftwo
+ \ifdefined#1%
+ \ifx#1\relax
+ \expandafter\expandafter\expandafter\@firstoftwo
+ \else
+ \expandafter\expandafter\expandafter\@secondoftwo
+ \fi
\else
- \expandafter\expandafter\expandafter\@secondoftwo
- \fi\fi}
+ \expandafter\@firstoftwo
+ \fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\caption@ifdefined}
% \changes{v1.8e}{2018/05/11}{This macro added}
-% Similar to \cs{@ifundefined} offered by the \LaTeX kernel,
-% but takes a macro as argument instead of a macro name.
+% |\caption@ifdefined|\marg{command}\marg{yes-code}\marg{no-code}\\
+% is similar to \cs{@ifundefined} offered by the \LaTeX kernel,
+% but takes a command as argument instead of a command name.
% \begin{macrocode}
\newcommand*\caption@ifdefined[1]{%
- \ifx#1\@undefined
- \expandafter\@secondoftwo
- \else\ifx#1\relax
- \expandafter\expandafter\expandafter\@secondoftwo
+ \ifdefined#1%
+ \ifx#1\relax
+ \expandafter\expandafter\expandafter\@secondoftwo
+ \else
+ \expandafter\expandafter\expandafter\@firstoftwo
+ \fi
\else
- \expandafter\expandafter\expandafter\@firstoftwo
- \fi\fi}
+ \expandafter\@secondoftwo
+ \fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\caption@ifinlist}
% \changes{v1.1}{2007/07/29}{Rewritten}
-% This helper macro checks if the first argument is in the comma separated
-% list which is offered as second argument. So for example
-% \begin{quote}
-% |\caption@ifinlist{frank}{axel,frank,olga,steven}{yes}{no}|
-% \end{quote}
-% would expand to |yes|.
+% |\caption@ifinlist|\marg{element}\marg{list}\marg{yes-code}\marg{no-code}\\
+% This helper command checks if the \meta{element} is in the comma separated
+% \meta{list}. So for example
+% \begin{quote}
+% |\caption@ifinlist{frank}{axel,frank,olga,steven}{yes}{no}|
+% \end{quote}
+% would expand to |yes|.\par
+% (Note: Since this command is used by the \package{floatrow} package as well
+% its syntax should not change.)
% \begin{macrocode}
\newcommand*\caption@ifinlist{%
\@expandtwoargs\caption@@ifinlist}
@@ -337,7 +316,9 @@
%
% \begin{macro}{\caption@ifin@list}
% \changes{v1.1}{2007/08/12}{This macro added}
-% |\caption@ifin@list|\marg{cmd}\marg{list entry}\marg{yes}\marg{no}
+% |\caption@ifin@list|\marg{cmd}\marg{element}\marg{yes-code}\marg{no-code}\\
+% is the same as |\caption@ifinlist| but with a command (containing a list)
+% instead of the list itself.
% \begin{macrocode}
\newcommand*\caption@ifin@list[2]{%
\caption@ifempty@list#1%
@@ -348,7 +329,9 @@
%
% \begin{macro}{\caption@g@addto@list}
% \changes{v1.1}{2007/07/29}{This macro added}
-% |\caption@g@addto@list|\marg{cmd}\marg{list entry}
+% |\caption@g@addto@list|\marg{cmd}\marg{element}\\
+% adds an element to a command containing a list.
+% (The command will get defined if it isn't defined yet.)
% \begin{macrocode}
\newcommand*\caption@g@addto@list[2]{%
\caption@ifempty@list#1{\gdef#1{#2}}{\g@addto@macro#1{,#2}}}
@@ -356,7 +339,8 @@
% \end{macro}
% \begin{macro}{\caption@l@addto@list}
% \changes{v1.1}{2007/07/29}{This macro added}
-% |\caption@l@addto@list|\marg{cmd}\marg{list entry}
+% |\caption@l@addto@list|\marg{cmd}\marg{element}\\
+% is the same as |\caption@g@addto@list| but works locally.
% \begin{macrocode}
\newcommand*\caption@l@addto@list[2]{%
\caption@ifempty@list#1{\def#1{#2}}{\l@addto@macro#1{,#2}}}
@@ -365,7 +349,10 @@
%
% \begin{macro}{\caption@g@removefrom@list}
% \changes{v1.1}{2007/07/29}{This macro added}
-% |\caption@g@removefrom@list|\marg{cmd}\marg{list entry}
+% |\caption@g@removefrom@list|\marg{cmd}\marg{element}\\
+% removes an element from a command containing a list.
+% \Note[Caveat]{\meta{cmd} will be expanded during this process since
+% \cs{@removeelement} is using \cs{edef} to build the new list.}
% \begin{macrocode}
\newcommand*\caption@g@removefrom@list[2]{%
\caption@l@removefrom@list#1{#2}%
@@ -374,9 +361,10 @@
% \end{macro}
% \begin{macro}{\caption@l@removefrom@list}
% \changes{v1.1}{2007/07/29}{This macro added}
-% |\caption@l@removefrom@list|\marg{cmd}\marg{list entry}\par
-% \Note[Caveat]{\meta{cmd} will be expanded during this process since
-% \cs{@removeelement} is using \cs{edef} to build the new list!}
+% |\caption@l@removefrom@list|\marg{cmd}\marg{element}\\
+% is the same as |\caption@g@removefrom@list| but works locally.
+% \Note[Caveat]{\meta{cmd} will be expanded during this process since
+% \cs{@removeelement} is using \cs{edef} to build the new list.}
% \begin{macrocode}
\newcommand*\caption@l@removefrom@list[2]{%
\caption@ifempty@list#1{}{\@expandtwoargs\@removeelement{#2}#1#1}}
@@ -385,19 +373,22 @@
%
% \begin{macro}{\caption@for@list}
% \changes{v1.1}{2007/07/29}{This macro added}
-% |\caption@for@list|\marg{cmd}\marg{code with \#1}
+% |\caption@for@list|\marg{cmd}\marg{code with \#1}\\
+% iterates all elements of the list (within \meta{cmd}) using the given
+% \meta{code}.
% \begin{macrocode}
\newcommand*\caption@for@list[2]{%
- \caption@ifempty@list#1{}{%
- \def\caption@tempb##1{#2}%
- \@for\caption@tempa:=#1\do{%
- \expandafter\caption@tempb\expandafter{\caption@tempa}}}}
+ \caption@ifempty@list#1{}%
+ {\def\caption@tempb##1{#2}%
+ \@for\caption@tempa:=#1\do{%
+ \expandafter\caption@tempb\expandafter{\caption@tempa}}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\caption@ifempty@list}
% \changes{v1.1}{2007/07/29}{This macro added}
-% |\caption@ifempty@list|\marg{cmd}\marg{true}\marg{false}
+% |\caption@ifempty@list|\marg{cmd}\marg{yes-code}\marg{no-code}\\
+% This helper command checks if the list (within \meta{cmd}) is empty.
% \begin{macrocode}
\newcommand*\caption@ifempty@list[1]{%
\ifx#1\@undefined
@@ -416,30 +407,33 @@
%
% \pagebreak[3]
% \begin{macro}{\caption@setbool}
-% \begin{macro}{\caption@set@bool}
% \changes{v1.1}{2007/04/05}{\cs{caption@set@bool}\marg{cmd}\marg{value} added}
% \begin{macro}{\caption@ifbool}
+% \changes{v1.1}{2020/08/02}{\cs{caption@if@bool}\marg{value} added}
% \begin{macro}{\caption@undefbool}
-% For setting and testing boolean options we offer these three helper macros:
-% \begin{quote}
-% |\caption@setbool|\marg{name}\marg{value}\\
-% | |(with |value = false/true/no/yes/off/on/0/1|)\\
-% |\caption@ifbool|\marg{name}\marg{if-clause}\marg{else-clause}\\
-% |\caption@undefbool|\marg{name}
-% \end{quote}
+% For setting and testing boolean options we offer these three helper macros:
+% \begin{quote}
+% |\caption@setbool|\marg{name}\marg{value}\\
+% | |(with |value = false/true/no/yes/off/on/0/1|)\\
+% |\caption@ifbool|\marg{name}\marg{if-clause}\marg{else-clause}\\
+% |\caption@undefbool|\marg{name}
+% \end{quote}
% \begin{macrocode}
\newcommand*\caption@setbool[1]{%
\expandafter\caption@set@bool\csname caption@if#1\endcsname}
% \end{macrocode}
% \begin{macrocode}
\newcommand*\caption@set@bool[2]{%
- \caption@ifinlist{#2}{1,true,yes,on}{%
- \let#1\@firstoftwo
- }{\caption@ifinlist{#2}{0,false,no,off}{%
- \let#1\@secondoftwo
- }{%
- \caption@Error{Undefined boolean value `#2'}%
- }}}
+ \caption@if@bool{#2}{\let#1\@firstoftwo}{\let#1\@secondoftwo}}
+% \end{macrocode}
+% \begin{macrocode}
+\newcommand*\caption@if@bool[1]{%
+ \caption@ifinlist{#1}{1,true,yes,on}%
+ {\@firstoftwo}%
+ {\caption@ifinlist{#1}{0,false,no,off}%
+ {}%
+ {\caption@Error{Undefined boolean value `#1'}}%
+ \@secondoftwo}}
% \end{macrocode}
% \begin{macrocode}
\newcommand*\caption@ifbool[1]{\@nameuse{caption@if#1}}
@@ -450,21 +444,31 @@
% \end{macro}
% \end{macro}
% \end{macro}
-% \end{macro}
%
% \begin{macro}{\caption@teststar}
% \changes{v1.1}{2007/05/08}{This macro and its usage added}
% \changes{v1.1e}{2007/10/28}{\cs{caption@teststar@} added}
-% |\caption@teststar|\marg{cmd}\marg{star arg}\marg{non-star arg}\\
-% |\caption@teststar@|\marg{cmd}\marg{star arg}\marg{non-star arg}
+% |\caption@teststar|\marg{cmd}\marg{star-arg}\marg{non-star-arg}\\
+% expands \meta{cmd} with either argument \marg{star-arg} or
+% \meta{non-star-arg}, depending on if the next char is a star (or not).\par
+% |\caption@teststar@|\marg{cmd}\marg{star-arg}\marg{non-star-arg}\\
+% will test the catcode of the character \@ additionally.
% \begin{macrocode}
-\newcommand*\caption@teststar[3]{\@ifstar{#1{#2}}{#1{#3}}}
+\newcommand*\caption@teststar[3]{%
+ \@ifstar{#1{#2}}{#1{#3}}}
% \end{macrocode}
% \begin{macrocode}
\newcommand*\caption@teststar@[3]{%
\@ifstar{#1{#2}}{\caption@ifatletter{#1{#2}}{#1{#3}}}}
\AtBeginDocument{\let\caption@teststar@\caption@teststar}
% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\caption@ifatletter}
+% \changes{v1.1e}{2007/10/28}{This macro added}
+% |\caption@ifatletter|\marg{yes-code}\marg{no-code}\\
+% will either expand \meta{yes-code} or \meta{no-code},
+% depending on the catcode of the character \@.
% \begin{macrocode}
\newcommand*\caption@ifatletter{%
\ifnum\the\catcode`\@=11
@@ -472,6 +476,8 @@
\else
\expandafter\@secondoftwo
\fi}
+% \end{macrocode}
+% \begin{macrocode}
\AtBeginDocument{\let\caption@ifatletter\@secondoftwo}
% \end{macrocode}
% \end{macro}
@@ -479,7 +485,9 @@
% \begin{macro}{\caption@withoptargs}
% \changes{v1.1}{2007/08/12}{This macro added}
% \changes{v1.5}{2012/04/09}{This macro revised}
-% |\caption@withoptargs|\marg{cmd}
+% |\caption@withoptargs|\marg{cmd}\\
+% collects a star and all optional arguments, and expands \meta{cmd}
+% afterwards with the collected stuff as first argument.
% \begin{macrocode}
\newcommand*\caption@withoptargs[1]{%
\@ifstar
@@ -506,8 +514,8 @@
%
% \begin{macro}{\caption@gobble}
% \changes{v1.4}{2011/08/19}{This macro added}
-% |\caption@gobble*|\oarg{arg}\oarg{\ldots}\marg{arg}\par
-% Same as |\@gobble|, but gobbles optional arguments as well.
+% |\caption@gobble*|\oarg{arg}\oarg{\ldots}\marg{arg}\\
+% is similar to |\@gobble| but gobbles a star and optional arguments as well.
% \begin{macrocode}
\DeclareRobustCommand*\caption@gobble{%
\caption@withoptargs\@gobbletwo}
@@ -517,11 +525,11 @@
% \begin{macro}{\caption@AtBeginDocument}
% \changes{v1.1}{2007/04/13}{This macro and its usage added}
% \changes{v1.2e}{2010/01/09}{Adapted to the combine document class}
-% |\caption@AtBeginDocument*|\marg{code}\\
-% Same as |\AtBeginDocument| but the execution of code
-% will be surrounded by two |\PackageInfo|s.
-% The starred variant causes the code to be executed after all code
-% specified using the non-starred variant.
+% |\caption@AtBeginDocument*|\marg{code}\\
+% is similar to |\AtBeginDocument| but the execution of code will be
+% surrounded by two |\Package|\-|Info|s.
+% The starred variant causes the code to be executed after all code
+% specified using the non-starred variant.
% \begin{macrocode}
\let\caption@begindocumenthook\@empty
\let\caption@@begindocumenthook\@empty
@@ -557,7 +565,8 @@
%
% \begin{macro}{\caption@Info}
% \changes{v1.3}{2010/10/25}{Moved from package to kernel}
-% |\caption@Info|\marg{message}
+% |\caption@Info|\marg{message}\\
+% issues an info message (with code line indication).
% \begin{macrocode}
\newcommand*\caption@Info[1]{%
\PackageInfo{caption}{#1}}
@@ -565,10 +574,11 @@
% \end{macro}
% \begin{macro}{\caption@InfoNoLine}
% \changes{v1.3}{2010/10/25}{Moved from package to kernel}
-% |\caption@InfoNoLine|\marg{message}\\
-% \Note{The \cs{@gobble} at the end of the 2nd argument of
-% \cs{PackageInfo} suppresses the line number info.
-% See TLC2\cite{TLC2}, A.4.7, p885 for details.}
+% |\caption@InfoNoLine|\marg{message}\\
+% issues an info message without code line indication.
+% \Note{The \cs{@gobble} at the end of the 2nd argument of
+% \cs{PackageInfo} suppresses the line number info.
+% See TLC2\cite{TLC2}, A.4.7, p885 for details.}
% \begin{macrocode}
\newcommand*\caption@InfoNoLine[1]{%
\caption@Info{#1\@gobble}}
@@ -577,7 +587,8 @@
%
% \begin{macro}{\caption@Warning}
% \changes{v1.1c}{2007/10/14}{This macro added, will now be used for warnings}
-% |\caption@Warning|\marg{message}
+% |\caption@Warning|\marg{message}\\
+% issues a warning message (with code line indication).
% \begin{macrocode}
\newcommand*\caption@Warning[1]{%
\caption@WarningNoLine{#1\on@line}}
@@ -585,7 +596,8 @@
% \end{macro}
% \begin{macro}{\caption@WarningNoLine}
% \changes{v1.1c}{2007/10/14}{This macro added, will now be used for warnings}
-% |\caption@WarningNoLine|\marg{message}
+% |\caption@WarningNoLine|\marg{message}\\
+% issues a warning message without code line indication.
% \begin{macrocode}
\newcommand*\caption@WarningNoLine[1]{%
\PackageWarning{caption}{#1.^^J\caption@wh\@gobbletwo}}
@@ -600,7 +612,8 @@
% \changes{v1.0j}{2007/01/20}{This macro added, will now be used for errors}
% \changes{v1.0o}{2007/04/11}{Renamed from \cs{caption@error} to \cs{caption@Error}}
% \changes{v1.1b}{2007/09/18}{Usage of \cs{caption@Package} removed}
-% |\caption@Error|\marg{message}
+% |\caption@Error|\marg{message}\\
+% issues an error message (with code line indication).
% \begin{macrocode}
\newcommand*\caption@Error[1]{%
\PackageError{caption}{#1}\caption@eh}
@@ -615,6 +628,9 @@
%
% \begin{macro}{\caption@KV@err}
% \changes{v1.1b}{2007/09/18}{This macro added}
+% |\caption@KV@err|\marg{message}\\
+% will be used to issue an error while parsing the key-value (package)
+% options.
% \begin{macrocode}
\let\caption@KV@err\caption@Error
% \end{macrocode}
@@ -622,15 +638,15 @@
%
% \section{Using the keyval package}
%
-% We need the \package{keyval} package for option handling, so we load it here.
+% We need the \package{keyval} package for option handling, so we load it here.\par
+% \emph{TODO:} Use some recent stuff instead, for example kvdefinekey and kvsetkeys.
% \begin{macrocode}
\RequirePackage{keyval}[1997/11/10]
% \end{macrocode}
%
% \begin{macro}{\undefine@key}
-% |\undefine@key|\marg{family}\marg{key}\par
-% This helper macro is the opposite of |\define@key|, it removes a keyval
-% definition.
+% |\undefine@key|\marg{family}\marg{key}\\
+% is the opposite of |\define@key|, it removes a keyval definition.
% \begin{macrocode}
\providecommand*\undefine@key[2]{%
\@nameundef{KV@#1@#2}\@nameundef{KV@#1@#2@default}}
@@ -640,8 +656,9 @@
% \begin{macro}{\@onlypreamble@key}
% \changes{v1.1}{2007/07/22}{This macro added}
% \changes{v1.1e}{2007/11/01}{\cs{KV@err} will be used now instead of \cs{@notprerr}}
-% |\onlypreamble@key|\marg{family}\marg{key}\par
-% Analogous to |\@onlypreamble| from \LaTeXe.
+% |\onlypreamble@key|\marg{family}\marg{key}\\
+% marks a keyval definition only valid in the document preamble, analogous to
+% |\@only|\-|preamble| from \LaTeXe.
% \begin{macrocode}
\providecommand*\@preamble@keys{}
\providecommand*\@onlypreamble@key[2]{\@cons\@preamble@keys{{#1}{#2}}}
@@ -660,13 +677,12 @@
% \end{macro}
%
% \begin{macro}{\DeclareCaptionOption}
-% |\DeclareCaptionOption|\marg{option}\oarg{default value}\marg{code}\\
-% |\DeclareCaptionOption*|\marg{option}\oarg{default value}\marg{code}\par
-% We declare our options using these commands (instead of using
-% |\DeclareOption| offered by \LaTeXe), so the keyval package is used.
-% The starred form makes the option available during the lifetime of the
-% current package only, so they can be used with |\usepackage|, but
-% \emph{not} with |\captionsetup| later on.
+% |\DeclareCaptionOption*|\marg{option}\oarg{default value}\marg{code}\\
+% We declare our options using these commands (instead of using
+% |\Declare|\-|Option| offered by \LaTeXe), so the keyval package is used.
+% The starred form makes the option available during the lifetime of the
+% current package only, so they can be used with |\use|\-|package|, but
+% \emph{not} with |\caption|\-|setup| later on.
% \begin{macrocode}
\newcommand*\DeclareCaptionOption{%
\caption@teststar\caption@declareoption\AtEndOfPackage\@gobble}
@@ -680,15 +696,15 @@
% \begin{macrocode}
\newcommand*\caption@declare@option{%
\define@key{caption}}
-%% no \@onlypreamble\caption@declare@option, will be used by \captionsetup
+%% no \@onlypreamble\caption@declare@option since it will be used by \captionsetup
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\DeclareCaptionOptionNoValue}
% \changes{v1.1c}{2007/10/06}{This macro added}
-% |\DeclareCaptionOptionNoValue|\marg{option}\marg{code}\\
-% |\DeclareCaptionOptionNoValue*|\marg{option}\marg{code}\par
-% Same as \cs{DeclareCaptionOption} but issues an error if a value is given.
+% |\DeclareCaptionOptionNoValue*|\marg{option}\marg{code}\\
+% is the same as |\DeclareCaptionOption| but issues an error if a value is
+% given.
% \begin{macrocode}
\newcommand*\DeclareCaptionOptionNoValue{%
\caption@teststar\caption@declareoption@novalue\AtEndOfPackage\@gobble}
@@ -713,8 +729,8 @@
%
% \begin{macro}{\ifcaptionsetup@star}
% \changes{v1.2a}{2008/01/12}{This macro added}
-% If the starred form of |\captionsetup| is used, this will be set to |true|.
-% (It will be reset to |false| at the end of |\caption@setkeys|.)
+% If the starred form of |\captionsetup| 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}
@@ -728,13 +744,13 @@
% \changes{v1.2a}{2008/01/12}{\cs{ifcaptionsetup@star} will be set now}
% \changes{v1.5}{2012/04/09}{Support of multiple optional arguments added}
% \changes{v1.8h}{2020/01/03}{Syntax check of saved options added}
-% |\captionsetup|\oarg{type}\ldots\marg{keyval-list of options}\\
-% |\captionsetup*|\oarg{type}\ldots\marg{keyval-list of options}\par
-% If the optional argument `type' is specified, we simply save or append
-% the option list, otherwise we `execute' it with |\setkeys|.
-% (The non-starred variant issues a warning if \meta{keyval-list of options}
-% is not used later on.)
-% \Note{The starred variant will be used inside packages automatically.}
+% |\captionsetup*|\oarg{type}\ldots\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|.
+% (The non-starred variant issues a warning if \meta{keyval-list of options}
+% is not used later on.)
+% \Note{The starred variant will be used inside packages automatically.}
% \begin{macrocode}
\newcommand*\captionsetup{%
\caption@teststar@\@captionsetup\@gobble\@firstofone}
@@ -773,7 +789,8 @@
%
% \begin{macro}{\caption@checkoptions}
% \changes{v1.8h}{2020/01/03}{This macro added}
-% Check the syntax of the given options by executing them inside a group.
+% |\caption@checkoptions|\marg{keyval-list of options}\\
+% checks the syntax of the given options by executing them inside a group.
% \begin{macrocode}
\newcommand*\caption@checkoptions[1]{%
\begingroup
@@ -788,8 +805,9 @@
%
% \begin{macro}{\IfCaptionOptionCheck}
% \changes{v1.10}{2020/05/10}{This macro added}
-% |\IfCaptionOptionCheck|\marg{yes-code}\marg{no-code}
-% executes the \meta{yes-code} if options are just checked for syntax, and \meta{no-code} if not.
+% |\IfCaptionOptionCheck|\marg{yes-code}\marg{no-code}\\
+% executes the \meta{yes-code} if options are just checked for syntax,
+% and \meta{no-code} if not.
% \begin{macrocode}
\let\IfCaptionOptionCheck\@secondoftwo
% \end{macrocode}
@@ -804,12 +822,11 @@
% \changes{v1.1}{2007/08/17}{Starred variant added}
% \changes{v1.1e}{2007/07/27}{Inside packages the starred variant will be used automatically}
% \changes{v1.2}{2007/11/16}{Bugfix 07-11-09: `space hack' added}
-% |\clearcaptionsetup|\oarg{option}\marg{type}\\
-% |\clearcaptionsetup*|\oarg{option}\marg{type}\par
-% This removes the saved option list associated with \meta{type}.
-% If \meta{option} is given, only this option will be removed from the list.
-% (The starred variant does not issue warnings.)
-% \Note{The starred variant will be used inside packages automatically.}
+% |\clearcaptionsetup*|\oarg{option}\marg{type}\\
+% removes the saved option list associated with \meta{type}.
+% If \meta{option} is given, only this option will be removed from the list.
+% (The starred variant does not issue warnings.)
+% \Note{The starred variant will be used inside packages automatically.}
% \begin{macrocode}
\newcommand*\clearcaptionsetup{%
\caption@teststar@\@clearcaptionsetup\@gobble\@firstofone}
@@ -867,9 +884,9 @@
% \changes{v1.0d}{2005/05/03}{Optimized for memory usage}
% \changes{v1.1}{2007/07/29}{Bugfix: Does not expand option list anymore}
% \changes{v1.2}{2007/11/16}{Bugfix 07-11-09: `space hack' added}
-% |\showcaptionsetup|\oarg{package}\marg{type}\par
-% This comes for debugging issues: It shows the saved option list which
-% is associated with \meta{type}.
+% |\showcaptionsetup|\oarg{package}\marg{type}\\
+% shows the saved option list which is associated with \meta{type}
+% (as warning message).
% \begin{macrocode}
\newcommand*\showcaptionsetup[2][\@firstofone]{%
\@bsphack
@@ -901,14 +918,9 @@
% \changes{v1.2}{2007/12/03}{Definition of \cs{caption@iftypewarning} removed}
% \changes{v1.3}{2010/09/05}{Starred variant added}
% \changes{v1.4b}{2012/01/12}{Starred variant removed}
-% |\caption@setoptions|\marg{type or environment or\ldots}\par
-% Caption options which have been saved with |\captionsetup|\oarg{type} can
-% be executed by using this command.
-% It simply executes the saved option list (and clears it afterwards),
-% if there is any.
-% \iffalse
-% (The starred variant do not clear the option list.)
-% \fi
+% |\caption@setoptions|\marg{type or environment or\ldots}\\
+% applies caption options which have been saved with |\caption|\-|setup|\oarg{type}.
+% To prevent multiple application the list will be cleared (locally) afterwards.
% \begin{macrocode}
\newcommand*\caption@setoptions[1]{%
\caption@Debug{options=#1}%
@@ -928,19 +940,19 @@
% \begin{macro}{\caption@removefromoptlist}
% \changes{v1.1}{2007/07/22}{This macro added}
% \changes{v1.2c}{2008/08/24}{Fatal typo corrected}
-% |\caption@addtooptlist|\marg{type}\\
-% |\caption@removefromoptlist|\marg{type}\par
-% Adds or removes an \meta{type} to the list of unused caption options.
-% Note that the catcodes of \meta{type} are sanitized here so removing
-% \meta{type} from the list do not fail when the \package{float} package
-% is used (since |\float@getstyle| gives a result which tokens have catcode
-% 12 $=$ ``other'').
+% |\caption@addtooptlist|\marg{type}\\
+% |\caption@removefromoptlist|\marg{type}\\
+% adds or removes an \meta{type} to the list of unused caption options.
+% Note that the catcodes of \meta{type} are sanitized here so removing
+% \meta{type} from the list do not fail when the \package{float} package
+% is used (since |\float@getstyle| gives a result which tokens have catcode
+% 12 $=$ ``other'').
% \begin{macrocode}
\newcommand*\caption@addtooptlist[1]{%
- \@ifundefined{caption@opt@#1@lineno}{%
- \caption@dooptlist\caption@g@addto@list{#1}%
- \expandafter\xdef\csname caption@opt@#1@lineno\endcsname{\the\inputlineno}%
- }{}}
+ \@ifundefined{caption@opt@#1@lineno}%
+ {\caption@dooptlist\caption@g@addto@list{#1}%
+ \expandafter\xdef\csname caption@opt@#1@lineno\endcsname{\the\inputlineno}}%
+ {}}
% \end{macrocode}
% \begin{macrocode}
\newcommand*\caption@removefromoptlist[1]{%
@@ -956,10 +968,10 @@
% \end{macrocode}
% \begin{macrocode}
\AtEndDocument{%
- \caption@for@list\caption@optlist{%
- \caption@WarningNoLine{%
- Unused \string\captionsetup[#1]
- on input line \csname caption@opt@#1@lineno\endcsname}}}
+ \caption@for@list\caption@optlist
+ {\caption@WarningNoLine{%
+ Unused \string\captionsetup[#1]
+ on input line \csname caption@opt@#1@lineno\endcsname}}}
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -974,10 +986,10 @@
% \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}
-% |\caption@setkeys|\oarg{package}\marg{family}\marg{key-values}\par
-% This one simply calls |\setkeys|\marg{family}\marg{key-values}
-% but lets the error messages not refer to the \package{keyval} package,
-% but to the \meta{package} package instead.
+% |\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
+% but to the \meta{package} package instead.
% \begin{macrocode}
\newcommand*\caption@setkeys{\@dblarg\caption@@setkeys}
% \end{macrocode}
@@ -1001,7 +1013,7 @@
\def\XKV@err{\let\@tempa\XKV@tkey\KV@err}%
% \end{macrocode}
% \begin{macrocode}
- \caption@Debug{\protect\setkeys{#2}{#3}}%
+ \caption@Debug{\noexpand\setkeys{#2}{#3}}%
\setkeys{#2}{#3}%
% \end{macrocode}
% \begin{macrocode}
@@ -1024,9 +1036,9 @@
% \begin{macro}{\caption@ExecuteOptions}
% \changes{v1.1}{2007/07/15}{This macro added}
% \changes{v1.3}{2010/09/04}{Depends on package now}
-% |\caption@ExecuteOptions|\marg{package}\marg{key-values}\par
-% We execute our options using the keyval interface, so we use this one
-% instead of |\ExecuteOptions| offered by \LaTeXe.
+% |\caption@ExecuteOptions|\marg{package}\marg{key-value options}\\
+% applies the given options using the keyval interface, so we use this one
+% instead of |\Execute|\-|Options| offered by \LaTeXe.
% \begin{macrocode}
\newcommand*\caption@ExecuteOptions[2]{%
\expandafter\@expandtwoargs\csname caption@setkeys@#1\endcsname{#1}{#2}}%
@@ -1035,21 +1047,17 @@
% \end{macro}
%
% \begin{macro}{\caption@ProcessOptions}
-% \changes{v1.0a}{2004/01/23}{Bugfix, see
-% \purett{news:400D360C.9678329F@gmx.net} for details}
-% \changes{v1.0g}{2006/01/03}{Improvement, uses \cs{caption@setkeys}
-% instead of \cs{setkeys}}
-% \changes{v1.0h}{2006/02/23}{Bugfix, now processes only those global
-% options which have a default value}
-% \changes{v1.0j}{2007/01/30}{\cs{ProcessOptionsWithKV} renamed to
-% \cs{caption@ProcessOptions} and moved from the package to the kernel}
-% \changes{v1.1}{2007/04/17}{Star variant added}
-% |\caption@ProcessOptions*|\marg{package}\par
-% We process our options using the keyval package, so we use this one
-% instead of |\ProcessOptions| offered by \LaTeXe.
-% The starred variant do not process the global options.
-% (This code was taken from the \package{hyperref} package\cite{hyperref}
-% \version{6.74} and improved.)
+% \changes{v1.0a}{2004/01/23}{Bugfix, see \purett{news:400D360C.9678329F@gmx.net} for details}
+% \changes{v1.0g}{2006/01/03}{Improvement, uses \cs{caption@setkeys} instead of \cs{setkeys}}
+% \changes{v1.0h}{2006/02/23}{Bugfix, now processes only those global options which have a default value}
+% \changes{v1.0j}{2007/01/30}{\cs{ProcessOptionsWithKV} renamed to \cs{caption@ProcessOptions} and moved from the package to the kernel}
+% \changes{v1.1}{2007/04/17}{Starred variant added}
+% |\caption@ProcessOptions*|\marg{package}\\
+% processes the given options using the keyval package, so we use this one
+% instead of |\Process|\-|Options| offered by \LaTeXe.
+% The starred variant does not process the global options.
+% (This code was taken from the \package{hyperref} package\cite{hyperref}
+% \version{6.74} and modified.)
% \begin{macrocode}
\newcommand*\caption@ProcessOptions{%
\caption@teststar\caption@@ProcessOptions\@gobble\@firstofone}
@@ -1082,11 +1090,11 @@
%
% \begin{macro}{\caption@SetupOptions}
% \changes{v1.3}{2010/09/04}{This macro added}
-% |\caption@SetupOptions|\marg{package}\marg{code}\par
-% After calling this macro |\caption@ExecuteOptions| and
-% |\usepackage|\oarg{options}\marg{package}
-% will both be mapped to \meta{code} with \meta{package} and \meta{options}
-% as arguments |#1| and |#2|. (This helps avoiding ``Option clash'' errors.)
+% |\caption@SetupOptions|\marg{package}\marg{code}\\
+% After application of this command |\caption@Execute|\-|Options| and
+% |\use|\-|package| will both be mapped to \meta{code} with \meta{package}
+% and \meta{options} as arguments |#1| and |#2|.
+% (This helps avoiding ``Option clash'' errors.)
% \begin{macrocode}
\newcommand\caption@SetupOptions[2]{%
\@namedef{caption@setkeys@#1}##1##2{#2}%
@@ -1120,6 +1128,263 @@
% \end{macrocode}
% \end{macro}
%
+% \section{Declaring and setting key values}
+%
+% \begin{macro}{\caption@decl}
+% \changes{v2.0}{2019/09/10}{This macro added}
+% |\caption@decl|\oarg{command}\marg{option}\marg{name}\\
+% is used for declaring boxes, fonts, formats etc.
+% (It defines |\caption@|\meta{option}|@|\meta{name}
+% using the given \meta{command}.)
+% \begin{macrocode}
+\newcommand*\caption@decl[3][\def]{%
+ \global\long\expandafter#1\csname caption@#2@#3\endcsname}
+\@onlypreamble\caption@decl
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\caption@ifdecl}
+% \changes{v2.0}{2019/09/10}{This macro added}
+% |\caption@ifdecl|\marg{option}\marg{name}\marg{yes-code}\marg{no-code}\\
+% checks if the given \meta{option} and \meta{name} combination is
+% already declared.
+% \begin{macrocode}
+\newcommand*\caption@ifdecl[2]{%
+ \@ifundefined{caption@#1@#2}\@secondoftwo\@firstoftwo}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\caption@checkdecl}
+% \changes{v2.0}{2019/09/10}{This macro added}
+% |\caption@checkdecl|\marg{option}\marg{name}\marg{yes-code}\\
+% behaves similar to |\caption@if|\-|decl| but issues an error message if the
+% given \meta{option} plus \meta{name} is not defined.
+% \begin{macrocode}
+\newcommand*\caption@checkdecl[2]{%
+ \caption@ifdecl{#1}{#2}%
+ \@firstofone
+ {\caption@Error{Undefined #1 `#2'}%
+ \@gobble}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\caption@set}
+% \changes{v2.0}{2019/09/10}{This macro added}
+% \changes{v2.0}{2020/07/26}{Uses \cs{def} instead of \cs{let} internally}
+% |\caption@set|\marg{option}\marg{name}\\
+% sets the declared \meta{option} to \meta{name}, for example
+% |label|\-|format| to |simple|.
+% Note that since version \version{2.0} future changes to \meta{name}
+% (via |\caption@decl|) will effect the outcome,
+% for example |\caption@decl{labelformat}{simple}\ldots| will not only change
+% the definition of the label format |simple| but also effect the current
+% label format if set to |simple| (via |\caption@set|).
+% \begin{macrocode}
+\newcommand*\caption@set{%
+ \caption@maparg\caption@@set}%
+% \end{macrocode}
+% \begin{macrocode}
+\newcommand*\caption@@set[3]{%
+ \caption@checkdecl{#1}{#3}{%
+% \expandafter\edef\csname caption@@#2\endcsname{#3}% could be used for debugging
+ \expandafter\def\csname caption@#2\expandafter\endcsname\expandafter{\csname caption@#1@#3\endcsname}}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\SetCaptionDefault}
+% \changes{v2.0}{2019/09/10}{This macro added}
+% \changes{v2.0}{2020/07/28}{Check for `default' added to prevent infinite loop}
+% |\SetCaptionDefault*|\marg{option}\marg{name}\\
+% sets the default value for the \meta{option}.
+% The starred variant is only relevant for setting default values for lengths
+% like |margin|. (See definition of |\caption@set|\-|default@length| for
+% details.)
+% \begin{macrocode}
+\newcommand*\SetCaptionDefault{%
+ \caption@teststar\caption@setdefault\def\edef}
+\@onlypreamble\SetCaptionDefault
+% \end{macrocode}
+% \begin{macrocode}
+\newcommand*\caption@setdefault[2]{%
+ \@ifundefined{caption@setdefault@#2}%
+ {\caption@maparg\caption@@setdefault}%
+ {\@nameuse{caption@setdefault@#2}{#1}}%
+ {#2}}
+% \end{macrocode}
+% \begin{macrocode}
+\newcommand*\caption@@setdefault[3]{%
+ \caption@ifdefault{#3}%
+ {\caption@Error{Invalid argument for \string\SetCaptionDefault: `#3'}}% would cause an infinite loop otherwise
+ {\caption@@set{#1}{#2@default}{#3}}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\caption@ifdefault}
+% \changes{v2.0}{2020/08/23}{This macro added}
+% |\caption@ifdefault|\marg{value}\marg{yes-code}\marg{no-code}\\
+% expands to \meta{yes-code} if the \meta{value} expands to `default',
+% and to \meta{no-code} otherwise.
+% \begin{macrocode}
+\newcommand*\caption@ifdefault[1]{%
+ \edef\caption@tempa{#1}%
+ \def\caption@tempb{default}%
+ \ifx\caption@tempa\caption@tempb
+ \expandafter\@firstoftwo
+ \else
+ \expandafter\@secondoftwo
+ \fi}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\caption@setmapping}
+% \changes{v2.0}{2020/08/23}{This macro added}
+% |\caption@setmapping|\marg{source option}\marg{destination option}\\
+% sets a mapping from the \meta{source option} to the
+% \meta{destination option}, for example |label|\-|font| to |font|
+% since |label|\-|font| does not have any own definitions but shares
+% them with |font|.
+% \begin{macrocode}
+\newcommand*\caption@setmapping[2]{%
+ \@namedef{caption@map@#1}{#2}}
+\@onlypreamble\caption@setmapping
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\caption@maparg}
+% \changes{v2.0}{2020/08/23}{This macro added}
+% |\caption@maparg|\marg{command}\marg{option}\\
+% similar to |\@dblarg| but either duplicates the given \meta{option} or
+% expands it to \meta{destination option} plus \meta{option} if a mapping
+% was defined for the given option (via |\caption@set|\-|mapping|).
+% \begin{macrocode}
+\newcommand*\caption@maparg[2]{%
+ \@ifundefined{caption@map@#2}%
+ {#1{#2}}%
+ {#1{\csname caption@map@#2\endcsname}}%
+ {#2}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\caption@switchdefault}
+% \changes{v2.0}{2020/08/01}{This macro added}
+% |\caption@switchdefault\marg{option}|\marg{code with \#1}\marg{name}\\
+% like |\Set|\-|Caption|\-|Default| but first expands the given code with the
+% to-be-overwritten internal command as argument, so it can be stored (and
+% restored later on).
+% The main purpose of this command is switching default settings in
+% \package{babel} language packages, e.g.:
+% \begin{quote}|\caption@switchdefault{labelfont}{\babel@save #1}{sc}|\end{quote}
+% \begin{macrocode}
+\def\caption@switchdefault#1#2{%
+ \def\caption@tempa##1{#2}%
+ \expandafter\caption@tempa\csname caption@#1@default\endcsname
+ \caption@setdefault\def{#1}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\caption@restoredefault}
+% \changes{v2.0}{2020/08/01}{This macro added}
+% |\caption@restoredefault\marg{option}|\marg{command}\\
+% restores a default setting which was stored to \meta{command} before
+% (via |\caption@switch|\-|default|).
+% \begin{macrocode}
+\def\caption@restoredefault#1#2{%
+ \caption@checkdecl{#1}{default}{%
+ \caption@ifdefined#2{%
+ \expandafter\let\csname caption@#1@default\endcsname#2%
+ \let#2\@undefined}{}}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\caption@decl@package}
+% \changes{v2.0}{2020/07/26}{This macro added}
+% |\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
+% |one|\-|half|\-|spacing| which is dependent on the \package{setspace}
+% package.
+% \begin{macrocode}
+\newcommand*\caption@decl@package[2]{%
+ \@ifnextchar[%]
+ {\caption@declare@package{#1}{#2}}%
+ {\caption@declarepackage{#1}{#2}}}
+\@onlypreamble\caption@decl@package
+% \end{macrocode}
+% \begin{macrocode}
+\def\caption@declare@package#1#2[#3]#4{%
+ \global\@namedef{caption@#1@#4@package}{#3}%
+ #2{#4}}
+\@onlypreamble\caption@declare@package
+% \end{macrocode}
+% \begin{macrocode}
+\newcommand*\caption@declarepackage[3]{%
+ \global\@nameundef{caption@#1@#3@package}%
+ #2{#3}}
+\@onlypreamble\caption@declarepackage
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\caption@load@package}
+% \changes{v2.0}{2020/07/26}{This macro added}
+% |\caption@load@package|\marg{option}\marg{value}\\
+% If the given option value needs a package, it will be loaded automatically.
+% \begin{macrocode}
+\newcommand*\caption@load@package[2]{%
+ \expandafter\let\expandafter\caption@tempa\csname caption@#1@#2@package\endcsname
+ \caption@ifdefined\caption@tempa
+ {\caption@requirepackage\caption@tempa{#1=#2}}%
+ {}}
+% \end{macrocode}
+% \end{macro}
+%
+% \section{Declaring and setting lengths}
+%
+% \begin{macro}{\DeclareCaptionLength}
+% \changes{v2.0}{2020/08/09}{This macro added}
+% |\DeclareCaptionLength|\marg{name}\marg{default value}\\
+% \begin{enumerate}
+% \item Defines a new length (dimension)
+% \item Installes a hook for |\caption@set|\-|default| so
+% |\caption@set|\-|default@length| will be used to set a default
+% value for this length
+% \item Sets a default value using |\Set|\-|Caption|\-|Default*|.
+% \end{enumerate}
+% \begin{macrocode}
+\newcommand*\DeclareCaptionLength[1]{%
+ \expandafter\newdimen\csname caption#1\endcsname
+ \@namedef{caption@setdefault@#1}##1{%
+ \caption@setdefault@length{##1}}%
+ \SetCaptionDefault*{#1}}
+\@onlypreamble\DeclareCaptionLength
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\caption@setdefault@length}
+% \changes{v2.0}{2020/08/09}{This macro added}
+% |\caption@setdefault@length*|\marg{cmd}\marg{name}\marg{value}\\
+% sets a default value for the given \meta{length}, either using |\def|
+% (if the starred variant is used) or |\edef| (if the non-starred variant is
+% used).
+% \begin{macrocode}
+\newcommand*\caption@setdefault@length[3]{%
+ \expandafter#1\csname caption#2@default\endcsname{#3}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\caption@setlength}
+% \changes{v2.0}{2020/08/09}{This macro added}
+% |\caption@setlength|\marg{name}\marg{value}\\
+% sets a length to either the given \meta{value} or to the default value if
+% \meta{value} is `default'.
+% \begin{macrocode}
+\newcommand*\caption@setlength[2]{%
+ \caption@ifdefault{#2}%
+ {\expandafter\let\expandafter\caption@tempa\csname caption#1@default\endcsname}%
+ {\def\caption@tempa{#2}}%
+ \expandafter\setlength\csname caption#1\endcsname\caption@tempa}
+% \end{macrocode}
+% \end{macro}
+%
% \section{Margin resp. width}
% \changes{v1.0n}{2007/04/01}{\cs{captionmarginx} renamed to \cs{captionmargin@}}
% \changes{v1.0n}{2007/04/03}{Option `twoside' added}
@@ -1128,17 +1393,17 @@
%
% \begin{macro}{\captionmargin}
% \begin{macro}{\captionwidth}
-% |\captionmargin| and |\captionwidth| contain the extra margin
-% resp. the total width used for captions. Please never set these values in
-% a direct way, they are just accessible in user documents to provide
-% compatibility to \version{1.x}.\par
-% Note that we can only set one value at a time, `margin' \emph{or} `width'.
-% If |\captionwidth| is not zero we will take this value afterwards,
-% otherwise |\captionmargin| and |\captionmargin@|.
-% \begin{macrocode}
-\newdimen\captionmargin
-\newdimen\captionmargin@
-\newdimen\captionwidth
+% |\captionmargin| and |\captionwidth| contain the extra margin
+% resp. the total width used for captions. Please never set these values in
+% a direct way, they are just accessible in user documents to provide
+% compatibility to \version{1.x} of the \package{caption} package.\par
+% Note that we can only set one value at a time, `margin' \emph{or} `width'.
+% If |\caption|\-|width| is not zero we will take this value afterwards,
+% otherwise |\caption|\-|margin| and |\caption|\-|margin@|.
+% \begin{macrocode}
+\DeclareCaptionLength{margin}{0pt}
+\DeclareCaptionLength{margin@}{\the\captionmargin}
+\DeclareCaptionLength{width}{0pt}
\newdimen\caption@tempdima
% \end{macrocode}
% \end{macro}
@@ -1159,6 +1424,7 @@
% \begin{macrocode}
\DeclareCaptionOption{twoside}[1]{\caption@set@bool\caption@iftwoside{#1}}
\DeclareCaptionOptionNoValue{oneside}{\caption@set@bool\caption@iftwoside0}
+\caption@set@bool\caption@iftwoside{\if@twoside 1\else 0\fi}
% \end{macrocode}
% \begin{macrocode}
\DeclareCaptionOption{minmargin}{\caption@setoptcmd\caption@minmargin{#1}}
@@ -1167,17 +1433,14 @@
%
% \begin{macro}{\setcaptionmargin}
% \changes{v1.0f}{2005/10/24}{Renamed from \cs{caption@setmargin} to \cs{setcaptionmargin}}
-% \changes{v1.0f}{2005/10/24}{\cs{setcaptionmargin} enhanced so it can take
-% left+right margin}
+% \changes{v1.0f}{2005/10/24}{\cs{setcaptionmargin} enhanced so it can take left+right margin}
% \changes{v1.1}{2007/08/11}{Starred variant added}
-% \changes{v1.1}{2007/08/12}{\cs{setlength}\cs{captionmargin} \&
-% \cs{setlength}\cs{captionmargin@} swapped so
-% `\texttt{margin*=}\cs{captionmargin}' works in singleline options}
+% \changes{v1.1}{2007/08/12}{\cs{setlength}\cs{captionmargin} \& \cs{setlength}\cs{captionmargin@} swapped so `\texttt{margin*=}\cs{captionmargin}' works in singleline options}
% \changes{v1.3}{2010/11/07}{Support for option \opt{calcmargin} added}
-% |\setcaptionmargin|\marg{amount}\\
-% |\setcaptionmargin*|\marg{amount}\par
-% Please never use this in user documents, it's just there to
-% provide compatibility to the \package{caption2} package.
+% |\setcaptionmargin*|\marg{amount}\\
+% sets the caption margin to the given \meta{amount}.
+% Please never use this in user documents, it's just there to
+% provide compatibility to the \package{caption2} package.
% \begin{macrocode}
\newcommand*\setcaptionmargin{%
\caption@resetcalcmargin
@@ -1194,8 +1457,8 @@
% \end{macrocode}
% \begin{macrocode}
\def\caption@@@setmargin#1,#2,#3\@nil{%
- \setlength\captionmargin@{#2}%
- \setlength\captionmargin{#1}%
+ \caption@setlength{margin}{#1}%
+ \caption@setlength{margin@}{#2}%
\addtolength\captionmargin@{-\captionmargin}}
% \end{macrocode}
% \end{macro}
@@ -1204,10 +1467,10 @@
% \changes{v1.0f}{2005/10/24}{Renamed from \cs{caption@setwidth} to \cs{setcaptionwidth}}
% \changes{v1.3}{2010/11/07}{Starred variant added}
% \changes{v1.3}{2010/11/07}{Support for option \opt{calcwidth} added}
-% |\setcaptionwidth|\marg{amount}\\
-% |\setcaptionwidth*|\marg{amount}\par
-% Please never use this in user documents, it's just there to
-% provide compatibility to the \package{caption2} package.
+% |\setcaptionwidth*|\marg{amount}\\
+% sets the caption width to the given \meta{amount}.
+% Please never use this in user documents, it's just there to
+% provide compatibility to the \package{caption2} package.
% \begin{macrocode}
\newcommand*\setcaptionwidth{%
\caption@resetcalcmargin
@@ -1220,20 +1483,16 @@
% \begin{macrocode}
\newcommand*\caption@@setwidth[2]{%
#1{\captionmargin\z@\captionmargin@\z@}%
- \setlength\captionwidth{#2}}%
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\caption@resetcalcmargin}
-% \changes{v1.3}{2010/11/07}{This macro added}
-% \begin{macrocode}
-\newcommand*\caption@resetcalcmargin{%
- \let\caption@calcmargin@hook\@empty}
+ \caption@setlength{width}{#2}}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\caption@setcalcmargin}
% \changes{v1.3}{2010/11/07}{This macro added}
+% |\caption@setcalcmargin*|\marg{amount}\\
+% sets the caption margin to the given \meta{amount}
+% right before the caption will be typeset, i.e.\meta{amount} will
+% not be evaluated immediately.
% \begin{macrocode}
\newcommand*\caption@setcalcmargin{%
\caption@teststar{\caption@@setcalcmargin\caption@setmargin}%
@@ -1247,8 +1506,22 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\caption@resetcalcmargin}
+% \changes{v1.3}{2010/11/07}{This macro added}
+% |\caption@resetcalcmargin|\\
+% clears the value which was stored in |\caption@set|\-|calc|\-|margin|.
+% \begin{macrocode}
+\newcommand*\caption@resetcalcmargin{%
+ \let\caption@calcmargin@hook\@empty}
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macro}{\caption@setcalcwidth}
% \changes{v1.3}{2010/11/07}{This macro added}
+% |\caption@setcalcwidth*|\marg{amount}\\
+% sets the caption width to the given \meta{amount}
+% right before the caption will be typeset, i.e.\meta{amount} will
+% not be evaluated immediately.
% \begin{macrocode}
\newcommand*\caption@setcalcwidth{%
\caption@teststar{\caption@@setcalcmargin\caption@setwidth}%
@@ -1260,8 +1533,8 @@
% \changes{v1.0n}{2007/04/03}{This counter added}
% \changes{v1.1e}{2007/10/28}{Renamed to \cs{caption@thecounter}; \cs{caption@stepcounter} added}
% \changes{v1.5}{2012/04/09}{\cs{caption@stepcounter} renamed to \cs{caption@stepthecounter}}
-% Internal counter. At the moment it will be used inside
-% |\caption@ifoddpage| only.
+% Internal counter.
+% At the moment it will be used inside |\caption@if|\-|odd|\-|page| only.
% \begin{macrocode}
\newcommand*\caption@thecounter{0}
% \end{macrocode}
@@ -1275,10 +1548,11 @@
%
% \begin{macro}{\caption@newlabel}
% \changes{v1.0n}{2007/04/03}{This macro added}
-% This command is a modified version of |\newlabel| from \LaTeX2e.
-% It will be written to the \texttt{.aux} file to
-% pass label information from one run to another.
-% (We use it inside |\caption@ifoddpage| and |\caption@ragged|.)
+% |\caption@newlabel|\marg{name}\marg{value}\\
+% This command is a modified version of |\new|\-|label| from \LaTeX2e.
+% It will be written to the \texttt{.aux} file to
+% pass label information from one run to another.
+% (We use it inside |\caption@if|\-|odd|\-|page|.)
% \begin{macrocode}
\newcommand*\caption@newlabel{\@newl@bel{caption@r}}
% \end{macrocode}
@@ -1286,8 +1560,8 @@
%
% \begin{macro}{\caption@thepage}
% \changes{v1.0n}{2007/04/03}{This macro added}
-% This command is a modified version of |\thepage| from \LaTeX2e.
-% It will be used inside |\caption@ifoddpage| only.
+% This command is a modified version of |\the|\-|page| from \LaTeX2e.
+% It will be used inside |\caption@if|\-|odd|\-|page| only.
% \begin{macrocode}
\newcommand*\caption@thepage{\the\c@page}
% \end{macrocode}
@@ -1295,9 +1569,10 @@
%
% \begin{macro}{\caption@label}
% \changes{v1.1}{2007/09/01}{This macro added}
-% \changes{v1.2}{2007/12/03}{Definition of \cs{caption@newlabel} in AUX file added}
-% This command is a modified version of |\label| from \LaTeX2e.
-% It will be used inside |\caption@ifoddpage| and |\FP@helpNote|.
+% \changes{v1.2}{2007/12/03}{Definition of \cs{caption@newlabel} in aux file added}
+% |\caption@label|\marg{name}\\
+% This command is a modified version of |\label| from \LaTeX2e.
+% It will be used inside |\caption@if|\-|odd|\-|page| and |\FP@help|\-|Note|.
% \begin{macrocode}
\newcommand*\caption@label[1]{%
\caption@@label
@@ -1315,8 +1590,9 @@
% \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}
-% This command is a modified version of |\pageref| from \LaTeX2e.
-% It will be used inside |\caption@ifoddpage| and |\FP@helpNote|.
+% |\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|.
% \begin{macrocode}
\newcommand*\caption@pageref[1]{%
\expandafter\ifx\csname caption@r@#1\endcsname\relax
@@ -1331,11 +1607,13 @@
% \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}}
-% At the moment this macro uses an own label\ldots ref mechanism,
-% but an alternative implementation method would be using the
-% \package{refcount} package\cite{refcount} and |\ifodd\getpagerefnumber{|\ldots|}|.
-% \Note{This macro re-defines itself so the \texttt{.aux} file will
-% only be used once per group.}
+% 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.}
% \begin{macrocode}
\newcommand*\caption@ifoddpage{%
\caption@iftwoside{%
@@ -1355,7 +1633,9 @@
%
% \begin{macro}{\caption@setoptcmd}
% \changes{v1.1}{2007/08/11}{This macro added}
-% |\caption@setoptcmd|\marg{cmd}\marg{off -or- value}
+% |\caption@setoptcmd|\marg{command}\marg{off -or- value}\\
+% defines the given \meta{command} to \meta{value},
+% but if \meta{value} if `off' the given \meta{command} is undefined instead.
% \begin{macrocode}
\newcommand*\caption@setoptcmd[2]{%
\caption@ifinlist{#2}{0,false,no,off}{\let#1\@undefined}{\def#1{#2}}}
@@ -1368,41 +1648,39 @@
% \changes{v1.1}{2007/07/29}{Renamed from \cs{captionindent} to \cs{caption@indent}}
% \begin{macro}{\caption@parindent}
% \begin{macro}{\caption@hangindent}
-% These are the indentions we support.
+% These are the indentions we support.
% \begin{macrocode}
-\newdimen\caption@indent
-\newdimen\caption@parindent
-\newdimen\caption@hangindent
+\DeclareCaptionLength{@indent}{0pt}
+\DeclareCaptionLength{@parindent}{0pt}
+\DeclareCaptionLength{@hangindent}{0pt}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
-% \changes{v1.0b}{2004/05/16}{Defaults added for options \opt{parindent=}
-% and \opt{hangindent=}}
-% \changes{v1.0f}{2005/08/22}{Option \opt{parskip=}: \cs{AtBeginCaption}
-% replaced by \cs{caption@@par}}
-% \changes{v1.0f}{2005/08/22}{Undocumented defaults for \opt{parindent=},
-% \opt{hangindent=}, and \opt{parskip=} removed}
+% \changes{v1.0b}{2004/05/16}{Defaults added for options \opt{parindent=} and \opt{hangindent=}}
+% \changes{v1.0f}{2005/08/22}{Option \opt{parskip=}: \cs{AtBeginCaption} replaced by \cs{caption@@par}}
+% \changes{v1.0f}{2005/08/22}{Undocumented defaults for \opt{parindent=}, \opt{hangindent=}, and \opt{parskip=} removed}
% \begin{macrocode}
-\DeclareCaptionOption{indent}[\leftmargini]{% obsolete!
- \setlength\caption@indent{#1}}
+\DeclareCaptionOption{indent}[\leftmargini]{% obsolete
+ \caption@setlength{@indent}{#1}}
\DeclareCaptionOption{indention}[\leftmargini]{%
- \setlength\caption@indent{#1}}
+ \caption@setlength{@indent}{#1}}
\DeclareCaptionOption{parindent}{%
- \setlength\caption@parindent{#1}}
+ \caption@setlength{@parindent}{#1}}
\DeclareCaptionOption{hangindent}{%
- \setlength\caption@hangindent{#1}}
+ \caption@setlength{@hangindent}{#1}}
\DeclareCaptionOption{parskip}{%
- \l@addto@macro\caption@@par{\setlength\parskip{#1}}}
+ \l@addto@macro\caption@@par{\setlength\parskip{#1}}}
% \end{macrocode}
%
% \section{Styles}
%
% \begin{macro}{\DeclareCaptionStyle}
-% \changes{v1.0a}{2004/01/17}{Pass through argument \#3 so extra spaces
-% between arguments do make any harm}
-% |\DeclareCaptionStyle|\marg{name}\oarg{single-line-list-of-KV}\marg{list-of-KV}
+% \changes{v1.0a}{2004/01/17}{Pass through argument \#3 so extra spaces between arguments do make any harm}
+% \changes{v2.0}{2019/09/10}{Uses \cs{caption@decl} now}
+% \changes{v2.0}{2020/07/27}{\cs{caption@sls} renamed to \cs{caption@slsty}}
+% |\DeclareCaptionStyle|\marg{name}\oarg{single-line-list-of-KV}\marg{list-of-KV}
% \begin{macrocode}
\newcommand*\DeclareCaptionStyle[1]{%
\@testopt{\caption@declarestyle{#1}}{}}
@@ -1410,8 +1688,16 @@
% \end{macrocode}
% \begin{macrocode}
\def\caption@declarestyle#1[#2]#3{%
- \global\@namedef{caption@sls@#1}{#2}%
- \global\@namedef{caption@sty@#1}{#3}}
+ \caption@decl{style}{#1}%
+ {\def\caption@slsty{#2}%
+ \def\caption@sty{#3}}%
+% \end{macrocode}
+% The \package{floatrow} package uses |\@if|\-|undefined{caption@sty@#1}| to
+% determine in |\flrow@set|\-|style| if a caption style is defined or not.
+% Since the \package{floatrow} package is unmaintained we fake the definition
+% so the test will still work.
+% \begin{macrocode}
+ \@namedef{caption@sty@#1}{\@unused}}
\@onlypreamble\caption@declarestyle
% \end{macrocode}
% \end{macro}
@@ -1427,58 +1713,55 @@
% \changes{v1.1}{2007/07/29}{Recursive style definitions should work now}
% \changes{v1.1d}{2007/10/23}{`SingleLine' renamed to `singleline' for consistency}
% \changes{v1.2}{2007/12/03}{Definition of \cs{caption@iftypewarning} removed}
-% |\caption@setstyle|\marg{name}\\
-% |\caption@setstyle*|\marg{name}\par
-% Selecting a caption style means saving the additional
-% \meta{single-line-list-of-KV} (this will be done by |\caption@sls|),
-% resetting the caption options to the base ones (this will be done using
-% |\caption@resetstyle|) and executing the \meta{list-of-KV} options
-% (this will be done using |\caption@setup|).\par
-% The starred version will give no error message if the given style is not
-% defined.
+% \changes{v2.0}{2019/09/10}{Uses \cs{caption@ifdecl} and \cs{caption@checkdecl} now}
+% |\caption@setstyle*|\marg{name}\\
+% Selecting a caption style means saving the additional
+% \meta{single-line-list-of-KV} (this will be done by |\caption@sl|\-|sty|),
+% resetting the caption options to the base ones (this will be done using
+% |\caption@reset|\-|style|) and executing the \meta{list-of-KV} options
+% (this will be done using |\caption@setup|).\par
+% The starred version will give no error message if the given style is not
+% defined.
% \begin{macrocode}
\newcommand*\caption@setstyle{%
- \caption@teststar\caption@@setstyle\@gobble\@firstofone}
+ \caption@teststar\caption@@setstyle\caption@ifdecl\caption@checkdecl}
% \end{macrocode}
% \begin{macrocode}
\newcommand*\caption@@setstyle[2]{%
- \@ifundefined{caption@sty@#2}%
- {#1{\caption@Error{Undefined style `#2'}}}%
- {\expandafter\let\expandafter\caption@sty\csname caption@sty@#2\endcsname
+ #1{style}{#2}%
+ {\caption@set{style}{#2}%
+ \caption@style % defines \caption@sty & \caption@slsty
\ifx\caption@setstyle@flag\@undefined
- \let\caption@setstyle@flag\relax
+ \let\caption@setstyle@flag\relax % prevent \caption@resetstyle if called recursively
\caption@resetstyle
\caption@xsetup\caption@sty
\let\caption@setstyle@flag\@undefined
\else
\caption@xsetup\caption@sty
- \fi
- \expandafter\let\expandafter\caption@sls\csname caption@sls@#2\endcsname
- \expandafter\caption@l@addto@list\expandafter\caption@opt@singleline
- \expandafter{\caption@sls}}}
+ \fi}%
+ {}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\caption@resetstyle}
-% \changes{v1.1}{2007/02/04}{%
-% This macro renamed from \cs{caption@setdefault} to \cs{caption@resetstyle}}
+% \changes{v1.1}{2007/02/04}{This macro renamed from \cs{caption@setdefault} to \cs{caption@resetstyle}}
% \changes{v1.1d}{2007/10/23}{`SingleLine' renamed to `singleline' for consistency}
% \changes{v1.2}{2007/11/17}{Usage of \opt{size=} added}
% \changes{v1.2b}{2008/05/06}{Usage of \opt{rule} added}
% \changes{v1.5}{2012/03/15}{\opt{box=parbox} added}
% \changes{v1.6}{2013/05/01}{\opt{box=none} added, \opt{box=parbox} changed to \opt{parbox=parbox}}
-% This resets (nearly) all caption options to the base ones.
-% \emph{Note that this does not touch the skips and the positioning!}
+% |\caption@resetstyle|\\
+% This resets (nearly) all caption options to the base ones.
+% \emph{Note that this does not touch the skips and the positioning.}
% \begin{macrocode}
\newcommand*\caption@resetstyle{%
\caption@setup{%
box=none,boxcolor=white,parbox=parbox,%
format=plain,labelformat=default,labelsep=colon,textformat=simple,%
- justification=justified,font=,size=,labelfont=,textfont=,%
+ font=,labelfont=,textfont=,size=,%
+ justification=justified,slc,rule,strut,%
margin=0pt,minmargin=0,maxmargin=0,%
- indent=0pt,parindent=0pt,hangindent=0pt,%
- slc,rule,strut}%
- \caption@clearsetup{singleline}}
+ indent=0pt,parindent=0pt,hangindent=0pt}}
% \end{macrocode}
% \end{macro}
%
@@ -1488,31 +1771,69 @@
% \changes{v1.1c}{2007/10/14}{\opt{format=plain} removed from caption style \opt{default}}
% \changes{v1.5}{2012/03/15}{\opt{box=default} added to caption style \opt{default}}
% Currently there are two pre-defined styles, called `base' \& `default'.
-% The first one is a perfect match to the behavior of |\@makecaption| offered
-% by the standard \LaTeX\ document classes (and was called `default' in
-% \thispackage\ \version{1.0}), the second one matches the document
+% The first one is a perfect match to the behavior of |\@make|\-|caption|
+% offered by the standard \LaTeX\ document classes (and was called `default'
+% in \thispackage\ \version{1.0}), the second one matches the document
% class actually used.
% \begin{macrocode}
\DeclareCaptionStyle{base}[indent=0pt,justification=centering]{}
\DeclareCaptionStyle{default}[indent=0pt,justification=centering]{%
- box=default,format=default,labelsep=default,textformat=default,%
- justification=default,font=default,labelfont=default,textfont=default}
+ box=default,%
+ format=default,labelformat=default,labelsep=default,textformat=default,%
+ font=default,labelfont=default,textfont=default,size=default,%
+ justification=default,slc=default,margin=default,%
+ indent=default,parindent=default,hangindent=default}
% \end{macrocode}
%
+% \begin{macro}{\DeclareCaptionSinglelinecheck}
+% \changes{v2.0}{2019/09/10}{This macro added}
+% |\DeclareCaptionSinglelinecheck|\marg{name}\marg{code}
+% \begin{macrocode}
+\newcommand*\DeclareCaptionSinglelinecheck[2]{%
+ \caption@decl{singlelinecheck}{#1}{#2}}
+\@onlypreamble\DeclareCaptionSinglelinecheck
+% \end{macrocode}
+% \end{macro}
+%
% \changes{v1.2b}{2008/05/06}{Option \opt{slc=} added}
% \begin{macrocode}
-\DeclareCaptionOption{singlelinecheck}[1]{\caption@set@bool\caption@ifslc{#1}}
+\DeclareCaptionOption{singlelinecheck}[1]{\caption@setsinglelinecheck{#1}}
\DeclareCaptionOption{slc}[1]{\KV@caption@singlelinecheck{#1}}
% \end{macrocode}
%
+% These are the pre-defined single-line-check code snippets.
+% \begin{macrocode}
+\DeclareCaptionSinglelinecheck{on}{\@firstoftwo}
+\DeclareCaptionSinglelinecheck{off}{\@secondoftwo}
+% \end{macrocode}
+%
+% `default' usually maps to `on'.
+% \begin{macrocode}
+\SetCaptionDefault{singlelinecheck}{on}
+% \end{macrocode}
+%
+% \begin{macro}{\caption@setsinglelinecheck}
+% \changes{v2.0}{2018/03/13}{This macro added}
+% |\caption@setsinglelinecheck|\marg{value}\\
+% sets the single-line-check either on or off,
+% where \meta{value} could be either a \meta{name} or boolean value.
+% \begin{macrocode}
+\newcommand*\caption@setsinglelinecheck[1]{%
+ \caption@ifdecl{singlelinecheck}{#1}%
+ {\caption@set{singlelinecheck}{#1}}%
+ {\caption@set@bool\caption@singlelinecheck{#1}}}
+% \end{macrocode}
+% \end{macro}
+%
% \section{Boxes}
%
% \begin{macro}{\DeclareCaptionBox}
% \changes{v1.5}{2012/03/15}{This macro added}
-% |\DeclareCaptionBox|\marg{name}\marg{code with \#1 and \#2}
+% \changes{v2.0}{2019/09/10}{Uses \cs{caption@decl} now}
+% |\DeclareCaptionBox|\marg{name}\marg{code with \#1 and \#2}
% \begin{macrocode}
\newcommand*\DeclareCaptionBox[2]{%
- \global\long\@namedef{caption@box@#1}##1##2{#2}}
+ \caption@decl{box}{#1}##1##2{#2}}
\@onlypreamble\DeclareCaptionBox
% \end{macrocode}
% \end{macro}
@@ -1520,31 +1841,15 @@
% \changes{v1.5}{2012/03/15}{Option \opt{box=} added}
% \changes{v1.6}{2013/05/01}{Option \opt{parbox=} added}
% \begin{macrocode}
-\DeclareCaptionOption{box}{\caption@setbox{#1}}
-\DeclareCaptionOption{parbox}{\caption@set@box\caption@parbox{#1}}
+\DeclareCaptionOption{box}{\caption@set{box}{#1}}
+\DeclareCaptionOption{parbox}{\caption@set{parbox}{#1}}
+\caption@setmapping{parbox}{box}
% \end{macrocode}
%
-% \begin{macro}{\caption@setbox}
-% |\caption@setbox|\marg{name}\par
-% Selecting a caption box simply means saving the code (in |\caption@box|).
-% \begin{macrocode}
-\newcommand*\caption@setbox{%
- \caption@set@box\caption@box}
-% \end{macrocode}
-% \begin{macrocode}
-\newcommand*\caption@set@box[2]{%
- \@ifundefined{caption@box@#2}%
- {\caption@Error{Undefined box `#2'}}%
- {\expandafter\let\expandafter#1\csname caption@box@#2\endcsname}}
-% \end{macrocode}
-% \end{macro}
-%
% There are four pre-defined boxes, called `empty', `none',
% `parbox', and `colorbox'.
-% \changes{v1.0i}{2006/05/13}{We define \cs{captionbox} instead of
-% \cs{caption@start/endbox}}
-% \changes{v1.0l}{2006/03/09}{Bugfix 07-03-09: \cs{captionbox} changed from
-% \cs{parbox-t} to \cs{parbox-b}}
+% \changes{v1.0i}{2006/05/13}{We define \cs{captionbox} instead of \cs{caption@start/endbox}}
+% \changes{v1.0l}{2006/03/09}{Bugfix 07-03-09: \cs{captionbox} changed from \cs{parbox-t} to \cs{parbox-b}}
% \changes{v1.2}{2007/11/11}{\cs{captionbox} renamed to \cs{caption@parbox}}
% \changes{v1.5}{2012/03/15}{\cs{caption@parbox} adapted to \cs{DeclareCaptionBox}}
% \changes{v1.6}{2013/05/02}{Option \opt{boxsep=} added}
@@ -1552,34 +1857,34 @@
\DeclareCaptionBox{empty}{}
\DeclareCaptionBox{none}{#2}
\DeclareCaptionBox{parbox}{\parbox[b]{#1}{#2}}
-%\DeclareCaptionBox{colorbox}{%
-% \colorbox{\caption@boxcolor}{\caption@box@parbox{\dimexpr #1-2\fboxsep}{#2}}}
-\DeclareCaptionBox{colorbox}{\colorbox{\caption@boxcolor}{%
- \setlength\caption@tempdima{#1}%
- \addtolength\caption@tempdima{-2\fboxsep}%
- \linewidth\caption@tempdima
- \hsize\caption@tempdima
- #2}}
+\DeclareCaptionBox{colorbox}{%
+ \colorbox\caption@boxcolor{%
+ \setlength\caption@tempdima{#1}%
+ \addtolength\caption@tempdima{-2\fboxsep}%
+ \linewidth\caption@tempdima
+ \hsize\caption@tempdima
+ #2}}
\DeclareCaptionOption{boxcolor}{\def\caption@boxcolor{#1}}
\DeclareCaptionOption{boxsep}{\setlength\fboxsep{#1}}
% \end{macrocode}
%
-% `default' usually maps to `none`.
+% `default' usually maps to `none' resp.~`parbox'.
% \begin{macrocode}
-\def\caption@box@default{\caption@box@none}
+\SetCaptionDefault{box}{none}
+%\SetCaptionDefault{parbox}{parbox}
% \end{macrocode}
%
% \section{Formats}
%
% \begin{macro}{\DeclareCaptionFormat}
-% \changes{v1.0a}{2004/01/17}{Pass through argument \#3 so extra spaces
-% between arguments do make any harm}
+% \changes{v1.0a}{2004/01/17}{Pass through argument \#3 so extra spaces between arguments do make any harm}
% \changes{v1.0c}{2005/02/09}{Starred variant added}
% \changes{v1.1c}{2007/10/15}{Optional argument added}
-% |\DeclareCaptionFormat|\marg{name}\marg{code with \#1, \#2, and \#3}\\
-% |\DeclareCaptionFormat*|\marg{name}\marg{code with \#1, \#2, and \#3}\par
-% The starred form causes the code being typeset in vertical (instead of
-% horizontal) mode, but does not support the |indention=| option.
+% \changes{v2.0}{2019/09/10}{Uses \cs{caption@decl} now}
+% \changes{v2.0}{2020/07/27}{\cs{caption@ifh} renamed to \cs{caption@ifhmode}}
+% |\DeclareCaptionFormat*|\marg{name}\marg{code with \#1, \#2, and \#3}\\
+% The starred form causes the code being typeset in vertical (instead of
+% horizontal) mode, but does not support the |indention=| option.
% \begin{macrocode}
\newcommand*\DeclareCaptionFormat{%
\caption@teststar\caption@declareformat\@gobble\@firstofone}
@@ -1592,62 +1897,44 @@
% \end{macrocode}
% \begin{macrocode}
\long\def\caption@@declareformat#1#2[#3]#4{%
- \global\expandafter\let\csname caption@ifh@#2\endcsname#1%
- \global\long\@namedef{caption@slfmt@#2}##1##2##3{#3}%
- \global\long\@namedef{caption@fmt@#2}##1##2##3{#4}}
+ \caption@decl[\edef]{format}{#2}{%
+ \unexpanded{\let\caption@ifhmode#1}%
+ \unexpanded{\long\def\caption@slfmt}####1####2####3\unexpanded{{#3}}%
+ \unexpanded{\long\def\caption@fmt}####1####2####3\unexpanded{{#4}}}}
\@onlypreamble\caption@@declareformat
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\caption@useformat}
+% \changes{v2.0}{2020/07/31}{This macro added}
+% |\caption@useformat|\marg{name}\\
+% expands |\caption@fmt| based on the given format \meta{name}.
% \begin{macrocode}
-\DeclareCaptionOption{format}{\caption@setformat{#1}}
-% \end{macrocode}
-%
-% \begin{macro}{\caption@setformat}
-% |\caption@setformat|\marg{name}\par
-% Selecting a caption format simply means saving the code (in |\caption@fmt|)
-% and if the code should be used in horizontal or vertical mode (|\caption@ifh|).
-% \begin{macrocode}
-\newcommand*\caption@setformat[1]{%
- \@ifundefined{caption@fmt@#1}%
- {\caption@Error{Undefined format `#1'}}%
- {\expandafter\let\expandafter\caption@ifh\csname caption@ifh@#1\endcsname
- \expandafter\let\expandafter\caption@slfmt\csname caption@slfmt@#1\endcsname
- \expandafter\let\expandafter\caption@fmt\csname caption@fmt@#1\endcsname}}
+\newcommand*\caption@useformat[1]{% used by caption-koma.sto
+ \caption@checkdecl{format}{#1}{%
+ \begingroup
+ \@nameuse{caption@format@#1}\global\let\caption@tempa\caption@fmt
+ \endgroup\caption@tempa}}
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\DeclareCaptionDefaultFormat}
-% \changes{v1.2a}{2008/01/31}{This macro added}
% \begin{macrocode}
-\newcommand*\DeclareCaptionDefaultFormat[1]{%
- \expandafter\def\expandafter\caption@fmt@default\expandafter
- {\csname caption@fmt@#1\endcsname}%
- \expandafter\def\expandafter\caption@slfmt@default\expandafter
- {\csname caption@slfmt@#1\endcsname}%
- \expandafter\def\expandafter\caption@ifh@default\expandafter
- {\csname caption@ifh@#1\endcsname}}
-\@onlypreamble\DeclareCaptionDefaultFormat
+\DeclareCaptionOption{format}{\caption@set{format}{#1}}
% \end{macrocode}
-% \end{macro}
%
-% \changes{v1.0a}{2004/01/23}{%
-% Caption format \opt{default} renamed to \opt{normal}}
-% \changes{v1.0e}{2005/05/12}{%
-% Caption format \opt{normal} renamed to \opt{@normal}}
-% \changes{v1.0f}{2005/08/25}{%
-% Caption format \opt{@normal} renamed to \opt{plain} and documented}
-% \changes{v1.1c}{2007/10/14}{%
-% Single-line variant of caption format \opt{hang} added}
+% \changes{v1.0a}{2004/01/23}{Caption format \opt{default} renamed to \opt{normal}}
+% \changes{v1.0e}{2005/05/12}{Caption format \opt{normal} renamed to \opt{@normal}}
+% \changes{v1.0f}{2005/08/25}{Caption format \opt{@normal} renamed to \opt{plain} and documented}
+% \changes{v1.1c}{2007/10/14}{Single-line variant of caption format \opt{hang} added}
% There are two pre-defined formats, called `plain' and `hang'.
% \begin{macrocode}
\DeclareCaptionFormat{plain}{#1#2#3\par}
% \end{macrocode}
% \begin{macrocode}
\DeclareCaptionFormat{hang}[#1#2#3\par]{%
- \caption@ifin@list\caption@lsepcrlist\caption@lsepname
+ \caption@iflabelseparatorwithnewline
{\caption@Error{%
- The option `labelsep=\caption@lsepname' does not work\MessageBreak
+ The option `labelsep=\caption@labelsep@name' does not work\MessageBreak
with `format=hang'}}%
{\@hangfrom{#1#2}%
\advance\caption@parindent\hangindent
@@ -1655,47 +1942,35 @@
\caption@@par#3\par}}
% \end{macrocode}
%
-% \changes{v1.0a}{2004/01/23}{Caption format \opt{default} linked to \opt{plain}}
-% \changes{v1.0d}{2005/04/28}{Bugfix 05-04-28: Missing \cs{caption@ifh@default} added}
% `default' usually maps to `plain'.
% \begin{macrocode}
-\DeclareCaptionDefaultFormat{plain}
+\SetCaptionDefault{format}{plain}
% \end{macrocode}
%
% \section{Label formats}
%
% \begin{macro}{\DeclareCaptionLabelFormat}
-% \changes{v1.0a}{2004/01/17}{%
-% Pass through argument \#2 so extra spaces between arguments do make any harm}
-% |\DeclareCaptionLabelFormat|\marg{name}\marg{code with \#1 and \#2}
+% \changes{v1.0a}{2004/01/17}{Pass through argument \#2 so extra spaces between arguments do make any harm}
+% \changes{v2.0}{2019/09/10}{Uses \cs{caption@decl} now}
+% |\DeclareCaptionLabelFormat|\marg{name}\marg{code with \#1 and \#2}
% \begin{macrocode}
\newcommand*\DeclareCaptionLabelFormat[2]{%
- \global\@namedef{caption@lfmt@#1}##1##2{#2}}
+ \caption@decl{labelformat}{#1}##1##2{#2}}
\@onlypreamble\DeclareCaptionLabelFormat
% \end{macrocode}
% \end{macro}
%
% \begin{macrocode}
-\DeclareCaptionOption{labelformat}{\caption@setlabelformat{#1}}
+\DeclareCaptionOption{labelformat}{\caption@set{labelformat}{#1}}
% \end{macrocode}
%
-% \begin{macro}{\caption@setlabelformat}
-% |\caption@setlabelformat|\marg{name}\par
-% Selecting a caption label format simply means saving the code (in |\caption@lfmt|).
-% \begin{macrocode}
-\newcommand*\caption@setlabelformat[1]{%
- \@ifundefined{caption@lfmt@#1}%
- {\caption@Error{Undefined label format `#1'}}%
- {\expandafter\let\expandafter\caption@lfmt\csname caption@lfmt@#1\endcsname}}
-% \end{macrocode}
-% \end{macro}
-%
% \changes{v1.2}{2007/12/16}{Caption label format \opt{brace} added}
% \changes{v1.7}{2015/09/16}{Caption label format \opt{autodot} added}
% \changes{v1.7}{2016/05/22}{Caption label format \opt{autodot} fixed}
% \changes{v1.8}{2016/05/22}{Caption label format \opt{unnumbered} added}
% There are six pre-defined label formats, called `empty', `simple',
% `parens', `brace', `autodot', and `unnumbered'.
+%
% \begin{macrocode}
\DeclareCaptionLabelFormat{empty}{}
\DeclareCaptionLabelFormat{simple}{\bothIfFirst{#1}{\nobreakspace}#2}
@@ -1705,63 +1980,120 @@
\DeclareCaptionLabelFormat{unnumbered}{#1}
% \end{macrocode}
%
-% `default' usually maps to `simple'.
+% \changes{v2.0}{2020/08/03}{Caption label format \opt{original} added}
+% The label format `original' tries to preserve the original definition
+% of the label format which was defined by |\fnum@|\meta{environment}.
+% If no original definition is available, use the label format `simple'
+% as fallback.
+%
+% \begin{macrocode}
+\DeclareCaptionLabelFormat{original}{%
+ \caption@ifdefined\caption@original@fnum
+ {\caption@original@fnum}%
+ {\caption@labelformat@simple{#1}{#2}}}
+% \end{macrocode}
+%
+% `default' usually maps to `original'.
% \begin{macrocode}
-\def\caption@lfmt@default{\caption@lfmt@simple}
+\SetCaptionDefault{labelformat}{original}
% \end{macrocode}
%
% \section{Label separators}
%
% \begin{macro}{\DeclareCaptionLabelSeparator}
-% \changes{v1.0a}{2004/01/17}{Pass through argument \#2 so extra spaces
-% between arguments do make any harm}
+% \changes{v1.0a}{2004/01/17}{Pass through argument \#2 so extra spaces between arguments do make any harm}
% \changes{v1.0f}{2005/08/25}{Starred variant added}
% \changes{v1.1}{2007/07/13}{Test for CR added}
% \changes{v1.3}{2011/08/06}{Test for CR revised}
-% |\DeclareCaptionLabelSeparator|\marg{name}\marg{code}\\
-% |\DeclareCaptionLabelSeparator*|\marg{name}\marg{code}\par
-% The starred form causes the label separator to be typeset \emph{without} using |\captionlabelfont|.
+% \changes{v2.0}{2018/05/15}{Variant with two stars added}
+% \changes{v2.0}{2019/09/10}{Uses \cs{caption@decl} now}
+% \changes{v2.0}{2020/07/27}{\cs{caption@iflf} renamed to \cs{caption@iflabelfont}}
+% \changes{v2.0}{2020/07/27}{\cs{caption@lsep} renamed to \cs{caption@labelsep}}
+% \changes{v2.0}{2020/07/27}{Definition of \cs{caption@labelsep@name} added}
+% |\DeclareCaptionLabelSeparator|\marg{name}\marg{code}\\
+% |\DeclareCaptionLabelSeparator*|\marg{name}\marg{code}\\
+% |\DeclareCaptionLabelSeparator**|\marg{name}\marg{condition}\marg{code}\\
+% The starred form causes the label separator to be typeset \emph{without}
+% using |\caption|\-|label|\-|font|.
+% The two-starred form uses \meta{condition} to decide if the label separator
+% should be typeset with or without using |\caption|\-|label|\-|font|.
% \begin{macrocode}
\newcommand\DeclareCaptionLabelSeparator{%
- \caption@teststar\caption@declarelabelseparator\@gobble\@firstofone}
+ \@ifstar
+ \DeclareCaptionLabelSeparator@
+ {\caption@declarelabelseparator\@firstofone}}
\@onlypreamble\DeclareCaptionLabelSeparator
% \end{macrocode}
% \begin{macrocode}
+\newcommand\DeclareCaptionLabelSeparator@{%
+ \@ifstar
+ \DeclareCaptionLabelSeparator@@
+ {\caption@declarelabelseparator\@gobble}}
+\@onlypreamble\DeclareCaptionLabelSeparator@
+% \end{macrocode}
+% \begin{macrocode}
+\newcommand*\DeclareCaptionLabelSeparator@@[2]{%
+ \caption@declarelabelseparator
+ {#2\@gobble\@firstofone}%
+ {#1}}
+\@onlypreamble\DeclareCaptionLabelSeparator@@
+% \end{macrocode}
+% \begin{macrocode}
\newcommand\caption@declarelabelseparator[3]{%
- \global\@namedef{caption@iflf@#2}{#1}%
- \global\long\@namedef{caption@lsep@#2}{#3}%
- \caption@@declarelabelseparator{#2}#3\\\@nil}
-\@onlypreamble\caption@declarelabelseparator
+ \caption@decl{labelseparator}{#2}%
+ {\def\caption@iflabelfont{#1}%
+ \def\caption@labelsep@name{#2}%
+ \def\caption@labelsep{#3}}%
% \end{macrocode}
+% Unfortunately |\Declare|\-|Float|\-|Separators| of the \package{floatrow}
+% package mis-uses |\Declare|\-|Caption|\-|Label|\-|Separator| instead of
+% storing the definition on its own. Since the \package{floatrow} package is
+% unmaintained we have to store the separator definition inside
+% |\caption@lsep@|\meta{name} for \package{floatrow}, too. (Sigh!)
% \begin{macrocode}
-\long\def\caption@@declarelabelseparator#1#2\\#3\@nil{%
- \def\@tempa{#3}\ifx\@tempa\@empty \else
- \caption@g@addto@list\caption@lsepcrlist{#1}%
- \fi}
-\@onlypreamble\caption@@declarelabelseparator
+ \@namedef{caption@lsep@#2}{#3}}
+% \end{macrocode}
+% Since the `default' caption label separator will usually not be defined
+% with |\Declare|\-|Caption|\-|Label|\-|Separator|, we need to define
+% |\caption@lsep@default| manually.
+% \Note{This definition is used by \package{magyar.ldf} but only needs to be different
+% than \cs{caption@lsep} (which is usually undefined).}
+% \begin{macrocode}
+\newcommand*\caption@lsep@default{\caption@labelseparator@default\caption@labelsep}%
+% \end{macrocode}
+% \begin{macrocode}
+\@onlypreamble\caption@declarelabelseparator
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\caption@LabelSeparatorWithNewline}
+% \changes{v2.0}{2020/07/27}{This macro added}
+% |\caption@LabelSeparatorWithNewline|\marg{name}\\
+% adds the given label separator to a list of label separators which uses
+% |\\| internally. (They are incompatible to the `hang' caption format.)
% \begin{macrocode}
-\DeclareCaptionOption{labelsep}{\caption@setlabelseparator{#1}}
-\DeclareCaptionOption{labelseparator}{\caption@setlabelseparator{#1}}
+\newcommand*\caption@LabelSeparatorWithNewline[1]{%
+ \caption@g@addto@list\caption@labelsep@crlist{#1}}
+\@onlypreamble\caption@LabelSeparatorWithNewline
% \end{macrocode}
+% \end{macro}
%
-% \begin{macro}{\caption@setlabelseparator}
-% |\caption@setlabelseparator|\marg{name}\par
-% Selecting a caption label separator simply means saving the code (in |\caption@lsep|).
+% \begin{macro}{\caption@iflabelseparatorwithnewline}
+% \changes{v2.0}{2020/07/31}{This macro added}
+% |\caption@iflabelseparatorwithnewline|\marg{yes-code}\marg{no-code}\\
+% tests if the current label separator uses |\\| internally.
% \begin{macrocode}
-\newcommand*\caption@setlabelseparator[1]{%
- \@ifundefined{caption@lsep@#1}%
- {\caption@Error{Undefined label separator `#1'}}%
- {\edef\caption@lsepname{#1}%
- \expandafter\let\expandafter\caption@iflf\csname caption@iflf@#1\endcsname
- \expandafter\let\expandafter\caption@lsep\csname caption@lsep@#1\endcsname}}
+\newcommand*\caption@iflabelseparatorwithnewline{%
+ \caption@ifin@list\caption@labelsep@crlist\caption@labelsep@name}
% \end{macrocode}
% \end{macro}
%
-% \changes{v1.0e}{2005/06/11}{Bugfix 05-03-23: Caption label separator
-% \opt{newline} implementation changed from \cs{newline} to \cs{\textbackslash}}
+% \begin{macrocode}
+\DeclareCaptionOption{labelsep}{\caption@set{labelseparator}{#1}}
+\DeclareCaptionOption{labelseparator}{\caption@set{labelseparator}{#1}}
+% \end{macrocode}
+%
+% \changes{v1.0e}{2005/06/11}{Bugfix 05-03-23: Caption label separator \opt{newline} implementation changed from \cs{newline} to \cs{\textbackslash}}
% \changes{v1.0f}{2005/08/24}{Caption label separator \opt{endash} added}
% There are seven pre-defined label separators, called `none', `colon', `period', `space',
% `quad', `newline', and `endash'.
@@ -1772,71 +2104,44 @@
\DeclareCaptionLabelSeparator{space}{ }
\DeclareCaptionLabelSeparator*{quad}{\quad}
\DeclareCaptionLabelSeparator*{newline}{\captionnewline}
+\caption@LabelSeparatorWithNewline{newline} % does not work with "format=hang"
\DeclareCaptionLabelSeparator*{endash}{\space\textendash\space}
% \end{macrocode}
%
% \begin{macro}{\captionnewline}
% \changes{v1.12}{2020/05/30}{This macro added}
-% Will be used in the caption label separator |new|\-|line|,
-% and re-defined for |long|\-|table| environments.
+% \changes{v2.0}{2020/07/31}{\cs{relax} added to definition}
+% |\captionnewline|\\
+% will be used in the caption label separator |new|\-|line|,
+% and re-defined for |long|\-|table| environments
+% (in package \package{ltcaption}).
% \begin{macrocode}
-\newcommand*\captionnewline{\\}
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\caption@setdefaultlabelsep}
-% \changes{v1.2d}{2009/03/29}{This macro added}
-% \begin{macrocode}
-\newcommand*\caption@setdefaultlabelsep[1]{%
- \ifx\caption@lsep\caption@lsep@default
- \caption@set@default@labelsep{#1}%
- \caption@setlabelseparator{default}%
- \else
- \caption@set@default@labelsep{#1}%
- \fi}
-% \end{macrocode}
-% \begin{macrocode}
-\newcommand*\caption@set@default@labelsep[1]{%
- \def\caption@lsep@default{\@nameuse{caption@lsep@#1}}%
- \def\caption@iflf@default{\@nameuse{caption@iflf@#1}}}
+\newcommand*\captionnewline{\\\relax}
% \end{macrocode}
% \end{macro}
%
% `default' usually maps to `colon'.
% \begin{macrocode}
-\caption@set@default@labelsep{colon}
+\SetCaptionDefault{labelseparator}{colon}
% \end{macrocode}
%
% \section{Text formats}
%
% \begin{macro}{\DeclareCaptionTextFormat}
% \changes{v1.0j}{2007/02/18}{This macro added}
-% |\DeclareCaptionTextFormat|\marg{name}\marg{code with \#1}
+% \changes{v2.0}{2019/09/10}{Uses \cs{caption@decl} now}
+% |\DeclareCaptionTextFormat|\marg{name}\marg{code with \#1}
% \begin{macrocode}
\newcommand*\DeclareCaptionTextFormat[2]{%
- \global\long\@namedef{caption@tfmt@#1}##1{#2}}
+ \caption@decl{textformat}{#1}##1{#2}}
\@onlypreamble\DeclareCaptionTextFormat
% \end{macrocode}
% \end{macro}
%
-% \changes{v1.0c}{2005/02/12}{Option \opt{strut=} added}
% \begin{macrocode}
-\DeclareCaptionOption{textformat}{\caption@settextformat{#1}}
-\DeclareCaptionOption{strut}[1]{\caption@set@bool\caption@ifstrut{#1}}
+\DeclareCaptionOption{textformat}{\caption@set{textformat}{#1}}
% \end{macrocode}
%
-% \begin{macro}{\caption@settextformat}
-% \changes{v1.0j}{2007/02/18}{This macro added}
-% |\caption@settextformat|\marg{name}\par
-% Selecting a caption text format simply means saving the code (in |\caption@tfmt|).
-% \begin{macrocode}
-\newcommand*\caption@settextformat[1]{%
- \@ifundefined{caption@tfmt@#1}%
- {\caption@Error{Undefined text format `#1'}}%
- {\expandafter\let\expandafter\caption@tfmt\csname caption@tfmt@#1\endcsname}}
-% \end{macrocode}
-% \end{macro}
-%
% There are three pre-defined text formats, called `empty', `simple' and `period'.
% \changes{v1.4}{2011/10/05}{Pre-defined text format `empty' added}
% \changes{v1.7}{2015/09/16}{The text format `empty' now takes care of the \cs{label}}
@@ -1848,9 +2153,9 @@
\long\def\caption@get@label#1\caption@makeanchor#2#3\@nil{%
\def\caption@tempa{#2}%
\ifx\caption@tempa\@empty
- \caption@getlabel#1\label{}\@nil
+ \caption@getlabel{#1}%
\else
- \caption@getlabel#2\label{}\@nil
+ \caption@getlabel{#2}%
\fi}
% \end{macrocode}
% \begin{macrocode}
@@ -1860,16 +2165,21 @@
%
% `default' usually maps to `simple'.
% \begin{macrocode}
-\def\caption@tfmt@default{\caption@tfmt@simple}
+\SetCaptionDefault{textformat}{simple}
% \end{macrocode}
%
% \begin{macro}{\caption@getlabel}
% \changes{v1.0}{2011/09/03}{\cs{label} can have optional arguments now}
% \changes{v1.7}{2015/09/16}{Moved from \package{bicaption} package to \package{caption3}}
% \changes{v1.8d}{2019/09/01}{Bugfix: Global definition of \cs{caption@thelabel} added}
-% Gets the label command out of the (first) caption text and stores it to |\caption@thelabel|.
-% \begin{macrocode}
-\long\def\caption@getlabel#1\label#2#3\@nil{%
+% \changes{v2.0}{2020/08/23}{Syntax changed}
+% |\caption@getlabel|\marg{text}\\
+% gets the label command out of the given caption text and stores it to
+% |\caption@the|\-|label|.
+% \begin{macrocode}
+\newcommand\caption@getlabel[1]{%
+ \caption@@getlabel#1\label{}\@nil}
+\long\def\caption@@getlabel#1\label#2#3\@nil{%
\def\@tempa{#2}%
\ifx\@tempa\@empty
\let\caption@thelabel\relax
@@ -1877,33 +2187,38 @@
\def\@tempb{*}%
\ifx\@tempa\@tempb
\def\caption@thelabel{\label*}%
- \caption@@getlabel#3\@nil
+ \caption@@@getlabel#3\@nil
\else
\def\caption@thelabel{\label}%
- \caption@@getlabel{#2}#3\@nil
+ \caption@@@getlabel{#2}#3\@nil
\fi
\fi}
% \end{macrocode}
% \begin{macrocode}
-\long\def\caption@@getlabel#1#2\@nil{%
+\long\def\caption@@@getlabel#1#2\@nil{%
\def\@tempa{#1}%
\def\@tempb{[}%
\ifx\@tempa\@tempb
- \caption@@@getlabel#1#2\@nil
+ \caption@@@@getlabel#1#2\@nil
\else
\l@addto@macro\caption@thelabel{{#1}}%
\fi}
% \end{macrocode}
% \begin{macrocode}
-\long\def\caption@@@getlabel[#1]#2\@nil{%
+\long\def\caption@@@@getlabel[#1]#2\@nil{%
\l@addto@macro\caption@thelabel{[{#1}]}%
- \caption@@getlabel#2\@nil}
+ \caption@@@getlabel#2\@nil}
% \end{macrocode}
% \begin{macrocode}
\let\caption@thelabel\relax
% \end{macrocode}
% \end{macro}
%
+% \changes{v1.0c}{2005/02/12}{Option \opt{strut=} added}
+% \begin{macrocode}
+\DeclareCaptionOption{strut}[1]{\caption@set@bool\caption@ifstrut{#1}}
+% \end{macrocode}
+%
% \section{Fonts}
%
% \begin{macro}{\DeclareCaptionFont}
@@ -1911,79 +2226,56 @@
% \changes{v1.1}{2007/05/07}{Internal: Uses \cs{caption@fnt} instead of \cs{caption@temp} now}
% \changes{v1.8h}{2020/01/03}{Check for \package{ragged2e} package related options added}
% \changes{v1.10}{2020/05/10}{Optional argument \opt{package} added}
-% |\DeclareCaptionFont|\oarg{package}\marg{name}\marg{code}
+% |\DeclareCaptionFont|\oarg{package}\marg{name}\marg{code}
% \begin{macrocode}
\newcommand*\DeclareCaptionFont{%
- \@ifnextchar[%]
- \caption@declare@font
- \caption@declarefont}
+ \caption@decl@package{font}{\caption@declarefont}}
\@onlypreamble\DeclareCaptionFont
% \end{macrocode}
% \begin{macrocode}
-\def\caption@declare@font[#1]#2{%
- \global\@namedef{caption@fnt@#2@package}{#1}%
- \caption@@declarefont{#2}}
-\@onlypreamble\caption@declare@font
+\newcommand*\caption@declarefont[2]{%
+ \caption@decl{font}{#1}##1{#2}%
+ \define@key{caption@font}{#1}[]{\caption@addto@font{#1}{##1}}}
+\@onlypreamble\caption@@declarefont
% \end{macrocode}
% \begin{macrocode}
-\newcommand*\caption@declarefont[1]{%
- \global\@nameundef{caption@fnt@#1@package}%
- \caption@@declarefont{#1}}
-\@onlypreamble\caption@declarefont
+\newcommand*\caption@addto@font[1]{%
% \end{macrocode}
% \begin{macrocode}
-\newcommand*\caption@@declarefont[2]{%
- \define@key{caption@fnt}{#1}[]{\caption@addto@fnt{#1}{#2}}%
- \caption@@@declarefont{#1}{#2}}
-\@onlypreamble\caption@@declarefont
+% Load package first, if necessary
+ \caption@load@package{font}{#1}%
% \end{macrocode}
+% Add the content to \cs{caption@fnt}
% \begin{macrocode}
-\newcommand*\caption@@@declarefont[2]{}% will be used by \DeclareCaptionJustification
-\@onlypreamble\caption@@@declarefont
+ \caption@add@to@font{font}{#1}}
% \end{macrocode}
% \begin{macrocode}
-\newcommand*\caption@addto@fnt[2]{%
- \expandafter\let\expandafter\caption@package\csname caption@fnt@#1@package\endcsname
- \caption@ifdefined\caption@package
- {\caption@requirepackage\caption@package{#1}}% load package, if necessary
- {}%
- \l@addto@macro\caption@fnt{#2}}
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\DeclareCaptionDefaultFont}
-% \changes{v1.1}{2006/05/14}{This macro added}
-% \changes{v1.2a}{2008/01/31}{Renamed from \cs{DeclareDefaultCaptionFont} to \cs{DeclareCaptionDefaultFont}}
-% |\DeclareCaptionDefaultFont|\marg{name}\marg{code}
-% \begin{macrocode}
-\newcommand*\DeclareCaptionDefaultFont[2]{%
- \global\@namedef{caption#1@default}{#2}}
-\@onlypreamble\DeclareCaptionDefaultFont
+\newcommand*\caption@add@to@font[3]{%
+ \expandafter\g@addto@macro\expandafter\caption@fnt\expandafter{\csname caption@#1@#2\endcsname{#3}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macrocode}
\DeclareCaptionOption{font}{\caption@setfont{font}{#1}}
\DeclareCaptionOption{font+}{\caption@addtofont{font}{#1}}
-\DeclareCaptionDefaultFont{font}{}
% \end{macrocode}
% \begin{macrocode}
\DeclareCaptionOption{labelfont}{\caption@setfont{labelfont}{#1}}
\DeclareCaptionOption{labelfont+}{\caption@addtofont{labelfont}{#1}}
-\DeclareCaptionDefaultFont{labelfont}{}
+\caption@setmapping{labelfont}{font}
% \end{macrocode}
% \begin{macrocode}
\DeclareCaptionOption{textfont}{\caption@setfont{textfont}{#1}}
\DeclareCaptionOption{textfont+}{\caption@addtofont{textfont}{#1}}
-\DeclareCaptionDefaultFont{textfont}{}
+\caption@setmapping{textfont}{font}
% \end{macrocode}
%
% \begin{macro}{\caption@setfont}
% \changes{v1.0j}{2007/01/30}{Usage of \cs{caption@setkeys} with optional argument}
% \changes{v1.1}{2006/05/14}{Support of \cs{DeclareDefaultCaptionFont} added}
-% |\caption@setfont|\marg{name}\marg{keyval-list of names}\par
-% Selecting a caption font means saving all the code snippets
-% in |\caption|\meta{name}.
+% |\caption@setfont|\marg{name}\marg{keyval-list of names}\\
+% Selecting a caption font means saving all the code snippets
+% in |\caption|\meta{name}.
% \begin{macrocode}
\newcommand*\caption@setfont[1]{%
\expandafter\let\csname caption#1\endcsname\@empty
@@ -1993,38 +2285,18 @@
%
% \begin{macro}{\caption@addtofont}
% \changes{v1.2}{2007/11/17}{This macro added}
-% |\caption@addtofont|\marg{name}\marg{keyval-list of names}\par
-% Like |\caption@setfont|, but adds the code snippets to |\caption|\meta{name}.\par
-% Because we use |\setkeys| recursive here we need to do this inside an
-% extra group.
+% |\caption@addtofont|\marg{name}\marg{keyval-list of names}\\
+% Like |\caption@set|\-|font|, but adds the code snippets to |\caption|\meta{name}.
+% Because we use |\set|\-|keys| recursive here we need to do this inside an
+% extra group.
% \begin{macrocode}
\newcommand*\caption@addtofont[2]{%
+ \expandafter\let\expandafter\caption@fnt\csname caption#1\endcsname
\begingroup
- \expandafter\let\expandafter\caption@fnt\csname caption#1\endcsname
- \define@key{caption@fnt}{default}[]{%
- \l@addto@macro\caption@fnt{\csname caption#1@default\endcsname}}%
- \caption@setkeys[caption]{caption@fnt}{#2}%
- \global\let\caption@tempa\caption@fnt
+ \define@key{caption@font}{default}[]{\caption@add@to@font{#1}{default}{##1}}%
+ \caption@setkeys[caption]{caption@font}{#2}%
\endgroup
- \expandafter\let\csname caption#1\endcsname\caption@tempa}
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\caption@font}
-% \changes{v1.1}{2007/05/07}{This macro added}
-% |\caption@font|\marg{keyval-list of names}\\
-% |\caption@font*|\marg{keyval-code}\par
-% Sets the given font, e.g.~|\caption@font{small,it}|
-% is equivalent to |\small\itshape|.
-% \begin{macrocode}
-\newcommand*\caption@font{%
- \caption@teststar\caption@@font\@firstofone
- {\caption@setkeys[caption]{caption@fnt}}}
-\newcommand*\caption@@font[2]{%
- \begingroup
- \def\caption@fnt{\endgroup}%
- #1{#2}%
- \caption@fnt}
+ \expandafter\let\csname caption#1\endcsname\caption@fnt}
% \end{macrocode}
% \end{macro}
%
@@ -2063,7 +2335,31 @@
\DeclareCaptionFont{Huge}{\Huge}
% \end{macrocode}
%
-% \changes{v1.8}{2018/05/01}{Font size \texttt{smaller} added}
+% \changes{v1.8}{2018/05/01}{Font sizes \texttt{smaller} and \texttt{larger} added}
+% \begin{macrocode}
+\DeclareCaptionFont{smaller}{\caption@smaller}
+\DeclareCaptionFont{larger}{\caption@larger}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\DeclareCaptionFont{none}{}
+\DeclareCaptionFont{normal}{%
+ \caption@font@normalcolor\@unused
+ \caption@font@normalfont\@unused
+ \caption@font@normalsize\@unused
+ \caption@font@singlespacing\@unused}
+% \end{macrocode}
+%
+% `default' usually maps to `none'.
+% \begin{macrocode}
+\SetCaptionDefault{font}{none}
+\SetCaptionDefault{labelfont}{none}
+\SetCaptionDefault{textfont}{none}
+% \end{macrocode}
+%
+% \begin{macro}{\caption@smaller}
+% |\caption@smaller|\\
+% selects a font size which is smaller than the current one.
% \begin{macrocode}
\newcommand\caption@smaller{%
\ifx\@currsize\tiny
@@ -2091,10 +2387,12 @@
Cannot determine current font size.\MessageBreak
Try setting it with `size=' explicitly}%
\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
-\DeclareCaptionFont{smaller}{\caption@smaller}
% \end{macrocode}
+% \end{macro}
%
-% \changes{v1.8}{2018/05/02}{Font size \texttt{larger} added}
+% \begin{macro}{\caption@larger}
+% |\caption@larger|\\
+% selects a font size which is larger than the current one.
% \begin{macrocode}
\newcommand\caption@larger{%
\ifx\@currsize\tiny
@@ -2122,23 +2420,20 @@
Cannot determine current font size.\MessageBreak
Try setting it with `size=' explicitly}%
\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
-\DeclareCaptionFont{larger}{\caption@larger}
% \end{macrocode}
+% \end{macro}
%
+% \begin{macro}{\caption@hypersetup}
+% |\caption@hypersetup|\marg{options}\\
+% expands to |\hypersetup|\marg{options} if defined, to nothing otherwise.
% \begin{macrocode}
-\DeclareCaptionFont{singlespacing}{}
+\newcommand*\caption@hypersetup{\caption@ifdefined\hypersetup\hypersetup\@gobble}
+\DeclareCaptionFont{hypersetup}{\caption@hypersetup{#1}} % for usage in \captionsetup{font={hypersetup=...}}
+\DeclareCaptionOption{hypersetup}{\caption@hypersetup{#1}} % for usage in \captionsetup[<env>]{hypersetup=...}
% \end{macrocode}
+% \end{macro}
%
-% \begin{macrocode}
-%\DeclareCaptionFont{normal}{%
-% \caption@font{normalcolor,normalfont,normalsize,singlespacing}
-\DeclareCaptionFont{normal}{%
- \caption@font*{%
- \KV@caption@fnt@normalcolor\@unused
- \KV@caption@fnt@normalfont\@unused
- \KV@caption@fnt@normalsize\@unused
- \KV@caption@fnt@singlespacing\@unused}}
-% \end{macrocode}
+% \section{Sizes}
%
% \changes{v1.0a}{2004/01/23}{Option \opt{size=} now sets \cs{captionsize} instead of \cs{captionfont}}
% The old versions \version{1.x} of \thispackage\ offered this
@@ -2146,51 +2441,46 @@
% so old documents will work fine.
% \begin{macrocode}
\DeclareCaptionOption{size}{\caption@setfont{size}{#1}}
-\DeclareCaptionDefaultFont{size}{}
+\caption@setmapping{size}{font}
+% \end{macrocode}
+%
+% `default' usually maps to `none'.
+% \begin{macrocode}
+\SetCaptionDefault{size}{none}
% \end{macrocode}
%
% \section{Justifications}
%
% \begin{macro}{\DeclareCaptionJustification}
-% \changes{v1.0a}{2004/01/17}{Pass through argument \#2 so extra spaces
-% between arguments do make any harm}
+% \changes{v1.0a}{2004/01/17}{Pass through argument \#2 so extra spaces between arguments do make any harm}
% \changes{v1.1}{2007/07/03}{Mapped to \cs{DeclareCaptionFont}}
-% |\DeclareCaptionJustification|\marg{name}\marg{code}
+% \changes{v2.0}{2020/07/26}{Uses \cs{caption@decl} now}
+% |\DeclareCaptionJustification|\oarg{package}\marg{name}\marg{code}
% \begin{macrocode}
\newcommand*\DeclareCaptionJustification{%
- \def\caption@@@declarefont##1##2{%
- \global\@namedef{caption@hj@##1}{##2}% for compatibility to v1.0, needed by floatrow package
- \let\caption@@@declarefont\@gobbletwo}%
- \DeclareCaptionFont}
-\@onlypreamble\DeclareCaptionJustification
+% \caption@decl@package{justification}{\caption@decl{justification}}} % Because of floatrow it isn't so easy...
% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\DeclareCaptionDefaultJustification}
-% \changes{v1.1}{2007/07/03}{This macro added}
-% \changes{v1.2a}{2008/01/31}{Renamed from \cs{DeclareDefaultCaptionJustification} to \cs{DeclareCaptionDefaultJustification}}
-% |\DeclareCaptionDefaultJustification|\marg{code}
+% Unfortunately the (unmaintained) \package{floatrow} uses the old storage scheme
+% of the \package{caption} package and therefore expects the justification code
+% in |\caption@hj@|\meta{name} instead of |\caption@justification@|\meta{name}.
+% For this reason we have to store the code for the \package{floatrow} package
+% additionally, so |\flrow@FBo|\-|Align| will still work fine.
% \begin{macrocode}
-\newcommand*\DeclareCaptionDefaultJustification[1]{%
- \global\@namedef{caption@hj@default}{#1}% for compatibility to v1.0
- \DeclareCaptionDefaultFont{@hj}{#1}}
-\@onlypreamble\DeclareCaptionDefaultJustification
+ \caption@withoptargs\caption@declare@justification}
% \end{macrocode}
-% \end{macro}
-%
% \begin{macrocode}
-\DeclareCaptionOption{justification}{\caption@setjustification{#1}}
-\DeclareCaptionDefaultJustification{}
+\newcommand*\caption@declare@justification[3]{%
+ \caption@decl@package{justification}{\caption@decl{justification}}#1{#2}{#3}%
+ \expandafter\let\csname caption@hj@#2\expandafter\endcsname\csname caption@justification@#2\endcsname}
+\@onlypreamble\DeclareCaptionJustification
% \end{macrocode}
+% \end{macro}
%
-% \begin{macro}{\caption@setjustification}
-% \changes{v1.1}{2007/07/03}{Mapped to \cs{caption@setfont}}
-% |\caption@setjustification|\marg{name}\par
-% Selecting a caption justification simply means saving the code (in |\caption@hj|).
% \begin{macrocode}
-\newcommand*\caption@setjustification{\caption@setfont{@hj}}
+\DeclareCaptionOption{justification}{%
+ \caption@load@package{justification}{#1}%
+ \caption@set{justification}{#1}}
% \end{macrocode}
-% \end{macro}
%
% These are the pre-defined justification code snippets.
% \begin{macrocode}
@@ -2202,10 +2492,15 @@
\DeclareCaptionJustification{raggedright}{\raggedright}
% \end{macrocode}
%
+% `default' usually maps to `justified'.
+% \begin{macrocode}
+\SetCaptionDefault{justification}{justified}
+% \end{macrocode}
+%
% \begin{macro}{\centerfirst}
% \changes{v1.0j}{2007/01/21}{Bugfix: Usage of \cs{@centercr} added (Thanks to Olga!)}
% \changes{v1.0j}{2007/01/21}{This macro renamed from \cs{caption@centerfirst} to \cs{centerfirst}}
-% Please blame Frank Mittelbach for the code of |\centerfirst| |:-)|
+% Please blame Frank Mittelbach for the code of |\center|\-|first| |:-)|
% \begin{macrocode}
\providecommand\centerfirst{%
\let\\\@centercr
@@ -2224,7 +2519,7 @@
% \begin{macro}{\centerlast}
% \changes{v1.0j}{2007/01/21}{Bugfix: Usage of \cs{@centercr} added (Thanks to Olga!)}
% \changes{v1.0j}{2007/01/21}{This macro renamed from \cs{caption@centerlast} to \cs{centerlast}}
-% This is based on code from Anne Br\"uggemann-Klein\cite{Anne}
+% This one is based on code from Anne Br\"uggemann-Klein\cite{Anne}.
% \begin{macrocode}
\providecommand\centerlast{%
\let\\\@centercr
@@ -2238,8 +2533,8 @@
%
% \begin{macro}{\abovecaptionskip}
% \begin{macro}{\belowcaptionskip}
-% Usually these skips are defined within the document class, but some
-% document classes don't do so.
+% Usually these skips are defined within the document class, but some
+% document classes don't.
% \begin{macrocode}
\caption@ifundefined\abovecaptionskip{%
\newlength\abovecaptionskip\setlength\abovecaptionskip{10\p@}}{}
@@ -2258,8 +2553,8 @@
%
% \begin{macro}{\caption@rule}
% \changes{v1.2b}{2008/05/06}{This macro added}
-% |\caption@rule|\par
-% Draws an invisible rule to adjust the ``skip'' setting.
+% |\caption@rule|\\
+% Draws an invisible rule to adjust the ``skip'' setting.
% \begin{macrocode}
\newcommand*\caption@rule{\caption@ifrule\caption@hrule\relax}
% \end{macrocode}
@@ -2284,57 +2579,71 @@
% usually has to take care for himself that this hint actually matches the
% right position.
%
+% \begin{macro}{\caption@declare@position}
+% \changes{v2.0}{2020/07/26}{This macro added}
+% |\caption@declare@position|\marg{name}\marg{code}\\
+% declares a captionposition setting of the given \meta{name},
+% \meta{code} must either expand to |\@first|\-|of|\-|two| (top) or
+% |\@second|\-|of|\-|two| (below).
+% \begin{macrocode}
+\newcommand*\caption@declare@position[2]{%
+ \caption@decl{position}{#1}{#2}}
+\@onlypreamble\caption@declare@position
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macrocode}
\DeclareCaptionOption{position}{\caption@setposition{#1}}
% \end{macrocode}
% \changes{v1.0a}{2004/01/09}{Options \opt{figureposition} and \opt{tableposition} added}
% \begin{macrocode}
-\DeclareCaptionOption{figureposition}{%
- \captionsetup*[figure]{position=#1}}
+\DeclareCaptionOption{figureposition}{\captionsetup*[figure]{position=#1}}
\@onlypreamble@key{caption}{figureposition}
% \end{macrocode}
% \begin{macrocode}
-\DeclareCaptionOption{tableposition}{%
- \captionsetup*[table]{position=#1}}
+\DeclareCaptionOption{tableposition}{\captionsetup*[table]{position=#1}}
\@onlypreamble@key{caption}{tableposition}
% \end{macrocode}
%
% \begin{macro}{\caption@setposition}
-% \changes{v1.0a}{2004/01/22}{Now the positions \opt{t}, \opt{above}, \opt{b},
-% \opt{below}, and \opt{a} are allowed, too}
+% \changes{v1.0a}{2004/01/22}{Now the positions \opt{t}, \opt{above}, \opt{b}, \opt{below}, and \opt{a} are allowed, too}
% \changes{v1.0c}{2004/08/10}{Usage of \cs{caption@defaultpos} added}
-% |\caption@setposition|\marg{position}\par
-% Selecting the caption position means that we put |\caption@position| to
-% the right value. \emph{Please do \textbf{not} use the internal macro
-% \cs{caption@position} in your own package or document, but use the wrapper
-% macro \cs{caption@iftop} instead.}
-% \begin{macrocode}
-\newcommand*\caption@setposition[1]{%
- \caption@ifinlist{#1}{d,default}{%
- \let\caption@position\caption@defaultpos
- }{\caption@ifinlist{#1}{t,top,above}{%
- \let\caption@position\@firstoftwo
- }{\caption@ifinlist{#1}{b,bottom,below}{%
- \let\caption@position\@secondoftwo
- }{\caption@ifinlist{#1}{a,auto}{%
- \let\caption@position\@undefined
- }{%
- \caption@Error{Undefined position `#1'}%
- }}}}}
+% \changes{v2.0}{2020/07/27}{Uses \cs{caption@set} now}
+% |\caption@setposition|\marg{position}\\
+% puts |\caption@position| to the right value.
+% \emph{Please do \textbf{not} use the internal macro
+% \cs{caption@position} in your own package or document, but use the
+% wrapper command \cs{caption@iftop} instead.}\par
+% (Note: Since this command is used by the \package{floatrow} package as well
+% its syntax should not change.)
+% \begin{macrocode}
+\newcommand*\caption@setposition{\caption@set{position}}
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\caption@defaultpos}
+% These are the pre-defined position code snippets.
+% \begin{macrocode}
+\caption@declare@position{t}{\@firstoftwo}
+\caption@declare@position{top}{\@firstoftwo}
+\caption@declare@position{above}{\@firstoftwo}
+\caption@declare@position{b}{\@secondoftwo}
+\caption@declare@position{bottom}{\@secondoftwo}
+\caption@declare@position{below}{\@secondoftwo}
+\caption@declare@position{a}{\caption@autoposition}% needed by floatrow package, \flrow@cappos
+\caption@declare@position{auto}{\caption@autoposition}
+% \end{macrocode}
+%
% \changes{v1.1}{2007/05/08}{Default position changed from `bottom' to `auto'}
-% The default `position' is `auto', this means that \thispackage\ will try
-% to guess the current position of the caption.
-% (But in many cases, for example in |longtable|s, this is doomed to fail!)\par
-% The setting `bottom' correspondents to the |\@makecaption| implementation
-% in the standard \LaTeX\ document classes, but `auto' should give better
-% results in most cases.
+% `default' usually maps to `auto'.
% \begin{macrocode}
-%\caption@setdefaultpos{a}% default = auto
-\let\caption@defaultpos\@undefined
+\SetCaptionDefault{position}{auto}
+% \end{macrocode}
+%
+% \begin{macro}{\caption@autoposition}
+% \changes{v2.0}{2020/07/27}{This macro added}
+% If in doubt, `position=auto' maps to `position=below'.
+% \begin{macrocode}
+\let\caption@autoposition\@secondoftwo
% \end{macrocode}
% \end{macro}
%
@@ -2342,70 +2651,51 @@
% \changes{v1.0a}{2004/01/23}{Split into \cs{caption@iftop} \& \cs{caption@fixposition}}
% \changes{v1.0c}{2005/02/12}{Adapted to \cs{caption@defaultpos}}
% \changes{v1.1}{2007/05/08}{Position will be fixed to `bottom' if `auto'}
-% |\caption@iftop|\marg{true-code}\marg{false-code}\par
-% (If the |position=| is set to |auto| we assume a |bottom| position here.)
+% \changes{v2.0}{2020/07/27}{Adapted to current implementation of `auto'}
+% |\caption@iftop|\marg{true-code}\marg{false-code}\\
+% Since version \version{2.0} this command is identical to |\caption@position|.
% \begin{macrocode}
-\newcommand*\caption@iftop{%
- \ifx\caption@position\@undefined
- \let\caption@position\@secondoftwo
-% = \caption@setposition b%
- \fi
- \caption@position}
+\newcommand*\caption@iftop{\caption@position}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\caption@fixposition}
-% \changes{v1.0b}{2004/05/16}{%
-% Split into \cs{caption@fixposition} & \cs{caption@autoposition}}
-% |\caption@fixposition|\par
-% This macro checks if the `position' is set to `auto'.
-% If yes, |\caption@autoposition| will be called to
-% set |\caption@position| to a proper value we can actually use.
+% \changes{v1.0a}{2004/01/23}{\cs{ifvmode} added}
+% \changes{v1.0b}{2004/05/16}{Split into \cs{caption@fixposition} & \cs{caption@autoposition}}
+% \changes{v2.0}{2020/07/27}{Adapted to current implementation of `auto'}
+% |\caption@fixposition|\\
+% We try to guess the current position of the caption by checking |\prev|\-|depth|.\par
+% A different solution would be setting the |\space|\-|factor| to something
+% not much less than 1000 (for example 994) in |\caption@start| and
+% checking this value here by |\ifnum\space|\-|factor=994|.
+% (It's implemented in the \package{threeparttable} package\cite{threeparttable} this way.)\par
+% Another idea would be checking |\@if|\-|mini|\-|page|, but since some packages
+% typeset the caption within a simple |\vbox| this does not seem to be a good one.
% \begin{macrocode}
\newcommand*\caption@fixposition{%
- \ifx\caption@position\@undefined
- \caption@autoposition
- \fi}
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\caption@autoposition}
-% \changes{v1.0a}{2004/01/23}{\cs{ifvmode} added}
-% |\caption@autoposition|\par
-% We guess the current position of the caption by checking |\prevdepth|.\par
-% A different solution would be setting the |\spacefactor| to something
-% not much less than 1000 (for example 994) in |\caption@start| and
-% checking this value here by |\ifnum\spacefactor=994|.
-% (It's implemented in the \package{threeparttable}
-% package\cite{threeparttable} this way.)\par
-% Another idea would be checking |\@ifminipage|, but since some packages
-% typeset the caption within a simple |\vbox| this does not seem to be a
-% good one.
-% \begin{macrocode}
-\newcommand*\caption@autoposition{%
\ifvmode
\edef\caption@tempa{\the\prevdepth}%
\caption@Debug{\protect\prevdepth=\caption@tempa}%
\ifdim\prevdepth>-\p@
- \let\caption@position\@secondoftwo
+ \let\caption@autoposition\@secondoftwo % position=below
\else
- \let\caption@position\@firstoftwo
+ \let\caption@autoposition\@firstoftwo % position=above
\fi
-% = \caption@setposition{\ifdim\prevdepth>-\p@ b\else t\fi}%
\else
\caption@Debug{no \protect\prevdepth}%
- \let\caption@position\@secondoftwo
-% = \caption@setposition b%
+ \let\caption@autoposition\@secondoftwo % position=below
\fi}
% \end{macrocode}
% \end{macro}
+%
% \begin{macro}{\caption@setautoposition}
% \changes{v1.1}{2007/06/10}{This macro added}
-% |\caption@setautoposition|\marg{position}\par
-% replaces the above algorithm by a different one (or a fixed position setting).
+% \changes{v2.0}{2020/07/27}{Adapted to current implementation of `auto'}
+% |\caption@setautoposition|\marg{position}\\
+% replaces the above algorithm by a different one (or a fixed position setting).
% \begin{macrocode}
\newcommand*\caption@setautoposition[1]{%
- \def\caption@autoposition{\caption@setposition{#1}}}
+ \def\caption@fixposition{\caption@@set{position}{autoposition}{#1}}}
% \end{macrocode}
% \end{macro}
%
@@ -2413,9 +2703,10 @@
%
% \begin{macro}{\AtBeginCaption}
% \begin{macro}{\AtEndCaption}
-% |\AtBeginCaption| \marg{code}\\
-% |\AtEndCaption| \marg{code}\par
-% These hooks can be used analogous to |\AtBeginDocument| and |\AtEndDocument|.
+% |\AtBeginCaption|\marg{code}\\
+% |\AtEndCaption|\marg{code}\\
+% These hooks can be used analogous to |\At|\-|Begin|\-|Document| and
+% |\At|\-|End|\-|Document|.
% \begin{macrocode}
\newcommand*\caption@beginhook{}
\newcommand*\caption@endhook{}
@@ -2436,10 +2727,14 @@
%
% \begin{macro}{\caption@setlist}
% \changes{v1.2a}{2008/03/20}{This macro added}
-% |\caption@setlist|\marg{boolean}
+% |\caption@setlist|\marg{boolean value}\\
+% sets the `list' option to either `off' or `on'.
% \begin{macrocode}
\newcommand*\caption@setlist{\caption@set@bool\caption@iflist}
% \end{macrocode}
+% \begin{macrocode}
+\caption@setlist{on}
+% \end{macrocode}
% \end{macro}
%
% \changes{v1.4}{2011/08/30}{Option \opt{listtype=} added}
@@ -2451,7 +2746,8 @@
%
% \begin{macro}{\caption@setlisttype}
% \changes{v1.4}{2011/08/30}{This macro added}
-% |\caption@setlisttype|\marg{type}
+% |\caption@setlisttype|\marg{type}\\
+% sets the `listtype' option to the given \meta{type}.
% \begin{macrocode}
\newcommand*\caption@setlisttype{%
\caption@setlisttype@ext{}%
@@ -2463,9 +2759,11 @@
\ifx#1\@empty \let#1\@undefined \fi}
% \end{macrocode}
% \end{macro}
+%
% \begin{macro}{\caption@setlisttype@ext}
% \changes{v1.4}{2011/08/30}{This macro added}
-% |\caption@setlisttype@ext|\marg{type extension}
+% |\caption@setlisttype@ext|\marg{type extension}\\
+% sets the `listtype' option to the given \meta{type extension}.
% \begin{macrocode}
\newcommand*\caption@setlisttype@ext{%
\caption@@setlisttype\caption@listtype@ext}
@@ -2475,10 +2773,11 @@
% \begin{macro}{\DeclareCaptionListFormat}
% \changes{v1.1}{2004/07/15}{This macro added}
% \changes{v1.2}{2007/11/17}{Renamed from \cs{DeclareCaptionListOfFormat} to \cs{DeclareCaptionListFormat}}
-% |\DeclareCaptionListFormat|\marg{name}\marg{code with \#1 and \#2}
+% \changes{v2.0}{2020/07/26}{Uses \cs{caption@decl} now}
+% |\DeclareCaptionListFormat|\marg{name}\marg{code with \#1 and \#2}
% \begin{macrocode}
\newcommand*\DeclareCaptionListFormat[2]{%
- \global\@namedef{caption@lstfmt@#1}##1##2{#2}}
+ \caption@decl{listformat}{#1}##1##2{#2}}
\@onlypreamble\DeclareCaptionListFormat
% \end{macrocode}
% \end{macro}
@@ -2486,53 +2785,33 @@
% \changes{v1.1}{2007/07/15}{Option \opt{listofformat=} added}
% \changes{v1.2}{2007/11/17}{Option \opt{listofformat=} renamed to \opt{listformat=}}
% \begin{macrocode}
-\DeclareCaptionOption{listformat}{\caption@setlistformat{#1}}
+\DeclareCaptionOption{listformat}{\caption@set{listformat}{#1}}
% \end{macrocode}
%
-% \begin{macro}{\caption@setlistformat}
-% \changes{v1.1}{2004/07/15}{This macro added}
-% \changes{v1.2}{2007/11/17}{Renamed from \cs{caption@setlistofformat} to \cs{caption@setlistformat}}
-% |\caption@setlistformat|\marg{name}\par
-% Selecting a caption list format simply means saving the code (in |\caption@lstfmt|).
-% \begin{macrocode}
-\newcommand*\caption@setlistformat[1]{%
- \@ifundefined{caption@lstfmt@#1}%
- {\caption@Error{Undefined list format `#1'}}%
- {\expandafter\let\expandafter\caption@lstfmt
- \csname caption@lstfmt@#1\endcsname}}
-% \end{macrocode}
-% \end{macro}
-%
-% There are five pre-defined list formats, taken from the \package{subfig} package.
+% There are seven pre-defined list formats. (The first five were taken from the \package{subfig} package.)
% \begin{macrocode}
\DeclareCaptionListFormat{empty}{}
\DeclareCaptionListFormat{simple}{#1#2}
-\DeclareCaptionListFormat{parens}{#1(#2)}
\DeclareCaptionListFormat{subsimple}{#2}
+\DeclareCaptionListFormat{parens}{#1(#2)}
\DeclareCaptionListFormat{subparens}{(#2)}
+\DeclareCaptionListFormat{period}{#1#2.}
+\DeclareCaptionListFormat{subperiod}{#2.}
% \end{macrocode}
%
-% \begin{macro}{\caption@setdefaultlistformat}
-% \changes{v1.2d}{2009/03/29}{This macro added}
-% \begin{macrocode}
-\newcommand*\caption@setdefaultlistformat[1]{%
- \ifx\caption@lstfmt\caption@lstfmt@default
- \caption@set@default@listformat{#1}%
- \caption@setlistformat{default}%
- \else
- \caption@set@default@listformat{#1}%
- \fi}
-% \end{macrocode}
+% `default' usually maps to `subsimple'.
% \begin{macrocode}
-\newcommand*\caption@set@default@listformat[1]{%
- \def\caption@lstfmt@default{\@nameuse{caption@lstfmt@#1}}}
+\SetCaptionDefault{listformat}{subsimple}
% \end{macrocode}
-% \end{macro}
%
-% `default' usually maps to `subsimple'.
+% \begin{macro}{\caption@lstfmt}
+% \changes{v2.0}{This macro added}
+% To provide backward compatibility we still offer \cs{caption@lstfmt}.
+% (\cs{caption@lstfmt} is used in the \package{dgruyter} package.)
% \begin{macrocode}
-\caption@set@default@listformat{subsimple}
+\newcommand*\caption@lstfmt{\caption@listformat}
% \end{macrocode}
+% \end{macro}
%
% \section{Debug option}
% \changes{v1.0k}{2007/03/04}{Debug option added}
@@ -2551,12 +2830,70 @@
\setkeys{caption}{debug=0}
% \end{macrocode}
%
-% \section{Document classes \& Babel support}
+% \section{Document class support}
+% \changes{v2.0}{2018/05/11}{Document class support re-written}
+%
+% \begin{macro}{\@makecaption@standard}
+% \begin{macrocode}
+% article|report|book.sty [2005/09/16 v1.4f Standard LaTeX document class]
+\newcommand\@makecaption@standard[2]{%
+ \vskip\abovecaptionskip
+ \sbox\@tempboxa{#1: #2}%
+ \ifdim \wd\@tempboxa >\hsize
+ #1: #2\par
+ \else
+ \global \@minipagefalse
+ \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
+ \fi
+ \vskip\belowcaptionskip}
+\@onlypreamble\@makecaption@standard
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@makecaption@arabic}
+% \begin{macrocode}
+% arabicore.sty [2006/01/01 v1.0 Arabi Core switching commands (may still change)]
+\newcommand\@makecaption@arabic[2]{%
+ \vskip\abovecaptionskip
+ \sbox\@tempboxa{#1: #2}%
+ \sbox\@Arabitempboxa{\textRL{#2} : #1}%
+ \if@rl{
+ \ifdim \wd\@Arabitempboxa >\hsize
+ \textRL{#2} : #1\par
+ \else
+ \global \@minipagefalse
+ \hb@xt@\hsize{\hfil\box\@Arabitempboxa\hfil}%
+ \fi}\else{
+ \ifdim \wd\@tempboxa >\hsize
+ #1: #2\par
+ \else
+ \global \@minipagefalse
+ \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
+ \fi}\fi
+ \vskip\belowcaptionskip}
+\@onlypreamble\@makecaption@arabic
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@makecaption@latvian}
+% \begin{macrocode}
+% latvian.ldf [2018/02/19 v2.0b Latvian support from the babel system]
+\newcommand\@makecaption@latvian[2]{%
+ \vskip10\p@
+ \sbox\@tempboxa{#1\if\empty#2\else: #2\fi}%
+ \ifdim\wd\@tempboxa>\hsize
+ #1: #2\par
+ \else
+ \hbox to\hsize{\hfil\box\@tempboxa\hfil}%
+ \fi}
+\@onlypreamble\@makecaption@latvian
+% \end{macrocode}
+% \end{macro}
%
% \begin{macro}{\caption@ifdocumentclass}
-% Boolean switch which is set if the document class could be detected successfully,
-% i.e. |\caption@document|\-|class| is set to a proper value.
-% (If |\caption@document|\-|class| is already set, this flag will also be set.)
+% Boolean switch which is set if the document class could be detected
+% successfully, i.e. |\caption@document|\-|class| is set to a proper value.
+% (If |\caption@document|\-|class| is already set, this flag will also be set.)
% \begin{macrocode}
\caption@setbool{documentclass}{1}
% \end{macrocode}
@@ -2564,8 +2901,8 @@
%
% \begin{macro}{\caption@documentclass}
% \changes{v1.8e}{2018/05/11}{This macro added}
-% Determine document class used.
-% Set |\caption@document|\-|class| by good-guessing, if not already set.
+% Determine document class used.
+% Set |\caption@document|\-|class| by good-guessing, if not already set.
% \begin{macrocode}
\caption@ifundefined\caption@documentclass{%
% \end{macrocode}
@@ -2589,19 +2926,19 @@
\caption@InfoNoLine{KOMA-Script document class detected}%
\def\caption@documentclass{koma}%
% \end{macrocode}
-% If |\@captionheadfont| is defined, we assume it's a AMS or SMF document class.
+% If |\@captionheadfont| is defined, we assume it's a AMS or SMF document class.
% \begin{macrocode}
}{\caption@ifdefined\@captionheadfont{%
\caption@InfoNoLine{AMS or SMF document class detected}%
- \def\caption@documentclass{ams}%
+ \def\caption@documentclass{ams-smf}%
% \end{macrocode}
-% If |\@CaptionFonts| is defined, we assume it's a NTG Dutch document class.
+% If |\CaptionFonts| is defined, we assume it's a NTG Dutch document class.
% \begin{macrocode}
}{\caption@ifdefined\CaptionFonts{%
\caption@InfoNoLine{NTG document class detected}%
\def\caption@documentclass{ntg}%
% \end{macrocode}
-% If |\cph@font| and |\cpb@font| are defined, we assume it's a NTG Dutch document class.
+% If |\cph@font| and |\cpb@font| are defined, we assume it's the thesis document class.
% \begin{macrocode}
}{\caption@ifdefined\cph@font{%
\caption@ifdefined\cpb@font\@firstoftwo\@secondoftwo
@@ -2612,453 +2949,376 @@
\def\caption@documentclass{thesis}%
}{%
% \end{macrocode}
-% If the definition of |\@makecaption| matches the one from the standard \LaTeX\ document classes
-% |article|, |report|, or |book|, we assume it's either one of them or is compatible to them.
+% If the definition of |\@make|\-|caption| matches the one from the standard
+% \LaTeX\ document classes |article|, |report|, or |book|, we assume it's
+% either one of them or is compatible to them.
% \begin{macrocode}
- % article|report|book [2005/09/16 v1.4f Standard LaTeX document class]
- \long\def\caption@tempa#1#2{%
- \vskip\abovecaptionskip
- \sbox\@tempboxa{#1: #2}%
- \ifdim \wd\@tempboxa >\hsize
- #1: #2\par
- \else
- \global \@minipagefalse
- \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
- \fi
- \vskip\belowcaptionskip}}
- \ifx\caption@tempa\@makecaption
- \caption@InfoNoLine{Standard document class detected}%
+ \ifx\@makecaption\@undefined
+ \caption@InfoNoLine{Document class w/o caption stuff detected}%
\else
+ \ifx\@makecaption\@makecaption@standard
+ \caption@InfoNoLine{Standard document class detected}%
+ \else
+ \ifx\@makecaption\@makecaption@arabic
+ \caption@InfoNoLine{arabic babel option detected}%
+ \else
+ \ifx\@makecaption\@makecaption@latvian
+ \caption@InfoNoLine{latvian babel option detected}%
+ \else
% \end{macrocode}
-% Otherwise we are clueless and use standard default settings for the captions anyway.
-% (And we unset the |document|\-|class| flag to indicate that the content of |\caption@document|\-|class| is not correct.)
+% Otherwise we are clueless and use standard default settings for the captions.
+% (And we unset the |document|\-|class| flag to indicate that the content of
+% |\caption@document|\-|class| is not correct.)
% \begin{macrocode}
- \caption@InfoNoLine{%
- Unknown document class (or package),\MessageBreak
- standard defaults will be used}%
- \caption@InfoNoLine{\string\@makecaption\space=\space\meaning\@makecaption\@gobble}%
- \caption@setbool{documentclass}{0}%
+ \caption@InfoNoLine{%
+ Unknown document class (or package),\MessageBreak
+ standard defaults will be used}%
+ \caption@InfoNoLine{\string\@makecaption\space=\space\meaning\@makecaption\@gobble}%
+ \caption@setbool{documentclass}{0}% unknown document class
+ \fi
+ \fi
+ \fi
\fi
- \def\caption@documentclass{base}%
- }}}}}}%
-}{}
% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\caption@ifclassloaded}
-% \changes{v1.8e}{2019/09/09}{This macro added}
-% |\caption@ifclassloaded|\marg{name}\marg{yes-code}\marg{no-code}
% \begin{macrocode}
-\newcommand*\caption@ifclassloaded[1]{%
- \edef\caption@tempa{#1}%
- \ifx\caption@tempa\caption@documentclass
- \expandafter\@firstoftwo
- \else
- \expandafter\@secondoftwo
- \fi}
+ \let\caption@documentclass\@empty % don't load adaption code later on
+ }}}}}}}%
+}{}
% \end{macrocode}
% \end{macro}
%
-% \subsection{The standard \texorpdfstring{\LaTeX{}}{LaTeX} classes}
-%
-% Since this is the default, there is no extra work to be done here.
-%
-% \subsection{The elsarticle classes}
-% \changes{v1.5}{2013/01/06}{elsarticle class support added}
-%
+% \begin{macro}{\AtCaptionPackage}
+% \changes{v2.0}{2018/05/14}{This macro added}
+% |\AtCaptionPackage|\marg{code}\\
+% can be used by the document class adaption packages to execute extra code
+% if the \package{caption} package is loaded (later on).
% \begin{macrocode}
-\caption@ifclassloaded{elsarticle}{%
+\newcommand*\AtCaptionPackage{%
+ \g@addto@macro\caption@documentclass@code}
+\@onlypreamble\AtCaptionPackage
% \end{macrocode}
% \begin{macrocode}
- \DeclareCaptionDefaultFont{font}{\footnotesize}
+\providecommand*\caption@documentclass@code{}
+\@onlypreamble\caption@documentclass@code
% \end{macrocode}
+% \end{macro}
+%
+% \section{Babel support}
+%
+% \begin{macro}{\caption@IfBabelPackageLoaded}
+% |\caption@IfBabelPackageLoaded|\marg{option}\marg{cmd}\marg{yes-code}\marg{no-code}\\
+% expands the given \meta{yes-code} if |\caption@if|\-|babel@|\meta{option}
+% is set and \meta{cmd} is defined.
+% Otherwise the \meta{no-code} is expanded.\par
+% This way the adaption could be prevented by defining
+% \begin{quote}|\def\caption@ifbabel@|\meta{option}|{false}|\end{quote}
% \begin{macrocode}
-}{}
+\newcommand*\caption@IfBabelPackageLoaded[4]{%
+ \caption@ifdefined#2\@firstofone\caption@AtBeginDocument{%
+ \caption@if@bool{\@nameuse{caption@ifbabel@#1}}%
+ {\def\caption@tempa{\caption@ifdefined#2}}%
+ {\let\caption@tempa\@secondoftwo}%
+ \caption@tempa
+ {\caption@InfoNoLine{#1 babel package is loaded}#3}%
+ {#4}}}
+\@onlypreamble\caption@IfBabelPackageLoaded
% \end{macrocode}
+% \end{macro}
%
-% \subsection{The \AmS{} \& \SmF{} classes}
-% \changes{v1.1}{2007/07/29}{\AmS\ \& \SmF\ classes support added}
+% \subsection{The arabic \& farsi babel option}
+% \changes{v1.8}{2018/05/20}{\package{arabic} babel support added}
+% \changes{v2.0}{2020/08/02}{\package{arabic} babel support updated}
+% \changes{v2.0}{2020/08/02}{\package{farsi} babel support added}
%
% \begin{macrocode}
-\caption@ifclassloaded{ams}{%
+\DeclareCaptionLabelSeparator{arabi}{\if@rl\space\fi: }
% \end{macrocode}
+%
+% \begin{macro}{\caption@IfBabelArabi}
+% |\caption@IfBabelArabic|\marg{yes-code}\marg{no-code}
% \begin{macrocode}
- \let\captionmargin\captionindent % set to 3pc by AMS class
- \begingroup\edef\@tempa{\endgroup
- \noexpand\caption@g@addto@list\noexpand\caption@sty@default
- {margin=\the\captionmargin
- \caption@ifdefined\smf@makecaption{,maxmargin=.1\linewidth}{}}}
- \@tempa
- \caption@g@addto@list\caption@sls@default{margin*=.5\captionmargin}
- \DeclareCaptionLabelSeparator{default}{.\enspace}
- \DeclareCaptionDefaultFont{font}{\@captionfont}
- \DeclareCaptionDefaultFont{labelfont}{\@captionheadfont}
- \DeclareCaptionDefaultFont{textfont}{\@captionfont\upshape}
- \captionsetup[figure]{position=b}
- \captionsetup[table]{position=t}
+\newcommand*\caption@IfBabelArabi{%
+ \caption@IfBabelPackageLoaded{arabi}{\ArabiCoreLoaded}}
+\@onlypreamble\caption@IfBabelArabi
% \end{macrocode}
% \begin{macrocode}
-}{}
+\providecommand*\caption@ifbabel@arabi{true}
% \end{macrocode}
-%
-% \subsection{The beamer class (Part one)}
-% \changes{v1.1}{2007/03/10}{\package{beamer} class support added}
-% \changes{v1.3}{2011/08/06}{\package{beamer} class support revised}
-% \changes{v1.5}{2013/04/27}{The \package{beamer} template \texttt{caption label separator} will be used now}
-% \changes{v1.7}{2016/05/22}{Re-definition of label format \texttt{simpleMagyar} added to \package{beamer} class support}
-% \changes{v1.7}{2018/04/15}{Re-definition of label format \texttt{simpleMagyar} revised}
-% \changes{v1.7}{2018/05/01}{Definition of \package{beamer} default label font revised}
+% \end{macro}
%
% \begin{macrocode}
-\caption@ifclassloaded{beamer}{%
+\caption@IfBabelArabi{%
% \end{macrocode}
%
-% \begin{macro}{\caption@ifbeamertemplate}
-% |\caption@ifbeamertemplate|\marg{caption template name}\marg{yes-code}\marg{no-code}\\
-% tests if the given beamer caption template was selected by the user (or not).
+% \begin{macro}{\caption@rl}
+% \changes{v1.8}{2018/05/20}{This macro added}
% \begin{macrocode}
- \newcommand*\caption@ifbeamertemplate[1]{%
- \begingroup
- \let\beamer@@tmpl@caption@ORI\beamer@@tmpl@caption
- \@nameuse{beamer@@tmpop@caption@#1}%
- \ifx\beamer@@tmpl@caption@ORI\beamer@@tmpl@caption
- \endgroup\expandafter\@firstoftwo
- \else
- \endgroup\expandafter\@secondoftwo
- \fi}
+ \newcommand\caption@rl[1]{\if@rl\textRL{#1}\else\textLR{#1}\fi}%
% \end{macrocode}
% \end{macro}
%
+% If the language `arabic' or `farsi' is selected, we switch the default label separator to `arabi'.
+%
% \begin{macrocode}
- \DeclareCaptionLabelFormat{default}{%
- \caption@ifbeamertemplate{numbered}%
- \caption@lfmt@simple
- \caption@lfmt@unnumbered
- {#1}{#2}}
-% \end{macrocode}
-% The \package{magyar} babel package redefines the current label format to a one called |simple|\-|Magyar|,
-% defined within |\@@magyar@caption|\-|fix| which will be executed |\At|\-|Begin|\-|Document|.
-% \begin{macrocode}
- \DeclareCaptionLabelFormat{default@magyar}{%
- \caption@ifbeamertemplate{numbered}%
- \caption@lfmt@simple@magyar
- \caption@lfmt@unnumbered
- {#1}{#2}}
- \@ifundefined{@@magyar@captionfix}\AtBeginDocument\@firstofone{%
- \@ifundefined{@@magyar@captionfix}{}{%
- \g@addto@macro\@@magyar@captionfix{%
- \let\caption@lfmt@simple@magyar\caption@lfmt@simpleMagyar
- \let\caption@lfmt@simpleMagyar\caption@lfmt@default@magyar}}}
+ \caption@ifdefined\extrasarabic{%
+ \addto\extrasarabic{%
+ \caption@switchdefault{labelseparator}{\babel@save #1}{arabi}}}{}%
+ \caption@ifdefined\extrasfarsi{%
+ \addto\extrasfarsi{%
+ \caption@switchdefault{labelseparator}{\babel@save #1}{arabi}}}{}%
% \end{macrocode}
+%
% \begin{macrocode}
- \caption@declarelabelseparator
- {\caption@ifbeamertemplate{caption name own line}\@gobble\@firstofone}
- {default}
- {\caption@ifbeamertemplate{caption name own line}{\\}%
- {\usebeamertemplate{caption label separator}}}
- \DeclareCaptionDefaultFont{font}{%
- \usebeamerfont*{caption}%
- \usebeamercolor[fg]{caption}}
- \DeclareCaptionDefaultFont{labelfont}{%
- \setbeamercolor*{caption}{}% avoid setting "caption" color additionally
- \usebeamercolor[fg]{caption name}%
- \setbeamerfont*{caption}{}% avoid setting "caption" font additionally
- \usebeamerfont{caption name}}
- \DeclareCaptionDefaultJustification{\raggedright}
+}{%
+ \let\caption@rl\@firstofone
+}
% \end{macrocode}
+%
+% \subsection{The french babel option}
+% \changes{v1.1}{2006/05/14}{\package{frenchb} babel support added}
+% \changes{v2.0}{2020/08/01}{\package{french} babel support updated}
+%
+% We provide a dummy `french' caption label separator (so |labelsep=french| works fine);
+% it will be re-defined dependant on the `french' package used later on.
% \begin{macrocode}
- \DeclareOption{beamerclass}{%
- \renewcommand\caption@ifslc{%
- \caption@ifbeamertemplate{caption name own line}\@secondoftwo\@firstoftwo}
- % Since the beamer class do not offer a `list of figures' we switch this support off.
- \captionsetup{list=0}}
- \PassOptionsToPackage{beamerclass}{caption3}
+\caption@ifdecl{labelseparator}{french}
+ {\let\caption@french@labelseparator\@undefined}%
+ {\caption@@set{labelseparator}{labelseparator@french}{default}%
+ \let\caption@french@labelseparator\caption@labelseparator@french}
% \end{macrocode}
%
-% If the \package{beamer} document class is used, we offer a beamer
-% template called `caption3' which can be used with option `beamer' or
-% |\setbeamertemplate{caption}[caption3]|.\par
-% (Note that this is of no use when the \package{caption} package is used, too.)
+% \begin{macro}{\caption@IfBabelFrench}
+% |\caption@IfBabelFrench|\marg{yes-code}\marg{no-code}
% \begin{macrocode}
- \defbeamertemplate{caption}{caption3}{%
- \caption@make\insertcaptionname\insertcaptionnumber\insertcaption}
+\newcommand*\caption@IfBabelFrench{%
+ \caption@IfBabelPackageLoaded{french}{\FB@makecaption}}
+\@onlypreamble\caption@IfBabelFrench
% \end{macrocode}
% \begin{macrocode}
- \DeclareOption{beamer}{%
- % \usebeamertemplate**{caption} will set font
- \DeclareCaptionDefaultFont{font}{}%
- \setbeamertemplate{caption}[caption3]}
+\providecommand*\caption@ifbabel@french{true}
% \end{macrocode}
-% \begin{macrocode}
+% \end{macro}
%
-% \begin{macrocode]
-}{}
+% \begin{macrocode}
+\caption@IfBabelFrench{%
% \end{macrocode}
%
-% \subsection{The KOMA-Script classes}
-% \changes{v1.1}{2007/03/31}{\KOMAScript\ classes support added}
+% If the language `french' is selected, we switch the default label separator to `french'
+% which uses |\if|\-|FB|\-|Customise|\-|Fig|\-|Tab|\-|Captions| and |\Caption|\-|Separator|.
%
% \begin{macrocode}
-\caption@ifclassloaded{koma}{%
-% \end{macrocode}
-% \begin{macrocode}
- \DeclareCaptionFormat{default}[#1#2#3\par]{%
- \ifdofullc@p
- \caption@ifin@list\caption@lsepcrlist\caption@lsepname
- {\caption@Error{%
- The option `labelsep=\caption@lsepname' does not work\MessageBreak
- with \noexpand\setcaphanging (which is set by default)}}%
- {\caption@fmt@hang{#1}{#2}{#3}}%
- \else
- #1#2%
- \ifdim\cap@indent<\z@
- \par
- \noindent\hspace*{-\cap@indent}%
- \else\if@capbreak
- \par
- \fi\fi
- #3\par
- \fi}
- \DeclareCaptionLabelSeparator{default}{\captionformat}
- \DeclareCaptionDefaultFont{font}{\scr@fnt@caption}
- \DeclareCaptionDefaultFont{labelfont}{\scr@fnt@captionlabel}
-% \end{macrocode}
-%
-% \changes{v1.0f}{2005/08/22}{Increased compatibility to KOMA-Script:
-% A special version of options `parindent' and `parskip' added}
-% \changes{v1.0g}{2006/01/03}{Bugfix 06-01-03: KOMA-Script variants of
-% `parskip' and `parindent' options revised and moved into caption kernel}
-% \changes{v1.0h}{2006/02/23}{KOMA-Script variants of `parskip' and
-% `parindent' are obsolete now, removed}
-% \changes{v1.0m}{2007/03/30}{KOMA-Script variants of `parskip' and
-% `parindent' re-added, since they still collide with the current
-% version of the subfig package (Sigh!)}
-%
-% There is an option clash between the \KOMAScript\ document classes
-% and the \package{caption} kernel, both define the options |parindent| and
-% |parskip| but with different meaning.
-% Furthermore the ones defined by the \package{caption} kernel take a
-% value as parameter but the \KOMAScript\ ones do not.
-% So we need special versions of the options |parindent| and |parskip| here
-% which determine if a value is given (and therefore should be treated as
-% our option) or not (and therefore should be ignored by us).\footnote{%^^A
-% This problem was completely solved due a change of \cs{caption@ProcessOptions}
-% in \thispackage\ \version{1.0h}, but we still need this workaround since
-% these options would otherwise still collide with the current version $1.3$
-% of the \package{subfig} package (Sigh!)}
-% \begin{macrocode}
- \let\caption@KV@parindent\KV@caption@parindent
- \DeclareCaptionOption{parindent}[]{%
- \ifx,#1,%
- \caption@Debug{Option `parindent' ignored}%
- \else
- \caption@KV@parindent{#1}%
- \fi}%
+ \ifx\caption@french@labelseparator\caption@labelseparator@french % still set to dummy label separator?
+ \DeclareCaptionLabelSeparator{french}{%
+ \ifFBCustomiseFigTabCaptions
+ \CaptionSeparator
+ \else
+ \space : %
+ \fi}%
+ \fi
+ \caption@ifdefined\extrasfrench{%
+ \addto\extrasfrench{%
+ \caption@switchdefault{labelseparator}{\babel@save #1}{french}}}{}%
% \end{macrocode}
+%
+% Suppress the warning about load order (since it's not longer valid anymore).
% \begin{macrocode}
- \let\caption@KV@parskip\KV@caption@parskip
- \DeclareCaptionOption{parskip}[]{%
- \ifx,#1,%
- \caption@Debug{Option `parskip' ignored}%
- \else
- \caption@KV@parskip{#1}%
- \fi}%
+ \caption@AtBeginDocument{\@nameuse{@FBwarning@capsepfalse}}%
% \end{macrocode}
+%
% \begin{macrocode}
}{}
% \end{macrocode}
%
-% \subsection{The \NTG{} Dutch classes}
-% \changes{v1.1}{2007/04/06}{NTG classes support added}
+% \subsection{The frenchle \& frenchpro package}
+% \changes{v1.1}{2006/05/14}{\package{frenchle/pro} package support added}
+% \changes{v2.0}{2020/08/01}{\package{frenchle/pro} package support updated}
%
+% \begin{macro}{\caption@IfFrenchLe}
+% |\caption@IfFrenchLe|\marg{yes-code}\marg{no-code}
% \begin{macrocode}
-\caption@ifclassloaded{ntg}{%
+\newcommand*\caption@IfFrenchLe{%
+ \caption@IfBabelPackageLoaded{frenchle}{\frenchTeXmods}}
+\@onlypreamble\caption@IfBabelFrenchLe
% \end{macrocode}
% \begin{macrocode}
- \DeclareCaptionDefaultFont{labelfont}{\CaptionLabelFont}
- \DeclareCaptionDefaultFont{textfont}{\CaptionTextFont}
+\providecommand*\caption@ifbabel@frenchle{true}
% \end{macrocode}
+% \end{macro}
+%
% \begin{macrocode}
-}{}
+\caption@IfFrenchLe{%
% \end{macrocode}
%
-% \subsection{The thesis class}
-% \changes{v1.2a}{2008/01/31}{thesis class support added}
-% \changes{v1.2e}{2009/11/15}{Bugfix 09-11-14: thesis class support revised}
+% If the language `french' is selected, we switch the default label separator to `french'
+% which uses |\caption|\-|separator|, and switch the default font to `it' and the default label font to `up'.
%
% \begin{macrocode}
-\caption@ifclassloaded{thesis}{%
+ \ifx\caption@french@labelseparator\caption@labelseparator@french % still set to dummy label separator?
+ \DeclareCaptionLabelSeparator{french}{\captionseparator\space}%
+ \fi
+ \g@addto@macro\extrasfrench{%
+ \caption@switchdefault{labelseparator}{\let\caption@original@labelseparator#1}{french}%
+ \caption@switchdefault{font}{\let\caption@original@font#1}{it}%
+ \caption@switchdefault{labelfont}{\let\caption@original@labelfont#1}{up}}%
+ \g@addto@macro\extrasenglish{%
+ \caption@restoredefault{labelseparator}{\caption@original@labelseparator}%
+ \caption@restoredefault{font}{\caption@original@font}%
+ \caption@restoredefault{labelfont}{\caption@original@labelfont}}%
% \end{macrocode}
+%
+% Since the \package{frenchle} package overwrites |\caption|\-|font| and |\caption|\-|label|\-|font|
+% (within |\GOfrench|) we need to save them beforehand and restore them afterwards.
+%
% \begin{macrocode}
- \DeclareCaptionDefaultFormat{hang}
- \DeclareCaptionDefaultFont{labelfont}{\cph@font}
- \DeclareCaptionDefaultFont{textfont}{\cpb@font}
+ \caption@AtBeginDocument{%
+ \let\captionfont@original\captionfont
+ \let\captionlabelfont@original\captionlabelfont}%
+ \g@addto@macro\GOfrench{%
+ \let\captionfont\captionfont@original
+ \let\captionlabelfont\captionlabelfont@original}%
% \end{macrocode}
+%
% \begin{macrocode}
}{}
% \end{macrocode}
%
-% \subsection{The arabic Babel option}
-% \changes{v1.8}{2018/05/20}{\package{arabic} babel package support added}
+% \subsection{The hungarian \& magyar babel option}
+% \changes{v1.3}{2009/03/29}{\package{magyar} babel support added}
+% \changes{v1.3a}{2011/08/12}{\package{magyar} babel support revised}
+% \changes{v1.8b}{2018/08/26}{\package{magyar} babel support revised}
+% \changes{v2.0}{2020/08/03}{\package{magyar} babel support updated}
%
% \begin{macrocode}
-\caption@ifdefined\ArabiCoreLoaded{%
+\DeclareCaptionLabelFormat{magyar}{#2\bothIfSecond{.~}{#1}}
% \end{macrocode}
%
-% \begin{macro}{\caption@rl}
-% \changes{v1.8}{2018/05/20}{This macro added}
+% \begin{macro}{\caption@IfBabelHungarian}
+% |\caption@IfBabelHungarian|\marg{yes-code}\marg{no-code}
% \begin{macrocode}
- \newcommand\caption@rl[1]{\if@rl\textRL{#1}\else\textLR{#1}\fi}
+\newcommand*\caption@IfBabelHungarian{%
+ \caption@IfBabelPackageLoaded{hungarian}{\magyar@opt@defaults}}
+\@onlypreamble\caption@IfBabelHungarian
% \end{macrocode}
-% \end{macro}
-%
% \begin{macrocode}
- \def\fnum@figure{\figurename\nobreakspace\thefigure}%
- \def\fnum@table{\tablename\nobreakspace\thetable}%
-% \end{macrocode}
-% \begin{macrocode}
- \DeclareCaptionLabelSeparator{arabi}{ : }
- \DeclareCaptionLabelSeparator{default}{%
- \if@rl\caption@lsep@arabi\else\caption@lsep@colon\fi}
+\providecommand*\caption@ifbabel@hungarian{true}
% \end{macrocode}
+% \end{macro}
+%
% \begin{macrocode}
-}{%
- \let\caption@rl\@firstofone
-}
+\caption@IfBabelHungarian{%
% \end{macrocode}
%
-% \subsection{The frenchb Babel option}
-% \changes{v1.1}{2006/05/14}{\package{frenchb} babel package support added}
+% If the language `hungarian' or `magyar' is selected,
+% we switch the default label format to `magyar', the default separator to `period',
+% and the default list format to `subperiod'.
%
% \begin{macrocode}
-\caption@ifdefined\FB@makecaption{%
-% \end{macrocode}
-% \begin{macrocode}
- \ifx\@makecaption\STD@makecaption
- \DeclareCaptionLabelSeparator{default}{\CaptionSeparator}
- \def\caption@frenchb{% supress frenchb warning
- \let\STD@makecaption\@makecaption
- \let\FB@makecaption\@makecaption}
- \else
- \ifx\@makecaption\@undefined\else
- \caption@InfoNoLine{%
- The definition of \protect\@makecaption\space
- has been changed,\MessageBreak
- frenchb will NOT customize it}%
- \fi
- \fi
+ \caption@ifdefined\extrashungarian{%
+ \addto\extrashungarian{%
+ \caption@switchdefault{labelformat}{\babel@save #1}{magyar}%
+ \caption@switchdefault{labelseparator}{\babel@save #1}{period}%
+ \caption@switchdefault{listformat}{\babel@save #1}{subperiod}}}{}%
+ \caption@ifdefined\extrasmagyar{%
+ \addto\extrasmagyar{%
+ \caption@switchdefault{labelformat}{\babel@save #1}{magyar}%
+ \caption@switchdefault{labelseparator}{\babel@save #1}{period}%
+ \caption@switchdefault{listformat}{\babel@save #1}{subperiod}}}{}%
% \end{macrocode}
+%
% \begin{macrocode}
}{}
% \end{macrocode}
%
-% \subsection{The frenchle/pro package}
-% \changes{v1.1}{2006/05/14}{\package{frenchle/pro} package support added}
+% \subsection{The latvian babel option}
%
% \begin{macrocode}
-\caption@ifdefined\frenchTeXmods{%
+\DeclareCaptionLabelFormat{latvian}{#2\bothIfSecond{~}{#1}}
% \end{macrocode}
+%
+% \begin{macro}{\caption@IfBabelLatvian}
+% |\caption@IfBabelLatvian|\marg{yes-code}\marg{no-code}
% \begin{macrocode}
- \DeclareCaptionDefaultFont{textfont}{\itshape}%
- \DeclareCaptionLabelSeparator{default}{\captionseparator\space}%
+\newcommand*\caption@IfBabelLatvian{%
+ \caption@IfBabelPackageLoaded{latvian}{\bbl@latvianindent}}
+\@onlypreamble\caption@IfBabelLatvian
% \end{macrocode}
% \begin{macrocode}
-}{}
+\providecommand*\caption@ifbabel@latvian{true}
% \end{macrocode}
-%
-% \subsection{The hungarian and magyar Babel option}
-% \changes{v1.3}{2009/03/29}{\package{magyar} package support added}
-% \changes{v1.3a}{2011/08/12}{\package{magyar} package support revised}
-% \changes{v1.8b}{2018/08/26}{\package{magyar} package support revised}
+% \end{macro}
%
% \begin{macrocode}
-\DeclareCaptionListFormat{subperiod}{#2.}
+\caption@IfBabelLatvian{%
% \end{macrocode}
%
+% If the language `latvian' is selected, we switch the default label format to `latvian'.
+%
% \begin{macrocode}
-\def\caption@tempa#1{%
- \@ifpackagewith{babel}{#1}{%
- \caption@InfoNoLine{#1 babel option is loaded}%
- \expandafter\addto\csname extras#1\endcsname{%
- % change default labelsep and listformat
- \caption@setdefaultlabelsep{period}%
- \caption@setdefaultlistformat{subperiod}}%
- \expandafter\addto\csname noextras#1\endcsname{%
- % change default labelsep and listformat
- \caption@setdefaultlabelsep{colon}%
- \caption@setdefaultlistformat{subsimple}}%
- }{}}
+ \caption@ifdefined\extraslatvian{%
+ \addto\extraslatvian{%
+ \caption@switchdefault{labelformat}{\babel@save #1}{latvian}}}{}%
% \end{macrocode}
+%
% \begin{macrocode}
-\caption@tempa{hungarian}
-\caption@tempa{magyar}
+}{}
% \end{macrocode}
%
-% TODO: babel-latvian/latvian.ldf
-%
% \section{Package support}
%
-% \begin{macro}{\caption@xpackage}
-% \changes{v1.11}{2020/05/10}{This macro added}
-% |\caption@xpackage|\marg{macro}\marg{package}\marg{option}
-% expands the given macro if the given package is not loaded.
-% (Note: We cannot use |\@ifpackageloaded| here since it's not available after |\AtBeginDocument|.)
+% \begin{macro}{\caption@ifpackageloaded}
+% \changes{v2.0}{2020/07/26}{This macro added}
+% |\caption@ifpackageloaded|\marg{package}\marg{yes-code}\marg{no-code}\\
+% expands the given code if the given package is (not) loaded.
+% (Note: We cannot use |\@if|\-|package|\-|loaded| here since it's not
+% available after |\At|\-|Begin|\-|Document|.)
% \begin{macrocode}
-\newcommand*\caption@xpackage[2]{%
- \expandafter\ifx\csname ver@#2.\caption@pkgextension\endcsname\relax
- \expandafter\@firstofone
+\newcommand*\caption@ifpackageloaded[1]{%
+ \expandafter\ifx\csname ver@#1.\caption@pkgextension\endcsname\relax
+ \expandafter\@secondoftwo
\else
- \expandafter\@gobbletwo
- \fi
- {#1{#2}}}
+ \expandafter\@firstoftwo
+ \fi}
% \end{macrocode}
% \begin{macrocode}
\let\caption@pkgextension\@pkgextension
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\caption@loadpackage}
-% \changes{v1.11}{2020/05/10}{This macro added}
-% |\caption@loadpackage|\marg{package}\marg{caption option}
-% loads the given package immediately.
-% \begin{macrocode}
-\newcommand*\caption@loadpackage{%
- \caption@xpackage\caption@@loadpackage}
-% \end{macrocode}
+% \begin{macro}{\caption@pkg@list}
+% \changes{v1.4b}{2012/01/12}{This macro added}
+% We used this in the past as list of packages loaded
+% |\At|\-|Begin|\-|Document|.
+% (Note: Old |.aux| files could contain
+% |\@cons|\-|\caption@pkg@list|\-|{{|\meta{package}|}}|,
+% so this macro should always be defined, even if we don't use it anymore.)
% \begin{macrocode}
-\newcommand*\caption@@loadpackage[2]{%
- \caption@Info{Option `#2' requires the `#1' package}%
- \RequirePackage{#1}\relax}
+\newcommand*\caption@pkg@list{}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\caption@requirepackage}
% \changes{v1.10}{2020/05/10}{This macro added}
-% |\caption@requirepackage|\marg{package}\marg{caption option}
-% indicates that the given package option needs a package.
+% \changes{v2.0}{2020/07/27}{This macro revised}
+% |\caption@requirepackage|\marg{package}\marg{option}\marg{value}\\
+% indicates that the given package option needs a package.
% \begin{macrocode}
-\newcommand*\caption@requirepackage{%
- \caption@xpackage\caption@@requirepackage}
+\newcommand*\caption@requirepackage[2]{%
+ \caption@ifpackageloaded{#1}{}{\caption@@requirepackage{#1}{#2}}}
% \end{macrocode}
% \begin{macrocode}
\newcommand*\caption@@requirepackage[2]{%
- \@cons\caption@packagelist{{#1}{#2}}}% load package later on
+ \@cons\caption@packagelist{{#1}{#2}}} % load package later on
% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\caption@pkg@list}
-% \changes{v1.4b}{2012/01/12}{This macro added}
-% We used this in the past as list of packages loaded |\AtBeginDocument|.
-% (Note: Old |.aux| files could contain |\@cons|\-|\caption@pkg@list|\-|{{|\meta{package}|}}|,
-% so this macro should always be defined, even if we change the following code in the future.)
% \begin{macrocode}
-\newcommand*\caption@pkg@list{}
+\caption@AtBeginDocument{%
+ \renewcommand*\caption@@requirepackage[2]{%
+ \caption@Error{Option `#2' requires the `#1' package}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\caption@packagelist}
% \changes{v1.11}{2020/05/10}{This macro added}
-% We use this as list of packages loaded |\AtBeginDocument|.
+% We use this as list of packages loaded |\At|\-|Begin|\-|Document|.
% \begin{macrocode}
\newcommand*\caption@packagelist{}
\@onlypreamble\caption@packagelist
@@ -3071,45 +3331,131 @@
\g@addto@macro\caption@tempa{%
\caption@loadpackage{#1}{#2}}}%
\caption@packagelist
- \caption@tempa
+ \caption@tempa}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\caption@loadpackage}
+% \changes{v1.11}{2020/05/10}{This macro added}
+% \changes{v2.0}{2020/07/26}{This macro revised}
+% |\caption@loadpackage|\marg{package}\marg{option}\marg{value}\\
+% loads the given package immediately.
+% \begin{macrocode}
+\newcommand*\caption@loadpackage[2]{%
+ \caption@ifpackageloaded{#1}{}{\caption@@loadpackage{#1}{#2}}}
+% \end{macrocode}
+% \begin{macrocode}
+\newcommand*\caption@@loadpackage[2]{%
+ \caption@Info{Option `#2' requires the `#1' package}%
+ \RequirePackage{#1}\relax}
% \end{macrocode}
% \begin{macrocode}
- \renewcommand*\caption@@loadpackage[2]{%
- \caption@Error{Option `#2' requires the `#1' package}}%
- \let\caption@@requirepackage\caption@@loadpackage
- }
+\caption@AtBeginDocument{%
+ \let\caption@@loadpackage\caption@@requirepackage}
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\caption@usepackage}
-% \changes{v1.11}{2020/05/10}{This macro added}
-% |\caption@usepackage|\marg{package}\marg{option}\marg{code}
-% loads the given package and executes the given code.
-% (Note: Since the package might use the crappy \package{keyval}
-% package, too, we need to save \& restore some macros here, otherwise this
-% recursion won't work properly.)
+% \subsection{The floatrow package}
+% \changes{v2.0}{2020/07/28}{Adaptions to the \package{floatrow} package added}
+%
+% Since the \package{floatrow} package is not maintained anymore,
+% we have to make adaptions to \thispackage~\version{2.0} here.
+% Please note that we only support the version $0.3b$ of the \package{floatrow} package,
+% so older versions do not work with this version of \thispackage, and newer
+% versions are expected to be adapted.
+%
% \begin{macrocode}
-\newcommand*\caption@usepackage[3]{%
- \IfCaptionOptionCheck
- {\caption@requirepackage{#1}{#2}}%
- {\let\KV@prefix@ORI\KV@prefix
- \let\@tempc@ORI\@tempc
- \caption@loadpackage{#1}{#2}%
- #3%
- \let\@tempc\@tempc@ORI
- \let\KV@prefix\KV@prefix@ORI}}
+\caption@AtBeginDocument{%
+ \def\@tempa{2008/08/02 v0.3b floatrow: float package extension}%
+ \expandafter\ifx\csname ver@floatrow.sty\endcsname\@tempa
+ \caption@InfoNoLine{floatrow package v0.3b is loaded}%
+% \end{macrocode}
+%
+% \begin{macro}{\captionlabel}
+% |\caption@format| needs to be expanded prior the use of |\caption@@@make|.
+% \begin{macrocode}
+ \renewcommand\captionlabel[1]{{% l.559
+ \def\FR@tmp{\@captype}%
+ \ifnum\floatbox@depth>\@ne
+ \def\FR@tmp{sub\@captype}\caption@setsubtype*{\FR@tmp}\stepcounter{\FR@tmp}%
+ \fi
+ \caption@format % <= This line added
+ \caption@@@make{\caption@fnum\FR@tmp}{#1}}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\flrow@setstyle}
+% This patch isn't working since |\flrow@setstyle| will be used by
+% \package{floatrow} right after loading \package{caption3}.
+% For this reason we still define |\caption@sty@|\meta{name} in
+% |\Declare|\-|Caption|\-|Style| instead.
+% \begin{macrocode}
+% \renewcommand*\flrow@setstyle[1]{% l.986
+% \@ifundefined{flrow@sty@#1}%
+% {\flrow@error{Undefined float style `#1'}}%
+% {\FBstyle@reset
+% \def\flrow@capsetup{%
+% \caption@ifdecl{style}{#1}{\caption@setstyle*{#1}}{}%
+% \caption@setoptions{#1}}%
+% \flrow@esetup{\csname flrow@sty@#1\endcsname}}}
+% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\flrow@FBoAlign}
+% This patch isn't working since |\flrow@FBoAlign| will be used by
+% \package{floatrow} right after loading \package{caption3}.
+% For this reason we still define |\caption@hj@|\meta{name} in
+% |\Declare|\-|Caption|\-|Justification| instead.
+% \begin{macrocode}
+% \renewcommand*\flrow@FBoAlign[1]{% l.1168
+% \caption@ifdecl{justification}{#1}%
+% {\expandafter\let\expandafter\floatobjectset
+% \csname caption@justification@#1\endcsname}%
+% {\flrow@error{Undefined object setting `#1'}}}%
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\flrow@setFRsep}
+% This patch isn't working since |\flrow@setFRsep| will be used by
+% \package{floatrow} right after loading \package{caption3}.
+% For this reason we still define |\caption@lsep@|\meta{name} in
+% |\Declare|\-|Caption|\-|Label|\-|Separator| instead.
+% \begin{macrocode}
+% \renewcommand*\flrow@setFRsep[2]{% l.1187
+% \caption@ifdecl{labelseparator}{#2}%
+% {\@nameuse{caption@labelseparator@#2}% defines \caption@labelsep
+% \let#1\caption@labelsep}%
+% {\flrow@error{Undefined float separator `#2'}}}%
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+ \fi}
+% \end{macrocode}
+%
% \subsection{The newfloat package}
%
% \begin{macro}{\caption@newfloat}
% \changes{v1.4b}{2012/01/12}{This macro added}
% \changes{v1.8h}{2020/01/03}{Usage of \cs{caption@ifpackageloaded} replaced by \cs{RequirePackage}}
% \changes{v1.11}{2020/05/10}{Usage of \cs{RequirePackage} replaced by \cs{caption@usepackage}}
-% |\caption@newfloat|\marg{option}\marg{code}
-% loads the \package{newfloat} package and executes the given code afterwards.
-% \begin{macrocode}
-\newcommand*\caption@newfloat{\caption@usepackage{newfloat}}
+% \changes{v2.0}{2020/07/27}{This macro revised}
+% |\caption@newfloat|\marg{option}\marg{value}\marg{code}\\
+% loads the \package{newfloat} package and executes the given code afterwards.
+% (Note: Since the package might use the crappy \package{keyval}
+% package, too, we need to save \& restore some macros here, otherwise this
+% recursion won't work properly.)
+% \begin{macrocode}
+\newcommand*\caption@newfloat[2]{%
+ \IfCaptionOptionCheck
+ {\caption@requirepackage{newfloat}{#1}}%
+ {\let\KV@prefix@ORI\KV@prefix
+ \let\@tempc@ORI\@tempc
+ \caption@loadpackage{newfloat}{#1}%
+ #2%
+ \let\@tempc\@tempc@ORI
+ \let\KV@prefix\KV@prefix@ORI}}
+% \end{macro}
% \end{macrocode}
% \end{macro}
%
@@ -3138,8 +3484,9 @@
% \changes{v1.2b}{2008/08/02}{Bugfix: Works now without \cs{addto}, too}
% \changes{v1.4a}{2011/10/29}{Outsourced to \package{newfloat} package}
% \changes{v1.4b}{2012/01/12}{Bugfix: Uses \cs{caption@newfloat} now}
-% |\caption@SetName|\marg{float}\marg{name}
-% \begin{macrocode}
+% |\caption@SetName|\marg{float}\marg{name}\\
+% loads the \package{newfloat} package and uses |\newfloat@set|\-|name|.
+% \begin{macrocode}
\newcommand*\caption@SetName[2]{%
\caption@newfloat{#1name}{\newfloat@setname{#1}{#2}}}
\@onlypreamble\caption@SetName
@@ -3152,7 +3499,8 @@
% \end{macrocode}
%
% \begin{macro}{\caption@setname}
-% |\caption@setname|\marg{float}\marg{name}
+% |\caption@setname|\marg{float}\marg{name}\\
+% sets the given float name, e.g.: `Figure` for `figure`.
% \begin{macrocode}
\newcommand*\caption@setname[2]{%
\@namedef{#1name}{#2}}
@@ -3173,10 +3521,11 @@
% \changes{v1.2}{2007/12/21}{This macro added}
% \changes{v1.4a}{2011/10/29}{Outsourced to \package{newfloat} package}
% \changes{v1.4b}{2012/01/12}{Bugfix: Uses \cs{caption@newfloat} now}
-% |\caption@within|\marg{float}\marg{value}
+% |\caption@within|\marg{float}\marg{value}\\
+% loads the \package{newfloat} package and uses |\newfloat@set|\-|within|.
% \begin{macrocode}
\newcommand*\caption@within[2]{%
- \caption@newfloat{#1within}{\newfloat@setwithin{#1}{#2}}}
+ \caption@newfloat{#1within=#2}{\newfloat@setwithin{#1}{#2}}}
% \end{macrocode}
% \end{macro}
%
@@ -3185,7 +3534,7 @@
%
% \begin{macrocode}
\DeclareCaptionOption{within}{%
- \caption@newfloat{within}{\newfloatsetup{within=#1}}}
+ \caption@newfloat{within=#1}{\newfloatsetup{within=#1}}}
\DeclareCaptionOptionNoValue{without}{%
\caption@newfloat{without}{\newfloatsetup{without}}}
% \end{macrocode}
@@ -3227,14 +3576,15 @@
% \end{macrocode}
%
% \subsection{The subfig package}
-% \changes{v1.1}{2007/07/07}{Several adaptions to the \package{subfig} package added}
+% \changes{v1.1}{2007/07/07}{Adaptions to the \package{subfig} package added}
% \changes{v1.4a}{2011/11/01}{Test for the \package{subfig} package revised}
%
% Since the \package{subfig} package is not maintained anymore,
-% we have to make several adaptions to \thispackage~\version{1.1} here.
-% Please note that we only support the version $1.3$ of the \package{subfig} package here.
-% So older versions do not work with this version of \thispackage, and newer
+% we have to make adaptions to \thispackage~\version{1.1} here.
+% Please note that we only support the version $1.3$ of the \package{subfig} package,
+% so older versions do not work with this version of \thispackage, and newer
% versions are expected to be adapted.
+%
% \begin{macrocode}
\caption@AtBeginDocument{%
\def\@tempa{2005/06/28 ver: 1.3 subfig package}%
@@ -3253,7 +3603,7 @@
% \end{macrocode}
%
% \begin{macro}{\@dottedxxxline}
-% New version of |\@dottedxxxline|
+% New version of |\@dottedxxxline|
% \begin{macrocode}
\def\sf@NEW@dottedxxxline#1#2#3#4#5#6#7{%
\begingroup
@@ -3269,7 +3619,7 @@
%
% \begin{macro}{\sf@subfloat}
% \changes{v1.4b}{2011/12/29}{Bugfix 11-12-23: Usage of \cs{caption@warmup} added}
-% New version of |\sf@subfloat|
+% New version of |\sf@subfloat|
% \begin{macrocode}
\def\sf@NEW@subfloat{%
\begingroup
@@ -3297,21 +3647,10 @@
%
% Make the \package{subfig} package documentation compile.
% \begin{macrocode}
-%%\@ifl@aded{dtx}{subfig}{\caption@loadpackage{ragged2e}{}}{} % not needed
\DeclareCaptionOption{lofdepth}[2]{\caption@ifdefined\c@lofdepth{\setcounter{lofdepth}{#1}}{}}
\DeclareCaptionOption{lotdepth}[2]{\caption@ifdefined\c@lotdepth{\setcounter{lotdepth}{#1}}{}}
% \end{macrocode}
%
-% \section{Execution of options}
-%
-% \begin{macrocode}
-\captionsetup{style=default,position=default,%
- list,listformat=default,twoside=\if@twoside 1\else 0\fi}
-% \end{macrocode}
-% \begin{macrocode}
-\ProcessOptions*
-% \end{macrocode}
-%
% \section{Making an `List of' entry}
%
% \begin{macro}{\caption@addcontentsline}
@@ -3324,10 +3663,9 @@
% \changes{v1.7}{2015/09/15}{Argument \#3 which holds the environment name added to \cs{caption@lstfmt}}
% \changes{v1.7}{2015/09/20}{Unfortunately \package{subfig} defines and uses \cs{caption@lstfmt} as well, so I replaced the third argument with \cs{captionlisttype}}
% \changes{v1.8}{2018/09/06}{Adapted to the \package{chkfloat} package}
-% |\caption@addcontentsline|\marg{type}\marg{list entry}\par
-% Makes an entry in the list-of-whatever, if requested,
-% i.e.~the argument \meta{list entry} is not empty and
-% |listof=| was set to |true|.
+% |\caption@addcontentsline|\marg{type}\marg{list entry}\\
+% makes an entry in the list-of-whatever, if requested, i.e.~the argument
+% \meta{list entry} is not empty and |list|\-|of=| was set to |true|.
% \begin{macrocode}
\newcommand\caption@addcontentsline[2]{%
\caption@ifcontentsline{#2}{%
@@ -3357,7 +3695,7 @@
\caption@add@contentsline
{\csname ext@#1\endcsname}%
{#1}%
- {\caption@lstfmt{\@nameuse{p@#1}}{\@nameuse{the#1}}}%
+ {\caption@listformat{\@nameuse{p@#1}}{\@nameuse{the#1}}}%
{\ignorespaces #2}%
\caption@chkfloat{#1}{#2}}}}
% \end{macrocode}
@@ -3400,39 +3738,54 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\caption@aboveskip}
+% \begin{macro}{\caption@belowskip}
+% \changes{v2.0}{2020/08/23}{This macro moved from package to kernel}
+% |\caption@aboveskip| and |\caption@belowskip|\\
+% typeset the skip above resp.~below the caption.
+% \begin{macrocode}
+\newcommand*\caption@aboveskip{%
+ \vskip\abovecaptionskip}
+% \end{macrocode}
+% \begin{macrocode}
+\newcommand*\caption@belowskip{%
+ \vskip\belowcaptionskip}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
% \begin{macro}{\caption@fnum}
% \changes{v1.1}{2007/08/21}{This macro added}
-% |\caption@fnum|\marg{float type}\par
-% Typesets the caption label; as replacement for |\fnum@|\meta{float type}.
+% \changes{v2.0}{2020/08/03}{The original definition will be stored in \cs{caption@original@fnum}}
+% |\caption@fnum|\marg{float type}\\
+% typesets the caption label; this acts as replacement for |\fnum@|\meta{float type}.
% \begin{macrocode}
-\newcommand*\caption@fnum[1]{\caption@lfmt{\@nameuse{#1name}}{\@nameuse{the#1}}}
+\newcommand*\caption@fnum[1]{%
+ \expandafter\let\expandafter\caption@original@fnum\csname caption@fnum@#1\endcsname % for label format `original'
+ \caption@labelformat{\@nameuse{#1name}}{\@nameuse{the#1}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\caption@make}
-% |\caption@make|\marg{float name}\marg{ref.\ number}\marg{text}\par
-% Typesets the caption.
+% |\caption@make|\marg{float name}\marg{ref.\ number}\marg{text}\\
+% typesets the caption.
% \begin{macrocode}
-\newcommand\caption@make[2]{\caption@@make{\caption@lfmt{#1}{#2}}}
+\newcommand\caption@make[2]{\caption@@make{\caption@labelformat{#1}{#2}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\caption@@make}
% \changes{v1.0b}{2004/05/16}{Bugfix 04-05-05: \cs{ifdim}\cs{captionindent=}\cs{z@} added}
-% \changes{v1.0c}{2005/02/12}{Bugfix 04-10-26: Use \cs{@tempdima} instead of
-% \cs{captionmargin} resp. \cs{captionwidth}; check for \cs{z@} added}
-% \changes{v1.0c}{2005/02/12}{Bugfix: \cs{hskip}\cs{captionmargin} to the end
-% of caption added}
+% \changes{v1.0c}{2005/02/12}{Bugfix 04-10-26: Use \cs{@tempdima} instead of \cs{captionmargin} resp. \cs{captionwidth}; check for \cs{z@} added}
+% \changes{v1.0c}{2005/02/12}{Bugfix: \cs{hskip}\cs{captionmargin} to the end of caption added}
% \changes{v1.0c}{2005/02/12}{Bugfix: \cs{strut} moved from here to \cs{caption@@@make}}
% \changes{v1.0c}{2005/02/12}{Single-line-check moved up so it can affect margins now}
-% \changes{v1.0c}{2005/02/09}{Improvement: \cs{caption@ifh} added}
+% \changes{v1.0c}{2005/02/09}{Improvement: \cs{caption@ifhmode} added}
% \changes{v1.0c}{2005/02/09}{Bugfix: \cs{leavevmode} added}
% \changes{v1.0f}{2005/08/24}{Uses \cs{sbox} instead of \cs{setbox} in single-line-check}
% \changes{v1.0g}{2005/12/04}{Uses \cs{caption@slc} now}
-% \changes{v1.0g}{2006/01/11}{Bugfix: \cs{caption@calcmargin} inside
-% single-line-check replaced by \cs{relax}}
-% \changes{v1.0g}{2006/01/11}{Bugfix: \cs{caption@startbox} will always be
-% typeset in horizontal mode}
+% \changes{v1.0g}{2006/01/11}{Bugfix: \cs{caption@calcmargin} inside single-line-check replaced by \cs{relax}}
+% \changes{v1.0g}{2006/01/11}{Bugfix: \cs{caption@startbox} will always be typeset in horizontal mode}
% \changes{v1.0i}{2006/05/13}{Uses \cs{caption@parbox} instead of \cs{caption@start/endbox}}
% \changes{v1.0j}{2007/01/04}{Oops, bugfix 04-05-05 got lost in v1.0h, re-added}
% \changes{v1.0n}{2007/04/03}{Usage of \cs{caption@ifoddpage} added}
@@ -3443,7 +3796,7 @@
% \changes{v1.6}{2013/05/01}{Usage of \cs{caption@box} added}
% \changes{v1.7}{2016/01/31}{Adapted to the \package{bicaption} package}
% \changes{v1.8f}{2019/12/18}{Usage of \cs{linewidth} replaced by \cs{hsize}}
-% |\caption@@make|\marg{caption label}\marg{caption text}
+% |\caption@@make|\marg{caption label}\marg{caption text}
% \begin{macrocode}
\newcommand\caption@@make[2]{%
\begingroup
@@ -3456,56 +3809,49 @@
\caption@stepthecounter
\caption@beginhook
% \end{macrocode}
-%
-% Typeset the outer box |\caption@box|
+% Typeset the outer box |\caption@box|
% \begin{macrocode}
\caption@box\hsize{%
% \end{macrocode}
-%
-% Special single-line treatment (option |singlelinecheck=|)
+% Special single-line treatment (option |singlelinecheck=|)
% \begin{macrocode}
- \caption@ifslc{\caption@slc{#1}{#2}\caption@singleline\relax}{}%
+ \caption@singlelinecheck{\caption@slc{#1}{#2}\caption@singleline\caption@multiline}{\caption@multiline}%
% \end{macrocode}
-%
-% Typeset the left margin (option |margin=|)
+% Typeset the left margin (option |margin=|)
% \begin{macrocode}
\caption@calcmargin
\caption@tempdima\captionmargin
\ifdim\captionmargin@=\z@ \else
\caption@ifoddpage{}{\advance\caption@tempdima\captionmargin@}%
\fi
- \caption@ifh{\advance\caption@tempdima\caption@indent}%
+ \caption@ifhmode{\advance\caption@tempdima\caption@indent}%
\hspace\caption@tempdima
% \end{macrocode}
-%
-% We actually use a |\vbox| of width |\captionwidth - \caption@indent|
-% to typeset the caption.
-% \Note{\cs{captionindent} is \emph{not} supported if the caption format
-% was defined with \cs{DeclareCaptionFormat*}.}
+% We actually use a |\vbox| of width |\captionwidth - \caption@indent|
+% to typeset the caption.
+% \Note{\cs{captionindent} is \emph{not} supported if the caption format
+% was defined with \cs{DeclareCaptionFormat*}.}
% \begin{macrocode}
\caption@tempdima\captionwidth
- \caption@ifh{\advance\caption@tempdima-\caption@indent}%
+ \caption@ifhmode{\advance\caption@tempdima-\caption@indent}%
\caption@parbox\caption@tempdima{%
% \end{macrocode}
-%
-% Typeset the indention (option |indention=|)\\
-% {\small Bugfix 04-05-05:
-% |\hskip-\caption@indent| replaced by |\ifdim\caption@indent=\z@|\ldots}
+% Typeset the indention (option |indention=|)\\
+% {\small Bugfix 04-05-05:
+% |\hskip-\caption@indent| replaced by |\ifdim\caption@indent=\z@|\ldots}
% \begin{macrocode}
- \caption@ifh{%
+ \caption@ifhmode{%
\ifdim\caption@indent=\z@
\leavevmode
\else
\hskip-\caption@indent
\fi}%
% \end{macrocode}
-%
-% Typeset the caption itself and close the |\caption@parbox|
+% Typeset the caption itself and close the |\caption@parbox|
% \begin{macrocode}
\caption@@@make{#1}{#2}}%
% \end{macrocode}
-%
-% Typeset the right margin (option |margin=|)
+% Typeset the right margin (option |margin=|)
% \begin{macrocode}
\caption@tempdima\captionmargin
\ifdim\captionmargin@=\z@ \else
@@ -3513,12 +3859,10 @@
\fi
\hspace\caption@tempdima
% \end{macrocode}
-%
-% Close the outer box |\caption@box|
+% Close the outer box |\caption@box|
% \begin{macrocode}
}%
% \end{macrocode}
-%
% \begin{macrocode}
\caption@endhook}
% \end{macrocode}
@@ -3534,14 +3878,14 @@
% \changes{v1.1}{2006/05/13}{Check of \cs{@listdepth} removed (not necessary anymore), use \cs{linewidth} instead of \cs{hsize}}
% \changes{v1.5}{2012/12/26}{max-margin stuff moved from \cs{caption@@make} to here}
% \changes{v1.8f}{2019/12/18}{Usage of \cs{linewidth} replaced by \cs{hsize}}
-% |\caption@calcmargin|\par
-% Calculate |\captionmargin| \& |\captionwidth|, so both contain valid
-% values.
+% |\caption@calcmargin|\\
+% calculates |\caption|\-|margin| and |\caption|\-|width|, so both contain
+% valid values.
% \begin{macrocode}
\newcommand*\caption@calcmargin{%
\caption@calcmargin@hook
% \end{macrocode}
-% Check margin, if |\caption@minmargin| or |\caption@maxmargin| is set
+% Check margin, if |\caption@min|\-|margin| or |\caption@max|\-|margin| is set
% \begin{macrocode}
\ifx\caption@maxmargin\@undefined \else
\ifdim\captionmargin>\caption@maxmargin\relax
@@ -3579,23 +3923,22 @@
% \end{macro}
%
% \begin{macro}{\caption@slc}
-% \changes{v1.1}{2007/06/13}{\cs{let}\cs{caption@hj}\cs{relax} added}
-% \changes{v1.1}{2007/07/29}{\cs{caption@setup}\cs{caption@sls} added after \cs{begingroup}}
+% \changes{v1.1}{2007/06/13}{\cs{let}\cs{caption@justification}\cs{relax} added}
+% \changes{v1.1}{2007/07/29}{\cs{caption@setup}\cs{\caption@sls} added after \cs{begingroup}}
% \changes{v1.1}{2007/07/29}{\cs{caption@calcmargin} added}
-% \changes{v1.1c}{2007/10/14}{Support of \cs{caption@slfmt} added}
-% \changes{v1.1d}{2007/10/23}{`SingleLine' renamed to `singleline' for consistency}
+% \changes{v1.1c}{2007/10/14}{\cs{caption@setup}\cs{\caption@opt@SingleLine} outsourced to \cs{caption@SingleLine}}
% \changes{v1.3}{2010/09/04}{Split into \cs{caption@slc} and \cs{caption@@slc}}
% \changes{v1.5}{2012/12/26}{Merged into a single macro again}
-% \changes{v1.5}{2013/04/14}{Definition and usage of \cs{ifsinglelinecaption} added}
-% |\caption@slc|\marg{label}\marg{text}\marg{single-line-code}\marg{multi-line-code}\par
-% This one does the single-line-check.
+% \changes{v1.5}{2013/04/14}{Usage of \cs{ifsinglelinecaption} added}
+% |\caption@slc|\marg{label}\marg{text}\marg{single-line-code}\marg{multi-line-code}\\
+% This one does the single-line-check.
% \begin{macrocode}
\newcommand\caption@slc[4]{%
\caption@Debug{Begin SLC}%
\singlelinecaptiontrue
\begingroup
\caption@singleline
- \let\caption@hj\@empty
+ \let\caption@justification\relax
\caption@calcmargin % calculate \captionwidth
\caption@prepareslc
\sbox\@tempboxa{\caption@@@make{#1}{#2}}%
@@ -3609,47 +3952,72 @@
\fi
\caption@Debug{End SLC}}
% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ifsinglelinecaption}
+% \changes{v1.5}{2013/04/14}{This definition added}
+% |\ifsinglelinecaption|\\
+% could be used inside own caption formats to test if the caption is
+% currently typeset as single-line caption (or not).
% \begin{macrocode}
\newif\ifsinglelinecaption
% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\caption@singleline}
+% \changes{v1.1c}{2007/10/14}{This macro extracted from \cs{caption@slc}}
+% \changes{v1.1c}{2007/10/14}{Support of \cs{caption@slfmt} added}
+% \changes{v1.1d}{2007/10/23}{This macro renamed from \cs{caption@SingleLine} to \cs{caption@singleline} for consistency}
+% |\caption@singleline|\\
+% prepares the typesetting of a single-line caption.
% \begin{macrocode}
\newcommand*\caption@singleline{%
- \caption@xsetup\caption@opt@singleline
+ \caption@xsetup\caption@slsty % Note: This could change \caption@format
+ \caption@format % defines \caption@ifhmode, \caption@slfmt, and \caption@fmt
\let\caption@fmt\caption@slfmt}
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\caption@multiline}
+% \changes{v2.0}{2020/07/28}{This macro added}
+% |\caption@multiline|\\
+% prepares the typesetting of a multi-line caption.
+% \begin{macrocode}
+\newcommand*\caption@multiline{%
+ \caption@format} % defines \caption@ifhmode, \caption@slfmt, and \caption@fmt
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macro}{\caption@prepareslc}
% \changes{v1.0b}{2004/05/16}{Bugfix: Redefinition of \cs{label} \& \cs{@footnotetext} added}
% \changes{v1.0b}{2004/05/16}{Redefine \cs{stepcounter} instead of \cs{footnote(mark)}}
-% \changes{v1.0c}{2005/02/12}{\cs{let}\cs{caption@hj}\cs{relax} added}
+% \changes{v1.0c}{2005/02/12}{\cs{let}\cs{caption@justification}\cs{relax} added}
% \changes{v1.0f}{2005/07/09}{Support of \package{endnotes} package added}
-% \changes{v1.1}{2007/06/13}{\cs{let}\cs{caption@hj}\cs{relax} moved to \cs{caption@slc}}
+% \changes{v1.1}{2007/06/13}{\cs{let}\cs{caption@justification}\cs{relax} moved to \cs{caption@slc}}
% \changes{v1.1}{2007/06/13}{Redefinition of \cs{(H@)refstepcounter} added}
% \changes{v1.1}{2007/08/12}{Redefinition of \cs{label} improved}
% \changes{v1.1c}{2007/10/06}{Definition of \cs{caption@l@stepcounter} added}
% \changes{v1.3}{2011/07/07}{Bugfix 11-07-06: Redefinition of \cs{footnote} and \cs{footnotemark} added, redefinition of \cs{stepcounter} and \cs{refstepcounter} dropped}
-% \changes{v1.4a}{2011/10/21}{Redefinition of \cs{pagenote} from \textsf{memoir} document class added}
% \changes{v1.4a}{2011/10/22}{Redefinition of \cs{footnote} revised}
% \changes{v1.5}{2013/04/13}{Redefinition os \cs{glsunset} added}
% \changes{v1.8}{2018/01/21}{Redefinition of \cs{endnote} added (thanks to Markus Kohm)}
% \changes{v1.8}{2018/05/16}{Redefinition of \cs{acused} added}
% \changes{v1.8}{2018/05/26}{Definition method changed so it can be pre-defined by other packages}
% \changes{v1.8}{2018/05/27}{Redefinition of \cs{hypertarget} added}
-% \changes{v1.12b}{2020/07/20}{Special adaption to \class{beamer} added}
-% |\caption@prepareslc|\par
-% Re-define anything which would disturb the single-line-check.
+% |\caption@prepareslc|\\
+% re-defines anything which could disturb the single-line-check.
% \begin{macrocode}
\providecommand*\caption@prepareslc{}
\g@addto@macro\caption@prepareslc{%
\let\label\caption@gobble
\let\hypertarget\@gobbletwo
% \end{macrocode}
-% We re-define \cs{footnote} so
-% \begin{enumerate}
-% \item The footnote counter will not be increased twice (but still the correct footnote mark will be used within the single-line-check)
-% \item The footnote text will not be evaluated twice
-% \end{enumerate}
+% We re-define \cs{footnote} so
+% \begin{enumerate}
+% \item The footnote counter will not be increased twice (but still the
+% correct footnote mark will be used within the single-line-check)
+% \item The footnote text will not be evaluated twice
+% \end{enumerate}
% \begin{macrocode}
\let\caption@footnote@ORI\footnote
\def\footnote{\caption@withoptargs\caption@footnote}%
@@ -3658,7 +4026,7 @@
\let\caption@footnotetext@ORI\@footnotetext
\let\@footnotetext\caption@gobble
% \end{macrocode}
-% Same for \cs{endnote}
+% Same for \cs{endnote}
% \begin{macrocode}
\let\caption@endnote@ORI\endnote
\def\endnote{\caption@withoptargs\caption@endnote}%
@@ -3667,22 +4035,19 @@
\let\caption@endnotetext@ORI\@endnotetext
\let\@endnotetext\caption@gobble
% \end{macrocode}
-% \begin{macrocode}
- \let\pagenote\caption@gobble
-% \end{macrocode}
-% Adaption to the \package{acronym} package\par
-% See also \url{https://tex.stackexchange.com/questions/428788}
+% Adaption to the \package{acronym} package\par
+% See also \url{https://tex.stackexchange.com/questions/428788}
% \begin{macrocode}
\let\acused\@gobble
\let\AC@placelabel\@gobble
% \end{macrocode}
-% Adaption to the \package{glossaries} package.\par
-% Please note that while this adaption is usually sufficient
-% it could give incorrect measuring results if \cs{gls} is both used
-% for the very first time and more than once (for a particular acronym).
-% The alternative would be using internal macros of the
-% \package{glossaries} package which I would like to avoid.\par
-% See also \url{https://tex.stackexchange.com/questions/108368}
+% Adaption to the \package{glossaries} package.\par
+% Please note that while this adaption is usually sufficient
+% it could give incorrect measuring results if \cs{gls} is both used
+% for the very first time and more than once (for a particular acronym).
+% The alternative would be using internal macros of the
+% \package{glossaries} package which I would like to avoid.\par
+% See also \url{https://tex.stackexchange.com/questions/108368}
% \begin{macrocode}
\let\glsunset\@gobble
% \end{macrocode}
@@ -3715,88 +4080,66 @@
\newcommand*\caption@l@stepcounter[1]{%
\advance\csname c@#1\endcsname\@ne\relax}
% \end{macrocode}
-% The patch above assumes that the optional arguments of \cs{footnote} and
-% \cs{footnotemark} match. Since this is not the case in \class{beamer} based documents,
-% and since \class{beamer} extents the syntax of \cs{footnote} in a special way,
-% we need a special patch here.\par
-% \emph{Note:} For this patch we assume that \cs{footnote} will always end with the usage of
-% \cs{beamer@footnotetext}. (Unfortunately \cs{footnote} is defined too monolithic
-% in \class{beamer} to offer a less dirty patch.)
-% \begin{macrocode}
-\caption@ifclassloaded{beamer}{%
- \g@addto@macro\caption@prepareslc{%
- \def\footnote{%
- \begingroup
- \let\stepcounter\caption@l@stepcounter
- \renewcommand<>\beamer@framefootnotetext[1]{%
- \endgroup}%
- \let\@footnotetext\beamer@framefootnotetext
- \caption@footnote@ORI}}}{}
-% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\caption@applyfont}
% \changes{v1.3}{2010/09/04}{This macro added}
-% |\caption@applyfont|\par
-% This macro executes the font relevant macros, i.e. by default
-% the options set by |justification=|, |font=|, and |size=|.
+% |\caption@applyfont|\\
+% applies the relevant font settings, i.e. by default
+% the options set by |justification=|, |font=|, and |size=|.
% \begin{macrocode}
\newcommand*\caption@applyfont{%
- \caption@hj\captionfont\captionsize}
+ \caption@justification\captionfont\captionsize}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\caption@@@make}
% \changes{v1.0b}{2004/05/16}{Bugfix 04-05-06: \cs{allowhyphens} added}
-% \changes{v1.0c}{2005/02/12}{Bugfix 04-12-16: Use some kind of
-% \cs{@startstrut}\cs{strutbox} instead of \cs{strut}}
+% \changes{v1.0c}{2005/02/12}{Bugfix 04-12-16: Use some kind of \cs{@startstrut}\cs{strutbox} instead of \cs{strut}}
% \changes{v1.0c}{2005/02/12}{Bugfix 05-01-23: \cs{@finalstrut}\cs{strutbox} added}
-% \changes{v1.0d}{2005/05/05}{Use \cs{caption@ifempty};
-% \cs{let}\cs{caption@ifstrut}\cs{@secondoftwo} added}
+% \changes{v1.0d}{2005/05/05}{Use \cs{caption@ifempty}; \cs{let}\cs{caption@ifstrut}\cs{@secondoftwo} added}
% \changes{v1.0d}{2005/05/05}{Bugfix: Handling of \cs{ifcaption@star} changed}
% \changes{v1.0f}{2005/08/24}{Check for empty label added}
% \changes{v1.0f}{2005/08/25}{\cs{caption@iflf} added}
-% \changes{v1.0j}{2007/02/18}{Usage of \cs{caption@tfmt} added}
+% \changes{v1.0j}{2007/02/18}{Usage of \cs{caption@textformat} added}
% \changes{v1.1}{2007/05/07}{Bugfix: \cs{ifhmode} added to \cs{@finalstrut}}
% \changes{v1.2}{2007/11/17}{Made option \opt{size=} stronger than \opt{font=}}
% \changes{v1.3}{2010/09/04}{Uses \cs{caption@applyfont} now}
% \changes{v1.3}{2010/11/01}{Bugfix: If the caption text is empty, the text format will be set to \opt{simple} now}
-% \changes{v1.7}{2016/02/01}{Bugfix: \cs{relax} added before \cs{caption@lsep} so the label separator
-% will not be gobbled if the label font command ignores spaces, e.g. by usage of \cs{color}}
-% \changes{v1.8}{2018/09/12}{\cs{par} replaced by \cs{captiontextend}}
-% |\caption@@@make|\marg{caption label}\marg{caption text}\par
-% This one finally typesets the caption paragraph, without margin and indention.
+% \changes{v1.7}{2016/02/01}{Bugfix: \cs{relax} added before \cs{caption@lsep} so the label separator will not be gobbled if the label font command ignores spaces, e.g. by usage of \cs{color}}
+% \changes{v1.8}{2018/09/12}{\cs{par} replaced by \cs{caption@textend}}
+% |\caption@@@make|\marg{caption label}\marg{caption text}\\
+% This one finally typesets the caption paragraph, without margin and indention.
% \begin{macrocode}
\newcommand\caption@@@make[2]{%
% \end{macrocode}
-%
-% If the label is empty, we use no caption label separator.
+% If the label is empty, we use no caption label separator.
% \begin{macrocode}
\sbox\@tempboxa{#1}%
\ifdim\wd\@tempboxa=\z@
- \let\caption@lsep\relax
+ \caption@set{labelseparator}{none}%
% \@capbreakfalse
\fi
% \end{macrocode}
-%
-% If the text is empty, we use no caption label separator, too.
-% (And no text format either.)
+% If the text is empty, we use no caption label separator, too.
+% (And no text format either.)
% \begin{macrocode}
\caption@ifempty{#2}{%
- \let\caption@lsep\@empty
- \let\caption@tfmt\@firstofone
+ \caption@set{labelseparator}{none}%
+ \caption@set{textformat}{simple}%
% \@capbreakfalse
% \let\caption@ifstrut\@secondoftwo
}%
% \end{macrocode}
-%
-% Take care that |\caption@parindent| and |\caption@hangindent| will be used
-% to typeset the paragraph.
+% \begin{macrocode}
+ \caption@labelseparator % defines \caption@iflabelfont, \caption@labelsep and \caption@labelsep@name (the latter is needed by \caption@fmt)
+% \end{macrocode}
+% Take care that |\caption@par|\-|indent| and |\caption@hang|\-|indent|
+% will be used to typeset the paragraph.
% \begin{macrocode}
\@setpar{\@@par\caption@@par}\caption@@par
% \end{macrocode}
-%
-% Finally typeset the caption.
+% Finally typeset the caption.
% \begin{macrocode}
\caption@applyfont
\caption@fmt
@@ -3808,26 +4151,26 @@
\fi}%
{\ifcaption@star\else
\begingroup
- \caption@iflf\captionlabelfont
- \relax\caption@lsep
+ \caption@iflabelfont\captionlabelfont
+ \relax\caption@labelsep
\endgroup
\fi}%
{{\captiontextfont
- \captiontextstart
+ \caption@textstart
\caption@ifstrut
{\vrule\@height\ht\strutbox\@width\z@}%
{}%
\nobreak\hskip\z@skip % enable hyphenation
- \caption@tfmt{#2}%
+ \caption@textformat{#2}%
% \caption@ifstrut{\vrule\@height\z@\@depth\dp\strutbox\@width\z@}{}%
\caption@ifstrut
{\ifhmode\@finalstrut\strutbox\fi}%
{}%
- \captiontextend}}}
+ \caption@textend}}}
% \end{macrocode}
% \begin{macrocode}
-\newcommand*\captiontextstart{}
-\newcommand*\captiontextend{\par}
+\newcommand*\caption@textstart{}
+\newcommand*\caption@textend{\par}
% \end{macrocode}
% \end{macro}
%
@@ -3836,12 +4179,12 @@
% \changes{v1.1}{2007/07/04}{Re-defines itself now}
% \changes{v1.2a}{2007/01/22}{Revised so \cs{label} will be detected, too}
% \changes{v1.2b}{2008/08/02}{Revised so \cs{index} and \cs{glossary} will be detected, too}
-% |\caption@ifempty|\marg{text}\marg{true} (\emph{no} \meta{false})\par
-% This one tests if the \meta{text} is actually empty.
-% \Note{This will be done without expanding the text,
-% therefore this is far away from being bullet-proof.}
-% \Note{This macro is re-defining itself so only
-% the first test (in a group) will actually be done.}
+% |\caption@ifempty|\marg{text}\marg{yes-code}\\
+% tests if the \meta{text} is actually empty.
+% \Note{This will be done without expanding the text,
+% therefore this is far away from being bullet-proof.}
+% \Note{This macro is re-defining itself so only
+% the first test (in a group) will actually be done.}
% \begin{macrocode}
\newcommand\caption@ifempty[1]{%
\caption@if@empty{#1}%
@@ -3890,8 +4233,8 @@
%
% \begin{macro}{\caption@@par}
% \changes{v1.0f}{2005/08/22}{Made this definition global}
-% |\caption@@par|\par
-% This command will be executed with every |\par| inside the caption.
+% |\caption@@par|\\
+% will be expanded with every |\par| inside the caption.
% \begin{macrocode}
\newcommand*\caption@@par{%
\parindent\caption@parindent\hangindent\caption@hangindent}%
@@ -3909,36 +4252,58 @@
% \changes{v1.2b}{2008/08/02}{Support of \cs{float@exts} and \cs{float@addtolists} added}
% \changes{v1.2e}{2010/01/09}{Usage of \cs{caption@DeclareWithinOption} added}
% \changes{v1.3}{2011/08/06}{Definition of \cs{listofXXXes} added}
-% \changes{v1.4a}{2011/10/29}{Outsourced as \package{newfloat} package}
-% |\DeclareCaptionType|\oarg{options}\marg{environment}\oarg{name}\oarg{list name}
+% \changes{v1.4a}{2011/10/29}{Outsourced to \package{newfloat} package}
+% |\DeclareCaptionType|\oarg{options}\marg{environment}\oarg{name}\oarg{list name}\\
+% loads the \package{newfloat} package and uses |\Declare|\-|Floating|\-|Environment|.
% \begin{macrocode}
\newcommand*\DeclareCaptionType{%
- \caption@loadpackage{newfloat}{}%
+ \caption@loadpackage{newfloat}{declare type}%
\DeclareFloatingEnvironment}
\@onlypreamble\DeclareCaptionType
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\caption@ForEachType}
+% \begin{macro}{\ForEachCaptionType}
% \changes{v1.4a}{2011/10/29}{This macro added}
-% |\caption@ForEachType|\marg{code}
-% will execute the given code for all (known) floating environments.
+% \changes{v1.13}{2020/07/29}{Renamed from \cs{caption@ForEachType} to \cs{ForEachCaptionType} and starred variant added}
+% |\ForEachCaptionType*|\marg{code with \#1}\\
+% will execute the given code for each (known) floating environment.
+% The starred variant will only work for already existing environments,
+% i.e.~no hook will be placed inside |\Declare|\-|Floating|\-|Environment|
+% (offered by the \package{newfloat} package).
+% \begin{macrocode}
+\newcommand*\ForEachCaptionType{%
+ \@ifstar
+ {\caption@foreach@type\@gobble}%
+ {\caption@foreach@type\@iden}}
+% \end{macrocode}
% \begin{macrocode}
-\newcommand\caption@ForEachType[1]{%
+\newcommand\caption@foreach@type[2]{%
\caption@ifdefined\ForEachFloatingEnvironment
- {\ForEachFloatingEnvironment{#1}}%
- {\def\@elt##1{#1}%
+ {\ForEachFloatingEnvironment*{#2}}%
+ {\def\@elt##1{#2}%
\caption@ifdefined\c@figure\@elt\@gobble{figure}%
\caption@ifdefined\c@table\@elt\@gobble{table}%
- \let\@elt\relax
- \newfloat@addtohook{#1}}}
+ \let\@elt\relax}%
+ #1{\newfloat@addtohook{#2}}}
% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\newfloat@addtohook}
+% |\newfloat@addtohook|\marg{code with \#1}\\
+% adds code to the hook called in |\Declare|\-|Floating|\-|Environment|.\par
+% Note: We use |\provide|\-|command| instead of |\new|\-|command| here since the
+% exact same code is defined in the \package{newfloat} package.
% \begin{macrocode}
\providecommand\newfloat@addtohook[1]{%
\toks@=\expandafter{\newfloat@hook{##1}#1}%
\edef\@tempa{\def\noexpand\newfloat@hook####1{\the\toks@}}%
\@tempa}
% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\newfloat@hook}
+% Hook used in |\Declare|\-|Floating|\-|Environment|.
% \begin{macrocode}
\providecommand*\newfloat@hook[1]{}
% \end{macrocode}
@@ -3954,11 +4319,13 @@
% \changes{v1.5}{2013/01/10}{Bugfix: Definition of autoref string corrected}
% \changes{v1.6}{2013/06/17}{Bugfix: \cs{c@tocdepth} will be set (locally) now}
% \changes{v1.8g}{2020/01/02}{Check revised if the sub-type is already defined or not}
-% |\DeclareCaptionSubType|\oarg{numbering scheme}\marg{type}\\
-% |\DeclareCaptionSubType*|\oarg{numbering scheme}\marg{type}\par
-% The starred variant provides the numbering format
-% \meta{type}|.|\meta{subtype} while the non-starred variant simply
-% uses \meta{subtype}.
+% \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)}
+% |\DeclareCaptionSubType*|\oarg{numbering scheme}\marg{type}\\
+% The starred variant provides the numbering format
+% \meta{type}|.|\meta{subtype} while the non-starred variant simply uses
+% \meta{subtype}.
% \begin{macrocode}
\newcommand*\DeclareCaptionSubType{%
\caption@teststar\caption@declaresubtype\@firstoftwo\@secondoftwo}
@@ -3973,39 +4340,42 @@
\def\caption@@declaresubtype#1[#2]#3{%
\@ifundefined{c@#3}%
{\caption@Error{No float type '#3' defined}}%
+ {\caption@@@declaresubtype{#1}{#2}{#3}{sub#3}}}
+\@onlypreamble\caption@@declaresubtype
% \end{macrocode}
-% Check if the sub-type was already defined by |\Declare|\-|Sub|\-|Type|.
-% If not, define the counter and list entry.
% \begin{macrocode}
- {\caption@ifsubtype{sub#3}%
- {\caption@Debug{Modify subtype `sub#3'}}%
- {\caption@Debug{New subtype `sub#3'}%
- \@ifundefined{c@sub#3}%
- {\newcounter{sub#3}\relax}%
- {\caption@Warning{Using already defined counter `sub#3'}}%
- \@addtoreset{sub#3}{#3}%
- \@namedef{ext@sub#3}{\csname ext@#3\endcsname}%
- \caption@declaresublistentry{#3}%
- \@cons\caption@subtypelist{{#3}}}%
+\newcommand*\caption@@@declaresubtype[4]{%
% \end{macrocode}
-% Support of \package{titletoc} package
% \begin{macrocode}
- \caption@ifdefined\contentsuse{%
- \contentsuse{sub#3}{\csname ext@sub#3\endcsname}}{}%
+% Check if the sub-type was already defined by |\Declare|\-|Sub|\-|Type|.
+% If not, define the counter and list entry.
+% \begin{macrocode}
+ \caption@ifin@list\caption@subtypelist{#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}}%
% \end{macrocode}
+% Support of \package{titletoc} package
% \begin{macrocode}
- \@namedef{sub#3name}{}%
- \@namedef{sub#3autorefname}{\csname #3autorefname\endcsname}%
- #1% is \@firstoftwo in star form, and \@secondoftwo otherwise
- {\@namedef{p@sub#3}{}%
- \@namedef{thesub#3}{\csname the#3\endcsname.\@nameuse{#2}{sub#3}}}%
- {\@namedef{p@sub#3}{\csname the#3\endcsname}%
- \@namedef{thesub#3}{\@nameuse{#2}{sub#3}}}%
- \@namedef{theHsub#3}{\csname theH#3\endcsname.\arabic{sub#3}}%
- }}
+ \caption@ifdefined\contentsuse{%
+ \contentsuse{#4}{\csname ext@#4\endcsname}}{}%
% \end{macrocode}
% \begin{macrocode}
-\@onlypreamble\caption@@declaresubtype
+ \@namedef{#4name}{}%
+ \@namedef{#4autorefname}{\csname #3autorefname\endcsname}%
+ #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}}}
+% \end{macrocode}
+% \begin{macrocode}
+\@onlypreamble\caption@@@declaresubtype
% \end{macrocode}
% \begin{macrocode}
\newcommand*\caption@declaresublistentry{%
@@ -4026,12 +4396,12 @@
% \begin{macrocode}
\long\def\caption@@@declaresublistentry#1\@dottedtocline#2\caption@nil#3{%
\def\@tempa{#1}%
-% Does \l@(sub)subsection start with \@dottedtocline?
+% Does \l@(sub)subsection start with \@dottedtocline?
\ifx\@tempa\@empty
-% Yes
+% Yes
\caption@@@@declaresublistentry{#3}#2\caption@nil
\else
-% No
+% No
\caption@@@@declaresublistentry{#3}@{3.8em}{3.2em}\caption@nil
\fi}
\@onlypreamble\caption@@@declaresublistentry
@@ -4067,8 +4437,8 @@
% \end{macro}
%
% \begin{macro}{\caption@subtypelist}
-% An \cs{@elt}-list containing the subtypes defined
-% with |\Declare|\-|Caption|\-|Sub|\-|Type|.
+% A list containing the sub-types defined with
+% |\Declare|\-|Caption|\-|Sub|\-|Type|.
% \begin{macrocode}
\newcommand*\caption@subtypelist{}
% \end{macrocode}
@@ -4076,53 +4446,68 @@
%
% \begin{macro}{\caption@ifsubtype}
% \changes{v1.8g}{2020/01/02}{This macro added}
-% This macro checks if the given subtype was defined
-% with |\Declare|\-|Caption|\-|Sub|\-|Type| or not.
+% \changes{v1.13}{2020/07/28}{Uses \cs{caption@ifin@list} now}
+% |\caption@ifsubtype|\marg{yes-code}\marg{no-code}\\
+% checks if the given subtype was defined with
+% |\Declare|\-|Caption|\-|Sub|\-|Type|.
% \begin{macrocode}
-\newcommand*\caption@ifsubtype[1]{%
- \begingroup
- \let\next\@secondoftwo
- \edef\@tempa{#1}%
- \def\@elt##1{%
- \def\@tempb{sub##1}%
- \ifx\@tempa\@tempb
- \let\next\@firstoftwo
- \fi}%
- \caption@subtypelist
- \expandafter\endgroup\next}
+\newcommand*\caption@ifsubtype{%
+ \caption@ifin@list\caption@subtypelist}
+% \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}\\
+% will execute the given code for each (known) sub-type.
+% The starred variant will only work for already existing sub-types,
+% i.e.~no hook will be placed inside |\Declare|\-|Caption|\-|Sub|\-|Type|.
+% \begin{macrocode}
+\newcommand*\ForEachCaptionSubType{%
+ \@ifstar
+ {\caption@foreach@subtype\@gobble}%
+ {\caption@foreach@subtype\@iden}}
+% \end{macrocode}
+% \begin{macrocode}
+\newcommand\caption@foreach@subtype[2]{%
+ \caption@for@list\caption@subtypelist{#2}%
+ #1{\caption@addto@subtype@hook{#2}}}
+% \end{macrocode}
+% \begin{macrocode}
+\providecommand\caption@addto@subtype@hook[1]{%
+ \toks@=\expandafter{\caption@subtype@hook{##1}#1}%
+ \edef\@tempa{\def\noexpand\caption@subtype@hook####1{\the\toks@}}%
+ \@tempa}
+% \end{macrocode}
+% \begin{macrocode}
+\providecommand*\caption@subtype@hook[1]{}
% \end{macrocode}
% \end{macro}
%
% Unfortunately the \class{memoir} document class resets the
% \texttt{subfigure} resp.~\texttt{subtable} counter at the begin
% of floating environments, i.e.~at |\@float|.
-% As a side-effect |\Continued|\-|Float| does not work correctly.
+% As a side-effect |\continued|\-|float| does not work correctly.
% For that reason we need to introduce macros to save and restore
% all sub-caption counters here.
%
-% \begin{macro}{\caption@restorecounters}
-% \changes{v1.5}{2013/05/01}{This macro added}
-% |\caption@restore|\-|counters| restores all counters saved with
-% |\caption@save|\-|counter|.
-% \begin{macrocode}
-\newcommand*\caption@restorecounters{%
- \caption@restore@counters
- \global\let\caption@restore@counters\@empty}
-% \end{macrocode}
-% \begin{macrocode}
-\newcommand*\caption@restore@counters{}
-% \end{macrocode}
-% \end{macro}
% \begin{macro}{\caption@savesubcounters}
% \changes{v1.5}{2013/05/01}{This macro added}
-% |\caption@save|\-|sub|\-|counters| saves all sub-caption counters,
-% so they can be restored with |\caption@restore|\-|counters| later on.
+% \changes{v1.13}{2020/07/28}{Uses \cs{caption@for@list} now for iterating the list}
+% |\caption@save|\-|sub|\-|counters|\\
+% saves all sub-caption counters,
+% so they can be restored with |\caption@restore|\-|counters| later on.
% \begin{macrocode}
\newcommand*\caption@savesubcounters{%
- \def\@elt##1{\caption@savecounter{sub##1}}%
- \caption@subtypelist
- \let\@elt\relax}%
+ \caption@for@list\caption@subtypelist{\caption@savecounter{##1}}}
% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\caption@savecounter}
+% \changes{v1.5}{2013/05/01}{This macro added}
+% |\caption@save|\-|counter|\marg{counter}\\
+% saves the given counter, so it can be restored with
+% |\caption@restore|\-|counters| later on.
% \begin{macrocode}
\newcommand*\caption@savecounter[1]{%
\edef\caption@tempa{%
@@ -4132,26 +4517,42 @@
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\caption@For}
-% \changes{v1.1a}{2007/09/07}{This macro added}
-% \changes{v1.2}{2007/11/16}{Renamed from \cs{ForFloatingEnvironments} to \cs{caption@For}}
-% |\caption@For|\marg{elt-list}\marg{code with \#1}\\
-% |\caption@For*|\marg{elt-list}\marg{code with \#1}
+% \begin{macro}{\caption@restorecounters}
+% \changes{v1.5}{2013/05/01}{This macro added}
+% |\caption@restore|\-|counters|
+% restores all counters saved with |\caption@save|\-|counter|.
% \begin{macrocode}
-\newcommand*\caption@For{%
- \caption@withoptargs\caption@@For}
-%\@onlypreamble\caption@For
+\newcommand*\caption@restorecounters{%
+ \caption@restore@counters
+ \global\let\caption@restore@counters\@empty}
% \end{macrocode}
% \begin{macrocode}
-\newcommand\caption@@For[3]{%
- \caption@AtBeginDocument#1{%
- \def\@elt##1{#3}%
- \@nameuse{caption@#2}%
- \let\@elt\relax}}%
-%\@onlypreamble\caption@@For
+\newcommand*\caption@restore@counters{}
% \end{macrocode}
% \end{macro}
%
+% \section{Execution of options}
+%
+% \begin{macrocode}
+\ifx\caption@documentclass\@empty\else
+ \@pushfilename
+ \edef\@currname{caption-\caption@documentclass}
+ \edef\@currext{sto}
+ \InputIfFileExists
+ {\@currname.\@currext}%
+ {}%
+ {\@missingfileerror\@currname\@currext}%
+ \@popfilename
+\fi
+% \end{macrocode}
+%
+% \begin{macrocode}
+\captionsetup{style=default,position=default,listformat=default}
+% \end{macrocode}
+% \begin{macrocode}
+\ProcessOptions*
+% \end{macrocode}
+%
% \iffalse
%</package>
% \fi