Debian Codegraph @

texmf-dist/source/latex/caption/fallback/v3.5/caption3.dtx

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