Debian Codegraph @

texmf-dist/source/latex/caption/caption3.dtx

raw
1 % \iffalse meta-comment
2 %
3 % This is file `caption3.dtx'.
4 %
5 % Copyright (C) 1994-2023 Axel Sommerfeldt ([email protected])
6 %
7 % --------------------------------------------------------------------------
8 %
9 % This work may be distributed and/or modified under the
10 % conditions of the LaTeX Project Public License, either version 1.3
11 % of this license or (at your option) any later version.
12 % The latest version of this license is in
13 % http://www.latex-project.org/lppl.txt
14 % and version 1.3 or later is part of all distributions of LaTeX
15 % version 2003/12/01 or later.
16 %
17 % This work has the LPPL maintenance status "maintained".
18 %
19 % This Current Maintainer of this work is Axel Sommerfeldt.
20 %
21 % This work consists of the files
22 % caption.ins, caption.dtx, caption-light.dtx, caption2.dtx, caption3.dtx,
23 % caption-ams-smf.dtx, caption-beamer.dtx, caption-elsarticle.dtx,
24 % caption-koma.dtx, caption-memoir.dtx, caption-ntg.dtx,
25 % caption-thesis.dtx, bicaption.dtx, ltcaption.dtx, subcaption.dtx,
26 % the derived files
27 % caption.sty, caption-light.sty, caption2.sty, caption3.sty,
28 % caption-ams-smf.sto, caption-beamer.sto, caption-elsarticle.sto,
29 % caption-koma.sto, caption-memoir.sto, caption-ntg.sto,
30 % caption-thesis.sto, bicaption.sty, ltcaption.sty, subcaption.sty.
31 %
32 % \fi
33 %
34 % \CheckSum{3855}
35 %
36 % \iffalse
37 %<*driver>
38 \NeedsTeXFormat{LaTeX2e}[1994/12/01]
39 \ProvidesFile{caption3.drv}[2023/07/10 v2.4 Implementation of the caption kernel]
40 %\errorcontextlines=3
41 %
42 \documentclass{captiondoc}
43 \hypersetup{pdfkeywords={LaTeX, package, caption3}}
44 %
45 \usepackage{caption3}[2020/12/22]
46 %
47 \begin{document}
48 \DocInput{caption3.dtx}
49 \end{document}
50 %</driver>
51 % \fi
52 %
53 % \def\thispackage{the \pkg{caption} kernel}
54 % \def\Thispackage{The \pkg{caption} kernel}
55 %
56 % \GetFileInfo{caption3.drv}
57 % \let\docdate\filedate
58 % \let\docversion\fileversion
59 % \GetFileInfo{caption3.sty}
60 %
61 % \title{The Implementation of
62 % \texorpdfstring{\thispackage\thanks{%^^A
63 % This package has version number \docversion.}}%^^A
64 % {the caption kernel}}
65 % \author{Axel Sommerfeldt\\
66 % \url{https://gitlab.com/axelsommerfeldt/caption}}
67 % \date{\docdate}
68 % \maketitle
69 %
70 % \begin{abstract}
71 % \Thispackage\ consists of two parts -- the kernel
72 % (|caption3.sty|) and the main package (|caption.sty|).
73 %
74 % The kernel provides all the user commands and internal macros which are
75 % necessary for typesetting captions and setting parameters regarding these.
76 % While the standard \LaTeX\ document classes provide an internal command
77 % called |\@makecaption| and no options to control its behavior (except the
78 % vertical skips above and below the caption itself), we provide similar
79 % commands called |\caption@make| and |\caption@@make|, but with a lot of
80 % options which can be selected with |\caption|\-|setup|.
81 % Loading the kernel part do not change the output of a \LaTeX\ document
82 % -- it just provides functionality which can be used by \LaTeXe\ packages
83 % which typesets captions, for example the \pkg{caption} and
84 % \pkg{subfig} packages.
85 % \end{abstract}
86 %
87 % \section*{Internal commands}
88 %
89 % These internal commands are save to use by other packages as well
90 % since their interface will not change in future releases:
91 % \begin{quote}\begin{tabular}{ll}
92 % Internal command & Currently used by \\
93 % \hline
94 % |\caption@addcontentsline| & \pkg{floatrow} \\
95 % |\caption@fnun| & \pkg{floatrow} \\
96 % |\caption@getlabel| & \pkg{subcaption} \\
97 % |\caption@gobble| & \pkg{subcaption} \\
98 % |\caption@ifinlist| & \pkg{floatrow} \\
99 % |\caption@iftop| & \pkg{keyfloat} \\
100 % |\caption@make| & \pkg{subfig} \\
101 % |\caption@@make| & \pkg{floatrow} \\
102 % |\caption@setoptions| & \pkg{floatrow} \\
103 % |\caption@setposition| & \pkg{floatrow} \\
104 % |\caption@switchdefault| & \emph{none} \\
105 % |\caption@withoptargs| & \pkg{subcaption} \\
106 % \end{tabular}\end{quote}
107 %
108 % If your package wants to use any other internal command of the \pkg{caption3} package,
109 % please write me an e-mail so we can define a proper interface together.
110 %
111 % Unfortunately these internal commands are used by other packages and therefore will likely
112 % not change in the future, too, but I do not support them (and maybe I will change them anyway
113 % and patch the other package on-the-fly instead, at least if it's unmaintained):
114 % \begin{quote}\begin{tabular}{ll}
115 % Internal command & Currently used by \\
116 % \hline
117 % |\caption@@@make| & \pkg{floatrow} \\
118 % |\caption@set@bool| & \pkg{floatrow} \\
119 % |\caption@setfont| & \pkg{floatrow} \\
120 % |\caption@setkeys| & \pkg{floatrow} \\
121 % |\caption@setstyle*| & \pkg{floatrow} \\
122 % \hline
123 % |\caption@hj@|\meta{name} & \pkg{floatrow} \\
124 % |\caption@lsep@|\meta{name} & \pkg{floatrow} \\
125 % |\caption@lsep@default| & \pkg{babel-hungarian} \\
126 % |\caption@sty@|\meta{name} & \pkg{floatrow} \\
127 % \end{tabular}\end{quote}
128 %
129 % Furthermore the \pkg{floatrow} package uses the undocumented option
130 % |position=a| (as abbreviation of |position=auto|).
131 %
132 % The \pkg{lwarp} package uses a lot of internal commands as well,
133 % but we are working on it on the Git branch \texttt{feature/lwarp}:
134 % \url{https://gitlab.com/axelsommerfeldt/caption/-/tree/feature/lwarp}
135 %
136 % \StopEventually{}
137 % \clearpage
138 % \tableofcontents
139 %
140 % \iffalse
141 % --------------------------------------------------------------------------- %
142 % \fi
143 %
144 % \DoNotIndex{\\,\_,\ ,\@@par}
145 % \DoNotIndex{\@bsphack}
146 % \DoNotIndex{\@car,\@cdr,\@classoptionslist,\@cons,\@currext,\@currname}
147 % \DoNotIndex{\@ehc,\@ehd,\@empty,\@esphack,\@expandtwoargs}
148 % \DoNotIndex{\@for,\@firstofone,\@firstoftwo}
149 % \DoNotIndex{\@gobble,\@gobblefour,\@gobbletwo,\@hangfrom}
150 % \DoNotIndex{\if@minipage,\@ifnextchar,\@ifpackagelater,\@ifpackageloaded}
151 % \DoNotIndex{\@ifstar,\@ifundefined,\@latex@error,\@minipagefalse,\@minipagetrue}
152 % \DoNotIndex{\@namedef,\@nameuse}
153 % \DoNotIndex{\@onlypreamble,\@parboxrestore,\@plus,\@ptionlist}
154 % \DoNotIndex{\@removeelement,\@restorepar,\@secondoftwo,\@setminipage,\@setpar}
155 % \DoNotIndex{\@tempa,\@tempboxa,\@tempdima,\@tempdimb,\@tempdimc,\@tempb,\@tempc}
156 % \DoNotIndex{\@testopt}
157 % \DoNotIndex{\@undefined,\@unprocessedoptions,\@unusedoptionlist}
158 % \DoNotIndex{\p@,\z@}
159 % \DoNotIndex{\active,\addtocounter,\addtolength,\advance,\aftergroup}
160 % \DoNotIndex{\baselineskip,\begin,\begingroup,\bfseries,\box}
161 % \DoNotIndex{\catcode,\centering,\changes,\csname,\def,\divide,\do,\downarrow}
162 % \DoNotIndex{\edef,\else,\empty,\end,\endcsname,\endgraf,\endgroup,\expandafter}
163 % \DoNotIndex{\fi,\footnotesize,\global}
164 % \DoNotIndex{\hangindent,\hbox,\hfil,\hsize,\hskip,\hspace,\hss}
165 % \DoNotIndex{\ifcase,\ifdim,\ifnum,\ifodd,\ifvoid,\ifvmode}
166 % \DoNotIndex{\ifx,\ignorespaces,\itshape}
167 % \DoNotIndex{\kernel@ifnextchar}
168 % \DoNotIndex{\Large,\large,\leavevmode,\leftmargini,\leftskip,\let,\linewidth}
169 % \DoNotIndex{\llap,\long,\m@ne,\margin,\mdseries,\message}
170 % \DoNotIndex{\newcommand,\newdimen,\newlength,\newline,\newif,\newsavebox}
171 % \DoNotIndex{\next,\nobreak,\nobreakspace,\noexpand,\noindent,\numberline}
172 % \DoNotIndex{\normalcolor,\normalfont,\normalsize,\or,\par,\parbox,\parfillskip}
173 % \DoNotIndex{\parindent,\parskip,\prevdepth,\protect,\protected@edef,\protected@write}
174 % \DoNotIndex{\providecommand,\quad}
175 % \DoNotIndex{\raggedleft,\raggedright,\relax,\renewcommand,\RequirePackage}
176 % \DoNotIndex{\rightskip,\rmfamily}
177 % \DoNotIndex{\sbox,\scriptsize,\scshape,\setbox,\setlength,\sffamily,\slshape}
178 % \DoNotIndex{\small,\string,\space,\strut}
179 % \DoNotIndex{\textheight,\the,\toks@,\typeout,\ttfamily}
180 % \DoNotIndex{\unvbox,\uparrow,\upshape,\usebox,\usepackage}
181 % \DoNotIndex{\value,\vbox,\vsize,\vskip,\wd,\width,\z@skip}
182 % \DoNotIndex{\AtBeginDocument,\AtEndOfPackage,\CurrentOption,\DeclareOption}
183 % \DoNotIndex{\ExecuteOptions,\GenericWarning,\IfFileExists,\InputIfFileExists}
184 % \DoNotIndex{\NeedsTeXFormat,\MessageBreak}
185 % \DoNotIndex{\PackageError,\PackageInfo,\PackageWarning,\PackageWarningNoLine}
186 % \DoNotIndex{\PassOptionsToPackage,\ProcessOptions,\ProvidesPackage}
187 %
188 % \iffalse
189 % --------------------------------------------------------------------------- %
190 % \fi
191 %
192 % \setlength{\parskip}{0pt plus 1pt}
193 % \newcommand*\Note[2][Note]{\par{\small\emph{#1:} #2}\par}
194 %
195 % \changes{v1.0}{2003/12/20}{Rewritten; many new commands and features}
196 % \changes{v1.0c}{2004/11/28}{Split into two packages: \pkg{caption} \& \pkg{caption3}}
197 %
198 % \iffalse
199 % --------------------------------------------------------------------------- %
200 % \fi
201 %
202 % \clearpage
203 %
204 % \iffalse
205 %<*package>
206 % \fi
207 %
208 % \section{Identification}
209 %
210 % We need at least \LaTeX2e\ version 1994/12/01.
211 % \begin{macrocode}
212 \NeedsTeXFormat{LaTeX2e}[1994/12/01]
213 % \end{macrocode}
214 %
215 % Bypass the release declarations in case the \LaTeX\ kernel doesn’t know how to deal with them
216 % (as suggested by \url{https://www.latex-project.org/publications/2018-FMi-TUB-tb122mitt-version-rollback.pdf}).
217 % \begin{macrocode}
218 \providecommand\DeclareRelease[3]{}
219 \providecommand\DeclareCurrentRelease[2]{}
220 % \end{macrocode}
221 %
222 % Declare all supported releases.
223 % \begin{macrocode}
224 \DeclareRelease{v1.0} {2003-12-20}{caption3_2007-04-11.sty} % for caption v3.0
225 \DeclareRelease{v1.1} {2007-09-01}{caption3_2010-01-14.sty} % for caption v3.1
226 \DeclareRelease{v1.3} {2011-08-06}{caption3_2011-11-01.sty} % for caption v3.2
227 \DeclareRelease{v1.8} {2013-01-10}{caption3_2019-09-01.sty} % for caption v3.3
228 \DeclareRelease{v1.13}{2019-11-24}{caption3_2020-07-29.sty} % for caption v3.4
229 \DeclareRelease{v2.0} {2020-08-30}{caption3_2020-10-26.sty} % for caption v3.5
230 \DeclareCurrentRelease{v2.3}{2022-02-20} % for caption v3.6
231 % \end{macrocode}
232 %
233 % Identify the current version of the package.
234 % \begin{macrocode}
235 \ProvidesPackage{caption3}[2023/07/31 v2.4d caption3 kernel (AR)]
236 % \end{macrocode}
237 %
238 % \section{Generic helpers}
239 %
240 % \begin{macro}{\kernel@ifnextchar}
241 % \changes{v1.1f}{2007/12/06}{Bugfix 07-12-06: This macro definition added (\cs{kernel@ifnextchar} was introduced in \LaTeXe\ 2004/01/23)}
242 % \changes{v2.4}{2022/04/18}{This macro moved from package to kernel}
243 % \begin{macrocode}
244 \@ifundefined{kernel@ifnextchar}{\let\kernel@ifnextchar\@ifnextchar}{}
245 % \end{macrocode}
246 % \end{macro}
247 %
248 % \begin{macro}{\@nameundef}
249 % |\@nameundef|\marg{command name}\\
250 % is the opposite to |\@name|\-|def| which is offered by the \LaTeX\ kernel.
251 % We use it to remove the definition of some commands and keyval options after
252 % |\begin{document}| (to save \TeX\ memory) and to remove caption options defined
253 % with |\caption|\-|setup|\oarg{type}.
254 % \begin{macrocode}
255 \providecommand*\@nameundef[1]{%
256 \expandafter\let\csname #1\endcsname\@undefined}
257 % \end{macrocode}
258 % \end{macro}
259 %
260 % \begin{macro}{\l@addto@macro}
261 % \changes{v1.5}{2013/04/26}{Revised}
262 % \changes{v2.0}{2019/09/11}{Relies on \eTeX{} now}
263 % |\l@addto@macro|\marg{command}\marg{code}\\
264 % The \LaTeXe\ kernel offers the internal helper macro |\g@addto@macro| which
265 % globally adds tokens to existing macros, like in |\AtBeginDocument|.
266 % This one is the same but it works locally, not globally.
267 % \begin{macrocode}
268 \providecommand\l@addto@macro[2]{%
269 \edef#1{\unexpanded\expandafter{#1#2}}}
270 % \end{macrocode}
271 % \end{macro}
272 %
273 % \begin{macro}{\bothIfFirst}
274 % \changes{v2.2}{2020/09/21}{Usage of \cs{caption@prepare@bothif} added}
275 % \begin{macro}{\bothIfSecond}
276 % \changes{v2.2}{2020/09/21}{Usage of \cs{caption@prepare@bothif} added}
277 % |\bothIfFirst|\marg{code no. 1}\marg{code no. 2}\\
278 % |\bothIfSecond|\marg{code no. 1}\marg{code no. 2}\\
279 % |\bothIfFirst| tests if the first argument is not empty, |\bothIfSecond|
280 % tests if the second argument is not empty. If yes both arguments get
281 % typeset, otherwise none of them.
282 % \begin{macrocode}
283 \def\bothIfFirst#1#2{\caption@bothif{#1}{#1#2}}
284 % \end{macrocode}
285 % \begin{macrocode}
286 \def\bothIfSecond#1#2{\caption@bothif{#2}{#1#2}}
287 % \end{macrocode}
288 % \begin{macrocode}
289 \newcommand*\caption@bothif[2]{%
290 \begingroup
291 \caption@prepare@bothif
292 \protected@xdef\caption@tempa{#1}%
293 \endgroup
294 \ifx\caption@tempa\@empty \else
295 #2%
296 \fi}
297 % \end{macrocode}
298 % \end{macro}
299 % \end{macro}
300 %
301 % \begin{macro}{\caption@prepare@bothif}
302 % \changes{v2.2}{2020/09/21}{This macro added}
303 % |\caption@prepare@bothif|\\
304 % re-defines anything which could disturb either |\both|\-|If|\-|First| or |\both|\-|If|\-|Second| check.
305 % \begin{macrocode}
306 \providecommand*\caption@prepare@bothif{}
307 \g@addto@macro\caption@prepare@bothif{%
308 \let\inputencoding\@gobble}
309 % \end{macrocode}
310 % \end{macro}
311 %
312 % \begin{macro}{\caption@ifundefined}
313 % \changes{v1.3a}{2011/08/12}{This macro added}
314 % \changes{v1.3b}{2011/08/18}{Made expandable}
315 % |\caption@ifundefined|\marg{command}\marg{yes-code}\marg{no-code}\\
316 % is similar to \cs{@ifundefined} offered by the \LaTeX kernel,
317 % but takes a command as argument instead of a command name.
318 % \begin{macrocode}
319 \newcommand*\caption@ifundefined[1]{%
320 \ifdefined#1%
321 \ifx#1\relax
322 \expandafter\expandafter\expandafter\@firstoftwo
323 \else
324 \expandafter\expandafter\expandafter\@secondoftwo
325 \fi
326 \else
327 \expandafter\@firstoftwo
328 \fi}
329 % \end{macrocode}
330 % \end{macro}
331 %
332 % \begin{macro}{\caption@ifdefined}
333 % \changes{v1.8e}{2018/05/11}{This macro added}
334 % |\caption@ifdefined|\marg{command}\marg{yes-code}\marg{no-code}\\
335 % is similar to \cs{@ifundefined} offered by the \LaTeX kernel,
336 % but takes a command as argument instead of a command name.
337 % \begin{macrocode}
338 \newcommand*\caption@ifdefined[1]{%
339 \ifdefined#1%
340 \ifx#1\relax
341 \expandafter\expandafter\expandafter\@secondoftwo
342 \else
343 \expandafter\expandafter\expandafter\@firstoftwo
344 \fi
345 \else
346 \expandafter\@secondoftwo
347 \fi}
348 % \end{macrocode}
349 % \end{macro}
350 %
351 % \begin{macro}{\caption@ifinlist}
352 % \changes{v1.1}{2007/07/29}{Rewritten}
353 % |\caption@ifinlist|\marg{element}\marg{list}\marg{yes-code}\marg{no-code}\\
354 % This helper command checks if the \meta{element} is in the comma separated
355 % \meta{list}. So for example
356 % \begin{quote}
357 % |\caption@ifinlist{frank}{axel,frank,olga,steven}{yes}{no}|
358 % \end{quote}
359 % would expand to |yes|.\par
360 % (Note: Since this command is used by the \pkg{floatrow} package as well
361 % its syntax should not change.)
362 % \begin{macrocode}
363 \newcommand*\caption@ifinlist{%
364 \@expandtwoargs\caption@@ifinlist}
365 % \end{macrocode}
366 % \begin{macrocode}
367 \newcommand*\caption@@ifinlist[2]{%
368 \begingroup
369 \def\@tempa##1,#1,##2\@nil{%
370 \endgroup
371 \ifx\relax##2\relax
372 \expandafter\@secondoftwo
373 \else
374 \expandafter\@firstoftwo
375 \fi}%
376 \@tempa,#2,#1,\@nil}%
377 % \end{macrocode}
378 % \end{macro}
379 %
380 % \begin{macro}{\caption@ifin@list}
381 % \changes{v1.1}{2007/08/12}{This macro added}
382 % |\caption@ifin@list|\marg{cmd}\marg{element}\marg{yes-code}\marg{no-code}\\
383 % is the same as |\caption@ifinlist| but with a command (containing a list)
384 % instead of the list itself.
385 % \begin{macrocode}
386 \newcommand*\caption@ifin@list[2]{%
387 \caption@ifempty@list#1%
388 {\@secondoftwo}%
389 {\@expandtwoargs\caption@@ifinlist{#2}{#1}}}
390 % \end{macrocode}
391 % \end{macro}
392 %
393 % \begin{macro}{\caption@g@addto@list}
394 % \changes{v1.1}{2007/07/29}{This macro added}
395 % |\caption@g@addto@list|\marg{cmd}\marg{element}\\
396 % adds an element to a command containing a list.
397 % (The command will get defined if it isn't defined yet.)
398 % \begin{macrocode}
399 \newcommand*\caption@g@addto@list[2]{%
400 \caption@ifempty@list#1{\gdef#1{#2}}{\g@addto@macro#1{,#2}}}
401 % \end{macrocode}
402 % \end{macro}
403 % \begin{macro}{\caption@l@addto@list}
404 % \changes{v1.1}{2007/07/29}{This macro added}
405 % |\caption@l@addto@list|\marg{cmd}\marg{element}\\
406 % is the same as |\caption@g@addto@list| but works locally.
407 % \begin{macrocode}
408 \newcommand*\caption@l@addto@list[2]{%
409 \caption@ifempty@list#1{\def#1{#2}}{\l@addto@macro#1{,#2}}}
410 % \end{macrocode}
411 % \end{macro}
412 %
413 % \begin{macro}{\caption@g@removefrom@list}
414 % \changes{v1.1}{2007/07/29}{This macro added}
415 % |\caption@g@removefrom@list|\marg{cmd}\marg{element}\\
416 % removes an element from a command containing a list.
417 % \Note[Caveat]{\meta{cmd} will be expanded during this process since
418 % \cs{@removeelement} is using \cs{edef} to build the new list.}
419 % \begin{macrocode}
420 \newcommand*\caption@g@removefrom@list[2]{%
421 \caption@l@removefrom@list#1{#2}%
422 \global\let#1#1}
423 % \end{macrocode}
424 % \end{macro}
425 % \begin{macro}{\caption@l@removefrom@list}
426 % \changes{v1.1}{2007/07/29}{This macro added}
427 % |\caption@l@removefrom@list|\marg{cmd}\marg{element}\\
428 % is the same as |\caption@g@removefrom@list| but works locally.
429 % \Note[Caveat]{\meta{cmd} will be expanded during this process since
430 % \cs{@removeelement} is using \cs{edef} to build the new list.}
431 % \begin{macrocode}
432 \newcommand*\caption@l@removefrom@list[2]{%
433 \caption@ifempty@list#1{}{\@expandtwoargs\@removeelement{#2}#1#1}}
434 % \end{macrocode}
435 % \end{macro}
436 %
437 % \begin{macro}{\caption@for@list}
438 % \changes{v1.1}{2007/07/29}{This macro added}
439 % |\caption@for@list|\marg{cmd}\marg{code with \#1}\\
440 % iterates all elements of the list (within \meta{cmd}) using the given
441 % \meta{code}.
442 % \begin{macrocode}
443 \newcommand*\caption@for@list[2]{%
444 \caption@ifempty@list#1{}%
445 {\def\caption@tempb##1{#2}%
446 \@for\caption@tempa:=#1\do{%
447 \expandafter\caption@tempb\expandafter{\caption@tempa}}}}
448 % \end{macrocode}
449 % \end{macro}
450 %
451 % \begin{macro}{\caption@ifempty@list}
452 % \changes{v1.1}{2007/07/29}{This macro added}
453 % |\caption@ifempty@list|\marg{cmd}\marg{yes-code}\marg{no-code}\\
454 % This helper command checks if the list (within \meta{cmd}) is empty.
455 % \begin{macrocode}
456 \newcommand*\caption@ifempty@list[1]{%
457 \ifx#1\@undefined
458 \expandafter\@firstoftwo
459 \else\ifx#1\relax
460 \expandafter\expandafter\expandafter\@firstoftwo
461 \else\ifx#1\@empty
462 \expandafter\expandafter\expandafter\expandafter
463 \expandafter\expandafter\expandafter\@firstoftwo
464 \else
465 \expandafter\expandafter\expandafter\expandafter
466 \expandafter\expandafter\expandafter\@secondoftwo
467 \fi\fi\fi}
468 % \end{macrocode}
469 % \end{macro}
470 %
471 % \pagebreak[3]
472 % \begin{macro}{\caption@setbool}
473 % \changes{v1.1}{2007/04/05}{\cs{caption@set@bool}\marg{cmd}\marg{value} added}
474 % \begin{macro}{\caption@ifbool}
475 % \changes{v1.1}{2020/08/02}{\cs{caption@if@bool}\marg{value} added}
476 % \begin{macro}{\caption@undefbool}
477 % For setting and testing boolean options we offer these three helper macros:
478 % \begin{quote}
479 % |\caption@setbool|\marg{name}\marg{value}\\
480 % | |(with |value = false/true/no/yes/off/on/0/1|)\\
481 % |\caption@ifbool|\marg{name}\marg{if-clause}\marg{else-clause}\\
482 % |\caption@undefbool|\marg{name}
483 % \end{quote}
484 % \begin{macrocode}
485 \newcommand*\caption@setbool[1]{%
486 \expandafter\caption@set@bool\csname caption@if#1\endcsname}
487 % \end{macrocode}
488 % \begin{macrocode}
489 \newcommand*\caption@set@bool[2]{%
490 \caption@if@bool{#2}{\let#1\@firstoftwo}{\let#1\@secondoftwo}}
491 % \end{macrocode}
492 % \begin{macrocode}
493 \newcommand*\caption@if@bool[1]{%
494 \caption@ifinlist{#1}{1,true,yes,on}%
495 {\@firstoftwo}%
496 {\caption@ifinlist{#1}{0,false,no,off}%
497 {}%
498 {\caption@Error{Undefined boolean value `#1'}}%
499 \@secondoftwo}}
500 % \end{macrocode}
501 % \begin{macrocode}
502 \newcommand*\caption@ifbool[1]{\@nameuse{caption@if#1}}
503 % \end{macrocode}
504 % \begin{macrocode}
505 \newcommand*\caption@undefbool[1]{\@nameundef{caption@if#1}}
506 % \end{macrocode}
507 % \end{macro}
508 % \end{macro}
509 % \end{macro}
510 %
511 % \begin{macro}{\caption@teststar}
512 % \changes{v1.1}{2007/05/08}{This macro and its usage added}
513 % \changes{v1.1e}{2007/10/28}{\cs{caption@teststar@} added}
514 % |\caption@teststar|\marg{cmd}\marg{star-arg}\marg{non-star-arg}\\
515 % expands \meta{cmd} with either argument \marg{star-arg} or
516 % \meta{non-star-arg}, depending on if the next char is a star (or not).\par
517 % |\caption@teststar@|\marg{cmd}\marg{star-arg}\marg{non-star-arg}\\
518 % will test the catcode of the character \@ additionally.
519 % \begin{macrocode}
520 \newcommand*\caption@teststar[3]{%
521 \@ifstar{#1{#2}}{#1{#3}}}
522 % \end{macrocode}
523 % \begin{macrocode}
524 \newcommand*\caption@teststar@[3]{%
525 \@ifstar{#1{#2}}{\caption@ifatletter{#1{#2}}{#1{#3}}}}
526 \AtBeginDocument{\let\caption@teststar@\caption@teststar}
527 % \end{macrocode}
528 % \end{macro}
529 %
530 % \begin{macro}{\caption@ifatletter}
531 % \changes{v1.1e}{2007/10/28}{This macro added}
532 % |\caption@ifatletter|\marg{yes-code}\marg{no-code}\\
533 % will either expand \meta{yes-code} or \meta{no-code},
534 % depending on the catcode of the character \@.
535 % \begin{macrocode}
536 \newcommand*\caption@ifatletter{%
537 \ifnum\the\catcode`\@=11
538 \expandafter\@firstoftwo
539 \else
540 \expandafter\@secondoftwo
541 \fi}
542 % \end{macrocode}
543 % \begin{macrocode}
544 \AtBeginDocument{\let\caption@ifatletter\@secondoftwo}
545 % \end{macrocode}
546 % \end{macro}
547 %
548 % \begin{macro}{\caption@withoptargs}
549 % \changes{v1.1}{2007/08/12}{This macro added}
550 % \changes{v1.5}{2012/04/09}{This macro revised}
551 % \changes{v2.4}{2022/04/18}{\cs{@ifnextchar} replaced by \cs{kernel@ifnextchar}}
552 % |\caption@withoptargs|\marg{cmd}\\
553 % collects a star and all optional arguments, and expands \meta{cmd}
554 % afterwards with the collected stuff as first argument.
555 % \begin{macrocode}
556 \newcommand*\caption@withoptargs[1]{%
557 \@ifstar
558 {\def\caption@tempa{*}\caption@@withoptargs{#1}}%
559 {\def\caption@tempa{}\caption@@withoptargs{#1}}}
560 % \end{macrocode}
561 % \begin{macrocode}
562 \def\caption@@withoptargs#1{%
563 \kernel@ifnextchar[%]
564 {\caption@@@withoptargs{#1}}%
565 {\caption@@@@withoptargs{#1}}}
566 % \end{macrocode}
567 % \begin{macrocode}
568 \def\caption@@@withoptargs#1[#2]{%
569 \l@addto@macro\caption@tempa{[{#2}]}%
570 \caption@@withoptargs{#1}}
571 % \end{macrocode}
572 % \begin{macrocode}
573 \def\caption@@@@withoptargs#1{%
574 \def\caption@tempb{#1}%
575 \expandafter\caption@tempb\expandafter{\caption@tempa}}
576 % \end{macrocode}
577 % \end{macro}
578 %
579 % \begin{macro}{\caption@gobble}
580 % \changes{v1.4}{2011/08/19}{This macro added}
581 % |\caption@gobble*|\oarg{arg}\oarg{\ldots}\marg{arg}\\
582 % is similar to |\@gobble| but gobbles a star and optional arguments as well.
583 % \begin{macrocode}
584 \DeclareRobustCommand*\caption@gobble{%
585 \caption@withoptargs\@gobbletwo}
586 % \end{macrocode}
587 % \end{macro}
588 %
589 % \begin{macro}{\caption@iftokens}
590 % \changes{v2.4d}{2023/07/31}{This macro added}
591 % |\caption@iftokens|\marg{arg}\marg{yes-code}\marg{no-code}\\
592 % This helper command checks if the given argument contains one or more tokens, i.e. is not empty.
593 % \begin{macrocode}
594 \newcommand\caption@iftokens[1]{%
595 \if\relax\detokenize{#1}\relax
596 \expandafter\@secondoftwo
597 \else
598 \expandafter\@firstoftwo
599 \fi}
600 % \end{macrocode}
601 % \end{macro}
602 %
603 % \begin{macro}{\caption@AtBeginDocument}
604 % \changes{v1.1}{2007/04/13}{This macro and its usage added}
605 % \changes{v1.2e}{2010/01/09}{Adapted to the combine document class}
606 % |\caption@AtBeginDocument*|\marg{code}\\
607 % is similar to |\AtBeginDocument| but the execution of code will be
608 % surrounded by two |\Package|\-|Info|s.
609 % The starred variant causes the code to be executed after all code
610 % specified using the non-starred variant.
611 % \begin{macrocode}
612 \let\caption@begindocumenthook\@empty
613 \let\caption@@begindocumenthook\@empty
614 % \end{macrocode}
615 % \begin{macrocode}
616 \def\caption@AtBeginDocument{%
617 \caption@teststar\g@addto@macro
618 \caption@@begindocumenthook\caption@begindocumenthook}
619 %\@onlypreamble\caption@AtBeginDocument
620 % \end{macrocode}
621 % \begin{macrocode}
622 \AtBeginDocument{%
623 \caption@InfoNoLine{Begin \noexpand\AtBeginDocument code}%
624 % \end{macrocode}
625 % \begin{macrocode}
626 \def\caption@AtBeginDocument{%
627 \@ifstar{\g@addto@macro\caption@@begindocumenthook}\@firstofone}%
628 \caption@begindocumenthook
629 \let\caption@begindocumenthook\relax
630 % \end{macrocode}
631 % \begin{macrocode}
632 \def\caption@AtBeginDocument{%
633 \@ifstar\@firstofone\@firstofone}%
634 \caption@@begindocumenthook
635 \let\caption@@begindocumenthook\relax
636 % \end{macrocode}
637 % \begin{macrocode}
638 \caption@InfoNoLine{End \noexpand\AtBeginDocument code}}
639 % \end{macrocode}
640 % \end{macro}
641 %
642 % \section{Information, Warnings, and Errors}
643 %
644 % \begin{macro}{\caption@Info}
645 % \changes{v1.3}{2010/10/25}{Moved from package to kernel}
646 % |\caption@Info|\marg{message}\\
647 % issues an info message (with code line indication).
648 % \begin{macrocode}
649 \newcommand*\caption@Info[1]{%
650 \PackageInfo{caption}{#1}}
651 % \end{macrocode}
652 % \end{macro}
653 % \begin{macro}{\caption@InfoNoLine}
654 % \changes{v1.3}{2010/10/25}{Moved from package to kernel}
655 % |\caption@InfoNoLine|\marg{message}\\
656 % issues an info message without code line indication.
657 % \Note{The \cs{@gobble} at the end of the 2nd argument of
658 % \cs{PackageInfo} suppresses the line number info.
659 % See TLC2\cite{TLC2}, A.4.7, p885 for details.}
660 % \begin{macrocode}
661 \newcommand*\caption@InfoNoLine[1]{%
662 \caption@Info{#1\@gobble}}
663 % \end{macrocode}
664 % \end{macro}
665 %
666 % \begin{macro}{\caption@Warning}
667 % \changes{v1.1c}{2007/10/14}{This macro added, will now be used for warnings}
668 % |\caption@Warning|\marg{message}\\
669 % issues a warning message (with code line indication).
670 % \begin{macrocode}
671 \newcommand*\caption@Warning[1]{%
672 \caption@WarningNoLine{#1\on@line}}
673 % \end{macrocode}
674 % \end{macro}
675 % \begin{macro}{\caption@WarningNoLine}
676 % \changes{v1.1c}{2007/10/14}{This macro added, will now be used for warnings}
677 % |\caption@WarningNoLine|\marg{message}\\
678 % issues a warning message without code line indication.
679 % \begin{macrocode}
680 \newcommand*\caption@WarningNoLine[1]{%
681 \PackageWarning{caption}{#1.^^J\caption@wh\@gobbletwo}}
682 % \end{macrocode}
683 % \begin{macrocode}
684 \newcommand*\caption@wh{%
685 See the caption package documentation for explanation.}
686 % \end{macrocode}
687 % \end{macro}
688 %
689 % \begin{macro}{\caption@Error}
690 % \changes{v1.0j}{2007/01/20}{This macro added, will now be used for errors}
691 % \changes{v1.0o}{2007/04/11}{Renamed from \cs{caption@error} to \cs{caption@Error}}
692 % \changes{v1.1b}{2007/09/18}{Usage of \cs{caption@Package} removed}
693 % \changes{v2.2a}{2020/09/28}{\cs{caption@eh} renamed to \cs{caption@@eh} and revised}
694 % |\caption@Error|\marg{message}\\
695 % issues an error message (with code line indication).
696 % \begin{macrocode}
697 \newcommand*\caption@Error[1]{%
698 \PackageError{caption}{#1}{\caption@@eh{caption}}}
699 % \end{macrocode}
700 % \begin{macrocode}
701 \newcommand*\caption@@eh[1]{%
702 If you do not understand this error, please take a closer look\MessageBreak
703 at the documentation of the `#1' package, especially the\MessageBreak
704 section about errors.\MessageBreak\@ehc}
705 % \end{macrocode}
706 % \end{macro}
707 %
708 % \begin{macro}{\caption@KV@err}
709 % \changes{v1.1b}{2007/09/18}{This macro added}
710 % |\caption@KV@err|\marg{message}\\
711 % will be used to issue an error while parsing the key-value (package)
712 % options.
713 % \begin{macrocode}
714 \let\caption@KV@err\caption@Error
715 % \end{macrocode}
716 % \end{macro}
717 %
718 % \section{Using the keyval package}
719 %
720 % We need the \pkg{keyval} package for option handling, so we load it here.\par
721 % \emph{TODO:} Use some recent stuff instead, for example kvdefinekey and kvsetkeys.
722 % \begin{macrocode}
723 \RequirePackage{keyval}[1997/11/10]
724 % \end{macrocode}
725 %
726 % \begin{macro}{\undefine@key}
727 % |\undefine@key|\marg{family}\marg{key}\\
728 % is the opposite of |\define@key|, it removes a keyval definition.
729 % \begin{macrocode}
730 \providecommand*\undefine@key[2]{%
731 \@nameundef{KV@#1@#2}\@nameundef{KV@#1@#2@default}}
732 % \end{macrocode}
733 % \end{macro}
734 %
735 % \begin{macro}{\@onlypreamble@key}
736 % \changes{v1.1}{2007/07/22}{This macro added}
737 % \changes{v1.1e}{2007/11/01}{\cs{KV@err} will be used now instead of \cs{@notprerr}}
738 % |\onlypreamble@key|\marg{family}\marg{key}\\
739 % marks a keyval definition only valid in the document preamble, analogous to
740 % |\@only|\-|preamble| from \LaTeXe.
741 % \begin{macrocode}
742 \providecommand*\@preamble@keys{}
743 \providecommand*\@onlypreamble@key[2]{\@cons\@preamble@keys{{#1}{#2}}}
744 \@onlypreamble\@onlypreamble@key
745 \@onlypreamble\@preamble@keys
746 % \end{macrocode}
747 % \begin{macrocode}
748 \providecommand*\@notprerr@key[1]{\KV@err{Can be used only in preamble}}
749 % \end{macrocode}
750 % \begin{macrocode}
751 \caption@AtBeginDocument*{%
752 \def\@elt#1#2{\expandafter\let\csname KV@#1@#2\endcsname\@notprerr@key}%
753 \@preamble@keys
754 \let\@elt\relax}
755 % \end{macrocode}
756 % \end{macro}
757 %
758 % \begin{macro}{\DeclareCaptionOption}
759 % |\DeclareCaptionOption*|\marg{option}\oarg{default value}\marg{code}\\
760 % We declare our options using these commands (instead of using
761 % |\Declare|\-|Option| offered by \LaTeXe), so the keyval package is used.
762 % The starred form makes the option available during the lifetime of the
763 % current package only, so they can be used with |\use|\-|package|, but
764 % \emph{not} with |\caption|\-|setup| later on.
765 % \begin{macrocode}
766 \newcommand*\DeclareCaptionOption{%
767 \caption@teststar\caption@declareoption\AtEndOfPackage\@gobble}
768 \@onlypreamble\DeclareCaptionOption
769 % \end{macrocode}
770 % \begin{macrocode}
771 \newcommand*\caption@declareoption[2]{%
772 #1{\undefine@key{caption}{#2}}\caption@declare@option{#2}}
773 \@onlypreamble\caption@declareoption
774 % \end{macrocode}
775 % \begin{macrocode}
776 \newcommand*\caption@declare@option{%
777 \define@key{caption}}
778 %% no \@onlypreamble\caption@declare@option since it will be used by \captionsetup
779 % \end{macrocode}
780 % \end{macro}
781 %
782 % \begin{macro}{\DeclareCaptionOptionNoValue}
783 % \changes{v1.1c}{2007/10/06}{This macro added}
784 % |\DeclareCaptionOptionNoValue*|\marg{option}\marg{code}\\
785 % is the same as |\DeclareCaptionOption| but issues an error if a value is
786 % given.
787 % \begin{macrocode}
788 \newcommand*\DeclareCaptionOptionNoValue{%
789 \caption@teststar\caption@declareoption@novalue\AtEndOfPackage\@gobble}
790 \@onlypreamble\DeclareCaptionOptionNoValue
791 % \end{macrocode}
792 % \begin{macrocode}
793 \newcommand\caption@declareoption@novalue[3]{%
794 \caption@declareoption{#1}{#2}[\KV@err]{%
795 \caption@option@novalue{#2}{##1}{#3}}}
796 \@onlypreamble\caption@declareoption@novalue
797 % \end{macrocode}
798 % \begin{macrocode}
799 \newcommand*\caption@option@novalue[2]{%
800 \ifx\KV@err#2%
801 \expandafter\@firstofone
802 \else
803 \KV@err{No value allowed for #1}%
804 \expandafter\@gobble
805 \fi}
806 % \end{macrocode}
807 % \end{macro}
808 %
809 % \begin{macro}{\captionsetup}
810 % \changes{v1.0a}{2004/01/17}{Bugfix: Missing \% added}
811 % \changes{v1.1}{2007/07/22}{Starred-variant added}
812 % \changes{v1.1e}{2007/07/27}{Inside packages the starred variant will be used automatically}
813 % \changes{v1.2}{2007/11/16}{Bugfix 07-11-09: `space hack' added}
814 % \changes{v1.2a}{2008/01/12}{\cs{ifcaptionsetup@star} will be set now}
815 % \changes{v1.5}{2012/04/09}{Support of multiple optional arguments added}
816 % \changes{v1.8h}{2020/01/03}{Syntax check of saved options added}
817 % \changes{v2.3b}{2022/03/17}{Usage of \cs{captionsetup} inside \cs{caption@setup@options@@} replaced by \cs{caption@setup@options@}}
818 % \changes{v2.4}{2022/04/18}{\cs{@ifnextchar} replaced by \cs{kernel@ifnextchar}}
819 % \changes{v2.4}{2022/04/18}{Usage of \cs{ifcaptionsetup@star} removed}
820 % |\captionsetup*|\oarg{type}\marg{keyval-list of options}\\
821 % applies the given list of options.
822 % If the optional argument `type' is specified, we simply save or append
823 % the option list, otherwise we `execute' it with |\set|\-|keys|.
824 % (The non-starred variant issues a warning if \meta{keyval-list of options}
825 % is not used later on.)
826 % \Note{The starred variant will be used inside packages automatically.}
827 % \begin{macrocode}
828 \newcommand*\captionsetup{%
829 \caption@teststar@\@captionsetup\@gobble\@firstofone}
830 % \end{macrocode}
831 % \begin{macrocode}
832 \newcommand*\@captionsetup[1]{%
833 \kernel@ifnextchar[%]
834 {\caption@setup@options#1}%
835 {\caption@setup}}
836 % \end{macrocode}
837 % \begin{macrocode}
838 \newcommand*\caption@setup{%
839 \caption@setkeys{caption}}
840 % \end{macrocode}
841 % \begin{macrocode}
842 \def\caption@setup@options#1[#2]{%
843 \kernel@ifnextchar[%]
844 {\caption@stepthecounter
845 \@expandtwoargs\caption@setup@options@@{#2}{@\caption@thecounter}#1}%
846 {\caption@setup@options@#1{#2}}}
847 % \end{macrocode}
848 % \begin{macrocode}
849 \def\caption@setup@options@@#1#2#3[#4]#5{%
850 \caption@declare@option{#2}[]{\caption@setup@options@\@gobble{#4}{#5}}%
851 \caption@setup@options@#3{#1}{#2}}
852 % \end{macrocode}
853 % \begin{macrocode}
854 \newcommand*\caption@setup@options@[3]{%
855 \@bsphack
856 #1{\caption@addtooptlist{#2}}%
857 \caption@checkoptions{#3}%
858 \expandafter\caption@l@addto@list\csname caption@opt@#2\endcsname{#3}%
859 \@esphack}
860 % \end{macrocode}
861 % \end{macro}
862 %
863 % \begin{macro}{\caption@checkoptions}
864 % \changes{v1.8h}{2020/01/03}{This macro added}
865 % |\caption@checkoptions|\marg{keyval-list of options}\\
866 % checks the syntax of the given options by executing them inside a group.
867 % \begin{macrocode}
868 \newcommand*\caption@checkoptions[1]{%
869 \begingroup
870 \caption@prepare@optioncheck
871 \caption@setup{#1}%
872 \endgroup}
873 % \end{macrocode}
874 % \begin{macrocode}
875 \providecommand*\caption@prepare@optioncheck{}
876 % \end{macrocode}
877 % \end{macro}
878 %
879 % \begin{macro}{\IfCaptionOptionCheck}
880 % \changes{v1.10}{2020/05/10}{This macro added}
881 % |\IfCaptionOptionCheck|\marg{yes-code}\marg{no-code}\\
882 % executes the \meta{yes-code} if options are just checked for syntax,
883 % and \meta{no-code} if not.
884 % \begin{macrocode}
885 \let\IfCaptionOptionCheck\@secondoftwo
886 % \end{macrocode}
887 % \begin{macrocode}
888 \g@addto@macro\caption@prepare@optioncheck{%
889 \let\IfCaptionOptionCheck\@firstoftwo}
890 % \end{macrocode}
891 % \end{macro}
892 %
893 % \begin{macro}{\clearcaptionsetup}
894 % \changes{v1.1}{2007/07/29}{Optional argument added}
895 % \changes{v1.1}{2007/08/17}{Starred variant added}
896 % \changes{v1.1e}{2007/07/27}{Inside packages the starred variant will be used automatically}
897 % \changes{v1.2}{2007/11/16}{Bugfix 07-11-09: `space hack' added}
898 % |\clearcaptionsetup*|\oarg{option}\marg{type}\\
899 % removes the saved option list associated with \meta{type}.
900 % If \meta{option} is given, only this option will be removed from the list.
901 % (The starred variant does not issue warnings.)
902 % \Note{The starred variant will be used inside packages automatically.}
903 % \begin{macrocode}
904 \newcommand*\clearcaptionsetup{%
905 \caption@teststar@\@clearcaptionsetup\@gobble\@firstofone}
906 % \end{macrocode}
907 % \begin{macrocode}
908 \newcommand*\@clearcaptionsetup[1]{%
909 \let\caption@tempa#1%
910 \@testopt\@@clearcaptionsetup{}}
911 % \end{macrocode}
912 % \begin{macrocode}
913 \def\@@clearcaptionsetup[#1]#2{%
914 \@bsphack
915 \expandafter\caption@ifempty@list\csname caption@opt@#2\endcsname
916 {\caption@tempa{\caption@Warning{Option list `#2' undefined}}}%
917 {\ifx,#1,%
918 \caption@clearsetup{#2}%
919 \else
920 \caption@@removefromsetup{#1}{#2}%
921 \fi}%
922 \@esphack}
923 % \end{macrocode}
924 % \begin{macrocode}
925 \newcommand*\caption@clearsetup[1]{%
926 \caption@removefromoptlist{#1}%
927 \@nameundef{caption@opt@#1}}
928 % \end{macrocode}
929 % \begin{macrocode}
930 \newcommand*\caption@removefromsetup{%
931 \let\caption@tempa\@gobble
932 \caption@@removefromsetup}
933 % \end{macrocode}
934 % \begin{macrocode}
935 \newcommand*\caption@@removefromsetup[2]{%
936 \expandafter\let\expandafter\@tempa\csname caption@opt@#2\endcsname
937 \expandafter\let\csname caption@opt@#2\endcsname\@undefined
938 \def\@tempb##1=##2\@nil{##1}%
939 \edef\@tempc{#1}%
940 \@for\@tempa:=\@tempa\do{%
941 \edef\@tempd{\expandafter\@tempb\@tempa=\@nil}%
942 \ifx\@tempd\@tempc
943 \let\caption@tempa\@gobble
944 \else
945 \expandafter\expandafter\expandafter\caption@l@addto@list
946 \expandafter\csname caption@opt@#2\expandafter\endcsname
947 \expandafter{\@tempa}%
948 \fi}%
949 \expandafter\caption@ifempty@list\csname caption@opt@#2\endcsname
950 {\caption@removefromoptlist{#2}}{}%
951 \caption@tempa{\caption@Warning{%
952 Option `#1' was not in list `#2'}}}
953 % \end{macrocode}
954 % \end{macro}
955 %
956 % \begin{macro}{\showcaptionsetup}
957 % \changes{v1.0d}{2005/05/03}{Optimized for memory usage}
958 % \changes{v1.1}{2007/07/29}{Bugfix: Does not expand option list anymore}
959 % \changes{v1.2}{2007/11/16}{Bugfix 07-11-09: `space hack' added}
960 % |\showcaptionsetup|\oarg{package}\marg{type}\\
961 % shows the saved option list which is associated with \meta{type}
962 % (as warning message).
963 % \begin{macrocode}
964 \newcommand*\showcaptionsetup[2][\@firstofone]{%
965 \@bsphack
966 \GenericWarning{}{%
967 #1 Caption Info: Option list on `#2'\MessageBreak
968 #1 Caption Data: \@ifundefined{caption@opt@#2}{%
969 -none-%
970 }{%
971 {\expandafter\expandafter\expandafter\strip@prefix
972 \expandafter\meaning\csname caption@opt@#2\endcsname}%
973 }}%
974 \@esphack}
975 % \end{macrocode}
976 % \end{macro}
977 %
978 % \changes{v1.1}{2007/07/02}{Option \opt{options=} added}
979 % \changes{v1.3}{2010/09/05}{Option \opt{options*=} added}
980 % \changes{v1.4b}{2012/01/12}{Option \opt{options*=} removed}
981 % \begin{macrocode}
982 \DeclareCaptionOption{options}{\caption@setoptions{#1}}
983 % \end{macrocode}
984 %
985 % \begin{macro}{\caption@setoptions}
986 % \changes{v1.0g}{2006/01/03}{Optional argument added}
987 % \changes{v1.0h}{2006/01/26}{Revised}
988 % \changes{v1.0j}{2007/01/30}{Optional argument removed}
989 % \changes{v1.1}{2007/04/11}{Usage of \cs{clearcaptionsetup} added}
990 % \changes{v1.1}{2007/05/09}{Renamed from \cs{caption@settype} to \cs{caption@setoptions}}
991 % \changes{v1.2}{2007/12/03}{Definition of \cs{caption@iftypewarning} removed}
992 % \changes{v1.3}{2010/09/05}{Starred variant added}
993 % \changes{v1.4b}{2012/01/12}{Starred variant removed}
994 % |\caption@setoptions|\marg{type or environment or\ldots}\\
995 % applies caption options which have been saved with |\caption|\-|setup|\oarg{type}.
996 % To prevent multiple application the list will be cleared (locally) afterwards.
997 % \begin{macrocode}
998 \newcommand*\caption@setoptions[1]{%
999 \caption@Debug{options=#1}%
1000 \expandafter\let\expandafter\caption@opt\csname caption@opt@#1\endcsname
1001 \ifx\caption@opt\relax \else
1002 \caption@xsetup\caption@opt
1003 \caption@clearsetup{#1}%
1004 \fi}
1005 % \end{macrocode}
1006 % \begin{macrocode}
1007 \newcommand*\caption@xsetup[1]{\expandafter\caption@setup\expandafter{#1}}
1008 % \end{macrocode}
1009 % \end{macro}
1010 %
1011 % \begin{macro}{\caption@addtooptlist}
1012 % \changes{v1.1}{2007/07/22}{This macro added}
1013 % \begin{macro}{\caption@removefromoptlist}
1014 % \changes{v1.1}{2007/07/22}{This macro added}
1015 % \changes{v1.2c}{2008/08/24}{Fatal typo corrected}
1016 % |\caption@addtooptlist|\marg{type}\\
1017 % |\caption@removefromoptlist|\marg{type}\\
1018 % adds or removes an \meta{type} to the list of unused caption options.
1019 % Note that the catcodes of \meta{type} are sanitized here so removing
1020 % \meta{type} from the list do not fail when the \pkg{float} package
1021 % is used (since |\float@getstyle| gives a result which tokens have catcode
1022 % 12 $=$ ``other'').
1023 % \begin{macrocode}
1024 \newcommand*\caption@addtooptlist[1]{%
1025 \@ifundefined{caption@opt@#1@lineno}%
1026 {\caption@dooptlist\caption@g@addto@list{#1}%
1027 \expandafter\xdef\csname caption@opt@#1@lineno\endcsname{\the\inputlineno}}%
1028 {}}
1029 % \end{macrocode}
1030 % \begin{macrocode}
1031 \newcommand*\caption@removefromoptlist[1]{%
1032 \caption@dooptlist\caption@g@removefrom@list{#1}%
1033 \global\expandafter\let\csname caption@opt@#1@lineno\endcsname\@undefined}
1034 % \end{macrocode}
1035 % \begin{macrocode}
1036 \newcommand*\caption@dooptlist[2]{%
1037 \begingroup
1038 \edef\@tempa{#2}\@onelevel@sanitize\@tempa
1039 \expandafter#1\expandafter\caption@optlist\expandafter{\@tempa}%
1040 \endgroup}
1041 % \end{macrocode}
1042 % \begin{macrocode}
1043 \AtEndDocument{%
1044 \caption@for@list\caption@optlist
1045 {\caption@WarningNoLine{%
1046 Unused \string\captionsetup[#1]
1047 on input line \csname caption@opt@#1@lineno\endcsname}}}
1048 % \end{macrocode}
1049 % \end{macro}
1050 % \end{macro}
1051 %
1052 % \begin{macro}{\caption@setkeys}
1053 % \changes{v1.0g}{2006/01/03}{This macro added}
1054 % \changes{v1.0j}{2007/01/20}{Bugfix: Usage of \cs{caption@keydepth} added}
1055 % \changes{v1.0j}{2007/01/30}{Optional argument added}
1056 % \changes{v1.0n}{2007/04/08}{\cs{caption@keydepth} is now a command instead of a counter}
1057 % \changes{v1.1b}{2007/09/18}{Usage of \cs{caption@Package} removed, we use \cs{caption@KV@err} instead}
1058 % \changes{v1.2}{2007/11/16}{Bugfix 07-11-09: `space hack' added}
1059 % \changes{v1.2a}{2008/01/12}{\cs{captionsetup@starfalse} added}
1060 % \changes{v1.2d}{2009/09/30}{Bugfix 09-09-29: Missing error handler will be defined automatically}
1061 % \changes{v1.4}{2011/08/24}{Redefinition of \cs{XKV@err} added}
1062 % \changes{v2.4}{2022/04/18}{\cs{captionsetup@starfalse} removed}
1063 % |\caption@setkeys|\oarg{package}\marg{family}\marg{key-values}\\
1064 % expands to |\setkeys|\marg{family}\marg{key-values},
1065 % but lets the error messages not refer to the \pkg{keyval} package
1066 % but to the \meta{package} package instead.
1067 % \begin{macrocode}
1068 \newcommand*\caption@setkeys{\@dblarg\caption@@setkeys}
1069 % \end{macrocode}
1070 % \begin{macrocode}
1071 \long\def\caption@@setkeys[#1]#2#3{%
1072 \@bsphack
1073 % \end{macrocode}
1074 % \begin{macrocode}
1075 \expandafter\let\csname ORI@KV@err\caption@keydepth\endcsname\KV@err
1076 \expandafter\let\csname ORI@KV@errx\caption@keydepth\endcsname\KV@errx
1077 \expandafter\let\csname ORI@XKV@err\caption@keydepth\endcsname\XKV@err
1078 \edef\caption@keydepth{\caption@keydepth i}%
1079 % \end{macrocode}
1080 % \begin{macrocode}
1081 \expandafter\let\expandafter\KV@err\csname #1@KV@err\endcsname
1082 \ifx\KV@err\relax
1083 \def\KV@err##1{\PackageError{#1}{##1}{%
1084 See the #1 package documentation for explanation.}}%
1085 \fi
1086 \def\KV@errx{\KV@err}%
1087 \def\XKV@err{\let\@tempa\XKV@tkey\KV@err}%
1088 % \end{macrocode}
1089 % \begin{macrocode}
1090 \caption@Debug{\noexpand\setkeys{#2}{#3}}%
1091 \setkeys{#2}{#3}%
1092 % \end{macrocode}
1093 % \begin{macrocode}
1094 \edef\caption@keydepth{\expandafter\@gobble\caption@keydepth}%
1095 \expandafter\let\expandafter\KV@err\csname ORI@KV@err\caption@keydepth\endcsname
1096 \expandafter\let\expandafter\KV@errx\csname ORI@KV@errx\caption@keydepth\endcsname
1097 \expandafter\let\expandafter\XKV@err\csname ORI@XKV@err\caption@keydepth\endcsname
1098 % \end{macrocode}
1099 % \begin{macrocode}
1100 \@esphack}
1101 % \end{macrocode}
1102 % \begin{macrocode}
1103 \let\caption@keydepth\@empty
1104 % \end{macrocode}
1105 % \end{macro}
1106 %
1107 % \begin{macro}{\caption@ExecuteOptions}
1108 % \changes{v1.1}{2007/07/15}{This macro added}
1109 % \changes{v1.3}{2010/09/04}{Depends on package now}
1110 % |\caption@ExecuteOptions|\marg{package}\marg{key-value options}\\
1111 % applies the given options using the keyval interface, so we use this one
1112 % instead of |\Execute|\-|Options| offered by \LaTeXe.
1113 % \begin{macrocode}
1114 \newcommand*\caption@ExecuteOptions[2]{%
1115 \expandafter\@expandtwoargs\csname caption@setkeys@#1\endcsname{#1}{#2}}%
1116 \@onlypreamble\caption@ExecuteOptions
1117 % \end{macrocode}
1118 % \end{macro}
1119 %
1120 % \begin{macro}{\caption@ProcessOptions}
1121 % \changes{v1.0a}{2004/01/23}{Bugfix, see \purett{news:[email protected]} for details}
1122 % \changes{v1.0g}{2006/01/03}{Improvement, uses \cs{caption@setkeys} instead of \cs{setkeys}}
1123 % \changes{v1.0h}{2006/02/23}{Bugfix, now processes only those global options which have a default value}
1124 % \changes{v1.0j}{2007/01/30}{\cs{ProcessOptionsWithKV} renamed to \cs{caption@ProcessOptions} and moved from the package to the kernel}
1125 % \changes{v1.1}{2007/04/17}{Starred variant added}
1126 % |\caption@ProcessOptions*|\marg{package}\\
1127 % processes the given options using the keyval package, so we use this one
1128 % instead of |\Process|\-|Options| offered by \LaTeXe.
1129 % The starred variant does not process the global options.
1130 % (This code was taken from the \pkg{hyperref} package\cite{hyperref}
1131 % \version{6.74} and modified.)
1132 % \begin{macrocode}
1133 \newcommand*\caption@ProcessOptions{%
1134 \caption@teststar\caption@@ProcessOptions\@gobble\@firstofone}
1135 \@onlypreamble\caption@ProcessOptions
1136 % \end{macrocode}
1137 % \begin{macrocode}
1138 \newcommand\caption@@ProcessOptions[2]{%
1139 \let\@tempc\relax
1140 \let\caption@tempa\@empty
1141 #1{% \@firstofone -or- \@gobble
1142 \@for\CurrentOption:=\@classoptionslist\do{%
1143 \@ifundefined{KV@#2@\CurrentOption}{}{%
1144 \@ifundefined{KV@#2@\CurrentOption @default}{%
1145 \PackageInfo{#2}{Global option `\CurrentOption' ignored}%
1146 }{%
1147 \PackageInfo{#2}{Global option `\CurrentOption' processed}%
1148 \edef\caption@tempa{\caption@tempa\CurrentOption,}%
1149 \@expandtwoargs\@removeelement\CurrentOption
1150 \@unusedoptionlist\@unusedoptionlist
1151 }%
1152 }%
1153 }%
1154 \let\CurrentOption\@empty
1155 }%
1156 \caption@ExecuteOptions{#2}{\caption@tempa\@ptionlist{\@currname.\@currext}}%
1157 \AtEndOfPackage{\let\@unprocessedoptions\relax}}
1158 \@onlypreamble\caption@@ProcessOptions
1159 % \end{macrocode}
1160 % \end{macro}
1161 %
1162 % \begin{macro}{\caption@SetupOptions}
1163 % \changes{v1.3}{2010/09/04}{This macro added}
1164 % |\caption@SetupOptions|\marg{package}\marg{code}\\
1165 % After application of this command |\caption@Execute|\-|Options| and
1166 % |\use|\-|package| will both be mapped to \meta{code} with \meta{package}
1167 % and \meta{options} as arguments |#1| and |#2|.
1168 % (This helps avoiding ``Option clash'' errors.)
1169 % \begin{macrocode}
1170 \newcommand\caption@SetupOptions[2]{%
1171 \@namedef{caption@setkeys@#1}##1##2{#2}%
1172 \expandafter\@onlypreamble\csname caption@setkeys@#1\endcsname
1173 \@cons\caption@SetupOptions@list{{#1}}}
1174 \@onlypreamble\caption@SetupOptions
1175 % \end{macrocode}
1176 % \begin{macrocode}
1177 \newcommand*\caption@SetupOptions@list{}
1178 \@onlypreamble\caption@SetupOptions@list
1179 % \end{macrocode}
1180 % \begin{macrocode}
1181 %% Unfortunately we have to patch internal \LaTeX\ code here
1182 %% to get rid of unnecessary ``Option clash'' error messages.
1183 %% I have asked Frank Mittelbach and David Carlisle in 2018
1184 %% and have asked Frank again in 2020 for a proper interface instead of
1185 %% this dirty hack, but my requests got declined.
1186 \let\caption@onefilewithoptions\@onefilewithoptions
1187 \def\@onefilewithoptions#1[#2]{%
1188 \begingroup
1189 \def\@tempa{%
1190 \endgroup
1191 \caption@onefilewithoptions{#1}[{#2}]}%
1192 \def\@tempb{#1}%
1193 \def\@elt##1{%
1194 \def\@tempc{##1}%
1195 \ifx\@tempb\@tempc
1196 \def\@tempa{%
1197 \endgroup
1198 \caption@ExecuteOptions{#1}{#2}%
1199 \caption@onefilewithoptions{#1}[]}%
1200 \fi}
1201 \caption@SetupOptions@list
1202 \@tempa}
1203 \@onlypreamble\caption@onefilewithoptions
1204 % \end{macrocode}
1205 % \end{macro}
1206 %
1207 % \section{Declaring and setting key values}
1208 %
1209 % \begin{macro}{\caption@decl}
1210 % \changes{v2.0}{2019/09/10}{This macro added}
1211 % |\caption@decl|\oarg{command}\marg{option}\marg{name}\\
1212 % is used for declaring boxes, fonts, formats etc.
1213 % (It defines |\caption@|\meta{option}|@|\meta{name}
1214 % using the given \meta{command}.)
1215 % \begin{macrocode}
1216 \newcommand*\caption@decl[3][\def]{%
1217 \global\long\expandafter#1\csname caption@#2@#3\endcsname}
1218 \@onlypreamble\caption@decl
1219 % \end{macrocode}
1220 % \end{macro}
1221 %
1222 % \begin{macro}{\caption@ifdecl}
1223 % \changes{v2.0}{2019/09/10}{This macro added}
1224 % |\caption@ifdecl|\marg{option}\marg{name}\marg{yes-code}\marg{no-code}\\
1225 % checks if the given \meta{option} and \meta{name} combination is
1226 % already declared.
1227 % \begin{macrocode}
1228 \newcommand*\caption@ifdecl[2]{%
1229 \@ifundefined{caption@#1@#2}\@secondoftwo\@firstoftwo}
1230 % \end{macrocode}
1231 % \end{macro}
1232 %
1233 % \begin{macro}{\caption@checkdecl}
1234 % \changes{v2.0}{2019/09/10}{This macro added}
1235 % |\caption@checkdecl|\marg{option}\marg{name}\marg{yes-code}\\
1236 % behaves similar to |\caption@if|\-|decl| but issues an error message if the
1237 % given \meta{option} plus \meta{name} is not defined.
1238 % \begin{macrocode}
1239 \newcommand*\caption@checkdecl[2]{%
1240 \caption@ifdecl{#1}{#2}%
1241 \@firstofone
1242 {\caption@Error{Undefined #1 `#2'}%
1243 \@gobble}}
1244 % \end{macrocode}
1245 % \end{macro}
1246 %
1247 % \begin{macro}{\caption@set}
1248 % \changes{v2.0}{2019/09/10}{This macro added}
1249 % \changes{v2.0}{2020/07/26}{Uses \cs{def} instead of \cs{let} internally}
1250 % |\caption@set|\marg{option}\marg{name}\\
1251 % sets the declared \meta{option} to \meta{name}, for example
1252 % |label|\-|format| to |simple|.
1253 % Note that since version \version{2.0} future changes to \meta{name}
1254 % (via |\caption@decl|) will effect the outcome,
1255 % for example |\caption@decl{labelformat}{simple}\ldots| will not only change
1256 % the definition of the label format |simple| but also effect the current
1257 % label format if set to |simple| (via |\caption@set|).
1258 % \begin{macrocode}
1259 \newcommand*\caption@set{%
1260 \caption@maparg\caption@@set}%
1261 % \end{macrocode}
1262 % \begin{macrocode}
1263 \newcommand*\caption@@set[3]{%
1264 \caption@checkdecl{#1}{#3}{%
1265 % \expandafter\edef\csname caption@@#2\endcsname{#3}% could be used for debugging
1266 \expandafter\def\csname caption@#2\expandafter\endcsname\expandafter{\csname caption@#1@#3\endcsname}}}
1267 % \end{macrocode}
1268 % \end{macro}
1269 %
1270 % \begin{macro}{\SetCaptionDefault}
1271 % \changes{v2.0}{2019/09/10}{This macro added}
1272 % \changes{v2.0}{2020/07/28}{Check for `default' added to prevent infinite loop}
1273 % |\SetCaptionDefault*|\marg{option}\marg{name}\\
1274 % sets the default value for the \meta{option}.
1275 % The starred variant is only relevant for setting default values for lengths
1276 % like |margin|. (See definition of |\caption@set|\-|default@length| for
1277 % details.)
1278 % \begin{macrocode}
1279 \newcommand*\SetCaptionDefault{%
1280 \caption@teststar\caption@setdefault\def\edef}
1281 \@onlypreamble\SetCaptionDefault
1282 % \end{macrocode}
1283 % \begin{macrocode}
1284 \newcommand*\caption@setdefault[2]{%
1285 \@ifundefined{caption@setdefault@#2}%
1286 {\caption@maparg\caption@@setdefault}%
1287 {\@nameuse{caption@setdefault@#2}{#1}}%
1288 {#2}}
1289 % \end{macrocode}
1290 % \begin{macrocode}
1291 \newcommand*\caption@@setdefault[3]{%
1292 \caption@ifdefault{#3}%
1293 {\caption@Error{Invalid argument for \string\SetCaptionDefault: `#3'}}% would cause an infinite loop otherwise
1294 {\caption@@set{#1}{#2@default}{#3}}}
1295 % \end{macrocode}
1296 % \end{macro}
1297 %
1298 % \begin{macro}{\caption@ifdefault}
1299 % \changes{v2.0}{2020/08/23}{This macro added}
1300 % |\caption@ifdefault|\marg{value}\marg{yes-code}\marg{no-code}\\
1301 % expands to \meta{yes-code} if the \meta{value} expands to `default',
1302 % and to \meta{no-code} otherwise.
1303 % \begin{macrocode}
1304 \newcommand*\caption@ifdefault{\caption@ifequal{default}}
1305 % \end{macrocode}
1306 % \begin{macrocode}
1307 \newcommand*\caption@ifequal[2]{%
1308 \edef\caption@tempa{#1}%
1309 \edef\caption@tempb{#2}%
1310 \ifx\caption@tempa\caption@tempb
1311 \expandafter\@firstoftwo
1312 \else
1313 \expandafter\@secondoftwo
1314 \fi}
1315 % \end{macrocode}
1316 % \end{macro}
1317 %
1318 % \begin{macro}{\caption@setmapping}
1319 % \changes{v2.0}{2020/08/23}{This macro added}
1320 % |\caption@setmapping|\marg{source option}\marg{destination option}\\
1321 % sets a mapping from the \meta{source option} to the
1322 % \meta{destination option}, for example |label|\-|font| to |font|
1323 % since |label|\-|font| does not have any own definitions but shares
1324 % them with |font|.
1325 % \begin{macrocode}
1326 \newcommand*\caption@setmapping[2]{%
1327 \@namedef{caption@map@#1}{#2}}
1328 \@onlypreamble\caption@setmapping
1329 % \end{macrocode}
1330 % \end{macro}
1331 %
1332 % \begin{macro}{\caption@maparg}
1333 % \changes{v2.0}{2020/08/23}{This macro added}
1334 % |\caption@maparg|\marg{command}\marg{option}\\
1335 % similar to |\@dblarg| but either duplicates the given \meta{option} or
1336 % expands it to \meta{destination option} plus \meta{option} if a mapping
1337 % was defined for the given option (via |\caption@set|\-|mapping|).
1338 % \begin{macrocode}
1339 \newcommand*\caption@maparg[2]{%
1340 \@ifundefined{caption@map@#2}%
1341 {#1{#2}}%
1342 {#1{\csname caption@map@#2\endcsname}}%
1343 {#2}}
1344 % \end{macrocode}
1345 % \end{macro}
1346 %
1347 % \begin{macro}{\caption@switchdefault}
1348 % \changes{v2.0}{2020/08/01}{This macro added}
1349 % |\caption@switchdefault\marg{option}|\marg{code with \#1}\marg{name}\\
1350 % like |\Set|\-|Caption|\-|Default| but first expands the given code with the
1351 % to-be-overwritten internal command as argument, so it can be stored (and
1352 % restored later on).
1353 % The main purpose of this command is switching default settings in
1354 % \pkg{babel} language packages, e.g.:
1355 % \begin{quote}|\caption@switchdefault{labelfont}{\babel@save #1}{sc}|\end{quote}
1356 % \begin{macrocode}
1357 \def\caption@switchdefault#1#2{%
1358 \def\caption@tempa##1{#2}%
1359 \expandafter\caption@tempa\csname caption@#1@default\endcsname
1360 \caption@setdefault\def{#1}}
1361 % \end{macrocode}
1362 % \end{macro}
1363 %
1364 % \begin{macro}{\caption@restoredefault}
1365 % \changes{v2.0}{2020/08/01}{This macro added}
1366 % |\caption@restoredefault\marg{option}|\marg{command}\\
1367 % restores a default setting which was stored to \meta{command} before
1368 % (via |\caption@switch|\-|default|).
1369 % \begin{macrocode}
1370 \def\caption@restoredefault#1#2{%
1371 \caption@checkdecl{#1}{default}{%
1372 \caption@ifdefined#2{%
1373 \expandafter\let\csname caption@#1@default\endcsname#2%
1374 \let#2\@undefined}{}}}
1375 % \end{macrocode}
1376 % \end{macro}
1377 %
1378 % \begin{macro}{\SetCaptionFallback}
1379 % \changes{v2.2}{2020/09/21}{This macro added}
1380 % |\SetCaptionFallback|\marg{option}\marg{name}\\
1381 % sets the fallback value for the \meta{option}.
1382 % \begin{macrocode}
1383 \newcommand*\SetCaptionFallback{%
1384 \caption@maparg\caption@@setfallback}
1385 \@onlypreamble\SetCaptionFallback
1386 % \end{macrocode}
1387 % \begin{macrocode}
1388 \newcommand*\caption@@setfallback[3]{%
1389 \caption@ifequal{fallback}{#3}%
1390 {\caption@Error{Invalid argument for \string\SetCaptionFallback: `#3'}}% would cause an infinite loop otherwise
1391 {\caption@@set{#1}{#2@fallback}{#3}}}
1392 \@onlypreamble\caption@@setfallback
1393 % \end{macrocode}
1394 % \end{macro}
1395 %
1396 % \begin{macro}{\caption@decl@package}
1397 % \changes{v2.0}{2020/07/26}{This macro added}
1398 % \changes{v2.4}{2022/04/18}{\cs{@ifnextchar} replaced by \cs{kernel@ifnextchar}}
1399 % |\caption@decl@package|\marg{option}\marg{cmd}\oarg{package}\marg{name}\ldots\\
1400 % Helper command to declare a caption package option value which is dependent
1401 % on the existence of a specific package, for example the |font| value
1402 % |one|\-|half|\-|spacing| which is dependent on the \pkg{setspace}
1403 % package.
1404 % \begin{macrocode}
1405 \newcommand*\caption@decl@package[2]{%
1406 \kernel@ifnextchar[%]
1407 {\caption@declare@package{#1}{#2}}%
1408 {\caption@declarepackage{#1}{#2}}}
1409 \@onlypreamble\caption@decl@package
1410 % \end{macrocode}
1411 % \begin{macrocode}
1412 \def\caption@declare@package#1#2[#3]#4{%
1413 \global\@namedef{caption@#1@#4@package}{#3}%
1414 #2{#4}}
1415 \@onlypreamble\caption@declare@package
1416 % \end{macrocode}
1417 % \begin{macrocode}
1418 \newcommand*\caption@declarepackage[3]{%
1419 \global\@nameundef{caption@#1@#3@package}%
1420 #2{#3}}
1421 \@onlypreamble\caption@declarepackage
1422 % \end{macrocode}
1423 % \end{macro}
1424 %
1425 % \begin{macro}{\caption@load@package}
1426 % \changes{v2.0}{2020/07/26}{This macro added}
1427 % |\caption@load@package|\marg{option}\marg{value}\\
1428 % If the given option value needs a package, it will be loaded automatically.
1429 % \begin{macrocode}
1430 \newcommand*\caption@load@package[2]{%
1431 \expandafter\let\expandafter\caption@tempa\csname caption@#1@#2@package\endcsname
1432 \caption@ifdefined\caption@tempa
1433 {\caption@requirepackage\caption@tempa{#1=#2}}%
1434 {}}
1435 % \end{macrocode}
1436 % \end{macro}
1437 %
1438 % \section{Declaring and setting lengths}
1439 %
1440 % \begin{macro}{\DeclareCaptionLength}
1441 % \changes{v2.0}{2020/08/09}{This macro added}
1442 % \changes{v2.3}{2021/01/17}{Now defines \cs{caption@xxx} instead of \cs{captionxxx} as length}
1443 % |\DeclareCaptionLength|\marg{name}\marg{default value}\\
1444 % \begin{enumerate}
1445 % \item Defines a new length (dimension)
1446 % \item Installes a hook for |\caption@set|\-|default| so
1447 % |\caption@set|\-|default@length| will be used to set a default
1448 % value for this length
1449 % \item Sets a default value using |\Set|\-|Caption|\-|Default*|.
1450 % \end{enumerate}
1451 % \begin{macrocode}
1452 \newcommand*\DeclareCaptionLength[1]{%
1453 \expandafter\newdimen\csname caption@#1\endcsname
1454 \@namedef{caption@setdefault@#1}{\caption@setdefault@length}%
1455 \SetCaptionDefault*{#1}}
1456 \@onlypreamble\DeclareCaptionLength
1457 % \end{macrocode}
1458 % \end{macro}
1459 %
1460 % \begin{macro}{\caption@setdefault@length}
1461 % \changes{v2.0}{2020/08/09}{This macro added}
1462 % \changes{v2.3}{2021/01/17}{Adapted to current implementation of \cs{DeclareCaptionLength}}
1463 % |\caption@setdefault@length*|\marg{cmd}\marg{name}\marg{value}\\
1464 % sets a default value for the given \meta{length}, either using |\def|
1465 % (if the starred variant is used) or |\edef| (if the non-starred variant is
1466 % used).
1467 % \begin{macrocode}
1468 \newcommand*\caption@setdefault@length[3]{%
1469 \expandafter#1\csname caption@#2@default\endcsname{#3}}
1470 % \end{macrocode}
1471 % \end{macro}
1472 %
1473 % \begin{macro}{\caption@setlength}
1474 % \changes{v2.0}{2020/08/09}{This macro added}
1475 % \changes{v2.3}{2021/01/17}{Adapted to current implementation of \cs{DeclareCaptionLength}}
1476 % |\caption@setlength|\marg{name}\marg{value}\\
1477 % sets a length to either the given \meta{value} or to the default value if
1478 % \meta{value} is `default'.
1479 % \begin{macrocode}
1480 \newcommand*\caption@setlength[2]{%
1481 \caption@ifdefault{#2}%
1482 {\expandafter\let\expandafter\caption@tempa\csname caption@#1@default\endcsname}%
1483 {\def\caption@tempa{#2}}%
1484 \expandafter\setlength\csname caption@#1\endcsname\caption@tempa}
1485 % \end{macrocode}
1486 % \end{macro}
1487 %
1488 % \begin{macro}{\caption@tempdima}
1489 % |\caption@tempdima| will be used as temporary dimension register, similar to |\@tempdima|.
1490 % \begin{macrocode}
1491 \newdimen\caption@tempdima
1492 % \end{macrocode}
1493 % \end{macro}
1494 %
1495 % \section{Margin or width}
1496 % \changes{v1.0n}{2007/04/03}{Option `twoside' added}
1497 % \changes{v1.1}{2007/08/11}{Options `margin*', `minmargin', and `maxmargin' added}
1498 % \changes{v1.2}{2007/11/10}{Option `oneside' added}
1499 %
1500 % \begin{macro}{\captionmargin}
1501 % |\captionmargin| contains the extra margin used for captions (if different than |0pt|).
1502 % It is just available for user documents to provide compatibility to \version{1.x} of
1503 % the \pkg{caption} package where |\set|\-|length\caption|\-|margin{|\ldots|}| was
1504 % the way how a caption margin was set.
1505 % \begin{macrocode}
1506 \newdimen\captionmargin
1507 \setlength\captionmargin{0pt}
1508 % \end{macrocode}
1509 % |\SetCaptionDefault{margin}{|\ldots|}| sets both default values,
1510 % i.e.~for the left and for the right margin.
1511 % \begin{macrocode}
1512 \newcommand\caption@setdefault@margin[3]{%
1513 \caption@setdefault@length{#1}{left#2}{#3}%
1514 \caption@setdefault@length{#1}{right#2}{#3}}
1515 % \end{macrocode}
1516 % \end{macro}
1517 %
1518 % \begin{macro}{\caption@leftmargin}
1519 % \changes{v1.0n}{2007/04/01}{\cs{captionmarginx} renamed to \cs{captionmargin@}}
1520 % \changes{v2.3}{2021/01/17}{\cs{captionmargin@} replaced by \cs{caption@leftmargin} and \cs{caption@rightmargin}}
1521 % \begin{macro}{\caption@rightmargin}
1522 % \changes{v1.0n}{2007/04/01}{\cs{captionmarginx} renamed to \cs{captionmargin@}}
1523 % \changes{v2.3}{2021/01/17}{\cs{captionmargin@} replaced by \cs{caption@leftmargin} and \cs{caption@rightmargin}}
1524 % |\caption@leftmargin| and |\caption@rightmargin| contain the extra margin used for captions.
1525 % (These values will be used if the obsolete |\caption|\-|margin| is set to |0pt|.)
1526 % \begin{macrocode}
1527 \DeclareCaptionLength{leftmargin}{0pt}
1528 \DeclareCaptionLength{rightmargin}{0pt}
1529 % \end{macrocode}
1530 % \end{macro}
1531 % \end{macro}
1532 %
1533 % \begin{macro}{\caption@width}
1534 % \changes{v2.3}{2021/01/17}{This dimension renamed from \cs{captionwidth} to \cs{caption@width}}
1535 % |\caption@width| contains the total width used for captions.
1536 % Note that we can only set one value at a time, `margin' \emph{or} `width'.
1537 % If |\caption|\-|@width| is not zero we will take this value,
1538 % otherwise |\caption|\-|@left|\-|margin| and |\caption|\-|@right|\-|margin|.
1539 % \begin{macrocode}
1540 \newdimen\caption@width
1541 \setlength\caption@width{0pt}
1542 % \end{macrocode}
1543 % \end{macro}
1544 %
1545 % \begin{macrocode}
1546 \DeclareCaptionOption{margin}{\caption@setmargin{#1}}
1547 \DeclareCaptionOption{margin*}{\caption@setmargin*{#1}}
1548 \DeclareCaptionOption{width}{\caption@setwidth{#1}}
1549 \DeclareCaptionOption{width*}{\caption@setwidth*{#1}}
1550 % \end{macrocode}
1551 % \begin{macrocode}
1552 \DeclareCaptionOption{calcmargin}{\caption@setcalcmargin{#1}}
1553 \DeclareCaptionOption{calcmargin*}{\caption@setcalcmargin*{#1}}
1554 \DeclareCaptionOption{calcwidth}{\caption@setcalcwidth{#1}}
1555 \DeclareCaptionOption{calcwidth*}{\caption@setcalcwidth*{#1}}
1556 % \end{macrocode}
1557 % \begin{macrocode}
1558 \DeclareCaptionOption{twoside}[1]{\caption@set@bool\caption@iftwoside{#1}}
1559 \DeclareCaptionOptionNoValue{oneside}{\caption@set@bool\caption@iftwoside0}
1560 \caption@set@bool\caption@iftwoside{\if@twoside 1\else 0\fi}
1561 % \end{macrocode}
1562 % \begin{macrocode}
1563 \DeclareCaptionOption{minmargin}{\caption@setoptcmd\caption@minmargin{#1}}
1564 \DeclareCaptionOption{maxmargin}{\caption@setoptcmd\caption@maxmargin{#1}}
1565 % \end{macrocode}
1566 %
1567 % \begin{macro}{\caption@setmargin}
1568 % \changes{v1.0f}{2005/10/24}{Renamed from \cs{caption@setmargin} to \cs{setcaptionmargin}}
1569 % \changes{v1.0f}{2005/10/24}{\cs{setcaptionmargin} enhanced so it can take left+right margin}
1570 % \changes{v1.1}{2007/08/11}{Starred variant added}
1571 % \changes{v1.1}{2007/08/12}{\cs{setlength}\cs{captionmargin} \& \cs{setlength}\cs{captionmargin@} swapped so `\texttt{margin*=}\cs{captionmargin}' works in singleline options}
1572 % \changes{v1.3}{2010/11/07}{Support for option \opt{calcmargin} added}
1573 % \changes{v2.3}{2021/01/17}{Renamed from \cs{setcaptionmargin} to \cs{caption@setmargin}; sets \cs{caption@width} or \cs{caption@leftmargin} and \cs{caption@rightmargin} now}
1574 % \changes{v2.3}{2021/01/19}{Only the left or right margin can be set by leaving the other value blank}
1575 % \changes{v2.4d}{2023/07/31}{Check for \cs{@empty} argument replaced by \cs{caption@iftokens}}
1576 % |\caption@setmargin*|\marg{amount}\\
1577 % sets the caption margin to the given \meta{amount}.
1578 % \begin{macrocode}
1579 \newcommand*\caption@setmargin{%
1580 \caption@resetcalcmargin
1581 \caption@@setmargin}
1582 % \end{macrocode}
1583 % \begin{macrocode}
1584 \newcommand*\caption@@setmargin{%
1585 \caption@teststar\caption@@@setmargin\@gobble\@firstofone}
1586 % \end{macrocode}
1587 % \begin{macrocode}
1588 \newcommand*\caption@@@setmargin[2]{%
1589 #1{\caption@width\z@}%
1590 \caption@@@@setmargin#2,#2,\@nil}
1591 % \end{macrocode}
1592 % \begin{macrocode}
1593 \def\caption@@@@setmargin#1,#2,#3\@nil{%
1594 \caption@iftokens{#1#2}%
1595 {\caption@@@@@setmargin{left}{#1}%
1596 \caption@@@@@setmargin{right}{#2}}%
1597 {\caption@Error{Missing number}}}
1598 % \end{macrocode}
1599 % \begin{macrocode}
1600 \newcommand*\caption@@@@@setmargin[2]{%
1601 \caption@iftokens{#2}{\caption@setlength{#1margin}{#2}}{}}
1602 % \end{macrocode}
1603 % \end{macro}
1604 %
1605 % \begin{macro}{\caption@setwidth}
1606 % \changes{v1.0f}{2005/10/24}{Renamed from \cs{caption@setwidth} to \cs{setcaptionwidth}}
1607 % \changes{v1.3}{2010/11/07}{Starred variant added}
1608 % \changes{v1.3}{2010/11/07}{Support for option \opt{calcwidth} added}
1609 % \changes{v2.3}{2021/01/17}{Renamed from \cs{setcaptionwidth} to \cs{caption@setwidth}; sets \cs{caption@width} or \cs{caption@leftmargin} and \cs{caption@rightmargin} now}
1610 % |\caption@setwidth*|\marg{amount}\\
1611 % sets the caption width to the given \meta{amount}.
1612 % \begin{macrocode}
1613 \newcommand*\caption@setwidth{%
1614 \caption@resetcalcmargin
1615 \caption@@setwidth}
1616 % \end{macrocode}
1617 % \begin{macrocode}
1618 \newcommand*\caption@@setwidth{%
1619 \caption@teststar\caption@@@setwidth\@gobble\@firstofone}
1620 % \end{macrocode}
1621 % \begin{macrocode}
1622 \newcommand*\caption@@@setwidth[2]{%
1623 #1{\caption@leftmargin\z@\caption@rightmargin\z@}%
1624 \setlength\caption@width{#2}}
1625 % \end{macrocode}
1626 % \end{macro}
1627 %
1628 % \begin{macro}{\caption@setcalcmargin}
1629 % \changes{v1.3}{2010/11/07}{This macro added}
1630 % \changes{v2.3}{2021/01/17}{Adapted to current implementation of \cs{caption@setmargin}}
1631 % |\caption@setcalcmargin*|\marg{amount}\\
1632 % sets the caption margin to the given \meta{amount}
1633 % right before the caption will be typeset, i.e.\meta{amount} will
1634 % not be evaluated immediately.
1635 % \begin{macrocode}
1636 \newcommand*\caption@setcalcmargin{%
1637 \caption@teststar{\caption@@setcalcmargin\caption@@setmargin}%
1638 \@secondoftwo\@firstoftwo}
1639 % \end{macrocode}
1640 % \begin{macrocode}
1641 \newcommand*\caption@@setcalcmargin[3]{%
1642 #2{\caption@resetcalcmargin
1643 \l@addto@macro\caption@calcmargin@hook{#1{#3}}}%
1644 {\l@addto@macro\caption@calcmargin@hook{#1*{#3}}}}
1645 % \end{macrocode}
1646 % \end{macro}
1647 %
1648 % \begin{macro}{\caption@resetcalcmargin}
1649 % \changes{v1.3}{2010/11/07}{This macro added}
1650 % |\caption@resetcalcmargin|\\
1651 % clears the value which was stored in |\caption@set|\-|calc|\-|margin|.
1652 % \begin{macrocode}
1653 \newcommand*\caption@resetcalcmargin{%
1654 \let\caption@calcmargin@hook\@empty}
1655 % \end{macrocode}
1656 % \end{macro}
1657 %
1658 % \begin{macro}{\caption@setcalcwidth}
1659 % \changes{v1.3}{2010/11/07}{This macro added}
1660 % \changes{v2.3}{2021/01/17}{Adapted to current implementation of \cs{caption@setmargin}}
1661 % |\caption@setcalcwidth*|\marg{amount}\\
1662 % sets the caption width to the given \meta{amount}
1663 % right before the caption will be typeset, i.e.\meta{amount} will
1664 % not be evaluated immediately.
1665 % \begin{macrocode}
1666 \newcommand*\caption@setcalcwidth{%
1667 \caption@teststar{\caption@@setcalcmargin\caption@@setwidth}%
1668 \@secondoftwo\@firstoftwo}
1669 % \end{macrocode}
1670 % \end{macro}
1671 %
1672 % \begin{macro}{\caption@thecounter}
1673 % \changes{v1.0n}{2007/04/03}{This counter added}
1674 % \changes{v1.1e}{2007/10/28}{Renamed from \cs{caption@counter} to \cs{caption@thecounter}; \cs{caption@stepcounter} added}
1675 % \changes{v1.5}{2012/04/09}{\cs{caption@stepcounter} renamed to \cs{caption@stepthecounter}}
1676 % \changes{v2.4}{2023/03/12}{Definition of \cs{caption@ifoddpage} added to \cs{caption@stepthecounter}}
1677 % Internal counter.
1678 % At the moment it will be used inside |\caption@if|\-|odd|\-|page| only.
1679 % \begin{macrocode}
1680 \newcommand*\caption@thecounter{0}
1681 % \end{macrocode}
1682 % \begin{macrocode}
1683 \newcommand*\caption@stepthecounter{%
1684 \@tempcnta\caption@thecounter
1685 \advance\@tempcnta\@ne\relax
1686 \xdef\caption@thecounter{\the\@tempcnta}%
1687 \global\let\caption@ifoddpage\caption@ifoddpage@}
1688 % \end{macrocode}
1689 % \end{macro}
1690 %
1691 % \begin{macro}{\caption@newlabel}
1692 % \changes{v1.0n}{2007/04/03}{This macro added}
1693 % |\caption@newlabel|\marg{name}\marg{value}\\
1694 % This command is a modified version of |\new|\-|label| from \LaTeX2e.
1695 % It will be written to the \texttt{.aux} file to
1696 % pass label information from one run to another.
1697 % (We use it inside |\caption@if|\-|odd|\-|page|.)
1698 % \begin{macrocode}
1699 \newcommand*\caption@newlabel{\@newl@bel{caption@r}}
1700 % \end{macrocode}
1701 % \end{macro}
1702 %
1703 % \begin{macro}{\caption@thepage}
1704 % \changes{v1.0n}{2007/04/03}{This macro added}
1705 % This command is a modified version of |\the|\-|page| from \LaTeX2e.
1706 % It will be used inside |\caption@if|\-|odd|\-|page| only.
1707 % \begin{macrocode}
1708 \newcommand*\caption@thepage{\the\c@page}
1709 % \end{macrocode}
1710 % \end{macro}
1711 %
1712 % \begin{macro}{\caption@label}
1713 % \changes{v1.1}{2007/09/01}{This macro added}
1714 % \changes{v1.2}{2007/12/03}{Definition of \cs{caption@newlabel} in aux file added}
1715 % |\caption@label|\marg{name}\\
1716 % This command is a modified version of |\label| from \LaTeX2e.
1717 % It will be used inside |\caption@if|\-|odd|\-|page| and |\FP@help|\-|Note|.
1718 % \begin{macrocode}
1719 \newcommand*\caption@label[1]{%
1720 \caption@@label
1721 \protected@write\@auxout{\let\caption@thepage\relax}%
1722 {\string\caption@newlabel{#1}{\caption@thepage}}}
1723 % \end{macrocode}
1724 % \begin{macrocode}
1725 \newcommand*\caption@@label{%
1726 \global\let\caption@@label\relax
1727 \protected@write\@auxout{}%
1728 {\string\providecommand*\string\caption@newlabel[2]{}}}
1729 % \end{macrocode}
1730 % \end{macro}
1731 %
1732 % \begin{macro}{\caption@pageref}
1733 % \changes{v1.1}{2007/09/01}{This macro added}
1734 % \changes{v1.2d}{2009/10/09}{Uses \cs{@latex@warning} instead of \cs{caption@Warning}}
1735 % \changes{v2.4}{2023/03/12}{The warning refers to \texttt{caption@NUM} instead of \texttt{NUM}}
1736 % \changes{v2.4a}{2023/03/13}{The warning refers to \texttt{caption NUM} instead of \texttt{caption@NUM}}
1737 % |\caption@pageref|\marg{name}\\
1738 % This command is a modified version of |\page|\-|ref| from \LaTeX2e.
1739 % It will be used inside |\caption@if|\-|odd|\-|page| and |\FP@help|\-|Note|.
1740 % \begin{macrocode}
1741 \newcommand*\caption@pageref[1]{%
1742 \expandafter\ifx\csname caption@r@#1\endcsname\relax
1743 \G@refundefinedtrue % => 'There are undefined references.'
1744 \@latex@warning{Reference `caption #1' on page \thepage \space undefined}%
1745 \else
1746 \expandafter\let\expandafter\caption@thepage\csname caption@r@#1\endcsname
1747 \fi}
1748 % \end{macrocode}
1749 % \end{macro}
1750 %
1751 % \begin{macro}{\caption@ifoddpage}
1752 % \changes{v1.0n}{2007/04/03}{This macro added}
1753 % \changes{v1.1e}{2007/10/28}{Incrementation of counter moved to \cs{caption@@make}}
1754 % \changes{v2.4}{2023/03/12}{Multiple use for the same counter will be handled correctly}
1755 % Currently this macro uses an own label\ldots ref mechanism,
1756 % but an alternative implementation method would use the
1757 % \pkg{refcount} package\cite{refcount} and
1758 % |\ifodd\get|\-|page|\-|ref|\-|number{|\ldots|}|.
1759 % Maybe we will change that in a later release.
1760 % \Note{This macro re-defines itself so the \texttt{.aux} file will only be used once per group.
1761 % This re-definition will be reset in \cs{caption@stepthecounter}.}
1762 % \begin{macrocode}
1763 \newcommand*\caption@ifoddpage@{%
1764 \caption@iftwoside{%
1765 \caption@label\caption@thecounter
1766 \caption@pageref\caption@thecounter
1767 \ifodd\caption@thepage
1768 \global\let\caption@ifoddpage\@firstoftwo
1769 \else
1770 \global\let\caption@ifoddpage\@secondoftwo
1771 \fi
1772 }{\global\let\caption@ifoddpage\@firstoftwo}%
1773 % \end{macrocode}
1774 % \begin{macrocode}
1775 \caption@ifoddpage}
1776 % \end{macrocode}
1777 % \end{macro}
1778 %
1779 % \begin{macro}{\caption@setoptcmd}
1780 % \changes{v1.1}{2007/08/11}{This macro added}
1781 % |\caption@setoptcmd|\marg{command}\marg{off -or- value}\\
1782 % defines the given \meta{command} to \meta{value},
1783 % but if \meta{value} if `off' the given \meta{command} is undefined instead.
1784 % \begin{macrocode}
1785 \newcommand*\caption@setoptcmd[2]{%
1786 \caption@ifinlist{#2}{0,false,no,off}{\let#1\@undefined}{\def#1{#2}}}
1787 % \end{macrocode}
1788 % \end{macro}
1789 %
1790 % \section{Indentions}
1791 %
1792 % \begin{macro}{\caption@indent}
1793 % \changes{v1.1}{2007/07/29}{Renamed from \cs{captionindent} to \cs{caption@indent}}
1794 % \begin{macro}{\caption@parindent}
1795 % \begin{macro}{\caption@hangindent}
1796 % These are the indentions we support.
1797 % \begin{macrocode}
1798 \DeclareCaptionLength{indent}{0pt}
1799 \DeclareCaptionLength{parindent}{0pt}
1800 \DeclareCaptionLength{hangindent}{0pt}
1801 % \end{macrocode}
1802 % \end{macro}
1803 % \end{macro}
1804 % \end{macro}
1805 %
1806 % \changes{v1.0b}{2004/05/16}{Defaults added for options \opt{parindent=} and \opt{hangindent=}}
1807 % \changes{v1.0f}{2005/08/22}{Option \opt{parskip=}: \cs{AtBeginCaption} replaced by \cs{caption@@par}}
1808 % \changes{v1.0f}{2005/08/22}{Undocumented defaults for \opt{parindent=}, \opt{hangindent=}, and \opt{parskip=} removed}
1809 % \begin{macrocode}
1810 \DeclareCaptionOption{indent}[\leftmargini]{% obsolete
1811 \caption@setlength{indent}{#1}}
1812 \DeclareCaptionOption{indention}[\leftmargini]{%
1813 \caption@setlength{indent}{#1}}
1814 \DeclareCaptionOption{parindent}{%
1815 \caption@setlength{parindent}{#1}}
1816 \DeclareCaptionOption{hangindent}{%
1817 \caption@setlength{hangindent}{#1}}
1818 \DeclareCaptionOption{parskip}{%
1819 \l@addto@macro\caption@@par{\setlength\parskip{#1}}}
1820 % \end{macrocode}
1821 %
1822 % \section{Styles}
1823 %
1824 % \begin{macro}{\DeclareCaptionStyle}
1825 % \changes{v1.0a}{2004/01/17}{Pass through argument \#3 so extra spaces between arguments do make any harm}
1826 % \changes{v2.0}{2019/09/10}{Uses \cs{caption@decl} now}
1827 % \changes{v2.0}{2020/07/27}{\cs{caption@sls} renamed to \cs{caption@slsty}}
1828 % |\DeclareCaptionStyle|\marg{name}\oarg{single-line-list-of-KV}\marg{list-of-KV}
1829 % \begin{macrocode}
1830 \newcommand*\DeclareCaptionStyle[1]{%
1831 \@testopt{\caption@declarestyle{#1}}{}}
1832 \@onlypreamble\DeclareCaptionStyle
1833 % \end{macrocode}
1834 % \begin{macrocode}
1835 \def\caption@declarestyle#1[#2]#3{%
1836 \caption@decl{style}{#1}%
1837 {\def\caption@slsty{#2}%
1838 \def\caption@sty{#3}}%
1839 % \end{macrocode}
1840 % The \pkg{floatrow} package uses |\@if|\-|undefined{caption@sty@#1}| to
1841 % determine in |\flrow@set|\-|style| if a caption style is defined or not.
1842 % Since the \pkg{floatrow} package is unmaintained we fake the definition
1843 % so the test will still work.
1844 % \begin{macrocode}
1845 \@namedef{caption@sty@#1}{\@unused}}
1846 \@onlypreamble\caption@declarestyle
1847 % \end{macrocode}
1848 % \end{macro}
1849 %
1850 % \changes{v1.2a}{2008/01/20}{Option \opt{style*=} added}
1851 % \begin{macrocode}
1852 \DeclareCaptionOption{style}{\caption@setstyle{#1}}
1853 \DeclareCaptionOption{style*}{\caption@setstyle*{#1}}
1854 % \end{macrocode}
1855 %
1856 % \begin{macro}{\caption@setstyle}
1857 % \changes{v1.0e}{2005/06/01}{Starred variant added}
1858 % \changes{v1.1}{2007/07/29}{Recursive style definitions should work now}
1859 % \changes{v1.1d}{2007/10/23}{`SingleLine' renamed to `singleline' for consistency}
1860 % \changes{v1.2}{2007/12/03}{Definition of \cs{caption@iftypewarning} removed}
1861 % \changes{v2.0}{2019/09/10}{Uses \cs{caption@ifdecl} and \cs{caption@checkdecl} now}
1862 % |\caption@setstyle*|\marg{name}\\
1863 % Selecting a caption style means saving the additional
1864 % \meta{single-line-list-of-KV} (this will be done by |\caption@sl|\-|sty|),
1865 % resetting the caption options to the base ones (this will be done using
1866 % |\caption@reset|\-|style|) and executing the \meta{list-of-KV} options
1867 % (this will be done using |\caption@setup|).\par
1868 % The starred version will give no error message if the given style is not
1869 % defined.
1870 % \begin{macrocode}
1871 \newcommand*\caption@setstyle{%
1872 \caption@teststar\caption@@setstyle\caption@ifdecl\caption@checkdecl}
1873 % \end{macrocode}
1874 % \begin{macrocode}
1875 \newcommand*\caption@@setstyle[2]{%
1876 #1{style}{#2}%
1877 {\caption@set{style}{#2}%
1878 \caption@style % defines \caption@sty & \caption@slsty
1879 \ifx\caption@setstyle@flag\@undefined
1880 \let\caption@setstyle@flag\relax % prevent \caption@resetstyle if called recursively
1881 \caption@resetstyle
1882 \caption@xsetup\caption@sty
1883 \let\caption@setstyle@flag\@undefined
1884 \else
1885 \caption@xsetup\caption@sty
1886 \fi}%
1887 {}}
1888 % \end{macrocode}
1889 % \end{macro}
1890 %
1891 % \begin{macro}{\caption@resetstyle}
1892 % \changes{v1.1}{2007/02/04}{This macro renamed from \cs{caption@setdefault} to \cs{caption@resetstyle}}
1893 % \changes{v1.1d}{2007/10/23}{`SingleLine' renamed to `singleline' for consistency}
1894 % \changes{v1.2}{2007/11/17}{Usage of \opt{size=} added}
1895 % \changes{v1.2b}{2008/05/06}{Usage of \opt{rule} added}
1896 % \changes{v1.5}{2012/03/15}{\opt{box=parbox} added}
1897 % \changes{v1.6}{2013/05/01}{\opt{box=none} added, \opt{box=parbox} changed to \opt{parbox=parbox}}
1898 % |\caption@resetstyle|\\
1899 % This resets (nearly) all caption options to the base ones.
1900 % \emph{Note that this does not touch the skips and the positioning.}
1901 % \begin{macrocode}
1902 \newcommand*\caption@resetstyle{%
1903 \caption@setup{%
1904 box=none,boxcolor=white,parbox=parbox,%
1905 format=plain,labelformat=default,labelsep=colon,textformat=simple,%
1906 font=,labelfont=,textfont=,size=,%
1907 justification=justified,slc,rule,strut,%
1908 margin=0pt,minmargin=0,maxmargin=0,%
1909 indent=0pt,parindent=0pt,hangindent=0pt}}
1910 % \end{macrocode}
1911 % \end{macro}
1912 %
1913 % \changes{v1.0c}{2005/02/12}{\opt{indent=0pt} added to caption style \opt{default}}
1914 % \changes{v1.1}{2007/02/04}{Caption style `default' renamed to `base', and a new `default' added}
1915 % \changes{v1.1}{2007/03/31}{\opt{format=plain} added to caption style \opt{default}}
1916 % \changes{v1.1c}{2007/10/14}{\opt{format=plain} removed from caption style \opt{default}}
1917 % \changes{v1.5}{2012/03/15}{\opt{box=default} added to caption style \opt{default}}
1918 % Currently there are two pre-defined styles, called `base' \& `default'.
1919 % The first one is a perfect match to the behavior of |\@make|\-|caption|
1920 % offered by the standard \LaTeX\ document classes (and was called `default'
1921 % in \thispackage\ \version{1.0}), the second one matches the document
1922 % class actually used.
1923 % \begin{macrocode}
1924 \DeclareCaptionStyle{base}[indent=0pt,justification=centering]{}
1925 \DeclareCaptionStyle{default}[indent=0pt,justification=centering]{%
1926 box=default,%
1927 format=default,labelformat=default,labelsep=default,textformat=default,%
1928 font=default,labelfont=default,textfont=default,size=default,%
1929 justification=default,slc=default,margin=default,%
1930 indent=default,parindent=default,hangindent=default}
1931 % \end{macrocode}
1932 %
1933 % \begin{macro}{\DeclareCaptionSinglelinecheck}
1934 % \changes{v2.0}{2019/09/10}{This macro added}
1935 % |\DeclareCaptionSinglelinecheck|\marg{name}\marg{code}
1936 % \begin{macrocode}
1937 \newcommand*\DeclareCaptionSinglelinecheck[2]{%
1938 \caption@decl{singlelinecheck}{#1}{#2}}
1939 \@onlypreamble\DeclareCaptionSinglelinecheck
1940 % \end{macrocode}
1941 % \end{macro}
1942 %
1943 % \changes{v1.2b}{2008/05/06}{Option \opt{slc=} added}
1944 % \begin{macrocode}
1945 \DeclareCaptionOption{singlelinecheck}[1]{\caption@setsinglelinecheck{#1}}
1946 \DeclareCaptionOption{slc}[1]{\KV@caption@singlelinecheck{#1}}
1947 % \end{macrocode}
1948 %
1949 % These are the pre-defined single-line-check code snippets.
1950 % \begin{macrocode}
1951 \DeclareCaptionSinglelinecheck{on}{\@firstoftwo}
1952 \DeclareCaptionSinglelinecheck{off}{\@secondoftwo}
1953 % \end{macrocode}
1954 %
1955 % `default' usually maps to `on'.
1956 % \begin{macrocode}
1957 \SetCaptionDefault{singlelinecheck}{on}
1958 % \end{macrocode}
1959 %
1960 % \begin{macro}{\caption@setsinglelinecheck}
1961 % \changes{v2.0}{2018/03/13}{This macro added}
1962 % |\caption@setsinglelinecheck|\marg{value}\\
1963 % sets the single-line-check either on or off,
1964 % where \meta{value} could be either a \meta{name} or boolean value.
1965 % \begin{macrocode}
1966 \newcommand*\caption@setsinglelinecheck[1]{%
1967 \caption@ifdecl{singlelinecheck}{#1}%
1968 {\caption@set{singlelinecheck}{#1}}%
1969 {\caption@set@bool\caption@singlelinecheck{#1}}}
1970 % \end{macrocode}
1971 % \end{macro}
1972 %
1973 % \section{Boxes}
1974 %
1975 % \begin{macro}{\DeclareCaptionBox}
1976 % \changes{v1.5}{2012/03/15}{This macro added}
1977 % \changes{v2.0}{2019/09/10}{Uses \cs{caption@decl} now}
1978 % \changes{v2.2f}{2020/10/26}{\cs{par} is now allowed as part of the \meta{code} argument}
1979 % |\DeclareCaptionBox|\marg{name}\marg{code with \#1 and \#2}
1980 % \begin{macrocode}
1981 \newcommand\DeclareCaptionBox[2]{%
1982 \caption@decl{box}{#1}##1##2{#2}}
1983 \@onlypreamble\DeclareCaptionBox
1984 % \end{macrocode}
1985 % \end{macro}
1986 %
1987 % \changes{v1.5}{2012/03/15}{Option \opt{box=} added}
1988 % \changes{v1.6}{2013/05/01}{Option \opt{parbox=} added}
1989 % \begin{macrocode}
1990 \DeclareCaptionOption{box}{\caption@set{box}{#1}}
1991 \DeclareCaptionOption{parbox}{\caption@set{parbox}{#1}}
1992 \caption@setmapping{parbox}{box}
1993 % \end{macrocode}
1994 %
1995 % There are four pre-defined boxes, called `empty', `none',
1996 % `parbox', and `colorbox'.
1997 % \changes{v1.0i}{2006/05/13}{We define \cs{captionbox} instead of \cs{caption@start/endbox}}
1998 % \changes{v1.0l}{2006/03/09}{Bugfix 07-03-09: \cs{captionbox} changed from \cs{parbox-t} to \cs{parbox-b}}
1999 % \changes{v1.2}{2007/11/11}{\cs{captionbox} renamed to \cs{caption@parbox}}
2000 % \changes{v1.5}{2012/03/15}{\cs{caption@parbox} adapted to \cs{DeclareCaptionBox}}
2001 % \changes{v1.6}{2013/05/02}{Option \opt{boxsep=} added}
2002 % \changes{v2.1b}{2020/09/17}{Missing braces re-added to \opt{colorbox} option code}
2003 % \begin{macrocode}
2004 \DeclareCaptionBox{empty}{}
2005 \DeclareCaptionBox{none}{#2}
2006 \DeclareCaptionBox{parbox}{\parbox[b]{#1}{#2}}
2007 \DeclareCaptionBox{colorbox}{%
2008 \colorbox{\caption@boxcolor}{%
2009 \setlength\caption@tempdima{#1}%
2010 \addtolength\caption@tempdima{-2\fboxsep}%
2011 \linewidth\caption@tempdima\relax
2012 \hsize\caption@tempdima\relax
2013 #2}}
2014 \DeclareCaptionOption{boxcolor}{\def\caption@boxcolor{#1}}
2015 \DeclareCaptionOption{boxsep}{\setlength\fboxsep{#1}}
2016 % \end{macrocode}
2017 %
2018 % `default' usually maps to `none' or `parbox'.
2019 % \begin{macrocode}
2020 \SetCaptionDefault{box}{none}
2021 %\SetCaptionDefault{parbox}{parbox}
2022 % \end{macrocode}
2023 %
2024 % \section{Formats}
2025 %
2026 % \begin{macro}{\DeclareCaptionFormat}
2027 % \changes{v1.0a}{2004/01/17}{Pass through argument \#3 so extra spaces between arguments do make any harm}
2028 % \changes{v1.0c}{2005/02/09}{Starred variant added}
2029 % \changes{v1.1c}{2007/10/15}{Optional argument added}
2030 % \changes{v2.0}{2019/09/10}{Uses \cs{caption@decl} now}
2031 % \changes{v2.0}{2020/07/27}{\cs{caption@ifh} renamed to \cs{caption@ifhmode}}
2032 % |\DeclareCaptionFormat*|\marg{name}\marg{code with \#1, \#2, and \#3}\\
2033 % The starred form causes the code being typeset in vertical (instead of
2034 % horizontal) mode, but does not support the |indention=| option.
2035 % \begin{macrocode}
2036 \newcommand*\DeclareCaptionFormat{%
2037 \caption@teststar\caption@declareformat\@gobble\@firstofone}
2038 \@onlypreamble\DeclareCaptionFormat
2039 % \end{macrocode}
2040 % \begin{macrocode}
2041 \newcommand*\caption@declareformat[2]{%
2042 \@dblarg{\caption@@declareformat#1{#2}}}
2043 \@onlypreamble\caption@declareformat
2044 % \end{macrocode}
2045 % \begin{macrocode}
2046 \long\def\caption@@declareformat#1#2[#3]#4{%
2047 \caption@decl[\edef]{format}{#2}{%
2048 \unexpanded{\let\caption@ifhmode#1}%
2049 \unexpanded{\long\def\caption@slfmt}####1####2####3\unexpanded{{#3}}%
2050 \unexpanded{\long\def\caption@fmt}####1####2####3\unexpanded{{#4}}}}
2051 \@onlypreamble\caption@@declareformat
2052 % \end{macrocode}
2053 % \end{macro}
2054 %
2055 % \begin{macro}{\caption@useformat}
2056 % \changes{v2.0}{2020/07/31}{This macro added}
2057 % |\caption@useformat|\marg{name}\\
2058 % expands |\caption@fmt| based on the given format \meta{name}.
2059 % \begin{macrocode}
2060 \newcommand*\caption@useformat[1]{% used by caption-koma.sto
2061 \caption@checkdecl{format}{#1}{%
2062 \begingroup
2063 \@nameuse{caption@format@#1}\global\let\caption@tempa\caption@fmt
2064 \endgroup\caption@tempa}}
2065 % \end{macrocode}
2066 % \end{macro}
2067 %
2068 % \begin{macrocode}
2069 \DeclareCaptionOption{format}{\caption@set{format}{#1}}
2070 % \end{macrocode}
2071 %
2072 % \changes{v1.0a}{2004/01/23}{Caption format \opt{default} renamed to \opt{normal}}
2073 % \changes{v1.0e}{2005/05/12}{Caption format \opt{normal} renamed to \opt{@normal}}
2074 % \changes{v1.0f}{2005/08/25}{Caption format \opt{@normal} renamed to \opt{plain} and documented}
2075 % \changes{v1.1c}{2007/10/14}{Single-line variant of caption format \opt{hang} added}
2076 % There are two pre-defined formats, called `plain' and `hang'.
2077 % \begin{macrocode}
2078 \DeclareCaptionFormat{plain}{#1#2#3\par}
2079 % \end{macrocode}
2080 % \begin{macrocode}
2081 \DeclareCaptionFormat{hang}[#1#2#3\par]{%
2082 \caption@iflabelseparatorwithnewline
2083 {\caption@Error{%
2084 The option `labelsep=\caption@labelsep@name' does not work\MessageBreak
2085 with `format=hang'}}%
2086 {\@hangfrom{#1#2}%
2087 \advance\caption@parindent\hangindent\relax
2088 \advance\caption@hangindent\hangindent\relax
2089 \caption@@par#3\par}}
2090 % \end{macrocode}
2091 %
2092 % `default' usually maps to `plain'.
2093 % \begin{macrocode}
2094 \SetCaptionDefault{format}{plain}
2095 % \end{macrocode}
2096 %
2097 % \section{Label formats}
2098 %
2099 % \begin{macro}{\DeclareCaptionLabelFormat}
2100 % \changes{v1.0a}{2004/01/17}{Pass through argument \#2 so extra spaces between arguments do make any harm}
2101 % \changes{v2.0}{2019/09/10}{Uses \cs{caption@decl} now}
2102 % |\DeclareCaptionLabelFormat|\marg{name}\marg{code with \#1 and \#2}
2103 % \begin{macrocode}
2104 \newcommand*\DeclareCaptionLabelFormat[2]{%
2105 \caption@decl{labelformat}{#1}##1##2{#2}}
2106 \@onlypreamble\DeclareCaptionLabelFormat
2107 % \end{macrocode}
2108 % \end{macro}
2109 %
2110 % \begin{macrocode}
2111 \DeclareCaptionOption{labelformat}{\caption@set{labelformat}{#1}}
2112 % \end{macrocode}
2113 %
2114 % \changes{v1.2}{2007/12/16}{Caption label format \opt{brace} added}
2115 % \changes{v1.7}{2015/09/16}{Caption label format \opt{autodot} added}
2116 % \changes{v1.7}{2016/05/22}{Caption label format \opt{autodot} fixed}
2117 % \changes{v1.8}{2016/05/22}{Caption label format \opt{unnumbered} added}
2118 % There are six pre-defined label formats, called `empty', `simple',
2119 % `parens', `brace', `autodot', and `unnumbered'.
2120 %
2121 % \begin{macrocode}
2122 \DeclareCaptionLabelFormat{empty}{}
2123 \DeclareCaptionLabelFormat{simple}{\bothIfFirst{#1}{\nobreakspace}#2}
2124 \DeclareCaptionLabelFormat{parens}{\bothIfFirst{#1}{\nobreakspace}(#2)}
2125 \DeclareCaptionLabelFormat{brace}{\bothIfFirst{#1}{\nobreakspace}#2)}
2126 \DeclareCaptionLabelFormat{autodot}{\bothIfFirst{#1}{\nobreakspace}#2\autodot} % obsolete, use `koma' instead
2127 \DeclareCaptionLabelFormat{unnumbered}{#1}
2128 % \end{macrocode}
2129 %
2130 % \changes{v2.0}{2020/08/03}{Caption label format \opt{original} added}
2131 % The label format `original' tries to preserve the original definition
2132 % of the label format which was defined by |\fnum@|\meta{environment}.
2133 % If no original definition is available, use the label format `simple'
2134 % as fallback.
2135 %
2136 % \begin{macrocode}
2137 \DeclareCaptionLabelFormat{original}{%
2138 \caption@ifdefined\caption@original@fnum
2139 {\caption@original@fnum}%
2140 {\caption@labelformat@fallback{#1}{#2}}}
2141 % \end{macrocode}
2142 %
2143 % `default' usually maps to `original' or `simple'.
2144 % \begin{macrocode}
2145 \SetCaptionDefault{labelformat}{original}
2146 \SetCaptionFallback{labelformat}{simple}
2147 % \end{macrocode}
2148 %
2149 % \section{Label separators}
2150 %
2151 % \begin{macro}{\DeclareCaptionLabelSeparator}
2152 % \changes{v1.0a}{2004/01/17}{Pass through argument \#2 so extra spaces between arguments do make any harm}
2153 % \changes{v1.0f}{2005/08/25}{Starred variant added}
2154 % \changes{v1.1}{2007/07/13}{Test for CR added}
2155 % \changes{v1.3}{2011/08/06}{Test for CR revised}
2156 % \changes{v2.0}{2018/05/15}{Variant with two stars added}
2157 % \changes{v2.0}{2019/09/10}{Uses \cs{caption@decl} now}
2158 % \changes{v2.0}{2020/07/27}{\cs{caption@iflf} renamed to \cs{caption@iflabelfont}}
2159 % \changes{v2.0}{2020/07/27}{\cs{caption@lsep} renamed to \cs{caption@labelsep}}
2160 % \changes{v2.0}{2020/07/27}{Definition of \cs{caption@labelsep@name} added}
2161 % |\DeclareCaptionLabelSeparator|\marg{name}\marg{code}\\
2162 % |\DeclareCaptionLabelSeparator*|\marg{name}\marg{code}\\
2163 % |\DeclareCaptionLabelSeparator**|\marg{name}\marg{condition}\marg{code}\\
2164 % The starred form causes the label separator to be typeset \emph{without}
2165 % using |\caption|\-|label|\-|font|.
2166 % The two-starred form uses \meta{condition} to decide if the label separator
2167 % should be typeset with or without using |\caption|\-|label|\-|font|.
2168 % \begin{macrocode}
2169 \newcommand\DeclareCaptionLabelSeparator{%
2170 \@ifstar
2171 \DeclareCaptionLabelSeparator@
2172 {\caption@declarelabelseparator\@firstofone}}
2173 \@onlypreamble\DeclareCaptionLabelSeparator
2174 % \end{macrocode}
2175 % \begin{macrocode}
2176 \newcommand\DeclareCaptionLabelSeparator@{%
2177 \@ifstar
2178 \DeclareCaptionLabelSeparator@@
2179 {\caption@declarelabelseparator\@gobble}}
2180 \@onlypreamble\DeclareCaptionLabelSeparator@
2181 % \end{macrocode}
2182 % \begin{macrocode}
2183 \newcommand*\DeclareCaptionLabelSeparator@@[2]{%
2184 \caption@declarelabelseparator
2185 {#2\@gobble\@firstofone}%
2186 {#1}}
2187 \@onlypreamble\DeclareCaptionLabelSeparator@@
2188 % \end{macrocode}
2189 % \begin{macrocode}
2190 \newcommand\caption@declarelabelseparator[3]{%
2191 \caption@decl{labelseparator}{#2}%
2192 {\def\caption@iflabelfont{#1}%
2193 \def\caption@labelsep@name{#2}%
2194 \def\caption@labelsep{#3}}%
2195 % \end{macrocode}
2196 % Unfortunately |\Declare|\-|Float|\-|Separators| of the \pkg{floatrow}
2197 % package mis-uses |\Declare|\-|Caption|\-|Label|\-|Separator| instead of
2198 % storing the definition on its own. Since the \pkg{floatrow} package is
2199 % unmaintained we have to store the separator definition inside
2200 % |\caption@lsep@|\meta{name} for \pkg{floatrow}, too. (Sigh!)
2201 % \begin{macrocode}
2202 \@namedef{caption@lsep@#2}{#3}}
2203 % \end{macrocode}
2204 % Since the `default' caption label separator will usually not be defined
2205 % with |\Declare|\-|Caption|\-|Label|\-|Separator|, we need to define
2206 % |\caption@lsep@default| manually.
2207 % \Note{This definition is used by \pkg{magyar.ldf} but only needs to be different
2208 % than \cs{caption@lsep} (which is usually undefined).}
2209 % \begin{macrocode}
2210 \newcommand*\caption@lsep@default{\caption@labelseparator@default\caption@labelsep}%
2211 % \end{macrocode}
2212 % \begin{macrocode}
2213 \@onlypreamble\caption@declarelabelseparator
2214 % \end{macrocode}
2215 % \end{macro}
2216 %
2217 % \begin{macro}{\caption@LabelSeparatorWithNewline}
2218 % \changes{v2.0}{2020/07/27}{This macro added}
2219 % |\caption@LabelSeparatorWithNewline|\marg{name}\\
2220 % adds the given label separator to a list of label separators which uses
2221 % |\\| internally. (They are incompatible to the `hang' caption format.)
2222 % \begin{macrocode}
2223 \newcommand*\caption@LabelSeparatorWithNewline[1]{%
2224 \caption@g@addto@list\caption@labelsep@crlist{#1}}
2225 \@onlypreamble\caption@LabelSeparatorWithNewline
2226 % \end{macrocode}
2227 % \end{macro}
2228 %
2229 % \begin{macro}{\caption@iflabelseparatorwithnewline}
2230 % \changes{v2.0}{2020/07/31}{This macro added}
2231 % |\caption@iflabelseparatorwithnewline|\marg{yes-code}\marg{no-code}\\
2232 % tests if the current label separator uses |\\| internally.
2233 % \begin{macrocode}
2234 \newcommand*\caption@iflabelseparatorwithnewline{%
2235 \caption@ifin@list\caption@labelsep@crlist\caption@labelsep@name}
2236 % \end{macrocode}
2237 % \end{macro}
2238 %
2239 % \begin{macrocode}
2240 \DeclareCaptionOption{labelsep}{\caption@set{labelseparator}{#1}}
2241 \DeclareCaptionOption{labelseparator}{\caption@set{labelseparator}{#1}}
2242 % \end{macrocode}
2243 %
2244 % \changes{v1.0e}{2005/06/11}{Caption label separator \opt{newline} implementation changed from \cs{newline} to \cs{textbackslash}}
2245 % \changes{v1.0f}{2005/08/24}{Caption label separator \opt{endash} added}
2246 % \changes{v1.12}{2020/05/30}{Caption label separator \opt{newline} implementation changed from \cs{textbackslash} to \cs{captionnewline}}
2247 % There are seven pre-defined label separators, called `none', `colon', `period', `space',
2248 % `quad', `newline', and `endash'.
2249 % \begin{macrocode}
2250 \DeclareCaptionLabelSeparator{none}{}
2251 \DeclareCaptionLabelSeparator{colon}{: }
2252 \DeclareCaptionLabelSeparator{period}{. }
2253 \DeclareCaptionLabelSeparator{space}{ }
2254 \DeclareCaptionLabelSeparator*{quad}{\quad}
2255 \DeclareCaptionLabelSeparator*{newline}{\captionnewline}
2256 % TODO: \DeclareCaptionLabelSeparator should detect on its own if it contains \captionnewline or not
2257 \caption@LabelSeparatorWithNewline{newline} % does not work with "format=hang"
2258 \DeclareCaptionLabelSeparator*{endash}{\space\textendash\space}
2259 % \end{macrocode}
2260 %
2261 % \changes{v2.2c}{2020/10/10}{Caption label separators \opt{gobble} and \opt{gobbletwo} added}
2262 %
2263 % It's a common hack to mis-use |\fnum@figure| and |\fnum@table| to replace the caption
2264 % label separator, for example changing the separator to a period plus space with
2265 % \begin{quote}
2266 % |\renewcommand\fnum@figure[1]{\figurename~\thefigure.}|
2267 % \end{quote}
2268 % or dropping the label and separator completely with
2269 % \begin{quote}
2270 % |\renewcommand\fnum@figure[1]{\ignorespaces}|\quad
2271 % \end{quote}
2272 % (taken from \url{https://comp.text.tex.narkive.com/XkJnYryR/figure-without-caption}).
2273 %
2274 % We emulate the behaviour of |\@make|\-|caption| of the base document classes
2275 % \cls{article}, \cls{report}, and \cls{book} in this regard (in |\caption@@@make|)
2276 % so these hacks still work if the \pkg{caption} package is loaded.
2277 %
2278 % These are the label separators used when one or two tokens after the label format
2279 % should be dropped, called `gobble' and `gobbletwo':
2280 % \begin{macrocode}
2281 \DeclareCaptionLabelSeparator{gobble}{ }
2282 \DeclareCaptionLabelSeparator{gobbletwo}{}
2283 % \end{macrocode}
2284 %
2285 % \begin{macro}{\captionnewline}
2286 % \changes{v1.12}{2020/05/30}{This macro added}
2287 % \changes{v2.0}{2020/07/31}{\cs{relax} added to definition}
2288 % |\captionnewline|\\
2289 % will be used in the caption label separator |new|\-|line|,
2290 % and re-defined for |long|\-|table| environments
2291 % (in package \pkg{ltcaption}).
2292 % \begin{macrocode}
2293 \newcommand*\captionnewline{\\\relax}
2294 % \end{macrocode}
2295 % \end{macro}
2296 %
2297 % `default' usually maps to `colon'.
2298 % \begin{macrocode}
2299 \SetCaptionDefault{labelseparator}{colon}
2300 % \end{macrocode}
2301 %
2302 % \section{Text formats}
2303 %
2304 % \begin{macro}{\DeclareCaptionTextFormat}
2305 % \changes{v1.0j}{2007/02/18}{This macro added}
2306 % \changes{v2.0}{2019/09/10}{Uses \cs{caption@decl} now}
2307 % \changes{v2.2f}{2020/10/26}{\cs{par} is now allowed as part of the \meta{code} argument}
2308 % |\DeclareCaptionTextFormat|\marg{name}\marg{code with \#1}
2309 % \begin{macrocode}
2310 \newcommand\DeclareCaptionTextFormat[2]{%
2311 \caption@decl{textformat}{#1}##1{#2}}
2312 \@onlypreamble\DeclareCaptionTextFormat
2313 % \end{macrocode}
2314 % \end{macro}
2315 %
2316 % \begin{macrocode}
2317 \DeclareCaptionOption{textformat}{\caption@set{textformat}{#1}}
2318 % \end{macrocode}
2319 %
2320 % There are three pre-defined text formats, called `empty', `simple' and `period'.
2321 % \changes{v1.4}{2011/10/05}{Pre-defined text format `empty' added}
2322 % \changes{v1.7}{2015/09/16}{The text format `empty' now takes care of the \cs{label}}
2323 % \changes{v2.3}{2020/12/26}{Clearance of \cs{caption@thelabel} replaced by \cs{caption@clrlabel}}
2324 % \changes{v2.4d}{2023/07/31}{Check for \cs{@empty} argument replaced by \cs{caption@iftokens}}
2325 % \begin{macrocode}
2326 \DeclareCaptionTextFormat{empty}{%
2327 \caption@get@label#1\caption@makeanchor{}\@nil
2328 \caption@thelabel\caption@clrlabel}
2329 \long\def\caption@get@label#1\caption@makeanchor#2#3\@nil{%
2330 \caption@iftokens{#2}{\caption@getlabel{#2}}{\caption@getlabel{#1}}}
2331 % \end{macrocode}
2332 % \begin{macrocode}
2333 \DeclareCaptionTextFormat{simple}{#1}
2334 \DeclareCaptionTextFormat{period}{#1.}
2335 % \end{macrocode}
2336 %
2337 % `default' usually maps to `simple'.
2338 % \begin{macrocode}
2339 \SetCaptionDefault{textformat}{simple}
2340 % \end{macrocode}
2341 %
2342 % \begin{macro}{\caption@getlabel}
2343 % \changes{v1.7}{2015/09/16}{Moved from \pkg{bicaption} package to \pkg{caption3}}
2344 % \changes{v2.0}{2020/08/23}{Syntax changed}
2345 % |\caption@getlabel|\marg{text}\\
2346 % gets the label command out of the given caption text and stores it to
2347 % |\caption@the|\-|label|.
2348 % \begin{macrocode}
2349 \newcommand\caption@getlabel[1]{%
2350 \caption@@getlabel#1\label{}\@nil}
2351 \long\def\caption@@getlabel#1\label#2#3\@nil{%
2352 \def\@tempa{#2}%
2353 \ifx\@tempa\@empty
2354 \let\caption@thelabel\relax
2355 \else
2356 \def\@tempb{*}%
2357 \ifx\@tempa\@tempb
2358 \def\caption@thelabel{\label*}%
2359 \caption@@@getlabel#3\@nil
2360 \else
2361 \def\caption@thelabel{\label}%
2362 \caption@@@getlabel{#2}#3\@nil
2363 \fi
2364 \fi}
2365 % \end{macrocode}
2366 % \begin{macrocode}
2367 \long\def\caption@@@getlabel#1#2\@nil{%
2368 \def\@tempa{#1}%
2369 \def\@tempb{[}%
2370 \ifx\@tempa\@tempb
2371 \caption@@@@getlabel#1#2\@nil
2372 \else
2373 \l@addto@macro\caption@thelabel{{#1}}%
2374 \fi}
2375 % \end{macrocode}
2376 % \begin{macrocode}
2377 \long\def\caption@@@@getlabel[#1]#2\@nil{%
2378 \l@addto@macro\caption@thelabel{[{#1}]}%
2379 \caption@@@getlabel#2\@nil}
2380 % \end{macrocode}
2381 % \end{macro}
2382 %
2383 % \begin{macro}{\caption@clrlabel}
2384 % \changes{v1.7}{2015/09/16}{Moved from \pkg{bicaption} package to \pkg{caption3}}
2385 % \changes{v1.8d}{2019/09/01}{Bugfix: Global definition of \cs{caption@thelabel} added}
2386 % \changes{v2.3}{2020/12/26}{Code moved into the new macro \cs{caption@clrlabel}}
2387 % |\caption@clrlabel|\\
2388 % resets |\caption@the|\-|label| to |\relax|.
2389 % \begin{macrocode}
2390 \newcommand*\caption@clrlabel{\let\caption@thelabel\relax}
2391 % \end{macrocode}
2392 % \begin{macrocode}
2393 \caption@clrlabel
2394 % \end{macrocode}
2395 % \end{macro}
2396 %
2397 % \changes{v1.0c}{2005/02/12}{Option \opt{strut=} added}
2398 % \begin{macrocode}
2399 \DeclareCaptionOption{strut}[1]{\caption@set@bool\caption@ifstrut{#1}}
2400 % \end{macrocode}
2401 %
2402 % \section{Fonts}
2403 %
2404 % \begin{macro}{\DeclareCaptionFont}
2405 % \changes{v1.0a}{2004/01/22}{Bugfix: Multi token arguments are allowed now}
2406 % \changes{v1.1}{2007/05/07}{Internal: Uses \cs{caption@fnt} instead of \cs{caption@temp} now}
2407 % \changes{v1.8h}{2020/01/03}{Check for \pkg{ragged2e} package related options added}
2408 % \changes{v1.10}{2020/05/10}{Optional argument \opt{package} added}
2409 % |\DeclareCaptionFont|\oarg{package}\marg{name}\marg{code}
2410 % \begin{macrocode}
2411 \newcommand*\DeclareCaptionFont{%
2412 \caption@decl@package{font}{\caption@declarefont}}
2413 \@onlypreamble\DeclareCaptionFont
2414 % \end{macrocode}
2415 % \begin{macrocode}
2416 \newcommand*\caption@declarefont[2]{%
2417 \caption@decl{font}{#1}##1{#2}%
2418 \define@key{caption@font}{#1}[]{\caption@addto@font{#1}{##1}}}
2419 \@onlypreamble\caption@@declarefont
2420 % \end{macrocode}
2421 % \begin{macrocode}
2422 \newcommand*\caption@addto@font[1]{%
2423 % \end{macrocode}
2424 % \begin{macrocode}
2425 % Load package first, if necessary
2426 \caption@load@package{font}{#1}%
2427 % \end{macrocode}
2428 % Add the content to \cs{caption@fnt}
2429 % \begin{macrocode}
2430 \caption@add@to@font{font}{#1}}
2431 % \end{macrocode}
2432 % \begin{macrocode}
2433 \newcommand*\caption@add@to@font[3]{%
2434 \expandafter\g@addto@macro\expandafter\caption@fnt\expandafter{\csname caption@#1@#2\endcsname{#3}}}
2435 % \end{macrocode}
2436 % \end{macro}
2437 %
2438 % \begin{macrocode}
2439 \DeclareCaptionOption{font}{\caption@setfont{font}{#1}}
2440 \DeclareCaptionOption{font+}{\caption@addtofont{font}{#1}}
2441 % \end{macrocode}
2442 % \begin{macrocode}
2443 \DeclareCaptionOption{labelfont}{\caption@setfont{labelfont}{#1}}
2444 \DeclareCaptionOption{labelfont+}{\caption@addtofont{labelfont}{#1}}
2445 \caption@setmapping{labelfont}{font}
2446 % \end{macrocode}
2447 % \begin{macrocode}
2448 \DeclareCaptionOption{textfont}{\caption@setfont{textfont}{#1}}
2449 \DeclareCaptionOption{textfont+}{\caption@addtofont{textfont}{#1}}
2450 \caption@setmapping{textfont}{font}
2451 % \end{macrocode}
2452 %
2453 % \begin{macro}{\caption@setfont}
2454 % \changes{v1.0j}{2007/01/30}{Usage of \cs{caption@setkeys} with optional argument}
2455 % \changes{v1.1}{2006/05/14}{Support of \cs{DeclareDefaultCaptionFont} added}
2456 % |\caption@setfont|\marg{name}\marg{keyval-list of names}\\
2457 % Selecting a caption font means saving all the code snippets
2458 % in |\caption|\meta{name}.
2459 % \begin{macrocode}
2460 \newcommand*\caption@setfont[1]{%
2461 \expandafter\let\csname caption#1\endcsname\@empty
2462 \caption@addtofont{#1}}
2463 % \end{macrocode}
2464 % \end{macro}
2465 %
2466 % \begin{macro}{\caption@addtofont}
2467 % \changes{v1.2}{2007/11/17}{This macro added}
2468 % |\caption@addtofont|\marg{name}\marg{keyval-list of names}\\
2469 % Like |\caption@set|\-|font|, but adds the code snippets to |\caption|\meta{name}.
2470 % Because we use |\set|\-|keys| recursive here we need to do this inside an
2471 % extra group.
2472 % \begin{macrocode}
2473 \newcommand*\caption@addtofont[2]{%
2474 \expandafter\let\expandafter\caption@fnt\csname caption#1\endcsname
2475 \begingroup
2476 \define@key{caption@font}{default}[]{\caption@add@to@font{#1}{default}{##1}}%
2477 \caption@setkeys[caption]{caption@font}{#2}%
2478 \endgroup
2479 \expandafter\let\csname caption#1\endcsname\caption@fnt}
2480 % \end{macrocode}
2481 % \end{macro}
2482 %
2483 % These are the pre-defined font code snippets.
2484 %
2485 % \changes{v1.1}{2007/05/07}{Color font support added}
2486 % \begin{macrocode}
2487 \DeclareCaptionFont{normalcolor}{\normalcolor}
2488 \DeclareCaptionFont{color}{\color{#1}}
2489 % \end{macrocode}
2490 %
2491 % \begin{macrocode}
2492 \DeclareCaptionFont{normalfont}{\normalfont}
2493 \DeclareCaptionFont{up}{\upshape}
2494 \DeclareCaptionFont{it}{\itshape}
2495 \DeclareCaptionFont{sl}{\slshape}
2496 \DeclareCaptionFont{sc}{\scshape}
2497 \DeclareCaptionFont{md}{\mdseries}
2498 \DeclareCaptionFont{bf}{\bfseries}
2499 \DeclareCaptionFont{rm}{\rmfamily}
2500 \DeclareCaptionFont{sf}{\sffamily}
2501 \DeclareCaptionFont{tt}{\ttfamily}
2502 % \end{macrocode}
2503 %
2504 % \changes{v1.7}{2018/05/01}{Missing font sizes \texttt{tiny}, \texttt{LARGE}, \texttt{huge}, and \texttt{Huge} added}
2505 % \begin{macrocode}
2506 \DeclareCaptionFont{tiny}{\tiny}
2507 \DeclareCaptionFont{scriptsize}{\scriptsize}
2508 \DeclareCaptionFont{footnotesize}{\footnotesize}
2509 \DeclareCaptionFont{small}{\small}
2510 \DeclareCaptionFont{normalsize}{\normalsize}
2511 \DeclareCaptionFont{large}{\large}
2512 \DeclareCaptionFont{Large}{\Large}
2513 \DeclareCaptionFont{LARGE}{\LARGE}
2514 \DeclareCaptionFont{huge}{\huge}
2515 \DeclareCaptionFont{Huge}{\Huge}
2516 % \end{macrocode}
2517 %
2518 % \changes{v1.8}{2018/05/01}{Font sizes \texttt{smaller} and \texttt{larger} added}
2519 % \begin{macrocode}
2520 \DeclareCaptionFont{smaller}{\caption@smaller}
2521 \DeclareCaptionFont{larger}{\caption@larger}
2522 % \end{macrocode}
2523 %
2524 % \begin{macrocode}
2525 \DeclareCaptionFont{none}{}
2526 \DeclareCaptionFont{normal}{%
2527 \caption@font@normalcolor\@unused
2528 \caption@font@normalfont\@unused
2529 \caption@font@normalsize\@unused
2530 \caption@font@singlespacing\@unused}
2531 % \end{macrocode}
2532 %
2533 % `default' usually maps to `none'.
2534 % \begin{macrocode}
2535 \SetCaptionDefault{font}{none}
2536 \SetCaptionDefault{labelfont}{none}
2537 \SetCaptionDefault{textfont}{none}
2538 % \end{macrocode}
2539 %
2540 % The \pkg{floatrow} package uses the fonts `footfont` and `@tempa` additionally,
2541 % so we need to map and define the default value for them, too.
2542 % \begin{macrocode}
2543 \caption@setmapping{footfont}{font}
2544 \SetCaptionDefault{footfont}{none}
2545 \caption@setmapping{@tempa}{font}
2546 \SetCaptionDefault{@tempa}{none}
2547 % \end{macrocode}
2548 %
2549 % \begin{macro}{\caption@smaller}
2550 % |\caption@smaller|\\
2551 % selects a font size which is smaller than the current one.
2552 % \begin{macrocode}
2553 \newcommand\caption@smaller{%
2554 \ifx\@currsize\tiny
2555 \relax
2556 \else\ifx\@currsize\scriptsize
2557 \tiny
2558 \else\ifx\@currsize\footnotesize
2559 \scriptsize
2560 \else\ifx\@currsize\small
2561 \footnotesize
2562 \else\ifx\@currsize\normalsize
2563 \small
2564 \else\ifx\@currsize\large
2565 \normalsize
2566 \else\ifx\@currsize\Large
2567 \large
2568 \else\ifx\@currsize\LARGE
2569 \Large
2570 \else\ifx\@currsize\huge
2571 \LARGE
2572 \else\ifx\@currsize\Huge
2573 \huge
2574 \else
2575 \caption@Warning{%
2576 Cannot determine current font size.\MessageBreak
2577 Try setting it with `size=' explicitly}%
2578 \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
2579 % \end{macrocode}
2580 % \end{macro}
2581 %
2582 % \begin{macro}{\caption@larger}
2583 % |\caption@larger|\\
2584 % selects a font size which is larger than the current one.
2585 % \begin{macrocode}
2586 \newcommand\caption@larger{%
2587 \ifx\@currsize\tiny
2588 \scriptsize
2589 \else\ifx\@currsize\scriptsize
2590 \footnotesize
2591 \else\ifx\@currsize\footnotesize
2592 \small
2593 \else\ifx\@currsize\small
2594 \normalsize
2595 \else\ifx\@currsize\normalsize
2596 \large
2597 \else\ifx\@currsize\large
2598 \Large
2599 \else\ifx\@currsize\Large
2600 \LARGE
2601 \else\ifx\@currsize\LARGE
2602 \huge
2603 \else\ifx\@currsize\huge
2604 \Huge
2605 \else\ifx\@currsize\Huge
2606 \relax
2607 \else
2608 \caption@Warning{%
2609 Cannot determine current font size.\MessageBreak
2610 Try setting it with `size=' explicitly}%
2611 \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
2612 % \end{macrocode}
2613 % \end{macro}
2614 %
2615 % \begin{macro}{\caption@hypersetup}
2616 % |\caption@hypersetup|\marg{options}\\
2617 % expands to |\hypersetup|\marg{options} if defined, to nothing otherwise.
2618 % \begin{macrocode}
2619 \newcommand*\caption@hypersetup{\caption@ifdefined\hypersetup\hypersetup\@gobble}
2620 \DeclareCaptionFont{hypersetup}{\caption@hypersetup{#1}} % for usage in \captionsetup{font={hypersetup=...}}
2621 \DeclareCaptionOption{hypersetup}{\caption@hypersetup{#1}} % for usage in \captionsetup[<env>]{hypersetup=...}
2622 % \end{macrocode}
2623 % \end{macro}
2624 %
2625 % \section{Sizes}
2626 %
2627 % \changes{v1.0a}{2004/01/23}{Option \opt{size=} now sets \cs{captionsize} instead of \cs{captionfont}}
2628 % The old versions \version{1.x} of \thispackage\ offered this
2629 % command to setup the font size used for captions. We still do
2630 % so old documents will work fine.
2631 % \begin{macrocode}
2632 \DeclareCaptionOption{size}{\caption@setfont{size}{#1}}
2633 \caption@setmapping{size}{font}
2634 % \end{macrocode}
2635 %
2636 % `default' usually maps to `none'.
2637 % \begin{macrocode}
2638 \SetCaptionDefault{size}{none}
2639 % \end{macrocode}
2640 %
2641 % \section{Justifications}
2642 %
2643 % \begin{macro}{\DeclareCaptionJustification}
2644 % \changes{v1.0a}{2004/01/17}{Pass through argument \#2 so extra spaces between arguments do make any harm}
2645 % \changes{v1.1}{2007/07/03}{Mapped to \cs{DeclareCaptionFont}}
2646 % \changes{v2.0}{2020/07/26}{Uses \cs{caption@decl} now}
2647 % |\DeclareCaptionJustification|\oarg{package}\marg{name}\marg{code}
2648 % \begin{macrocode}
2649 \newcommand*\DeclareCaptionJustification{%
2650 % \caption@decl@package{justification}{\caption@decl{justification}}} % Because of floatrow it isn't so easy...
2651 % \end{macrocode}
2652 % Unfortunately the (unmaintained) \pkg{floatrow} uses the old storage scheme
2653 % of the \pkg{caption} package and therefore expects the justification code
2654 % in |\caption@hj@|\meta{name} instead of |\caption@justification@|\meta{name}.
2655 % For this reason we have to store the code for the \pkg{floatrow} package
2656 % additionally, so |\flrow@FBo|\-|Align| will still work fine.
2657 % \begin{macrocode}
2658 \caption@withoptargs\caption@declare@justification}
2659 % \end{macrocode}
2660 % \begin{macrocode}
2661 \newcommand*\caption@declare@justification[3]{%
2662 \caption@decl@package{justification}{\caption@decl{justification}}#1{#2}{#3}%
2663 \expandafter\let\csname caption@hj@#2\expandafter\endcsname\csname caption@justification@#2\endcsname}
2664 \@onlypreamble\DeclareCaptionJustification
2665 % \end{macrocode}
2666 % \end{macro}
2667 %
2668 % \begin{macrocode}
2669 \DeclareCaptionOption{justification}{%
2670 \caption@load@package{justification}{#1}%
2671 \caption@set{justification}{#1}}
2672 % \end{macrocode}
2673 %
2674 % These are the pre-defined justification code snippets.
2675 % \begin{macrocode}
2676 \DeclareCaptionJustification{justified}{}
2677 \DeclareCaptionJustification{centering}{\centering}
2678 \DeclareCaptionJustification{centerfirst}{\centerfirst}
2679 \DeclareCaptionJustification{centerlast}{\centerlast}
2680 \DeclareCaptionJustification{raggedleft}{\raggedleft}
2681 \DeclareCaptionJustification{raggedright}{\raggedright}
2682 % \end{macrocode}
2683 %
2684 % `default' usually maps to `justified'.
2685 % \begin{macrocode}
2686 \SetCaptionDefault{justification}{justified}
2687 % \end{macrocode}
2688 %
2689 % \begin{macro}{\centerfirst}
2690 % \changes{v1.0j}{2007/01/21}{Bugfix: Usage of \cs{@centercr} added (Thanks to Olga!)}
2691 % \changes{v1.0j}{2007/01/21}{This macro renamed from \cs{caption@centerfirst} to \cs{centerfirst}}
2692 % Please blame Frank Mittelbach for the code of |\center|\-|first| |:-)|
2693 % \begin{macrocode}
2694 \providecommand\centerfirst{%
2695 \let\\\@centercr
2696 \edef\caption@normaladjust{%
2697 \leftskip\the\leftskip
2698 \rightskip\the\rightskip
2699 \parfillskip\the\parfillskip\relax}%
2700 \leftskip\z@\@plus -1fil%
2701 \rightskip\z@\@plus 1fil%
2702 \parfillskip\z@skip
2703 \noindent\hskip\z@\@plus 2fil%
2704 \@setpar{\@@par\@restorepar\caption@normaladjust}}
2705 % \end{macrocode}
2706 % \end{macro}
2707 %
2708 % \begin{macro}{\centerlast}
2709 % \changes{v1.0j}{2007/01/21}{Bugfix: Usage of \cs{@centercr} added (Thanks to Olga!)}
2710 % \changes{v1.0j}{2007/01/21}{This macro renamed from \cs{caption@centerlast} to \cs{centerlast}}
2711 % This one is based on code from Anne Br\"uggemann-Klein\cite{Anne}.
2712 % \begin{macrocode}
2713 \providecommand\centerlast{%
2714 \let\\\@centercr
2715 \leftskip\z@\@plus 1fil%
2716 \rightskip\z@\@plus -1fil%
2717 \parfillskip\z@\@plus 2fil\relax}
2718 % \end{macrocode}
2719 % \end{macro}
2720 %
2721 % \section{Vertical spaces before and after captions}
2722 %
2723 % \begin{macro}{\abovecaptionskip}
2724 % \begin{macro}{\belowcaptionskip}
2725 % Usually these skips are defined within the document class, but some
2726 % document classes don't.
2727 % \begin{macrocode}
2728 \caption@ifundefined\abovecaptionskip{%
2729 \newlength\abovecaptionskip\setlength\abovecaptionskip{10\p@}}{}
2730 \caption@ifundefined\belowcaptionskip{%
2731 \newlength\belowcaptionskip\setlength\belowcaptionskip{0\p@}}{}
2732 % \end{macrocode}
2733 % \end{macro}
2734 % \end{macro}
2735 %
2736 % \changes{v1.0c}{2005/02/12}{Option \opt{skip=} added}
2737 % \begin{macrocode}
2738 \DeclareCaptionOption{aboveskip}{\setlength\abovecaptionskip{#1}}
2739 \DeclareCaptionOption{belowskip}{\setlength\belowcaptionskip{#1}}
2740 \DeclareCaptionOption{skip}{\setlength\abovecaptionskip{#1}}
2741 % \end{macrocode}
2742 %
2743 % \begin{macro}{\caption@rule}
2744 % \changes{v1.2b}{2008/05/06}{This macro added}
2745 % |\caption@rule|\\
2746 % Draws an invisible rule to adjust the ``skip'' setting.
2747 % \begin{macrocode}
2748 \newcommand*\caption@rule{\caption@ifrule\caption@hrule\relax}
2749 % \end{macrocode}
2750 % \begin{macrocode}
2751 \newcommand*\caption@hrule{\hrule\@height\z@}
2752 % \end{macrocode}
2753 % \end{macro}
2754 %
2755 % \changes{v1.2b}{2008/05/06}{Option \opt{rule=} added}
2756 % \begin{macrocode}
2757 \DeclareCaptionOption{rule}[1]{\caption@set@bool\caption@ifrule{#1}}
2758 % \end{macrocode}
2759 %
2760 % \section{Positioning}
2761 %
2762 % These macros handle the right position of the caption.
2763 % Note that the position is actually \emph{not} controlled by the
2764 % \pkg{caption3} kernel options, but by the user (or a specific package
2765 % like the \pkg{float} package) instead.
2766 % The user can put the |\caption| command wherever he likes! So this stuff
2767 % is only to give us a \emph{hint} where to put the right skips, the user
2768 % usually has to take care for himself that this hint actually matches the
2769 % right position.
2770 %
2771 % \begin{macro}{\DeclareCaptionPosition}
2772 % \changes{v2.0}{2020/07/26}{This macro added}
2773 % \changes{v2.3}{2021/01/02}{This macro renamed from \cs{caption@declare@position} to \cs{DeclareCaptionPosition} and re-written}
2774 % |\DeclareCaptionPosition|\marg{name}\marg{fallback-code}\marg{regular-code}\\
2775 % declares a caption position setting of the given \meta{name}.
2776 % The \meta{fallback-code} will be used when |\caption@iftop| is used before |\caption|
2777 % and the \meta{regular-code} will be used when |\caption| is used before |\caption@iftop|.
2778 % \begin{macrocode}
2779 \newcommand*\DeclareCaptionPosition[3]{%
2780 \caption@decl[\edef]{position}{#1}{%
2781 \unexpanded{\def\caption@fallback@position}####1####2\unexpanded{{#2}}%
2782 \unexpanded{\def\caption@regular@position}####1####2\unexpanded{{#3}}}}
2783 \@onlypreamble\DeclareCaptionPosition
2784 % \end{macrocode}
2785 % \end{macro}
2786 %
2787 % \begin{macrocode}
2788 \DeclareCaptionOption{position}{\caption@setposition{#1}}
2789 % \end{macrocode}
2790 % \changes{v1.0a}{2004/01/09}{Options \opt{figureposition} and \opt{tableposition} added}
2791 % \begin{macrocode}
2792 \DeclareCaptionOption{figureposition}{\captionsetup*[figure]{position=#1}}
2793 \@onlypreamble@key{caption}{figureposition}
2794 % \end{macrocode}
2795 % \begin{macrocode}
2796 \DeclareCaptionOption{tableposition}{\captionsetup*[table]{position=#1}}
2797 \@onlypreamble@key{caption}{tableposition}
2798 % \end{macrocode}
2799 %
2800 % \begin{macro}{\caption@setposition}
2801 % \changes{v1.0a}{2004/01/22}{Now the positions \opt{t}, \opt{above}, \opt{b}, \opt{below}, and \opt{a} are allowed, too}
2802 % \changes{v1.0c}{2004/08/10}{Usage of \cs{caption@defaultpos} added}
2803 % \changes{v2.0}{2020/07/27}{Uses \cs{caption@set} now}
2804 % \changes{v2.3}{2021/01/02}{Uses \cs{caption@initposition} additionally}
2805 % |\caption@setposition|\marg{position}\\
2806 % puts |\caption@position| to the right value.
2807 % (Note: Since this command is used by the \pkg{floatrow} package as well its syntax should not change.)
2808 % \begin{macrocode}
2809 \newcommand*\caption@setposition{%
2810 \caption@initposition
2811 \caption@set{position}}
2812 % \end{macrocode}
2813 % \end{macro}
2814 %
2815 % These are the pre-defined position code snippets.
2816 % \begin{macrocode}
2817 \DeclareCaptionPosition{top}{#1}{#1}
2818 \def\caption@position@t{\caption@position@top}
2819 \def\caption@position@above{\caption@position@top}
2820 % \end{macrocode}
2821 % \begin{macrocode}
2822 \DeclareCaptionPosition{bottom}{#2}{#2}
2823 \def\caption@position@b{\caption@position@bottom}
2824 \def\caption@position@below{\caption@position@bottom}
2825 % \end{macrocode}
2826 % \begin{macrocode}
2827 \DeclareCaptionPosition{auto}{#2}{\caption@autoposition{#1}{#2}}
2828 \def\caption@position@a{\caption@position@auto} % needed by floatrow package, \flrow@cappos
2829 % \end{macrocode}
2830 %
2831 % \changes{v1.1}{2007/05/08}{Default position changed from `bottom' to `auto'}
2832 % `default' usually maps to `auto'.
2833 % \begin{macrocode}
2834 \SetCaptionDefault{position}{auto}
2835 % \end{macrocode}
2836 %
2837 % \begin{macro}{\caption@initposition}
2838 % \changes{v2.3}{2021/01/02}{This macro added}
2839 % |\caption@initposition|\\
2840 % initialize the position option defined with |\Declare|\-|Caption|\-|Position|.
2841 % This macro is usually used at |\@float|, i.e. at the beginning of a floating
2842 % environment.
2843 % \begin{macrocode}
2844 \newcommand*\caption@initposition{%
2845 \let\caption@@iftop\@undefined}
2846 % \end{macrocode}
2847 % \end{macro}
2848 %
2849 % \begin{macro}{\caption@iftop}
2850 % \changes{v1.0a}{2004/01/23}{Split into \cs{caption@iftop} \& \cs{caption@fixposition}}
2851 % \changes{v1.0c}{2005/02/12}{Adapted to \cs{caption@defaultpos}}
2852 % \changes{v1.1}{2007/05/08}{Position will be fixed to `bottom' if `auto'}
2853 % \changes{v2.0}{2020/07/27}{Adapted to current implementation of `auto'}
2854 % \changes{v2.3}{2021/01/02}{Adapted to current implementation of `position'}
2855 % |\caption@iftop|\marg{true-code}\marg{false-code}\\
2856 % tests if the caption position is set to `top' and sets the state to 2.
2857 % \begin{macrocode}
2858 \newcommand*\caption@iftop{%
2859 \caption@@fixposition\caption@fallback@position
2860 \caption@@iftop}
2861 % \end{macrocode}
2862 % \end{macro}
2863 %
2864 % \begin{macro}{\caption@fixposition}
2865 % \changes{v1.0a}{2004/01/23}{\cs{ifvmode} added}
2866 % \changes{v1.0b}{2004/05/16}{Split into \cs{caption@fixposition} & \cs{caption@autoposition}}
2867 % \changes{v2.0}{2020/07/27}{Adapted to current implementation of `auto'}
2868 % \changes{v2.3}{2021/01/02}{Adapted to current implementation of `position'}
2869 % |\caption@fixposition|\\
2870 % freezes the position settings defined with |\Declare|\-|Caption|\-|Position|
2871 % by expanding the given code, either the \meta{fallback-code} or the \meta{regular-code}.
2872 % This macro is usually used at |\caption|, i.e. before the main caption is
2873 % typeset. (Note: This macro is not used at |\caption| inside sub-figures.)
2874 % \begin{macrocode}
2875 \newcommand*\caption@fixposition{%
2876 \caption@@fixposition\caption@regular@position}
2877 % \end{macrocode}
2878 % \begin{macrocode}
2879 \newcommand*\caption@@fixposition[1]{%
2880 \ifx\caption@@iftop\@undefined
2881 \caption@position % defines \caption@fallback@position and \caption@regular@position
2882 #1{\let\caption@@iftop\@firstoftwo}{\let\caption@@iftop\@secondoftwo}%
2883 \fi}
2884 % \end{macrocode}
2885 % \end{macro}
2886 %
2887 % \begin{macro}{\caption@setautoposition}
2888 % \changes{v1.1}{2007/06/10}{This macro added}
2889 % \changes{v2.0}{2020/07/27}{Adapted to current implementation of `auto'}
2890 % \changes{v2.3}{2021/01/03}{Adapted to current implementation of `auto'}
2891 % |\caption@setautoposition|\marg{position}\\
2892 % replaces the above algorithm by a different one (or a fixed position setting).
2893 % \begin{macrocode}
2894 \newcommand*\caption@setautoposition[1]{%
2895 \renewcommand*\caption@position@auto{%
2896 \@nameuse{caption@position@#1}}}
2897 % \end{macrocode}
2898 % \end{macro}
2899 %
2900 % \begin{macro}{\caption@autoposition}
2901 % \changes{v1.0a}{2004/01/23}{\cs{ifvmode} added}
2902 % \changes{v1.0b}{2004/05/16}{Split into \cs{caption@fixposition} & \cs{caption@autoposition}}
2903 % \changes{v2.0}{2020/07/27}{Adapted to current implementation of `auto'}
2904 % \changes{v2.3}{2021/01/05}{Adapted to current implementation of `auto'; \cs{ifvmode} moved into definition of `auto'}
2905 % \changes{v2.3a}{2022/02/28}{\cs{ifvmode} moved back into this macro}
2906 % We try to guess the current position of the caption by checking |\prev|\-|depth|.
2907 %
2908 % A different solution would be setting the |\space|\-|factor| to something
2909 % not much less than 1000 (for example 994) in |\caption@start| and
2910 % checking this value here by |\ifnum\space|\-|factor=994|.
2911 % (It's implemented in the \pkg{threeparttable} package\cite{threeparttable} this way.)
2912 %
2913 % Another idea would be checking |\@if|\-|mini|\-|page|, but since some packages
2914 % typeset the caption within a simple |\vbox| this does not seem to be a good one.
2915 % \begin{macrocode}
2916 \newcommand*\caption@autoposition[2]{%
2917 \ifvmode
2918 \edef\caption@tempa{\the\prevdepth}%
2919 \caption@Debug{\string\prevdepth=\caption@tempa}%
2920 \ifdim\prevdepth>-\p@
2921 #2% position=bottom
2922 \else
2923 #1% position=top
2924 \fi
2925 \else
2926 #2% position=bottom
2927 \fi}
2928 % \end{macrocode}
2929 % \end{macro}
2930 %
2931 % \begin{macro}{\DeclareCaptionAutoPosition}
2932 % \changes{v2.3}{2021/01/05}{This macro added}
2933 % |\DeclareCaptionAutoPosition|\marg{code with \#1 and \#2}\\
2934 % replaces the inner algorithm of |position=auto| with a custom one.
2935 % If \#1 is applied the skip will be typeset below the caption
2936 % (like |position=t|), if \#2 is applied the skip will by typeset
2937 % above the caption (like |position=b|).
2938 % \begin{macrocode}
2939 \newcommand*\DeclareCaptionAutoPosition{%
2940 \renewcommand*\caption@autoposition[2]}%
2941 % \end{macrocode}
2942 % \end{macro}
2943 %
2944 % \section{Hooks}
2945 %
2946 % \begin{macro}{\AtBeginCaption}
2947 % \begin{macro}{\AtEndCaption}
2948 % |\AtBeginCaption|\marg{code}\\
2949 % |\AtEndCaption|\marg{code}\\
2950 % These hooks can be used analogous to |\At|\-|Begin|\-|Document| and
2951 % |\At|\-|End|\-|Document|.
2952 % \begin{macrocode}
2953 \newcommand*\caption@beginhook{}
2954 \newcommand*\caption@endhook{}
2955 \newcommand*\AtBeginCaption{\l@addto@macro\caption@beginhook}
2956 \newcommand*\AtEndCaption{\l@addto@macro\caption@endhook}
2957 % \end{macrocode}
2958 % \end{macro}
2959 % \end{macro}
2960 %
2961 % \section{Lists}
2962 %
2963 % \changes{v1.0b}{2004/05/16}{Option \opt{listof=} added}
2964 % \changes{v1.2}{2007/11/17}{Option \opt{list=} added}
2965 % \begin{macrocode}
2966 \DeclareCaptionOption{list}[1]{\caption@setlist{#1}}
2967 \DeclareCaptionOption{listof}[1]{\caption@setlist{#1}}
2968 % \end{macrocode}
2969 %
2970 % \begin{macro}{\caption@setlist}
2971 % \changes{v1.2a}{2008/03/20}{This macro added}
2972 % |\caption@setlist|\marg{boolean value}\\
2973 % sets the `list' option to either `off' or `on'.
2974 % \begin{macrocode}
2975 \newcommand*\caption@setlist{\caption@set@bool\caption@iflist}
2976 % \end{macrocode}
2977 % \begin{macrocode}
2978 \caption@setlist{on}
2979 % \end{macrocode}
2980 % \end{macro}
2981 %
2982 % \changes{v1.4}{2011/08/30}{Option \opt{listtype=} added}
2983 % \changes{v1.4}{2011/08/30}{Option \opt{listtype+=} added}
2984 % \begin{macrocode}
2985 \DeclareCaptionOption{listtype}{\caption@setlisttype{#1}}
2986 \DeclareCaptionOption{listtype+}{\caption@setlisttype@ext{#1}}
2987 % \end{macrocode}
2988 %
2989 % \begin{macro}{\caption@setlisttype}
2990 % \changes{v1.4}{2011/08/30}{This macro added}
2991 % |\caption@setlisttype|\marg{type}\\
2992 % sets the `listtype' option to the given \meta{type}.
2993 % \begin{macrocode}
2994 \newcommand*\caption@setlisttype{%
2995 \caption@setlisttype@ext{}%
2996 \caption@@setlisttype\caption@listtype}
2997 % \end{macrocode}
2998 % \begin{macrocode}
2999 \newcommand*\caption@@setlisttype[2]{%
3000 \edef#1{#2}%
3001 \ifx#1\@empty \let#1\@undefined \fi}
3002 % \end{macrocode}
3003 % \end{macro}
3004 %
3005 % \begin{macro}{\caption@setlisttype@ext}
3006 % \changes{v1.4}{2011/08/30}{This macro added}
3007 % |\caption@setlisttype@ext|\marg{type extension}\\
3008 % sets the `listtype' option to the given \meta{type extension}.
3009 % \begin{macrocode}
3010 \newcommand*\caption@setlisttype@ext{%
3011 \caption@@setlisttype\caption@listtype@ext}
3012 % \end{macrocode}
3013 % \end{macro}
3014 %
3015 % \begin{macro}{\DeclareCaptionListFormat}
3016 % \changes{v1.1}{2004/07/15}{This macro added}
3017 % \changes{v1.2}{2007/11/17}{Renamed from \cs{DeclareCaptionListOfFormat} to \cs{DeclareCaptionListFormat}}
3018 % \changes{v2.0}{2020/07/26}{Uses \cs{caption@decl} now}
3019 % |\DeclareCaptionListFormat|\marg{name}\marg{code with \#1 and \#2}
3020 % \begin{macrocode}
3021 \newcommand*\DeclareCaptionListFormat[2]{%
3022 \caption@decl{listformat}{#1}##1##2{#2}}
3023 \@onlypreamble\DeclareCaptionListFormat
3024 % \end{macrocode}
3025 % \end{macro}
3026 %
3027 % \changes{v1.1}{2007/07/15}{Option \opt{listofformat=} added}
3028 % \changes{v1.2}{2007/11/17}{Option \opt{listofformat=} renamed to \opt{listformat=}}
3029 % \begin{macrocode}
3030 \DeclareCaptionOption{listformat}{\caption@set{listformat}{#1}}
3031 % \end{macrocode}
3032 %
3033 % There are seven pre-defined list formats. (The first five were taken from the \pkg{subfig} package.)
3034 % \begin{macrocode}
3035 \DeclareCaptionListFormat{empty}{}
3036 \DeclareCaptionListFormat{simple}{#1#2}
3037 \DeclareCaptionListFormat{subsimple}{#2}
3038 \DeclareCaptionListFormat{parens}{#1(#2)}
3039 \DeclareCaptionListFormat{subparens}{(#2)}
3040 \DeclareCaptionListFormat{period}{#1#2.}
3041 \DeclareCaptionListFormat{subperiod}{#2.}
3042 % \end{macrocode}
3043 %
3044 % `default' usually maps to `subsimple'.
3045 % \begin{macrocode}
3046 \SetCaptionDefault{listformat}{subsimple}
3047 % \end{macrocode}
3048 %
3049 % \begin{macro}{\caption@lstfmt}
3050 % \changes{v2.0}{This macro added}
3051 % To provide backward compatibility we still offer \cs{caption@lstfmt}.
3052 % (\cs{caption@lstfmt} is used in the \pkg{dgruyter} package.)
3053 % \begin{macrocode}
3054 \newcommand*\caption@lstfmt{\caption@listformat}
3055 % \end{macrocode}
3056 % \end{macro}
3057 %
3058 % \section{Debug option}
3059 % \changes{v1.0k}{2007/03/04}{Debug option added}
3060 %
3061 % \begin{macrocode}
3062 \DeclareCaptionOption{debug}[1]{%
3063 \caption@set@bool\caption@ifdebug{#1}%
3064 \caption@ifdebug
3065 {\let\caption@Debug\caption@Info}%
3066 {\let\caption@Debug\@gobble}}
3067 % \end{macrocode}
3068 % \begin{macrocode}
3069 \DeclareOption{debug}{\setkeys{caption}{debug}}
3070 % \end{macrocode}
3071 % \begin{macrocode}
3072 \setkeys{caption}{debug=0}
3073 % \end{macrocode}
3074 %
3075 % \section{Document class support}
3076 % \changes{v2.0}{2018/05/11}{Document class support re-written}
3077 %
3078 % \begin{macro}{\@makecaption@standard}
3079 % \begin{macrocode}
3080 % article|report|book.sty [2005/09/16 v1.4f Standard LaTeX document class]
3081 \newcommand\@makecaption@standard[2]{%
3082 \vskip\abovecaptionskip
3083 \sbox\@tempboxa{#1: #2}%
3084 \ifdim \wd\@tempboxa >\hsize
3085 #1: #2\par
3086 \else
3087 \global \@minipagefalse
3088 \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
3089 \fi
3090 \vskip\belowcaptionskip}
3091 \@onlypreamble\@makecaption@standard
3092 % \end{macrocode}
3093 % \end{macro}
3094 %
3095 % \begin{macro}{\@makecaption@arabic}
3096 % \begin{macrocode}
3097 % arabicore.sty [2006/01/01 v1.0 Arabi Core switching commands (may still change)]
3098 \newcommand\@makecaption@arabic[2]{%
3099 \vskip\abovecaptionskip
3100 \sbox\@tempboxa{#1: #2}%
3101 \sbox\@Arabitempboxa{\textRL{#2} : #1}%
3102 \if@rl{
3103 \ifdim \wd\@Arabitempboxa >\hsize
3104 \textRL{#2} : #1\par
3105 \else
3106 \global \@minipagefalse
3107 \hb@xt@\hsize{\hfil\box\@Arabitempboxa\hfil}%
3108 \fi}\else{
3109 \ifdim \wd\@tempboxa >\hsize
3110 #1: #2\par
3111 \else
3112 \global \@minipagefalse
3113 \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
3114 \fi}\fi
3115 \vskip\belowcaptionskip}
3116 \@onlypreamble\@makecaption@arabic
3117 % \end{macrocode}
3118 % \end{macro}
3119 %
3120 % \begin{macro}{\@makecaption@latvian}
3121 % \begin{macrocode}
3122 % latvian.ldf [2018/02/19 v2.0b Latvian support from the babel system]
3123 \newcommand\@makecaption@latvian[2]{%
3124 \vskip10\p@
3125 \sbox\@tempboxa{#1\if\empty#2\else: #2\fi}%
3126 \ifdim\wd\@tempboxa>\hsize
3127 #1: #2\par
3128 \else
3129 \hbox to\hsize{\hfil\box\@tempboxa\hfil}%
3130 \fi}
3131 \@onlypreamble\@makecaption@latvian
3132 % \end{macrocode}
3133 % \end{macro}
3134 %
3135 % \begin{macro}{\caption@documentclass}
3136 % \changes{v1.8e}{2018/05/11}{This macro added}
3137 % Determine document class used.
3138 % Set |\caption@document|\-|class| by good-guessing, if not already set.
3139 % \begin{macrocode}
3140 \caption@ifundefined\caption@documentclass{%
3141 % \end{macrocode}
3142 % \begin{macrocode}
3143 \@ifclassloaded{beamer}{%
3144 \caption@InfoNoLine{beamer document class detected}%
3145 \def\caption@documentclass{beamer}%
3146 % \end{macrocode}
3147 % \begin{macrocode}
3148 }{\@ifclassloaded{elsarticle}{%
3149 \caption@InfoNoLine{elsarticle document class detected}%
3150 \def\caption@documentclass{elsarticle}%
3151 % \end{macrocode}
3152 % \begin{macrocode}
3153 }{\@ifclassloaded{memoir}{%
3154 \caption@InfoNoLine{memoir document class detected}%
3155 \def\caption@documentclass{memoir}%
3156 % \end{macrocode}
3157 % \begin{macrocode}
3158 }{\caption@ifdefined\scr@caption{%
3159 \caption@InfoNoLine{KOMA-Script document class detected}%
3160 \def\caption@documentclass{koma}%
3161 % \end{macrocode}
3162 % If |\@captionheadfont| is defined, we assume it's a AMS or SMF document class.
3163 % \begin{macrocode}
3164 }{\caption@ifdefined\@captionheadfont{%
3165 \caption@InfoNoLine{AMS or SMF document class detected}%
3166 \def\caption@documentclass{ams-smf}%
3167 % \end{macrocode}
3168 % If |\CaptionFonts| is defined, we assume it's a NTG Dutch document class.
3169 % \begin{macrocode}
3170 }{\caption@ifdefined\CaptionFonts{%
3171 \caption@InfoNoLine{NTG document class detected}%
3172 \def\caption@documentclass{ntg}%
3173 % \end{macrocode}
3174 % If |\cph@font| and |\cpb@font| are defined, we assume it's the thesis document class.
3175 % \begin{macrocode}
3176 }{\caption@ifdefined\cph@font{%
3177 \caption@ifdefined\cpb@font\@firstoftwo\@secondoftwo
3178 }{%
3179 \@secondoftwo
3180 }{%
3181 \caption@InfoNoLine{thesis document class detected}%
3182 \def\caption@documentclass{thesis}%
3183 }{%
3184 % \end{macrocode}
3185 % If the definition of |\@make|\-|caption| matches the one from the standard
3186 % \LaTeX\ document classes |article|, |report|, or |book|, we assume it's
3187 % either one of them or is compatible to them.
3188 % \begin{macrocode}
3189 \def\caption@documentclass{standard}%
3190 \ifx\@makecaption\@undefined
3191 \caption@InfoNoLine{Document class w/o caption stuff detected}%
3192 \else
3193 \ifx\@makecaption\@makecaption@standard
3194 \caption@InfoNoLine{Standard document class detected}%
3195 \else
3196 \ifx\@makecaption\@makecaption@arabic
3197 \caption@InfoNoLine{arabic babel option detected}%
3198 \else
3199 \ifx\@makecaption\@makecaption@latvian
3200 \caption@InfoNoLine{latvian babel option detected}%
3201 \else
3202 % \end{macrocode}
3203 % Otherwise we are clueless and use standard default settings for the captions.
3204 % (And we unset the |document|\-|class| flag to indicate that the content of
3205 % |\caption@document|\-|class| is not correct.)
3206 % \begin{macrocode}
3207 \caption@InfoNoLine{%
3208 Unknown document class (or package),\MessageBreak
3209 standard defaults will be used}%
3210 \caption@InfoNoLine{\string\@makecaption\space=\space\meaning\@makecaption\@gobble}%
3211 \def\caption@documentclass{unknown}%
3212 \fi
3213 \fi
3214 \fi
3215 \fi
3216 % \end{macrocode}
3217 % \begin{macrocode}
3218 }}}}}}}%
3219 }{}
3220 % \end{macrocode}
3221 % \end{macro}
3222 %
3223 % \begin{macro}{\caption@ifdocumentclass}
3224 % \changes{v2.4b}{2023/03/14}{This macro redefined}
3225 % |\caption@ifdocumentclass|\marg{name}\marg{yes-code}\marg{no-code}\\
3226 % expands the given \meta{yes-code} if |\caption@document|\-|class| matches the given \meta{name}.
3227 % Otherwise the \meta{no-code} is expanded.
3228 % \begin{macrocode}
3229 \newcommand*\caption@ifdocumentclass[1]{%
3230 \begingroup
3231 \edef\caption@tempa{\caption@documentclass}%
3232 \edef\caption@tempb{#1}%
3233 \ifx\caption@tempa\caption@tempb
3234 \endgroup\expandafter\@firstoftwo
3235 \else
3236 \endgroup\expandafter\@secondoftwo
3237 \fi}
3238 % \end{macrocode}
3239 % \end{macro}
3240 %
3241 % \begin{macro}{\AtCaptionPackage}
3242 % \changes{v2.0}{2018/05/14}{This macro added}
3243 % |\AtCaptionPackage|\marg{code}\\
3244 % can be used by the document class adaption packages to execute extra code
3245 % if the \pkg{caption} package is loaded (later on).
3246 % This code will by applied right before the package options are evaluated.
3247 % \begin{macrocode}
3248 \newcommand*\AtCaptionPackage{%
3249 \g@addto@macro\caption@documentclass@code}
3250 \@onlypreamble\AtCaptionPackage
3251 % \end{macrocode}
3252 % \begin{macrocode}
3253 \providecommand*\caption@documentclass@code{}
3254 \@onlypreamble\caption@documentclass@code
3255 % \end{macrocode}
3256 % \end{macro}
3257 %
3258 % \begin{macro}{\AfterCaptionPackage}
3259 % \changes{v2.1}{2020/09/12}{This macro added}
3260 % |\AfterCaptionPackage|\marg{code}\\
3261 % can be used by the document class adaption packages to execute extra code
3262 % if the \pkg{caption} package is loaded (later on).
3263 % This code will by applied at the very end.
3264 % \begin{macrocode}
3265 \newcommand*\AfterCaptionPackage{%
3266 \g@addto@macro\caption@endtitles@code}
3267 \@onlypreamble\AfterCaptionPackage
3268 % \end{macrocode}
3269 % \begin{macrocode}
3270 \providecommand*\caption@endtitles@code{}
3271 \@onlypreamble\caption@endtitles@code
3272 % \end{macrocode}
3273 % \end{macro}
3274 %
3275 % \section{Babel support}
3276 %
3277 % \begin{macro}{\caption@IfBabelPackageLoaded}
3278 % |\caption@IfBabelPackageLoaded|\marg{option}\marg{cmd}\marg{yes-code}\marg{no-code}\\
3279 % expands the given \meta{yes-code} if |\caption@if|\-|babel@|\meta{option}
3280 % is set and \meta{cmd} is defined.
3281 % Otherwise the \meta{no-code} is expanded.\par
3282 % This way the adaption could be prevented by defining
3283 % \begin{quote}|\def\caption@ifbabel@|\meta{option}|{false}|\end{quote}
3284 % \begin{macrocode}
3285 \newcommand*\caption@IfBabelPackageLoaded[4]{%
3286 \caption@ifdefined#2\@firstofone\caption@AtBeginDocument{%
3287 \caption@if@bool{\@nameuse{caption@ifbabel@#1}}%
3288 {\def\caption@tempa{\caption@ifdefined#2}}%
3289 {\let\caption@tempa\@secondoftwo}%
3290 \caption@tempa
3291 {\caption@InfoNoLine{#1 babel package is loaded}#3}%
3292 {#4}}}
3293 \@onlypreamble\caption@IfBabelPackageLoaded
3294 % \end{macrocode}
3295 % \end{macro}
3296 %
3297 % \subsection{The arabic \& farsi babel option}
3298 % \changes{v1.8}{2018/05/20}{\pkg{arabic} babel support added}
3299 % \changes{v2.0}{2020/08/02}{\pkg{arabic} babel support updated}
3300 % \changes{v2.0}{2020/08/02}{\pkg{farsi} babel support added}
3301 %
3302 % \begin{macrocode}
3303 \DeclareCaptionLabelSeparator{arabi}{\if@rl\space\fi: }
3304 % \end{macrocode}
3305 %
3306 % \begin{macro}{\caption@IfBabelArabi}
3307 % |\caption@IfBabelArabic|\marg{yes-code}\marg{no-code}
3308 % \begin{macrocode}
3309 \newcommand*\caption@IfBabelArabi{%
3310 \caption@IfBabelPackageLoaded{arabi}{\ArabiCoreLoaded}}
3311 \@onlypreamble\caption@IfBabelArabi
3312 % \end{macrocode}
3313 % \begin{macrocode}
3314 \providecommand*\caption@ifbabel@arabi{true}
3315 % \end{macrocode}
3316 % \end{macro}
3317 %
3318 % \begin{macrocode}
3319 \caption@IfBabelArabi{%
3320 % \end{macrocode}
3321 %
3322 % \begin{macro}{\caption@rl}
3323 % \changes{v1.8}{2018/05/20}{This macro added}
3324 % \begin{macrocode}
3325 \newcommand\caption@rl[1]{\if@rl\textRL{#1}\else\textLR{#1}\fi}%
3326 % \end{macrocode}
3327 % \end{macro}
3328 %
3329 % If the language `arabic' or `farsi' is selected, we switch the default label separator to `arabi'.
3330 %
3331 % \begin{macrocode}
3332 \caption@ifdefined\extrasarabic{%
3333 \addto\extrasarabic{%
3334 \caption@switchdefault{labelseparator}{\babel@save #1}{arabi}}}{}%
3335 \caption@ifdefined\extrasfarsi{%
3336 \addto\extrasfarsi{%
3337 \caption@switchdefault{labelseparator}{\babel@save #1}{arabi}}}{}%
3338 % \end{macrocode}
3339 %
3340 % \begin{macrocode}
3341 }{%
3342 \let\caption@rl\@firstofone
3343 }
3344 % \end{macrocode}
3345 %
3346 % \subsection{The babel-french package}
3347 % \changes{v1.1}{2006/05/14}{\pkg{frenchb} babel support added}
3348 % \changes{v2.0}{2020/08/01}{\pkg{french} babel support updated}
3349 %
3350 % We provide a `french' caption label separator.
3351 % |\caption@french@label|\-|separator| will be defined later on,
3352 % dependent on the `french' package used later on.
3353 %
3354 % \begin{macrocode}
3355 \DeclareCaptionLabelSeparator{french}{\caption@french@labelseparator}
3356 % \end{macrocode}
3357 %
3358 % \begin{macro}{\caption@IfBabelFrench}
3359 % |\caption@IfBabelFrench|\marg{yes-code}\marg{no-code}
3360 % \begin{macrocode}
3361 \newcommand*\caption@IfBabelFrench{%
3362 \caption@IfBabelPackageLoaded{french}{\FB@makecaption}}
3363 \@onlypreamble\caption@IfBabelFrench
3364 % \end{macrocode}
3365 % \begin{macrocode}
3366 \providecommand*\caption@ifbabel@french{true}
3367 % \end{macrocode}
3368 % \end{macro}
3369 %
3370 % \begin{macrocode}
3371 \caption@IfBabelFrench{%
3372 % \end{macrocode}
3373 %
3374 % The \pkg{babel-french} package uses |\Caption|\-|Separator| as label separator.
3375 %
3376 % \begin{macrocode}
3377 \providecommand\caption@french@labelseparator{\CaptionSeparator}%
3378 % \end{macrocode}
3379 %
3380 % Add a space before the label separator `colon' in French
3381 % in order to avoid problems when |Auto|\-|Space|\-|Punctuation| is set to |false|.
3382 %
3383 % \begin{macrocode}
3384 \ifFB@active@punct
3385 \DeclareCaptionLabelSeparator{colon}{%
3386 \ifFBfrench\penalty\@M\FBcolonspace\fi : }%
3387 \fi
3388 % \end{macrocode}
3389 %
3390 % We switch the default label separator to `french', dependant on the switches
3391 % |Customise|\-|Fig|\-|Tab|\-|Captions| and |Old|\-|Fig|\-|Tab|\-|Captions|.
3392 %
3393 % \begin{macrocode}
3394 \ifFBOldFigTabCaptions
3395 \caption@ifdefined\extrasfrench{%
3396 \addto\extrasfrench{%
3397 \caption@switchdefault{labelseparator}{\babel@save #1}{french}}}{}%
3398 \caption@ifdefined\extrasacadian{%
3399 \addto\extrasacadian{%
3400 \caption@switchdefault{labelseparator}{\babel@save #1}{french}}}{}%
3401 \else
3402 \ifFBCustomiseFigTabCaptions
3403 \caption@AtBeginDocument{%
3404 \ifFB@mainlanguage@FR
3405 \SetCaptionDefault{labelseparator}{french}%
3406 \fi}%
3407 \fi
3408 \fi
3409 % \end{macrocode}
3410 %
3411 % \begin{macrocode}
3412 }{}
3413 % \end{macrocode}
3414 %
3415 % \subsection{The frenchle \& frenchpro package}
3416 % \changes{v1.1}{2006/05/14}{\pkg{frenchle/pro} package support added}
3417 % \changes{v2.0}{2020/08/01}{\pkg{frenchle/pro} package support updated}
3418 %
3419 % \begin{macro}{\caption@IfFrenchLe}
3420 % |\caption@IfFrenchLe|\marg{yes-code}\marg{no-code}
3421 % \begin{macrocode}
3422 \newcommand*\caption@IfFrenchLe{%
3423 \caption@IfBabelPackageLoaded{frenchle}{\frenchTeXmods}}
3424 \@onlypreamble\caption@IfBabelFrenchLe
3425 % \end{macrocode}
3426 % \begin{macrocode}
3427 \providecommand*\caption@ifbabel@frenchle{true}
3428 % \end{macrocode}
3429 % \end{macro}
3430 %
3431 % \begin{macrocode}
3432 \caption@IfFrenchLe{%
3433 % \end{macrocode}
3434 %
3435 % The \pkg{frenchle} package uses |\caption|\-|separator| plus |\space| as label separator.
3436 %
3437 % \begin{macrocode}
3438 \providecommand\caption@french@labelseparator{\captionseparator\space}%
3439 % \end{macrocode}
3440 %
3441 % If the language `french' is selected, we switch the default label separator to `french',
3442 % and switch the default font to `it' and the default label font to `up'.
3443 %
3444 % \begin{macrocode}
3445 \g@addto@macro\extrasfrench{%
3446 \caption@switchdefault{labelseparator}{\let\caption@original@labelseparator#1}{french}%
3447 \caption@switchdefault{font}{\let\caption@original@font#1}{it}%
3448 \caption@switchdefault{labelfont}{\let\caption@original@labelfont#1}{up}}%
3449 \g@addto@macro\extrasenglish{%
3450 \caption@restoredefault{labelseparator}{\caption@original@labelseparator}%
3451 \caption@restoredefault{font}{\caption@original@font}%
3452 \caption@restoredefault{labelfont}{\caption@original@labelfont}}%
3453 % \end{macrocode}
3454 %
3455 % Since the \pkg{frenchle} package overwrites |\caption|\-|font| and |\caption|\-|label|\-|font|
3456 % (within |\GOfrench|) we need to save them beforehand and restore them afterwards.
3457 %
3458 % \begin{macrocode}
3459 \caption@AtBeginDocument{%
3460 \let\captionfont@original\captionfont
3461 \let\captionlabelfont@original\captionlabelfont}%
3462 \g@addto@macro\GOfrench{%
3463 \let\captionfont\captionfont@original
3464 \let\captionlabelfont\captionlabelfont@original}%
3465 % \end{macrocode}
3466 %
3467 % \begin{macrocode}
3468 }{}
3469 % \end{macrocode}
3470 %
3471 % \subsection{The babel-hungarian package}
3472 % \changes{v1.3}{2009/03/29}{\pkg{magyar} babel support added}
3473 % \changes{v1.3a}{2011/08/12}{\pkg{magyar} babel support revised}
3474 % \changes{v1.8b}{2018/08/26}{\pkg{magyar} babel support revised}
3475 % \changes{v2.0}{2020/08/03}{\pkg{magyar} babel support updated}
3476 %
3477 % \begin{macrocode}
3478 \DeclareCaptionLabelFormat{magyar}{#2\bothIfSecond{.~}{#1}}
3479 % \end{macrocode}
3480 %
3481 % \begin{macro}{\caption@IfBabelHungarian}
3482 % |\caption@IfBabelHungarian|\marg{yes-code}\marg{no-code}
3483 % \begin{macrocode}
3484 \newcommand*\caption@IfBabelHungarian{%
3485 \caption@IfBabelPackageLoaded{hungarian}{\magyar@opt@defaults}}
3486 \@onlypreamble\caption@IfBabelHungarian
3487 % \end{macrocode}
3488 % \begin{macrocode}
3489 \providecommand*\caption@ifbabel@hungarian{true}
3490 % \end{macrocode}
3491 % \end{macro}
3492 %
3493 % \begin{macrocode}
3494 \caption@IfBabelHungarian{%
3495 % \end{macrocode}
3496 %
3497 % If the language `hungarian' or `magyar' is selected,
3498 % we switch the default label format to `magyar', the default separator to `period',
3499 % and the default list format to `subperiod'.
3500 %
3501 % \begin{macrocode}
3502 \caption@ifdefined\extrashungarian{%
3503 \addto\extrashungarian{%
3504 \caption@switchdefault{labelformat}{\babel@save #1}{magyar}%
3505 \caption@switchdefault{labelseparator}{\babel@save #1}{period}%
3506 \caption@switchdefault{listformat}{\babel@save #1}{subperiod}}}{}%
3507 \caption@ifdefined\extrasmagyar{%
3508 \addto\extrasmagyar{%
3509 \caption@switchdefault{labelformat}{\babel@save #1}{magyar}%
3510 \caption@switchdefault{labelseparator}{\babel@save #1}{period}%
3511 \caption@switchdefault{listformat}{\babel@save #1}{subperiod}}}{}%
3512 % \end{macrocode}
3513 %
3514 % \begin{macrocode}
3515 }{}
3516 % \end{macrocode}
3517 %
3518 % \subsection{The latvian babel option}
3519 %
3520 % \begin{macrocode}
3521 \DeclareCaptionLabelFormat{latvian}{#2\bothIfSecond{~}{#1}}
3522 % \end{macrocode}
3523 %
3524 % \begin{macro}{\caption@IfBabelLatvian}
3525 % |\caption@IfBabelLatvian|\marg{yes-code}\marg{no-code}
3526 % \begin{macrocode}
3527 \newcommand*\caption@IfBabelLatvian{%
3528 \caption@IfBabelPackageLoaded{latvian}{\bbl@latvianindent}}
3529 \@onlypreamble\caption@IfBabelLatvian
3530 % \end{macrocode}
3531 % \begin{macrocode}
3532 \providecommand*\caption@ifbabel@latvian{true}
3533 % \end{macrocode}
3534 % \end{macro}
3535 %
3536 % \begin{macrocode}
3537 \caption@IfBabelLatvian{%
3538 % \end{macrocode}
3539 %
3540 % If the language `latvian' is selected, we switch the default label format to `latvian'.
3541 %
3542 % \begin{macrocode}
3543 \caption@ifdefined\extraslatvian{%
3544 \addto\extraslatvian{%
3545 \caption@switchdefault{labelformat}{\babel@save #1}{latvian}}}{}%
3546 % \end{macrocode}
3547 %
3548 % \begin{macrocode}
3549 }{}
3550 % \end{macrocode}
3551 %
3552 % \section{Package support}
3553 %
3554 % \begin{macro}{\caption@ifpackageloaded}
3555 % \changes{v2.0}{2020/07/26}{This macro added}
3556 % |\caption@ifpackageloaded|\marg{package}\marg{yes-code}\marg{no-code}\\
3557 % expands the given code if the given package is (not) loaded.
3558 % (Note: We cannot use |\@if|\-|package|\-|loaded| here since it's not
3559 % available after |\At|\-|Begin|\-|Document|.)
3560 % \begin{macrocode}
3561 \newcommand*\caption@ifpackageloaded[1]{%
3562 \expandafter\ifx\csname ver@#1.\caption@pkgextension\endcsname\relax
3563 \expandafter\@secondoftwo
3564 \else
3565 \expandafter\@firstoftwo
3566 \fi}
3567 % \end{macrocode}
3568 % \begin{macrocode}
3569 \let\caption@pkgextension\@pkgextension
3570 % \end{macrocode}
3571 % \end{macro}
3572 %
3573 % \begin{macro}{\caption@pkg@list}
3574 % \changes{v1.4b}{2012/01/12}{This macro added}
3575 % We used this in the past as list of packages loaded
3576 % |\At|\-|Begin|\-|Document|.
3577 % (Note: Old |.aux| files could contain
3578 % |\@cons|\-|\caption@pkg@list|\-|{{|\meta{package}|}}|,
3579 % so this macro should always be defined, even if we don't use it anymore.)
3580 % \begin{macrocode}
3581 \newcommand*\caption@pkg@list{}
3582 % \end{macrocode}
3583 % \end{macro}
3584 %
3585 % \begin{macro}{\caption@requirepackage}
3586 % \changes{v1.10}{2020/05/10}{This macro added}
3587 % \changes{v2.0}{2020/07/27}{This macro revised}
3588 % |\caption@requirepackage|\marg{package}\marg{option}\marg{value}\\
3589 % indicates that the given package option needs a package.
3590 % \begin{macrocode}
3591 \newcommand*\caption@requirepackage[2]{%
3592 \caption@ifpackageloaded{#1}{}{\caption@@requirepackage{#1}{#2}}}
3593 % \end{macrocode}
3594 % \begin{macrocode}
3595 \newcommand*\caption@@requirepackage[2]{%
3596 \@cons\caption@packagelist{{#1}{#2}}} % load package later on
3597 % \end{macrocode}
3598 % \begin{macrocode}
3599 \caption@AtBeginDocument{%
3600 \renewcommand*\caption@@requirepackage[2]{%
3601 \caption@Error{Option `#2' requires the `#1' package}}}
3602 % \end{macrocode}
3603 % \end{macro}
3604 %
3605 % \begin{macro}{\caption@packagelist}
3606 % \changes{v1.11}{2020/05/10}{This macro added}
3607 % We use this as list of packages loaded |\At|\-|Begin|\-|Document|.
3608 % \begin{macrocode}
3609 \newcommand*\caption@packagelist{}
3610 \@onlypreamble\caption@packagelist
3611 % \end{macrocode}
3612 % \begin{macrocode}
3613 \caption@AtBeginDocument{%
3614 \def\caption@tempa{\endgroup}%
3615 \begingroup
3616 \def\@elt#1#2{%
3617 \g@addto@macro\caption@tempa{%
3618 \caption@loadpackage{#1}{#2}}}%
3619 \caption@packagelist
3620 \caption@tempa}
3621 % \end{macrocode}
3622 % \end{macro}
3623 %
3624 % \begin{macro}{\caption@loadpackage}
3625 % \changes{v1.11}{2020/05/10}{This macro added}
3626 % \changes{v2.0}{2020/07/26}{This macro revised}
3627 % |\caption@loadpackage|\marg{package}\marg{option}\marg{value}\\
3628 % loads the given package immediately.
3629 % \begin{macrocode}
3630 \newcommand*\caption@loadpackage[2]{%
3631 \caption@ifpackageloaded{#1}{}{\caption@@loadpackage{#1}{#2}}}
3632 % \end{macrocode}
3633 % \begin{macrocode}
3634 \newcommand*\caption@@loadpackage[2]{%
3635 \caption@Info{Option `#2' requires the `#1' package}%
3636 \RequirePackage{#1}\relax}
3637 % \end{macrocode}
3638 % \begin{macrocode}
3639 \caption@AtBeginDocument{%
3640 \let\caption@@loadpackage\caption@@requirepackage}
3641 % \end{macrocode}
3642 % \end{macro}
3643 %
3644 % \subsection{The newfloat package}
3645 %
3646 % \begin{macro}{\caption@newfloat}
3647 % \changes{v1.4b}{2012/01/12}{This macro added}
3648 % \changes{v1.8h}{2020/01/03}{Usage of \cs{caption@ifpackageloaded} replaced by \cs{RequirePackage}}
3649 % \changes{v1.11}{2020/05/10}{Usage of \cs{RequirePackage} replaced by \cs{caption@usepackage}}
3650 % \changes{v2.0}{2020/07/27}{This macro revised}
3651 % |\caption@newfloat|\marg{option}\marg{value}\marg{code}\\
3652 % loads the \pkg{newfloat} package and executes the given code afterwards.
3653 % (Note: Since the package might use the crappy \pkg{keyval}
3654 % package, too, we need to save \& restore some macros here, otherwise this
3655 % recursion won't work properly.)
3656 % \begin{macrocode}
3657 \newcommand*\caption@newfloat[2]{%
3658 \IfCaptionOptionCheck
3659 {\caption@requirepackage{newfloat}{#1}}%
3660 {\let\KV@prefix@ORI\KV@prefix
3661 \let\@tempc@ORI\@tempc
3662 \caption@loadpackage{newfloat}{#1}%
3663 #2%
3664 \let\@tempc\@tempc@ORI
3665 \let\KV@prefix\KV@prefix@ORI}}
3666 % \end{macro}
3667 % \end{macrocode}
3668 % \end{macro}
3669 %
3670 % \changes{v1.0c}{2004/08/03}{Options \opt{figurename} and \opt{tablename} added}
3671 % \changes{v1.1}{2007/07/04}{Options \opt{figurename} and \opt{tablename} re-written}
3672 % \changes{v1.2}{2007/11/18}{Option \opt{name} added}
3673 % \begin{macrocode}
3674 \DeclareCaptionOption{figurename}{\caption@SetName{figure}{#1}}
3675 \@onlypreamble@key{caption}{figurename}
3676 \DeclareCaptionOption{tablename}{\caption@SetName{table}{#1}}
3677 \@onlypreamble@key{caption}{tablename}
3678 % \end{macrocode}
3679 %
3680 % \changes{v1.2a}{2008/02/28}{Options \opt{listfigurename} and \opt{listtablename} added}
3681 % \begin{macrocode}
3682 \DeclareCaptionOption{listfigurename}{\caption@SetName{listfigure}{#1}}
3683 \@onlypreamble@key{caption}{listfigurename}
3684 \DeclareCaptionOption{listtablename}{\caption@SetName{listtable}{#1}}
3685 \@onlypreamble@key{caption}{listtablename}
3686 % \end{macrocode}
3687 %
3688 % \begin{macro}{\caption@SetName}
3689 % \changes{v1.1}{2007/07/04}{This macro added}
3690 % \changes{v1.2}{2007/11/18}{After-preamble variant added}
3691 % \changes{v1.2a}{2008/02/28}{Renamed from \cs{caption@SetFloatName} to \cs{caption@SetName}}
3692 % \changes{v1.2b}{2008/08/02}{Bugfix: Works now without \cs{addto}, too}
3693 % \changes{v1.4a}{2011/10/29}{Outsourced to \pkg{newfloat} package}
3694 % \changes{v1.4b}{2012/01/12}{Bugfix: Uses \cs{caption@newfloat} now}
3695 % |\caption@SetName|\marg{float}\marg{name}\\
3696 % loads the \pkg{newfloat} package and uses |\newfloat@set|\-|name|.
3697 % \begin{macrocode}
3698 \newcommand*\caption@SetName[2]{%
3699 \caption@newfloat{#1name}{\newfloat@setname{#1}{#2}}}
3700 \@onlypreamble\caption@SetName
3701 % \end{macrocode}
3702 % \end{macro}
3703 %
3704 % \begin{macrocode}
3705 \DeclareCaptionOption{name}{%
3706 \IfCaptionOptionCheck{}{\caption@setname\@captype{#1}}}
3707 % \end{macrocode}
3708 %
3709 % \begin{macro}{\caption@setname}
3710 % |\caption@setname|\marg{float}\marg{name}\\
3711 % sets the given float name, e.g.: `Figure` for `figure`.
3712 % \begin{macrocode}
3713 \newcommand*\caption@setname[2]{%
3714 \@namedef{#1name}{#2}}
3715 % \end{macrocode}
3716 % \end{macro}
3717 %
3718 % \changes{v1.2}{2007/12/21}{Options \opt{figurewithin} and \opt{tablewithin} added}
3719 % \changes{v1.2e}{2010/01/09}{The \opt{within} options are now available within the document, too}
3720 %
3721 % \begin{macrocode}
3722 \DeclareCaptionOption{figurewithin}{\caption@within{figure}{#1}}
3723 \DeclareCaptionOptionNoValue{figurewithout}{\caption@within{figure}{none}}
3724 \DeclareCaptionOption{tablewithin}{\caption@within{table}{#1}}
3725 \DeclareCaptionOptionNoValue{tablewithout}{\caption@within{table}{none}}
3726 % \end{macrocode}
3727 %
3728 % \begin{macro}{\caption@within}
3729 % \changes{v1.2}{2007/12/21}{This macro added}
3730 % \changes{v1.4a}{2011/10/29}{Outsourced to \pkg{newfloat} package}
3731 % \changes{v1.4b}{2012/01/12}{Bugfix: Uses \cs{caption@newfloat} now}
3732 % |\caption@within|\marg{float}\marg{value}\\
3733 % loads the \pkg{newfloat} package and uses |\newfloat@set|\-|within|.
3734 % \begin{macrocode}
3735 \newcommand*\caption@within[2]{%
3736 \caption@newfloat{#1within=#2}{\newfloat@setwithin{#1}{#2}}}
3737 % \end{macrocode}
3738 % \end{macro}
3739 %
3740 % \changes{v1.2b}{2008/04/13}{Option \opt{within} added}
3741 % \changes{v1.2e}{2010/01/09}{The global \opt{within} option will now affect user-defined floats declared with \cs{DeclareCaptionType}, too}
3742 %
3743 % \begin{macrocode}
3744 \DeclareCaptionOption{within}{%
3745 \caption@newfloat{within=#1}{\newfloatsetup{within=#1}}}
3746 \DeclareCaptionOptionNoValue{without}{%
3747 \caption@newfloat{without}{\newfloatsetup{without}}}
3748 % \end{macrocode}
3749 %
3750 % \subsection{The ragged2e package}
3751 % \changes{v1.0b}{2004/05/16}{Improved \pkg{ragged2e} package support}
3752 % \changes{v1.8h}{2020/01/03}{Revised \pkg{ragged2e} package support}
3753 % \changes{v1.9}{2020/05/05}{Enhanced \pkg{ragged2e} package support}
3754 % \changes{v1.10}{2020/05/10}{Revised \pkg{ragged2e} package support}
3755 %
3756 % We support the upper-case commands offered by the \pkg{ragged2e}
3757 % package.
3758 % \begin{macrocode}
3759 \DeclareCaptionJustification[ragged2e]{Justified}{\justifying}
3760 \DeclareCaptionJustification[ragged2e]{Centering}{\Centering}
3761 \DeclareCaptionJustification[ragged2e]{RaggedLeft}{\RaggedLeft}
3762 \DeclareCaptionJustification[ragged2e]{RaggedRight}{\RaggedRight}
3763 % \end{macrocode}
3764 %
3765 % \subsection{The sansmath package}
3766 % \changes{v1.3}{2011/01/01}{\pkg{sansmath} package support added}
3767 % \changes{v1.10}{2020/05/10}{\pkg{sansmath} package support revised}
3768 %
3769 % \begin{macrocode}
3770 \DeclareCaptionFont[sansmath]{sansmath}{\sansmath}
3771 % \end{macrocode}
3772 %
3773 % \subsection{The setspace package}
3774 % \changes{v1.0n}{2007/04/02}{\pkg{setspace} package support added}
3775 % \changes{v1.2d}{2009/10/09}{\pkg{setspace} package support revised}
3776 % \changes{v2.3}{2021/11/20}{The font option \opt{stretch} does not require the \pkg{setspace} package anymore}
3777 %
3778 % \begin{macrocode}
3779 \DeclareCaptionFont{singlespacing}{%
3780 \caption@ifdefined\setspace@singlespace
3781 {\setstretch\setspace@singlespace}% usually 1, could be changed by \SetSinglespace
3782 {}}
3783 \DeclareCaptionFont{stretch}{%
3784 \caption@ifdefined\setstretch
3785 {\setstretch{#1}}%
3786 {\def\baselinestretch{#1}\selectfont}}
3787 % \end{macrocode}
3788 % \begin{macrocode}
3789 \DeclareCaptionFont[setspace]{onehalfspacing}{\onehalfspacing}
3790 \DeclareCaptionFont[setspace]{doublespacing}{\doublespacing}
3791 % \end{macrocode}
3792 %
3793 % \subsection{The subfig package}
3794 % \changes{v1.1}{2007/07/07}{Adaptions to the \pkg{subfig} package added}
3795 % \changes{v1.4a}{2011/11/01}{Test for the \pkg{subfig} package revised}
3796 % \changes{v2.0a}{2020/09/07}{Re-definition of \cs{sf@ifpositiontop} added}
3797 %
3798 % Since the \pkg{subfig} package is not maintained anymore,
3799 % we have to make adaptions to \thispackage~\version{1.1} here.
3800 % Please note that we only support the version $1.3$ of the \pkg{subfig} package,
3801 % so older versions do not work with this version of \thispackage, and newer
3802 % versions are expected to be adapted.
3803 %
3804 % \begin{macrocode}
3805 \caption@AtBeginDocument{%
3806 \def\@tempa{2005/06/28 ver: 1.3 subfig package}%
3807 \expandafter\ifx\csname [email protected]\endcsname\@tempa
3808 \caption@InfoNoLine{subfig package v1.3 is loaded}%
3809 % \end{macrocode}
3810 % \begin{macrocode}
3811 \def\caption@eh{\caption@@eh{subfig}}%
3812 \let\caption@setfloattype\@gobble
3813 \let\@dottedxxxline\sf@NEW@dottedxxxline
3814 \let\sf@subfloat\sf@NEW@subfloat
3815 \def\sf@ifpositiontop{\caption@iftop}%
3816 % \end{macrocode}
3817 % \begin{macrocode}
3818 \fi
3819 \let\sf@NEW@dottedxxxline\@undefined
3820 \let\sf@NEW@subfloat\@undefined}
3821 % \end{macrocode}
3822 %
3823 % \begin{macro}{\@dottedxxxline}
3824 % New version of |\@dottedxxxline|
3825 % \begin{macrocode}
3826 \def\sf@NEW@dottedxxxline#1#2#3#4#5#6#7{%
3827 \begingroup
3828 \caption@setfloattype{#1}%
3829 \caption@setoptions{subfloat}%
3830 \caption@setoptions{sub#1}%
3831 \ifnum #3>\@nameuse{c@#2depth}\else
3832 \@dottedtocline{\z@}{#4}{#5}{#6}{#7}%
3833 \fi
3834 \endgroup}
3835 % \end{macrocode}
3836 % \end{macro}
3837 %
3838 % \begin{macro}{\sf@subfloat}
3839 % \changes{v1.4b}{2011/12/29}{Bugfix 11-12-23: Usage of \cs{caption@warmup} added}
3840 % New version of |\sf@subfloat|
3841 % \begin{macrocode}
3842 \def\sf@NEW@subfloat{%
3843 \begingroup
3844 \@nameuse{caption@warmup}%
3845 \caption@setfloattype\@captype
3846 \sf@ifpositiontop{%
3847 \maincaptiontoptrue
3848 }{%
3849 \maincaptiontopfalse
3850 }%
3851 \caption@setoptions{subfloat}%
3852 \caption@setoptions{sub\@captype}%
3853 \let\sf@oldlabel=\label
3854 \let\label=\subfloat@label
3855 \ifmaincaptiontop\else
3856 \advance\@nameuse{c@\@captype}\@ne\relax
3857 \fi
3858 \refstepcounter{sub\@captype}%
3859 \setcounter{sub\@captype @save}{\value{sub\@captype}}%
3860 \@ifnextchar [% %] match left bracket
3861 {\sf@@subfloat}%
3862 {\sf@@subfloat[\@empty]}}
3863 % \end{macrocode}
3864 % \end{macro}
3865 %
3866 % Make the \pkg{subfig} package documentation compile.
3867 % \begin{macrocode}
3868 \DeclareCaptionOption{lofdepth}[2]{\caption@ifdefined\c@lofdepth{\setcounter{lofdepth}{#1}}{}}
3869 \DeclareCaptionOption{lotdepth}[2]{\caption@ifdefined\c@lotdepth{\setcounter{lotdepth}{#1}}{}}
3870 % \end{macrocode}
3871 %
3872 % \section{Making an `List of' entry}
3873 %
3874 % \begin{macro}{\caption@addcontentsline}
3875 % \changes{v1.1}{2007/07/01}{This macro added}
3876 % \changes{v1.3}{2010/10/26}{Error check added}
3877 % \changes{v1.3}{2011/06/24}{Split into two macros}
3878 % \changes{v1.4}{2011/08/19}{Split into three macros}
3879 % \changes{v1.4}{2011/08/30}{Support for option \opt{listtype=} added}
3880 % \changes{v1.5}{2012/01/15}{Usage of \cs{caption@addsubcontentslines} added}
3881 % \changes{v1.7}{2015/09/15}{Argument \#3 which holds the environment name added to \cs{caption@lstfmt}}
3882 % \changes{v1.7}{2015/09/20}{Unfortunately \pkg{subfig} defines and uses \cs{caption@lstfmt} as well, so I replaced the third argument with \cs{captionlisttype}}
3883 % \changes{v1.8}{2018/09/06}{Adapted to the \pkg{chkfloat} package}
3884 % \changes{v2.3}{2021/01/06}{Usage of \cs{p@xxx} and \cs{thexxx} replaced by \cs{caption@p} and \cs{caption@the}}
3885 % |\caption@addcontentsline|\marg{type}\marg{list entry}\\
3886 % makes an entry in the list-of-whatever, if requested, i.e.~the argument
3887 % \meta{list entry} is not empty and |list|\-|of=| was set to |true|.
3888 % \begin{macrocode}
3889 \newcommand\caption@addcontentsline[2]{%
3890 \caption@ifcontentsline{#2}{%
3891 \begingroup
3892 \let\@tempa\@gobble
3893 \caption@ifdefined\caption@listtype
3894 {\let\@tempa\@firstofone}%
3895 {\edef\caption@listtype{#1}}%
3896 \caption@ifdefined\caption@listtype@ext
3897 {\edef\caption@listtype{\caption@listtype\caption@listtype@ext}%
3898 \let\@tempa\@firstofone}%
3899 {}%
3900 \@tempa
3901 {\caption@Debug{addcontentsline: #1 => \caption@listtype}%
3902 % \caption@setoptions\caption@listtype
3903 \@namedef{the\caption@listtype}{\caption@the{#1}}}%
3904 \expandafter\caption@@addcontentsline\expandafter{\caption@listtype}{#2}%
3905 \endgroup}%
3906 \caption@addsubcontentslines{#1}}
3907 % \end{macrocode}
3908 % \begin{macrocode}
3909 \newcommand\caption@@addcontentsline[2]{%
3910 {\let\\\space
3911 \@ifundefined{ext@#1}%
3912 {\caption@Error{No float type '#1' defined}}%
3913 {\def\captionlisttype{#1}%
3914 \caption@add@contentsline
3915 {\csname ext@#1\endcsname}%
3916 {#1}%
3917 {\caption@listformat{\caption@p{#1}}{\caption@the{#1}}}%
3918 {\ignorespaces #2}%
3919 \caption@chkfloat{#1}{#2}}}}
3920 % \end{macrocode}
3921 % \begin{macrocode}
3922 \newcommand*\caption@add@contentsline{%
3923 \caption@@@addcontentsline}
3924 % \end{macrocode}
3925 % \begin{macrocode}
3926 \newcommand*\caption@@@addcontentsline[4]{%
3927 % \caption@ifdefined\main@Arabi@language
3928 % {\addtocontents{#1}{\xstring\select@language{\main@Arabi@language}}}{}%
3929 \addcontentsline{#1}{#2}{\protect\numberline{#3}{#4}}}
3930 % \end{macrocode}
3931 % \begin{macrocode}
3932 \let\caption@chkfloat\@gobbletwo
3933 % \end{macrocode}
3934 % \begin{macrocode}
3935 \newcommand\caption@ifcontentsline[1]{%
3936 \caption@iflist
3937 {\def\@tempa{#1}}%
3938 {\let\@tempa\@empty}%
3939 \ifx\@tempa\@empty
3940 \expandafter\@gobble
3941 \else
3942 \expandafter\@firstofone
3943 \fi}
3944 % \end{macrocode}
3945 % \begin{macrocode}
3946 \newcommand*\caption@addsubcontentslines[1]{}
3947 % \end{macrocode}
3948 % \end{macro}
3949 %
3950 % \section{Typesetting the caption}
3951 %
3952 % \begin{macro}{\ifcaption@star}
3953 % If the starred form of |\caption| is used, this will be set to |true|.
3954 % (It will be reset to |false| at the end of |\caption@@make|.)
3955 % \begin{macrocode}
3956 \newif\ifcaption@star
3957 % \end{macrocode}
3958 % \end{macro}
3959 %
3960 % \begin{macro}{\caption@aboveskip}
3961 % \begin{macro}{\caption@belowskip}
3962 % \changes{v2.0}{2020/08/23}{This macro moved from package to kernel}
3963 % |\caption@aboveskip| and |\caption@belowskip|\\
3964 % typeset the skip above or below the caption.
3965 % \begin{macrocode}
3966 \newcommand*\caption@aboveskip{%
3967 \vskip\abovecaptionskip}
3968 % \end{macrocode}
3969 % \begin{macrocode}
3970 \newcommand*\caption@belowskip{%
3971 \vskip\belowcaptionskip}
3972 % \end{macrocode}
3973 % \end{macro}
3974 % \end{macro}
3975 %
3976 % \begin{macro}{\caption@fnum}
3977 % \changes{v1.1}{2007/08/21}{This macro added}
3978 % \changes{v2.0}{2020/08/03}{The original definition will be stored in \cs{caption@original@fnum}}
3979 % \changes{v2.3}{2021/01/06}{Usage of \cs{thexxx} replaced by \cs{caption@the}}
3980 % \changes{v2.3}{2022/01/05}{Definition of \cs{caption@@fnum} added}
3981 % |\caption@fnum|\marg{float type}\\
3982 % |\caption@@fnum|\marg{float type}\marg{name}\marg{number}\\
3983 % typesets the caption label; this acts as replacement for |\fnum@|\meta{float type}.
3984 % \begin{macrocode}
3985 \newcommand*\caption@fnum[1]{%
3986 \caption@@fnum{#1}{\@nameuse{#1name}}{\caption@the{#1}}}
3987 % \end{macrocode}
3988 % \begin{macrocode}
3989 \newcommand*\caption@@fnum[1]{%
3990 \expandafter\let\expandafter\caption@original@fnum\csname caption@fnum@#1\endcsname % for label format `original'
3991 \caption@labelformat}
3992 % \end{macrocode}
3993 % \end{macro}
3994 %
3995 % \begin{macro}{\caption@setfnum}
3996 % \changes{v1.1}{2007/03/10}{This macro added}
3997 % \changes{v2.0}{2020/08/03}{Adapted to \pkg{caption3} v2.0}
3998 % \changes{v2.3}{2022/01/05}{Definition moved from package to kernel}
3999 % |\caption@setfnum|\marg{type}\\
4000 % stores the original definition of |\fnum@|\meta{type} in |\caption@fnum@|\meta{type}
4001 % and re-defines it according the caption label format set with |label|\-|format=|.
4002 % \begin{macrocode}
4003 \newcommand*\caption@setfnum[1]{%
4004 \@ifundefined{caption@fnum@#1}%
4005 {\expandafter\let\csname caption@fnum@#1\expandafter\endcsname\csname fnum@#1\endcsname
4006 \@namedef{fnum@#1}{\caption@fnum{#1}}}%
4007 {}}
4008 % \end{macrocode}
4009 % \end{macro}
4010 %
4011 % \begin{macro}{\caption@p}
4012 % \changes{v2.3}{2021/01/06}{This macro added}
4013 % |\caption@p| is a simple wrapper macro for |\@nameuse{p@#1}|.
4014 % \begin{macrocode}
4015 \newcommand*\caption@p[1]{\@nameuse{p@#1}}
4016 % \end{macrocode}
4017 % \end{macro}
4018 %
4019 % \begin{macro}{\caption@the}
4020 % \changes{v2.3}{2021/01/06}{This macro added}
4021 % |\caption@the| is a simple wrapper macro for |\@nameuse{the#1}|.
4022 % \begin{macrocode}
4023 \newcommand*\caption@the[1]{\@nameuse{the#1}}
4024 % \end{macrocode}
4025 % \end{macro}
4026 %
4027 % \begin{macro}{\caption@make}
4028 % \changes{v2.3}{2022/01/05}{Optional argument \meta{float type} added}
4029 % |\caption@make|\oarg{float type}\marg{float name}\marg{ref.\ number}\marg{text}\\
4030 % typesets the caption.
4031 % \begin{macrocode}
4032 \newcommand*\caption@make{%
4033 \kernel@ifnextchar[%]
4034 \caption@make@
4035 {\caption@make@@\caption@labelformat}}
4036 % \end{macrocode}
4037 % \begin{macrocode}
4038 \def\caption@make@[#1]{%
4039 \caption@make@@{\caption@@fnum{#1}}}
4040 % \end{macrocode}
4041 % \begin{macrocode}
4042 \newcommand\caption@make@@[3]{%
4043 \caption@@make{#1{#2}{#3}}}
4044 % \end{macrocode}
4045 % \end{macro}
4046 %
4047 % \begin{macro}{\caption@@make}
4048 % \changes{v1.0b}{2004/05/16}{Bugfix 04-05-05: \cs{ifdim}\cs{captionindent=}\cs{z@} added}
4049 % \changes{v1.0c}{2005/02/12}{Bugfix 04-10-26: Use \cs{@tempdima} instead of \cs{captionmargin} or \cs{captionwidth}; check for \cs{z@} added}
4050 % \changes{v1.0c}{2005/02/12}{Bugfix: \cs{hskip}\cs{captionmargin} to the end of caption added}
4051 % \changes{v1.0c}{2005/02/12}{Bugfix: \cs{strut} moved from here to \cs{caption@@@make}}
4052 % \changes{v1.0c}{2005/02/12}{Single-line-check moved up so it can affect margins now}
4053 % \changes{v1.0c}{2005/02/09}{Improvement: \cs{caption@ifhmode} added}
4054 % \changes{v1.0c}{2005/02/09}{Bugfix: \cs{leavevmode} added}
4055 % \changes{v1.0f}{2005/08/24}{Uses \cs{sbox} instead of \cs{setbox} in single-line-check}
4056 % \changes{v1.0g}{2005/12/04}{Uses \cs{caption@slc} now}
4057 % \changes{v1.0g}{2006/01/11}{Bugfix: \cs{caption@calcmargin} inside single-line-check replaced by \cs{relax}}
4058 % \changes{v1.0g}{2006/01/11}{Bugfix: \cs{caption@startbox} will always be typeset in horizontal mode}
4059 % \changes{v1.0i}{2006/05/13}{Uses \cs{caption@parbox} instead of \cs{caption@start/endbox}}
4060 % \changes{v1.0j}{2007/01/04}{Oops, bugfix 04-05-05 got lost in v1.0h, re-added}
4061 % \changes{v1.0n}{2007/04/03}{Usage of \cs{caption@ifoddpage} added}
4062 % \changes{v1.1}{2007/07/29}{\cs{caption@calcmargin} moved below single-line-check}
4063 % \changes{v1.1e}{2007/10/28}{\cs{caption@stepcounter} added}
4064 % \changes{v1.5}{2012/03/15}{Uses \cs{caption@tempdima} instead of \cs{@tempdima}}
4065 % \changes{v1.5}{2012/12/26}{max-margin stuff moved to \cs{caption@calcmargin}}
4066 % \changes{v1.6}{2013/05/01}{Usage of \cs{caption@box} added}
4067 % \changes{v1.7}{2016/01/31}{Adapted to the \pkg{bicaption} package}
4068 % \changes{v1.8f}{2019/12/18}{Usage of \cs{linewidth} replaced by \cs{hsize}}
4069 % \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}}
4070 % |\caption@@make|\marg{caption label}\marg{caption text}
4071 % \begin{macrocode}
4072 \newcommand\caption@@make[2]{%
4073 \begingroup
4074 \caption@@make@{#1}{#2}%
4075 \endgroup
4076 \caption@@make@epilogue}
4077 % \end{macrocode}
4078 % \begin{macrocode}
4079 \newcommand\caption@@make@[2]{%
4080 \caption@stepthecounter
4081 \caption@beginhook
4082 % \end{macrocode}
4083 % Typeset the outer box |\caption@box|
4084 % \begin{macrocode}
4085 \caption@box\hsize{%
4086 % \end{macrocode}
4087 % Special single-line treatment (option |singlelinecheck=|)
4088 % \begin{macrocode}
4089 \caption@singlelinecheck{\caption@slc{#1}{#2}\caption@singleline\caption@multiline}{\caption@multiline}%
4090 % \end{macrocode}
4091 % Typeset the left margin (option |margin=|)
4092 % \begin{macrocode}
4093 \caption@calcmargin
4094 \caption@make@leftmargin
4095 % \end{macrocode}
4096 % We actually use a |\vbox| of width |\caption@width - \caption@indent|
4097 % to typeset the caption.
4098 % \Note{\cs{captionindent} is \emph{not} supported if the caption format
4099 % was defined with \cs{DeclareCaptionFormat*}.}
4100 % \begin{macrocode}
4101 \caption@make@parbox{%
4102 % \end{macrocode}
4103 % Typeset the indention (option |indention=|)\\
4104 % {\small Bugfix 04-05-05:
4105 % |\hskip-\caption@indent| replaced by |\ifdim\caption@indent=\z@|\ldots}
4106 % \begin{macrocode}
4107 \caption@make@indention
4108 % \end{macrocode}
4109 % Typeset the caption itself and close the |\caption@parbox|
4110 % \begin{macrocode}
4111 \caption@@@make{#1}{#2}}%
4112 % \end{macrocode}
4113 % Typeset the right margin (option |margin=|)
4114 % \begin{macrocode}
4115 \caption@make@rightmargin
4116 % \end{macrocode}
4117 % Close the outer box |\caption@box|
4118 % \begin{macrocode}
4119 }%
4120 % \end{macrocode}
4121 % \begin{macrocode}
4122 \caption@endhook}
4123 % \end{macrocode}
4124 % \begin{macrocode}
4125 \newcommand*\caption@make@leftmargin{%
4126 \caption@tempdima\caption@leftmargin
4127 \caption@ifhmode{\advance\caption@tempdima\caption@indent\relax}%
4128 \hspace\caption@tempdima}
4129 % \end{macrocode}
4130 % \begin{macrocode}
4131 \newcommand*\caption@make@parbox{%
4132 \caption@tempdima\caption@width
4133 \caption@ifhmode{\advance\caption@tempdima-\caption@indent\relax}%
4134 \caption@parbox\caption@tempdima}
4135 % \end{macrocode}
4136 % \begin{macrocode}
4137 \newcommand*\caption@make@indention{%
4138 \caption@ifhmode{%
4139 \ifdim\caption@indent=\z@
4140 \leavevmode
4141 \else
4142 \hskip-\caption@indent
4143 \fi}}
4144 \newcommand*\caption@make@rightmargin{%
4145 \hspace\caption@rightmargin}
4146 % \end{macrocode}
4147 % \begin{macrocode}
4148 \newcommand*\caption@@make@epilogue{%
4149 \global\caption@starfalse}
4150 % \end{macrocode}
4151 % \end{macro}
4152 %
4153 % \begin{macro}{\caption@calcmargin}
4154 % \changes{v1.0f}{2005/10/24}{Internal: \cs{ifcaption@width} replaced by \cs{ifdim}\cs{captionwidth=}\cs{z@}}
4155 % \changes{v1.0g}{2006/01/12}{Improvement: Takes care of list environment now}
4156 % \changes{v1.1}{2006/05/13}{Check of \cs{@listdepth} removed (not necessary anymore), use \cs{linewidth} instead of \cs{hsize}}
4157 % \changes{v1.5}{2012/12/26}{max-margin stuff moved from \cs{caption@@make} to here}
4158 % \changes{v1.8f}{2019/12/18}{Usage of \cs{linewidth} replaced by \cs{hsize}}
4159 % \changes{v2.3}{2021/01/17}{Uses \cs{caption@width} or \cs{caption@leftmargin} and \cs{caption@rightmargin} now}
4160 % |\caption@calcmargin|\\
4161 % calculates |\caption|\-|@left|\-|margin|, |\caption|\-|@width|, and |\caption|\-|@right|\-|margin|,
4162 % so all three contain valid values afterwards.
4163 % \begin{macrocode}
4164 \newcommand*\caption@calcmargin{%
4165 \caption@calcmargin@hook
4166 \ifdim\caption@width=\z@
4167 % \end{macrocode}
4168 % If |\caption|\-|margin| is set use this value instead of |\caption@left|\-|margin| and |\caption@right|\-|margin|
4169 % \begin{macrocode}
4170 \ifdim\captionmargin=\z@ \else
4171 \caption@leftmargin\captionmargin
4172 \caption@rightmargin\captionmargin
4173 \fi
4174 % \end{macrocode}
4175 % Check the margin values if |\caption@min|\-|margin| or |\caption@max|\-|margin| is set
4176 % \begin{macrocode}
4177 \ifx\caption@maxmargin\@undefined \else
4178 \ifdim\caption@leftmargin>\caption@maxmargin
4179 \caption@leftmargin\caption@maxmargin
4180 \fi
4181 \ifdim\caption@rightmargin>\caption@maxmargin
4182 \caption@rightmargin\caption@maxmargin
4183 \fi
4184 \fi
4185 \ifx\caption@minmargin\@undefined \else
4186 \ifdim\caption@leftmargin<\caption@minmargin
4187 \caption@leftmargin\caption@minmargin
4188 \fi
4189 \ifdim\caption@rightmargin<\caption@minmargin
4190 \caption@rightmargin\caption@minmargin
4191 \fi
4192 \fi
4193 % \end{macrocode}
4194 % Check if the left and right margins needs to be swapped
4195 % \begin{macrocode}
4196 \ifdim\caption@leftmargin=\caption@rightmargin \else
4197 \caption@ifoddpage{}{%
4198 \caption@tempdima\caption@leftmargin
4199 \caption@leftmargin\caption@rightmargin
4200 \caption@rightmargin\caption@tempdima}%
4201 \fi
4202 % \end{macrocode}
4203 % Set |\caption@width|
4204 % \begin{macrocode}
4205 \caption@width\hsize
4206 \advance\caption@width by -\caption@leftmargin\relax
4207 \advance\caption@width by -\caption@rightmargin\relax
4208 % \end{macrocode}
4209 % \begin{macrocode}
4210 \else
4211 \caption@leftmargin\hsize
4212 \advance\caption@leftmargin by -\caption@width\relax
4213 \divide\caption@leftmargin by 2\relax
4214 \caption@rightmargin\caption@leftmargin
4215 \fi
4216 % \end{macrocode}
4217 % \begin{macrocode}
4218 \caption@Debug{%
4219 hsize=\the\hsize,
4220 width=\the\caption@width,\MessageBreak
4221 leftmargin=\the\caption@leftmargin,
4222 rightmargin=\the\caption@rightmargin}}
4223 % \end{macrocode}
4224 % \end{macro}
4225 %
4226 % \begin{macro}{\caption@slc}
4227 % \changes{v1.1}{2007/06/13}{\cs{let}\cs{caption@justification}\cs{relax} added}
4228 % \changes{v1.1}{2007/07/29}{\cs{caption@setup}\cs{caption@sls} added after \cs{begingroup}}
4229 % \changes{v1.1}{2007/07/29}{\cs{caption@calcmargin} added}
4230 % \changes{v1.1c}{2007/10/14}{\cs{caption@setup}\cs{caption@opt@SingleLine} outsourced to \cs{caption@SingleLine}}
4231 % \changes{v1.3}{2010/09/04}{Split into \cs{caption@slc} and \cs{caption@@slc}}
4232 % \changes{v1.5}{2012/12/26}{Merged into a single macro again}
4233 % \changes{v1.5}{2013/04/14}{Usage of \cs{ifsinglelinecaption} added}
4234 % |\caption@slc|\marg{label}\marg{text}\marg{single-line-code}\marg{multi-line-code}\\
4235 % This one does the single-line-check.
4236 % \begin{macrocode}
4237 \newcommand\caption@slc[4]{%
4238 \caption@Debug{Begin SLC}%
4239 \singlelinecaptiontrue
4240 \begingroup
4241 \caption@singleline
4242 \let\caption@justification\relax
4243 \caption@calcmargin % calculate \caption@width
4244 \caption@prepareslc
4245 \sbox\@tempboxa{\caption@@@make{#1}{#2}}%
4246 \ifdim\wd\@tempboxa>\caption@width
4247 \endgroup
4248 \singlelinecaptionfalse
4249 #4%
4250 \else
4251 \endgroup
4252 #3%
4253 \fi
4254 \caption@Debug{End SLC}}
4255 % \end{macrocode}
4256 % \end{macro}
4257 %
4258 % \begin{macro}{\ifsinglelinecaption}
4259 % \changes{v1.5}{2013/04/14}{This definition added}
4260 % |\ifsinglelinecaption|\\
4261 % could be used inside own caption formats to test if the caption is
4262 % currently typeset as single-line caption (or not).
4263 % \begin{macrocode}
4264 \newif\ifsinglelinecaption
4265 % \end{macrocode}
4266 % \end{macro}
4267 %
4268 % \begin{macro}{\caption@singleline}
4269 % \changes{v1.1c}{2007/10/14}{This macro extracted from \cs{caption@slc}}
4270 % \changes{v1.1c}{2007/10/14}{Support of \cs{caption@slfmt} added}
4271 % \changes{v1.1d}{2007/10/23}{This macro renamed from \cs{caption@SingleLine} to \cs{caption@singleline} for consistency}
4272 % |\caption@singleline|\\
4273 % prepares the typesetting of a single-line caption.
4274 % \begin{macrocode}
4275 \newcommand*\caption@singleline{%
4276 \caption@xsetup\caption@slsty % Note: This could change \caption@format
4277 \caption@format % defines \caption@ifhmode, \caption@slfmt, and \caption@fmt
4278 \let\caption@fmt\caption@slfmt}
4279 % \end{macrocode}
4280 % \end{macro}
4281 %
4282 % \begin{macro}{\caption@multiline}
4283 % \changes{v2.0}{2020/07/28}{This macro added}
4284 % |\caption@multiline|\\
4285 % prepares the typesetting of a multi-line caption.
4286 % \begin{macrocode}
4287 \newcommand*\caption@multiline{%
4288 \caption@format} % defines \caption@ifhmode, \caption@slfmt, and \caption@fmt
4289 % \end{macrocode}
4290 % \end{macro}
4291 %
4292 % \begin{macro}{\AtCaptionSingleLineCheck}
4293 % \changes{v2.3}{2021/06/30}{This macro added}
4294 % |\AtCaptionSingleLineCheck|\marg{code}\\
4295 % adds code to be expanded right before the single-line-check.
4296 % (This will be done in an extra group, so all changes done are unually limited to the check.)
4297 % \begin{macrocode}
4298 \newcommand*\AtCaptionSingleLineCheck{%
4299 \g@addto@macro\caption@prepareslc}
4300 % \end{macrocode}
4301 % \end{macro}
4302 %
4303 % \begin{macro}{\caption@prepareslc}
4304 % \changes{v1.0b}{2004/05/16}{Redefinition of \cs{label} \& \cs{@footnotetext} added}
4305 % \changes{v1.0b}{2004/05/16}{Redefine \cs{stepcounter} instead of \cs{footnote(mark)}}
4306 % \changes{v1.0c}{2005/02/12}{\cs{let}\cs{caption@justification}\cs{relax} added}
4307 % \changes{v1.0f}{2005/07/09}{Support of \pkg{endnotes} package added}
4308 % \changes{v1.1}{2007/06/13}{\cs{let}\cs{caption@justification}\cs{relax} moved to \cs{caption@slc}}
4309 % \changes{v1.1}{2007/06/13}{Redefinition of \cs{(H@)refstepcounter} added}
4310 % \changes{v1.1}{2007/08/12}{Redefinition of \cs{label} improved}
4311 % \changes{v1.1c}{2007/10/06}{Definition of \cs{caption@l@stepcounter} added}
4312 % \changes{v1.3}{2011/07/07}{Redefinition of \cs{footnote} and \cs{footnotemark} added, redefinition of \cs{stepcounter} and \cs{refstepcounter} dropped}
4313 % \changes{v1.5}{2013/04/13}{Redefinition os \cs{glsunset} added}
4314 % \changes{v1.8}{2018/01/21}{Redefinition of \cs{endnote} added (thanks to Markus Kohm)}
4315 % \changes{v1.8}{2018/05/16}{Redefinition of \cs{acused} added}
4316 % \changes{v1.8}{2018/05/26}{Definition method changed so it can be pre-defined by other packages}
4317 % \changes{v1.8}{2018/05/27}{Redefinition of \cs{hypertarget} added}
4318 % \changes{v2.3}{2021/07/03}{Redefinition of \cs{footnote} and \cs{endnote} stuff revised}
4319 % \changes{v2.4c}{2023/07/28}{Redefinition of \cs{index} and \cs{glossary} added}
4320 % \changes{v2.4c}{2023/07/28}{Application of code defined via \cs{GetTitleStringDisableCommands} added}
4321 % |\caption@prepareslc|\\
4322 % re-defines anything which could disturb the single-line-check.
4323 % \begin{macrocode}
4324 \providecommand*\caption@prepareslc{}
4325 \AtCaptionSingleLineCheck{%
4326 \let\caption@protect\protect
4327 \caption@ifdefined\GTS@DisablePredefinedCmds\GTS@DisablePredefinedCmds\relax
4328 % \end{macrocode}
4329 % \begin{macrocode}
4330 \let\label\caption@gobble
4331 \let\index\caption@gobble
4332 \let\glossary\caption@gobble
4333 \let\hypertarget\@gobbletwo
4334 % \end{macrocode}
4335 % We re-define \cs{footnote} so
4336 % \begin{enumerate}
4337 % \item The footnote counter will not be increased twice (but still the
4338 % correct footnote mark will be used within the single-line-check)
4339 % \item The footnote text will not be evaluated twice
4340 % \end{enumerate}
4341 % \begin{macrocode}
4342 \let\footnote\caption@footnote
4343 \let\footnotemark\caption@footnotemark
4344 \let\footnotetext\caption@footnotetext
4345 \let\@footnotetext\@gobble
4346 % \end{macrocode}
4347 % Adaption to the \pkg{hyperref} package
4348 % \begin{macrocode}
4349 \let\H@@footnotetext\@gobble
4350 \let\H@@mpfootnotetext\@gobble
4351 \caption@ifdefined\H@@footnotemark
4352 {\let\@footnotemark\H@@footnotemark}%
4353 {}%
4354 % \end{macrocode}
4355 % Adaption to the \pkg{tablefootnote} package
4356 % \begin{macrocode}
4357 \let\tablefootnote\caption@footnote
4358 % \end{macrocode}
4359 % Same for \cs{endnote}
4360 % \begin{macrocode}
4361 \let\endnote\caption@endnote
4362 \let\endnotemark\caption@endnotemark
4363 \let\endnotetext\caption@endnotetext
4364 \let\@endnotetext\@gobble
4365 % \end{macrocode}
4366 % Adaption to the \pkg{acronym} package\par
4367 % See also \url{https://tex.stackexchange.com/questions/428788}
4368 % \begin{macrocode}
4369 \let\acused\@gobble
4370 \let\AC@placelabel\@gobble
4371 % \end{macrocode}
4372 % Adaption to the \pkg{glossaries} package\par
4373 % Please note that while this adaption is usually sufficient
4374 % it could give incorrect measuring results if \cs{gls} is both used
4375 % for the very first time and more than once (for a particular acronym).
4376 % The alternative would be using internal macros of the
4377 % \pkg{glossaries} package which I would like to avoid.\par
4378 % See also \url{https://tex.stackexchange.com/questions/108368}
4379 % \begin{macrocode}
4380 \let\glsunset\@gobble
4381 % \end{macrocode}
4382 % Execute code defined by |\Get|\-|Title|\-|String|\-|Disable|\-|Commands|
4383 % \begin{macrocode}
4384 \caption@ifdefined\GTS@DisableHook\GTS@DisableHook\relax
4385 \let\protect\caption@protect
4386 % \end{macrocode}
4387 % \begin{macrocode}
4388 }
4389 % \end{macrocode}
4390 % \end{macro}
4391 %
4392 % \begin{macro}{\caption@footnote}
4393 % \changes{v1.3}{2011/07/07}{This macro added}
4394 % \changes{v1.4a}{2011/10/22}{This macro revised}
4395 % \changes{v2.3}{2021/07/03}{This macro re-written}
4396 % \changes{v2.4}{2022/04/18}{\cs{@ifnextchar} replaced by \cs{kernel@ifnextchar}}
4397 % The following code was taken from |base/ltfloat.dtx| but |\step|\-|counter|
4398 % is replaced by |\caption@l@step|\-|counter| so the footnote counter will
4399 % only be incremented temporarily for the single-line-check.
4400 % (In the past we had re-used the original code but with re-defined
4401 % |\step|\-|counter| but this has proofed as non-sufficient when
4402 % using footnote related packages like the \pkg{footmisc} package.
4403 % Now we might end up getting a wrong footnote marker, but this code has to
4404 % be sufficient for the single-line-check.))
4405 % \begin{macrocode}
4406 \newcommand*\caption@footnote{%
4407 \kernel@ifnextchar[%]
4408 \@xfootnote
4409 {\caption@l@stepcounter\@mpfn
4410 \protected@xdef\@thefnmark{\thempfn}%
4411 \@footnotemark\@footnotetext}}
4412 % \end{macrocode}
4413 % \end{macro}
4414 %
4415 % \begin{macro}{\caption@footnotemark}
4416 % \changes{v1.3}{2011/07/07}{This macro added}
4417 % \changes{v2.3}{2021/07/03}{This macro re-written}
4418 % \changes{v2.4}{2022/04/18}{\cs{@ifnextchar} replaced by \cs{kernel@ifnextchar}}
4419 % The following code was taken from |base/ltfloat.dtx| but |\step|\-|counter|
4420 % is replaced by |\caption@l@step|\-|counter| so the footnote counter will
4421 % only be incremented temporarily for the single-line-check.
4422 % \begin{macrocode}
4423 \newcommand*\caption@footnotemark{%
4424 \kernel@ifnextchar[%]
4425 \@xfootnotemark
4426 {\caption@l@stepcounter{footnote}%
4427 \protected@xdef\@thefnmark{\thefootnote}%
4428 \@footnotemark}}
4429 % \end{macrocode}
4430 % \end{macro}
4431 %
4432 % \begin{macro}{\caption@footnotetext}
4433 % \changes{v2.3}{2021/07/03}{This macro added}
4434 % \changes{v2.4}{2022/04/18}{\cs{@ifnextchar} replaced by \cs{kernel@ifnextchar}}
4435 % The following code was taken from |base/ltfloat.dtx|.
4436 % \begin{macrocode}
4437 \newcommand*\caption@footnotetext{%
4438 \kernel@ifnextchar[%]
4439 \@xfootnotenext
4440 {\protected@xdef\@thefnmark{\thempfn}%
4441 \@footnotetext}}
4442 % \end{macrocode}
4443 % \end{macro}
4444 %
4445 % \begin{macro}{\caption@endnote}
4446 % \changes{v1.8}{2018/01/21}{This macro added}
4447 % \changes{v2.3}{2021/07/03}{This macro re-written}
4448 % \changes{v2.4}{2022/04/18}{\cs{@ifnextchar} replaced by \cs{kernel@ifnextchar}}
4449 % The following code was taken from |endnotes/endnotes.sty| but |\step|\-|counter|
4450 % is replaced by |\caption@l@step|\-|counter| so the footnote counter will
4451 % only be incremented temporarily for the single-line-check.
4452 % (In the past we had re-used the original code but with re-defined
4453 % |\step|\-|counter|.)
4454 % \begin{macrocode}
4455 \newcommand*\caption@endnote{%
4456 \kernel@ifnextchar[%]
4457 \@xendnote
4458 {\caption@l@stepcounter{endnote}%
4459 \protected@xdef\@theenmark{\theendnote}%
4460 \@endnotemark\@endnotetext}}
4461 % \end{macrocode}
4462 % \end{macro}
4463 %
4464 % \begin{macro}{\caption@endnotemark}
4465 % \changes{v1.8}{2018/01/21}{This macro added}
4466 % \changes{v2.3}{2021/07/03}{This macro re-written}
4467 % \changes{v2.4}{2022/04/18}{\cs{@ifnextchar} replaced by \cs{kernel@ifnextchar}}
4468 % The following code was taken from |endnotes/endnotes.sty| but |\step|\-|counter|
4469 % is replaced by |\caption@l@step|\-|counter| so the footnote counter will
4470 % only be incremented temporarily for the single-line-check.
4471 % \begin{macrocode}
4472 \newcommand*\caption@endnotemark{%
4473 \kernel@ifnextchar[%]
4474 \@xendnotemark
4475 {\caption@l@stepcounter{endnote}%
4476 \protected@xdef\@theenmark{\theendnote}%
4477 \@endnotemark}}
4478 % \end{macrocode}
4479 % \end{macro}
4480 %
4481 % \begin{macro}{\caption@endnotetext}
4482 % \changes{v2.3}{2021/07/03}{This macro added}
4483 % \changes{v2.4}{2022/04/18}{\cs{@ifnextchar} replaced by \cs{kernel@ifnextchar}}
4484 % The following code was taken from |endnotes/endnotes.sty|.
4485 % \begin{macrocode}
4486 \newcommand*\caption@endnotetext{%
4487 \kernel@ifnextchar[%]
4488 \@xendnotenext
4489 {\protected@xdef\@theenmark{\theendnote}%
4490 \@endnotetext}}
4491 % \end{macrocode}
4492 % \end{macro}
4493 %
4494 % \begin{macro}{\caption@l@stepcounter}
4495 % \changes{v1.3}{2011/07/07}{This macro added}
4496 % \begin{macrocode}
4497 \newcommand*\caption@l@stepcounter[1]{%
4498 \advance\csname c@#1\endcsname\@ne\relax}
4499 % \end{macrocode}
4500 % \end{macro}
4501 %
4502 % \begin{macro}{\caption@applyfont}
4503 % \changes{v1.3}{2010/09/04}{This macro added}
4504 % |\caption@applyfont|\\
4505 % applies the relevant font settings, i.e. by default
4506 % the options set by |justification=|, |font=|, and |size=|.
4507 % \begin{macrocode}
4508 \newcommand*\caption@applyfont{%
4509 \caption@justification\captionfont\captionsize}
4510 % \end{macrocode}
4511 % \end{macro}
4512 %
4513 % \begin{macro}{\caption@@@make}
4514 % \changes{v1.0b}{2004/05/16}{Bugfix 04-05-06: \cs{allowhyphens} added}
4515 % \changes{v1.0c}{2005/02/12}{Bugfix 04-12-16: Use some kind of \cs{@startstrut}\cs{strutbox} instead of \cs{strut}}
4516 % \changes{v1.0c}{2005/02/12}{Bugfix 05-01-23: \cs{@finalstrut}\cs{strutbox} added}
4517 % \changes{v1.0d}{2005/05/05}{Use \cs{caption@ifempty}; \cs{let}\cs{caption@ifstrut}\cs{@secondoftwo} added}
4518 % \changes{v1.0d}{2005/05/05}{Bugfix: Handling of \cs{ifcaption@star} changed}
4519 % \changes{v1.0f}{2005/08/24}{Check for empty label added}
4520 % \changes{v1.0f}{2005/08/25}{\cs{caption@iflf} added}
4521 % \changes{v1.0j}{2007/02/18}{Usage of \cs{caption@textformat} added}
4522 % \changes{v1.1}{2007/05/07}{Bugfix: \cs{ifhmode} added to \cs{@finalstrut}}
4523 % \changes{v1.2}{2007/11/17}{Made option \opt{size=} stronger than \opt{font=}}
4524 % \changes{v1.3}{2010/09/04}{Uses \cs{caption@applyfont} now}
4525 % \changes{v1.3}{2010/11/01}{Bugfix: If the caption text is empty, the text format will be set to \opt{simple} now}
4526 % \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}}
4527 % \changes{v1.8}{2018/09/12}{\cs{par} replaced by \cs{caption@textend}}
4528 % \changes{v2.2c}{2020/10/10}{Usage of the label separators \opt{gobble} and \opt{gobbletwo} added}
4529 % \changes{v2.2e}{2020/10/21}{Adaptions to \pkg{floatrow} package added}
4530 % |\caption@@@make|\marg{caption label}\marg{caption text}\\
4531 % This one finally typesets the caption paragraph, without margin and indention.
4532 % \begin{macrocode}
4533 \newcommand\caption@@@make[2]{%
4534 % \end{macrocode}
4535 % The \pkg{floatrow} package uses |\caption@@@make|, too,
4536 % but without using |\caption@single|\-|line| or |\caption@multi|\-|line|.
4537 % For this reason we must expand |\caption@format| if |\caption@fmt| isn't defined yet.
4538 % Furthermore it uses |\caption@lfmt| as argument which was renamed to
4539 % |\caption@label|\-|format| in \pkg{caption3}\version{2.0}.
4540 % \begin{macrocode}
4541 \ifx\caption@fmt\@undefined\caption@format\fi
4542 \let\caption@lfmt\caption@labelformat
4543 % \end{macrocode}
4544 % If the label is empty, we use the label separator `none'.
4545 % Futhermore we use this check to determine if |#1| ends with either
4546 % |\@gobble|, |\@gobble|\-|two|, and/or |\ignore|\-|spaces|.
4547 % If yes, we use the corresponding label separator.
4548 % \begin{macrocode}
4549 \global\def\caption@tempa{gobbletwo}%
4550 \global\def\caption@tempb{}%
4551 \sbox\@tempboxa{%
4552 \let\caption@ignorespaces\ignorespaces
4553 \def\ignorespaces{%
4554 \global\def\caption@tempb{two}% "gobble" -> "gobbletwo" if \ignorespaces is used addtionally
4555 \caption@ignorespaces}%
4556 #1%
4557 {\global\let\caption@tempa\@undefined\aftergroup\@gobble}%
4558 {\global\def\caption@tempa{gobble\caption@tempb}}}%
4559 \ifdim\wd\@tempboxa=\z@
4560 \gdef\caption@tempa{none}%
4561 % \@capbreakfalse
4562 \fi
4563 \ifx\caption@tempa\@undefined \else
4564 \@expandtwoargs\caption@set{labelseparator}{\caption@tempa}%
4565 \fi
4566 % \end{macrocode}
4567 % If the text is empty, we use no caption label separator, too.
4568 % (And no text format either.)
4569 % \begin{macrocode}
4570 \caption@ifempty{#2}{%
4571 \caption@set{labelseparator}{none}%
4572 \caption@set{textformat}{simple}%
4573 % \@capbreakfalse
4574 % \let\caption@ifstrut\@secondoftwo
4575 }%
4576 % \end{macrocode}
4577 % \begin{macrocode}
4578 \caption@labelseparator % defines \caption@iflabelfont, \caption@labelsep and \caption@labelsep@name (the latter is needed by \caption@fmt)
4579 % \end{macrocode}
4580 % Take care that |\caption@par|\-|indent| and |\caption@hang|\-|indent|
4581 % will be used to typeset the paragraph.
4582 % \begin{macrocode}
4583 \@setpar{\@@par\caption@@par}\caption@@par
4584 % \end{macrocode}
4585 % Finally typeset the caption.
4586 % \begin{macrocode}
4587 \caption@applyfont
4588 \caption@fmt
4589 {\ifcaption@star\else
4590 \begingroup
4591 \captionlabelfont
4592 #1\relax\relax
4593 \endgroup
4594 \fi}%
4595 {\ifcaption@star\else
4596 \begingroup
4597 \caption@iflabelfont\captionlabelfont
4598 \relax\caption@labelsep
4599 \endgroup
4600 \fi}%
4601 {{\captiontextfont
4602 \caption@textstart
4603 \caption@ifstrut
4604 {\vrule\@height\ht\strutbox\@width\z@}%
4605 {}%
4606 \nobreak\hskip\z@skip % enable hyphenation
4607 \caption@textformat{#2}%
4608 % \caption@ifstrut{\vrule\@height\z@\@depth\dp\strutbox\@width\z@}{}%
4609 \caption@ifstrut
4610 {\ifhmode\@finalstrut\strutbox\fi}%
4611 {}%
4612 \caption@textend}}}
4613 % \end{macrocode}
4614 % \begin{macrocode}
4615 \newcommand*\caption@textstart{}
4616 \newcommand*\caption@textend{\par}
4617 % \end{macrocode}
4618 % \end{macro}
4619 %
4620 % \begin{macro}{\caption@ifempty}
4621 % \changes{v1.0d}{2005/05/05}{This macro added}
4622 % \changes{v1.1}{2007/07/04}{Re-defines itself now}
4623 % \changes{v1.2a}{2007/01/22}{Revised so \cs{label} will be detected, too}
4624 % \changes{v1.2b}{2008/08/02}{Revised so \cs{index} and \cs{glossary} will be detected, too}
4625 % |\caption@ifempty|\marg{text}\marg{yes-code}\\
4626 % tests if the \meta{text} is actually empty.
4627 % \Note{This will be done without expanding the text,
4628 % therefore this is far away from being bullet-proof.}
4629 % \Note{This macro is re-defining itself so only
4630 % the first test (in a group) will actually be done.}
4631 % \begin{macrocode}
4632 \newcommand\caption@ifempty[1]{%
4633 \caption@if@empty{#1}%
4634 \caption@ifempty\@unused}
4635 % \end{macrocode}
4636 % \begin{macrocode}
4637 \newcommand\caption@if@empty[1]{%
4638 \def\caption@tempa{#1}%
4639 \ifx\caption@tempa\@empty
4640 \let\caption@ifempty\@secondoftwo
4641 \else
4642 \expandafter\def\expandafter\caption@tempa\expandafter{%
4643 \caption@car#1\caption@if@empty\caption@nil}%
4644 \def\caption@tempb{\caption@if@empty}%
4645 \ifx\caption@tempa\caption@tempb
4646 \let\caption@ifempty\@secondoftwo
4647 \else
4648 \def\caption@tempb{\ignorespaces}%
4649 \ifx\caption@tempa\caption@tempb
4650 \expandafter\caption@if@empty\expandafter{\@gobble#1}%
4651 \else
4652 \def\caption@tempb{\label}%
4653 \ifx\caption@tempa\caption@tempb
4654 \expandafter\caption@if@empty\expandafter{\@gobbletwo#1}%
4655 \else
4656 \def\caption@tempb{\index}%
4657 \ifx\caption@tempa\caption@tempb
4658 \expandafter\caption@if@empty\expandafter{\@gobbletwo#1}%
4659 \else
4660 \def\caption@tempb{\glossary}%
4661 \ifx\caption@tempa\caption@tempb
4662 \expandafter\caption@if@empty\expandafter{\@gobbletwo#1}%
4663 \else
4664 \let\caption@ifempty\@gobbletwo
4665 \fi
4666 \fi
4667 \fi
4668 \fi
4669 \fi
4670 \fi}
4671 % \end{macrocode}
4672 % \begin{macrocode}
4673 \long\def\caption@car#1#2\caption@nil{#1}% same as \@car, but \long
4674 % \end{macrocode}
4675 % \end{macro}
4676 %
4677 % \begin{macro}{\caption@@par}
4678 % \changes{v1.0f}{2005/08/22}{Made this definition global}
4679 % |\caption@@par|\\
4680 % will be expanded with every |\par| inside the caption.
4681 % \begin{macrocode}
4682 \newcommand*\caption@@par{%
4683 \parindent\caption@parindent\hangindent\caption@hangindent}%
4684 % \end{macrocode}
4685 % \end{macro}
4686 %
4687 % \section{Types \& sub-types}
4688 %
4689 % \begin{macro}{\DeclareCaptionType}
4690 % \changes{v1.1}{2007/08/12}{This macro added}
4691 % \changes{v1.1a}{2007/09/07}{Three optional arguments added}
4692 % \changes{v1.2}{2007/12/06}{Renamed from \cs{DeclareFloatingEnvironment} to \cs{DeclareCaptionType}}
4693 % \changes{v1.2}{2007/12/21}{Optional argument revised, uses key-value syntax now}
4694 % \changes{v1.2b}{2008/04/13}{Uses \cs{caption@within@default} now}
4695 % \changes{v1.2b}{2008/08/02}{Support of \cs{float@exts} and \cs{float@addtolists} added}
4696 % \changes{v1.2e}{2010/01/09}{Usage of \cs{caption@DeclareWithinOption} added}
4697 % \changes{v1.3}{2011/08/06}{Definition of \cs{listofXXXes} added}
4698 % \changes{v1.4a}{2011/10/29}{Outsourced to \pkg{newfloat} package}
4699 % |\DeclareCaptionType|\oarg{options}\marg{environment}\oarg{name}\oarg{list name}\\
4700 % loads the \pkg{newfloat} package and uses |\Declare|\-|Floating|\-|Environment|.
4701 % \begin{macrocode}
4702 \newcommand*\DeclareCaptionType{%
4703 \caption@loadpackage{newfloat}{declare type}%
4704 \DeclareFloatingEnvironment}
4705 \@onlypreamble\DeclareCaptionType
4706 % \end{macrocode}
4707 % \end{macro}
4708 %
4709 % \begin{macro}{\ForEachCaptionType}
4710 % \changes{v1.4a}{2011/10/29}{This macro added}
4711 % \changes{v1.13}{2020/07/29}{Renamed from \cs{caption@ForEachType} to \cs{ForEachCaptionType} and starred variant added}
4712 % |\ForEachCaptionType*|\marg{code with \#1}\\
4713 % will execute the given code for each (known) floating environment.
4714 % The starred variant will only work for already existing environments,
4715 % i.e.~no hook will be placed inside |\Declare|\-|Floating|\-|Environment|
4716 % (offered by the \pkg{newfloat} package).
4717 % \begin{macrocode}
4718 \newcommand*\ForEachCaptionType{%
4719 \@ifstar
4720 {\caption@foreach@type\@gobble}%
4721 {\caption@foreach@type\@iden}}
4722 % \end{macrocode}
4723 % \begin{macrocode}
4724 \newcommand\caption@foreach@type[2]{%
4725 \caption@ifdefined\ForEachFloatingEnvironment
4726 {\ForEachFloatingEnvironment*{#2}}%
4727 {\def\@elt##1{#2}%
4728 \caption@ifdefined\c@figure\@elt\@gobble{figure}%
4729 \caption@ifdefined\c@table\@elt\@gobble{table}%
4730 \let\@elt\relax}%
4731 #1{\newfloat@addtohook{#2}}}
4732 % \end{macrocode}
4733 % \end{macro}
4734 %
4735 % \begin{macro}{\newfloat@addtohook}
4736 % |\newfloat@addtohook|\marg{code with \#1}\\
4737 % adds code to the hook called in |\Declare|\-|Floating|\-|Environment|.\par
4738 % Note: We use |\provide|\-|command| instead of |\new|\-|command| here since the
4739 % exact same code is defined in the \pkg{newfloat} package.
4740 % \begin{macrocode}
4741 \providecommand\newfloat@addtohook[1]{%
4742 \toks@=\expandafter{\newfloat@hook{##1}#1}%
4743 \edef\@tempa{\def\noexpand\newfloat@hook####1{\the\toks@}}%
4744 \@tempa}
4745 % \end{macrocode}
4746 % \end{macro}
4747 %
4748 % \begin{macro}{\newfloat@hook}
4749 % Hook used in |\Declare|\-|Floating|\-|Environment|.
4750 % \begin{macrocode}
4751 \providecommand*\newfloat@hook[1]{}
4752 % \end{macrocode}
4753 % \end{macro}
4754 %
4755 % \begin{macro}{\DeclareCaptionSubType}
4756 % \changes{v1.2}{2007/11/16}{This macro added}
4757 % \changes{v1.2a}{2008/03/11}{Bugfix: \cs{subfigurename} will be defined now}
4758 % \changes{v1.2d}{2009/10/09}{Bugfix 08-10-01: Usage of \cs{caption@addtoreset} added}
4759 % \changes{v1.3}{2011/01/01}{\cs{@dottedlofline} will be defined \& used now}
4760 % \changes{v1.4}{2011/10/09}{Support of the titletoc package added}
4761 % \changes{v1.5}{2011/12/29}{Usage of \cs{caption@addtoreset} replaced by \cs{@addtoreset}}
4762 % \changes{v1.5}{2013/01/10}{Bugfix: Definition of autoref string corrected}
4763 % \changes{v1.6}{2013/06/17}{Bugfix: \cs{c@tocdepth} will be set (locally) now}
4764 % \changes{v1.8g}{2020/01/02}{Check revised if the sub-type is already defined or not}
4765 % \changes{v1.13}{2020/07/28}{Uses \cs{caption@l@addto@list} instead of \cs{@cons} now}
4766 % \changes{v1.13}{2020/07/29}{Usage of \cs{caption@subtype@hook} added}
4767 % \changes{v1.13}{2020/07/29}{We don't re-use existing counters anymore (This was a bad idea anyway)}
4768 % \changes{v1.13b}{2022/04/06}{We don't re-use existing counters anymore (Part 2)}
4769 % \changes{v2.4}{2022/04/06}{If a counter is already defined the counter source will be included in the resulting error message}
4770 % \changes{v2.4d}{2023/07/31}{Check for \cs{@empty} argument replaced by \cs{caption@iftokens}}
4771 % |\DeclareCaptionSubType*|\oarg{numbering scheme}\marg{type}\\
4772 % The starred variant provides the numbering format
4773 % \meta{type}|.|\meta{subtype} while the non-starred variant simply uses
4774 % \meta{subtype}.
4775 % \begin{macrocode}
4776 \newcommand*\DeclareCaptionSubType{%
4777 \caption@teststar\caption@declaresubtype\@firstoftwo\@secondoftwo}
4778 \@onlypreamble\DeclareCaptionSubType
4779 % \end{macrocode}
4780 % \begin{macrocode}
4781 \newcommand*\caption@declaresubtype[1]{%
4782 \@testopt{\caption@@declaresubtype#1}{alph}}
4783 \@onlypreamble\caption@declaresubtype
4784 % \end{macrocode}
4785 % \begin{macrocode}
4786 \def\caption@@declaresubtype#1[#2]#3{%
4787 \@ifundefined{c@#3}%
4788 {\caption@Error{No float type '#3' defined}}%
4789 {\caption@@@declaresubtype{#1}{#2}{#3}{sub#3}}}
4790 \@onlypreamble\caption@@declaresubtype
4791 % \end{macrocode}
4792 % \begin{macrocode}
4793 \newcommand*\caption@@@declaresubtype[4]{%
4794 % \end{macrocode}
4795 % \begin{macrocode}
4796 % Check if the sub-type was already defined by |\Declare|\-|Sub|\-|Type|.
4797 % If not, define the counter and list entry.
4798 % \begin{macrocode}
4799 \caption@ifdefined@subtype{#4}%
4800 {\caption@Info{Modify subtype `#4'}}%
4801 {\caption@Info{New subtype `#4'}%
4802 \@ifundefined{c@#4}%
4803 {\newcounter{#4}[#3]%
4804 \@namedef{#4name}{}%
4805 \@namedef{#4autorefname}{\csname #3autorefname\endcsname}%
4806 % \end{macrocode}
4807 % \begin{macrocode}
4808 \@namedef{ext@#4}{\csname ext@#3\endcsname}%
4809 \caption@declaresublistentry{#3}%
4810 % \end{macrocode}
4811 % Support of \pkg{titletoc} package
4812 % \begin{macrocode}
4813 \caption@ifdefined\contentsuse{%
4814 \contentsuse{#4}{\csname ext@#4\endcsname}}{}%
4815 % \end{macrocode}
4816 % \begin{macrocode}
4817 \caption@l@addto@list\caption@subtypelist{#4}%
4818 \caption@subtype@hook{#4}}%
4819 % \end{macrocode}
4820 % \begin{macrocode}
4821 {\caption@subtypesource\caption@subtype@source{#4}%
4822 \caption@Error{The counter `#4' was already defined by\MessageBreak\caption@subtype@source}}}%
4823 % \end{macrocode}
4824 % \begin{macrocode}
4825 #1% is \@firstoftwo in star form, and \@secondoftwo otherwise
4826 {\@namedef{p@#4}{}%
4827 \@namedef{the#4}{\csname the#3\endcsname.\@nameuse{#2}{#4}}}%
4828 {\@namedef{p@#4}{\csname the#3\endcsname}%
4829 \@namedef{the#4}{\@nameuse{#2}{#4}}}%
4830 \@namedef{theH#4}{\csname theH#3\endcsname.\arabic{#4}}}
4831 % \end{macrocode}
4832 % \begin{macrocode}
4833 \@onlypreamble\caption@@@declaresubtype
4834 % \end{macrocode}
4835 % \begin{macrocode}
4836 \newcommand*\caption@declaresublistentry{%
4837 \caption@ifdefined\l@chapter
4838 {\caption@@declaresublistentry\l@subsection}%
4839 {\caption@@declaresublistentry\l@subsubsection}}
4840 \@onlypreamble\caption@declaresublistentry
4841 % \end{macrocode}
4842 % \begin{macrocode}
4843 \newcommand*\caption@@declaresublistentry[2]{%
4844 \ifx#1\@undefined
4845 \caption@@@declaresublistentry\relax\@dottedtocline\caption@nil{#2}%
4846 \else
4847 \expandafter\caption@@@declaresublistentry#1{}{}\@dottedtocline\caption@nil{#2}%
4848 \fi}
4849 \@onlypreamble\caption@@declaresublistentry
4850 % \end{macrocode}
4851 % \begin{macrocode}
4852 \long\def\caption@@@declaresublistentry#1\@dottedtocline#2\caption@nil#3{%
4853 % Does \l@(sub)subsection start with \@dottedtocline?
4854 \caption@iftokens{#1}%
4855 % No
4856 {\caption@@@@declaresublistentry{#3}@{3.8em}{3.2em}\caption@nil}%
4857 % Yes
4858 {\caption@@@@declaresublistentry{#3}#2\caption@nil}}
4859 \@onlypreamble\caption@@@declaresublistentry
4860 % \end{macrocode}
4861 % \begin{macrocode}
4862 \def\caption@@@@declaresublistentry#1#2#3#4#5\caption@nil{%
4863 \expandafter\caption@@@@@declaresublistentry\expandafter
4864 {\csname @dotted\csname ext@#1\endcsname line\endcsname}{#1}{#3}{#4}}
4865 \@onlypreamble\caption@@@@declaresublistentry
4866 % \end{macrocode}
4867 % \begin{macrocode}
4868 \newcommand*\caption@@@@@declaresublistentry[4]{%
4869 \@namedef{l@sub#2}{#1{2}{#3}{#4}}%
4870 \expandafter\caption@@@@@@declaresublistentry
4871 \expandafter#1\expandafter{\csname ext@#2\endcsname depth}}
4872 \@onlypreamble\caption@@@@@declaresublistentry
4873 % \end{macrocode}
4874 % \begin{macrocode}
4875 \newcommand*\caption@@@@@@declaresublistentry[2]{
4876 \ifx#1\relax
4877 \def#1##1{%
4878 \def\next{\@dottedtocline{##1}}%
4879 \@ifundefined{c@#2}{}{%
4880 \ifnum ##1>\@nameuse{c@#2}\relax
4881 \let\next\@gobblefour
4882 \else
4883 \c@tocdepth=\@nameuse{c@#2}\relax
4884 \fi}%
4885 \next}%
4886 \fi}
4887 \@onlypreamble\caption@@@@@@declaresublistentry
4888 % \end{macrocode}
4889 % \end{macro}
4890 %
4891 % \begin{macro}{\caption@subtypelist}
4892 % A list containing the sub-types defined with
4893 % |\Declare|\-|Caption|\-|Sub|\-|Type|.
4894 % \begin{macrocode}
4895 \newcommand*\caption@subtypelist{}
4896 % \end{macrocode}
4897 % \end{macro}
4898 %
4899 % \begin{macro}{\caption@ifdefined@subtype}
4900 % \changes{v1.8g}{2020/01/02}{This macro definition added}
4901 % \changes{v1.13}{2020/07/28}{Uses \cs{caption@ifin@list} now}
4902 % \changes{v2.3}{2022/01/07}{Renamed from \cs{caption@ifsubtype} to \cs{caption@ifdefined@subtype}}
4903 % |\caption@ifdefined@subtype|\marg{subtype}\marg{yes-code}\marg{no-code}\\
4904 % checks if the given subtype was defined with |\Declare|\-|Caption|\-|Sub|\-|Type|.
4905 % \begin{macrocode}
4906 \newcommand*\caption@ifdefined@subtype{%
4907 \caption@ifin@list\caption@subtypelist}
4908 % \end{macrocode}
4909 % \end{macro}
4910 %
4911 % \begin{macro}{\caption@subtypesource}
4912 % \changes{v2.4}{2022/04/06}{This macro definition added}
4913 % |\caption@subtypesource|\marg{cmd}\marg{sub-type}\\
4914 % is used by |\Declare|\-|Caption|\-|Sub|\-|Type| to indicate what command and package
4915 % has defined the given sub-type.
4916 % \begin{macrocode}
4917 \newcommand*\caption@subtypesource[2]{%
4918 \caption@ifdefined@subtype{#2}%
4919 {\def#1{\noexpand\DeclareCaptionSubType (offered by the caption package)}}%
4920 {\caption@ifin@list\sf@counterlist{#2}%
4921 {\def#1{\noexpand\newsubfloat (offered by the subfig package)}}%
4922 {\def#1{an unknown document class or package}}}}
4923 % \end{macrocode}
4924 % \end{macro}
4925 %
4926 % \begin{macro}{\ForEachCaptionSubType}
4927 % \changes{v1.13}{2020/07/29}{This macro added as replacement for \cs{caption@For}}
4928 % |\ForEachCaptionSubType*|\marg{code with \#1}\\
4929 % will execute the given code for each (known) sub-type.
4930 % The starred variant will only work for already existing sub-types,
4931 % i.e.~no hook will be placed inside |\Declare|\-|Caption|\-|Sub|\-|Type|.
4932 % \begin{macrocode}
4933 \newcommand*\ForEachCaptionSubType{%
4934 \@ifstar
4935 {\caption@foreach@subtype\@gobble}%
4936 {\caption@foreach@subtype\@iden}}
4937 % \end{macrocode}
4938 % \begin{macrocode}
4939 \newcommand\caption@foreach@subtype[2]{%
4940 \caption@for@list\caption@subtypelist{#2}%
4941 #1{\caption@addto@subtype@hook{#2}}}
4942 % \end{macrocode}
4943 % \begin{macrocode}
4944 \providecommand\caption@addto@subtype@hook[1]{%
4945 \toks@=\expandafter{\caption@subtype@hook{##1}#1}%
4946 \edef\@tempa{\def\noexpand\caption@subtype@hook####1{\the\toks@}}%
4947 \@tempa}
4948 % \end{macrocode}
4949 % \begin{macrocode}
4950 \providecommand*\caption@subtype@hook[1]{}
4951 % \end{macrocode}
4952 % \end{macro}
4953 %
4954 % \begin{macro}{\@memresetsubcounter}
4955 % \changes{v1.5}{2013/05/01}{The macro \cs{caption@savesubcounters} added}
4956 % \changes{v1.13}{2020/07/28}{Uses \cs{caption@for@list} now for iterating the list}
4957 % \changes{v2.2b}{2020/10/06}{This stuff replaced by a patch of \cs{@memresetsubcounter}}
4958 % The \cls{memoir} document class resets the \texttt{subfigure}
4959 % or \texttt{subtable} counter at the begin of floating environments using
4960 % |\@mem|\-|reset|\-|sub|\-|counter|.
4961 % As a side-effect |\continued|\-|float| does not work correctly.
4962 % For that reason we need to patch |\@mem|\-|reset|\-|sub|\-|counter| here,
4963 % suppressing the counter reset if the counter was defined with
4964 % |\Declare|\-|Caption|\-|Sub|\-|Type|.
4965 % \begin{macrocode}
4966 \caption@ifdefined\@memresetsubcounter
4967 {\let\caption@memresetsubcounter\@memresetsubcounter
4968 \renewcommand*\@memresetsubcounter[1]{%
4969 \caption@ifdefined@subtype{sub#1}\@gobble\caption@memresetsubcounter{#1}}}%
4970 {}
4971 % \end{macrocode}
4972 % \end{macro}
4973 %
4974 % \section{Execution of options}
4975 %
4976 % \begin{macrocode}
4977 \caption@ifdocumentclass{unknown}{}{%
4978 \caption@ifdocumentclass{standard}{}{%
4979 \@pushfilename
4980 \edef\@currname{caption-\caption@documentclass}
4981 \edef\@currext{sto}
4982 \InputIfFileExists
4983 {\@currname.\@currext}%
4984 {}%
4985 {\@missingfileerror\@currname\@currext}%
4986 \@popfilename}}
4987 % \end{macrocode}
4988 %
4989 % \begin{macrocode}
4990 \captionsetup{style=default,position=default,listformat=default}
4991 % \end{macrocode}
4992 % \begin{macrocode}
4993 \ProcessOptions*
4994 % \end{macrocode}
4995 %
4996 % \iffalse
4997 %</package>
4998 % \fi
4999 %
5000 % \clearpage
5001 % \begin{thebibliography}{99}
5002 % \bibitem{TLC2}
5003 % Frank Mittelbach and Michel Goossens:\\
5004 % \newblock {\em The {\LaTeX} Companion (2nd.~Ed.)},\\
5005 % \newblock Addison-Wesley, 2004.
5006 %
5007 % \bibitem{Anne}
5008 % Anne Br\"uggemann-Klein:\\
5009 % \emph{Einf\"uhrung in die Dokumentverarbeitung},\\
5010 % B.G. Teubner, Stuttgart, 1989
5011 %
5012 % \bibitem{hyperref}
5013 % Sebastian Rahtz \& Heiko Oberdiek:\\
5014 % \href{http://www.ctan.org/pkg/hyperref}%
5015 % {\emph{Hypertext marks in \LaTeX}},\\
5016 % November 12, 2007
5017 %
5018 % \bibitem{refcount}
5019 % Heiko Oberdiek:\\
5020 % \href{http://www.ctan.org/pkg/refcount}%
5021 % {\emph{The refcount package}},\\
5022 % 2006/02/20
5023 %
5024 % \bibitem{threeparttable}
5025 % Donald Arseneau:\\
5026 % \href{http://www.ctan.org/pkg/threeparttable}%
5027 % {\emph{Three part tables: title, tabular environment, notes}},\\
5028 % 2003/06/13
5029 % \end{thebibliography}
5030 %
5031 % \iffalse
5032 % --------------------------------------------------------------------------- %
5033 % \fi
5034 %
5035 % \clearpage
5036 % \Finale
5037 %
5038 \endinput