diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/caption/caption3.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/caption/caption3.dtx | 397 |
1 files changed, 221 insertions, 176 deletions
diff --git a/Master/texmf-dist/source/latex/caption/caption3.dtx b/Master/texmf-dist/source/latex/caption/caption3.dtx index ea759a3c87b..96b2bc8ea95 100644 --- a/Master/texmf-dist/source/latex/caption/caption3.dtx +++ b/Master/texmf-dist/source/latex/caption/caption3.dtx @@ -32,12 +32,12 @@ % caption-deu.tex, caption-eng.tex, caption-rus.tex. % % \fi -% \CheckSum{3648} +% \CheckSum{3674} % % \iffalse %<*driver> \NeedsTeXFormat{LaTeX2e}[1994/12/01] -\ProvidesFile{caption3.drv}[2020/09/12 v2.1 Implementation of the caption kernel] +\ProvidesFile{caption3.drv}[2020/10/11 v2.2 Implementation of the caption kernel] \hbadness=9999 \newcount\hbadness \hfuzz=100pt % Make TeX shut up. %\errorcontextlines=3 % @@ -84,7 +84,7 @@ % % \newcommand*\csmarg[1]{\texttt{\char`\{#1\char`\}}} % \newcommand*\csoarg[1]{\texttt{\char`\[#1\char`\]}} -% \newcommand*\version[2][]{\textit{v#2}} +% \newcommand*\version[2][]{v$#2$} % % \GetFileInfo{caption3.drv} % \let\docdate\filedate @@ -117,6 +117,56 @@ % \package{subfig} packages. % \end{abstract} % +% \section*{Internal commands} +% +% 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 \\ +% \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} \\ +% \end{tabular}\end{quote} +% +% If your package wants to use any other internal command of the \package{caption3} package, +% please write me an e-mail so we can define a proper interface together. +% +% Unfortunately these internal commands are used by other packages and therefore will likely +% 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 \\ +% \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} \\ +% \hline +% |\caption@hj@|\meta{name} & \package{floatrow} \\ +% |\caption@lsep@|\meta{name} & \package{floatrow} \\ +% |\caption@lsep@default| & \package{babel-hungarian} \\ +% |\caption@sty@|\meta{name} & \package{floatrow} \\ +% \end{tabular}\end{quote} +% +% Furthermore the \package{floatrow} package uses the undocumented option +% |position=a| (as abbreviation of |position=auto|). +% +% The \package{lwarp} package uses a lot of internal commands as well, +% but we are working on it on the Git branch \texttt{feature/lwarp}: +% \url{https://gitlab.com/axelsommerfeldt/caption/-/tree/feature/lwarp} +% % \StopEventually{} % \clearpage % \tableofcontents @@ -192,17 +242,17 @@ % % \begin{macrocode} \NeedsTeXFormat{LaTeX2e}[1994/12/01] -\ProvidesPackage{caption3}[2020/09/17 v2.1b caption3 kernel (AR)] +\ProvidesPackage{caption3}[2020/10/21 v2.2e caption3 kernel (AR)] % \end{macrocode} % % \section{Generic helpers} % % \begin{macro}{\@nameundef} % |\@nameundef|\marg{command name}\\ -% is the opposite to |\@namedef| which is offered by the \LaTeX\ kernel. +% is the opposite to |\@name|\-|def| 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}. +% with |\caption|\-|setup|\oarg{type}. % \begin{macrocode} \providecommand*\@nameundef[1]{% \expandafter\let\csname #1\endcsname\@undefined} @@ -223,29 +273,44 @@ % \end{macro} % % \begin{macro}{\bothIfFirst} +% \changes{v2.2}{2020/09/21}{Usage of \cs{caption@prepare@bothif} added} % \begin{macro}{\bothIfSecond} +% \changes{v2.2}{2020/09/21}{Usage of \cs{caption@prepare@bothif} added} % |\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}% - \ifx\caption@tempa\@empty \else - #1#2% - \fi} +\def\bothIfFirst#1#2{\caption@bothif{#1}{#1#2}} +% \end{macrocode} +% \begin{macrocode} +\def\bothIfSecond#1#2{\caption@bothif{#2}{#1#2}} % \end{macrocode} % \begin{macrocode} -\def\bothIfSecond#1#2{% - \protected@edef\caption@tempa{#2}% +\newcommand*\caption@bothif[2]{% + \begingroup + \caption@prepare@bothif + \protected@xdef\caption@tempa{#1}% + \endgroup \ifx\caption@tempa\@empty \else - #1#2% + #2% \fi} % \end{macrocode} % \end{macro} % \end{macro} % +% \begin{macro}{\caption@prepare@bothif} +% \changes{v2.2}{2020/09/21}{This macro added} +% |\caption@prepare@bothif|\\ +% re-defines anything which could disturb either |\both|\-|If|\-|First| or |\both|\-|If|\-|Second| check. +% \begin{macrocode} +\providecommand*\caption@prepare@bothif{} +\g@addto@macro\caption@prepare@bothif{% + \let\inputencoding\@gobble} +% \end{macrocode} +% \end{macro} +% % \begin{macro}{\caption@ifundefined} % \changes{v1.3a}{2011/08/12}{This macro added} % \changes{v1.3b}{2011/08/18}{Made expandable} @@ -612,16 +677,17 @@ % \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} +% \changes{v2.2a}{2020/09/28}{\cs{caption@eh} renamed to \cs{caption@@eh} and revised} % |\caption@Error|\marg{message}\\ % issues an error message (with code line indication). % \begin{macrocode} \newcommand*\caption@Error[1]{% - \PackageError{caption}{#1}\caption@eh} + \PackageError{caption}{#1}{\caption@@eh{caption}}} % \end{macrocode} % \begin{macrocode} -\newcommand*\caption@eh{% +\newcommand*\caption@@eh[1]{% If you do not understand this error, please take a closer look\MessageBreak - at the documentation of the `caption' package, especially the\MessageBreak + at the documentation of the `#1' package, especially the\MessageBreak section about errors.\MessageBreak\@ehc} % \end{macrocode} % \end{macro} @@ -729,7 +795,7 @@ % % \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|. +% If the starred form of |\caption|\-|setup| is used, this will be set to |true|. % (It will be reset to |false| at the end of |\caption@set|\-|keys|.) % \begin{macrocode} \newif\ifcaptionsetup@star @@ -1225,9 +1291,12 @@ % expands to \meta{yes-code} if the \meta{value} expands to `default', % and to \meta{no-code} otherwise. % \begin{macrocode} -\newcommand*\caption@ifdefault[1]{% +\newcommand*\caption@ifdefault{\caption@ifequal{default}} +% \end{macrocode} +% \begin{macrocode} +\newcommand*\caption@ifequal[2]{% \edef\caption@tempa{#1}% - \def\caption@tempb{default}% + \edef\caption@tempb{#2}% \ifx\caption@tempa\caption@tempb \expandafter\@firstoftwo \else @@ -1296,6 +1365,24 @@ % \end{macrocode} % \end{macro} % +% \begin{macro}{\SetCaptionFallback} +% \changes{v2.2}{2020/09/21}{This macro added} +% |\SetCaptionFallback|\marg{option}\marg{name}\\ +% sets the fallback value for the \meta{option}. +% \begin{macrocode} +\newcommand*\SetCaptionFallback{% + \caption@maparg\caption@@setfallback} +\@onlypreamble\SetCaptionFallback +% \end{macrocode} +% \begin{macrocode} +\newcommand*\caption@@setfallback[3]{% + \caption@ifequal{fallback}{#3}% + {\caption@Error{Invalid argument for \string\SetCaptionFallback: `#3'}}% would cause an infinite loop otherwise + {\caption@@set{#1}{#2@fallback}{#3}}} +\@onlypreamble\caption@@setfallback +% \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\\ @@ -1529,9 +1616,9 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}{\caption@counter} +% \begin{macro}{\caption@thecounter} % \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.1e}{2007/10/28}{Renamed from \cs{caption@counter} to \cs{caption@thecounter}; \cs{caption@stepcounter} added} % \changes{v1.5}{2012/04/09}{\cs{caption@stepcounter} renamed to \cs{caption@stepthecounter}} % Internal counter. % At the moment it will be used inside |\caption@if|\-|odd|\-|page| only. @@ -1541,7 +1628,7 @@ % \begin{macrocode} \newcommand*\caption@stepthecounter{% \@tempcnta\caption@thecounter - \advance\@tempcnta\@ne + \advance\@tempcnta\@ne\relax \xdef\caption@thecounter{\the\@tempcnta}} % \end{macrocode} % \end{macro} @@ -1862,8 +1949,8 @@ \colorbox{\caption@boxcolor}{% \setlength\caption@tempdima{#1}% \addtolength\caption@tempdima{-2\fboxsep}% - \linewidth\caption@tempdima - \hsize\caption@tempdima + \linewidth\caption@tempdima\relax + \hsize\caption@tempdima\relax #2}} \DeclareCaptionOption{boxcolor}{\def\caption@boxcolor{#1}} \DeclareCaptionOption{boxsep}{\setlength\fboxsep{#1}} @@ -1938,8 +2025,8 @@ The option `labelsep=\caption@labelsep@name' does not work\MessageBreak with `format=hang'}}% {\@hangfrom{#1#2}% - \advance\caption@parindent\hangindent - \advance\caption@hangindent\hangindent + \advance\caption@parindent\hangindent\relax + \advance\caption@hangindent\hangindent\relax \caption@@par#3\par}} % \end{macrocode} % @@ -1991,12 +2078,13 @@ \DeclareCaptionLabelFormat{original}{% \caption@ifdefined\caption@original@fnum {\caption@original@fnum}% - {\caption@labelformat@simple{#1}{#2}}} + {\caption@labelformat@fallback{#1}{#2}}} % \end{macrocode} % -% `default' usually maps to `original'. +% `default' usually maps to `original' resp. `simple'. % \begin{macrocode} \SetCaptionDefault{labelformat}{original} +\SetCaptionFallback{labelformat}{simple} % \end{macrocode} % % \section{Label separators} @@ -2094,8 +2182,9 @@ \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.0e}{2005/06/11}{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} +% \changes{v1.12}{2020/05/30}{Caption label separator \opt{newline} implementation changed from \cs{textbackslash} to \cs{captionnewline}} % There are seven pre-defined label separators, called `none', `colon', `period', `space', % `quad', `newline', and `endash'. % \begin{macrocode} @@ -2105,10 +2194,35 @@ \DeclareCaptionLabelSeparator{space}{ } \DeclareCaptionLabelSeparator*{quad}{\quad} \DeclareCaptionLabelSeparator*{newline}{\captionnewline} +% TODO: \DeclareCaptionLabelSeparator should detect on its own if it contains \captionnewline or not \caption@LabelSeparatorWithNewline{newline} % does not work with "format=hang" \DeclareCaptionLabelSeparator*{endash}{\space\textendash\space} % \end{macrocode} % +% \changes{v2.2c}{2020/10/10}{Caption label separators \opt{gobble} and \opt{gobbletwo} added} +% +% It's a common hack to mis-use |\fnum@figure| and |\fnum@table| to replace the caption +% label separator, for example changing the separator to a period plus space with +% \begin{quote} +% |\renewcommand\fnum@figure[1]{\figurename~\thefigure.}| +% \end{quote} +% or dropping the label and separator completely with +% \begin{quote} +% |\renewcommand\fnum@figure[1]{\ignorespaces}|\quad +% \end{quote} +% (taken from \url{http://compgroups.net/comp.text.tex/figure-without-caption/1915079}). +% +% We emulate the behaviour of |\@make|\-|caption| of the base document classes +% \class{article}, \class{report}, and \class{book} in this regard (in |\caption@@@make|) +% so these hacks still work if the \package{caption} package is loaded. +% +% These are the label separators used when one or two tokens after the label format +% should be dropped, called `gobble' and `gobbletwo': +% \begin{macrocode} +\DeclareCaptionLabelSeparator{gobble}{ } +\DeclareCaptionLabelSeparator{gobbletwo}{} +% \end{macrocode} +% % \begin{macro}{\captionnewline} % \changes{v1.12}{2020/05/30}{This macro added} % \changes{v2.0}{2020/07/31}{\cs{relax} added to definition} @@ -2358,6 +2472,15 @@ \SetCaptionDefault{textfont}{none} % \end{macrocode} % +% The \package{floatrow} package uses the fonts `footfont` and `@tempa` additionally, +% so we need to map and define the default value for them, too. +% \begin{macrocode} +\caption@setmapping{footfont}{font} +\SetCaptionDefault{footfont}{none} +\caption@setmapping{@tempa}{font} +\SetCaptionDefault{@tempa}{none} +% \end{macrocode} +% % \begin{macro}{\caption@smaller} % |\caption@smaller|\\ % selects a font size which is smaller than the current one. @@ -2612,9 +2735,6 @@ % \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} @@ -3093,7 +3213,7 @@ } % \end{macrocode} % -% \subsection{The french babel option} +% \subsection{The babel-french package} % \changes{v1.1}{2006/05/14}{\package{frenchb} babel support added} % \changes{v2.0}{2020/08/01}{\package{french} babel support updated} % @@ -3131,7 +3251,10 @@ % in order to avoid problems when |Auto|\-|Space|\-|Punctuation| is set to |false|. % % \begin{macrocode} - \DeclareCaptionLabelSeparator{colon}{\autospace@beforeFDP : }% + \ifFB@active@punct + \DeclareCaptionLabelSeparator{colon}{% + \ifFBfrench\penalty\@M\FBcolonspace\fi : }% + \fi % \end{macrocode} % % We switch the default label separator to `french', dependant on the switches @@ -3215,7 +3338,7 @@ }{} % \end{macrocode} % -% \subsection{The hungarian \& magyar babel option} +% \subsection{The babel-hungarian package} % \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} @@ -3388,84 +3511,6 @@ % \end{macrocode} % \end{macro} % -% \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} -\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} @@ -3626,6 +3671,7 @@ \caption@InfoNoLine{subfig package v1.3 is loaded}% % \end{macrocode} % \begin{macrocode} + \def\caption@eh{\caption@@eh{subfig}}% \let\caption@setfloattype\@gobble \let\@dottedxxxline\sf@NEW@dottedxxxline \let\sf@subfloat\sf@NEW@subfloat @@ -3670,7 +3716,7 @@ \let\sf@oldlabel=\label \let\label=\subfloat@label \ifmaincaptiontop\else - \advance\@nameuse{c@\@captype}\@ne + \advance\@nameuse{c@\@captype}\@ne\relax \fi \refstepcounter{sub\@captype}% \setcounter{sub\@captype @save}{\value{sub\@captype}}% @@ -3857,9 +3903,9 @@ \caption@calcmargin \caption@tempdima\captionmargin \ifdim\captionmargin@=\z@ \else - \caption@ifoddpage{}{\advance\caption@tempdima\captionmargin@}% + \caption@ifoddpage{}{\advance\caption@tempdima\captionmargin@\relax}% \fi - \caption@ifhmode{\advance\caption@tempdima\caption@indent}% + \caption@ifhmode{\advance\caption@tempdima\caption@indent\relax}% \hspace\caption@tempdima % \end{macrocode} % We actually use a |\vbox| of width |\captionwidth - \caption@indent| @@ -3868,7 +3914,7 @@ % was defined with \cs{DeclareCaptionFormat*}.} % \begin{macrocode} \caption@tempdima\captionwidth - \caption@ifhmode{\advance\caption@tempdima-\caption@indent}% + \caption@ifhmode{\advance\caption@tempdima-\caption@indent\relax}% \caption@parbox\caption@tempdima{% % \end{macrocode} % Typeset the indention (option |indention=|)\\ @@ -3890,7 +3936,7 @@ % \begin{macrocode} \caption@tempdima\captionmargin \ifdim\captionmargin@=\z@ \else - \caption@ifoddpage{\advance\caption@tempdima\captionmargin@}{}% + \caption@ifoddpage{\advance\caption@tempdima\captionmargin@\relax}{}% \fi \hspace\caption@tempdima % \end{macrocode} @@ -3935,14 +3981,14 @@ % \end{macrocode} % \begin{macrocode} \ifdim\captionwidth=\z@ - \captionwidth\hsize - \advance\captionwidth by -2\captionmargin - \advance\captionwidth by -\captionmargin@ + \captionwidth\hsize\relax + \advance\captionwidth by -2\captionmargin\relax + \advance\captionwidth by -\captionmargin@\relax \else - \captionmargin\hsize - \advance\captionmargin by -\captionwidth - \divide\captionmargin by 2 - \captionmargin@\z@ + \captionmargin\hsize\relax + \advance\captionmargin by -\captionwidth\relax + \divide\captionmargin by 2\relax + \captionmargin@\z@\relax \fi % \end{macrocode} % \begin{macrocode} @@ -3959,9 +4005,9 @@ % % \begin{macro}{\caption@slc} % \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@setup}\cs{caption@sls} added after \cs{begingroup}} % \changes{v1.1}{2007/07/29}{\cs{caption@calcmargin} added} -% \changes{v1.1c}{2007/10/14}{\cs{caption@setup}\cs{\caption@opt@SingleLine} outsourced to \cs{caption@SingleLine}} +% \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}{Usage of \cs{ifsinglelinecaption} added} @@ -4143,18 +4189,44 @@ % \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{caption@textend}} +% \changes{v2.2c}{2020/10/10}{Usage of the label separators \opt{gobble} and \opt{gobbletwo} added} +% \changes{v2.2e}{2020/10/21}{Adaptions to \package{floatrow} package added} % |\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. -% \begin{macrocode} - \sbox\@tempboxa{#1}% +% The \package{floatrow} package uses |\caption@@@make|, too, +% but without using |\caption@single|\-|line| or |\caption@multi|\-|line|. +% For this reason we must expand |\caption@format| if |\caption@fmt| isn't defined yet. +% Furthermore it uses |\caption@lfmt| as argument which was renamed to +% |\caption@label|\-|format| in \package{caption3}\version{2.0}. +% \begin{macrocode} + \ifx\caption@fmt\@undefined\caption@format\fi + \let\caption@lfmt\caption@labelformat +% \end{macrocode} +% If the label is empty, we use the label separator `none'. +% Futhermore we use this check to determine if |#1| ends with either +% |\@gobble|, |\@gobble|\-|two|, and/or |\ignore|\-|spaces|. +% If yes, we use the corresponding label separator. +% \begin{macrocode} + \global\def\caption@tempa{gobbletwo}% + \global\def\caption@tempb{}% + \sbox\@tempboxa{% + \let\caption@ignorespaces\ignorespaces + \def\ignorespaces{% + \global\def\caption@tempb{two}% "gobble" -> "gobbletwo" if \ignorespaces is used addtionally + \caption@ignorespaces}% + #1% + {\global\let\caption@tempa\@undefined\aftergroup\@gobble}% + {\global\def\caption@tempa{gobble\caption@tempb}}}% \ifdim\wd\@tempboxa=\z@ - \caption@set{labelseparator}{none}% + \gdef\caption@tempa{none}% % \@capbreakfalse \fi + \ifx\caption@tempa\@undefined \else + \@expandtwoargs\caption@set{labelseparator}{\caption@tempa}% + \fi % \end{macrocode} % If the text is empty, we use no caption label separator, too. % (And no text format either.) @@ -4181,7 +4253,7 @@ {\ifcaption@star\else \begingroup \captionlabelfont - #1% + #1\relax\relax \endgroup \fi}% {\ifcaption@star\else @@ -4385,7 +4457,7 @@ % 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@ifsubtype{#4}% {\caption@Debug{Modify subtype `#4'}}% {\caption@Debug{New subtype `#4'}% \newcounter{#4}[{#3}]% @@ -4519,50 +4591,23 @@ % \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. -% For that reason we need to introduce macros to save and restore -% all sub-caption counters here. -% -% \begin{macro}{\caption@savesubcounters} -% \changes{v1.5}{2013/05/01}{This macro added} +% \begin{macro}{\@memresetsubcounter} +% \changes{v1.5}{2013/05/01}{The macro \cs{caption@savesubcounters} added} % \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{% - \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{% - \noexpand\l@addto@macro\noexpand\caption@restore@counters - {\noexpand\setcounter{#1}{\number\value{#1}}}}% - \caption@tempa} -% \end{macrocode} -% \end{macro} -% -% \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} +% \changes{v2.2b}{2020/10/06}{This stuff replaced by a patch of \cs{@memresetsubcounter}} +% The \class{memoir} document class resets the \texttt{subfigure} +% resp.~\texttt{subtable} counter at the begin of floating environments using +% |\@mem|\-|reset|\-|sub|\-|counter|. +% As a side-effect |\continued|\-|float| does not work correctly. +% For that reason we need to patch |\@mem|\-|reset|\-|sub|\-|counter| here, +% suppressing the counter reset if the counter was defined with +% |\Declare|\-|Caption|\-|Sub|\-|Type|. % \begin{macrocode} -\newcommand*\caption@restore@counters{} +\caption@ifdefined\@memresetsubcounter + {\let\caption@memresetsubcounter\@memresetsubcounter + \renewcommand*\@memresetsubcounter[1]{% + \caption@ifsubtype{sub#1}\@gobble\caption@memresetsubcounter{#1}}}% + {} % \end{macrocode} % \end{macro} % |