diff options
Diffstat (limited to 'macros/latex/contrib/caption/caption3.dtx')
-rw-r--r-- | macros/latex/contrib/caption/caption3.dtx | 761 |
1 files changed, 512 insertions, 249 deletions
diff --git a/macros/latex/contrib/caption/caption3.dtx b/macros/latex/contrib/caption/caption3.dtx index 96b2bc8ea9..5c91c87aa6 100644 --- a/macros/latex/contrib/caption/caption3.dtx +++ b/macros/latex/contrib/caption/caption3.dtx @@ -2,7 +2,7 @@ % % This is file `caption3.dtx'. % -% Copyright (C) 1994-2020 Axel Sommerfeldt (axel.sommerfeldt@f-m.fm) +% Copyright (C) 1994-2022 Axel Sommerfeldt (axel.sommerfeldt@f-m.fm) % % -------------------------------------------------------------------------- % @@ -27,17 +27,16 @@ % 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. +% caption-thesis.sto, bicaption.sty, ltcaption.sty, subcaption.sty. % % \fi -% \CheckSum{3674} +% +% \CheckSum{3781} % % \iffalse %<*driver> \NeedsTeXFormat{LaTeX2e}[1994/12/01] -\ProvidesFile{caption3.drv}[2020/10/11 v2.2 Implementation of the caption kernel] +\ProvidesFile{caption3.drv}[2021/01/02 v2.3 Implementation of the caption kernel] \hbadness=9999 \newcount\hbadness \hfuzz=100pt % Make TeX shut up. %\errorcontextlines=3 % @@ -61,7 +60,7 @@ \ifpdf\usepackage{hypdestopt}\fi \hypersetup{pdfkeywords={LaTeX, package, caption},pdfstartpage={},pdfstartview={}} % -\usepackage{caption3}[2020/09/12] +\usepackage{caption3}[2020/12/22] % \DeclareRobustCommand*\eTeX{\texorpdfstring {\leavevmode\hbox{$\varepsilon$}-\TeX}% @@ -110,7 +109,7 @@ % called |\@makecaption| and no options to control its behavior (except the % vertical skips above and below the caption itself), we provide similar % commands called |\caption@make| and |\caption@@make|, but with a lot of -% options which can be selected with |\captionsetup|. +% options which can be selected with |\caption|\-|setup|. % Loading the kernel part do not change the output of a \LaTeX\ document % -- it just provides functionality which can be used by \LaTeXe\ packages % which typesets captions, for example the \package{caption} and @@ -122,18 +121,20 @@ % These internal commands are save to use by other packages as well % since their interface will not change in future releases: % \begin{quote}\begin{tabular}{ll} -% Internal command & Currently used by \\ +% Internal command & Currently used by \\ % \hline -% |\caption@addcontentsline| & \package{floatrow} \\ -% |\caption@fnun| & \package{floatrow} \\ -% |\caption@ifinlist| & \package{floatrow} \\ -% |\caption@iftop| & \package{keyfloat}, \package{subfig} \\ -% |\caption@make| & \package{subfig} \\ -% |\caption@@make| & \package{floatrow} \\ -% |\caption@setautoposition| & \package{bidi} \\ -% |\caption@setoptions| & \package{floatrow} \\ -% |\caption@setposition| & \package{floatrow} \\ -% |\caption@switchdefault| & \emph{none} \\ +% |\caption@addcontentsline| & \package{floatrow} \\ +% |\caption@fnun| & \package{floatrow} \\ +% |\caption@getlabel| & \package{subcaption} \\ +% |\caption@gobble| & \package{subcaption} \\ +% |\caption@ifinlist| & \package{floatrow} \\ +% |\caption@iftop| & \package{keyfloat} \\ +% |\caption@make| & \package{subfig} \\ +% |\caption@@make| & \package{floatrow} \\ +% |\caption@setoptions| & \package{floatrow} \\ +% |\caption@setposition| & \package{floatrow} \\ +% |\caption@switchdefault| & \emph{none} \\ +% |\caption@withoptargs| & \package{subcaption} \\ % \end{tabular}\end{quote} % % If your package wants to use any other internal command of the \package{caption3} package, @@ -143,21 +144,18 @@ % not change in the future, too, but I do not support them (and maybe I will change them anyway % and patch the other package on-the-fly instead, at least if it's unmaintained): % \begin{quote}\begin{tabular}{ll} -% Internal command & Currently used by \\ +% Internal command & Currently used by \\ % \hline -% |\caption@hangindent | & \package{bidi} \\ -% |\caption@@@make| & \package{floatrow} \\ -% |\caption@@par| & \package{bidi} \\ -% |\caption@parindent| & \package{bidi} \\ -% |\caption@set@bool| & \package{floatrow} \\ -% |\caption@setfont| & \package{floatrow} \\ -% |\caption@setkeys| & \package{floatrow} \\ -% |\caption@setstyle*| & \package{floatrow} \\ +% |\caption@@@make| & \package{floatrow} \\ +% |\caption@set@bool| & \package{floatrow} \\ +% |\caption@setfont| & \package{floatrow} \\ +% |\caption@setkeys| & \package{floatrow} \\ +% |\caption@setstyle*| & \package{floatrow} \\ % \hline -% |\caption@hj@|\meta{name} & \package{floatrow} \\ -% |\caption@lsep@|\meta{name} & \package{floatrow} \\ +% |\caption@hj@|\meta{name} & \package{floatrow} \\ +% |\caption@lsep@|\meta{name} & \package{floatrow} \\ % |\caption@lsep@default| & \package{babel-hungarian} \\ -% |\caption@sty@|\meta{name} & \package{floatrow} \\ +% |\caption@sty@|\meta{name} & \package{floatrow} \\ % \end{tabular}\end{quote} % % Furthermore the \package{floatrow} package uses the undocumented option @@ -198,6 +196,7 @@ % \DoNotIndex{\hangindent,\hbox,\hfil,\hsize,\hskip,\hspace,\hss} % \DoNotIndex{\ifcase,\ifdim,\ifnum,\ifodd,\ifvoid,\ifvmode} % \DoNotIndex{\ifx,\ignorespaces,\itshape} +% \DoNotIndex{\kernel@ifnextchar} % \DoNotIndex{\Large,\large,\leavevmode,\leftmargini,\leftskip,\let,\linewidth} % \DoNotIndex{\llap,\long,\m@ne,\margin,\mdseries,\message} % \DoNotIndex{\newcommand,\newdimen,\newlength,\newline,\newif,\newsavebox} @@ -240,9 +239,32 @@ % % \section{Identification} % +% We need at least \LaTeX2e\ version 1994/12/01. % \begin{macrocode} \NeedsTeXFormat{LaTeX2e}[1994/12/01] -\ProvidesPackage{caption3}[2020/10/21 v2.2e caption3 kernel (AR)] +% \end{macrocode} +% +% Bypass the release declarations in case the \LaTeX\ kernel doesn’t know how to deal with them +% (as suggested by \url{https://www.latex-project.org/publications/2018-FMi-TUB-tb122mitt-version-rollback.pdf}). +% \begin{macrocode} +\providecommand\DeclareRelease[3]{} +\providecommand\DeclareCurrentRelease[2]{} +% \end{macrocode} +% +% Declare all supported releases. +% \begin{macrocode} +\DeclareRelease{v1.0} {2003-12-20}{caption3_2007-04-11.sty} % for caption v3.0 +\DeclareRelease{v1.1} {2007-09-01}{caption3_2010-01-14.sty} % for caption v3.1 +\DeclareRelease{v1.3} {2011-08-06}{caption3_2011-11-01.sty} % for caption v3.2 +\DeclareRelease{v1.8} {2013-01-10}{caption3_2019-09-01.sty} % for caption v3.3 +\DeclareRelease{v1.13}{2019-11-24}{caption3_2020-07-29.sty} % for caption v3.4 +\DeclareRelease{v2.0} {2020-08-30}{caption3_2020-10-26.sty} % for caption v3.5 +\DeclareCurrentRelease{v2.3}{2022-02-20} % for caption v3.6 +% \end{macrocode} +% +% Identify the current version of the package. +% \begin{macrocode} +\ProvidesPackage{caption3}[2022/01/07 v2.3 caption3 kernel (AR)] % \end{macrocode} % % \section{Generic helpers} @@ -1428,6 +1450,7 @@ % % \begin{macro}{\DeclareCaptionLength} % \changes{v2.0}{2020/08/09}{This macro added} +% \changes{v2.3}{2021/01/17}{Now defines \cs{caption@xxx} instead of \cs{captionxxx} as length} % |\DeclareCaptionLength|\marg{name}\marg{default value}\\ % \begin{enumerate} % \item Defines a new length (dimension) @@ -1438,9 +1461,8 @@ % \end{enumerate} % \begin{macrocode} \newcommand*\DeclareCaptionLength[1]{% - \expandafter\newdimen\csname caption#1\endcsname - \@namedef{caption@setdefault@#1}##1{% - \caption@setdefault@length{##1}}% + \expandafter\newdimen\csname caption@#1\endcsname + \@namedef{caption@setdefault@#1}{\caption@setdefault@length}% \SetCaptionDefault*{#1}} \@onlypreamble\DeclareCaptionLength % \end{macrocode} @@ -1448,59 +1470,94 @@ % % \begin{macro}{\caption@setdefault@length} % \changes{v2.0}{2020/08/09}{This macro added} +% \changes{v2.3}{2021/01/17}{Adapted to current implementation of \cs{DeclareCaptionLength}} % |\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}} + \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} +% \changes{v2.3}{2021/01/17}{Adapted to current implementation of \cs{DeclareCaptionLength}} % |\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}% + {\expandafter\let\expandafter\caption@tempa\csname caption@#1@default\endcsname}% {\def\caption@tempa{#2}}% - \expandafter\setlength\csname caption#1\endcsname\caption@tempa} + \expandafter\setlength\csname caption@#1\endcsname\caption@tempa} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\caption@tempdima} +% |\caption@tempdima| will be used as temporary dimension register, similar to |\@tempdima|. +% \begin{macrocode} +\newdimen\caption@tempdima % \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} % \changes{v1.1}{2007/08/11}{Options `margin*', `minmargin', and `maxmargin' added} % \changes{v1.2}{2007/11/10}{Option `oneside' added} % % \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} 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@|. +% |\captionmargin| contains the extra margin used for captions (if different than |0pt|). +% It is just available for user documents to provide compatibility to \version{1.x} of +% the \package{caption} package where |\set|\-|length\caption|\-|margin{|\ldots|}| was +% the way how a caption margin was set. % \begin{macrocode} -\DeclareCaptionLength{margin}{0pt} -\DeclareCaptionLength{margin@}{\the\captionmargin} -\DeclareCaptionLength{width}{0pt} -\newdimen\caption@tempdima +\newdimen\captionmargin +\setlength\captionmargin{0pt} +% \end{macrocode} +% |\SetCaptionDefault{margin}{|\ldots|}| sets both default values, +% i.e.~for the left and for the right margin. +% \begin{macrocode} +\newcommand\caption@setdefault@margin[3]{% + \caption@setdefault@length{#1}{left#2}{#3}% + \caption@setdefault@length{#1}{right#2}{#3}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\caption@leftmargin} +% \changes{v1.0n}{2007/04/01}{\cs{captionmarginx} renamed to \cs{captionmargin@}} +% \changes{v2.3}{2021/01/17}{\cs{captionmargin@} replaced by \cs{caption@leftmargin} and \cs{caption@rightmargin}} +% \begin{macro}{\caption@rightmargin} +% \changes{v1.0n}{2007/04/01}{\cs{captionmarginx} renamed to \cs{captionmargin@}} +% \changes{v2.3}{2021/01/17}{\cs{captionmargin@} replaced by \cs{caption@leftmargin} and \cs{caption@rightmargin}} +% |\caption@leftmargin| and |\caption@rightmargin| contain the extra margin used for captions. +% (These values will be used if the obsolete |\caption|\-|margin| is set to |0pt|.) +% \begin{macrocode} +\DeclareCaptionLength{leftmargin}{0pt} +\DeclareCaptionLength{rightmargin}{0pt} % \end{macrocode} % \end{macro} % \end{macro} % +% \begin{macro}{\caption@width} +% \changes{v2.3}{2021/01/17}{This dimension renamed from \cs{captionwidth} to \cs{caption@width}} +% |\caption@width| contains the total width used for captions. +% 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, +% otherwise |\caption|\-|@left|\-|margin| and |\caption|\-|@right|\-|margin|. % \begin{macrocode} -\DeclareCaptionOption{margin}{\setcaptionmargin{#1}} -\DeclareCaptionOption{margin*}{\setcaptionmargin*{#1}} -\DeclareCaptionOption{width}{\setcaptionwidth{#1}} -\DeclareCaptionOption{width*}{\setcaptionwidth*{#1}} +\newdimen\caption@width +\setlength\caption@width{0pt} +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +\DeclareCaptionOption{margin}{\caption@setmargin{#1}} +\DeclareCaptionOption{margin*}{\caption@setmargin*{#1}} +\DeclareCaptionOption{width}{\caption@setwidth{#1}} +\DeclareCaptionOption{width*}{\caption@setwidth*{#1}} % \end{macrocode} % \begin{macrocode} \DeclareCaptionOption{calcmargin}{\caption@setcalcmargin{#1}} @@ -1518,71 +1575,82 @@ \DeclareCaptionOption{maxmargin}{\caption@setoptcmd\caption@maxmargin{#1}} % \end{macrocode} % -% \begin{macro}{\setcaptionmargin} +% \begin{macro}{\caption@setmargin} % \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.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.3}{2010/11/07}{Support for option \opt{calcmargin} added} -% |\setcaptionmargin*|\marg{amount}\\ +% \changes{v2.3}{2021/01/17}{Renamed from \cs{setcaptionmargin} to \cs{caption@setmargin}; sets \cs{caption@width} resp.~\cs{caption@leftmargin} and \cs{caption@rightmargin} now} +% \changes{v2.3}{2021/01/19}{Only the left or right margin can be set by leaving the other value blank} +% |\caption@setmargin*|\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{% +\newcommand*\caption@setmargin{% \caption@resetcalcmargin - \caption@setmargin} + \caption@@setmargin} % \end{macrocode} % \begin{macrocode} -\newcommand*\caption@setmargin{% - \caption@teststar\caption@@setmargin\@gobble\@firstofone} +\newcommand*\caption@@setmargin{% + \caption@teststar\caption@@@setmargin\@gobble\@firstofone} % \end{macrocode} % \begin{macrocode} -\newcommand*\caption@@setmargin[2]{% - #1{\captionwidth\z@}% - \caption@@@setmargin#2,#2,\@nil} +\newcommand*\caption@@@setmargin[2]{% + #1{\caption@width\z@}% + \caption@@@@setmargin#2,#2,\@nil} +% \end{macrocode} +% \begin{macrocode} +\def\caption@@@@setmargin#1,#2,#3\@nil{% + \def\caption@tempa{#1#2}% + \ifx\caption@tempa\@empty + \caption@Error{Missing number}% + \else + \caption@@@@@setmargin{left}{#1}% + \caption@@@@@setmargin{right}{#2}% + \fi} % \end{macrocode} % \begin{macrocode} -\def\caption@@@setmargin#1,#2,#3\@nil{% - \caption@setlength{margin}{#1}% - \caption@setlength{margin@}{#2}% - \addtolength\captionmargin@{-\captionmargin}} +\newcommand*\caption@@@@@setmargin[2]{% + \def\caption@tempa{#2}% + \ifx\caption@tempa\@empty \else + \caption@setlength{#1margin}{#2}% + \fi} % \end{macrocode} % \end{macro} % -% \begin{macro}{\setcaptionwidth} +% \begin{macro}{\caption@setwidth} % \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}\\ +% \changes{v2.3}{2021/01/17}{Renamed from \cs{setcaptionwidth} to \cs{caption@setwidth}; sets \cs{caption@width} resp.~\cs{caption@leftmargin} and \cs{caption@rightmargin} now} +% |\caption@setwidth*|\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{% +\newcommand*\caption@setwidth{% \caption@resetcalcmargin - \caption@setwidth} + \caption@@setwidth} % \end{macrocode} % \begin{macrocode} -\newcommand*\caption@setwidth{% - \caption@teststar\caption@@setwidth\@gobble\@firstofone} +\newcommand*\caption@@setwidth{% + \caption@teststar\caption@@@setwidth\@gobble\@firstofone} % \end{macrocode} % \begin{macrocode} -\newcommand*\caption@@setwidth[2]{% - #1{\captionmargin\z@\captionmargin@\z@}% - \caption@setlength{width}{#2}}% +\newcommand*\caption@@@setwidth[2]{% + #1{\caption@leftmargin\z@\caption@rightmargin\z@}% + \setlength\caption@width{#2}} % \end{macrocode} % \end{macro} % % \begin{macro}{\caption@setcalcmargin} % \changes{v1.3}{2010/11/07}{This macro added} +% \changes{v2.3}{2021/01/17}{Adapted to current implementation of \cs{caption@setmargin}} % |\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}% + \caption@teststar{\caption@@setcalcmargin\caption@@setmargin}% \@secondoftwo\@firstoftwo} % \end{macrocode} % \begin{macrocode} @@ -1605,13 +1673,14 @@ % % \begin{macro}{\caption@setcalcwidth} % \changes{v1.3}{2010/11/07}{This macro added} +% \changes{v2.3}{2021/01/17}{Adapted to current implementation of \cs{caption@setmargin}} % |\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}% + \caption@teststar{\caption@@setcalcmargin\caption@@setwidth}% \@secondoftwo\@firstoftwo} % \end{macrocode} % \end{macro} @@ -1737,9 +1806,9 @@ % \begin{macro}{\caption@hangindent} % These are the indentions we support. % \begin{macrocode} -\DeclareCaptionLength{@indent}{0pt} -\DeclareCaptionLength{@parindent}{0pt} -\DeclareCaptionLength{@hangindent}{0pt} +\DeclareCaptionLength{indent}{0pt} +\DeclareCaptionLength{parindent}{0pt} +\DeclareCaptionLength{hangindent}{0pt} % \end{macrocode} % \end{macro} % \end{macro} @@ -1750,13 +1819,13 @@ % \changes{v1.0f}{2005/08/22}{Undocumented defaults for \opt{parindent=}, \opt{hangindent=}, and \opt{parskip=} removed} % \begin{macrocode} \DeclareCaptionOption{indent}[\leftmargini]{% obsolete - \caption@setlength{@indent}{#1}} + \caption@setlength{indent}{#1}} \DeclareCaptionOption{indention}[\leftmargini]{% - \caption@setlength{@indent}{#1}} + \caption@setlength{indent}{#1}} \DeclareCaptionOption{parindent}{% - \caption@setlength{@parindent}{#1}} + \caption@setlength{parindent}{#1}} \DeclareCaptionOption{hangindent}{% - \caption@setlength{@hangindent}{#1}} + \caption@setlength{hangindent}{#1}} \DeclareCaptionOption{parskip}{% \l@addto@macro\caption@@par{\setlength\parskip{#1}}} % \end{macrocode} @@ -1917,9 +1986,10 @@ % \begin{macro}{\DeclareCaptionBox} % \changes{v1.5}{2012/03/15}{This macro added} % \changes{v2.0}{2019/09/10}{Uses \cs{caption@decl} now} +% \changes{v2.2f}{2020/10/26}{\cs{par} is now allowed as part of the \meta{code} argument} % |\DeclareCaptionBox|\marg{name}\marg{code with \#1 and \#2} % \begin{macrocode} -\newcommand*\DeclareCaptionBox[2]{% +\newcommand\DeclareCaptionBox[2]{% \caption@decl{box}{#1}##1##2{#2}} \@onlypreamble\DeclareCaptionBox % \end{macrocode} @@ -2245,9 +2315,10 @@ % \begin{macro}{\DeclareCaptionTextFormat} % \changes{v1.0j}{2007/02/18}{This macro added} % \changes{v2.0}{2019/09/10}{Uses \cs{caption@decl} now} +% \changes{v2.2f}{2020/10/26}{\cs{par} is now allowed as part of the \meta{code} argument} % |\DeclareCaptionTextFormat|\marg{name}\marg{code with \#1} % \begin{macrocode} -\newcommand*\DeclareCaptionTextFormat[2]{% +\newcommand\DeclareCaptionTextFormat[2]{% \caption@decl{textformat}{#1}##1{#2}} \@onlypreamble\DeclareCaptionTextFormat % \end{macrocode} @@ -2260,11 +2331,11 @@ % 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}} +% \changes{v2.3}{2020/12/26}{Clearance of \cs{caption@thelabel} replaced by \cs{caption@clrlabel}} % \begin{macrocode} \DeclareCaptionTextFormat{empty}{% \caption@get@label#1\caption@makeanchor{}\@nil - \caption@thelabel - \global\let\caption@thelabel\relax} + \caption@thelabel\caption@clrlabel} \long\def\caption@get@label#1\caption@makeanchor#2#3\@nil{% \def\caption@tempa{#2}% \ifx\caption@tempa\@empty @@ -2284,9 +2355,7 @@ % \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} % \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 @@ -2324,8 +2393,19 @@ \l@addto@macro\caption@thelabel{[{#1}]}% \caption@@@getlabel#2\@nil} % \end{macrocode} +% \end{macro} +% +% \begin{macro}{\caption@clrlabel} +% \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} +% \changes{v2.3}{2020/12/26}{Code moved into the new macro \cs{caption@clrlabel}} +% |\caption@clrlabel|\\ +% resets |\caption@the|\-|label| to |\relax|. % \begin{macrocode} -\let\caption@thelabel\relax +\newcommand*\caption@clrlabel{\let\caption@thelabel\relax} +% \end{macrocode} +% \begin{macrocode} +\caption@clrlabel % \end{macrocode} % \end{macro} % @@ -2703,16 +2783,19 @@ % usually has to take care for himself that this hint actually matches the % right position. % -% \begin{macro}{\caption@declare@position} +% \begin{macro}{\DeclareCaptionPosition} % \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). +% \changes{v2.3}{2021/01/02}{This macro renamed from \cs{caption@declare@position} to \cs{DeclareCaptionPosition} and re-written} +% |\DeclareCaptionPosition|\marg{name}\marg{fallback-code}\marg{regular-code}\\ +% declares a caption position setting of the given \meta{name}. +% The \meta{fallback-code} will be used when |\caption@iftop| is used before |\caption| +% and the \meta{regular-code} will be used when |\caption| is used before |\caption@iftop|. % \begin{macrocode} -\newcommand*\caption@declare@position[2]{% - \caption@decl{position}{#1}{#2}} -\@onlypreamble\caption@declare@position +\newcommand*\DeclareCaptionPosition[3]{% + \caption@decl[\edef]{position}{#1}{% + \unexpanded{\def\caption@fallback@position}####1####2\unexpanded{{#2}}% + \unexpanded{\def\caption@regular@position}####1####2\unexpanded{{#3}}}} +\@onlypreamble\DeclareCaptionPosition % \end{macrocode} % \end{macro} % @@ -2733,38 +2816,45 @@ % \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} % \changes{v2.0}{2020/07/27}{Uses \cs{caption@set} now} +% \changes{v2.3}{2021/01/02}{Uses \cs{caption@initposition} additionally} % |\caption@setposition|\marg{position}\\ % puts |\caption@position| to the right value. -% (Note: Since this command is used by the \package{floatrow} package as well -% its syntax should not change.) +% (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}} +\newcommand*\caption@setposition{% + \caption@initposition + \caption@set{position}} % \end{macrocode} % \end{macro} % % 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} +\DeclareCaptionPosition{top}{#1}{#1} +\def\caption@position@t{\caption@position@top} +\def\caption@position@above{\caption@position@top} +% \end{macrocode} +% \begin{macrocode} +\DeclareCaptionPosition{bottom}{#2}{#2} +\def\caption@position@b{\caption@position@bottom} +\def\caption@position@below{\caption@position@bottom} % \end{macrocode} % % \changes{v1.1}{2007/05/08}{Default position changed from `bottom' to `auto'} -% `default' usually maps to `auto'. +% \changes{v1.3}{2021/01/02}{Default position changed back from `auto' to `bottom'} +% `default' usually maps to `bottom'. % \begin{macrocode} -\SetCaptionDefault{position}{auto} +\SetCaptionDefault{position}{bottom} % \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{macro}{\caption@initposition} +% \changes{v2.3}{2021/01/02}{This macro added} +% |\caption@initposition|\\ +% initialize the position option defined with |\Declare|\-|Caption|\-|Position|. +% This macro is usually used at |\@float|, i.e. at the beginning of a floating +% environment. % \begin{macrocode} -\let\caption@autoposition\@secondoftwo +\newcommand*\caption@initposition{% + \let\caption@@iftop\@undefined} % \end{macrocode} % \end{macro} % @@ -2773,10 +2863,13 @@ % \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'} % \changes{v2.0}{2020/07/27}{Adapted to current implementation of `auto'} +% \changes{v2.3}{2021/01/02}{Adapted to current implementation of `position'} % |\caption@iftop|\marg{true-code}\marg{false-code}\\ -% Since version \version{2.0} this command is identical to |\caption@position|. +% tests if the caption position is set to `top' and sets the state to 2. % \begin{macrocode} -\newcommand*\caption@iftop{\caption@position} +\newcommand*\caption@iftop{% + \caption@@fixposition\caption@fallback@position + \caption@@iftop} % \end{macrocode} % \end{macro} % @@ -2784,39 +2877,22 @@ % \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'} +% \changes{v2.3}{2021/01/02}{Adapted to current implementation of `position'} % |\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. +% freezes the position settings defined with |\Declare|\-|Caption|\-|Position| +% by expanding the given code, either the \meta{fallback-code} or the \meta{regular-code}. +% This macro is usually used at |\caption|, i.e. before the main caption is +% typeset. (Note: This macro is not used at |\caption| inside sub-figures.) % \begin{macrocode} \newcommand*\caption@fixposition{% - \ifvmode - \edef\caption@tempa{\the\prevdepth}% - \caption@Debug{\protect\prevdepth=\caption@tempa}% - \ifdim\prevdepth>-\p@ - \let\caption@autoposition\@secondoftwo % position=below - \else - \let\caption@autoposition\@firstoftwo % position=above - \fi - \else - \caption@Debug{no \protect\prevdepth}% - \let\caption@autoposition\@secondoftwo % position=below - \fi} + \caption@@fixposition\caption@regular@position} % \end{macrocode} -% \end{macro} -% -% \begin{macro}{\caption@setautoposition} -% \changes{v1.1}{2007/06/10}{This macro added} -% \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@fixposition{\caption@@set{position}{autoposition}{#1}}} +\newcommand*\caption@@fixposition[1]{% + \ifx\caption@@iftop\@undefined + \caption@position % defines \caption@fallback@position and \caption@regular@position + #1{\let\caption@@iftop\@firstoftwo}{\let\caption@@iftop\@secondoftwo}% + \fi} % \end{macrocode} % \end{macro} % @@ -3643,14 +3719,21 @@ % \subsection{The setspace package} % \changes{v1.0n}{2007/04/02}{\package{setspace} package support added} % \changes{v1.2d}{2009/10/09}{\package{setspace} package support revised} +% \changes{v2.3}{2021/11/20}{The font option \opt{stretch} does not require the \package{setspace} package anymore} % % \begin{macrocode} \DeclareCaptionFont{singlespacing}{% - \caption@ifdefined\setspace@singlespace{% - \setstretch\setspace@singlespace}{}}% normally 1 + \caption@ifdefined\setspace@singlespace + {\setstretch\setspace@singlespace}% usually 1, could be changed by \SetSinglespace + {}} +\DeclareCaptionFont{stretch}{% + \caption@ifdefined\setstretch + {\setstretch{#1}}% + {\def\baselinestretch{#1}\selectfont}} +% \end{macrocode} +% \begin{macrocode} \DeclareCaptionFont[setspace]{onehalfspacing}{\onehalfspacing} \DeclareCaptionFont[setspace]{doublespacing}{\doublespacing} -\DeclareCaptionFont[setspace]{stretch}{\setstretch{#1}} % \end{macrocode} % % \subsection{The subfig package} @@ -3675,7 +3758,7 @@ \let\caption@setfloattype\@gobble \let\@dottedxxxline\sf@NEW@dottedxxxline \let\sf@subfloat\sf@NEW@subfloat - \let\sf@ifpositiontop\caption@iftop + \def\sf@ifpositiontop{\caption@iftop}% % \end{macrocode} % \begin{macrocode} \fi @@ -3744,6 +3827,7 @@ % \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} +% \changes{v2.3}{2021/01/06}{Usage of \cs{p@xxx} and \cs{thexxx} replaced by \cs{caption@p} and \cs{caption@the}} % |\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|. @@ -3762,7 +3846,7 @@ \@tempa {\caption@Debug{addcontentsline: #1 => \caption@listtype}% % \caption@setoptions\caption@listtype - \@namedef{the\caption@listtype}{\@nameuse{the#1}}}% + \@namedef{the\caption@listtype}{\caption@the{#1}}}% \expandafter\caption@@addcontentsline\expandafter{\caption@listtype}{#2}% \endgroup}% \caption@addsubcontentslines{#1}} @@ -3776,7 +3860,7 @@ \caption@add@contentsline {\csname ext@#1\endcsname}% {#1}% - {\caption@listformat{\@nameuse{p@#1}}{\@nameuse{the#1}}}% + {\caption@listformat{\caption@p{#1}}{\caption@the{#1}}}% {\ignorespaces #2}% \caption@chkfloat{#1}{#2}}}} % \end{macrocode} @@ -3838,20 +3922,71 @@ % \begin{macro}{\caption@fnum} % \changes{v1.1}{2007/08/21}{This macro added} % \changes{v2.0}{2020/08/03}{The original definition will be stored in \cs{caption@original@fnum}} +% \changes{v2.3}{2021/01/06}{Usage of \cs{thexxx} replaced by \cs{caption@the}} +% \changes{v2.3}{2022/01/05}{Definition of \cs{caption@@fnum} added} % |\caption@fnum|\marg{float type}\\ +% |\caption@@fnum|\marg{float type}\marg{name}\marg{number}\\ % typesets the caption label; this acts as replacement for |\fnum@|\meta{float type}. % \begin{macrocode} \newcommand*\caption@fnum[1]{% + \caption@@fnum{#1}{\@nameuse{#1name}}{\caption@the{#1}}} +% \end{macrocode} +% \begin{macrocode} +\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}}} + \caption@labelformat} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\caption@setfnum} +% \changes{v1.1}{2007/03/10}{This macro added} +% \changes{v2.0}{2020/08/03}{Adapted to \package{caption3} v2.0} +% \changes{v2.3}{2022/01/05}{Definition moved from package to kernel} +% |\caption@setfnum|\marg{type}\\ +% stores the original definition of |\fnum@|\meta{type} in |\caption@fnum@|\meta{type} +% and re-defines it according the caption label format set with |label|\-|format=|. +% \begin{macrocode} +\newcommand*\caption@setfnum[1]{% + \@ifundefined{caption@fnum@#1}% + {\expandafter\let\csname caption@fnum@#1\expandafter\endcsname\csname fnum@#1\endcsname + \@namedef{fnum@#1}{\caption@fnum{#1}}}% + {}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\caption@p} +% \changes{v2.3}{2021/01/06}{This macro added} +% |\caption@p| is a simple wrapper macro for |\@nameuse{p@#1}|. +% \begin{macrocode} +\newcommand*\caption@p[1]{\@nameuse{p@#1}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\caption@the} +% \changes{v2.3}{2021/01/06}{This macro added} +% |\caption@the| is a simple wrapper macro for |\@nameuse{the#1}|. +% \begin{macrocode} +\newcommand*\caption@the[1]{\@nameuse{the#1}} % \end{macrocode} % \end{macro} % % \begin{macro}{\caption@make} -% |\caption@make|\marg{float name}\marg{ref.\ number}\marg{text}\\ +% \changes{v2.3}{2022/01/05}{Optional argument \meta{float type} added} +% |\caption@make|\oarg{float type}\marg{float name}\marg{ref.\ number}\marg{text}\\ % typesets the caption. % \begin{macrocode} -\newcommand\caption@make[2]{\caption@@make{\caption@labelformat{#1}{#2}}} +\newcommand*\caption@make{% + \kernel@ifnextchar[%] + \caption@make@ + {\caption@make@@\caption@labelformat}} +% \end{macrocode} +% \begin{macrocode} +\def\caption@make@[#1]{% + \caption@make@@{\caption@@fnum{#1}}} +% \end{macrocode} +% \begin{macrocode} +\newcommand\caption@make@@[3]{% + \caption@@make{#1{#2}{#3}}} % \end{macrocode} % \end{macro} % @@ -3877,6 +4012,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}} +% \changes{v2.3}{2021/01/16}{Some code encapsulated as \cs{caption@make@leftmargin}, \cs{caption@make@parbox}, \cs{caption@make@indention}, and \cs{caption@make@rightmargin}} % |\caption@@make|\marg{caption label}\marg{caption text} % \begin{macrocode} \newcommand\caption@@make[2]{% @@ -3901,32 +4037,20 @@ % Typeset the left margin (option |margin=|) % \begin{macrocode} \caption@calcmargin - \caption@tempdima\captionmargin - \ifdim\captionmargin@=\z@ \else - \caption@ifoddpage{}{\advance\caption@tempdima\captionmargin@\relax}% - \fi - \caption@ifhmode{\advance\caption@tempdima\caption@indent\relax}% - \hspace\caption@tempdima + \caption@make@leftmargin % \end{macrocode} -% We actually use a |\vbox| of width |\captionwidth - \caption@indent| +% We actually use a |\vbox| of width |\caption@width - \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@ifhmode{\advance\caption@tempdima-\caption@indent\relax}% - \caption@parbox\caption@tempdima{% + \caption@make@parbox{% % \end{macrocode} % Typeset the indention (option |indention=|)\\ % {\small Bugfix 04-05-05: % |\hskip-\caption@indent| replaced by |\ifdim\caption@indent=\z@|\ldots} % \begin{macrocode} - \caption@ifhmode{% - \ifdim\caption@indent=\z@ - \leavevmode - \else - \hskip-\caption@indent - \fi}% + \caption@make@indention % \end{macrocode} % Typeset the caption itself and close the |\caption@parbox| % \begin{macrocode} @@ -3934,11 +4058,7 @@ % \end{macrocode} % Typeset the right margin (option |margin=|) % \begin{macrocode} - \caption@tempdima\captionmargin - \ifdim\captionmargin@=\z@ \else - \caption@ifoddpage{\advance\caption@tempdima\captionmargin@\relax}{}% - \fi - \hspace\caption@tempdima + \caption@make@rightmargin % \end{macrocode} % Close the outer box |\caption@box| % \begin{macrocode} @@ -3948,7 +4068,30 @@ \caption@endhook} % \end{macrocode} % \begin{macrocode} -\newcommand\caption@@make@epilogue{% +\newcommand*\caption@make@leftmargin{% + \caption@tempdima\caption@leftmargin + \caption@ifhmode{\advance\caption@tempdima\caption@indent\relax}% + \hspace\caption@tempdima} +% \end{macrocode} +% \begin{macrocode} +\newcommand*\caption@make@parbox{% + \caption@tempdima\caption@width + \caption@ifhmode{\advance\caption@tempdima-\caption@indent\relax}% + \caption@parbox\caption@tempdima} +% \end{macrocode} +% \begin{macrocode} +\newcommand*\caption@make@indention{% + \caption@ifhmode{% + \ifdim\caption@indent=\z@ + \leavevmode + \else + \hskip-\caption@indent + \fi}} +\newcommand*\caption@make@rightmargin{% + \hspace\caption@rightmargin} +% \end{macrocode} +% \begin{macrocode} +\newcommand*\caption@@make@epilogue{% \global\caption@starfalse} % \end{macrocode} % \end{macro} @@ -3959,47 +4102,70 @@ % \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}} +% \changes{v2.3}{2021/01/17}{Uses \cs{caption@width} resp.~\cs{caption@leftmargin} and \cs{caption@rightmargin} now} % |\caption@calcmargin|\\ -% calculates |\caption|\-|margin| and |\caption|\-|width|, so both contain -% valid values. +% calculates |\caption|\-|@left|\-|margin|, |\caption|\-|@width|, and |\caption|\-|@right|\-|margin|, +% so all three contain valid values afterwards. % \begin{macrocode} \newcommand*\caption@calcmargin{% \caption@calcmargin@hook + \ifdim\caption@width=\z@ % \end{macrocode} -% Check margin, if |\caption@min|\-|margin| or |\caption@max|\-|margin| is set +% If |\caption|\-|margin| is set use this value instead of |\caption@left|\-|margin| and |\caption@right|\-|margin| % \begin{macrocode} - \ifx\caption@maxmargin\@undefined \else - \ifdim\captionmargin>\caption@maxmargin\relax - \captionmargin\caption@maxmargin\relax + \ifdim\captionmargin=\z@ \else + \caption@leftmargin\captionmargin + \caption@rightmargin\captionmargin \fi - \fi - \ifx\caption@minmargin\@undefined \else - \ifdim\captionmargin<\caption@minmargin\relax - \captionmargin\caption@minmargin\relax +% \end{macrocode} +% Check the margin values if |\caption@min|\-|margin| or |\caption@max|\-|margin| is set +% \begin{macrocode} + \ifx\caption@maxmargin\@undefined \else + \ifdim\caption@leftmargin>\caption@maxmargin + \caption@leftmargin\caption@maxmargin + \fi + \ifdim\caption@rightmargin>\caption@maxmargin + \caption@rightmargin\caption@maxmargin + \fi + \fi + \ifx\caption@minmargin\@undefined \else + \ifdim\caption@leftmargin<\caption@minmargin + \caption@leftmargin\caption@minmargin + \fi + \ifdim\caption@rightmargin<\caption@minmargin + \caption@rightmargin\caption@minmargin + \fi \fi - \fi +% \end{macrocode} +% Check if the left and right margins needs to be swapped +% \begin{macrocode} + \ifdim\caption@leftmargin=\caption@rightmargin \else + \caption@ifoddpage{}{% + \caption@tempdima\caption@leftmargin + \caption@leftmargin\caption@rightmargin + \caption@rightmargin\caption@tempdima}% + \fi +% \end{macrocode} +% Set |\caption@width| +% \begin{macrocode} + \caption@width\hsize + \advance\caption@width by -\caption@leftmargin\relax + \advance\caption@width by -\caption@rightmargin\relax % \end{macrocode} % \begin{macrocode} - \ifdim\captionwidth=\z@ - \captionwidth\hsize\relax - \advance\captionwidth by -2\captionmargin\relax - \advance\captionwidth by -\captionmargin@\relax \else - \captionmargin\hsize\relax - \advance\captionmargin by -\captionwidth\relax - \divide\captionmargin by 2\relax - \captionmargin@\z@\relax + \caption@leftmargin\hsize + \advance\caption@leftmargin by -\caption@width\relax + \divide\caption@leftmargin by 2\relax + \caption@rightmargin\caption@leftmargin \fi % \end{macrocode} % \begin{macrocode} \caption@Debug{% - \string\hsize=\the\hsize, - \string\captionwidth=\the\captionwidth,\MessageBreak - \string\captionmargin=\the\captionmargin, - \string\captionmargin@=\the\captionmargin@}% -% \end{macrocode} -% \begin{macrocode} -} + hsize=\the\hsize, + width=\the\caption@width,\MessageBreak + leftmargin=\the\caption@leftmargin, + rightmargin=\the\caption@rightmargin}} % \end{macrocode} % \end{macro} % @@ -4020,10 +4186,10 @@ \begingroup \caption@singleline \let\caption@justification\relax - \caption@calcmargin % calculate \captionwidth + \caption@calcmargin % calculate \caption@width \caption@prepareslc \sbox\@tempboxa{\caption@@@make{#1}{#2}}% - \ifdim\wd\@tempboxa>\captionwidth + \ifdim\wd\@tempboxa>\caption@width \endgroup \singlelinecaptionfalse #4% @@ -4069,8 +4235,19 @@ % \end{macrocode} % \end{macro} % +% \begin{macro}{\AtCaptionSingleLineCheck} +% \changes{v2.3}{2021/06/30}{This macro added} +% |\AtCaptionSingleLineCheck|\marg{code}\\ +% adds code to be expanded right before the single-line-check. +% (This will be done in an extra group, so all changes done are unually limited to the check.) +% \begin{macrocode} +\newcommand*\AtCaptionSingleLineCheck{% + \g@addto@macro\caption@prepareslc} +% \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}{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@justification}\cs{relax} added} % \changes{v1.0f}{2005/07/09}{Support of \package{endnotes} package added} @@ -4078,18 +4255,18 @@ % \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/22}{Redefinition of \cs{footnote} revised} +% \changes{v1.3}{2011/07/07}{Redefinition of \cs{footnote} and \cs{footnotemark} added, redefinition of \cs{stepcounter} and \cs{refstepcounter} dropped} % \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{v2.3}{2021/07/03}{Redefinition of \cs{footnote} and \cs{endnote} stuff revised} % |\caption@prepareslc|\\ % re-defines anything which could disturb the single-line-check. % \begin{macrocode} \providecommand*\caption@prepareslc{} -\g@addto@macro\caption@prepareslc{% +\AtCaptionSingleLineCheck{% \let\label\caption@gobble \let\hypertarget\@gobbletwo % \end{macrocode} @@ -4100,21 +4277,29 @@ % \item The footnote text will not be evaluated twice % \end{enumerate} % \begin{macrocode} - \let\caption@footnote@ORI\footnote - \def\footnote{\caption@withoptargs\caption@footnote}% - \let\caption@footnotemark@ORI\footnotemark - \def\footnotemark{\caption@withoptargs\caption@footnotemark}% - \let\caption@footnotetext@ORI\@footnotetext - \let\@footnotetext\caption@gobble + \let\footnote\caption@footnote + \let\footnotemark\caption@footnotemark + \let\footnotetext\caption@footnotetext + \let\@footnotetext\@gobble +% \end{macrocode} +% Adaption to the \package{hyperref} package +% \begin{macrocode} + \let\H@@footnotetext\@gobble + \let\H@@mpfootnotetext\@gobble + \caption@ifdefined\H@@footnotemark + {\let\@footnotemark\H@@footnotemark}% + {}% +% \end{macrocode} +% Adaption to the \package{tablefootnote} package +% \begin{macrocode} + \let\tablefootnote\caption@footnote % \end{macrocode} % Same for \cs{endnote} % \begin{macrocode} - \let\caption@endnote@ORI\endnote - \def\endnote{\caption@withoptargs\caption@endnote}% - \let\caption@endnotemark@ORI\endnotemark - \def\endnotemark{\caption@withoptargs\caption@endnotemark}% - \let\caption@endnotetext@ORI\@endnotetext - \let\@endnotetext\caption@gobble + \let\endnote\caption@endnote + \let\endnotemark\caption@endnotemark + \let\endnotetext\caption@endnotetext + \let\@endnotetext\@gobble % \end{macrocode} % Adaption to the \package{acronym} package\par % See also \url{https://tex.stackexchange.com/questions/428788} @@ -4135,28 +4320,106 @@ % \begin{macrocode} } % \end{macrocode} +% \end{macro} +% +% \begin{macro}{\caption@footnote} +% \changes{v1.3}{2011/07/07}{This macro added} +% \changes{v1.4a}{2011/10/22}{This macro revised} +% \changes{v2.3}{2021/07/03}{This macro re-written} +% The following code was taken from |base/ltfloat.dtx| but |\step|\-|counter| +% is replaced by |\caption@l@step|\-|counter| so the footnote counter will +% only be incremented temporarily for the single-line-check. +% (In the past we had re-used the original code but with re-defined +% |\step|\-|counter| but this has proofed as non-sufficient when +% using footnote related packages like the \package{footmisc} package. +% Now we might end up getting a wrong footnote marker, but this code has to +% be sufficient for the single-line-check.)) % \begin{macrocode} -\newcommand\caption@footnote[2]{% - \caption@footnotemark{#1}} +\newcommand*\caption@footnote{% + \@ifnextchar[%] + \@xfootnote + {\caption@l@stepcounter\@mpfn + \protected@xdef\@thefnmark{\thempfn}% + \@footnotemark\@footnotetext}} % \end{macrocode} +% \end{macro} +% +% \begin{macro}{\caption@footnotemark} +% \changes{v1.3}{2011/07/07}{This macro added} +% \changes{v2.3}{2021/07/03}{This macro re-written} +% The following code was taken from |base/ltfloat.dtx| but |\step|\-|counter| +% is replaced by |\caption@l@step|\-|counter| so the footnote counter will +% only be incremented temporarily for the single-line-check. % \begin{macrocode} -\newcommand\caption@footnotemark[1]{% - \begingroup - \let\stepcounter\caption@l@stepcounter - \caption@footnotemark@ORI#1\relax - \endgroup} +\newcommand*\caption@footnotemark{% + \@ifnextchar[%] + \@xfootnotemark + {\caption@l@stepcounter{footnote}% + \protected@xdef\@thefnmark{\thefootnote}% + \@footnotemark}} % \end{macrocode} +% \end{macro} +% +% \begin{macro}{\caption@footnotetext} +% \changes{v2.3}{2021/07/03}{This macro added} +% The following code was taken from |base/ltfloat.dtx|. % \begin{macrocode} -\newcommand\caption@endnote[2]{% - \caption@endnotemark{#1}} +\newcommand*\caption@footnotetext{% + \@ifnextchar[%] + \@xfootnotenext + {\protected@xdef\@thefnmark{\thempfn}% + \@footnotetext}} % \end{macrocode} +% \end{macro} +% +% \begin{macro}{\caption@endnote} +% \changes{v1.8}{2018/01/21}{This macro added} +% \changes{v2.3}{2021/07/03}{This macro re-written} +% The following code was taken from |endnotes/endnotes.sty| but |\step|\-|counter| +% is replaced by |\caption@l@step|\-|counter| so the footnote counter will +% only be incremented temporarily for the single-line-check. +% (In the past we had re-used the original code but with re-defined +% |\step|\-|counter|.) % \begin{macrocode} -\newcommand\caption@endnotemark[1]{% - \begingroup - \let\stepcounter\caption@l@stepcounter - \caption@endnotemark@ORI#1\relax - \endgroup} +\newcommand*\caption@endnote{% + \@ifnextchar[%] + \@xendnote + {\caption@l@stepcounter{endnote}% + \protected@xdef\@theenmark{\theendnote}% + \@endnotemark\@endnotetext}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\caption@endnotemark} +% \changes{v1.8}{2018/01/21}{This macro added} +% \changes{v2.3}{2021/07/03}{This macro re-written} +% The following code was taken from |endnotes/endnotes.sty| but |\step|\-|counter| +% is replaced by |\caption@l@step|\-|counter| so the footnote counter will +% only be incremented temporarily for the single-line-check. +% \begin{macrocode} +\newcommand*\caption@endnotemark{% + \@ifnextchar[%] + \@xendnotemark + {\caption@l@stepcounter{endnote}% + \protected@xdef\@theenmark{\theendnote}% + \@endnotemark}} % \end{macrocode} +% \end{macro} +% +% \begin{macro}{\caption@endnotetext} +% \changes{v2.3}{2021/07/03}{This macro added} +% The following code was taken from |endnotes/endnotes.sty|. +% \begin{macrocode} +\newcommand*\caption@endnotetext{% + \@ifnextchar[%] + \@xendnotenext + {\protected@xdef\@theenmark{\theendnote}% + \@endnotetext}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\caption@l@stepcounter} +% \changes{v1.3}{2011/07/07}{This macro added} % \begin{macrocode} \newcommand*\caption@l@stepcounter[1]{% \advance\csname c@#1\endcsname\@ne\relax} @@ -4457,7 +4720,7 @@ % Check if the sub-type was already defined by |\Declare|\-|Sub|\-|Type|. % If not, define the counter and list entry. % \begin{macrocode} - \caption@ifsubtype{#4}% + \caption@ifdefined@subtype{#4}% {\caption@Debug{Modify subtype `#4'}}% {\caption@Debug{New subtype `#4'}% \newcounter{#4}[{#3}]% @@ -4551,14 +4814,14 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}{\caption@ifsubtype} -% \changes{v1.8g}{2020/01/02}{This macro added} +% \begin{macro}{\caption@ifdefined@subtype} +% \changes{v1.8g}{2020/01/02}{This macro definition added} % \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|. +% \changes{v2.3}{2022/01/07}{Renamed from \cs{caption@ifsubtype} to \cs{caption@ifdefined@subtype}} +% |\caption@ifdefined@subtype|\marg{subtype}\marg{yes-code}\marg{no-code}\\ +% checks if the given subtype was defined with |\Declare|\-|Caption|\-|Sub|\-|Type|. % \begin{macrocode} -\newcommand*\caption@ifsubtype{% +\newcommand*\caption@ifdefined@subtype{% \caption@ifin@list\caption@subtypelist} % \end{macrocode} % \end{macro} @@ -4606,7 +4869,7 @@ \caption@ifdefined\@memresetsubcounter {\let\caption@memresetsubcounter\@memresetsubcounter \renewcommand*\@memresetsubcounter[1]{% - \caption@ifsubtype{sub#1}\@gobble\caption@memresetsubcounter{#1}}}% + \caption@ifdefined@subtype{sub#1}\@gobble\caption@memresetsubcounter{#1}}}% {} % \end{macrocode} % \end{macro} |