Debian Codegraph @

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