From 675bcc9067ccef91624a9eca025506a4ce1d37b3 Mon Sep 17 00:00:00 2001
From: Norbert Preining <norbert@preining.info>
Date: Tue, 12 May 2020 03:03:03 +0000
Subject: CTAN sync 202005120303

---
 macros/latex/contrib/caption/caption3.dtx | 604 +++++++++++++++++++-----------
 1 file changed, 380 insertions(+), 224 deletions(-)

(limited to 'macros/latex/contrib/caption/caption3.dtx')

diff --git a/macros/latex/contrib/caption/caption3.dtx b/macros/latex/contrib/caption/caption3.dtx
index 5cd6a8d9ea..7319d178df 100644
--- a/macros/latex/contrib/caption/caption3.dtx
+++ b/macros/latex/contrib/caption/caption3.dtx
@@ -28,7 +28,7 @@
 %   caption-deu.tex, caption-eng.tex, caption-rus.tex.
 % 
 % \fi
-% \CheckSum{3476}
+% \CheckSum{3573}
 %
 % \iffalse
 %<*driver>
@@ -191,7 +191,7 @@
 %
 %    \begin{macrocode}
 \NeedsTeXFormat{LaTeX2e}[1994/12/01]
-\ProvidesPackage{caption3}[2020/01/03 v1.8h caption3 kernel (AR)]
+\ProvidesPackage{caption3}[2020/05/10 v1.11 caption3 kernel (AR)]
 %    \end{macrocode}
 %
 % \section{Workaround for bug in package \package{arabtex}}
@@ -773,7 +773,6 @@
 % \begin{macro}{\caption@checkoptions}
 % \changes{v1.8h}{2020/01/03}{This macro added}
 % Check the syntax of the given options by executing them inside a group.
-% (This way the \package{ragged2e} package check will be done for these options, too.)
 %    \begin{macrocode}
 \newcommand*\caption@checkoptions[1]{%
   \begingroup
@@ -781,11 +780,21 @@
     \caption@setup{#1}%
   \endgroup}
 %    \end{macrocode}
-% Some caption options depend on the definition of |\@captype|,
-% so we set it to |figure| before executing them.
 %    \begin{macrocode}
-\newcommand*\caption@prepare@optioncheck{%
-  \def\@captype{figure}}
+\providecommand*\caption@prepare@optioncheck{}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\IfCaptionOptionCheck}
+% \changes{v1.10}{2020/05/10}{This macro added}
+% |\IfCaptionOptionCheck|\marg{yes-code}\marg{no-code}
+% executes the \meta{yes-code} if options are just checked for syntax, and \meta{no-code} if not.
+%    \begin{macrocode}
+\let\IfCaptionOptionCheck\@secondoftwo
+%    \end{macrocode}
+%    \begin{macrocode}
+\g@addto@macro\caption@prepare@optioncheck{%
+  \let\IfCaptionOptionCheck\@firstoftwo}
 %    \end{macrocode}
 % \end{macro}
 %
@@ -1078,17 +1087,17 @@
 %  will both be mapped to \meta{code} with \meta{package} and \meta{options}
 %  as arguments |#1| and |#2|. (This helps avoiding ``Option clash'' errors.)
 %    \begin{macrocode}
