Debian Codegraph @

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

raw
1 % \iffalse meta-comment
2 %
3 % This is file `caption.dtx'.
4 %
5 % Copyright (C) 1994-2023 Axel Sommerfeldt ([email protected])
6 %
7 % --------------------------------------------------------------------------
8 %
9 % This work may be distributed and/or modified under the
10 % conditions of the LaTeX Project Public License, either version 1.3
11 % of this license or (at your option) any later version.
12 % The latest version of this license is in
13 % http://www.latex-project.org/lppl.txt
14 % and version 1.3 or later is part of all distributions of LaTeX
15 % version 2003/12/01 or later.
16 %
17 % This work has the LPPL maintenance status "maintained".
18 %
19 % This Current Maintainer of this work is Axel Sommerfeldt.
20 %
21 % This work consists of the files
22 % caption.ins, caption.dtx, caption-light.dtx, caption2.dtx, caption3.dtx,
23 % caption-ams-smf.dtx, caption-beamer.dtx, caption-elsarticle.dtx,
24 % caption-koma.dtx, caption-memoir.dtx, caption-ntg.dtx,
25 % caption-thesis.dtx, bicaption.dtx, ltcaption.dtx, subcaption.dtx,
26 % the derived files
27 % caption.sty, caption-light.sty, caption2.sty, caption3.sty,
28 % caption-ams-smf.sto, caption-beamer.sto, caption-elsarticle.sto,
29 % caption-koma.sto, caption-memoir.sto, caption-ntg.sto,
30 % caption-thesis.sto, bicaption.sty, ltcaption.sty, subcaption.sty,
31 % and the user manuals
32 % caption-deu.tex, caption-eng.tex, caption-rus.tex.
33 %
34 % \fi
35 % \CheckSum{2705}
36 %
37 % \iffalse
38 %<*driver>
39 \NeedsTeXFormat{LaTeX2e}[1994/12/01]
40 \ProvidesFile{caption.drv}[2020/10/11 v3.5 Implementation of the caption package]
41 \hbadness=9999 \newcount\hbadness \hfuzz=100pt % Make TeX shut up.
42 %\errorcontextlines=3
43 %
44 \documentclass{ltxdoc}
45 \setlength\parindent{0pt}
46 \setlength\parskip{\smallskipamount}
47 %
48 \makeatletter % make room for subsections like 2.16.14 in the TOC
49 %\newcommand*\l@subsection{\@dottedtocline{2}{1.5em}{2.3em}}
50 \renewcommand*\l@subsection{\@dottedtocline{2}{1.5em}{2.7em}}
51 \makeatother
52 %
53 \usepackage{ifpdf}
54 \ifpdf
55 \usepackage{mathptmx,courier}
56 \usepackage[scaled=0.90]{helvet}
57 \addtolength\marginparwidth{15pt}
58 \fi
59 %
60 \usepackage{hypdoc}
61 \ifpdf\usepackage{hypdestopt}\fi
62 \hypersetup{pdfkeywords={LaTeX, package, caption},pdfstartpage={},pdfstartview={}}
63 %
64 \usepackage[debug]{caption}[2013/01/01]
65 %
66 \DeclareRobustCommand*\eTeX{\texorpdfstring
67 {\leavevmode\hbox{$\varepsilon$}-\TeX}%
68 {e-TeX}}
69 %
70 \begin{document}
71 \DocInput{caption.dtx}
72 \end{document}
73 %</driver>
74 % \fi
75 %
76 % \newcommand*\purerm[1]{\texorpdfstring{{\upshape\mdseries\rmfamily #1}}{#1}}
77 % \newcommand*\puresf[1]{\texorpdfstring{{\upshape\mdseries\sffamily #1}}{#1}}
78 % \newcommand*\purett[1]{\texorpdfstring{{\upshape\mdseries\ttfamily #1}}{#1}}
79 % \let\class\puresf \let\package\puresf
80 % \let\env\purett \let\opt\purett
81 %
82 % \def\thispackage{the \package{caption} package}
83 % \def\Thispackage{The \package{caption} package}
84 %
85 % \newcommand*\csmarg[1]{\texttt{\char`\{#1\char`\}}}
86 % \newcommand*\csoarg[1]{\texttt{\char`\[#1\char`\]}}
87 % \newcommand*\version[2][]{v$#2$}
88 %
89 % \newcommand*\issue[1]{GitLab~\##1}
90 %
91 % \GetFileInfo{caption.drv}
92 % \let\docdate\filedate
93 % \let\docversion\fileversion
94 % \GetFileInfo{caption.sty}
95 %
96 % \title{The Implementation of
97 % \texorpdfstring{\thispackage\thanks{%^^A
98 % This package has version number \docversion.}}%^^A
99 % {the caption package}}
100 % \author{Axel Sommerfeldt\\
101 % \url{https://gitlab.com/axelsommerfeldt/caption}}
102 % \date{\docdate}
103 % \maketitle
104 %
105 % \begin{abstract}
106 % \Thispackage\ consists of two parts -- the kernel
107 % (|caption3.sty|) and the main package (|caption.sty|).
108 %
109 % \Thispackage\ redefines the \LaTeX\ commands
110 % |\caption|, |\@caption|, and |\@makecaption| and maps the latter one to
111 % |\caption@@make|, giving the user the possibility to control the look \& feel
112 % of the captions from floating environments like |figure| and |table|.
113 % Furthermore it does similar to the caption stuff coming from other packages
114 % (like the \package{longtable} or \package{supertabular} package):
115 % Mapping the appropriate internal commands (like |\LT@makecaption| or
116 % |\ST@caption|) to the ones offered by the \package{caption3} kernel.
117 % So you can think of \thispackage\ as a layer package, it
118 % simply provides adaptation layers between the caption stuff coming from
119 % \LaTeXe\ or packages, and the caption stuff offered by the
120 % \package{caption3} kernel.
121 % \end{abstract}
122 %
123 % \section*{User manual}
124 %
125 % This document is describing the code implementation only.
126 % The user documentation can be found in
127 % \nopagebreak\begin{quote}
128 % \begin{tabular}{ll}
129 % \href{http://mirror.ctan.org/macros/latex/contrib/caption/caption-eng.pdf}%
130 % {\texttt{caption-eng.pdf}} & The English documentation \\
131 % \href{http://mirror.ctan.org/macros/latex/contrib/caption/caption-rus.pdf}%
132 % {\texttt{caption-rus.pdf}} & The Russian documentation\footnotemark \\
133 % \href{http://mirror.ctan.org/macros/latex/contrib/caption/caption-deu.pdf}%
134 % {\texttt{caption-deu.pdf}} & The German documentation \\
135 % \end{tabular}
136 % \footnotetext{Thanks a lot to Olga Lapko for this translation}
137 % \end{quote}
138 %
139 % \pagebreak[4]
140 % \section*{Internal commands}
141 %
142 % These internal commands are save to use by other packages as well
143 % since their interface will not change in future releases:
144 % \begin{quote}\begin{tabular}{ll}
145 % Internal command & Currently used by \\
146 % \hline
147 % |\caption@kernel@addcontentsline| & \package{floatrow} \\
148 % |\caption@makecaption| & \package{bidi} \\
149 % |\caption@settype| & \package{newfloat} \\
150 % |\caption@setsubtype| & \package{floatrow} \\
151 % |\caption@starfalse| & \package{bidi} \\
152 % |\caption@startrue| & \package{bidi} \\
153 % |\caption@xlabel| & \package{cleveref} \\
154 % \end{tabular}\end{quote}
155 %
156 % If your package wants to use any other internal command of the \package{caption} package,
157 % please write me an e-mail so we can define a proper interface together.
158 %
159 % The \package{lwarp} package uses a lot of internal commands as well,
160 % but we are working on it on the Git branch \texttt{feature/lwarp}:
161 % \url{https://gitlab.com/axelsommerfeldt/caption/-/tree/feature/lwarp}
162 %
163 % \StopEventually{}
164 % \clearpage
165 % \tableofcontents
166 %
167 % \iffalse
168 % --------------------------------------------------------------------------- %
169 % \fi
170 %
171 % \DoNotIndex{\\,\_,\ ,\@@par}
172 % \DoNotIndex{\@bsphack}
173 % \DoNotIndex{\@car,\@cdr,\@classoptionslist,\@cons,\@currext,\@currname}
174 % \DoNotIndex{\@ehc,\@ehd,\@empty,\@esphack,\@expandtwoargs}
175 % \DoNotIndex{\@for,\@firstofone,\@firstoftwo}
176 % \DoNotIndex{\@gobble,\@gobblefour,\@gobbletwo,\@hangfrom}
177 % \DoNotIndex{\if@minipage,\@ifnextchar,\@ifpackagelater,\@ifpackageloaded}
178 % \DoNotIndex{\@ifstar,\@ifundefined,\@latex@error,\@minipagefalse,\@minipagetrue}
179 % \DoNotIndex{\@namedef,\@nameuse}
180 % \DoNotIndex{\@onlypreamble,\@parboxrestore,\@plus,\@ptionlist}
181 % \DoNotIndex{\@removeelement,\@restorepar,\@secondoftwo,\@setminipage,\@setpar}
182 % \DoNotIndex{\@tempa,\@tempboxa,\@tempdima,\@tempdimb,\@tempdimc,\@tempb,\@tempc}
183 % \DoNotIndex{\@testopt}
184 % \DoNotIndex{\@undefined,\@unprocessedoptions,\@unusedoptionlist}
185 % \DoNotIndex{\p@,\z@}
186 % \DoNotIndex{\active,\addtocounter,\addtolength,\advance,\aftergroup}
187 % \DoNotIndex{\baselineskip,\begin,\begingroup,\bfseries,\box}
188 % \DoNotIndex{\catcode,\centering,\changes,\csname,\def,\divide,\do,\downarrow}
189 % \DoNotIndex{\edef,\else,\empty,\end,\endcsname,\endgraf,\endgroup,\expandafter}
190 % \DoNotIndex{\fi,\footnotesize,\global}
191 % \DoNotIndex{\hangindent,\hbox,\hfil,\hsize,\hskip,\hspace,\hss}
192 % \DoNotIndex{\ifcase,\ifdim,\ifnum,\ifodd,\ifvoid,\ifvmode}
193 % \DoNotIndex{\ifx,\ignorespaces,\itshape}
194 % \DoNotIndex{\Large,\large,\leavevmode,\leftmargini,\leftskip,\let,\linewidth}
195 % \DoNotIndex{\llap,\long,\m@ne,\margin,\mdseries,\message}
196 % \DoNotIndex{\newcommand,\newdimen,\newlength,\newline,\newif,\newsavebox}
197 % \DoNotIndex{\next,\nobreak,\nobreakspace,\noexpand,\noindent,\numberline}
198 % \DoNotIndex{\normalcolor,\normalfont,\normalsize,\or,\par,\parbox,\parfillskip}
199 % \DoNotIndex{\parindent,\parskip,\prevdepth,\protect,\protected@edef,\protected@write}
200 % \DoNotIndex{\providecommand,\quad}
201 % \DoNotIndex{\raggedleft,\raggedright,\relax,\renewcommand,\RequirePackage}
202 % \DoNotIndex{\rightskip,\rmfamily}
203 % \DoNotIndex{\sbox,\scriptsize,\scshape,\setbox,\setlength,\sffamily,\slshape}
204 % \DoNotIndex{\small,\string,\space,\strut}
205 % \DoNotIndex{\textheight,\the,\toks@,\typeout,\ttfamily}
206 % \DoNotIndex{\unvbox,\uparrow,\upshape,\usebox,\usepackage}
207 % \DoNotIndex{\value,\vbox,\vsize,\vskip,\wd,\width,\z@skip}
208 % \DoNotIndex{\AtBeginDocument,\AtEndOfPackage,\CurrentOption,\DeclareOption}
209 % \DoNotIndex{\ExecuteOptions,\GenericWarning,\IfFileExists,\InputIfFileExists}
210 % \DoNotIndex{\NeedsTeXFormat,\MessageBreak}
211 % \DoNotIndex{\PackageError,\PackageInfo,\PackageWarning,\PackageWarningNoLine}
212 % \DoNotIndex{\PassOptionsToPackage,\ProcessOptions,\ProvidesPackage}
213 %
214 % \iffalse
215 % --------------------------------------------------------------------------- %
216 % \fi
217 %
218 % \setlength{\parskip}{0pt plus 1pt}
219 % \newcommand*\Note[2][Note]{\par{\small\emph{#1:} #2}\par}
220 %
221 % \changes{v1.0}{1994/10/27}{First release}
222 % \changes{v1.1}{1994/11/03}{New option \texttt{centerlast}}
223 % \changes{v1.2}{1994/11/28}{Support of the \package{float} package}
224 % \changes{v1.3}{1995/01/09}{Support of \cs{captionlabelfont} in subcaptions}
225 % \changes{v1.4}{1995/01/30}{New option \texttt{nooneline}}
226 % \changes{v1.4b}{1995/04/05}{Bugfix release}
227 % \changes{v3.0}{2003/12/20}{Rewritten; many new commands and features}
228 % \changes{v3.0d}{2004/11/28}{Split into two packages: \package{caption} \& \package{caption3}}
229 %
230 % \iffalse
231 % --------------------------------------------------------------------------- %
232 % \fi
233 %
234 % \clearpage
235 %
236 % \iffalse
237 %<*package>
238 % \fi
239 %
240 % \section{Identification}
241 %
242 % \begin{macrocode}
243 \NeedsTeXFormat{LaTeX2e}[1994/12/01]
244 \ProvidesPackage{caption}[2023/08/05 v3.5j Customizing captions (AR)]
245 % \end{macrocode}
246 %
247 % \section{Loading the kernel}
248 %
249 % \begin{macrocode}
250 \RequirePackage{caption3}[=2020/10/06] % needs v2.2b or newer
251 % \end{macrocode}
252 %
253 % \section{Check against unknown document classes}
254 %
255 % \begin{macrocode}
256 \caption@ifbool{documentclass}{}{%
257 \caption@WarningNoLine{%
258 Unknown document class (or package),\MessageBreak
259 standard defaults will be used}}
260 % \end{macrocode}
261 %
262 % \section{Check against incompatible packages}
263 %
264 % \changes{v3.0p}{2007/04/06}{Check against obsolete \package{caption2} package added}
265 % \begin{macrocode}
266 \@ifpackageloaded{caption2}{%
267 \caption@Error{%
268 You can't use both, the (obsolete) caption2 *and*\MessageBreak
269 the (current) caption package}%
270 \endinput
271 }{}
272 % \end{macrocode}
273 %
274 % \changes{v3.1}{2007/06/15}{Check against incompatible \package{ftcap} package added}
275 % \changes{v3.1}{2007/06/15}{Check against incompatible \package{nonfloat} package added}
276 % \changes{v3.1}{2007/06/18}{Check against incompatible \package{topcapt} package added}
277 % \begin{macrocode}
278 \caption@AtBeginDocument{%
279 \@ifpackageloaded{ftcap}{\caption@DisablePositionOption{ftcap}}{}%
280 \@ifpackageloaded{nonfloat}{\caption@DisablePositionOption{nonfloat}}{}%
281 \@ifpackageloaded{topcapt}{\caption@DisablePositionOption{topcapt}}{}}
282 % \end{macrocode}
283 % \begin{macro}{\caption@DisablePositionOption}
284 % \changes{v3.1g}{2008/03/20}{\texttt{position=b} added}
285 % \changes{v3.1h}{2008/03/29}{%
286 % Name changed from \cs{caption@IncompatiblePackage} to \cs{caption@DisablePositionOption};
287 % disables the `position' option now instead of issuing a warning}
288 % |\caption@DisablePositionOption|\marg{package}\par
289 % disables the `position' option.
290 % \begin{macrocode}
291 \newcommand*\caption@DisablePositionOption[1]{%
292 \caption@InfoNoLine{%
293 `#1' package detected; setting `position=b' for compatibility reasons}%
294 \caption@setposition b%
295 % \end{macrocode}
296 % \begin{macrocode}
297 \DeclareCaptionOption{position}{%
298 \caption@Error{Usage of the `position' option is incompatible\MessageBreak
299 to the `#1' package}}}
300 % \end{macrocode}
301 % \begin{macrocode}
302 \@onlypreamble\caption@DisablePositionOption
303 % \end{macrocode}
304 % \end{macro}
305 %
306 % \section{Declaration of options}
307 %
308 % \subsection{Miscellaneous options}
309 %
310 % \begin{macrocode}
311 \DeclareCaptionOption*{config}[caption]{%
312 \InputIfFileExists{#1.cfg}%
313 {\typeout{*** Local configuration file #1.cfg used ***}}%
314 {\caption@Warning{Configuration file #1.cfg not found}}}
315 % \end{macrocode}
316 %
317 % \begin{macro}{\caption@selectlistentry}
318 % \changes{v3.2}{2010/11/07}{This macro added}
319 % |\caption@selectlistentry|\marg{\purett{heading} or \purett{entry}}
320 % \begin{macrocode}
321 \newcommand*\caption@selectlistentry[1]{%
322 \caption@ifinlist{#1}{heading}{%
323 \let\caption@iflistheading\@firstoftwo
324 }{\caption@ifinlist{#1}{default,list-entry,entry}{%
325 \let\caption@iflistheading\@secondoftwo
326 }{%
327 \caption@Error{Undefined list-entry selection `#1'}%
328 }}}
329 % \end{macrocode}
330 % \end{macro}
331 %
332 % \changes{v3.3}{2012-03-25}{Option \opt{list-entry} added}
333 % \begin{macrocode}
334 \DeclareCaptionOption{list-entry}{\caption@selectlistentry{#1}}
335 \captionsetup{list-entry=default}
336 % \end{macrocode}
337 %
338 % \begin{macro}{\caption@declparboxrestore}
339 % \changes{v3.5g}{2020/10/26}{This macro added}
340 % |\caption@declparboxrestore|\marg{name}\marg{code}
341 % \begin{macrocode}
342 % TODO: Remove \caption@declparboxrestore
343 \newcommand\caption@declparboxrestore{%
344 \caption@decl{parboxrestore}}
345 % \end{macrocode}
346 % \begin{macrocode}
347 \@onlypreamble\caption@declparboxrestore
348 % \end{macrocode}
349 % \end{macro}
350 %
351 % \begin{macro}{\caption@setparboxrestore}
352 % \changes{v3.2}{2010/11/07}{This macro added}
353 % \changes{v3.5g}{2020/10/26}{New implementation; default changed from `partial' to `full'}
354 % |\caption@setparboxrestore|\marg{\purett{partial} or \purett{full}}
355 % \begin{macrocode}
356 % TODO: Remove \caption@setparboxrestore
357 \newcommand*\caption@setparboxrestore{%
358 \caption@set{parboxrestore}}
359 % \end{macrocode}
360 % \begin{macrocode}
361 \caption@declparboxrestore{full}{%
362 \@parboxrestore}
363 % \end{macrocode}
364 % The original code (from |latex/base/ltboxes.dtx|):
365 % \begin{verbatim}
366 % \def\@parboxrestore{\@arrayparboxrestore\let\\\@normalcr}
367 % \def\@arrayparboxrestore{%
368 % \let\if@nobreak\iffalse
369 % \let\if@noskipsec\iffalse
370 % \let\par\@@par
371 % \let\-\@dischyph
372 % \let\'\@acci\let\`\@accii\let\=\@acciii
373 % \parindent\z@ \parskip\z@skip
374 % \everypar{}%
375 % \linewidth\hsize
376 % \@totalleftmargin\z@
377 % \leftskip\z@skip \rightskip\z@skip \@rightskip\z@skip
378 % \parfillskip\@flushglue \lineskip\normallineskip
379 % \baselineskip\normalbaselineskip
380 % \sloppy}
381 % \end{verbatim}%^^A
382 % This one will be used by |\@caption| instead of |\@parboxrestore|.
383 % \begin{macrocode}
384 \caption@declparboxrestore{partial}{%
385 \let\if@nobreak\iffalse
386 \let\if@noskipsec\iffalse
387 \let\par\@@par
388 % \let\-\@dischyph
389 % \let\'\@acci\let\`\@accii\let\=\@acciii
390 \parindent\z@ \parskip\z@skip
391 \everypar{}%
392 % \linewidth\hsize
393 % \@totalleftmargin\z@
394 \leftskip\z@skip \rightskip\z@skip \@rightskip\z@skip
395 \parfillskip\@flushglue \lineskip\normallineskip
396 \baselineskip\normalbaselineskip
397 \sloppy
398 \let\\\@normalcr}
399 % \end{macrocode}
400 % \end{macro}
401 %
402 % \begin{macro}{\caption@parboxrestore@mini}
403 % \changes{v3.2}{2010/10/24}{This macro added}
404 % \changes{v3.5g}{2020/10/26}{Renamed from \cs{caption@boxrestore@mini} to \cs{caption@parboxrestore@mini}}
405 % Resets |\par| so the very first |\par| in |\@caption| behaves quite the same as in floating environments.
406 % Will be used by |\set|\-|caption|\-|type|.
407 % \begin{macrocode}
408 \caption@declparboxrestore{mini}{%
409 \let\par\@@par
410 \parindent\z@ \parskip\z@skip
411 \sloppy}
412 % \end{macrocode}
413 % \end{macro}
414 %
415 % `default' usually maps to `full'.
416 % \changes{v3.5g}{2020/10/26}{The default of \cs{caption@parboxrestore} maps to `full' instead of `partial' now}
417 % \begin{macrocode}
418 \SetCaptionDefault{parboxrestore}{full}
419 % \end{macrocode}
420 %
421 % \changes{v3.2}{2010/11/07}{Option \opt{parboxrestore} added}
422 % \begin{macrocode}
423 % TODO: Remove the (undocumentated) option "parboxrestore"
424 \DeclareCaptionOption{parboxrestore}{\caption@setparboxrestore{#1}}
425 % \end{macrocode}
426 %
427 % \begin{macro}{\caption@parboxrestore}
428 % \changes{v3.1}{2007/03/03}{This macro and its usage added}
429 % \changes{v3.1b}{2007/09/17}{Bugfix: Redefinition of CR added}
430 % \changes{v3.2}{2010/11/07}{Support of option \opt{parboxrestore} added}
431 % \changes{v3.5g}{2020/10/26}{New implementation; renamed from \cs{caption@boxrestore} to \cs{caption@parboxrestore}}
432 % \begin{macrocode}
433 % TODO: Change definition to \def\caption@parboxrestore{\@parboxrestore}
434 \captionsetup{parboxrestore=default}
435 % \end{macrocode}
436 % \end{macro}
437 %
438 % \changes{v3.1f}{2007/11/28}{Option \opt{@minipage=} added}
439 % \begin{macrocode}
440 \DeclareCaptionOption{@minipage}{%
441 \caption@ifinlist{#1}{auto,default}%
442 {\let\caption@if@minipage\@gobbletwo}%
443 {\caption@set@bool\caption@if@minipage{#1}}}
444 \captionsetup{@minipage=default}
445 % \end{macrocode}
446 %
447 % \subsection{caption v1.x compatibility options}
448 % \changes{v3.1}{2007/07/21}{Option `compatibility' added}
449 % \changes{v3.1}{2007/09/01}{caption v1.x compatibility options revised}
450 % \changes{v3.1d}{2007/10/24}{Bugfix 07-10-24 in caption v1.x$ compatibility options}
451 % \changes{v3.5a}{2020/09/02}{caption v1.x compatibility options fixed}
452 %
453 % Currently we support |v1| and |v3| as values for the |compatibility=| option.
454 % But since this used to be a boolean option is the past we still support any boolean value
455 % for compatibility reasons.
456 %
457 % \begin{macrocode}
458 \DeclareCaptionOption{compatibility}[v1]{%
459 \caption@ifinlist{#1}{v1,1,true,yes,on}{%
460 \let\caption@ifcompatibility\@firstoftwo
461 }{\caption@ifinlist{#1}{v3,3,0,false,no,off}{%
462 \let\caption@ifcompatibility\@secondoftwo
463 }{%
464 \caption@Error{Undefined compatibility value `#1'}%
465 }}}
466 \@onlypreamble@key{caption}{compatibility}
467 % \end{macrocode}
468 % \begin{macrocode}
469 \caption@setbool{compatibility}{0} % default: Try not to be compatible to v1.x
470 % \end{macrocode}
471 %
472 % \begin{macro}{\caption@setincompatible}
473 % \changes{v3.4}{2019/09/09}{This macro added}
474 % |\caption@setincompatible|\marg{condition}\marg{message text}
475 % \begin{macrocode}
476 \newcommand*\caption@setincompatible[2]{%
477 #1{%
478 \caption@WarningNoLine{%
479 #2;\MessageBreak
480 Setting compatibility to v1}%
481 \caption@setbool{compatibility}{1}%
482 }{}}
483 % \end{macrocode}
484 % \end{macro}
485 %
486 % Check against incompatible packages which used to work fine with v1 of the `caption' package.
487 % \begin{macrocode}
488 \caption@AtBeginDocument{\caption@ifcompatibility{}{%
489 % \end{macrocode}
490 % The usage of the (now obsolete) \package{captcont} package,
491 % which brings its own definition of |\caption*|, was quite common in the old days.
492 % \begin{macrocode}
493 \caption@setincompatible{\@ifpackageloaded{captcont}}{captcont package is loaded}%
494 % \end{macrocode}
495 % To be continued\ldots
496 % \begin{macrocode}
497 }}
498 % \end{macrocode}
499 %
500 % \begin{macrocode}
501 \DeclareCaptionOptionNoValue*{normal}{%
502 \caption@setup{format=plain,justification=justified}}
503 \DeclareCaptionOptionNoValue*{isu}{%
504 \caption@setup{format=hang,justification=justified}}
505 \DeclareCaptionOptionNoValue*{hang}{%
506 \caption@setup{format=hang,justification=justified}}
507 \DeclareCaptionOptionNoValue*{center}{%
508 \caption@setup{format=plain,justification=centering}}
509 \DeclareCaptionOptionNoValue*{centerlast}{%
510 \caption@setup{format=plain,justification=centerlast}}
511 % \end{macrocode}
512 %
513 % \begin{macrocode}
514 \DeclareCaptionOptionNoValue*{scriptsize}{\def\captionfont{\scriptsize}}
515 \DeclareCaptionOptionNoValue*{footnotesize}{\def\captionfont{\footnotesize}}
516 \DeclareCaptionOptionNoValue*{small}{\def\captionfont{\small}}
517 \DeclareCaptionOptionNoValue*{normalsize}{\def\captionfont{\normalsize}}
518 \DeclareCaptionOptionNoValue*{large}{\def\captionfont{\large}}
519 \DeclareCaptionOptionNoValue*{Large}{\def\captionfont{\Large}}
520 % \end{macrocode}
521 %
522 % \begin{macrocode}
523 \DeclareCaptionOptionNoValue*{up}{\caption@setup{labelfont+=up}}
524 \DeclareCaptionOptionNoValue*{it}{\caption@setup{labelfont+=it}}
525 \DeclareCaptionOptionNoValue*{sl}{\caption@setup{labelfont+=sl}}
526 \DeclareCaptionOptionNoValue*{sc}{\caption@setup{labelfont+=sc}}
527 \DeclareCaptionOptionNoValue*{md}{\caption@setup{labelfont+=md}}
528 \DeclareCaptionOptionNoValue*{bf}{\caption@setup{labelfont+=bf}}
529 \DeclareCaptionOptionNoValue*{rm}{\caption@setup{labelfont+=rm}}
530 \DeclareCaptionOptionNoValue*{sf}{\caption@setup{labelfont+=sf}}
531 \DeclareCaptionOptionNoValue*{tt}{\caption@setup{labelfont+=tt}}
532 % \end{macrocode}
533 %
534 % \begin{macrocode}
535 \DeclareCaptionOptionNoValue*{nooneline}{\caption@setup{slc=0}}
536 % \end{macrocode}
537 %
538 % \begin{macrocode}
539 \caption@setbool{ruled}{0}
540 \DeclareCaptionOptionNoValue*{ruled}{\caption@setbool{ruled}{1}}
541 % \end{macrocode}
542 %
543 % \subsection{caption2 v2.x compatibility options}
544 % \changes{v3.0h}{2005/07/08}{caption2 \version{2.x} compatibility options added}
545 % \changes{v3.1}{2007/09/01}{caption2 v2.x compatibility options revised}
546 % \changes{v3.1d}{2007/10/24}{Bugfix 07-10-24 in caption v2.x$ compatibility options}
547 % \changes{v3.5a}{2020/09/02}{caption v2.x compatibility options fixed}
548 %
549 % \begin{macrocode}
550 \DeclareCaptionOptionNoValue*{flushleft}{%
551 \caption@setup{format=plain,justification=raggedright}}
552 \DeclareCaptionOptionNoValue*{flushright}{%
553 \caption@setup{format=plain,justification=raggedleft}}
554 % \end{macrocode}
555 % \begin{macrocode}
556 \DeclareCaptionOptionNoValue*{oneline}{\caption@setup{slc=1}}
557 % \end{macrocode}
558 % \begin{macrocode}
559 \DeclareCaptionOptionNoValue*{ignoreLTcapwidth}{%
560 \caption@WarningNoLine{Obsolete option `ignoreLTcapwidth' ignored}}
561 % \end{macrocode}
562 %
563 % \subsection{Obsolete caption v3.0 options}
564 % \changes{v3.1}{2007/05/07}{Package option \opt{caption} marked as obsolete,
565 % gives error now}
566 %
567 % \begin{macrocode}
568 \DeclareCaptionOption*{caption}{%
569 \caption@setbool{temp}{#1}%
570 \caption@ifbool{temp}{}{%
571 \caption@Error{%
572 The package option `caption=#1' is obsolete.\MessageBreak
573 Please pass this option to the subfig package instead\MessageBreak
574 and do *not* load the caption package anymore}}}
575 % \end{macrocode}
576 %
577 % \subsection{fltpage package support options}
578 %
579 % \changes{v3.1}{2007/09/01}{Options `FPlist' \& `FPref' added}
580 % With these options is controlled where the list-of entry and |\ref| resp.
581 % |\pageref| or |\autoref| will link to.
582 % Defaults are |FPlist=caption| and |FPref=figure| which is inconsistent,
583 % but compatible to the usual behaviour of the \package{fltpage} package.
584 % \begin{macrocode}
585 \DeclareCaptionOption{FPlist}[1]{\caption@setFPoption{list}{#1}}
586 \DeclareCaptionOption{FPref}[1]{\caption@setFPoption{ref}{#1}}
587 \@onlypreamble@key{caption}{FPlist}
588 \@onlypreamble@key{caption}{FPref}
589 % \end{macrocode}
590 % \begin{macrocode}
591 \newcommand*\caption@setFPoption[2]{%
592 \edef\caption@tempa{\@car#2\@nil}%
593 \caption@setbool{FP#1cap}{\if c\caption@tempa 1\else 0\fi}}
594 \@onlypreamble\caption@setFPoption
595 % \end{macrocode}
596 % \begin{macrocode}
597 \captionsetup{FPlist=caption,FPref=figure}
598 % \end{macrocode}
599 %
600 % \subsection{hyperref package support options}
601 %
602 % \changes{v3.1}{2007/06/21}{Options `hypcap' \& `hypcapspace' added}
603 % With |hypcap=off| one can turn the \package{hypcap} support off
604 % (default is |on|).
605 % \begin{macrocode}
606 \DeclareCaptionOption{hypcap}[1]{\caption@setbool{hypcap}{#1}}
607 \DeclareCaptionOption{hypcapspace}{\def\caption@hypcapspace{#1}}
608 % \end{macrocode}
609 % \begin{macrocode}
610 \captionsetup{hypcap=1,hypcapspace=.5\baselineskip}
611 % \end{macrocode}
612 %
613 % \section{Document class support}
614 %
615 % Execute the code declared with |\At|\-|Caption|\-|Package|.
616 % We do this right before processing the options so stuff done with
617 % |\At|\-|Caption|\-|Package| could be overwritten by user options.
618 %
619 % \begin{macrocode}
620 \caption@documentclass@code
621 \let\caption@documentclass@code\@undefined
622 \let\AtCaptionPackage\@firstofone
623 % \end{macrocode}
624 %
625 % \section{Processing of options}
626 %
627 % \changes{v3.0m}{2007/03/04}{Verbose option added}
628 % \changes{v3.1}{2007/07/02}{Verbose option removed from package}
629 % \changes{v3.1}{2007/03/17}{We do not process global options anymore}
630 %
631 % \begin{macrocode}
632 \caption@SetupOptions{caption}{\caption@setkeys{#1}{#2}}
633 \caption@ProcessOptions*{caption}
634 % \end{macrocode}
635 %
636 % \section{\cs{caption}, \cs{@caption}, and \cs{@makecaption}}
637 %
638 % \begin{macro}{\caption@ifflag}
639 % \changes{v3.3}{2011/12/28}{This switch added}
640 % \changes{v3.3}{2018/08/08}{Rewritten (and renamed) so a counter is used instead of a switch}
641 % Since we support continued floats and sub-figures it's not an easy task
642 % to manage the figure (and table) counter. (Especially since previous versions
643 % of the caption package has proven that correcting a counter locally is not a good idea.)
644 %
645 % These three switches hold the
646 % current status: |\caption@if|\-|flag{2}| is set if the caption was already
647 % typeset (so the counter doesn't need to be incremented for sub-figures),
648 % |\caption@if|\-|flag{4}| is set if there is already content which have
649 % incremented the counter (so the counter doesn't need to be incremented
650 % for the main caption, further sub-figures, and other stuff), and
651 % |\caption@if|\-|flag{1}| is set if |\continued|\-|float| was given.
652 %
653 % In the past three boolean switches were used to store the flags, but since some
654 % packages (like the \package{floatrow} and \package{tabu} package) try hard to keep
655 % counter changes locally under certain circumstances, it seems a good idea to make
656 % these flags a counter value, too.
657 % \begin{macrocode}
658 \newcounter{caption@flags}
659 % \end{macrocode}
660 % \begin{macrocode}
661 \newcommand*\caption@ifflag[1]{%
662 \@tempcnta\c@caption@flags
663 \divide\@tempcnta #1\relax
664 \ifodd\@tempcnta
665 \expandafter\@firstoftwo
666 \else
667 \expandafter\@secondoftwo
668 \fi}
669 % \end{macrocode}
670 % \end{macro}
671 %
672 % \begin{macro}{\caption@clrflags}
673 % \changes{v3.3}{2018/08/08}{This macro added}
674 % \begin{macro}{\caption@clrflag}
675 % \changes{v3.3}{2013/04/14}{This macro added}
676 % \changes{v3.3}{2018/08/08}{Rewritten so a counter is used instead of a switch}
677 % \begin{macro}{\caption@setflag}
678 % \changes{v3.3}{2013/04/14}{This macro added}
679 % \changes{v3.3}{2018/08/08}{Rewritten so a counter is used instead of a switch}
680 % Furthermore we introduce the macros \cs{caption@clrflag} and \cs{caption@setflag}
681 % for clearing resp.~setting these flags.
682 % \begin{macrocode}
683 \newcommand*\caption@clrflags{%
684 \setcounter{caption@flags}\z@}
685 % \end{macrocode}
686 % \begin{macrocode}
687 \newcommand*\caption@clrflag[1]{%
688 \caption@ifflag{#1}{\caption@addtoflags{-#1}}{}}
689 \newcommand*\caption@setflag[1]{%
690 \caption@ifflag{#1}{}{\caption@addtoflags{#1}}}
691 \newcommand*\caption@addtoflags{%
692 \addtocounter{caption@flags}}
693 % \end{macrocode}
694 % \end{macro}
695 % \end{macro}
696 % \end{macro}
697 %
698 % \begin{macro}{\caption@caption}
699 % \changes{v3.0f}{2005/05/22}{Bugfix: \cs{ContinuedFloat} added}
700 % \changes{v3.0f}{2005/06/13}{Support of \cs{caption*[]} removed}
701 % \changes{v3.0l}{2007/01/19}{Minimal support of \textsf{combine} package added}
702 % \changes{v3.1}{2007/02/04}{Re-written, does not save\&use original definition anymore}
703 % Here comes our definition of |\caption| and |\caption*|.
704 % Beside the support of the starred variant this code was adapted to the
705 % various packages we support.
706 % We are using |\caption@dblarg| instead of |\@dblarg| so |\caption{}|
707 % (with an empty arg.) will produce a list-of entry, but |\caption[]{}|
708 % won't.
709 % \begin{macrocode}
710 \def\caption@caption{%
711 \caption@iftype
712 {\caption@checkgrouplevel\@empty\caption
713 \caption@star
714 {\caption@refstepcounter\@captype}%
715 {\caption@dblarg{\@caption\@captype}}}%
716 {\caption@Error{\noexpand\caption outside float}%
717 \caption@gobble}}
718 % \end{macrocode}
719 % \end{macro}
720 %
721 % \begin{macro}{\caption@star}
722 % \changes{v3.1}{2007/06/24}{Renamed from \cs{caption@caption} to \cs{caption@star}}
723 % \changes{v3.2c}{2011/08/21}{\cs{global} removed}
724 % A helper macro which processes the optional |*| after |\caption|.
725 % \begin{macrocode}
726 \newcommand*\caption@star[2]{%
727 \@ifstar{\caption@startrue#2[]}{#1#2}}
728 % \end{macrocode}
729 % \end{macro}
730 %
731 % \begin{macro}{\caption@@caption}
732 % \changes{v3.1}{2007/02/04}{Re-written, does not save\&use original definition anymore}
733 % \changes{v3.1f}{2007/11/28}{Bugfix: Handling of \texttt{@minipage} flag added}
734 % \changes{v3.1f}{2007/11/28}{Support of option \opt{@minipage} added}
735 % \changes{v3.1g}{2008/03/16}{Internal: Uses \cs{caption@prepareanchor} now}
736 % \changes{v3.2d}{2011/10/21}{Adapted to the \textsf{memoir} document class}
737 % \changes{v3.2f}{2012/01/14}{Usage of \cs{M@gettitle} moved to \cs{caption@prepareanchor}}
738 % \changes{v3.3}{2013/01/06}{Adapted to the \textsf{nag} package}
739 % As above, our version has been adapted to the packages we support.
740 % Additionally our code is nested by |\caption@begin|\-|ex| \&
741 % |\caption@end| instead of |\begin|\-|group| \& |\end|\-|group|.
742 % Furthermore we use |\caption@par|\-|box|\-|restore| instead of
743 % |\@parbox|\-|restore|.
744 % \begin{macrocode}
745 \long\def\caption@@caption#1[#2]#3{%
746 % \end{macrocode}
747 % \begin{macrocode}
748 \ifcaption@star \else
749 \caption@prepareanchor{#1}{#2}%
750 \memcaptioninfo{#1}{\csname the#1\endcsname}{#2}{#3}%
751 \@nameuse{nag@hascaptiontrue}%
752 \fi
753 % \end{macrocode}
754 % \begin{macrocode}
755 \par
756 \caption@beginex{#1}{#2}{#3}%
757 \caption@setfloatcapt{%
758 \caption@parboxrestore
759 \if@minipage
760 \@setminipage
761 \fi
762 \caption@normalsize
763 \ifcaption@star
764 \let\caption@makeanchor\@firstofone
765 \fi
766 \@makecaption{\csname fnum@#1\endcsname}%
767 {\ignorespaces\caption@makeanchor{#3}}\par
768 \caption@if@minipage\@minipagetrue\@minipagefalse}%
769 \caption@end}
770 % \end{macrocode}
771 % \begin{macrocode}
772 \newcommand*\caption@before@parboxrestore{}
773 \newcommand*\caption@after@parboxrestore{}
774 % \end{macrocode}
775 % \class{memoir} document class stuff:
776 % \begin{macrocode}
777 \providecommand\memcaptioninfo[4]{}
778 % \end{macrocode}
779 % \end{macro}
780 %
781 % \begin{macro}{\caption@prepareanchor}
782 % \changes{v3.1g}{2008/03/16}{This macro added}
783 % \changes{v3.2f}{2012/01/14}{Usage of \cs{M@gettitle} moved from \cs{caption@@caption}}
784 % \begin{macrocode}
785 \newcommand*\caption@prepareanchor[2]{%
786 \caption@makecurrent{#1}{#2}%
787 \caption@ifhypcap\caption@@start\relax
788 \M@gettitle{#2}}
789 % \end{macrocode}
790 % \class{memoir} document class stuff:
791 % \begin{macrocode}
792 \providecommand\M@gettitle[1]{}
793 % \end{macrocode}
794 % \end{macro}
795 %
796 % \begin{macro}{\caption@makecaption}
797 % \changes{v3.1i}{2008/05/06}{Usage of \cs{caption@rule} added}
798 % |\@makecaption|\marg{label}\marg{text}\par
799 % We do basically the same as the original code (from the standard
800 % \LaTeX\ document classes), but take care of the |position=| setting
801 % and use |\caption@@make| from the \package{caption} kernel to finally
802 % typeset the caption.
803 % \begin{macrocode}
804 \long\def\caption@makecaption#1#2{%
805 \caption@make@above
806 \caption@@make{#1}{#2}%
807 \caption@make@below}
808 % \end{macrocode}
809 % \end{macro}
810 %
811 % \begin{macro}{\caption@make@above}
812 % \begin{macro}{\caption@make@below}
813 % \changes{v3.3a}{2019/04/02}{This macro added}
814 % |\caption@make@above|\\
815 % |\caption@make@below|\par
816 % Typesets the stuff above resp.~below the caption, depending on |\caption@iftop|.
817 % \begin{macrocode}
818 \newcommand*\caption@make@above{%
819 \caption@iftop
820 \caption@belowskip
821 {\caption@rule\caption@aboveskip}}
822 % \end{macrocode}
823 % \begin{macrocode}
824 \newcommand*\caption@make@below{%
825 \caption@iftop
826 {\caption@aboveskip\caption@rule}%
827 \caption@belowskip}
828 % \end{macrocode}
829 % \end{macro}
830 % \end{macro}
831 %
832 % \begin{macro}{\caption@redefine}
833 % \changes{v3.1k}{2009/03/30}{This macro added, it contains the patching code now}
834 % \begin{macrocode}
835 \newcommand*\caption@redefine{}
836 % \end{macrocode}
837 % \end{macro}
838 %
839 % Prior to \version{3.4} we only redefined |\caption| and |\@caption| if the current definitions
840 % were well known, so documents written in the old (\package{caption} package \version{1.x}) days
841 % (where |\caption| \& |\@caption| were not redefined by us) still compiled fine.
842 % This used to make sense when introducing \version{3.0} in the year 2003
843 % but is simply overcautious and especially unwanted by the user nowadays.
844 % So starting with \version{3.4} we only do not redefine |\caption| and |\@caption| if the
845 % `compatibility' option is set to `v1'.
846 %
847 % \begin{macrocode}
848 \g@addto@macro\caption@redefine{%
849 % \end{macrocode}
850 % \begin{macrocode}
851 \caption@ifcompatibility{%
852 % \end{macrocode}
853 % \begin{macrocode}
854 \caption@InfoNoLine{
855 \noexpand\caption will not be redefined since `compatibility' is set to v1}%
856 % \end{macrocode}
857 % \begin{macrocode}
858 \renewcommand*\caption@redefine{}%
859 % \end{macrocode}
860 %
861 % |\continuedfloat| is not supported in compatibility mode `v1'.
862 % \begin{macrocode}
863 \renewcommand*\caption@continuedfloat[1]{%
864 \caption@Error{Not available with option `compatibility=v1'}}%
865 % \end{macrocode}
866 %
867 % |\caption@start| is not supported in compatibility mode `v1'.
868 % \begin{macrocode}
869 \caption@AtBeginDocument*{%
870 \let\caption@start\relax
871 \caption@ifdefined\caption@ORI@capstart{%
872 \caption@Debug{%
873 Restore hypcap definition of \string\capstart\@gobble}%
874 \let\capstart\caption@ORI@capstart}{}%
875 }%
876 % \end{macrocode}
877 %
878 % \begin{macro}{\caption@star}
879 % We redefine |\caption@star| here so it does not make any harm.
880 % \begin{macrocode}
881 \renewcommand*\caption@star[2]{#1#2}%
882 % \end{macrocode}
883 % \end{macro}
884 %
885 % \begin{macrocode}
886 }{%
887 % \end{macrocode}
888 %
889 % \begin{macro}{\caption}
890 % \begin{macro}{\@caption}
891 % \begin{macrocode}
892 \renewcommand*\caption@redefine{%
893 \let\caption\caption@caption
894 \let\@caption\caption@@caption}%
895 % \end{macrocode}
896 % \end{macro}
897 % \end{macro}
898 %
899 % \begin{macrocode}
900 }%
901 % \end{macrocode}
902 % \begin{macrocode}
903 \caption@redefine
904 \caption@AtBeginDocument*{%
905 \let\caption@ORI@capstart\@undefined}%
906 % \end{macrocode}
907 %
908 % \begin{macro}{\@xfloat}
909 % \changes{v3.1}{2007/05/09}{This re-definition added}
910 % \changes{v3.1b}{2007/09/22}{Will now be redefined in compatibility mode, too}
911 % \changes{v3.5}{2020/08/30}{Hook added}
912 % We redefine |\@x|\-|float| so inside floating environments our
913 % type-specific options will be used, a \package{hyperref}
914 % anchor will be set etc.
915 % \begin{macrocode}
916 \let\caption@ORI@xfloat\@xfloat
917 % \end{macrocode}
918 % \begin{macrocode}
919 \def\@xfloat#1[#2]{%
920 \caption@ORI@xfloat{#1}[#2]%
921 \caption@settype{#1}%
922 \caption@xfloat@hook}%
923 % \end{macrocode}
924 % Hook, could be extended with |\g@addto@macro\caption@x|\-|float@hook{|\ldots|}|.
925 % (The caption type could be found in |\@cap|\-|type|.)
926 % \begin{macrocode}
927 \newcommand*\caption@xfloat@hook{}%
928 % \end{macrocode}
929 % \end{macro}
930 %
931 % \begin{macro}{\@xdblfloat}
932 % \changes{v3.5}{2020/08/30}{Re-definition of \cs{xdblfloat} added}
933 % We redefine |\@xdbl|\-|float|, too, so special options for |figure*|
934 % resp.~|table*| will be applied here.
935 % \begin{macrocode}
936 \let\caption@ORI@xdblfloat\@xdblfloat
937 % \end{macrocode}
938 % \begin{macrocode}
939 \def\@xdblfloat#1[#2]{%
940 \caption@ORI@xdblfloat{#1}[#2]% expands to \@xfloat{#1}[#2] + extra stuff
941 \caption@setoptions{#1*}%
942 \caption@xdblfloat@hook}%
943 % \end{macrocode}
944 % Hook, could be extended with |\g@addto@macro\caption@xdbl|\-|float@hook{|\ldots|}|.
945 % (The caption type could be found in |\@cap|\-|type|.)
946 % \begin{macrocode}
947 \newcommand*\caption@xdblfloat@hook{}%
948 % \end{macrocode}
949 % \end{macro}
950 %
951 % \begin{macrocode}
952 }
953 % \end{macrocode}
954 %
955 % Some packages (like the \package{hyperref} package for example) redefines
956 % |\caption| and |\@caption|, too.
957 % So we have to use |\AtBeginDocument| here, so we can make sure
958 % our definition is the one which will be valid at last.
959 % \begin{macrocode}
960 \caption@AtBeginDocument{\caption@redefine}
961 % \end{macrocode}
962 %
963 % \begin{macro}{\@makecaption}
964 % \begin{macrocode}
965 \let\@makecaption\caption@makecaption
966 % \end{macrocode}
967 % \end{macro}
968 %
969 % \begin{macro}{\phantomcaption}
970 % \changes{v3.2}{2010/10/31}{Bugfix 10-09-01b: This macro added}
971 % |\phantomcaption|\par
972 % Use this one for figures with subcaptions but without main caption.
973 % \begin{macrocode}
974 \newcommand\phantomcaption{%
975 \caption@iftype
976 {\caption@refstepcounter\@captype}%
977 {\caption@Error{\noexpand\phantomcaption outside float}}}%
978 % \end{macrocode}
979 % \end{macro}
980 %
981 % \section{\cs{setcaptiontype} and \cs{setcaptionsubtype}}
982 %
983 % \changes{v3.0d}{2004/08/03}{Option \opt{type=} added}
984 % \changes{v3.1}{2007/06/25}{Option \opt{type*=} added}
985 % \changes{v3.1f}{2007/11/16}{Option \opt{subtype} \& \opt{subtype*} added}
986 % \changes{v3.2}{2010/10/24}{Bugfix 10-10-17: Option \opt{type=} uses \cs{setcaptiontype} instead of \cs{caption@settype} now}
987 %
988 % \begin{macrocode}
989 \caption@AtBeginDocument{%
990 % \end{macrocode}
991 % \begin{macrocode}
992 \DeclareCaptionOption{type}{\setcaptiontype{#1}}%
993 \DeclareCaptionOption{type*}{\setcaptiontype*{#1}}%
994 % \end{macrocode}
995 % \begin{macrocode}
996 \DeclareCaptionOptionNoValue{subtype}{\setcaptionsubtype\relax}%
997 \DeclareCaptionOptionNoValue{subtype*}{\setcaptionsubtype*}%
998 % \end{macrocode}
999 % \begin{macrocode}
1000 }
1001 % \end{macrocode}
1002 %
1003 % \emph{Important Note:}
1004 % Like |\captionof| the option |type=| should only be used inside a
1005 % group, box, or environment and does not check if the argument is a valid
1006 % floating environment or not.
1007 %
1008 % \begin{macro}{\setcaptiontype}
1009 % \changes{v3.2}{2010/10/24}{This macro added}
1010 % \changes{v3.4e}{2020/01/02}{Check added if the subtype is defined}
1011 % \changes{v3.5}{2020/08/24}{Definition method adapted to the \package{caption-light} package}
1012 % Like |\captionsetup{type=xxx}|, but also works if |\caption|\-|setup| was redefined.
1013 % \begin{macrocode}
1014 \def\setcaptiontype{%
1015 \caption@parboxrestore@mini
1016 \caption@settype}
1017 % \end{macrocode}
1018 % \end{macro}
1019 %
1020 % \begin{macro}{\setcaptionsubtype}
1021 % \changes{v3.2a}{2011/08/15}{This macro added}
1022 % \changes{v3.5d}{2020/09/28}{This macro revised}
1023 % Same, but sets the sub-type.
1024 % \begin{macrocode}
1025 \newcommand\setcaptionsubtype{%
1026 \caption@iftype
1027 \caption@setsubtype
1028 {\caption@Error{\noexpand\setcaptionsubtype outside float}}}%
1029 % \end{macrocode}
1030 % \begin{macrocode}
1031 \newcommand\caption@setsubtype{%
1032 \caption@teststar\caption@@setsubtype\@firstoftwo\@secondoftwo}
1033 % \end{macrocode}
1034 % \begin{macrocode}
1035 \newcommand*\caption@@setsubtype[1]{%
1036 \caption@@@settype{sub}{#1}{sub\@captype}}
1037 % \end{macrocode}
1038 % \end{macro}
1039 %
1040 % \begin{macro}{\caption@settype}
1041 % \changes{v3.1}{2007/05/09}{This macro added}
1042 % \changes{v3.1b}{2007/09/22}{Usage of \cs{caption@xlabel} added}
1043 % \changes{v3.1d}{2007/10/23}{Error message for \cs{caption@checkgrouplevel} revised}
1044 % \changes{v3.1f}{2007/11/16}{\cs{caption@setsubtype} added}
1045 % \changes{v3.1f}{2007/12/03}{Crappy \cs{caption@iftypewarning} replaced}
1046 % \changes{v3.1g}{2008/01/12}{Usage of \cs{ifcaptionsetup@star} added}
1047 % \changes{v3.2}{2010/10/26}{Error message moved from here to \cs{caption@refstepcounter}}
1048 % \changes{v3.3}{2011/12/28}{Resetting of \cs{ifcaption@caption} and \cs{ifcaption@subcaption} added}
1049 % \changes{v3.4e}{2020/01/02}{Checks added to prevent misuse regading subtypes}
1050 % \changes{v3.5d}{2020/09/28}{This macro revised}
1051 % |\caption@settype*|\marg{type}\par
1052 % sets |\@captype| and executes the options associated with it
1053 % (using |\caption@set|\-|options|).
1054 % Furthermore we check |\current|\-|group|\-|level| (if avail),
1055 % redefine |\@currentlabel| so a |\label| before |\caption| will result
1056 % in a hint instead of a wrong reference, and
1057 % use the macro |\caption@|(|sub|)|type|\-|hook| (which will be used by our
1058 % \package{float} package support).\par
1059 % The non-starred version sets a \package{hyperref} anchor additionally
1060 % (if |hypcap=|\-|true| and the \package{hypcap} package is not loaded).
1061 % \begin{macrocode}
1062 \newcommand*\caption@settype{%
1063 \caption@clrflags
1064 \caption@set@type}
1065 % \end{macrocode}
1066 % \begin{macrocode}
1067 \newcommand*\caption@set@type{%
1068 \caption@teststar\caption@@settype\@firstoftwo\@secondoftwo}
1069 % \end{macrocode}
1070 % \begin{macrocode}
1071 \newcommand*\caption@@settype{%
1072 \caption@@@settype{}}
1073 % \end{macrocode}
1074 % \begin{macrocode}
1075 \newcommand*\caption@@@settype[3]{%
1076 % #1 = "" or "sub"
1077 % #2 = \@firstoftwo in star form, \@secondoftwo otherwise
1078 % #3 = <type>, e.g.: "figure" or "subfigure"
1079 \caption@Debug{#1type=#3}%
1080 \@nameuse{caption@check#1type}{#3}%
1081 {\caption@checkgrouplevel{#1}{%
1082 \captionsetup{#1type#2*\@empty=...}#2{ or
1083 \@backslashchar#1captionof}{}}%
1084 % \end{macrocode}
1085 % \begin{macrocode}
1086 \edef\caption@tempa{#3}%
1087 \expandafter\ifx\csname @#1captype\endcsname\caption@tempa \else
1088 \ifcaptionsetup@star\else\@nameuse{caption@#1type@warning}\fi
1089 \fi
1090 \expandafter\let\csname @#1captype\endcsname\caption@tempa
1091 % \end{macrocode}
1092 % \begin{macrocode}
1093 \@nameuse{caption@#1typehook}%
1094 % \end{macrocode}
1095 % \begin{macrocode}
1096 \caption@setoptions{#3}%
1097 \ifx\caption@opt\relax
1098 \@nameundef{caption@#1type@warning}%
1099 \else
1100 \@namedef{caption@#1type@warning}{\caption@Warning{%
1101 The #1type was already set to
1102 `\csname @#1captype\endcsname'\MessageBreak}}%
1103 \fi
1104 % \end{macrocode}
1105 % \begin{macrocode}
1106 #2{}{%
1107 \let\@currentlabel\caption@undefinedlabel
1108 % \let\@currentHlabel\@undefined
1109 \ifx\caption@x@label\@undefined
1110 \let\caption@x@label\label
1111 \let\label\caption@xlabel
1112 \fi
1113 \caption@start}}}
1114 % \end{macrocode}
1115 % \end{macro}
1116 %
1117 % \begin{macro}{\caption@iftype}
1118 % \changes{v3.1}{2007/04/11}{This macro and its usage added}
1119 % Since we often need to check if |\@captype| is defined (means: we
1120 % are inside a floating environment) this helper macro was introduced.
1121 % \begin{macrocode}
1122 \newcommand*\caption@iftype{\caption@ifdefined\@captype}
1123 % \end{macrocode}
1124 % \end{macro}
1125 %
1126 % \begin{macro}{\caption@checktype}
1127 % \changes{v3.4g}{2020/01/02}{This macro and its usage added}
1128 % \changes{v3.4m}{2020/07/29}{Check of \cs{sf@counterlist} from \package{subfig} package added}
1129 % |\caption@checktype|\marg{type}\marg{code}\par
1130 % is used by |\caption@settype| and should either expand the code or issue an error
1131 % if the given type is not a proper type, i.e. it is a sub-type instead (either defined by
1132 % |\DeclareCaptionSubType| or |\newsubfloat|\cite{subfig}).
1133 % \begin{macrocode}
1134 \newcommand*\caption@checktype[1]{%
1135 \caption@ifsubtype{#1}\@firstoftwo{\caption@ifin@list\sf@counterlist{#1}}%
1136 {\caption@Error{Should not be used with subtype `#1'}%
1137 \@gobble}%
1138 \@firstofone}
1139 % \end{macrocode}
1140 % \end{macro}
1141 %
1142 % \begin{macro}{\caption@checksubtype}
1143 % \changes{v3.4g}{2020/01/02}{This macro and its usage added}
1144 % \changes{v3.4m}{2020/07/29}{Check of \cs{sf@counterlist} from \package{subfig} package added}
1145 % |\caption@checksubtype|\marg{type}\marg{code}\par
1146 % is used by |\caption@settype| and should either expand the code or issue an error
1147 % if the given type is not a proper sub-type, i.e. not defined by |\Declare|\-|Caption|\-|Sub|\-|Type|.
1148 % Since the |sub|\-|float|\-|row| environment offered by the \package{floatrow} package\cite{floatrow}
1149 % is using |\caption|\-|setup{sub|\-|type}| even if the sub-type was defined by |\new|\-|sub|\-|float|
1150 % offered by \package{subfig}\cite{subfig}, we take a more relaxed view of things here and allow
1151 % those sub-types as well (but not without warning since we do not support this).
1152 % \begin{macrocode}
1153 \newcommand*\caption@checksubtype[1]{%
1154 \caption@ifsubtype{#1}%
1155 \@firstofone
1156 {\caption@ifin@list\sf@counterlist{#1}%
1157 {\caption@Warning{%
1158 \noexpand\setcaptionsubtype without \string\DeclareCaptionSubType.\MessageBreak
1159 This is not designed to work; you could try replacing\MessageBreak
1160 the `subfig' package with `subcaption' to resolve\MessageBreak
1161 this problem which occurred}%
1162 \@firstofone}%
1163 {\caption@Error{Undefined subtype `#1'}%
1164 \@gobble}}}
1165 % \end{macrocode}
1166 % \end{macro}
1167 %
1168 % \begin{macro}{\caption@checkgrouplevel}
1169 % \changes{v3.1}{2007/07/15}{This macro and its usage added}
1170 % \changes{v3.1f}{2007/11/28}{Error changed to warning (compatibility)}
1171 % \changes{v3.3}{2013/04/21}{Uses \cs{caption@ifeTeX} now}
1172 % \changes{v3.5}{2019/09/11}{Relies on \eTeX{} now}
1173 % Checks if |\captionsetup{type=|\ldots|}| or |\caption| is done
1174 % inside a group or not -- in the latter case a warning message will
1175 % be issued.
1176 % \begin{macrocode}
1177 \newcommand*\caption@checkgrouplevel[2]{%
1178 \@ifundefined{#1caption@grouplevel}{%
1179 \caption@ifundefined\caption@grouplevel{\let\caption@grouplevel\z@}{}%
1180 \ifnum\currentgrouplevel>\caption@grouplevel\relax
1181 \expandafter\edef\csname #1caption@grouplevel\endcsname{%
1182 \the\currentgrouplevel}%
1183 \else
1184 \caption@Warning{\string#2\MessageBreak outside box or environment}%
1185 \fi
1186 }{}}%
1187 % \end{macrocode}
1188 % \end{macro}
1189 %
1190 % \begin{macro}{\caption@undefinedlabel}
1191 % \changes{v3.1}{2007/07/03}{This macro and its usage added}
1192 % \changes{v3.1b}{2007/09/22}{Contents changed to \texttt{??}}
1193 % \changes{v3.1i}{2008/04/13}{Contents changed to \cs{caption@xref}(\ldots)}
1194 % \changes{v3.1k}{2009/03/30}{Bugfix 08-12-08: \cs{caption@xref} is robust now}
1195 % \changes{v3.2c}{2011/09/13}{Text changed from `before' to `without proper'}
1196 % \changes{v3.3}{2016/02/21}{Text changed from `without proper \cs{caption}' to `without proper reference'}
1197 % This label will be used for |\currentlabel| inside (floating) environments
1198 % as default. (see above)
1199 % \iffalse\Note{All commands used have to be robust here.}\fi
1200 % \begin{macrocode}
1201 \newcommand*\caption@undefinedlabel{%
1202 \protect\caption@xref{\caption@labelname}{\on@line}}
1203 % \end{macrocode}
1204 % \begin{macrocode}
1205 \DeclareRobustCommand*\caption@xref[2]{%
1206 \caption@WarningNoLine{\noexpand\label without proper reference#2}%
1207 \@setref\relax\@undefined{#1}}
1208 % \end{macrocode}
1209 % \begin{macrocode}
1210 \newcommand*\caption@labelname{??}
1211 % \end{macrocode}
1212 % \end{macro}
1213 % \begin{macro}{\caption@xlabel}
1214 % \changes{v3.1b}{2007/09/22}{This macro and its usage added}
1215 % \changes{v3.1f}{2007/11/11}{Revised}
1216 % \changes{v3.1i}{2008/04/13}{Bugfix: \cs{pageref} should always work now}
1217 % \changes{v3.2c}{2011/08/19}{Works with optional arguments now, too}
1218 % The new code of |\label| inside floating environments.
1219 % |\label| will be redefined using |\caption@withoptargs|, so
1220 % |#1| are the optional arguments (if any), and
1221 % |#2| is the mandatory argument here.
1222 % \begin{macrocode}
1223 \newcommand*\caption@xlabel{%
1224 \caption@withoptargs\caption@@xlabel}
1225 % \end{macrocode}
1226 % \begin{macrocode}
1227 \newcommand*\caption@@xlabel[2]{%
1228 \caption@@@xlabel
1229 \def\caption@labelname{#2}%
1230 \caption@x@label#1{#2}}
1231 % \end{macrocode}
1232 % \begin{macrocode}
1233 \newcommand*\caption@@@xlabel{%
1234 \global\let\caption@@@xlabel\@empty
1235 \@bsphack
1236 \protected@write\@auxout{}%
1237 {\string\providecommand*\string\caption@xref[2]{%
1238 \string\@setref\string\relax\string\@undefined{\string##1}}}%
1239 \@esphack}
1240 % \end{macrocode}
1241 % \end{macro}
1242 %
1243 % \begin{macro}{\captionof}
1244 % \changes{v3.1}{2007/05/09}{Uses \cs{caption@settype} instead of \cs{def}\cs{@captype}}
1245 % \changes{v3.1c}{2007/09/22}{Bugfix: Redefinition of \cs{caption@setfloatcapt} removed}
1246 % \changes{v3.1e}{2007/10/30}{Better compatibility: Will be defined with \cs{AtBeginDocument} now}
1247 % \changes{v3.2}{2010/10/24}{Bugfix 10-10-17: Uses \cs{setcaptiontype} instead of \cs{caption@settype} now}
1248 % \changes{v3.5}{2020/08/24}{Definition method adapted to the \package{caption-light} package}
1249 % |\captionof|\marg{type}\oarg{lst\_entry}\marg{heading}\\
1250 % |\captionof*|\oarg{lst\_entry}\marg{heading}\par
1251 % \Note{This will be defined with \cs{AtBeginDocument} so
1252 % \cs{usepackage}\csmarg{caption,capt-of} will still work.
1253 % (Compatibility to \version{1.x})}
1254 % \begin{macrocode}
1255 \caption@AtBeginDocument{%
1256 \def\captionof{\caption@teststar\caption@of{\caption*}\caption}}
1257 % \end{macrocode}
1258 % \begin{macrocode}
1259 \providecommand*\caption@of[2]{\setcaptiontype*{#2}#1}
1260 % \end{macrocode}
1261 % \end{macro}
1262 %
1263 % \section{\cs{captionlistentry}}
1264 %
1265 % \begin{macro}{\captionlistentry}
1266 % \changes{v3.1}{2007/07/28}{This macro added}
1267 % \changes{v3.1f}{2007/11/16}{Bugfix 07-11-09: `space hack' added}
1268 % \changes{v3.1g}{2008/01/20}{Starred variant added}
1269 % \changes{v3.1l}{2010/01/09}{Adapted to current version of nameref package}
1270 % |\captionlistentry|\oarg{float type}\marg{list entry}\\
1271 % |\captionlistentry*|\oarg{float type}\marg{list entry}
1272 % \begin{macrocode}
1273 \newcommand*\captionlistentry{%
1274 \caption@teststar\@captionlistentry\@firstoftwo\@secondoftwo}
1275 % \end{macrocode}
1276 % \begin{macrocode}
1277 \newcommand*\@captionlistentry[1]{%
1278 \@testopt{\caption@listentry{#1}}\@captype}
1279 % \end{macrocode}
1280 % \begin{macrocode}
1281 \def\caption@listentry#1[#2]#3{%
1282 \@bsphack
1283 #1{\caption@gettitle{#3}}%
1284 {\caption@refstepcounter{#2}%
1285 \caption@makecurrent{#2}{#3}}%
1286 \caption@addcontentsline{#2}{#3}%
1287 \@esphack}
1288 % \end{macrocode}
1289 % \end{macro}
1290 %
1291 % \section{\cs{captionbox}}
1292 %
1293 % \begin{macro}{\captionbox}
1294 % \changes{v3.2}{2010/12/17}{This macro added}
1295 % \changes{v3.2a}{2011/08/16}{\cs{captionsetup} replaces with \cs{captionbox@settype} and \cs{caption@setposition}}
1296 % \changes{v3.3}{2012/04/09}{Adapted to revised version of \cs{caption@withoptargs}}
1297 % \changes{v3.3}{2017/03/19}{When used with fixed witdh the content will not be hboxed anymore}
1298 % \changes{v3.3c}{2019/09/01}{Adapted so it could be used by \cs{subfloat} offered by \package{subcaption}}
1299 % \changes{v3.5}{2020/07/28}{Adapted to \package{caption3} v2.0}
1300 % A |\parbox| with contents and caption, separated by an invisible |\hrule|.
1301 % \begin{macrocode}
1302 \newcommand*\captionbox{%
1303 \caption@withoptargs{\caption@ibox\@gobble}}
1304 % \end{macrocode}
1305 % \begin{macrocode}
1306 \newcommand\caption@ibox[3]{%
1307 \kernel@ifnextchar[%]
1308 {\caption@iibox{#1}{#2}{#3}}%
1309 {\caption@iibox@{#1}{#2}{#3}}}
1310 % \end{macrocode}
1311 % \begin{macrocode}
1312 \long\def\caption@iibox#1#2#3[#4]{%
1313 \@testopt{\caption@iiibox{#1}{#2}{#3}[{#4}]}\captionbox@innerpos@default}
1314 % \end{macrocode}
1315 % \begin{macrocode}
1316 \long\def\caption@iibox@#1#2#3#4{%
1317 \setbox\@tempboxa\hbox{#4}%
1318 \caption@iiibox{#1}{#2}{#3}[\wd\@tempboxa][\captionbox@innerpos@default]{\unhbox\@tempboxa}}
1319 % \end{macrocode}
1320 % \begin{macrocode}
1321 \long\def\caption@iiibox#1{%
1322 \caption@iiiibox{#1}\vbox\vtop}
1323 % \end{macrocode}
1324 % \begin{macrocode}
1325 \long\def\caption@iiiibox#1#2#3#4#5[#6][#7]#8{%
1326 \begingroup
1327 #1*% set \caption@position
1328 \caption@iftop{%
1329 \endgroup
1330 \parbox[t]{#6}{%
1331 #1\relax
1332 \caption@setposition t%
1333 #2{\caption#4{#5}}%
1334 \captionbox@hrule
1335 \csname caption@justification@#7\endcsname
1336 #8}%
1337 }{%
1338 \endgroup
1339 \parbox[b]{#6}{%
1340 #1\relax
1341 \caption@setposition b%
1342 \csname caption@justification@#7\endcsname
1343 #8%
1344 \captionbox@hrule
1345 #3{\caption#4{#5}}}%
1346 }}
1347 % \end{macrocode}
1348 % \begin{macrocode}
1349 \newcommand*\captionbox@innerpos@default{c}
1350 \newcommand*\captionbox@hrule{\hrule\@height\z@\relax}
1351 % \end{macrocode}
1352 % \begin{macrocode}
1353 \providecommand*\caption@justification@c{\centering}
1354 \providecommand*\caption@justification@l{\raggedright}
1355 \providecommand*\caption@justification@r{\raggedleft}
1356 \providecommand*\caption@justification@s{}
1357 % \end{macrocode}
1358 % \end{macro}
1359 %
1360 % \section{\cs{continuedfloat}}
1361 %
1362 % \begin{macro}{\continuedfloat}
1363 % \changes{v3.0i}{2005/11/12}{Optional argument added}
1364 % \changes{v3.0g}{2005/06/28}{Bugfix: \cs{newcounter} replaced by \cs{newcount}}
1365 % \changes{v3.1}{2007/07/02}{Format of \package{hyperref} extension changed}
1366 % \changes{v3.1}{2007/07/07}{\cs{caption@setoptions} added}
1367 % \changes{v3.1g}{2008/01/29}{Starred variant added}
1368 % \changes{v3.2f}{2011/12/17}{Undocumented optional argument removed}
1369 % \changes{v3.3}{2011/12/28}{Uses \cs{ifcaption@ContinuedFloat} now}
1370 % \changes{v3.3}{2013/05/01}{Usage of \cs{caption@restorecounters} added}
1371 % \changes{v3.3}{2013/12/16}{Bugfix: Does not use \cs{caption@ContinuedFloat} anymore since this breaks \cs{ContinuedFloat} offered by the \package{subfig} package}
1372 % \changes{v3.4}{2015/09/16}{Renamed from \cs{ContinuedFloat} to \cs{continuedfloat}}
1373 % \changes{v3.5f}{2020/10/06}{Usage of \cs{caption@restorecounters} removed}
1374 % |\continuedfloat|\\
1375 % |\continuedfloat*|\par
1376 % This mainly sets the appropriate flag, increments the
1377 % continuation counter, and executes the given options.
1378 % Furthermore we set |\caption@reset|\-|continued|\-|float| to |\@gobble| so the
1379 % continuation counter will not be reset to zero inside |\caption@ref|\-|step|\-|counter|.\par
1380 % When the \package{hyperref} package is used we have the problem
1381 % that the usage of |\continued|\-|float| will create duplicate
1382 % hyper links -- |\@current|\-|Href| will be the same for the main float and
1383 % the continued ones. So we have to make sure unique labels and references
1384 % will be created each time. We do this by extending |\the|\-|H|\-|figure| and
1385 % |\the|\-|H|\-|table|, so for continued floats the scheme
1386 % \begin{quote}\meta{type}|.|\meta{type \#}|\alph{|\meta{continued \#}|}|\end{quote}
1387 % will be used instead of
1388 % \begin{quote}\meta{type}|.|\meta{type \#}\quad\quad.\end{quote}
1389 % \par{\small(This implementation follows an idea from Steven Douglas Cochran.)}
1390 % \Note{This does not help if the \package{hyperref} package option
1391 % \texttt{naturalnames=true} is set.}
1392 % \begin{macrocode}
1393 \def\continuedfloat{%
1394 \caption@iftype
1395 {\caption@continuedfloat\@captype}%
1396 {\caption@Error{\noexpand\continuedfloat outside float}}}
1397 % \end{macrocode}
1398 % \begin{macrocode}
1399 \newcommand*\caption@continuedfloat[1]{%
1400 \@ifstar
1401 {\caption@@refstepcounter\@captype
1402 \caption@@continuedfloat{#1}}%
1403 {\caption@continued@float{#1}}}
1404 % \end{macrocode}
1405 % \begin{macrocode}
1406 \newcommand*\caption@continued@float[1]{%
1407 \edef\caption@tempa{#1}%
1408 \ifx\caption@tempa\caption@CFtype
1409 \caption@@continuedfloat{#1}%
1410 \else
1411 \caption@Error{Continued `#1' after `\caption@CFtype'}%
1412 \fi}
1413 % \end{macrocode}
1414 % \begin{macrocode}
1415 \newcommand*\caption@@continuedfloat{%
1416 \caption@setflag1% continued float
1417 \caption@@@continuedfloat}
1418 \newcommand*\caption@@@continuedfloat{%
1419 \stepcounter{continuedfloat}%
1420 \caption@@@@continuedfloat}
1421 % \end{macrocode}
1422 % \begin{macrocode}
1423 \newcommand*\caption@@@@continuedfloat[1]{%
1424 \caption@setoptions{ContinuedFloat}% for compatibility reasons
1425 \caption@setoptions{continuedfloat}%
1426 \caption@setoptions{continued#1}%
1427 \expandafter\l@addto@macro\csname the#1\endcsname\thecontinuedfloat
1428 \@ifundefined{theH#1}{}{%
1429 \expandafter\l@addto@macro\csname theH#1\endcsname{%
1430 \@alph\c@continuedfloat}}%
1431 \let\caption@@@@continuedfloat\@gobble}
1432 % \end{macrocode}
1433 % \begin{macrocode}
1434 \newcommand*\caption@CFtype{??}
1435 % \end{macrocode}
1436 % \end{macro}
1437 %
1438 % \begin{macro}{\thecontinuedfloat}
1439 % \changes{v3.4}{2015/09/16}{Renamed from \cs{theContinuedFloat} to \cs{thecontinuedfloat}}
1440 % This one is preset to \cs{@empty}, so usually the continuation counter is not
1441 % included in the caption label or references.
1442 % \begin{macrocode}
1443 \newcounter{continuedfloat}
1444 \let\c@ContinuedFloat\c@continuedfloat % defined for compatibility reasons
1445 \def\thecontinuedfloat{\theContinuedFloat}
1446 \let\theContinuedFloat\@empty % defined for compatibility reasons
1447 % \end{macrocode}
1448 % \end{macro}
1449 %
1450 % \begin{macro}{\caption@reset@continuedfloat}
1451 % \changes{v3.2f}{2011/12/17}{Redefinition of \cs{continuedfloat} added}
1452 % |\caption@reset@continuedfloat|\marg{type}\par
1453 % If a continuation counter is defined, we reset it.
1454 % (This one will be called inside |\@caption|.)
1455 % \begin{macrocode}
1456 \newcommand*\caption@reset@continuedfloat[1]{%
1457 \xdef\caption@CFtype{#1}%
1458 \@stpelt{continuedfloat}}
1459 % \end{macrocode}
1460 % \end{macro}
1461 %
1462 % \begin{macro}{\ContinuedFloat}
1463 % For compatibility reasons we still support |\Continued|\-|Float|.
1464 % \begin{macrocode}
1465 \def\ContinuedFloat{\continuedfloat} % defined for compatibility reasons
1466 % \end{macrocode}
1467 % \end{macro}
1468 %
1469 % \begin{macro}{\caption@ContinuedFloat}
1470 % \changes{v3.0f}{2005/06/11}{This macro added}
1471 % \changes{v3.3}{2013/12/16}{Bugfix: Revised and defined with \cs{def} instead of \cs{newcommand}}
1472 % |\caption@ContinuedFloat|\marg{type}\par
1473 % This one is used by \cs{ContinuedFloat} offered by the \package{subfig} package.
1474 % \begin{macrocode}
1475 \def\caption@ContinuedFloat{%
1476 \let\caption@reset@continuedfloat\@gobble
1477 \caption@@@continuedfloat}
1478 % \end{macrocode}
1479 % \end{macro}
1480 %
1481 % \section{Internal helpers}
1482 %
1483 % \begin{macro}{\caption@refstepcounter}
1484 % \changes{v3.1}{2007/07/28}{This macro added}
1485 % \changes{v3.2}{2010/10/26}{Error message moved from \cs{caption@@@settype} to here}
1486 % \changes{v3.2c}{2011/09/04}{Support of \cs{donemaincaptiontrue} from \textsf{memoir} document class added}
1487 % \changes{v3.3}{2011/12/28}{Usage of \cs{ifcaption@caption}, \cs{ifcaption@subcaption}, and \cs{ifcaption@ContinuedFloat} added}
1488 % \changes{v3.5e}{2020/09/28}{Bugfix in re-definition of \cs{stepcounter}; uses \cs{edef} instead of \cs{def} now}
1489 % Increments the float (i.e. |figure| or |table|) counter,
1490 % resets the continuation counter, and redefines itself to |\@gobble|.
1491 % \begin{macrocode}
1492 \newcommand*\caption@refstepcounter[1]{%
1493 \@ifundefined{c@#1}%
1494 {\caption@Error{No float type '#1' defined}}%
1495 {\caption@ref@stepcounter{#1}%
1496 % \end{macrocode}
1497 % Set flag if this part of the figure (or table) contains a caption now.
1498 % (If |\caption@if|\-|top| is not set, |\caption| is at the bottom of this part,
1499 % therefore ending this part, so we set the flag to |false| in this case.)
1500 % \begin{macrocode}
1501 \caption@fixposition % TODO: Make this independant on the "position" setting
1502 \caption@iftop\caption@setflag\caption@clrflag2% caption
1503 % \end{macrocode}
1504 % This part does not contain content (like sub-figures) yet,
1505 % so we set |\if|\-|caption@sub|\-|caption| to |false|.
1506 % \begin{macrocode}
1507 \caption@clrflag4% subcaption
1508 % \end{macrocode}
1509 % Support of the \textsf{memoir} document class.
1510 % \begin{macrocode}
1511 \@nameuse{donemaincaptiontrue}}}
1512 % \end{macrocode}
1513 % \begin{macrocode}
1514 \newcommand*\caption@ref@stepcounter{%
1515 \caption@ifflag1{% continued float
1516 \let\caption@tempa\caption@@refcounter
1517 \caption@clrflag1% continued float
1518 }{%
1519 \let\caption@tempa\caption@@refstepcounter
1520 \caption@ifflag2{}{% caption
1521 \caption@ifflag4{% subcaption
1522 % Counter was already incremented by content, so we suppress \stepcounter{#1} here
1523 \let\caption@tempa\caption@@refcounter
1524 }{}%
1525 }%
1526 }%
1527 \caption@tempa}
1528 % \end{macrocode}
1529 % \begin{macrocode}
1530 \newcommand*\caption@@refcounter[1]{%
1531 \let\caption@stepcounter@ORI\stepcounter
1532 \def\stepcounter##1{%
1533 \edef\caption@tempa{#1}%
1534 \edef\caption@tempb{##1}%
1535 \ifx\caption@tempa\caption@tempb \else
1536 \caption@stepcounter@ORI{##1}%
1537 \fi}%
1538 \caption@@@refstepcounter{#1}%
1539 \let\stepcounter\caption@stepcounter@ORI}
1540 % \end{macrocode}
1541 % \begin{macrocode}
1542 \newcommand*\caption@@refstepcounter[1]{%
1543 \caption@prepare@stepcounter{#1}{ref}%
1544 \caption@@@refstepcounter{#1}}
1545 % \end{macrocode}
1546 % \begin{macrocode}
1547 \newcommand*\caption@@stepcounter[1]{%
1548 \caption@prepare@stepcounter{#1}{}%
1549 \caption@@@stepcounter{#1}}
1550 % \end{macrocode}
1551 % \begin{macrocode}
1552 \newcommand*\caption@prepare@stepcounter[2]{%
1553 \caption@addsubcontentslines{#2stepcounter}%
1554 \caption@reset@continuedfloat{#1}}
1555 % \end{macrocode}
1556 % \begin{macrocode}
1557 \newcommand*\caption@@@refstepcounter{\refstepcounter}
1558 % \end{macrocode}
1559 % \begin{macrocode}
1560 \newcommand*\caption@@@stepcounter{\stepcounter}
1561 % \end{macrocode}
1562 % \end{macro}
1563 %
1564 % \begin{macro}{\caption@dblarg}
1565 % \changes{v3.1}{2007/02/05}{This macro added}
1566 % \changes{v3.1f}{2007/12/06}{Bugfix 07-12-06: Changed so it works without \cs{kernel@ifnextchar} (which was introduced in \LaTeXe\ 2004/01/23), too}
1567 % \changes{v3.3}{2012/03/25}{Support of option \opt{list-entry} added}
1568 % A |\relax| was added compared to |\@dblarg| so |\caption{}| will be
1569 % expanded to |\caption[\relax]{}| (and not to |\caption[]{}|).
1570 % Furthermore support for option \opt{list-entry} was added.
1571 % \begin{macrocode}
1572 \@ifundefined{kernel@ifnextchar}{\let\kernel@ifnextchar\@ifnextchar}{}
1573 % \end{macrocode}
1574 % \begin{macrocode}
1575 \newcommand\caption@dblarg[1]{%
1576 \kernel@ifnextchar[{\caption@ydblarg{#1}}{\caption@xdblarg{#1}}}
1577 % \end{macrocode}
1578 % \begin{macrocode}
1579 \newcommand\caption@xdblarg[2]{%
1580 #1[{#2\relax}]{#2}}
1581 % \end{macrocode}
1582 % \begin{macrocode}
1583 \long\def\caption@ydblarg#1[#2]#3{%
1584 \caption@iflistheading{#1[{#3}]{#3}}{#1[{#2}]{#3}}}
1585 % \end{macrocode}
1586 % \end{macro}
1587 %
1588 % \begin{macro}{\caption@begin}
1589 % \changes{v3.0a}{2004/01/23}{\cs{caption@settype} changed to \cs{caption@setfloattype}}
1590 % \changes{v3.0e}{2005/04/12}{Check for default label format added}
1591 % \changes{v3.0f}{2005/06/11}{Usage of \cs{caption@resetContinuedFloat} added}
1592 % \changes{v3.1}{2007/05/09}{Usage of \cs{caption@setfloattype} \& \cs{caption@resetContinuedFloat} removed}
1593 % \changes{v3.3}{2011/12/29}{Usage of \cs{caption@fixedposition} removed}
1594 % Our handling of |\caption| will always be surrounded by
1595 % |\caption@begin| (or |\caption@beginex|) and |\caption@end|.\par
1596 % |\caption@begin|\marg{type} performs these tasks:
1597 % \begin{enumerate}
1598 % \item[1.] Override the |position=| setting, if necessary.
1599 % (for example if set to |auto| or used inside a |supertabular|)
1600 % \item[2.] Start a new group.
1601 % \item[3.] Define |\fnum@|\meta{type} if the caption label format is set
1602 % to non-default.
1603 % \end{enumerate}
1604 % \begin{macrocode}
1605 \newcommand*\caption@begin[1]{%
1606 \caption@fixposition
1607 \begingroup
1608 \caption@setfnum{#1}}
1609 % \end{macrocode}
1610 % \end{macro}
1611 %
1612 % \begin{macro}{\caption@beginex}
1613 % \changes{v3.0b}{2004/05/16}{Support of \opt{listof=} added}
1614 % \changes{v3.0l}{2007/02/04}{Takes now 3 args instead of 2, check for empty heading added}
1615 % \changes{v3.1}{2007/07/01}{Makes lst-entry now instead of redefining \cs{addcontentsline}}
1616 % \changes{v3.2}{2010/10/26}{Bugfix 09-05-15: Setting of \cs{lst@@caption} added}
1617 % \changes{v3.5h}{2022/03/01}{Hook added, setting of \cs{lst@@caption} removed}
1618 % |\caption@beginex|\marg{type}\marg{list entry}\marg{heading}\par
1619 % performs the same tasks as |\caption@begin| and additionally:
1620 % \begin{enumerate}
1621 % \item[4.] Apply the hook |\caption@beginex@hook|
1622 % \item[5.] Make an entry in the list-of-whatever.
1623 % \item[6.] Set |\caption@ifempty| according argument \meta{heading}.
1624 % \end{enumerate}
1625 % \begin{macrocode}
1626 \newcommand\caption@beginex[3]{%
1627 \caption@begin{#1}%
1628 \caption@beginex@hook
1629 \caption@addcontentsline{#1}{#2}%
1630 \caption@ifempty{#3}{}}
1631 % \end{macrocode}
1632 % \begin{macrocode}
1633 \newcommand*\caption@beginex@hook{}
1634 % \end{macrocode}
1635 % \end{macro}
1636 %
1637 % \begin{macro}{\caption@end}
1638 % \changes{v3.3}{2011/12/29}{Usage of \cs{caption@fixedposition} removed}
1639 % |\caption@end| closes the group.
1640 % \begin{macrocode}
1641 \newcommand*\caption@end{%
1642 \endgroup}
1643 % \end{macrocode}
1644 % \end{macro}
1645 %
1646 % \changes{v3.0a}{2004/01/23}{Internal hooks \cs{caption@@begin} \& \cs{caption@@end} added}
1647 % \changes{v3.0h}{2005/10/06}{Internal hooks \cs{caption@@begin} \& \cs{caption@@end} removed}
1648 %
1649 % \begin{macro}{\caption@setfnum}
1650 % \changes{v3.1}{2007/03/10}{This macro added}
1651 % \changes{v3.5}{2020/08/03}{Adapted to \package{caption3} v2.0}
1652 % |\caption@setfnum|\marg{type}\\
1653 % stores the original definition of |\fnum@|\meta{type} in |\caption@fnum@|\meta{type}
1654 % and re-defines it according the caption label format set with |label|\-|format=|.
1655 % \begin{macrocode}
1656 \newcommand*\caption@setfnum[1]{%
1657 \@ifundefined{caption@fnum@#1}%
1658 {\expandafter\let\csname caption@fnum@#1\expandafter\endcsname\csname fnum@#1\endcsname
1659 \@namedef{fnum@#1}{\caption@fnum{#1}}}%
1660 {}}
1661 % \end{macrocode}
1662 % \end{macro}
1663 %
1664 % \begin{macro}{\caption@normalsize}
1665 % \changes{v3.1}{2007/05/05}{This macro and its usage added}
1666 % \changes{v3.5}{2020/07/27}{Adapted to \package{caption3} v2.0}
1667 % This one will be used by |\@caption| instead of |\normalsize|.
1668 % \begin{macrocode}
1669 \newcommand*\caption@normalsize{%
1670 \caption@font@normal\@unused}
1671 % \end{macrocode}
1672 % \end{macro}
1673 %
1674 % \begin{macro}{\caption@setfloatcapt}
1675 % Needed for support of the \package{float} package, where the caption will
1676 % not be typeset directly, but catched in a |\vbox| called |\@floatcapt|
1677 % instead.
1678 % \begin{macrocode}
1679 \let\caption@setfloatcapt\@firstofone
1680 % \end{macrocode}
1681 % \end{macro}
1682 %
1683 % \begin{macro}{\caption@makecurrent}
1684 % This one is needed for support of the \package{nameref} and \package{hyperref} package.
1685 % \changes{v3.2f}{2012/01/14}{Bugfix: Usage of \cs{caption@gettitle} added}
1686 % \begin{macrocode}
1687 \newcommand*\caption@makecurrent[1]{\caption@gettitle}
1688 % \end{macrocode}
1689 % \end{macro}
1690 %
1691 % \begin{macro}{\caption@makeanchor}
1692 % \begin{macro}{\caption@start}
1693 % \begin{macro}{\caption@@start}
1694 % \begin{macro}{\caption@freezeHref}
1695 % \begin{macro}{\caption@defrostHref}
1696 % All these are needed for support of the \package{hyperref} package.
1697 % \begin{macrocode}
1698 \let\caption@makeanchor\@firstofone
1699 \let\caption@start\relax
1700 \let\caption@@start\relax
1701 \let\caption@freezeHref\relax
1702 \let\caption@defrostHref\relax
1703 % \end{macrocode}
1704 % \end{macro}
1705 % \end{macro}
1706 % \end{macro}
1707 % \end{macro}
1708 % \end{macro}
1709 %
1710 % \begin{macro}{\caption@gettitle}
1711 % \changes{v3.1l}{2010/01/09}{This macro and its usage added to adapt the definition of \cs{@currentlabelname} to recent versions of \package{nameref}}
1712 % \changes{v3.5j}{2023/08/05}{Support for older versions of \package{nameref} revised to make it compatible with \LaTeX\ 2023-06-01}
1713 % This one is needed for support of the \package{nameref} package.
1714 % \begin{macrocode}
1715 \newcommand\caption@gettitle[1]{%
1716 \caption@ifdefined\NR@gettitle
1717 {\NR@gettitle{#1}}% % support for recent versions of nameref package
1718 {\caption@ifdefined\NR@sect{\def\@currentlabelname{#1}}{}}} % support for older versions of nameref package
1719 % \end{macrocode}
1720 % \end{macro}
1721 %
1722 % \section{Support for sub-captions}
1723 % \changes{v3.1f}{2007/11/16}{Support for sub-captions added}
1724 %
1725 % \begin{macro}{\caption@subtypehook}
1726 % \changes{v3.1g}{2008/03/20}{Redefinition of \cs{caption@setlist} added}
1727 % \changes{v3.1k}{2009/10/09}{Bugfix 09-08-12b: \cs{@makecaption} will now be restored here, too}
1728 % \changes{v3.2}{2011/06/26}{Uses \cs{caption@@addcontentsline} instead of \cs{addcontentsline} now}
1729 % \changes{v3.2a}{2011/08/17}{Redefinition of \cs{phantomcaption} added}
1730 % \changes{v3.2a}{2011/08/17}{Usage of \cs{caption@warmup} added}
1731 % \changes{v3.2c}{2011/09/30}{Bugfix 11-09-26: Usage of \cs{if@subfloatrow} added}
1732 % \changes{v3.3}{2011/12/28}{Bugfix 11-12-16: \cs{caption@l@stepcounter} replaced by \cs{stepcounter}}
1733 % \changes{v3.3}{2012/03/15}{Usage of \cs{caption@setbox} added}
1734 % \changes{v3.3}{2013/05/01}{Redefinition of \cs{caption@settype} added}
1735 % \changes{v3.3}{2013/06/17}{Missing redefinition of \cs{captionlistentry} added}
1736 % \changes{v3.3}{2018/09/06}{Adapted to the \package{chkfloat} package}
1737 % \changes{v3.4f}{2020/01/03}{Redefinition of \cs{@caption} added since it was redefined by the \env{threeparttable} environment}
1738 % \changes{v3.5}{2020/07/27}{Adapted to \package{caption3} v2.0}
1739 % Hook, will be used inside \cs{caption@setsubtype}.\par
1740 % (Note: If we are inside an |sub|\-|float|\-|row| environment we have to keep
1741 % the |\@make|\-|caption| code of the \package{floatrow} package intact.)
1742 % \begin{macrocode}
1743 \newcommand*\caption@subtypehook{%
1744 \ifx\caption\caption@subcaption \else
1745 \caption@warmup
1746 % \end{macrocode}
1747 % \begin{macrocode}
1748 \caption@ifflag2{}{% caption
1749 % no \caption in this part of the (floating) environment yet
1750 \let\caption@add@contentsline\caption@addsubcontentsline
1751 \let\caption@addsubcontentslines\@gobble
1752 \caption@ifflag4{}{% subcaption
1753 % no \subcaption in this part of the (floating) environment yet
1754 \caption@ifflag1{% continued float
1755 \caption@clrflag1%
1756 }{%
1757 \caption@@stepcounter\@captype
1758 }%
1759 \caption@setflag4% subcaption
1760 }%
1761 }%
1762 % \end{macrocode}
1763 % \begin{macrocode}
1764 \c@continuedfloat=0\relax
1765 \let\caption@setfloatcapt\@firstofone
1766 \let\caption@chkfloat\@gobbletwo
1767 % \end{macrocode}
1768 % \begin{macrocode}
1769 \caption@set{box}{none}%
1770 \caption@clearmargin
1771 \caption@iflist{}{\let\caption@setlist\@gobble}%
1772 \caption@setoptions{sub}%
1773 \caption@setoptions{subfloat}% for subfig-package compatibility
1774 % \end{macrocode}
1775 % \begin{macrocode}
1776 % redefine \setcaptiontype
1777 \def\caption@settype{\caption@withoptargs\caption@sub@settype}%
1778 \def\caption@sub@settype##1##2{%
1779 \edef\caption@tempa{##2}%
1780 \ifx\caption@tempa\@captype
1781 %%% \caption@setsubtype##1\relax
1782 \else
1783 \caption@Error{##2 inside \@subcaptype}%
1784 \fi}%
1785 % \end{macrocode}
1786 % \begin{macrocode}
1787 % redefine \caption
1788 \let\caption\caption@subcaption
1789 \let\@caption\caption@@caption
1790 \let\phantomcaption\caption@subphantom
1791 \let\captionlistentry\caption@sublistentry
1792 % \let\@captype\@subcaptype
1793 \let\caption@refstepcounter\caption@@@refstepcounter
1794 % \end{macrocode}
1795 % \begin{macrocode}
1796 % restore \@makecaption
1797 \if@subfloatrow
1798 \caption@Debug{Keeping \string\@makecaption}%
1799 \else
1800 \let\@makecaption\caption@makecaption
1801 \fi
1802 \fi}%
1803 % \end{macrocode}
1804 % \end{macro}
1805 %
1806 % \begin{macro}{\if@subfloatrow}
1807 % \changes{v3.2c}{2011/09/30}{This macro added}
1808 % This macro tests if we are inside an |sub|\-|float|\-|row| or |sub|\-|float|\-|row*| environment.
1809 % \begin{macrocode}
1810 \caption@AtBeginDocument{%
1811 \caption@ifundefined\@subfloatrowtrue
1812 {\newif\if@subfloatrow
1813 \caption@ifundefined\subfloatrow
1814 {}%
1815 {\caption@Debug{Patching subfloatrow environment}%
1816 \g@addto@macro\capsubrowsettings{\@subfloatrowtrue}%
1817 \g@addto@macro\killfloatstyle{%
1818 \ifx\c@FRobj\c@FRsobj\@subfloatrowtrue\fi}}}%
1819 {\caption@Debug{\string\if@subfloatrow is already defined}}}%
1820 % \end{macrocode}
1821 % \end{macro}
1822 %
1823 % \begin{macro}{\caption@subcaption}
1824 % Makes a sub-caption.
1825 % \begin{macrocode}
1826 \newcommand*\caption@subcaption{%
1827 \caption@checkgrouplevel{sub}\subcaption
1828 \caption@star
1829 {\caption@refstepcounter\@subcaptype}%
1830 {\caption@dblarg{\@caption\@subcaptype}}}
1831 % \end{macrocode}
1832 % \end{macro}
1833 %
1834 % \begin{macro}{\caption@subphantom}
1835 % \changes{v3.2a}{2011/08/17}{This macro added}
1836 % Same as |\phantomcaption|, but for sub-captions.
1837 % \begin{macrocode}
1838 \newcommand*\caption@subphantom{%
1839 \caption@checkgrouplevel{sub}\phantomsubcaption
1840 \caption@refstepcounter\@subcaptype}
1841 % \end{macrocode}
1842 % \end{macro}
1843 %
1844 % \begin{macro}{\caption@sublistentry}
1845 % \changes{v3.3}{2013/06/17}{This macro added}
1846 % Same as |\captionlistentry|, but for sub-captions.
1847 % \begin{macrocode}
1848 \newcommand*\caption@sublistentry{%
1849 \caption@teststar\@subcaptionlistentry\@firstoftwo\@secondoftwo}
1850 % \end{macrocode}
1851 % \begin{macrocode}
1852 \newcommand*\@subcaptionlistentry[1]{%
1853 \@testopt{\caption@listentry{#1}}\@subcaptype}
1854 % \end{macrocode}
1855 % \end{macro}
1856 %
1857 % \begin{macro}{caption@clearsubcontentslines}
1858 % Clear pending sub-caption list entries.
1859 % \begin{macrocode}
1860 \newcommand*\caption@clearsubcontentslines{%
1861 \global\let\caption@subcontentslines\@empty}
1862 % \end{macrocode}
1863 % \begin{macrocode}
1864 \caption@clearsubcontentslines
1865 % \end{macrocode}
1866 % \end{macro}
1867 %
1868 % \begin{macro}{\caption@addsubcontentsline}
1869 % \changes{v3.1i}{2008/08/02}{\cs{label}, \cs{index}, and \cs{glossary} are allowed inside the list entry now}
1870 % \changes{v3.2}{2011/06/26}{Uses \cs{caption@@addcontentsline} instead of \cs{addcontentsline} now}
1871 % \changes{v3.2c}{2011/08/19}{Uses \cs{caption@gobble} instead of \cs{@gobble} now}
1872 % \changes{v3.3}{2012/01/15}{Debug message added}
1873 % \changes{v3.3}{2013/03/10}{A single \cs{protect} replaced by \cs{noexpand}}
1874 % Add a pending sub-caption list entry.
1875 % \begin{macrocode}
1876 \newcommand*\caption@addsubcontentsline[4]{%
1877 \caption@Debug{\string\caption@addsubcontentsline{#1}{#2}}%
1878 \begingroup
1879 \let\label\caption@gobble
1880 \let\index\caption@gobble
1881 \let\glossary\caption@gobble
1882 \protected@edef\@tempa{\endgroup
1883 \noexpand\g@addto@macro\noexpand\caption@subcontentslines{%
1884 \noexpand\@namedef{the#2}{\csname the#2\endcsname}%
1885 \ifx\@currentHref\@undefined \else
1886 \noexpand\def\noexpand\@currentHref{\@currentHref}%
1887 \fi
1888 \noexpand\caption@@@addcontentsline{#1}{#2}{#3}{#4}}}%
1889 \@tempa}
1890 % \end{macrocode}
1891 % \end{macro}
1892 %
1893 % \begin{macro}{\flushsubcaptionlistentries}
1894 % \changes{v3.3}{2012/01/15}{Renamed from \cs{caption@addsubcontentslines} to \cs{flushsubcaptionlistentries}}
1895 % \changes{v3.3}{2013/03/10}{Bugfix: Missing redefinition of \cs{caption@addsubcontentslines} added}
1896 % Writes pending sub-caption list entries.
1897 % \begin{macrocode}
1898 \newcommand*\flushsubcaptionlistentries{%
1899 \caption@addsubcontentslines{user}}
1900 % \end{macrocode}
1901 % \begin{macrocode}
1902 \renewcommand*\caption@addsubcontentslines[1]{%
1903 \caption@Debug{\string\flushsubcaptionlistentries (#1)}%
1904 \begingroup
1905 \caption@subcontentslines
1906 \endgroup
1907 \caption@clearsubcontentslines}
1908 % \end{macrocode}
1909 % We need to patch \cs{chapter} otherwise a vertical gap will be inserted into
1910 % the list prior pending sub-caption list entries.
1911 % We do this |\At|\-|Begin|\-|Document| so packages like \package{newfloat}
1912 % will not complain about an unknown document class.
1913 % \begin{macrocode}
1914 \AtBeginDocument{%
1915 % \end{macrocode}
1916 % \begin{macrocode}
1917 \caption@ifdefined\chapter{%
1918 \let\caption@chapter@ORI\chapter
1919 \def\chapter{%
1920 \caption@addsubcontentslines{chapter}\caption@chapter@ORI}}{}%
1921 % \end{macrocode}
1922 % Same for \cs{appendix}.
1923 % \begin{macrocode}
1924 \caption@ifdefined\appendix{%
1925 \let\caption@appendix@ORI\appendix
1926 \def\appendix{%
1927 \caption@addsubcontentslines{appendix}\caption@appendix@ORI}}{}%
1928 % \end{macrocode}
1929 % Flush the list of pending sub-caption list entries at the end of the document.
1930 % \begin{macrocode}
1931 \caption@addsubcontentslines{AtEndDocument}%
1932 % \end{macrocode}
1933 % \begin{macrocode}
1934 }
1935 % \end{macrocode}
1936 % \end{macro}
1937 %
1938 % \section{Babel package support}
1939 %
1940 % \subsection{The arabic \& farsi babel option}
1941 % \changes{v3.5}{2020/08/02}{\package{arabic} babel support addded}
1942 %
1943 % \begin{macrocode}
1944 \caption@IfBabelArabi{%
1945 % \end{macrocode}
1946 %
1947 % The \package{arabicore} package re-defines |\@make|\-|caption|, |\fnum@figure|, and |\fnum@table|
1948 % incompatible to the \package{caption} package, therefore we have to restore our resp.~the original definitions here.
1949 %
1950 % \begin{macrocode}
1951 \let\@makecaption\caption@makecaption
1952 \def\fnum@figure{\figurename\nobreakspace\thefigure}%
1953 \def\fnum@table{\tablename\nobreakspace\thetable}%
1954 % \end{macrocode}
1955 %
1956 % \begin{macrocode}
1957 }{}
1958 % \end{macrocode}
1959 %
1960 % \subsection{The frenchle \& frenchpro package}
1961 % \changes{v3.0h}{2005/10/03}{\package{frenchle/pro} package support added}
1962 % \changes{v3.5}{2020/08/01}{\package{frenchle/pro} package support updated}
1963 %
1964 % \begin{macrocode}
1965 \caption@IfFrenchLe{%
1966 % \end{macrocode}
1967 %
1968 % \begin{macro}{\f@ffrench}
1969 % \begin{macro}{\f@tfrench}
1970 % |\f@ffrench| and |\f@tfrench| reflect |\fnum@figure| and |\fnum@table|
1971 % when used in French mode. These contain additional code which typesets
1972 % the caption separator |\caption|\-|separator| instead of the usual colon.
1973 % Because this breaks with our |\@make|\-|caption| code we have to remove
1974 % this additional code here.
1975 % \begin{macrocode}
1976 \def\f@ffrench{\ifx\listoffigures\relax\else\figurename~\thefigure\fi}%
1977 \def\f@tfrench{\ifx\listoftables\relax\else\tablename~\thetable\fi}%
1978 \let\@eatDP\@undefined
1979 % \end{macrocode}
1980 % \end{macro}
1981 % \end{macro}
1982 %
1983 % Since the \package{frenchle} package overwrites |\@make|\-|caption| (within |\GO|\-|french|),
1984 % we need to save it beforehand and restore it afterwards.
1985 % \begin{macrocode}
1986 \caption@AtBeginDocument{%
1987 \let\caption@original@makecaption\@makecaption}%
1988 \g@addto@macro\GOfrench{%
1989 \let\@makecaption\caption@original@makecaption}%
1990 % \end{macrocode}
1991 %
1992 % \begin{macrocode}
1993 }{}
1994 % \end{macrocode}
1995 %
1996 % \subsection{The hungarian \& magyar babel option}
1997 % \changes{v3.2}{2009/03/29}{\package{magyar} babel support added}
1998 % \changes{v3.3}{2018/08/26}{\package{magyar} babel support revised}
1999 % \changes{v3.5}{2020/08/02}{\package{magyar} babel support updated}
2000 %
2001 % \begin{macrocode}
2002 \caption@IfBabelHungarian{%
2003 % \end{macrocode}
2004 %
2005 % Since the \package{magyar} package tends to overwrite |\@make|\-|caption|
2006 % we save it beforehand and restore it afterwards.
2007 % \Note{Currently it will not be overwritten, caused by a side-effect of a
2008 % work-around for the \package{floatrow} package within \package{caption3}.}
2009 %
2010 % \begin{macrocode}
2011 \caption@AtBeginDocument{%
2012 \let\caption@original@makecaption\@makecaption}%
2013 \caption@ifdefined\extrashungarian{%
2014 \addto\extrashungarian{%
2015 \let\@makecaption\caption@original@makecaption}}{}%
2016 \caption@ifdefined\extrasmagyar{%
2017 \addto\extrasmagyar{%
2018 \let\@makecaption\caption@original@makecaption}}{}%
2019 % \end{macrocode}
2020 %
2021 % \begin{macrocode}
2022 }{}
2023 % \end{macrocode}
2024 %
2025 % \subsection{The latvian babel option}
2026 % \changes{v3.5}{2020/08/02}{\package{latvian} babel support updated}
2027 %
2028 % \begin{macrocode}
2029 \caption@IfBabelLatvian{%
2030 % \end{macrocode}
2031 %
2032 % The \package{latvian} package re-defines |\@make|\-|caption| incompatible to the \package{caption} package,
2033 % therefore we have to restore our definitions here.
2034 %
2035 % \begin{macrocode}
2036 \let\@makecaption\caption@makecaption
2037 % \end{macrocode}
2038 %
2039 % \begin{macrocode}
2040 }{}
2041 % \end{macrocode}
2042 %
2043 % \section{Package support}
2044 % \changes{v3.1}{2007/04/11}{Package options `float', `longtable' etc.~are not supported anymore, removed}
2045 %
2046 % \begin{macro}{\caption@IfPackageLoaded}
2047 % \changes{v3.0f}{2005/05/29}{3rd argument \meta{code} added, so no extra check is needed}
2048 % \changes{v3.1}{2007/07/04}{Re-written \& renamed from \cs{caption@ifpackage} to \cs{caption@IfPackageLoaded}}
2049 % \changes{v3.3}{2018/12/26}{Bugfix: Missing curly braces added}
2050 % |\caption@IfPackageLoaded|\marg{package}\oarg{version}\marg{true}\marg{false}\par
2051 % Some kind of combination of |\@ifpackageloaded| and |\@ifpackagelater|.
2052 % If the \meta{package} is not loaded yet, the check will be (re-)done
2053 % |\AtBeginDocument|, so the \meta{package} could be loaded later on, too.
2054 % \begin{macrocode}
2055 \newcommand\caption@IfPackageLoaded[1]{%
2056 \@testopt{\caption@@IfPackageLoaded{#1}}{}}
2057 \@onlypreamble\caption@IfPackageLoaded
2058 % \end{macrocode}
2059 % \begin{macrocode}
2060 \long\def\caption@@IfPackageLoaded#1[#2]#3#4{%
2061 \@ifpackageloaded{#1}\@firstofone{%
2062 \caption@Debug{#1 package is not loaded (yet)\@gobble}%
2063 \caption@AtBeginDocument}{%
2064 \caption@If@Package@Loaded{#1}[{#2}]{#3}{#4}}}
2065 \@onlypreamble\caption@@IfPackageLoaded
2066 % \end{macrocode}
2067 % \begin{macrocode}
2068 \long\def\caption@If@Package@Loaded#1[#2]{%
2069 \@ifpackageloaded{#1}{%
2070 \caption@InfoNoLine{#1 package is loaded}%
2071 \@ifpackagelater{#1}{#2}\@firstoftwo{%
2072 \caption@Error{%
2073 For a successful cooperation we need at least version\MessageBreak
2074 `#2' of package #1,\MessageBreak
2075 but only version\MessageBreak
2076 `\csname ver@#1.\@pkgextension\endcsname'\MessageBreak
2077 is available}%
2078 \@secondoftwo}%
2079 }{\@secondoftwo}}
2080 \@onlypreamble\caption@If@Package@Loaded
2081 % \end{macrocode}
2082 % \end{macro}
2083 %
2084 % \begin{macro}{\caption@clearmargin}
2085 % \changes{v3.1}{2007/05/05}{This macro and its usage added}
2086 % This macro will be used by some package support stuff where the usual
2087 % margin setting is not welcome, e.g. in the \package{sidecap} package.
2088 % \begin{macrocode}
2089 \newcommand*\caption@clearmargin{%
2090 \setcaptionmargin\z@
2091 \let\caption@minmargin\@undefined}
2092 % \end{macrocode}
2093 % \end{macro}
2094 %
2095 % \begin{macrocode}
2096 \caption@setbool{needfreeze}{0}
2097 \caption@AtBeginDocument*{%
2098 \caption@ifneedfreeze{%
2099 % \end{macrocode}
2100 %
2101 % \begin{macro}{\caption@freezetype}
2102 % \changes{v3.3}{2013/05/01}{This macro added}
2103 % |\caption@freezetype|\marg{type}\par
2104 % Used by the \package{fltpage} \& \package{sidecap} package support.
2105 % \begin{macrocode}
2106 \newcommand*\caption@freezetype[1]{%
2107 \caption@settype*{#1}%
2108 \captionsetup*[sub]{hypcap=true}% Note: This is just a (q&d) workaround!
2109 \caption@freeze}%
2110 % \end{macrocode}
2111 % \end{macro}
2112 %
2113 % \begin{macro}{\caption@freeze}
2114 % \changes{v3.1}{2007/07/22}{This macro added}
2115 % \changes{v3.1c}{2007/10/06}{\cs{caption} \& \cs{@caption} revised for enhanced compatibility}
2116 % \changes{v3.1c}{2007/10/06}{Bugfix: Made \cs{@caption} long}
2117 % \changes{v3.1f}{2007/11/16}{Uses `space hack' instead of \cs{ignorespaces} now}
2118 % \changes{v3.1g}{2008/01/29}{Starred variants of \cs{ContinuedFloat} and \cs{captionsetup} added}
2119 % \changes{v3.2}{2010/10/26}{Bugfix 10-09-01a: Uses \cs{ignorespaces} instead of `space hack' again}
2120 % \changes{v3.2a}{2011/08/17}{Starred variant of \cs{caption@freeze} removed}
2121 % \changes{v3.2b}{2011/08/18}{Redefines \cs{caption@setup} instead of \cs{captionsetup} now}
2122 % \changes{v3.2b}{2011/08/18}{Redefinition of \cs{label} revised}
2123 % \changes{v3.2c}{2011/08/21}{Revised}
2124 % \changes{v3.3}{2013/01/06}{Adapted to new switch \cs{caption@caption} etc.}
2125 % |\caption@freeze|\par
2126 % Used by the \package{bicaption} package.
2127 % \begin{macrocode}
2128 \newcommand*\caption@freeze{%
2129 \let\caption@frozen@continuedfloat\continuedfloat
2130 \def\continuedfloat{%
2131 \caption@@freeze{\caption@@@@continuedfloat\@captype}%
2132 \caption@frozen@continuedfloat}%
2133 % \end{macrocode}
2134 % \begin{macrocode}
2135 \let\caption@frozen@setup\caption@setup
2136 \def\caption@setup##1{%
2137 \caption@@freeze{\caption@setup{##1}}%
2138 \caption@frozen@setup{##1}}%
2139 % \end{macrocode}
2140 % \begin{macrocode}
2141 \let\caption@frozen@caption\caption
2142 \def\caption{%
2143 \def\caption{%
2144 \caption@Error{%
2145 Only one \noexpand\caption can be placed in this environment}%
2146 \caption@gobble}%
2147 \@ifstar
2148 {\caption@SC@caption*}%
2149 {\let\@currentlabel\caption@SClabel
2150 \caption@withoptargs\caption@SC@caption}}%
2151 \long\def\caption@SC@caption##1##2{%
2152 \caption@@freeze{\caption##1{##2}}%
2153 \ignorespaces}%
2154 % \end{macrocode}
2155 % \begin{macrocode}
2156 \let\caption@frozen@label\label
2157 \def\label{%
2158 \caption@withoptargs\caption@SC@label}%
2159 \def\caption@SC@label##1##2{%
2160 \ifx\@currentlabel\caption@SClabel
2161 \@bsphack
2162 \caption@freeze@label{##1}{##2}%
2163 \@esphack
2164 \else
2165 \caption@frozen@label##1{##2}%
2166 \fi}%
2167 \def\caption@SClabel{\caption@undefinedlabel}%
2168 \def\caption@freeze@label##1##2{%
2169 \caption@@freeze{\label##1{##2}}}%
2170 % \end{macrocode}
2171 % \begin{macrocode}
2172 \global\let\caption@frozen@content\@empty
2173 \long\def\caption@@freeze{%
2174 \g@addto@macro\caption@frozen@content}%
2175 % \end{macrocode}
2176 % \begin{macrocode}
2177 \def\caption@warmup{%
2178 \let\continuedfloat\caption@frozen@continuedfloat
2179 \let\caption@setup\caption@frozen@setup
2180 \let\caption\caption@frozen@caption
2181 \let\label\caption@frozen@label}}%
2182 % \end{macrocode}
2183 % \end{macro}
2184 %
2185 % \begin{macro}{\caption@prepare@defrost}
2186 % \changes{v3.3}{2013/01/06}{This macro added}
2187 % Prevent resetting the caption flags
2188 % \begin{macrocode}
2189 \newcommand*\caption@prepare@defrost{%
2190 \let\caption@settype\caption@set@type}
2191 % \end{macrocode}
2192 % \end{macro}
2193 %
2194 % \begin{macro}{\caption@defrost}
2195 % \changes{v3.1}{2007/07/22}{This macro added}
2196 % \changes{v3.1g}{2008/01/30}{\cs{caption@defrost@setup} added}
2197 % \changes{v3.2c}{2011/08/21}{Adapted to changes of \cs{caption@freeze}}
2198 % \changes{v3.2c}{2011/08/21}{\cs{caption@defrost@setup} removed}
2199 % |\caption@defrost|
2200 % \begin{macrocode}
2201 \newcommand*\caption@defrost{%
2202 \ifx\caption@frozen@caption\@undefined
2203 \caption@frozen@content
2204 \else
2205 \caption@Error{Internal Error:\MessageBreak
2206 \noexpand\caption@defrost in same group as \string\caption@freeze}%
2207 \fi}%
2208 % \end{macrocode}
2209 % \end{macro}
2210 %
2211 % \begin{macrocode}
2212 }{}%
2213 \caption@undefbool{needfreeze}}
2214 % \end{macrocode}
2215 %
2216 % \begin{macro}{\caption@warmup}
2217 % \changes{v3.2a}{2011/08/17}{This macro added}
2218 % |\caption@warmup|
2219 % \begin{macrocode}
2220 \let\caption@warmup\relax
2221 % \end{macrocode}
2222 % \end{macro}
2223 %
2224 % \subsection{The changepage package}
2225 % \changes{v3.4k}{2020/05/30}{Patch of the \package{changepage} package added}
2226 %
2227 % \begin{macrocode}
2228 \caption@IfPackageLoaded{changepage}[2008/07/23 memoir-v3.7k]{%
2229 % \end{macrocode}
2230 %
2231 % Both environments, \env{adjustwidth} and \env{adjustwidth*}, are starting a \env{list} \cs{item}.
2232 % But \cs{hsize} isn't set properly inside a \env{list} item, and therefore \cs{@makecaption}
2233 % (offered by document classes) doesn't work properly when used inside \env{adjustwidth}.
2234 % Therefore we try to detect the situation ``Are we inside a adjustwidth environment?''
2235 % inside \cs{@makecaption} and fix this. (Sigh!)
2236 %
2237 % We cannot simply set and test a flag here since our adjustment to \cs{hsize} should
2238 % not be done within a \cs{parbox} within a adjustwidth environment for example,
2239 % and therefore we store \cs{hsize} and \cs{linewidth}, and test \cs{hsize} and \cs{linewidth}
2240 % against the stored values instead. If they are equal we are (hopefully) quite save
2241 % to assume that we are now inside a plain \env{adjustwidth} environment and therefore need
2242 % to fix \cs{hsize} before typesetting the caption. (Deep sigh!)
2243 %
2244 % \begin{macro}{\caption@adjustwidth@hsize}
2245 % \begin{macro}{\caption@adjustwidth@linewidth}
2246 % \begin{macrocode}
2247 \newdimen\caption@adjustwidth@hsize
2248 \newdimen\caption@adjustwidth@linewidth
2249 % \end{macrocode}
2250 % \end{macro}
2251 % \end{macro}
2252 %
2253 % \begin{macro}{\caption@set@adjustwidth}
2254 % \changes{v3.4k}{2020/05/30}{This macro and its usage added}
2255 % \changes{v3.5h}{2022/03/01}{Usage of \cs{AtBeginCaption} replaced by \cs{l@addto@macro}\cs{caption@beginex@hook}}
2256 % Store the values of \cs{hsize} and \cs{linewidth}.
2257 % \begin{macrocode}
2258 \providecommand*\caption@set@adjustwidth{%
2259 \caption@adjustwidth@hsize\hsize
2260 \caption@adjustwidth@linewidth\linewidth
2261 \l@addto@macro\caption@beginex@hook\caption@test@adjustwidth}%
2262 % \end{macrocode}
2263 % \begin{macrocode}
2264 \providecommand*\caption@patch@changepage[1]{%
2265 \expandafter\let\csname caption@#1\expandafter\endcsname\csname #1\endcsname
2266 \expandafter\renewcommand\csname #1\endcsname[2]{%
2267 \@nameuse{caption@#1}{##1}{##2}%
2268 \caption@set@adjustwidth}}%
2269 \caption@patch@changepage{adjustwidth}%
2270 \caption@patch@changepage{adjustwidth*}%
2271 \let\caption@patch@changepage\relax
2272 % \end{macrocode}
2273 % \end{macro}
2274 %
2275 % \begin{macro}{\caption@test@adjustwidth}
2276 % \changes{v3.4k}{2020/05/30}{This macro and its usage added}
2277 % Test if the values of \cs{hsize} and \cs{linewidth} are identical to
2278 % the ones stored in the \env{adjustwidth} environment.
2279 % If yes, set \cs{hsize} to the correct value.
2280 % \begin{macrocode}
2281 \providecommand\caption@test@adjustwidth{%
2282 \ifdim\hsize=\caption@adjustwidth@hsize
2283 \ifdim\linewidth=\caption@adjustwidth@linewidth
2284 \hsize=\linewidth
2285 \fi
2286 \fi}%
2287 % \end{macrocode}
2288 % \end{macro}
2289 %
2290 % \begin{macrocode}
2291 }{}%
2292 % \end{macrocode}
2293 %
2294 % \subsection{The chkfloat package}
2295 % \changes{v3.3}{2018/09/06}{Support of the \package{chkfloat} package added}
2296 %
2297 % \begin{macrocode}
2298 \caption@IfPackageLoaded{chkfloat}[2012/08/19 v0.1]{%
2299 % \end{macrocode}
2300 %
2301 % \begin{macro}{\caption@chkfloat}
2302 % \changes{v3.3}{2018/09/06}{This macro added}
2303 % \begin{macrocode}
2304 \caption@ifdefined\chkfloat@addcontentsline{%
2305 \renewcommand\caption@chkfloat{\chkfloat@addcontentsline}%
2306 }{%
2307 \renewcommand\caption@chkfloat[2]{%
2308 \caption@ifdefined\chkfloat@page{%
2309 \addtocontents{fof}{\protect\chkfloat@{\thepage}{\chkfloat@page}{\csname fnum@#1\endcsname: #2}}%
2310 }{}}%
2311 }%
2312 % \end{macrocode}
2313 % \end{macro}
2314 %
2315 % \begin{macrocode}
2316 }{}%
2317 % \end{macrocode}
2318 %
2319 % \subsection{The float package}
2320 % \changes{v3.0f}{2005/05/31}{\package{float} package support rewritten and improved}
2321 % \iffalse
2322 % (This is a more straight-ahead implementation, but it only works with v1.3
2323 % now, so v1.2 is no longer supported. The old code including documentation
2324 % can be found in caption-30f-050530.zip)
2325 % \fi
2326 %
2327 % The \package{float} package usually do not use the \LaTeX\ kernel command
2328 % |\@caption| to typeset the caption but |\float@caption| instead.
2329 % (|\@caption| will only be used if the float is re-styled with
2330 % |\restylefloat*|.)
2331 %
2332 % The main two things |\float@caption| is doing different are:
2333 % \begin{itemize}
2334 % \item The caption will be typeset inside a |\savebox| called |\@floatcapt|
2335 % so it can be placed above or below the float contents afterwards.
2336 % \item |\@makecaption| will not be used to finally typeset the caption.
2337 % Instead |\@fs@capt| will be used which definition is part of the float
2338 % style.
2339 % (Note that |\@fs@capt| will not typeset any vertical space above or below
2340 % the caption; instead this space will be typeset by the float style code
2341 % itself.)
2342 % \end{itemize}
2343 %
2344 % \begin{macrocode}
2345 \caption@IfPackageLoaded{float}[2001/11/08 v1.3d]{%
2346 \@ifpackageloaded{floatrow}{%
2347 \caption@If@Package@Loaded{floatrow}[2007/08/24 v0.2a]{}{}%
2348 }{%
2349 % \end{macrocode}
2350 %
2351 % \begin{macro}{\@float@setevery}
2352 % \changes{v3.1k}{2009/10/09}{Bugfix 08-12-05: \cs{color@begin/endgroup} added
2353 % to redefinition of \cs{caption@setfloatcapt}}
2354 % \changes{v3.4b}{2019/12/16}{Usage of \cs{caption@float@setname} added}
2355 % |\@float@setevery|\marg{float type} is provided by the \package{float}
2356 % package; it's called every time a floating environment defined with
2357 % |\newfloat| or |\restylefloat| begins.
2358 % We use this hook to do some adaptations and to setup the proper caption
2359 % style (if defined) and additional settings declared with
2360 % |\captionsetup|\oarg{float style}.
2361 % \begin{macrocode}
2362 \let\caption@ORI@float@setevery\@float@setevery
2363 \def\@float@setevery#1{%
2364 \float@ifcaption{#1}{%
2365 % \end{macrocode}
2366 %
2367 % First of all we set the caption position to it's proper value by
2368 % converting |\@fs@iftopcapt| (which is part of a float style and
2369 % controls where the caption will be typeset, above or below the float
2370 % contents) to our |position=| setting.
2371 % Since the spacing above and below the caption will be done by the float
2372 % style and \emph{not} by us this sounds quite useless. But in fact it isn't,
2373 % since some packages based on \thispackage\ (like the \package{subfig}
2374 % package) could have an interest for this information and therefore use the
2375 % |\caption@iftop| macro we provide in our kernel. Furthermore we need this
2376 % information for ourself in |\captionof| which uses |\@makecaption| to
2377 % finally typeset the caption with skips.
2378 % \begin{macrocode}
2379 \caption@setposition{\@fs@iftopcapt t\else b\fi}%
2380 % \end{macrocode}
2381 %
2382 % Afterward we redefine |\caption@setfloatcapt| (which will be used inside
2383 % |\@caption|) so the caption will be set inside the box |\@floatcapt|,
2384 % without extra vertical space.
2385 % \begin{macrocode}
2386 \renewcommand\caption@setfloatcapt[1]{%
2387 \let\@makecaption\caption@@make
2388 \global\setbox\@floatcapt\vbox{%
2389 \color@begingroup ##1\color@endgroup}}%
2390 % \end{macrocode}
2391 %
2392 % To allow different caption styles for different float styles we also
2393 % determine the current float style (e.g. `ruled') and select
2394 % a caption style (and additional settings) with the same name, if defined.
2395 % \begin{macrocode}
2396 \float@getstyle\float@style{#1}%
2397 \caption@setstyle*\float@style
2398 \caption@setoptions\float@style
2399 % \end{macrocode}
2400 %
2401 % \begin{macrocode}
2402 }{}%
2403 \caption@float@setname{#1}%
2404 \caption@freezeHref % will be defrosted in \float@makebox
2405 \caption@ORI@float@setevery{#1}}%
2406 % \end{macrocode}
2407 % \end{macro}
2408 %
2409 % \begin{macro}{\float@makebox}
2410 % \changes{v3.3}{2013/01/06}{Corrects wrong load order hyperref-float now}
2411 % \changes{v3.3}{2013/02/03}{Correction of wrong load order hyperref-float revised}
2412 % Redefine |\float@makebox| (only if we are not operating in compatibility mode `v1').
2413 % \begin{macrocode}
2414 \caption@AtBeginDocument{\caption@ifcompatibility{}{%
2415 % \end{macrocode}
2416 % If it was redefined by the \package{hyperref} package,
2417 % we need to build on the original definition (and not on the redefined one).
2418 % \begin{macrocode}
2419 \caption@ifdefined\HyOrg@float@makebox
2420 {\let\caption@ORI@float@makebox\HyOrg@float@makebox}%
2421 {\let\caption@ORI@float@makebox\float@makebox}%
2422 \renewcommand\float@makebox[1]{%
2423 \caption@ORI@float@makebox{#1\relax \caption@defrostHref}}%
2424 % \end{macrocode}
2425 % \begin{macrocode}
2426 }}%
2427 % \end{macrocode}
2428 % \end{macro}
2429 %
2430 % \begin{macro}{\caption@float@setname}
2431 % \changes{v3.1}{2007/07/08}{float package hook added}
2432 % \changes{v3.4b}{2019/12/16}{Renamed from \cs{caption@typehook} to \cs{caption@float@setname}}
2433 % \LaTeX\ and almost every other packages use
2434 % |\|\meta{type}|name|
2435 % to provide a macro for the type resp.~environment name -- for example
2436 % the command |\figurename| will usually contain the name of the floating
2437 % environment |figure|:
2438 % \begin{quote}
2439 % |\newcommand\figurename{Figure}|
2440 % \end{quote}
2441 % But the \package{float} package doesn't follow this common naming
2442 % convention:
2443 % For floats defined with |\newfloat| it uses |\fname@|\meta{type} instead,
2444 % which breaks with our code (and with |\autoref| and some other things as
2445 % well).
2446 % So we have to map the \package{float} package name to the common one here.\par
2447 % \Note{If the float was not defined with \cs{newfloat} but with
2448 % \cs{restylefloat} instead, \cs{fname@}\meta{type} is not defined.}
2449 % \begin{macrocode}
2450 \newcommand*\caption@float@setname[1]{%
2451 \expandafter\ifx\csname #1name\endcsname\relax
2452 \expandafter\let\csname #1name\expandafter\endcsname\csname fname@#1\endcsname
2453 \fi}%
2454 % \end{macrocode}
2455 % \end{macro}
2456 %
2457 % \changes{v3.0f}{2005/06/26}{Skips of \env{plaintop} and \env{boxed} floats corrected}
2458 % \begin{macro}{\fs@plaintop}
2459 % \begin{macro}{\fs@boxed}
2460 % Since the float styles |plaintop| and |boxed| don't use |\abovecaptionskip|
2461 % which could be set with |skip=| (|plaintop| uses |\belowcaptionskip| instead of
2462 % |\abovecaptionskip|, and |boxed| uses a fixed space of |2pt|)
2463 % we patch the according float style macros here to change this.
2464 % \begin{macrocode}
2465 \g@addto@macro\fs@plaintop{\def\@fs@mid{\vspace\abovecaptionskip\relax}}%
2466 \g@addto@macro\fs@boxed{\def\@fs@mid{\kern\abovecaptionskip\relax}}%
2467 % \end{macrocode}
2468 % \end{macro}
2469 % \end{macro}
2470 %
2471 % \begin{macro}{\float@getstyle}
2472 % \changes{v3.1}{2007/06/10}{This macro added}
2473 % |\float@getstyle|\marg{cmd}\marg{type}\par
2474 % Determining the float style is not so easy because the only hint
2475 % provided by the \package{float} package is the macro
2476 % |\fst@|\meta{float type} which points to the macro which represents the
2477 % float style. So for example after
2478 % \begin{quote}
2479 % |\floatstyle{ruled}|\\
2480 % |\newfloat{Program}{tbp}{lop}|
2481 % \end{quote}
2482 % |\fst@Program| will be defined as
2483 % \begin{quote}
2484 % |\def\fst@Program{\fs@ruled}|\quad.
2485 % \end{quote}\par
2486 % So here is what we do: We make the first level expansion of
2487 % |\fst@|\meta{float type} a string so we can gobble the first four tokens
2488 % (= |\fs@|), so only the the name of the float style is left.\par
2489 % \emph{TODO:} We need to convert the catcodes here.
2490 % \begin{macrocode}
2491 \providecommand*\float@getstyle[2]{%
2492 \edef#1{%
2493 \noexpand\expandafter\noexpand\@gobblefour\noexpand\string
2494 \expandafter\expandafter\expandafter\noexpand
2495 \csname fst@#2\endcsname}%
2496 \edef#1{#1}%
2497 \caption@Debug{floatstyle{#2} = `#1'}}%
2498 % \end{macrocode}
2499 % \end{macro}
2500 %
2501 % \begin{macro}{\float@ifcaption}
2502 % \changes{v3.1}{2007/06/23}{This macro added}
2503 % |\float@ifcaption|\marg{type}\marg{if-clause}\marg{else-clause}\par
2504 % Here we determine if the user has used |\newfloat| resp.~|\restylefloat|,
2505 % or |\restylefloat*|.
2506 % This is quite easy: If |\@float@c@|\meta{captype} is the same as
2507 % |\float@caption|, the user has used |\newfloat| or |\restylefloat|,
2508 % otherwise we assume he has used |\restylefloat*|.
2509 % (This test will fail if some package re-defines |\float@caption|,
2510 % so we have to assume that there is no one.)
2511 % \begin{macrocode}
2512 \providecommand*\float@ifcaption[1]{%
2513 \expandafter\ifx\csname @float@c@#1\endcsname\float@caption
2514 \expandafter\@firstoftwo
2515 \else
2516 \expandafter\@secondoftwo
2517 \fi}%
2518 % \end{macrocode}
2519 % \end{macro}
2520 %
2521 % \begin{macrocode}
2522 }}{%
2523 \providecommand*\float@ifcaption[1]{\@secondoftwo}%
2524 % \clearcaptionsetup{boxed}% used by the floatrow package?
2525 }
2526 % \end{macrocode}
2527 %
2528 % The skip between `boxed' floats and their caption defaults to |2pt|.
2529 %
2530 % \begin{macrocode}
2531 \captionsetup[boxed]{skip=2pt} % do not issue a warning when not used
2532 % \end{macrocode}
2533 %
2534 % \changes{v3.0f}{2005/05/26}{\opt{strut=0} added to caption style \opt{ruled}}
2535 % \changes{v3.0f}{2005/05/27}{Option \opt{ruled} fixed}
2536 % To emulate the `ruled' definition of |\@fs@capt| we provide a caption style
2537 % `ruled' with appropriate options. But if the package option |ruled| was
2538 % specified, we setup some caption parameters to emulate the behavior
2539 % of \thispackage\ \version{1.x} option |ruled| instead, i.e.,
2540 % the current caption settings will be used, but without margin and without
2541 % `single-line-check'.
2542 % \begin{macrocode}
2543 \caption@ifbool{ruled}{%
2544 \captionsetup[ruled]{margin=0pt,minmargin=0,slc=0}%
2545 }{%
2546 \DeclareCaptionStyle{ruled}{labelfont=bf,labelsep=space,strut=0}%
2547 }
2548 \caption@undefbool{ruled}
2549 % \end{macrocode}
2550 %
2551 % \subsection{The floatflt package}
2552 % \changes{v3.1}{2007/06/10}{Support of the \package{floatflt} package added}
2553 %
2554 % \begin{macrocode}
2555 \caption@IfPackageLoaded{floatflt}[1996/02/27 v1.3]{%
2556 % \end{macrocode}
2557 %
2558 % \begin{macro}{\floatingfigure}
2559 % We patch |\floatingfigure| so |\caption@floatflt| will be used.
2560 % \begin{macrocode}
2561 \let\caption@ORI@floatingfigure\floatingfigure
2562 \def\floatingfigure{%
2563 \caption@floatflt{figure}%
2564 \caption@ORI@floatingfigure}%
2565 % \end{macrocode}
2566 % \end{macro}
2567 %
2568 % \begin{macro}{\floatingtable}
2569 % Same with |\floatingtable|\ldots
2570 % \begin{macrocode}
2571 \let\caption@ORI@floatingtable\floatingtable
2572 \def\floatingtable{%
2573 \caption@floatflt{table}%
2574 % \caption@setautoposition b%
2575 \caption@ORI@floatingtable}%
2576 % \end{macrocode}
2577 % \end{macro}
2578 %
2579 % \begin{macro}{\caption@floatflt}
2580 % \changes{v3.1c}{2007/10/06}{Bugfix: \cs{caption@clearmargin} added}
2581 % Here we do two things:
2582 % \begin{enumerate}
2583 % \item We use |\caption@set|\-|options{|\-|floating|\meta{type}|}| so
2584 % |\caption|\-|setup[|\-|floating|\meta{type}|]{|\ldots|}| is supported.
2585 % \item |\line|\-|width| must be set correctly.
2586 % Usually this is done by |\@par|\-|box|\-|restore| inside |\@caption|,
2587 % but since we use |\@caption@parbox|\-|restore| we have to map this to
2588 % |\@par|\-|box|\-|restore| instead.
2589 % \end{enumerate}
2590 % \begin{macrocode}
2591 \newcommand*\caption@floatflt[1]{%
2592 \caption@settype{#1}%
2593 \caption@clearmargin
2594 \caption@setparboxrestore{full}%
2595 \caption@setoptions{floating#1}}%
2596 % \end{macrocode}
2597 % \end{macro}
2598 %
2599 % \begin{macrocode}
2600 }{}
2601 % \end{macrocode}
2602 %
2603 % \subsection{The fltpage package}
2604 % \changes{v3.1}{2007/07/22}{Support of the \package{fltpage} package added}
2605 %
2606 % \begin{macrocode}
2607 \caption@IfPackageLoaded{fltpage}[1998/10/29 v.0.3]{%
2608 \caption@setbool{needfreeze}{1}%
2609 % \end{macrocode}
2610 %
2611 % \begin{macro}{\FP@positionLabel}
2612 % \changes{v3.2c}{2011/08/28}{This redefinition added}
2613 % Original code:
2614 % \begin{verbatim}
2615 % \newcommand{\FP@positionLabel}{%
2616 % FP\@captype-\number\value{FP@\@captype C}-pos}
2617 % \end{verbatim}%^^A
2618 % \begin{macrocode}
2619 \renewcommand\FP@positionLabel{%
2620 FP\FP@captype-\number\value{FP@\FP@captype C}-pos}%
2621 % \end{macrocode}
2622 % \end{macro}
2623 %
2624 % \begin{macro}{\FP@helpNote}
2625 % Original code:
2626 % \begin{verbatim}
2627 % \newcommand{\FP@helpNote}[2]{%
2628 % \typeout{FP#1 is inserted on page \pageref{#2}!}}%
2629 % \end{verbatim}%^^A
2630 % \begin{macrocode}
2631 \renewcommand\FP@helpNote[2]{%
2632 \begingroup % save \caption@thepage
2633 \caption@pageref{#2}%
2634 \typeout{FP#1 is inserted on page \caption@thepage!}%
2635 \endgroup}%
2636 % \end{macrocode}
2637 % \end{macro}
2638 %
2639 % \begin{macro}{\FP@floatBegin}
2640 % \changes{v3.1f}{2007/11/16}{Uses `space hack' instead of \cs{ignorespaces} now}
2641 % \changes{v3.1k}{2009/10/09}{Bugfix 09-09-11: Missing \cs{ignorespaces} added}
2642 % \changes{v3.2c}{2011/08/28}{Adapted to current version of \cs{caption@freeze}}
2643 % \changes{v3.2f}{2012/02/19}{Bugfix 12-02-16: \texttt{minipage} environment added}
2644 % \changes{v3.3}{2013/05/01}{Usage of \cs{caption@freeze} replaced by \cs{caption@freezetype}}
2645 % Original code:
2646 % \begin{verbatim}
2647 % \newcommand{\FP@floatBegin}[1]{%
2648 % \gdef\@captype{#1}%
2649 % \global\let\FP@savedCaptionCommand\caption%
2650 % \global\let\FP@savedLabelCommand\label%
2651 % \ifthenelse{\equal{\@captype}{figure}}
2652 % {\global\let\old@Fnum\fnum@figure}%
2653 % {\global\let\old@Fnum\fnum@table}%
2654 % \let\FP@LabelText\@empty%
2655 % \let\FP@CaptionText\@empty%
2656 % \let\FP@optionalCaptionText\@empty%
2657 % \renewcommand\label[1]{\gdef\FP@LabelText{##1}}%
2658 % \renewcommand\caption[2][]{%
2659 % \gdef\FP@optionalCaptionText{##1}\gdef\FP@CaptionText{##2}}%
2660 % \begin{lrbox}{\FP@floatCorpusBOX}%
2661 % }%
2662 % \end{verbatim}%^^A
2663 % \begin{macrocode}
2664 \renewcommand*\FP@floatBegin[1]{%
2665 \def\FP@captype{#1}%
2666 \begin{lrbox}{\FP@floatCorpusBOX}%
2667 \minipage\hsize % changes from LR mode to vertical mode
2668 \caption@freezetype{#1}%
2669 \ignorespaces}%
2670 % \end{macrocode}
2671 % \end{macro}
2672 %
2673 % \begin{macro}{\FP@floatEnd}
2674 % \changes{v3.1g}{2008/01/30}{Some minor bugfixes}
2675 % \changes{v3.2c}{2011/08/28}{Adapted to current version of \cs{caption@freeze}}
2676 % \changes{v3.2f}{2012/02/19}{Bugfix 12-02-16: \texttt{minipage} environment added}
2677 % Original code:
2678 % \begin{verbatim}
2679 % \newcommand{\FP@floatEnd}{%
2680 % \end{lrbox}%
2681 % \global\setbox\FP@floatCorpusBOX=\box\FP@floatCorpusBOX
2682 % \stepcounter{FP@\@captype C}%
2683 % \FP@savedLabelCommand{\FP@positionLabel}%
2684 % \FP@helpNote{\@captype}{\FP@positionLabel}%
2685 % \FP@float
2686 % {\FP@positionLabel}% location label test
2687 % {\begin{\@captype}[p!]
2688 % \usebox{\FP@floatCorpusBOX}%
2689 % \refstepcounter{\@captype}%
2690 % \ifthenelse{\equal{\FP@LabelText}{\@empty}}
2691 % {}{\FP@savedLabelCommand{\expandafter\protect\FP@LabelText}}%
2692 % \end{\@captype}}
2693 % {\addtocounter{\@captype}{-1}}
2694 % {\begin{\@captype}[b!]%
2695 % \ifthenelse{\equal{\FP@guide}{\@empty}}%
2696 % {}{\ifthenelse{\equal{\@captype}{figure}}%
2697 % {\renewcommand{\fnum@figure}{\old@Fnum\ {\FP@guide}}}%
2698 % {\renewcommand{\fnum@table}{\old@Fnum\ {\FP@guide}}}}%
2699 % \setlength{\abovecaptionskip}{2pt plus2pt minus 1pt} % length above caption
2700 % \setlength{\belowcaptionskip}{2pt plus2pt minus 1pt} % length above caption
2701 % \FP@separatorCaption%
2702 % \ifthenelse{\equal{\FP@optionalCaptionText}{\@empty}}%
2703 % {\FP@savedCaptionCommand{\expandafter\protect\FP@CaptionText}}%
2704 % {\FP@savedCaptionCommand[\expandafter\protect\FP@optionalCaptionText]%
2705 % {\expandafter\protect\FP@CaptionText}}%
2706 % \end{\@captype}}%
2707 % }%
2708 % \end{verbatim}%^^A
2709 % \begin{macrocode}
2710 \renewcommand*\FP@floatEnd{%
2711 \endminipage
2712 \end{lrbox}%
2713 % \end{macrocode}
2714 % \begin{macrocode}
2715 \stepcounter{FP@\FP@captype C}%
2716 \caption@label\FP@positionLabel
2717 \FP@helpNote\FP@captype\FP@positionLabel
2718 % \end{macrocode}
2719 % \begin{macrocode}
2720 \FP@float
2721 {\FP@positionLabel}% location label test
2722 {\caption@prepare@defrost
2723 \begin\FP@captype[p!]%
2724 \usebox\FP@floatCorpusBOX
2725 \end\FP@captype}%
2726 {\@ifundefined{theH\FP@captype}{}{%
2727 \expandafter\l@addto@macro\csname theH\FP@captype\endcsname{.FP}}}%
2728 {\caption@prepare@defrost
2729 \begin\FP@captype[b!]%
2730 \let\FP@savedSetfnumCommand\caption@setfnum
2731 \def\caption@setfnum##1{%
2732 \FP@savedSetfnumCommand{##1}%
2733 \ifx\FP@guide\@empty \else
2734 \expandafter\l@addto@macro\csname fnum@##1\endcsname{\ {\FP@guide}}%
2735 \fi}%
2736 \setlength\abovecaptionskip{2pt plus 2pt minus 1pt}% length above caption
2737 \setlength\belowcaptionskip{2pt plus 2pt minus 1pt}% length below caption
2738 \caption@setoptions{FP\@captype}%
2739 \FP@separatorCaption
2740 \caption@defrost
2741 \end\FP@captype}%
2742 }%
2743 % \end{macrocode}
2744 % \end{macro}
2745 %
2746 % \begin{macrocode}
2747 }{%
2748 \let\caption@ifFPlistcap\@undefined
2749 \let\caption@ifFPrefcap\@undefined
2750 }
2751 % \end{macrocode}
2752 %
2753 % \subsection{The hyperref package}
2754 % \changes{v3.0f}{2005/06/11}{Support of the \package{hyperref} package added}
2755 % \changes{v3.1}{2007/03/09}{Usage of \cs{hyper@makecurrent} instead of
2756 % \cs{theHfigure} as indicator for \package{hyperref} package}
2757 % \changes{v3.2}{2011/07/30}{Test if \package{hyperref} has stopped early revised}
2758 % \changes{v3.2c}{2011/08/24}{Test if \package{hyperref} has stopped early adapted to current version of \package{hyperref} package: Usage of \cs{IfHyperBoolean} added}
2759 %
2760 % \begin{macrocode}
2761 \caption@IfPackageLoaded{hyperref}[2003/11/30 v6.74m]{%
2762 % Test if hyperref has stopped early
2763 \caption@ifundefined\IfHyperBoolean{%
2764 \caption@set@bool\caption@ifhyp@stoppedearly0%
2765 \caption@ifundefined\H@refstepcounter
2766 {\caption@set@bool\caption@ifhyp@stoppedearly1}{%
2767 \caption@ifundefined\hyper@makecurrent
2768 {\caption@set@bool\caption@ifhyp@stoppedearly1}{%
2769 \caption@ifundefined\measuring@true
2770 {\caption@set@bool\caption@ifhyp@stoppedearly1}{}}}%
2771 }{%
2772 \def\caption@ifhyp@stoppedearly{\IfHyperBoolean{stoppedearly}}%
2773 }%
2774 \caption@ifhyp@stoppedearly{% hyperref has stopped early
2775 \caption@InfoNoLine{%
2776 Hyperref support is turned off\MessageBreak
2777 because hyperref has stopped early}%
2778 }{%
2779 \g@addto@macro\caption@prepareslc{\measuring@true}%
2780 % \end{macrocode}
2781 %
2782 % \begin{macro}{\caption@@@refstepcounter}
2783 % We redefine |\caption@@refstepcounter| so |\H@refstepcounter| will be used
2784 % instead of |\refstepcounter| inside |\caption| \& |\captionlistentry|.
2785 % \begin{macrocode}
2786 \renewcommand*\caption@@@refstepcounter{\H@refstepcounter}%
2787 % \end{macrocode}
2788 % \end{macro}
2789 %
2790 % \begin{macro}{\caption@makecurrent}
2791 % \changes{v3.1l}{2010/01/09}{Adapted to current version of nameref package}
2792 % We redefine |\caption@makecurrent| so a \package{hyperref} label
2793 % will be defined inside |\@caption|.
2794 % \Note{Will be redefined by \cs{caption@start}.}
2795 % \begin{macrocode}
2796 \renewcommand*\caption@makecurrent[2]{%
2797 \caption@makecurrentHref{#1}%
2798 \caption@Debug{hyperref current=\@currentHref}%
2799 \caption@gettitle{#2}}%
2800 % \end{macrocode}
2801 % \begin{macrocode}
2802 \newcommand*\caption@makecurrentHref{\hyper@makecurrent}%
2803 % \end{macrocode}
2804 % \end{macro}
2805 %
2806 % \begin{macro}{\caption@makeanchor}
2807 % \changes{v3.1l}{2010/01/09}{Adapted to the current hyperref package}
2808 % We redefine |\caption@makeanchor| so a \package{hyperref} anchor
2809 % will be set inside |\@caption|.
2810 % \Note{Will be redefined by \cs{caption@start}.}
2811 % \begin{macrocode}
2812 \renewcommand\caption@makeanchor[1]{%
2813 \caption@Debug{hyperref anchor: \@currentHref}%
2814 % If we cannot have nesting, the anchor is empty.
2815 \ifHy@nesting
2816 \expandafter\hyper@@anchor\expandafter{\@currentHref}{#1}%
2817 \else
2818 \Hy@raisedlink{%
2819 \expandafter\hyper@@anchor\expandafter{\@currentHref}{\relax}%
2820 }#1%
2821 \fi}%
2822 % \end{macrocode}
2823 % \begin{macrocode}
2824 \g@addto@macro\caption@prepareslc{\let\caption@makeanchor\@firstofone}%
2825 % \end{macrocode}
2826 % \end{macro}
2827 %
2828 % \paragraph{The hypcap option}
2829 %
2830 % \begin{macro}{\if@capstart}
2831 % Like the \package{hypcap} package we define the switch |\if@capstart|, too.
2832 % \begin{macrocode}
2833 \newif\if@capstart
2834 % \end{macrocode}
2835 % \end{macro}
2836 %
2837 % \begin{macro}{\caption@start}
2838 % \changes{v3.0l}{2007/02/20}{%
2839 % \cs{caption@currentHref} renamed to \cs{hc@currentHref}}
2840 % \changes{v3.1}{2007/06/21}{%
2841 % This macro renamed from \cs{capstart} to \cs{caption@start} and revised}
2842 % While the \package{hypcap} package defines a macro called |\capstart|
2843 % our variant is called |\caption@start| and is controlled by the option
2844 % |hypcap=||false|/|true|.
2845 % \begin{macrocode}
2846 \def\caption@start{\caption@ifhypcap\caption@start@\relax}%
2847 \def\caption@start@{%
2848 % \end{macrocode}
2849 % Generate the \package{hyperref} label and set the \package{hyperref} anchor,
2850 % usually (if |hypcap=false|) both is done inside |\@caption|.
2851 % \begin{macrocode}
2852 \caption@makestart\@captype
2853 \caption@startanchor\@currentHref
2854 % \end{macrocode}
2855 % Prevent |\@caption| from generating a new \package{hyperref} label,
2856 % use the label we save in |\hc@currentHref| instead.
2857 % (We also support the |@capstart| flag from the \package{hypcap} package.)
2858 % \begin{macrocode}
2859 \global\@capstarttrue
2860 \let\hc@currentHref\@currentHref
2861 \def\caption@makecurrentHref##1{%
2862 \global\@capstartfalse
2863 \global\let\@currentHref\hc@currentHref}%
2864 % \end{macrocode}
2865 % Prevent |\@caption| from generating a \package{hyperref} anchor since this
2866 % has already been done.
2867 % \begin{macrocode}
2868 \let\caption@makeanchor\@firstofone
2869 % \end{macrocode}
2870 % \begin{macrocode}
2871 }%
2872 % \end{macrocode}
2873 % \end{macro}
2874 %
2875 % \begin{macro}{\caption@makestart}
2876 % \changes{v3.1c}{2007/09/30}{\cs{@currentHref} will be extended by \texttt{caption}
2877 % instead of \texttt{xxx} now}
2878 % |\caption@makestart|\marg{type}
2879 % defines a \package{hyperref} anchor inside |\caption@start|.\par
2880 % Since we offer |\continuedfloat| the float counter can change between
2881 % `now' and |\caption|, i.e., we simply don't know the figure or table counter
2882 % yet and therefore we are not able to generate the `right' \package{hyperref}
2883 % label.
2884 % Two different solutions of this problem came into my mind:
2885 % \begin{enumerate}
2886 % \item I could use the aux file for this purpose.\par
2887 % -or-
2888 % \item I set |hypertexnames=false| locally.
2889 % Furthermore I use |#1.caption.|\meta{counter} (instead of |#1.|\meta{counter})
2890 % as naming scheme for |\@currentHref| to avoid conflicts with other hyper
2891 % links which are generated with |hypertexnames=true|.
2892 % \end{enumerate}
2893 % The first idea has the advantage that the `right' anchor name will be
2894 % generated, but one needs an additional \LaTeX\ run if figures or tables
2895 % will be inserted or removed.\par
2896 % The second idea has the advantage that it's very easy to implement, but
2897 % has some side-effects, e.g. the anchor names don't follow the figure or
2898 % table label names anymore.\par
2899 % Since I'm lazy I implemented the second idea, maybe I will revise this
2900 % later on.
2901 % \begin{macrocode}
2902 \newcommand*\caption@makestart[1]{%
2903 \begingroup
2904 \Hy@hypertexnamesfalse
2905 % \gdef\@currentHlabel{}%
2906 \hyper@makecurrent{#1.caption}%
2907 \endgroup
2908 \caption@Debug{hypcap start=\@currentHref}}%
2909 % \end{macrocode}
2910 % \end{macro}
2911 %
2912 % \begin{macro}{\caption@startanchor}
2913 % \changes{v3.1b}{2007/09/17}{Bugfix 06-09-17: We use \cs{caption@anchor} instead of \cs{hyper@@anchor}}
2914 % \changes{v3.1g}{2008/03/16}{Warning about TeX mode replaced with debug info}
2915 % |\caption@startanchor|\marg{Href}
2916 % sets a \package{hyperref} anchor inside |\caption@start|.\par
2917 % This code was taken from the \package{hypcap} package\cite{hypcap} and adapted.
2918 % \Note{Since \cs{hyper@@anchor}\marg{Href}\csmarg{\string\relax} can cause
2919 % a change from vertical mode to horizontal mode (design flaw in
2920 % \package{hyperref} package!?), and since the workaround
2921 % \cs{let}\cs{leavevmode}\cs{relax} which can be found in the
2922 % \package{hypcap} package is not always sufficient
2923 % (for example with ``Direct pdfmark support'' and \texttt{breaklinks=true}),
2924 % we use \cs{caption@anchor} instead of \cs{hyper@@anchor} here.}
2925 % \begin{macrocode}
2926 \newcommand*\caption@startanchor[1]{%
2927 \ifvmode\begingroup
2928 \caption@Debug{hypcap anchor: #1 (vertical mode)}%
2929 \@tempdima\prevdepth
2930 \nointerlineskip
2931 \vspace*{-\caption@hypcapspace}%
2932 \caption@anchor{#1}%
2933 \vspace*{\caption@hypcapspace}%
2934 \prevdepth\@tempdima
2935 \endgroup\else
2936 \caption@Debug{hypcap anchor: #1 (horizontal mode)}%
2937 \caption@anchor{#1}%
2938 \fi}%
2939 % \end{macrocode}
2940 % \end{macro}
2941 %
2942 % \begin{macro}{\caption@anchor}
2943 % \changes{v3.1c}{2007/10/17}{Workaround 07-10-17: We use \cs{caption@raisedlink} instead of \cs{Hy@raisedlink} now}
2944 % |\caption@anchor|\marg{Href} sets a \package{hyperref} anchor.
2945 % \begin{macrocode}
2946 \newcommand*\caption@anchor[1]{%
2947 \ifmeasuring@ \else
2948 \caption@raisedlink{\hyper@anchorstart{#1}\hyper@anchorend}%
2949 \fi}%
2950 % \end{macrocode}
2951 % \Note{Since \cs{Hy@raisedlink} change \cs{@tempdima} we surrounded it by \cs{ifvmode},
2952 % suppressing ``\texttt{LaTeX Warning: Float too large for page by 1.0pt}'' in \texttt{sideways} floats.
2953 % (This is not necessary since \package{hyperref} \version{6.77}.)}
2954 % \begin{macrocode}
2955 \ifx\HyperRaiseLinkLength\@tempdima
2956 \def\caption@raisedlink#1{\ifvmode#1\else\Hy@raisedlink{#1}\fi}%
2957 \else
2958 \let\caption@raisedlink\Hy@raisedlink
2959 \fi
2960 % \end{macrocode}
2961 % \end{macro}
2962 %
2963 % \begin{macro}{\caption@@start}
2964 % Will be used by |\caption@freezeHref|. Apart from that we issue a warning
2965 % if we expect a saved \package{hyperref} label coming from |\caption@start|,
2966 % but there isn't any.
2967 % \begin{macrocode}
2968 \def\caption@@start{%
2969 \caption@ifundefined\hc@currentHref{%
2970 \caption@Warning{%
2971 The option `hypcap=true' will be ignored for this\MessageBreak
2972 particular \string\caption}}{}}%
2973 % \end{macrocode}
2974 % \end{macro}
2975 %
2976 % \begin{macro}{\caption@freezeHref}
2977 % Suppress |\caption@start| from generating a \package{hyperref} label and
2978 % setting a \package{hyperref} anchor. Instead if |\@caption| generates a
2979 % \package{hyperref} label, it will be stored in |\caption@currentHref|.
2980 % Furthermore we need to redefine |\caption@setfloatcapt| so no
2981 % \package{hyperref} anchor will be placed in |\@caption|.
2982 % \iffalse
2983 % (Since |\caption@setfloatcapt| will be set to |\@firstofone| inside
2984 % |\subcaption| there is no need to add its restauration to
2985 % |\caption@subtypehook|.)
2986 % \fi
2987 % \begin{macrocode}
2988 \def\caption@freezeHref{%
2989 \let\caption@ORI@start\caption@start
2990 \def\caption@start{\let\caption@start\caption@ORI@start}%
2991 % \end{macrocode}
2992 % \begin{macrocode}
2993 % \let\caption@ORI@@start\caption@@start
2994 % \l@addto@macro\caption@subtypehook{%
2995 % \let\caption@@start\caption@ORI@@start}%
2996 % \end{macrocode}
2997 % \begin{macrocode}
2998 \global\let\caption@currentHref\@undefined
2999 \def\caption@@start{\global\let\caption@currentHref\@currentHref}%
3000 % \end{macrocode}
3001 % \begin{macrocode}
3002 \let\caption@ORI@setfloatcapt\caption@setfloatcapt
3003 \renewcommand*\caption@setfloatcapt{%
3004 \ifx\caption@currentHref\@undefined \else
3005 \let\caption@makeanchor\@firstofone
3006 \fi
3007 \caption@ORI@setfloatcapt}}%
3008 % \end{macrocode}
3009 % \end{macro}
3010 %
3011 % \begin{macro}{\caption@defrostHref}
3012 % If there is a freezed |\@currentHref|, we set the \package{hyperref}
3013 % anchor here.
3014 % \begin{macrocode}
3015 \def\caption@defrostHref{%
3016 \ifx\caption@currentHref\@undefined \else
3017 \caption@startanchor\caption@currentHref
3018 \global\let\caption@currentHref\@undefined
3019 \fi}%
3020 % \end{macrocode}
3021 % \end{macro}
3022 %
3023 % \begin{macrocode}
3024 }}{}
3025 % \end{macrocode}
3026 %
3027 % \subsection{The hypcap package}
3028 % \changes{v3.0f}{2005/06/22}{Support of the \package{hypcap} package added}
3029 % \changes{v3.0l}{2007/02/20}{Adapted to \package{hypcap} \version{1.6}}
3030 % \changes{v3.1e}{2007/11/04}{\package{hypcap} support adapted to \package{hyperref} \version{6.77}}
3031 %
3032 % \begin{macrocode}
3033 \caption@IfPackageLoaded{hypcap}{% v1.0
3034 \ifx\caption@start\relax \else % hyperref hasn't stopped early
3035 % \end{macrocode}
3036 %
3037 % If the \package{hypcap} package was loaded, we give up our own
3038 % hyperlink placement algorithm and give the control over the placement
3039 % to the \package{hypcap} package instead.
3040 %
3041 % \begin{macro}{\capstart}
3042 % \changes{v3.1k}{2009/10/09}{Support of \cs{ifcapstart} (\package{hypcap} package \version{1.10}) added}
3043 % We do this simply by mapping |\capstart| to |\caption@start@|,
3044 % although our code does not behave exactly like the original one:
3045 % The original |\capstart| has an effect on the next |\caption|
3046 % only but our version affects \emph{all} |\caption|s in the same
3047 % environment, at least unless a new |\capstart| will be placed.
3048 % \begin{macrocode}
3049 \let\caption@ORI@capstart\capstart % save for compatibility mode
3050 \caption@ifundefined\capstarttrue % check for v1.10 of hypcap package
3051 {\def\capstart{\caption@start@}}%
3052 {\def\capstart{\ifcapstart\caption@start@\fi}}%
3053 \let\caption@start\relax
3054 \let\caption@@start\relax
3055 % \end{macrocode}
3056 % \end{macro}
3057 %
3058 % \begin{macro}{\caption@hypcapspace}
3059 % Furthermore we map our |\caption@hypcapspace| to |\hypcapspace|
3060 % offered by the \package{hypcap} package.
3061 % \begin{macrocode}
3062 \caption@set@bool\caption@ifhypcap 1%
3063 \renewcommand*\caption@hypcapspace{\hypcapspace}%
3064 % \end{macrocode}
3065 % \end{macro}
3066 %
3067 % \begin{macrocode}
3068 \fi}{}
3069 % \end{macrocode}
3070 %
3071 % \subsection{The listings package}
3072 % \changes{v3.0b}{2004/05/16}{Support of the \package{listings} package added}
3073 %
3074 % \begin{macrocode}
3075 \caption@IfPackageLoaded{listings}[2004/02/13 v1.2]{%
3076 % \end{macrocode}
3077 %
3078 % \begin{macro}{\lst@MakeCaption}
3079 % \changes{v3.1g}{2008/01/20}{Bugfix: Skips are handled correctly now}
3080 % \changes{v3.1k}{2008/03/29}{Bugfix 08-10-16-dctt: \texttt{rule=0} added}
3081 % \changes{v3.2}{2010/10/26}{Bugfix 10-07-20a: Set \cs{hsize} to \cs{linewidth}, if necessary}
3082 % \changes{v3.4c}{2020/01/01}{Ugly workaround for usage in lists added}
3083 % \changes{v3.4d}{2020/01/01}{Ugly workaround for usage in lists revised}
3084 % To support the \package{listings} package we need to redefine
3085 % |\lst@Make|\-|Caption| so the original stuff is nested with
3086 % |\caption@begin| and |\caption@end| etc.\par
3087 % We set a flag inside the "Init" hook of the \package{listings} package (where adaption of |\line|\-|width| etc.~takes place).
3088 % \begin{macrocode}
3089 \caption@setbool{lst@Init}{0}%
3090 \lst@AddToHook{Init}{\caption@setbool{lst@Init}{1}}%
3091 % \end{macrocode}
3092 % \begin{macrocode}
3093 \let\caption@ORI@lst@MakeCaption\lst@MakeCaption
3094 \def\lst@MakeCaption#1{% #1 is `t' or `b'
3095 % \end{macrocode}
3096 % This macro is always called twice by the \package{listings} package (with `t' resp. `b' as parameter),
3097 % therefore we need an extra group here.
3098 % \begin{macrocode}
3099 \begingroup
3100 % \end{macrocode}
3101 % Inside lists the \package{listings} package ignores the left margin (|\@total|\-|left|\-|margin|) for captions.
3102 % We emulate this behaviour by adding a negative skip which will be typeset ahead of |\caption@box|.\par
3103 % Note: We only need to do this if the ``Init'' hook of the \package{listings} package wasn't called yet.
3104 % \begin{macrocode}
3105 \caption@iflst@Init{}{%
3106 \edef\caption@lst@leftskip{\noexpand\hskip-\the\@totalleftmargin\noexpand\relax}%
3107 \l@addto@macro\caption@beginhook\caption@lst@leftskip}%
3108 % \end{macrocode}
3109 % We set |position=#1| and if it was set to `top',
3110 % we swap the skips so the default behavior of the \package{listings} package
3111 % will not be changed. (Note that the \package{listings} package has set its
3112 % own |\abovecaptionskip| \& |\belowcaptionskip| values prior to calling
3113 % \cs{lst@MakeCaption}.)
3114 % \begin{macrocode}
3115 \caption@setposition{#1}%
3116 \caption@iftop{%
3117 \@tempdima\belowcaptionskip
3118 \belowcaptionskip\abovecaptionskip
3119 \abovecaptionskip\@tempdima}{}%
3120 % \end{macrocode}
3121 % Workaround for issue with wrong skips (FIXME: This should be examined further)
3122 % \begin{macrocode}
3123 \caption@setup{rule=0}%
3124 % \end{macrocode}
3125 % Afterwards we set the local `lstlisting' options.
3126 % \begin{macrocode}
3127 \caption@setoptions{lstlisting}%
3128 % \end{macrocode}
3129 % If the |position=| is now set to |auto|, we take over the |captionpos=|
3130 % setting from the \package{listings} package.
3131 % \begin{macrocode}
3132 \caption@setautoposition{#1}%
3133 % \end{macrocode}
3134 % At the end we do similar stuff as in our \cs{@caption} code.
3135 % \begin{macrocode}
3136 \caption@begin{lstlisting}%
3137 \caption@ORI@lst@MakeCaption{#1}%
3138 \caption@end
3139 % \end{macrocode}
3140 % \begin{macrocode}
3141 \endgroup}%
3142 % \end{macrocode}
3143 % \end{macro}
3144 %
3145 % \begin{macro}{\lst@makecaption}
3146 % \begin{macro}{\lst@maketitle}
3147 % Wrapper macros for typesetting the |caption=| resp. |title=| value.
3148 % \begin{macrocode}
3149 \def\lst@makecaption{\caption@starfalse\@makecaption}%
3150 \def\lst@maketitle{\caption@startrue\@makecaption\@empty}%
3151 % \end{macrocode}
3152 % \end{macro}
3153 % \end{macro}
3154 %
3155 % \begin{macro}{\ext@lstlisting}
3156 % \changes{v3.1}{2007/03/03}{This macro added}
3157 % Since the \package{listings} package do not define |\ext@lstlisting|
3158 % but we needed it when |\captionof{lstlisting}| will be done by the end user,
3159 % we define it here.
3160 % \begin{macrocode}
3161 \providecommand*\ext@lstlisting{lol}%
3162 % \end{macrocode}
3163 % \end{macro}
3164 %
3165 % \begin{macro}{\lst@@caption}
3166 % \changes{v3.1}{2007/03/03}{This macro added}
3167 % \changes{v3.1a}{2007/07/13}{Bugfix 07-09-13: \cs{lst@@caption} will not be re-defined anymore}
3168 % \changes{v3.2}{2010/10/26}{Bugfix 09-05-15: Setting of \cs{lst@@caption} added to \cs{caption@beginex}}
3169 % \changes{v3.5h}{2022/03/01}{Re-definition of \cs{lst@@caption} moved from \cs{caption@beginex} to \cs{caption@beginex@hook}}
3170 % We define |\lst@@caption| to non-|\@empty|, so |\fnum@lst|\-|listing| will
3171 % include a numbering.
3172 % \begin{macrocode}
3173 \l@addto@macro\caption@beginex@hook{\let\lst@@caption\relax}%
3174 % \end{macrocode}
3175 % \end{macro}
3176 %
3177 % \begin{macrocode}
3178 }{}
3179 % \end{macrocode}
3180 %
3181 % \subsection{The longtable package}
3182 %
3183 % \begin{macro}{\LTcaptype}
3184 % \changes{v3.1}{2007/07/06}{This macro and its support added}
3185 % |\LTcaptype| is preset to |table|.
3186 % \begin{macrocode}
3187 \providecommand*\LTcaptype{table}
3188 % \end{macrocode}
3189 % \end{macro}
3190 %
3191 % \begin{macro}{\caption@AtBeginLongtable}
3192 % \changes{v3.5}{2018/04/15}{This macro added}
3193 % \begin{macrocode}
3194 \providecommand*\caption@LT@array{}
3195 \newcommand\caption@AtBeginLongtable{%
3196 \g@addto@macro\caption@LT@array}
3197 % \end{macrocode}
3198 % \end{macro}
3199 %
3200 % \begin{macrocode}
3201 \caption@IfPackageLoaded{longtable}[1995/05/24 v3.14]{%
3202 % \end{macrocode}
3203 % \begin{macrocode}
3204 \RequirePackage{ltcaption}[=2018/08/26]%
3205 \let\LT@@makecaption\@undefined
3206 % \end{macrocode}
3207 %
3208 % \begin{macro}{\LT@array}
3209 % \changes{v3.1}{2007/07/22}{This redefinition added}
3210 % \changes{v3.1a}{2007/09/16}{Bugfix: This redefinition will always be done \cs{AtBeginDocument}}
3211 % \changes{v3.1g}{2008/01/20}{Bugfix in \cs{captionlistentry}: Table counter will not be incremented anymore, \cs{nameref} works}
3212 % \changes{v3.3}{2016/01/31}{Support for \cs{bicaption} added}
3213 % \changes{v3.3}{2018/10/05}{Definition of \cs{captionlistentry} fixed}
3214 % \changes{v3.5}{2018/04/15}{Usage of \cs{caption@AtBeginLongtable} added}
3215 % We redefine |\LT@array| here to get |\captionsetup|\marg{options} working inside |longtable|s.
3216 % \Note{Since the \package{hyperref} package patches \cs{LT@array} as well
3217 % and since this only works with the original definition of \cs{LT@array},
3218 % we have to do this after the \package{hyperref} package, i.e.~\cs{AtBeginDocument}.}
3219 % \begin{macrocode}
3220 \caption@AtBeginDocument{%
3221 \let\caption@ORI@LT@array\LT@array
3222 \renewcommand*\LT@array{%
3223 \caption@LT@array
3224 \caption@ORI@LT@array}}%
3225 % \end{macrocode}
3226 % \begin{macrocode}
3227 \caption@AtBeginLongtable{%
3228 % |\captionsetup| for longtable:
3229 % \begin{macrocode}
3230 \global\let\caption@opt@@longtable\@undefined
3231 \def\captionsetup{%
3232 \noalign\bgroup
3233 \@ifstar\@captionsetup\@captionsetup}% gobble *
3234 \def\@captionsetup#1{\LT@captionsetup{#1}\egroup}%
3235 \def\LT@captionsetup#1{%
3236 \captionsetup@startrue\caption@setup@options[@longtable]{#1}%
3237 \global\let\caption@opt@@longtable\caption@opt@@longtable}%
3238 % \end{macrocode}
3239 % |\captionlistentry| for longtable:
3240 % \begin{macrocode}
3241 \def\captionlistentry{%
3242 \noalign\bgroup
3243 \@ifstar{\egroup\LT@listentry\LTcaptype}% gobble *
3244 {\egroup\LT@listentry\LTcaptype}}%
3245 % \end{macrocode}
3246 % |\continuedfloat| for longtable:\\
3247 % {\small(Commented out, since it's not deeply tested and quite useless anyway)}
3248 % \Note{\package{hyperref} versions $<$ v6.76j uses $2\times$ \cs{hyper@makecurrent}}
3249 % \begin{macrocode}
3250 % \caption@ifhypcap{%
3251 % \let\caption@ORI@hyper@makecurrent\hyper@makecurrent
3252 % \def\hyper@makecurrent##1{%
3253 % \let\hyper@makecurrent\caption@ORI@hyper@makecurrent
3254 % \caption@makestart{##1}%
3255 %% \let\Hy@LT@currentHlabel\@currentHlabel
3256 % \let\Hy@LT@currentHref\@currentHref
3257 % \def\hyper@makecurrent####1{%
3258 %% \let\@currentHlabel\Hy@LT@currentHlabel
3259 % \let\@currentHref\Hy@LT@currentHref}}%
3260 % \let\caption@ORI@continuedfloat\continuedfloat
3261 % \def\continuedfloat{\noalign{%
3262 % \gdef\caption@setContinuedFloat{%
3263 % \let\caption@reset@continuedfloat\@gobble}%
3264 % \def\caption@setoptions##1{%
3265 % \g@addto@macro\caption@setContinuedFloat{%
3266 % \caption@setoptions{##1}}}%
3267 % \let\@captype\LTcaptype
3268 % \caption@ORI@ContinuedFloat}}%
3269 % }{%
3270 % \def\continuedfloat{\noalign{%
3271 % \caption@Error{%
3272 % \noexpand\continuedfloat inside longtables\MessageBreak
3273 % is only available with `hypcap=true'}}}%
3274 % }%
3275 % \global\let\caption@setContinuedFloat\@empty
3276 \def\continuedfloat{\noalign{%
3277 \caption@Error{\noexpand\continuedfloat outside float}}}%
3278 % \end{macrocode}
3279 % |\bicaption| for longtable:
3280 % \begin{macrocode}
3281 \let\bicaption\LT@bicaption
3282 % \end{macrocode}
3283 % \begin{macrocode}
3284 }%
3285 % \end{macrocode}
3286 % \end{macro}
3287 %
3288 % \begin{macro}{\LT@capti@n}
3289 % \changes{v3.3}{2016/02/01}{This re-definition added}
3290 % The original implementation:
3291 % \begin{verbatim}
3292 % \def\LT@capti@n{%
3293 % \@ifstar
3294 % {\egroup\LT@c@ption\@gobble[]}%
3295 % {\egroup\@xdblarg{\LT@c@ption\@firstofone}}}
3296 % \end{verbatim}%^^A
3297 % Our implementation uses |\caption@xdblarg| instead of |\@xdblarg|:
3298 % \begin{macrocode}
3299 \def\LT@capti@n{%
3300 \@ifstar
3301 {\egroup\LT@c@ption\@gobble[]}%
3302 {\egroup\caption@xdblarg{\LT@c@ption\@firstofone}}}%
3303 % \end{macrocode}
3304 % \end{macro}
3305 %
3306 % \begin{macro}{\LT@makecaption}
3307 % \changes{v3.0d}{2004/08/10}{Bugfix 04-08-04: \cs{abovecaptionskip} \& \cs{belowcaptionskip} will be used now}
3308 % \changes{v3.0e}{2005/05/05}{Bugfix: \cs{captionsetup[longtable]} overrides \cs{LTcapwidth} now}
3309 % \changes{v3.0h}{2005/10/07}{\cs{caption@LT@make} introduced}
3310 % \changes{v3.3}{2016/02/01}{Support for \cs{bicaption} via \cs{caption@LT@setup} added}
3311 % \changes{v3.3a}{2019/04/02}{Work-around for problem with \package{floatrow} added}
3312 % |\LT@makecaption|\marg{cmd}\marg{label}\marg{text}\par
3313 % \smallskip
3314 % The original definition:
3315 % \begin{verbatim}
3316 % \def\LT@makecaption#1#2#3{%
3317 % \LT@mcol\LT@cols c{\hbox to\z@{\hss\parbox[t]\LTcapwidth{%
3318 % % Based on article class "\@makecaption", "#1" is "\@gobble" in star
3319 % % form, and "\@firstofone" otherwise.
3320 % \sbox\@tempboxa{#1{#2: }#3}%
3321 % \ifdim\wd\@tempboxa>\hsize
3322 % #1{#2: }#3%
3323 % \else
3324 % \hbox to\hsize{\hfil\box\@tempboxa\hfil}%
3325 % \fi
3326 % \endgraf\vskip\baselineskip}%
3327 % \hss}}}
3328 % \end{verbatim}%^^A
3329 % Our definition:
3330 % \begin{macrocode}
3331 \renewcommand\LT@makecaption[3]{%
3332 \caption@LT@make{%
3333 \caption@LT@settype\LTcaptype
3334 % \end{macrocode}
3335 % |\caption@LT@setup| is re-defined inside the \package{bicaption} package
3336 % and contains the preparation of typesetting of the bilingual caption.
3337 % \begin{macrocode}
3338 \caption@LT@setup
3339 % \end{macrocode}
3340 % \iffalse
3341 % The default |position=| setting for longtables is |top|.
3342 % (This emulates the standard behavior of the \package{longtable} package
3343 % which has no skip above the caption but a skip below it.)
3344 % \fi
3345 % |position=auto| is a bad idea for longtables, but we do our very best.
3346 % This works quite well for captions inside the longtable contents, but
3347 % not for captions inside the longtable (end)foot.
3348 % \Note{This should be `top' if unclear!}
3349 % \begin{macrocode}
3350 \caption@setautoposition{\ifcase\LT@rows t\else b\fi}%
3351 % \end{macrocode}
3352 % We set |\ifcaption@star| according the 1st argument.
3353 % \begin{macrocode}
3354 \caption@startrue#1\caption@starfalse
3355 % \end{macrocode}
3356 % \begin{macrocode}
3357 \caption@prepare@stepcounter\LTcaptype{LT}%
3358 % \end{macrocode}
3359 % \changes{v3.1}{2007/05/05}{\cs{caption@font@normal} added}
3360 % \begin{macrocode}
3361 \caption@begin\LTcaptype
3362 \caption@normalsize
3363 % \end{macrocode}
3364 % The following skip has the purpose to correct the height of the
3365 % |\parbox[t]|. Usually it's the height of the very first line, but
3366 % because of our extra skips (|\abovecaptionskip| and |\belowcaptionskip|)
3367 % it's always |0pt|.\par
3368 % (A different idea would be typesetting the first skip outside the longtable
3369 % column with |\noalign{\vskip|\ldots|}|, but this means we have to move
3370 % |\caption@begin| to some other place because it does not work in tabular
3371 % mode. And at the moment I have no idea on how to do this in an elegant
3372 % way\ldots)
3373 % \begin{macrocode}
3374 \vskip-\ht\strutbox
3375 % \end{macrocode}
3376 % Work-around for problem with \package{floatrow}:
3377 % The |\below|\-|caption|\-|skip| disturbs the environment in which the caption is actually typeset (by creating extra, unwanted space),
3378 % so we supress this skip if the \package{floatrow} package is loaded.
3379 % (This fixes \issue{50})
3380 % \begin{macrocode}
3381 \caption@ifdefined\FBifcaptop{%
3382 \let\caption@belowskip\@empty}{}%
3383 % \end{macrocode}
3384 % The following code should look familiar. We do our skips and use
3385 % |\caption@@make| to typeset the caption itself.
3386 % \begin{macrocode}
3387 \caption@make@above
3388 \caption@@make{#2}{#3}\endgraf
3389 \caption@make@below
3390 \caption@end}}%
3391 % \end{macrocode}
3392 % \end{macro}
3393 %
3394 % \begin{macro}{\LT@listentry}
3395 % \changes{v3.3}{2018/08/26}{This macro added}
3396 % \changes{v3.3}{2018/10/05}{Bugfix: \cs{ignorespaces} added}
3397 % \changes{v3.3}{2018/12/26}{Bugfix: Missing curly braces added}
3398 % \begin{macrocode}
3399 \renewcommand*\LT@listentry[2]{%
3400 \begingroup
3401 \caption@LT@settype{#1}%
3402 \caption@listentry\@firstoftwo[{#1}]{#2}%
3403 \endgroup\ignorespaces}%
3404 % \end{macrocode}
3405 % \end{macro}
3406 %
3407 % \begin{macro}{\caption@LT@settype}
3408 % \changes{v3.3}{2018/08/26}{This macro added}
3409 % \changes{v3.3}{2018/10/05}{Uses argument no. 1 instead of \cs{LTcaptype}}
3410 % \begin{macrocode}
3411 \newcommand*\caption@LT@settype[1]{%
3412 \caption@settype*{#1}%
3413 % \end{macrocode}
3414 % If |\LTcapwidth| is not set to its default value |4in| we assume
3415 % that it shall overwrite our own setting.
3416 % (But |\captionsetup[longtable]{width=|\ldots|}| will overwrite |\LTcapwidth|.)
3417 % \begin{macrocode}
3418 \ifdim\LTcapwidth=4in \else
3419 \setcaptionwidth\LTcapwidth
3420 \fi
3421 % \end{macrocode}
3422 % \begin{macrocode}
3423 \caption@setoptions{longtable}%
3424 % \caption@setContinuedFloat
3425 % \end{macrocode}
3426 % Finally set options applied by |\captionsetup| inside the longtable.
3427 % \begin{macrocode}
3428 \caption@setoptions{@longtable}}%
3429 % \end{macrocode}
3430 % \end{macro}
3431 %
3432 % \begin{macro}{\flrow@setlist}
3433 % \changes{v3.4g}{2020/01/03}{Redefinition of this macro added}
3434 % The \package{floatrow} package uses |\flrow@setlist{{table}{longtable}}| inside its redefinition of |\LT@array| without setting |\@captype| first,
3435 % and this makes |\captionsetup[table]{name=...}| doomed to fail for longtables (``Undefined control sequence'').
3436 % Unfortunately we cannot easily patch |\LT@array| again to fix this bug in \package{floatrow} since it will be patched |\AtBeginDocument|.
3437 % Therefore we patch |\flrow@setlist| instead to catch and fix the bug on-the-fly.
3438 % \begin{macrocode}
3439 \caption@AtBeginDocument{\caption@ifdefined\flrow@setlist@{%
3440 \caption@InfoNoLine{Fixing longtable code of `floatrow' package}%
3441 \let\caption@flrow@setlist@\flrow@setlist@
3442 \renewcommand\flrow@setlist@[1]{%
3443 \def\caption@tempa{{table}{longtable}}%
3444 \def\caption@tempb{#1}%
3445 \ifx\caption@tempa\caption@tempb
3446 \def\@captype{table}%
3447 \fi
3448 \caption@flrow@setlist@{#1}}%
3449 }{}}%
3450 % \end{macrocode}
3451 % \end{macro}
3452 %
3453 % \begin{macrocode}
3454 }{%
3455 \let\caption@AtBeginLongtable\@gobble
3456 \let\caption@LT@array\@undefined
3457 }
3458 % \end{macrocode}
3459 %
3460 % \begin{macro}{\caption@LT@setup}
3461 % \changes{v3.3}{2016/02/01}{This macro added}
3462 % Hook for stuff which prepares the typesetting of the \package{longtable} caption.
3463 % \begin{macrocode}
3464 \providecommand*\caption@LT@setup{}
3465 % \end{macrocode}
3466 % \end{macro}
3467 %
3468 % \subsection{The picinpar package}
3469 % \changes{v3.1}{2007/06/13}{Support of the \package{picinpar} package added}
3470 %
3471 % \begin{macrocode}
3472 \caption@IfPackageLoaded{picinpar}{%
3473 % \end{macrocode}
3474 %
3475 % \begin{macro}{\figwindow}
3476 % \begin{macro}{\tabwindow}
3477 % The \package{picinpar} package comes with its own caption code
3478 % (|\wincaption|, |\@wincaption|, |\@makewincaption|, \ldots)
3479 % so we redefine |\figwindow| \& |\tabwindow| to use |\caption| instead.
3480 % \begin{macrocode}
3481 \long\def\figwindow[#1,#2,#3,#4] {%
3482 \caption@window{figure}%
3483 \caption@setoptions{figwindow}%
3484 \begin{window}[#1,#2,{#3},\caption@wincaption{#4}] }%
3485 % \end{macrocode}
3486 % \begin{macrocode}
3487 \long\def\tabwindow[#1,#2,#3,#4] {%
3488 \caption@window{table}%
3489 \caption@setoptions{tabwindow}%
3490 \begin{window}[#1,#2,{#3},\caption@wincaption{#4}] }%
3491 % \end{macrocode}
3492 % \end{macro}
3493 % \end{macro}
3494 %
3495 % \begin{macro}{\caption@window}
3496 % \changes{v3.1c}{2007/10/06}{Bugfix: \cs{caption@clearmargin} added}
3497 % Beside calling |\caption@settype| we redefine |\caption@par|\-|box|\-|restore|
3498 % (as in \package{floatflt} \& \package{picins} package support)
3499 % and |\@makecaption| (as in \package{float} package support) here.
3500 % \begin{macrocode}
3501 \newcommand*\caption@window[1]{%
3502 \let\@makecaption\caption@@make
3503 \caption@setautoposition b%
3504 \caption@settype{#1}%
3505 \caption@clearmargin
3506 \caption@setparboxrestore{full}}%
3507 % \end{macrocode}
3508 % \end{macro}
3509 %
3510 % \begin{macro}{\caption@wincaption}
3511 % \changes{v3.1d}{2007/10/25}{Missing \% added}
3512 % \changes{v3.3}{2013/04/14}{\cs{caption@ContinuedFloattrue} added}
3513 % \changes{v3.3}{2018/10/06}{\cs{caption@ContinuedFloattrue} replaced by \cs{caption@setflag1}}
3514 % This one finally typesets the caption using |\caption|.
3515 % \begin{macrocode}
3516 \newcommand\caption@wincaption[1]{%
3517 % \end{macrocode}
3518 % This will be done twice for every |figwindow| \& |tabwindow| caption --
3519 % on the first run |\picwd| is |0pt|, on the second run |\picwd| is |\hsize|.
3520 % \begin{macrocode}
3521 \ifdim\picwd=\z@
3522 \let\caption@makecurrent\@gobbletwo
3523 \let\caption@@start\relax
3524 \caption@prepareslc
3525 \else
3526 \caption@setflag1%
3527 \fi
3528 % \end{macrocode}
3529 % The argument |#1| could contain simply the caption text
3530 % (e.g.~|A figure caption|), but it could also contain an optional argument,
3531 % the \meta{lst\_entry}
3532 % (e.g.~|[An| |entry| |to| |the| |LOF]||{A| |figure| |caption}|).
3533 % Therefore we have to test if |#1| begins with~|[| or not; furthermore we
3534 % support a starred variant -- as in |\caption*| -- so we test for~|*|, too.
3535 % \begin{macrocode}
3536 \edef\@tempa{\expandafter\noexpand\@car#1\@nil}%
3537 \if\@tempa*%
3538 \let\@tempa\@firstofone
3539 \else\if\@tempa[%]
3540 \let\@tempa\@firstofone
3541 \else
3542 \let\@tempa\@empty
3543 \fi\fi
3544 \expandafter\caption\@tempa{#1}}%
3545 % \end{macrocode}
3546 % \end{macro}
3547 %
3548 % \begin{macrocode}
3549 }{}
3550 % \end{macrocode}
3551 %
3552 % \subsection{The picins package}
3553 % \changes{v3.0j}{2006/01/26}{Support of the \package{picins} package added}
3554 %
3555 % \begin{macro}{\piccaptiontype}
3556 % |\piccaptiontype|\marg{type}\par
3557 % We offer this macro for changing the \meta{type} of the caption, so the user
3558 % doesn't have to redefine |\@captype|, as proposed in the \package{picins}
3559 % documentation.
3560 % \Note{We define this macro here so it can be used in the
3561 % preamble of the document, even when \thispackage\ was loaded prior to the
3562 % \package{picins} package.}
3563 % \begin{macrocode}
3564 \newcommand*\piccaptiontype[1]{\def\@piccaptype{#1}}
3565 % \end{macrocode}
3566 % \end{macro}
3567 %
3568 % \begin{macrocode}
3569 \caption@IfPackageLoaded{picins}{%
3570 % \end{macrocode}
3571 %
3572 % Initial set |\@piccaptype| and undefine |\@captype| which was set to
3573 % |figure| by the \package{picins} package.
3574 % \begin{macrocode}
3575 \caption@ifundefined\@piccaptype{%
3576 \caption@iftype{%
3577 \let\@piccaptype\@captype
3578 }{%
3579 \def\@piccaptype{figure}%
3580 }%
3581 }{}%
3582 \let\@captype\@undefined
3583 % \end{macrocode}
3584 %
3585 % \begin{macro}{\piccaption}
3586 % The original code:
3587 % \begin{verbatim}
3588 % \def\piccaption{\@ifnextchar [{\@piccaption}{\@piccaption[]}}
3589 % \end{verbatim}%^^A
3590 % Our code uses |\caption@star| so |\piccaption*| works,
3591 % and |\caption@dblarg| so |\piccaption{}| works correctly.
3592 % \begin{macrocode}
3593 \def\piccaption{\caption@star\relax{\caption@dblarg\@piccaption}}%
3594 % \end{macrocode}
3595 % \end{macro}
3596 %
3597 % \begin{macro}{\make@piccaption}
3598 % \changes{v3.1}{2007/12/06}{Bugfix: \cs{caption@clearmargin} will always be used now}
3599 % The original code:
3600 % \begin{verbatim}
3601 % \def\make@piccaption{%
3602 % [...]
3603 % \setbox\@TEXT=\vbox{\hsize\hsiz@\caption[\sh@rtf@rm]{\capti@nt@xt}}%
3604 % }
3605 % \end{verbatim}%^^A
3606 % In our code we have to correct several things:
3607 % \begin{enumerate}
3608 % \item |\@captype| must be defined, since we have removed the global
3609 % definition.
3610 % \item We use |\caption@setoptions{parpic}| so
3611 % |\captionsetup[parpic]{|\ldots|}| is supported.
3612 % \item |\linewidth| must be set correctly.
3613 % Usually this is done by |\@parbox|\-|restore| inside |\@caption|,
3614 % but since we use |\@caption@parbox|\-|restore| we have to map this to
3615 % |\@parbox|\-|restore| instead.
3616 % \item The two arguments of |\caption| (|\sh@rtf@rm| \& |\capti@nt@xt|)
3617 % should be expanded on first level so |\caption[]{|\ldots|}| and
3618 % |\caption[|\ldots|]{}| work correctly.
3619 % \end{enumerate}
3620 % \begin{macrocode}
3621 \let\caption@ORI@make@piccaption\make@piccaption
3622 \def\make@piccaption{%
3623 \let\caption@ORI\caption
3624 % \end{macrocode}
3625 % \begin{macrocode}
3626 \long\def\caption[##1]##2{%
3627 \caption@freezeHref % will be defrosted in \ivparpic
3628 \caption@settype\@piccaptype
3629 % \ifnum\c@piccaptionpos>2\relax
3630 \caption@clearmargin
3631 % \else
3632 % \captionwidth\z@ % do not use "width=" setting
3633 % \fi
3634 \caption@setparboxrestore{full}%
3635 \caption@setoptions{parpic}%
3636 \caption@setautoposition b%
3637 % \end{macrocode}
3638 % \begin{macrocode}
3639 \expandafter\expandafter\expandafter\caption@ORI
3640 \expandafter\expandafter\expandafter[%
3641 \expandafter\expandafter\expandafter{%
3642 \expandafter##1\expandafter}\expandafter]\expandafter{##2}}%
3643 % \end{macrocode}
3644 % {\footnotesize\begin{quote}
3645 % \leavevmode\llap{-or-\quad}%^^A
3646 % |\begingroup|\\
3647 % | \toks0\expandafter{##1}| |\toks2\expandafter{##2}|\\
3648 % | \edef\x{\endgroup|\\
3649 % | \noexpand\caption@ORI[{\the\toks0}]{\the\toks2}}|\\
3650 % | \x|
3651 % \end{quote}
3652 % \begin{quote}
3653 % \leavevmode\llap{-or-\quad}%^^A
3654 % |\edef\x{%|\\
3655 % | \noexpand\caption@ORI[{\unexpanded\expandafter{##1}}]%|\\
3656 % | {\unexpanded\expandafter{##2}}}|\\
3657 % |\-|
3658 % \end{quote}}
3659 % \begin{macrocode}
3660 \caption@ORI@make@piccaption
3661 \let\caption\caption@ORI}%
3662 % \end{macrocode}
3663 % \end{macro}
3664 %
3665
3666 % \begin{macro}{\ivparpic}
3667 % \changes{v3.3}{2018/12/26}{Bugfix: Missing curly braces added}
3668 % We need to set our \package{hyperref} anchor here.
3669 % Not bullet-proof since we have to redefine |\noindent| here!
3670 % \begin{macrocode}
3671 \let\caption@ORI@ivparpic\ivparpic
3672 \def\ivparpic(#1,#2)(#3,#4)[#5][#6]#7{%
3673 \let\caption@ORI@noindent\noindent
3674 \def\noindent{%
3675 \caption@defrostHref
3676 \let\noindent\caption@ORI@noindent
3677 \noindent}%
3678 \caption@ORI@ivparpic(#1,#2)(#3,#4)[{#5}][{#6}]{#7}%
3679 \let\noindent\caption@ORI@noindent}%
3680 % \end{macrocode}
3681 % \end{macro}
3682 %
3683 % \begin{macrocode}
3684 }{%
3685 \let\piccaptiontype\@undefined
3686 }
3687 % \end{macrocode}
3688 %
3689 % \subsection{The rotating package}
3690 %
3691 % \begin{macrocode}
3692 \caption@IfPackageLoaded{rotating}[1995/08/22 v2.10]{%
3693 % \end{macrocode}
3694 %
3695 % \begin{macro}{\rotcaption}
3696 % \changes{v3.0c}{2004/07/16}{Bugfix: Check for \cs{caption@star} removed}
3697 % \changes{v3.0i}{2005/12/07}{Rewritten, works with \package{hyperref} now}
3698 % Make |\rotcaption*| work.
3699 % \begin{macrocode}
3700 \def\rotcaption{\let\@makecaption\@makerotcaption\caption}%
3701 % \let\@rotcaption\@undefined
3702 % \end{macrocode}
3703 % \end{macro}
3704 %
3705 % \begin{macro}{\rotcaptionof}
3706 % \changes{v3.0i}{2005/12/07}{New}
3707 % Make |\rotcaptionof(*)| work.
3708 % \begin{macrocode}
3709 \def\rotcaptionof{%
3710 \caption@teststar\caption@of{\rotcaption*}\rotcaption}%
3711 % \end{macrocode}
3712 % \end{macro}
3713 %
3714 % \begin{macro}{\@makerotcaption}
3715 % \changes{v3.0i}{2005/12/06}{Rewritten, should finally work proper now}
3716 % \changes{v3.0m}{2007/03/04}{Uses \cs{caption@parbox} instead of \cs{caption@start/endbox} now}
3717 % \changes{v3.3}{2012/12/26}{Rewritten (again)}
3718 % Original (bugfixed) code:
3719 % \begin{verbatim}
3720 % \long\def\@makerotcaption#1#2{%
3721 % \setbox\@tempboxa\hbox{#1: #2}%
3722 % \ifdim \wd\@tempboxa > .8\vsize
3723 % \rotatebox{90}{%
3724 % \begin{minipage}{.8\textheight}#1: #2\end{minipage}%
3725 % }%\par % <== \par removed (AR)
3726 % \else%
3727 % \rotatebox{90}{\box\@tempboxa}%
3728 % \fi
3729 % \nobreak\hspace{12pt}% <== \nobreak added (AR)
3730 % }
3731 % \end{verbatim}%^^A
3732 % Our version emulates this behavior, but if |width=| is set,
3733 % the rotated caption is always typeset as |\parbox|.
3734 % (Note that |margin=| is not supported here.)
3735 % \begin{macrocode}
3736 \long\def\@makerotcaption#1#2{%
3737 \rotatebox{90}{%
3738 \ifdim\captionwidth=\z@
3739 \setcaptionwidth{.8\vsize}%
3740 \l@addto@macro\caption@singleline{%
3741 \caption@setup{parbox=none}}%
3742 \fi
3743 \let\caption@calcmargin\relax
3744 \caption@@make{#1}{#2}}%
3745 \nobreak\hspace{12pt}}%
3746 % \end{macrocode}
3747 % \end{macro}
3748 %
3749 % \begin{macrocode}
3750 }{}
3751 % \end{macrocode}
3752 %
3753 % \subsection{The sidecap package}
3754 %
3755 % \begin{macrocode}
3756 \caption@IfPackageLoaded{sidecap}[2003/06/06 v1.6f]{%
3757 \caption@setbool{needfreeze}{1}%
3758 % \end{macrocode}
3759 %
3760 % \begin{macro}{\SC@zfloat}
3761 % \changes{v3.0b}{2004/05/16}{Local definition of \cs{captionsetup} added}
3762 % \changes{v3.0c}{2004/07/16}{Bugfix 04-07-15: Check for \cs{caption@star} removed}
3763 % \changes{v3.1c}{2007/10/06}{\cs{caption} will be saved \& restored now}
3764 % \changes{v3.2a}{2011/08/17}{Bugfix: Uses \cs{caption@freeze} instead of \cs{caption@freeze*} now}
3765 % \changes{v3.3}{2013/05/01}{Usage of \cs{caption@freeze} replaced by \cs{caption@freezetype}}
3766 % \changes{v3.5i}{2022/07/10}{\cs{ignorespaces} appended}
3767 % This macro will be called at the start of the environment, here is a good
3768 % opportunity to do some adaptations to |\caption| and |\captionsetup|.
3769 % \begin{macrocode}
3770 \let\caption@ORI@SC@zfloat\SC@zfloat
3771 \def\SC@zfloat#1#2#3[#4]{%
3772 % \end{macrocode}
3773 % First we use the original definition, but restore \cs{caption} and \cs{label}
3774 % so \cs{caption@freeze} and \cs{caption@warmup} will work correctly.
3775 % \begin{macrocode}
3776 \caption@ORI@SC@zfloat{#1}{#2}{#3}[#4]%
3777 \SC@RestoreCommands
3778 % \end{macrocode}
3779 % Since the sidecap package uses our |\caption| code outside the
3780 % environment the regular |\caption|\-|setup| will not work.
3781 % So we need a special version here which saves the given argument list
3782 % which will be executed later on.
3783 % Furthermore we need to make |\caption*| work.
3784 % \begin{macrocode}
3785 \caption@freezetype{#2}%
3786 % \end{macrocode}
3787 % The sidecap package uses |\ifx\label\SC@label| to test if it is just inside a
3788 % |SC|\-|figure| or not. So we redefine |\SC@label| here so this test will still work.
3789 % \begin{macrocode}
3790 \let\SC@label\label
3791 % \end{macrocode}
3792 % Since the original definition of |\SC@zfloat| ends with |\begin{lrbox}| which ends with |\ignore|\-|spaces|,
3793 % we do have to end our re-definition of |\SC@zfloat| with |\ignore|\-|spaces| as well.
3794 % \begin{macrocode}
3795 \ignorespaces}%
3796 % \end{macrocode}
3797 % \begin{macrocode}
3798 \providecommand*\SC@RestoreCommands{%
3799 \let\caption=\SC@orig@caption \let\label=\SC@orig@label}%
3800 % \end{macrocode}
3801 % \end{macro}
3802 %
3803 % \begin{macro}{\endSC@FLOAT}
3804 % \changes{v3.0i}{2006/01/12}{\cs{@listdepth}\cs{z@} added}
3805 % \changes{v3.1}{2007/05/05}{Call of \cs{caption@setoptions}\arg{SCfloat} added}
3806 % This macro will be called at the end of the environment, here we need to
3807 % setup our stuff before the \package{sidecap} package actually typesets
3808 % its caption.
3809 % \begin{macrocode}
3810 \let\caption@ORI@endSC@FLOAT\endSC@FLOAT
3811 \def\endSC@FLOAT{%
3812 % \end{macrocode}
3813 % Before we can typeset the caption we need to set the margin to zero
3814 % because any extra margin would only be disturbing here.\par
3815 % (We don't need to take care about the caption position because
3816 % the sidecap package set both |\abovecaptionskip| and |\belowcaptionskip|
3817 % to a skip of zero anyway.)\par
3818 % Furthermore |\SC@justify| will override the caption justification, if set.
3819 % The usage of |\SC@justify| differs from version to version of the
3820 % \package{sidecap} package:\par
3821 % \begin{tabular}{ll}
3822 % Version 1.4: & |\SC@justify| is not defined\\
3823 % Version 1.5: & |\SC@justify| is |\relax| when not set\\
3824 % Version 1.6: & |\SC@justify| is |\@empty| when not set\\
3825 % \end{tabular}
3826 % \begin{macrocode}
3827 \def\caption@setSC@justify{%
3828 \caption@clearmargin
3829 \ifx\SC@justify\@empty \else
3830 \let\caption@justification\SC@justify
3831 \let\SC@justify\@empty
3832 \fi}%
3833 % \end{macrocode}
3834 % Make the original definition of |\endSC@FLOAT| to use our caption
3835 % stuff instead of its own.
3836 % \Note{At this point the \package{sidecap} definition of \cs{caption} is valid,
3837 % not the regular one!}
3838 % \begin{macrocode}
3839 \let\caption\SC@orig@caption
3840 \def\SC@orig@caption[##1]##2{%
3841 \caption@setSC@justify
3842 %%% \caption@setoptions{SC}%
3843 \caption@setoptions{SC\@captype}%
3844 \caption@defrost}%
3845 % \end{macrocode}
3846 % Finally we call the original definition of |\endSC@FLOAT|.
3847 % \begin{macrocode}
3848 \caption@setSC@justify % for compatibility mode
3849 \caption@prepare@defrost
3850 \caption@ORI@endSC@FLOAT}%
3851 % \end{macrocode}
3852 % \end{macro}
3853 %
3854 % \begin{macrocode}
3855 }{}
3856 % \end{macrocode}
3857 %
3858 % \subsection{The subfigure package}
3859 % \changes{v3.1}{2007/04/06}{subfigure package support added}
3860 %
3861 % \begin{macrocode}
3862 \caption@IfPackageLoaded{subfigure}[2002/01/23 v2.1]{%
3863 % \end{macrocode}
3864 %
3865 % \begin{macro}{\sf@ifpositiontop}
3866 % \changes{v3.1a}{2007/09/15}{Bugfix 07-09-15: Check for \cs{@captype} added}
3867 % If the \package{subfigure} package is loaded, we map |\sf@ifpositiontop|
3868 % to |\iffiguretopcap| resp. |\iftabletopcap|, so the \package{subfigure}
3869 % \version{2.1} options \opt{figbotcap} etc. will still work.
3870 % \begin{macrocode}
3871 \def\sf@ifpositiontop{%
3872 \ifx\@captype\@undefined
3873 \expandafter\@gobbletwo
3874 \else\ifx\@captype\relax
3875 \expandafter\expandafter\expandafter\@gobbletwo
3876 \else
3877 \expandafter\expandafter\expandafter\sf@if@position@top
3878 \fi\fi}
3879 % \end{macrocode}
3880 % \begin{macrocode}
3881 \def\sf@if@position@top{%
3882 \@ifundefined{if\@captype topcap}%
3883 {\@gobbletwo}%
3884 {\@nameuse{if\@captype topcap}%
3885 \expandafter\@firstoftwo
3886 \else
3887 \expandafter\@secondoftwo
3888 \fi}}
3889 % \end{macrocode}
3890 % \end{macro}
3891 %
3892 % \begin{macrocode}
3893 }{}
3894 % \end{macrocode}
3895 %
3896 % \subsection{The supertabular and xtab packages}
3897 %
3898 % \begin{macrocode}
3899 \caption@IfPackageLoaded{supertabular}[2002/07/19 v4.1e]{%
3900 % \end{macrocode}
3901 %
3902 % \begin{macro}{\tablecaption}
3903 % \changes{v3.0e}{2005/05/05}{Made \cs{topcaption*} and \cs{bottomcaption*} work}
3904 % \changes{v3.1h}{2008/04/01}{Bugfix: Star variant does not increment table counter anymore}
3905 % Make |\topcaption*| and |\bottomcaption*| work.
3906 % \begin{macrocode}
3907 \renewcommand*\tablecaption{%
3908 \caption@star
3909 {\refstepcounter{table}}%
3910 {\caption@dblarg{\@xtablecaption}}}%
3911 % \end{macrocode}
3912 % \end{macro}
3913 %
3914 % \begin{macro}{\@xtablecaption}
3915 % \changes{v3.1h}{2008/04/01}{Made \cs{nameref} \& \cs{autoref} work}
3916 % \changes{v3.1l}{2010/01/09}{Adapted to current version of nameref package}
3917 % \changes{v3.3}{2018/12/26}{Bugfix: Missing curly braces added}
3918 % Make |\nameref| and |\autoref| work.
3919 % \begin{macrocode}
3920 \let\caption@ORI@xtablecaption\@xtablecaption
3921 \long\def\@xtablecaption[#1]#2{%
3922 \caption@gettitle{#2}%
3923 \caption@ORI@xtablecaption[{#1}]{#2}}%
3924 % \end{macrocode}
3925 % \end{macro}
3926 %
3927 % \begin{macro}{\ST@caption}
3928 % \changes{v3.0a}{2004/01/23}{Bugfix: Missing \cs{par} added}
3929 % \changes{v3.1h}{2008/04/01}{Bugfix: \cs{@currentlabelname} will be set now}
3930 % The original code:
3931 % \begin{verbatim}
3932 % \long\def\ST@caption#1[#2]#3{\par%
3933 % \addcontentsline{\csname ext@#1\endcsname}{#1}%
3934 % {\protect\numberline{%
3935 % \csname the#1\endcsname}{\ignorespaces #2}}
3936 % \begingroup
3937 % \@parboxrestore
3938 % \normalsize
3939 % \if@topcaption \vskip -10\p@ \fi
3940 % \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
3941 % \if@topcaption \vskip 10\p@ \fi
3942 % \endgroup}
3943 % \end{verbatim}%^^A
3944 % \begin{macrocode}
3945 \long\def\ST@caption#1[#2]#3{\par%
3946 \caption@settype*{#1}%
3947 \caption@setoptions{supertabular}%
3948 % \end{macrocode}
3949 % The |position=| setting will be overwritten by the
3950 % \package{supertabular} package: If |\topcaption| was used,
3951 % the position will be |top| automatically, |bottom| otherwise.
3952 % \begin{macrocode}
3953 \caption@setposition{\if@topcaption t\else b\fi}%
3954 % \end{macrocode}
3955 % \begin{macrocode}
3956 \caption@beginex{#1}{#2}{#3}%
3957 \caption@parboxrestore
3958 \caption@normalsize
3959 \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
3960 \caption@end}%
3961 % \end{macrocode}
3962 % \end{macro}
3963 %
3964 % \begin{macrocode}
3965 }{}
3966 % \end{macrocode}
3967 %
3968 % \changes{v3.1h}{2008/04/01}{Support of the xtab package added}
3969 % \begin{macrocode}
3970 \caption@IfPackageLoaded{xtab}[2000/04/09 v2.3]{%
3971 % \end{macrocode}
3972 %
3973 % \begin{macro}{\tablecaption}
3974 % Make |\topcaption*| and |\bottomcaption*| work.
3975 % \begin{macrocode}
3976 \renewcommand*\tablecaption{%
3977 \caption@star
3978 {\refstepcounter{table}}%
3979 {\caption@dblarg{\@xtablecaption}}}%
3980 % \end{macrocode}
3981 % \end{macro}
3982 %
3983 % \begin{macro}{\@xtablecaption}
3984 % \changes{v3.1l}{2010/01/09}{Adapted to current version of nameref package}
3985 % \changes{v3.3}{2018/12/26}{Bugfix: Missing curly braces added}
3986 % Make |\nameref| and |\autoref| work.
3987 % \begin{macrocode}
3988 \let\caption@ORI@xtablecaption\@xtablecaption
3989 \long\def\@xtablecaption[#1]#2{%
3990 \caption@gettitle{#2}%
3991 \caption@ORI@xtablecaption[{#1}]{#2}}%
3992 % \end{macrocode}
3993 % \end{macro}
3994 %
3995 % \begin{macro}{\ST@caption}
3996 % The original code:
3997 % \begin{verbatim}
3998 % \long\def\ST@caption#1[#2]#3{\par%
3999 % \@initisotab
4000 % \addcontentsline{\csname ext@#1\endcsname}{#1}%
4001 % {\protect\numberline{%
4002 % \csname the#1\endcsname}{\ignorespaces #2}}%
4003 % \begingroup
4004 % \@parboxrestore
4005 % \normalsize
4006 % %% \if@topcaption \vskip -10\p@ \fi
4007 % \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
4008 % %% \if@topcaption \vskip 10\p@ \fi
4009 % \endgroup
4010 % \global\advance\ST@pageleft -\PWSTcapht
4011 % \ST@trace\tw@{Added caption. Space left for xtabular: \the\ST@pageleft}}
4012 % \end{verbatim}%^^A
4013 % \begin{macrocode}
4014 \long\def\ST@caption#1[#2]#3{\par%
4015 \caption@settype*{#1}%
4016 \caption@setoptions{xtabular}%
4017 % \end{macrocode}
4018 % \begin{macrocode}
4019 \caption@set{position}{\if@topcaption t\else b\fi}%
4020 % \end{macrocode}
4021 % \begin{macrocode}
4022 \@initisotab
4023 \caption@beginex{#1}{#2}{#3}%
4024 \caption@parboxrestore
4025 \caption@normalsize
4026 \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
4027 \caption@end
4028 \global\advance\ST@pageleft -\PWSTcapht
4029 \ST@trace\tw@{Added caption. Space left for xtabular: \the\ST@pageleft}}%
4030 % \end{macrocode}
4031 % \end{macro}
4032 %
4033 % \begin{macrocode}
4034 }{}
4035 % \end{macrocode}
4036 %
4037 % \subsection{The threeparttable package}
4038 % \changes{v3.1}{2007/05/08}{Support of the \package{threeparttable} package added}
4039 %
4040 % \begin{macrocode}
4041 \caption@IfPackageLoaded{threeparttable}[2003/06/13 v3.0]{%
4042 % \end{macrocode}
4043 %
4044 % \begin{macro}{\threeparttable}
4045 % \changes{v3.3}{2016/01/31}{Bugfix: \cs{@captype} will be used if already defined}
4046 % Unfortunately |\@captype| is not set when |\TPT@common| will be used,
4047 % so we have to redefine |\threeparttable| and |\measuredfigure| instead.
4048 % \begin{macrocode}
4049 \let\caption@ORI@threeparttable\threeparttable
4050 \renewcommand*\threeparttable{%
4051 \caption@settype{\@ifundefined{@captype}{table}{\@captype}}%
4052 %%% \caption@setposition{auto}% ?
4053 \caption@clearmargin
4054 \caption@setoptions{threeparttable}%
4055 \caption@ORI@threeparttable}%
4056 % \end{macrocode}
4057 % \end{macro}
4058 % \begin{macro}{\measuredfigure}
4059 % \changes{v3.3}{2016/01/31}{Bugfix: \cs{@captype} will be used if already defined}
4060 % Same here\ldots
4061 % \begin{macrocode}
4062 \let\caption@ORI@measuredfigure\measuredfigure
4063 \renewcommand*\measuredfigure{%
4064 \caption@settype{\@ifundefined{@captype}{figure}{\@captype}}%
4065 %%% \caption@setposition{auto}% ?
4066 \caption@clearmargin
4067 \caption@setoptions{measuredfigure}%
4068 \caption@ORI@measuredfigure}%
4069 % \end{macrocode}
4070 % \end{macro}
4071 %
4072 % \begin{macro}{\TPT@caption}
4073 % The original code:
4074 % \begin{verbatim}
4075 % \def\TPT@caption#1[#2]#3{\gdef\TPT@docapt
4076 % {\par\global\let\TPT@docapt\@undefined \TPT@LA@caption{#1}[{#2}]%
4077 % {\strut\ignorespaces#3\ifhmode\unskip\@finalstrut\strutbox\fi}}%
4078 % \ifx\TPT@hsize\@empty \let\label\TPT@gatherlabel \abovecaptionskip\z@skip
4079 % \else \TPT@docapt \fi \ignorespaces}
4080 % \end{verbatim}%^^A
4081 % \begin{macrocode}
4082 \def\TPT@caption#1[#2]#3{%
4083 \gdef\TPT@docapt{%
4084 \global\let\TPT@docapt\@undefined
4085 \caption@setautoposition\caption@TPT@position
4086 \TPT@LA@caption{#1}[{#2}]{#3}}%
4087 \ifx\TPT@hsize\@empty
4088 \let\label\TPT@gatherlabel % Bug: does not work for measuredfigures
4089 \gdef\caption@TPT@position{t}%
4090 \g@addto@macro\TPT@docapt\caption@TPT@eatvskip
4091 \else
4092 \def\caption@TPT@position{b}%
4093 \TPT@docapt
4094 \fi
4095 \ignorespaces}%
4096 % \end{macrocode}
4097 % \begin{macrocode}
4098 %\newcommand*\caption@TPT@eatvskip{\vskip-.2\baselineskip}%
4099 \def\caption@TPT@eatvskip#1\vskip{#1\@tempdima=}%
4100 % \end{macrocode}
4101 % \end{macro}
4102 %
4103 % \begin{macrocode}
4104 }{}
4105 % \end{macrocode}
4106 %
4107 % \subsection{The wrapfig package}
4108 % \changes{v3.1}{2007/05/05}{Support of the \package{wrapfig} package added}
4109 % \changes{v3.2d}{2011/11/02}{Support of the \package{wrapfig} package rewritten}
4110 %
4111 % \begin{macrocode}
4112 \caption@IfPackageLoaded{wrapfig}[2003/01/31 v3.6]{%
4113 % \end{macrocode}
4114 %
4115 % \begin{macro}{\wrapfloat}
4116 % \changes{v3.2d}{2011/11/02}{Redefinition of this macro added}
4117 % First of all we make the \package{wrapfig} package independent from the package
4118 % load order regarding the \package{float} package.
4119 % Since the usage of |\@float@set|\-|every| is missing in the code of the \package{wrapfig}
4120 % package (it should be in the redefinition of |\float@re|\-|style|, right after
4121 % |\@nameuse{fst@#1}|), we don't use it here, too,
4122 % especially since |\wrap|\-|float| will usually not be used when used with re-styled floats.
4123 % \begin{macrocode}
4124 \renewcommand*\wrapfloat[1]{%
4125 \def\@captype{#1}%
4126 \@ifundefined{fst@#1}{}{%
4127 \@nameuse{fst@#1}%
4128 % \@float@setevery{#1}%
4129 \def\WF@floatstyhook{\let\@currbox\WF@box
4130 \global\setbox\WF@box\float@makebox{\wd\WF@box}}}%
4131 \@ifnextchar[\WF@wr{\WF@wr[]}}
4132 % \end{macrocode}
4133 % \end{macro}
4134 %
4135 % \begin{macro}{\WF@rapt}
4136 % \changes{v3.2d}{2011/11/02}{Usage of \cs{WF@captionstyhook} added}
4137 % Original code:
4138 % \begin{verbatim}
4139 % \def\WF@rapt[#1]#2{% final two args: #1 = overhang, #2 = width,
4140 % \gdef\WF@ovh{#1}% hold overhang for later, when \width is known
4141 % \global\setbox\WF@box\vtop\bgroup \setlength\hsize{#2}%
4142 % \ifdim\hsize>\z@ \@parboxrestore \else
4143 % \setbox\z@\hbox\bgroup \let\wf@@caption\caption \let\caption\wf@caption
4144 % \ignorespaces \fi}
4145 % \end{verbatim}%^^A
4146 % Our code has |\WF@captionstyhook| in addition:
4147 % \begin{macrocode}
4148 \def\WF@rapt[#1]#2{% final two args: #1 = overhang, #2 = width,
4149 \gdef\WF@ovh{#1}% hold overhang for later, when \width is known
4150 \global\setbox\WF@box\vtop\bgroup \setlength\hsize{#2}%
4151 \expandafter\WF@captionstyhook\expandafter{\@captype}% <= new
4152 \ifdim\hsize>\z@ \@parboxrestore \else
4153 \setbox\z@\hbox\bgroup \let\wf@@caption\caption \let\caption\wf@caption
4154 \ignorespaces \fi}%
4155 % \end{macrocode}
4156 % \end{macro}
4157 %
4158 % \begin{macro}{\WF@captionstyhook}
4159 % \changes{v3.2d}{2011/11/02}{This macro added}
4160 % \changes{v3.2e}{2011/11/10}{Bugfix 11-11-09: float package support fixed}
4161 % We place our \package{hyperref} anchor here, apply the `wrap' options etc.
4162 % Since the usage of |\@float@set|\-|every| is missing in the \package{wrapfig}
4163 % package we will catch it up here for making the necessary adaptions to the
4164 % \package{float} package.
4165 % \begin{macrocode}
4166 \def\WF@captionstyhook#1{%
4167 \let\@captype\@undefined
4168 \@ifundefined{fst@#1}{}{\@float@setevery{#1}}%
4169 \caption@settype{#1}%
4170 \caption@clearmargin
4171 %%% \caption@setoptions{wrap}%
4172 \caption@setoptions{wrap#1}}%
4173 % \end{macrocode}
4174 % \end{macro}
4175 %
4176 % \begin{macrocode}
4177 }{}
4178 % \end{macrocode}
4179 %
4180 % \section{That's all Folks!}
4181 %
4182 % Execute the code declared with |\After|\-|Caption|\-|Package|.
4183 %
4184 % \begin{macrocode}
4185 \caption@endtitles@code
4186 \let\caption@endtitles@code\@undefined
4187 \let\AfterCaptionPackage\@firstofone
4188 % \end{macrocode}
4189 %
4190 % \iffalse
4191 %</package>
4192 % \fi
4193 %
4194 % \iffalse
4195 % --------------------------------------------------------------------------- %
4196 % \fi
4197 %
4198 % \clearpage
4199 % \begin{thebibliography}{99}
4200 % \bibitem{float}
4201 % Anselm Lingnau:\\
4202 % \href{http://www.ctan.org/pkg/float}%
4203 % {\emph{An Improved Environment for Floats}},\\
4204 % 2001/11/08
4205 %
4206 % \bibitem{floatflt}
4207 % Mats Dahlgren:\\
4208 % \href{http://www.ctan.org/pkg/floatflt}%
4209 % {\emph{Welcome to the floatflt package}},\\
4210 % 1998/06/05
4211 %
4212 % \bibitem{floatrow}
4213 % Olga Lapko:\\
4214 % \href{http://www.ctan.org/pkg/floatrow}%
4215 % {\emph{The floatrow package documentation}},\\
4216 % 2009/08/02
4217 %
4218 % \bibitem{fltpage}
4219 % Sebastian Gross:\\
4220 % \href{http://www.ctan.org/pkg/fltpage}%
4221 % {\emph{Welcome to the beta test of fltpage package!}},\\
4222 % 1998/11/13
4223 %
4224 % \bibitem{hyperref}
4225 % Sebastian Rahtz \& Heiko Oberdiek:\\
4226 % \href{http://www.ctan.org/pkg/hyperref}%
4227 % {\emph{Hypertext marks in \LaTeX: a manual for hyperref}},\\
4228 % November 2012
4229 %
4230 % \bibitem{hypcap}
4231 % Heiko Oberdiek:\\
4232 % \href{http://www.ctan.org/pkg/oberdiek}%
4233 % {\emph{The hypcap package -- Adjusting anchors of captions}},\\
4234 % 2011/02/16
4235 %
4236 % \bibitem{listings}
4237 % Carsten Heinz \& Brooks Moses:\\
4238 % \href{http://www.ctan.org/pkg/listings}%
4239 % {\emph{The Listings Package}},\\
4240 % 2007/02/22
4241 %
4242 % \bibitem{longtable}
4243 % David Carlisle:\\
4244 % \href{http://www.ctan.org/pkg/longtable}%
4245 % {\emph{The longtable package}},\\
4246 % 2004/02/01
4247 %
4248 % \bibitem{picinpar}
4249 % Friedhelm Sowa:\\
4250 % \href{http://www.ctan.org/pkg/picinpar}%
4251 % {\emph{Pictures in Paragraphs}},\\
4252 % July 13, 1993
4253 %
4254 % \bibitem{picins}
4255 % Joachim Bleser and Edmund Lang:\\
4256 % \href{http://www.ctan.org/pkg/picins}%
4257 % {\emph{PicIns-Benutzerhandbuch Version 3.0}},\\
4258 % September~1992
4259 %
4260 % \bibitem{rotating}
4261 % Sebastian Rahtz and Leonor Barroca:\\
4262 % \href{http://www.ctan.org/pkg/rotating}%
4263 % {\emph{A style option for rotated objects in \LaTeX}},\\
4264 % 1997/09/26
4265 %
4266 % \bibitem{sidecap}
4267 % Rolf Niepraschk \& Hubert G\"a\ss lein:\\
4268 % \href{http://www.ctan.org/pkg/sidecap}%
4269 % {\emph{The sidecap package}},\\
4270 % 2003/06/06
4271 %
4272 % \bibitem{subfigure}
4273 % Steven D. Cochran:\\
4274 % \href{http://www.ctan.org/pkg/subfigure}%
4275 % {\emph{The subfigure package}},\\
4276 % 2005/03/15
4277 %
4278 % \bibitem{subfig}
4279 % Steven D. Cochran:\\
4280 % \href{http://www.ctan.org/pkg/subfig}%
4281 % {\emph{The subfig package}},\\
4282 % 2005/07/05
4283 %
4284 % \bibitem{supertabular}
4285 % Johannes Braams and Theo Jurriens:\\
4286 % \href{http://www.ctan.org/pkg/supertabular}%
4287 % {\emph{The supertabular environment}},\\
4288 % 2004/02/20
4289 %
4290 % \bibitem{threeparttable}
4291 % Donald Arseneau:\\
4292 % \href{http://www.ctan.org/pkg/threeparttable}%
4293 % {\emph{Three part tables: title, tabular environment, notes}},\\
4294 % March 5, 2010
4295 %
4296 % \bibitem{wrapfig}
4297 % Donald Arseneau:\\
4298 % \href{http://www.ctan.org/pkg/wrapfig}%
4299 % {\emph{WRAPFIG.STY ver 3.6}},\\
4300 % Jan 31, 2003
4301 %
4302 % \bibitem{xtab}
4303 % Peter Wilson:\\
4304 % \href{http://www.ctan.org/pkg/xtab}%
4305 % {\emph{The xtab package}},\\
4306 % 2011/07/31
4307 % \end{thebibliography}
4308 %
4309 % \iffalse
4310 % --------------------------------------------------------------------------- %
4311 % \fi
4312 %
4313 % \clearpage
4314 % \Finale
4315 %
4316 \endinput