-\newcommand*\caption@packagelist{}
-\@onlypreamble\caption@packagelist
-%    \end{macrocode}
-%    \begin{macrocode}
 \newcommand\caption@SetupOptions[2]{%
   \@namedef{caption@setkeys@#1}##1##2{#2}%
   \expandafter\@onlypreamble\csname caption@setkeys@#1\endcsname
-  \@cons\caption@packagelist{{#1}}}
+  \@cons\caption@SetupOptions@list{{#1}}}
 \@onlypreamble\caption@SetupOptions
 %    \end{macrocode}
 %    \begin{macrocode}
+\newcommand*\caption@SetupOptions@list{}
+\@onlypreamble\caption@SetupOptions@list
+%    \end{macrocode}
+%    \begin{macrocode}
 \let\caption@onefilewithoptions\@onefilewithoptions
 \def\@onefilewithoptions#1[#2]{%
   \begingroup
@@ -1104,7 +1113,7 @@
         \caption@ExecuteOptions{#1}{#2}%
         \caption@onefilewithoptions{#1}[]}%
     \fi}
-  \caption@packagelist
+  \caption@SetupOptions@list
   \@tempa}
 \@onlypreamble\caption@onefilewithoptions
 %    \end{macrocode}
@@ -1891,16 +1900,44 @@
 % \changes{v1.0a}{2004/01/22}{Bugfix: Multi token arguments are allowed now}
 % \changes{v1.1}{2007/05/07}{Internal: Uses \cs{caption@fnt} instead of \cs{caption@temp} now}
 % \changes{v1.8h}{2020/01/03}{Check for \package{ragged2e} package related options added}
-%  |\DeclareCaptionFont|\marg{name}\marg{code}
+% \changes{v1.10}{2020/05/10}{Optional argument \opt{package} added}
+%  |\DeclareCaptionFont|\oarg{package}\marg{name}\marg{code}
 %    \begin{macrocode}
-\newcommand*\DeclareCaptionFont[2]{%
-  \define@key{caption@fnt}{#1}[]{\caption@addto@fnt{#2}}}
+\newcommand*\DeclareCaptionFont{%
+  \@ifnextchar[%]
+    \caption@declare@font
+    \caption@declarefont}
 \@onlypreamble\DeclareCaptionFont
 %    \end{macrocode}
 %    \begin{macrocode}
-\newcommand*\caption@addto@fnt[1]{%
-  \caption@check@ragged{#1}%
-  \l@addto@macro\caption@fnt{#1}}
+\def\caption@declare@font[#1]#2{%
+  \global\@namedef{caption@fnt@#2@package}{#1}%
+  \caption@@declarefont{#2}}
+\@onlypreamble\caption@declare@font
+%    \end{macrocode}
+%    \begin{macrocode}
+\newcommand*\caption@declarefont[1]{%
+  \global\@nameundef{caption@fnt@#1@package}%
+  \caption@@declarefont{#1}}
+\@onlypreamble\caption@declarefont
+%    \end{macrocode}
+%    \begin{macrocode}
+\newcommand*\caption@@declarefont[2]{%
+  \define@key{caption@fnt}{#1}[]{\caption@addto@fnt{#1}{#2}}%
+  \caption@@@declarefont{#1}{#2}}
+\@onlypreamble\caption@@declarefont
+%    \end{macrocode}
+%    \begin{macrocode}
+\newcommand*\caption@@@declarefont[2]{}% will be used by \DeclareCaptionJustification
+\@onlypreamble\caption@@@declarefont
+%    \end{macrocode}
+%    \begin{macrocode}
+\newcommand*\caption@addto@fnt[2]{%
+  \expandafter\let\expandafter\caption@package\csname caption@fnt@#1@package\endcsname
+  \caption@ifdefined\caption@package
+    {\caption@requirepackage\caption@package{#1}}% load package, if necessary
+    {}%
+  \l@addto@macro\caption@fnt{#2}}
 %    \end{macrocode}
 % \end{macro}
 %
@@ -2078,26 +2115,8 @@
 \DeclareCaptionFont{larger}{\caption@larger}
 %    \end{macrocode}
 %
-% \changes{v1.3}{2011/01/01}{\package{sansmath} package support added}
-%    \begin{macrocode}
-\DeclareCaptionFont{sansmath}{\sansmath}
-%    \end{macrocode}
-%
-% \changes{v1.0n}{2007/04/02}{\package{setspace} package support added}
-% \changes{v1.2d}{2009/10/09}{Bugfix 09-05-18: \package{setspace} package support revised}
-%    \begin{macrocode}
-\DeclareCaptionFont{singlespacing}{%
-  \caption@ifdefined\setspace@singlespace{%
-    \setstretch\setspace@singlespace}{}}% normally 1
-\DeclareCaptionFont{onehalfspacing}{%
-  \caption@setspace{onehalfspacing}\onehalfspacing\relax}
-\DeclareCaptionFont{doublespacing}{%
-  \caption@setspace{doublespacing}\doublespacing\relax}
-\DeclareCaptionFont{stretch}{%
-  \caption@setspace{stretch}\setstretch\@gobble{#1}}
-%    \end{macrocode}
 %    \begin{macrocode}
-\newcommand*\caption@setspace{\caption@ifpackageloaded{setspace}}
+\DeclareCaptionFont{singlespacing}{}
 %    \end{macrocode}
 %
 %    \begin{macrocode}
@@ -2128,9 +2147,11 @@
 % \changes{v1.1}{2007/07/03}{Mapped to \cs{DeclareCaptionFont}}
 %  |\DeclareCaptionJustification|\marg{name}\marg{code}
 %    \begin{macrocode}
-\newcommand*\DeclareCaptionJustification[2]{%
-  \global\@namedef{caption@hj@#1}{#2}% for compatibility to v1.0
-  \DeclareCaptionFont{#1}{#2}}
+\newcommand*\DeclareCaptionJustification{%
+  \def\caption@@@declarefont##1##2{%
+    \global\@namedef{caption@hj@##1}{##2}% for compatibility to v1.0, needed by floatrow package
+    \let\caption@@@declarefont\@gobbletwo}%
+  \DeclareCaptionFont}
 \@onlypreamble\DeclareCaptionJustification
 %    \end{macrocode}
 % \end{macro}
@@ -2203,119 +2224,6 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \subsection{The ragged2e package}
-% \changes{v1.0b}{2004/05/16}{Improved \package{ragged2e} package support}
-% \changes{v1.8h}{2020/01/03}{Revised \package{ragged2e} package support}
-%
-% We also support the upper-case commands offered by the \package{ragged2e}
-% package.
-% Note that these just map to their lower-case variants if the
-% \package{ragged2e} package is not available.
-%    \begin{macrocode}
-\DeclareCaptionJustification{Centering}{\caption@Centering}
-\DeclareCaptionJustification{RaggedLeft}{\caption@RaggedLeft}
-\DeclareCaptionJustification{RaggedRight}{\caption@RaggedRight}
-%    \end{macrocode}
-%    \begin{macrocode}
-\newcommand*\caption@Centering{%
-  \caption@ragged{Centering}\Centering\centering}
-\newcommand*\caption@RaggedLeft{%
-  \caption@ragged{RaggedLeft}\RaggedLeft\raggedleft}
-\newcommand*\caption@RaggedRight{%
-  \caption@ragged{RaggedRight}\RaggedRight\raggedright}
-%    \end{macrocode}
-%
-% \begin{macro}{\caption@ragged}
-% \changes{v1.0n}{2007/04/07}{The `ragged2e' package will now only been loaded when needed}
-% \changes{v1.0o}{2007/04/11}{Bugfix: Usage of \cs{caption@Info} replaced by \cs{caption@Debug}}
-% \changes{v1.1}{2007/04/16}{A different warning will be given on first \LaTeX\ run}
-% \changes{v1.4f}{2012/01/12}{Uses \cs{caption@ifpackageloaded} now}
-% |\caption@ragged|\marg{yes-code}\marg{no-code}
-% executes the \meta{yes-code} if the \package{ragged2e} package is loaded and \meta{no-code} if not.
-%    \begin{macrocode}
-\newcommand*\caption@ragged{\caption@ifpackageloaded{ragged2e}}
-%    \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\caption@ifpackageloaded}
-% \changes{v1.4f}{2012/01/12}{This macro added}
-% \changes{v1.8h}{2020/01/03}{Does not load the package anymore but issue an error message instead}
-% |\caption@ifpackageloaded|\marg{package}\marg{option}\marg{yes-code}\marg{no-code}
-% executes the \meta{yes-code} if the given package is loaded and \meta{no-code} if not.
-%    \begin{macrocode}
-\newcommand*\caption@ifpackageloaded[4]{%
-  \caption@ifdefined#3#3{%
-    \caption@Error{Option `#2' requires the `#1' package\MessageBreak
-      (or an alternative definition of \string#3)}%
-    #4}}
-%    \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\caption@pkg@list}
-% \changes{v1.4f}{2012/01/12}{This macro added}
-% We use this as list of packages loaded |\AtBeginDocument|.
-% (Note: Old |.aux| files could contain |\@cons|\-|\caption@pkg@list|\-|{{|\meta{package}|}}|,
-% so this macro should always be defined, even if we change the following code in the future.)
-%    \begin{macrocode}
-\newcommand*\caption@pkg@list{}
-%    \end{macrocode}
-%    \begin{macrocode}
-\caption@AtBeginDocument{%
-  \def\caption@tempa{\endgroup}%
-  \begingroup
-  \def\@elt#1{%
-    \g@addto@macro\caption@tempa{%
-      \caption@InfoNoLine{Load package `#1'}%
-      \RequirePackage{#1}\relax}}%
-  \caption@pkg@list
-  \caption@tempa}
-%    \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\caption@check@ragged}
-% \changes{v1.4h}{2020/01/03}{This macro added}
-% In the past we tried to load the \package{ragged2e} package automatically if needed.
-% But since we have dropped this unreliable code users will get an error message instead.
-% To compensate for this change we try to detect the usage of the \package{ragged2e}
-% at least within the preamble of the document.
-% (Note: Checking the name of the option is not sufficient here since it could have
-%  been re-defined by the user. So we have to check the option code instead.)
-%    \begin{macrocode}
-\@ifpackageloaded{ragged2e}{\let\caption@check@ragged\@gobble}{%
-%    \end{macrocode}
-%    \begin{macrocode}
-  \newcommand*\caption@check@ragged[1]{%
-    \begingroup
-      \def\caption@tempa{#1}%
-      \caption@check@ragged@{Centering}%
-      \caption@check@ragged@{RaggedLeft}%
-      \caption@check@ragged@{RaggedRight}%
-    \endgroup}%
-%    \end{macrocode}
-%    \begin{macrocode}
-  \newcommand*\caption@check@ragged@[1]{%
-    \expandafter\def\expandafter\caption@tempb\expandafter{\csname caption@#1\endcsname}%
-    \ifx\caption@tempa\caption@tempb % our definition of `ragged2e' option?
-      \@ifundefined{#1}{%
-        \caption@Info{Usage of `ragged2e' command \expandafter\string\csname #1\endcsname\space detected}%
-        \@cons\caption@pkg@list{{ragged2e}}% load `ragged2e' package later on
-        \global\let\caption@check@ragged\@gobble}{}%
-    \fi
-  }%
-%    \end{macrocode}
-%    \begin{macrocode}
-  \caption@AtBeginDocument{%
-    \let\caption@check@ragged\@gobble
-    \let\caption@check@ragged@\@undefined}}
-%    \end{macrocode}
-% Make the \package{subfig} package documentation compile.
-%    \begin{macrocode}
-%%\@ifl@aded{dtx}{subfig}{\RequirePackage{ragged2e}\relax}{} % not needed
-\DeclareCaptionOption{lofdepth}[2]{\caption@ifdefined\c@lofdepth{\setcounter{lofdepth}{#1}}{}}
-\DeclareCaptionOption{lotdepth}[2]{\caption@ifdefined\c@lotdepth{\setcounter{lotdepth}{#1}}{}}
-%    \end{macrocode}
-% \end{macro}
-%
 % \section{Vertical spaces before and after captions}
 %
 % \begin{macro}{\abovecaptionskip}
@@ -2369,6 +2277,17 @@
 %    \begin{macrocode}
 \DeclareCaptionOption{position}{\caption@setposition{#1}}
 %    \end{macrocode}
+% \changes{v1.0a}{2004/01/09}{Options \opt{figureposition} and \opt{tableposition} added}
+%    \begin{macrocode}
+\DeclareCaptionOption{figureposition}{%
+  \captionsetup*[figure]{position=#1}}
+\@onlypreamble@key{caption}{figureposition}
+%    \end{macrocode}
+%    \begin{macrocode}
+\DeclareCaptionOption{tableposition}{%
+  \captionsetup*[table]{position=#1}}
+\@onlypreamble@key{caption}{tableposition}
+%    \end{macrocode}
 %
 % \begin{macro}{\caption@setposition}
 % \changes{v1.0a}{2004/01/22}{Now the positions \opt{t}, \opt{above}, \opt{b},
@@ -3067,6 +2986,312 @@
 %
 % TODO: babel-latvian/latvian.ldf
 %
+% \section{Package support}
+%
+% \begin{macro}{\caption@xpackage}
+% \changes{v1.11}{2020/05/10}{This macro added}
+% |\caption@xpackage|\marg{macro}\marg{package}\marg{option}
+% expands the given macro if the given package is not loaded.
+% (Note: We cannot use |\@ifpackageloaded| here since it's not available after |\AtBeginDocument|.)
+%    \begin{macrocode}
+\newcommand*\caption@xpackage[2]{%
+  \expandafter\ifx\csname ver@#2.\caption@pkgextension\endcsname\relax
+    \expandafter\@firstofone
+  \else
+    \expandafter\@gobbletwo
+  \fi
+  {#1{#2}}}
+%    \end{macrocode}
+%    \begin{macrocode}
+\let\caption@pkgextension\@pkgextension
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\caption@loadpackage}
+% \changes{v1.11}{2020/05/10}{This macro added}
+% |\caption@loadpackage|\marg{package}\marg{caption option}
+% loads the given package immediately.
+%    \begin{macrocode}
+\newcommand*\caption@loadpackage{%
+  \caption@xpackage\caption@@loadpackage}
+%    \end{macrocode}
+%    \begin{macrocode}
+\newcommand*\caption@@loadpackage[2]{%
+  \caption@Info{Option `#2' requires the `#1' package}%
+  \RequirePackage{#1}\relax}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\caption@requirepackage}
+% \changes{v1.10}{2020/05/10}{This macro added}
+% |\caption@requirepackage|\marg{package}\marg{caption option}
+% indicates that the given package option needs a package.
+%    \begin{macrocode}
+\newcommand*\caption@requirepackage{%
+  \caption@xpackage\caption@@requirepackage}
+%    \end{macrocode}
+%    \begin{macrocode}
+\newcommand*\caption@@requirepackage[2]{%
+  \@cons\caption@packagelist{{#1}{#2}}}% load package later on
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\caption@pkg@list}
+% \changes{v1.4b}{2012/01/12}{This macro added}
+% We used this in the past as list of packages loaded |\AtBeginDocument|.
+% (Note: Old |.aux| files could contain |\@cons|\-|\caption@pkg@list|\-|{{|\meta{package}|}}|,
+% so this macro should always be defined, even if we change the following code in the future.)
+%    \begin{macrocode}
+\newcommand*\caption@pkg@list{}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\caption@packagelist}
+% \changes{v1.11}{2020/05/10}{This macro added}
+% We use this as list of packages loaded |\AtBeginDocument|.
+%    \begin{macrocode}
+\newcommand*\caption@packagelist{}
+\@onlypreamble\caption@packagelist
+%    \end{macrocode}
+%    \begin{macrocode}
+\caption@AtBeginDocument{%
+  \def\caption@tempa{\endgroup}%
+  \begingroup
+  \def\@elt#1#2{%
+    \g@addto@macro\caption@tempa{%
+      \caption@loadpackage{#1}{#2}}}%
+  \caption@packagelist
+  \caption@tempa
+%    \end{macrocode}
+%    \begin{macrocode}
+  \renewcommand*\caption@@loadpackage[2]{%
+    \caption@Error{Option `#2' requires the `#1' package}}%
+  \let\caption@@requirepackage\caption@@loadpackage
+  }
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\caption@usepackage}
+% \changes{v1.11}{2020/05/10}{This macro added}
+% |\caption@usepackage|\marg{package}\marg{option}\marg{code}
+% loads the given package and executes the given code.
+% (Note: Since the package might use the crappy \package{keyval}
+%  package, too, we need to save \& restore some macros here, otherwise this
+%  recursion won't work properly.)
+%    \begin{macrocode}
+\newcommand*\caption@usepackage[3]{%
+  \IfCaptionOptionCheck
+    {\caption@requirepackage{#1}{#2}}%
+    {\let\KV@prefix@ORI\KV@prefix
+     \let\@tempc@ORI\@tempc
+     \caption@loadpackage{#1}{#2}%
+     #3%
+     \let\@tempc\@tempc@ORI
+     \let\KV@prefix\KV@prefix@ORI}}
+% \end{macro}
+%
+% \subsection{The newfloat package}
+%
+% \begin{macro}{\caption@newfloat}
+% \changes{v1.4b}{2012/01/12}{This macro added}
+% \changes{v1.8h}{2020/01/03}{Usage of \cs{caption@ifpackageloaded} replaced by \cs{RequirePackage}}
+% \changes{v1.11}{2020/05/10}{Usage of \cs{RequirePackage} replaced by \cs{caption@usepackage}}
+% |\caption@newfloat|\marg{option}\marg{code}
+% loads the \package{newfloat} package and executes the given code afterwards.
+%    \begin{macrocode}
+\newcommand*\caption@newfloat{\caption@usepackage{newfloat}}
+%    \end{macrocode}
+% \end{macro}
+%
+% \changes{v1.0c}{2004/08/03}{Options \opt{figurename} and \opt{tablename} added}
+% \changes{v1.1}{2007/07/04}{Options \opt{figurename} and \opt{tablename} re-written}
+% \changes{v1.2}{2007/11/18}{Option \opt{name} added}
+%    \begin{macrocode}
+\DeclareCaptionOption{figurename}{\caption@SetName{figure}{#1}}
+\@onlypreamble@key{caption}{figurename}
+\DeclareCaptionOption{tablename}{\caption@SetName{table}{#1}}
+\@onlypreamble@key{caption}{tablename}
+%    \end{macrocode}
+%
+% \changes{v1.2a}{2008/02/28}{Options \opt{listfigurename} and \opt{listtablename} added}
+%    \begin{macrocode}
+\DeclareCaptionOption{listfigurename}{\caption@SetName{listfigure}{#1}}
+\@onlypreamble@key{caption}{listfigurename}
+\DeclareCaptionOption{listtablename}{\caption@SetName{listtable}{#1}}
+\@onlypreamble@key{caption}{listtablename}
+%    \end{macrocode}
+%
+% \begin{macro}{\caption@SetName}
+% \changes{v1.1}{2007/07/04}{This macro added}
+% \changes{v1.2}{2007/11/18}{After-preamble variant added}
+% \changes{v1.2a}{2008/02/28}{Renamed from \cs{caption@SetFloatName} to \cs{caption@SetName}}
+% \changes{v1.2b}{2008/08/02}{Bugfix: Works now without \cs{addto}, too}
+% \changes{v1.4a}{2011/10/29}{Outsourced to \package{newfloat} package}
+% \changes{v1.4b}{2012/01/12}{Bugfix: Uses \cs{caption@newfloat} now}
+%  |\caption@SetName|\marg{float}\marg{name}
+%    \begin{macrocode}
+\newcommand*\caption@SetName[2]{%
+  \caption@newfloat{#1name}{\newfloat@setname{#1}{#2}}}
+\@onlypreamble\caption@SetName
+%    \end{macrocode}
+% \end{macro}
+%
+%    \begin{macrocode}
+\DeclareCaptionOption{name}{%
+  \IfCaptionOptionCheck{}{\caption@setname\@captype{#1}}}
+%    \end{macrocode}
+%
+% \begin{macro}{\caption@setname}
+%  |\caption@setname|\marg{float}\marg{name}
+%    \begin{macrocode}
+\newcommand*\caption@setname[2]{%
+  \@namedef{#1name}{#2}}
+%    \end{macrocode}
+% \end{macro}
+%
+% \changes{v1.2}{2007/12/21}{Options \opt{figurewithin} and \opt{tablewithin} added}
+% \changes{v1.2e}{2010/01/09}{The \opt{within} options are now available within the document, too}
+%
+%    \begin{macrocode}
+\DeclareCaptionOption{figurewithin}{\caption@within{figure}{#1}}
+\DeclareCaptionOptionNoValue{figurewithout}{\caption@within{figure}{none}}
+\DeclareCaptionOption{tablewithin}{\caption@within{table}{#1}}
+\DeclareCaptionOptionNoValue{tablewithout}{\caption@within{table}{none}}
+%    \end{macrocode}
+%
+% \begin{macro}{\caption@within}
+% \changes{v1.2}{2007/12/21}{This macro added}
+% \changes{v1.4a}{2011/10/29}{Outsourced to \package{newfloat} package}
+% \changes{v1.4b}{2012/01/12}{Bugfix: Uses \cs{caption@newfloat} now}
+% |\caption@within|\marg{float}\marg{value}
+%    \begin{macrocode}
+\newcommand*\caption@within[2]{%
+  \caption@newfloat{#1within}{\newfloat@setwithin{#1}{#2}}}
+%    \end{macrocode}
+% \end{macro}
+%
+% \changes{v1.2b}{2008/04/13}{Option \opt{within} added}
+% \changes{v1.2e}{2010/01/09}{The global \opt{within} option will now affect user-defined floats declared with \cs{DeclareCaptionType}, too}
+%
+%    \begin{macrocode}
+\DeclareCaptionOption{within}{%
+  \caption@newfloat{within}{\newfloatsetup{within=#1}}}
+\DeclareCaptionOptionNoValue{without}{%
+  \caption@newfloat{without}{\newfloatsetup{without}}}
+%    \end{macrocode}
+%
+% \subsection{The ragged2e package}
+% \changes{v1.0b}{2004/05/16}{Improved \package{ragged2e} package support}
+% \changes{v1.8h}{2020/01/03}{Revised \package{ragged2e} package support}
+% \changes{v1.9}{2020/05/05}{Enhanced \package{ragged2e} package support}
+% \changes{v1.10}{2020/05/10}{Revised \package{ragged2e} package support}
+%
+% We support the upper-case commands offered by the \package{ragged2e}
+% package.
+%    \begin{macrocode}
+\DeclareCaptionJustification[ragged2e]{Justified}{\justifying}
+\DeclareCaptionJustification[ragged2e]{Centering}{\Centering}
+\DeclareCaptionJustification[ragged2e]{RaggedLeft}{\RaggedLeft}
+\DeclareCaptionJustification[ragged2e]{RaggedRight}{\RaggedRight}
+%    \end{macrocode}
+%
+% \subsection{The sansmath package}
+% \changes{v1.3}{2011/01/01}{\package{sansmath} package support added}
+% \changes{v1.10}{2020/05/10}{\package{sansmath} package support revised}
+%
+%    \begin{macrocode}
+\DeclareCaptionFont[sansmath]{sansmath}{\sansmath}
+%    \end{macrocode}
+%
+% \subsection{The setspace package}
+% \changes{v1.0n}{2007/04/02}{\package{setspace} package support added}
+% \changes{v1.2d}{2009/10/09}{\package{setspace} package support revised}
+%
+%    \begin{macrocode}
+\DeclareCaptionFont{singlespacing}{%
+  \caption@ifdefined\setspace@singlespace{%
+    \setstretch\setspace@singlespace}{}}% normally 1
+\DeclareCaptionFont[setspace]{onehalfspacing}{\onehalfspacing}
+\DeclareCaptionFont[setspace]{doublespacing}{\doublespacing}
+\DeclareCaptionFont[setspace]{stretch}{\setstretch{#1}}
+%    \end{macrocode}
+%
+% \subsection{The subfig package}
+% \changes{v1.1}{2007/07/07}{Several adaptions to the \package{subfig} package added}
+% \changes{v1.4a}{2011/11/01}{Test for the \package{subfig} package revised}
+%
+% Since the \package{subfig} package is not maintained anymore,
+% we have to make several adaptions to \thispackage~\version{1.1} here.
+% Please note that we only support the version $1.3$ of the \package{subfig} package here.
+% So older versions do not work with this version of \thispackage, and newer
+% versions are expected to be adapted.
+%    \begin{macrocode}
+\caption@AtBeginDocument{%
+  \def\@tempa{2005/06/28 ver: 1.3 subfig package}%
+  \expandafter\ifx\csname ver@subfig.sty\endcsname\@tempa
+    \caption@InfoNoLine{subfig package v1.3 is loaded}%
+%    \end{macrocode}
+%    \begin{macrocode}
+    \let\caption@setfloattype\@gobble
+    \let\@dottedxxxline\sf@NEW@dottedxxxline
+    \let\sf@subfloat\sf@NEW@subfloat
+%    \end{macrocode}
+%    \begin{macrocode}
+  \fi
+  \let\sf@NEW@dottedxxxline\@undefined
+  \let\sf@NEW@subfloat\@undefined}
+%    \end{macrocode}
+%
+% \begin{macro}{\@dottedxxxline}
+% New version of |\@dottedxxxline|
+%    \begin{macrocode}
+\def\sf@NEW@dottedxxxline#1#2#3#4#5#6#7{%
+  \begingroup
+    \caption@setfloattype{#1}%
+    \caption@setoptions{subfloat}%
+    \caption@setoptions{sub#1}%
+    \ifnum #3>\@nameuse{c@#2depth}\else
+      \@dottedtocline{\z@}{#4}{#5}{#6}{#7}%
+    \fi
+  \endgroup}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\sf@subfloat}
+% \changes{v1.4b}{2011/12/29}{Bugfix 11-12-23: Usage of \cs{caption@warmup} added}
+% New version of |\sf@subfloat|
+%    \begin{macrocode}
+\def\sf@NEW@subfloat{%
+  \begingroup
+    \@nameuse{caption@warmup}%
+    \caption@setfloattype\@captype
+    \sf@ifpositiontop{%
+      \maincaptiontoptrue
+    }{%
+      \maincaptiontopfalse
+    }%
+    \caption@setoptions{subfloat}%
+    \caption@setoptions{sub\@captype}%
+    \let\sf@oldlabel=\label
+    \let\label=\subfloat@label
+    \ifmaincaptiontop\else
+      \advance\@nameuse{c@\@captype}\@ne
+    \fi
+    \refstepcounter{sub\@captype}%
+    \setcounter{sub\@captype @save}{\value{sub\@captype}}%
+    \@ifnextchar [%  %] match left bracket
+      {\sf@@subfloat}%
+      {\sf@@subfloat[\@empty]}}
+%    \end{macrocode}
+% \end{macro}
+%
+% Make the \package{subfig} package documentation compile.
+%    \begin{macrocode}
+%%\@ifl@aded{dtx}{subfig}{\caption@loadpackage{ragged2e}{}}{} % not needed
+\DeclareCaptionOption{lofdepth}[2]{\caption@ifdefined\c@lofdepth{\setcounter{lofdepth}{#1}}{}}
+\DeclareCaptionOption{lotdepth}[2]{\caption@ifdefined\c@lotdepth{\setcounter{lotdepth}{#1}}{}}
+%    \end{macrocode}
+%
 % \section{Execution of options}
 %
 %    \begin{macrocode}
@@ -3644,7 +3869,7 @@
 %  |\DeclareCaptionType|\oarg{options}\marg{environment}\oarg{name}\oarg{list name}
 %    \begin{macrocode}
 \newcommand*\DeclareCaptionType{%
-  \RequirePackage{newfloat}%
+  \caption@loadpackage{newfloat}{}%
   \DeclareFloatingEnvironment}
 \@onlypreamble\DeclareCaptionType
 %    \end{macrocode}
@@ -3882,75 +4107,6 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \section{subfig package adaptions}
-% \changes{v1.1}{2007/07/07}{Several adaptions to the \package{subfig} package added}
-% \changes{v1.4a}{2011/11/01}{Bugfix 11-11-01: Test for the \package{subfig} package revised}
-%
-% Since the \package{subfig} package is not maintained anymore,
-% we have to make several adaptions to \thispackage~\version{1.1} here.
-% Please note that we only support the version $1.3$ of the \package{subfig} package here.
-% So older versions do not work with this version of \thispackage, and newer
-% versions are expected to be adapted.
-%    \begin{macrocode}
-\caption@AtBeginDocument{%
-  \def\@tempa{2005/06/28 ver: 1.3 subfig package}%
-  \expandafter\ifx\csname ver@subfig.sty\endcsname\@tempa
-    \caption@InfoNoLine{subfig package v1.3 is loaded}%
-%    \end{macrocode}
-%    \begin{macrocode}
-    \let\caption@setfloattype\@gobble
-    \let\@dottedxxxline\sf@NEW@dottedxxxline
-    \let\sf@subfloat\sf@NEW@subfloat
-%    \end{macrocode}
-%    \begin{macrocode}
-  \fi
-  \let\sf@NEW@dottedxxxline\@undefined
-  \let\sf@NEW@subfloat\@undefined}
-%    \end{macrocode}
-%
-% \begin{macro}{\@dottedxxxline}
-% New version of |\@dottedxxxline|
-%    \begin{macrocode}
-\def\sf@NEW@dottedxxxline#1#2#3#4#5#6#7{%
-  \begingroup
-    \caption@setfloattype{#1}%
-    \caption@setoptions{subfloat}%
-    \caption@setoptions{sub#1}%
-    \ifnum #3>\@nameuse{c@#2depth}\else
-      \@dottedtocline{\z@}{#4}{#5}{#6}{#7}%
-    \fi
-  \endgroup}
-%    \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\sf@subfloat}
-% \changes{v1.4b}{2011/12/29}{Bugfix 11-12-23: Usage of \cs{caption@warmup} added}
-% New version of |\sf@subfloat|
-%    \begin{macrocode}
-\def\sf@NEW@subfloat{%
-  \begingroup
-    \@nameuse{caption@warmup}%
-    \caption@setfloattype\@captype
-    \sf@ifpositiontop{%
-      \maincaptiontoptrue
-    }{%
-      \maincaptiontopfalse
-    }%
-    \caption@setoptions{subfloat}%
-    \caption@setoptions{sub\@captype}%
-    \let\sf@oldlabel=\label
-    \let\label=\subfloat@label
-    \ifmaincaptiontop\else
-      \advance\@nameuse{c@\@captype}\@ne
-    \fi
-    \refstepcounter{sub\@captype}%
-    \setcounter{sub\@captype @save}{\value{sub\@captype}}%
-    \@ifnextchar [%  %] match left bracket
-      {\sf@@subfloat}%
-      {\sf@@subfloat[\@empty]}}
-%    \end{macrocode}
-% \end{macro}
-%
 % \iffalse
 %</package>
 % \fi
-- 
cgit v1.2.3

