summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/newfloat/newfloat.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/newfloat/newfloat.dtx')
-rw-r--r--macros/latex/contrib/newfloat/newfloat.dtx420
1 files changed, 319 insertions, 101 deletions
diff --git a/macros/latex/contrib/newfloat/newfloat.dtx b/macros/latex/contrib/newfloat/newfloat.dtx
index eed00a0f96..a332724864 100644
--- a/macros/latex/contrib/newfloat/newfloat.dtx
+++ b/macros/latex/contrib/newfloat/newfloat.dtx
@@ -2,7 +2,7 @@
%
% This is file `newfloat.dtx'.
%
-% Copyright (C) 2011-2019 Axel Sommerfeldt (axel.sommerfeldt@f-m.fm)
+% Copyright (C) 2011-2023 Axel Sommerfeldt (axel.sommerfeldt@f-m.fm)
%
% --------------------------------------------------------------------------
%
@@ -14,21 +14,18 @@
% and version 1.3 or later is part of all distributions of LaTeX
% version 2003/12/01 or later.
%
-% This work has the LPPL maintenance status "maintained".
-%
-% This Current Maintainer of this work is Axel Sommerfeldt.
+% This work has the LPPL maintenance status "unmaintained".
%
% This work consists of the files newfloat.ins, newfloat.dtx,
% and the derived file newfloat.sty.
%
% \fi
-% \CheckSum{1609}
+% \CheckSum{1665}
%
% \iffalse
%<*driver>
\NeedsTeXFormat{LaTeX2e}[1994/12/01]
-\ProvidesFile{newfloat.drv}%
- [2013/04/27 v1.1 This package offers a command for defining new floating environments]
+\ProvidesFile{newfloat.drv}[2023/10/01 v1.2 This package offers a command for defining new floating environments]
\hbadness=9999 \newcount\hbadness \hfuzz=48pt % Make TeX shut up.
%
\documentclass{ltxdoc}
@@ -71,11 +68,11 @@
% \newcommand*\purerm[1]{{\upshape\mdseries\rmfamily #1}}
% \newcommand*\puresf[1]{{\upshape\mdseries\sffamily #1}}
% \newcommand*\purett[1]{{\upshape\mdseries\ttfamily #1}}
-% \let\class\puresf \let\package\puresf
+% \let\cls\puresf \let\pkg\puresf
% \let\env\purett \let\opt\purett
%
-% \def\thispackage{the \package{newfloat} package}
-% \def\Thispackage{The \package{newfloat} package}
+% \def\thispackage{the \pkg{newfloat} package}
+% \def\Thispackage{The \pkg{newfloat} package}
%
% \newcommand*\csmarg[1]{\texttt{\char`\{#1\char`\}}}
% \newcommand*\csoarg[1]{\texttt{\char`\[#1\char`\]}}
@@ -163,6 +160,8 @@
% |fileext=| & \meta{file extension}\\
% |listname=| & \meta{list name}\\
% |name=| & \meta{prosa name}\\
+% |autorefname=| & \meta{name used in \cs{autoref} offered by \pkg{hyperref}}\\
+% |legendname=| & \meta{name used in \cs{legend} offered by \cls{memoir}}\\
% |placement=| & \meta{combination of \,\purett{htbp}}\\
% |within=| & \meta{``within'' counter} \emph{or} \texttt{none}\\
% |chapterlistsgaps=| & \texttt{on} \emph{or} \texttt{off}~\footnotemark[1]
@@ -176,7 +175,7 @@
% If no \meta{options} are given,
% ``lo\meta{type}'' will be used as \meta{file extension} for the list,
% ``List of \meta{name}s'' as \meta{list name}.
-% ``\meta{name}'' as \meta{name} (but with the first letter capitalized),
+% ``\meta{name}'' as \meta{name}, \meta{autoref name}, and \meta{legend name} (but with the first letter capitalized),
% ``|tbp|'' as \meta{placement} specifier,
% and ``|chapter|'' resp. ``|none|'' as \meta{``within'' counter},
% i.e., the counter which resets the numbering.
@@ -191,10 +190,10 @@
% resp.~|\list|\-|of|\meta{type}|es|,
% analogous to |\list|\-|of|\-|figures| and |\list|\-|of|\-|tables|.
%
-% If the \package{fltpage} package is loaded, an environment called
+% If the \pkg{fltpage} package is loaded, an environment called
% |FP|\meta{type} will be defined additionally, same for |sideways|\meta{type}
-% (\package{rotating} package), |SC|\meta{type} (\package{sidecap} package),
-% and |wrap|\meta{type} (\package{wrapfig} package).
+% (\pkg{rotating} package), |SC|\meta{type} (\pkg{sidecap} package),
+% and |wrap|\meta{type} (\pkg{wrapfig} package).
%
% \bigskip
%
@@ -220,10 +219,10 @@
% | name=Matrix,|\\
% | placement=p,|\\
% | within=section,|\\
-% | chapterlistsgaps=off,|\\
-% | ]{matrix}|
+% | chapterlistsgaps=off|\\
+% | ]{matrixx}|
% \end{quote}
-% will define a new floating environment called |matrix| with the given settings.
+% will define a new floating environment called |matrixx| with the given settings.
% Please note that names which contain spaces needs to be enclosed in curly braces.
%
% \pagebreak[3]
@@ -235,10 +234,10 @@
% \end{quote}
% will change the settings of existing ones, i.e. either |figure| or |table|,
% or a one created with |\Declare|\-|Floating|\-|Environment|,
-% or a one created with |\new|\-|float| offered by the \package{float} package,
-% or a one created with |\new|\-|float| offered by the \package{memoir} document class,
-% or a one created with |\Declare|\-|New|\-|Float|\-|Type| offered by the \package{floatrow} package,
-% or \ldots
+% or a one created with |\new|\-|float| offered by the \pkg{float} package,
+% or a one created with |\new|\-|float| offered by the \pkg{memoir} document class,
+% or a one created with |\Declare|\-|New|\-|Float|\-|Type| offered by the \pkg{floatrow} package,
+% or a one created by a document class or any other package.
%
% The \meta{options} are the same as the options for
% |\Declare|\-|Floating|\-|Environment|,
@@ -255,7 +254,7 @@
% |\SetupFloatingEnvironment{lstlisting}{chapterlistsgaps=off}|
% \end{quote}
% will switch off the chapter lists gaps for |lstlisting| environments
-% offered by the \package{listings} package.
+% offered by the \pkg{listings} package.
%
% \pagebreak[3]
% \section{\cs{ForEachFloatingEnvironment}}
@@ -267,7 +266,7 @@
% and for ones defined with |\Declare|\-|Floating|\-|Environment| later on.
%
% \pagebreak[3]
-% So for example the \package{subcaption} packages uses
+% So for example the \pkg{subcaption} packages uses
% \begin{quote}
% |\ForEachFloatingEnvironment{\DeclareCaptionSubType{#1}}|
% \end{quote}
@@ -324,11 +323,11 @@
% | \renewcommand{\cftfigpresnum}{Diagram~}}|
% \end{quote}
% will change the part typeset in front of the diagram number within the
-% ``List of Diagrams'' when using the \package{tocloft} package~\cite{tocloft}.
+% ``List of Diagrams'' when using the \pkg{tocloft} package~\cite{tocloft}.
% Without the code above you will get the part defined for figures instead.
%
% \pagebreak[3]
-% However, when dealing with the \package{tocloft} package it's a better
+% However, when dealing with the \pkg{tocloft} package it's a better
% idea not to use |\Prepare|\-|List|\-|Of| but the customization facilities of that package
% instead, e.g.:
% \begin{quote}
@@ -359,11 +358,110 @@
% |\end{document}|
% \end{quote}
%
+% \pagebreak[3]
+% \section{Multi-language support}
+%
+% The options \opt{name=} etc.~will set names for the current language only.
+% If support for multiple languages is needed, the command |\addto\captions|\meta{language}
+% offered by the \pkg{babel} package needs to be used to set names for all the different languages.
+%
+% These are the corresponding command names:
+%
+% \nobreak\medskip\nobreak\noindent
+% \begin{minipage}{\linewidth}
+% \centering
+% \begin{tabular}{lll}
+% Option & Command & Description \\
+% \hline
+% \opt{listname=} & |\list|\meta{float}|name| & Heading of the list \\
+% \opt{name=} & |\|\meta{float}|name| & Name used in |\caption| \\
+% \opt{autorefname=} & |\|\meta{float}|autorefname| & Name used in |\autoref| \\
+% \opt{legendname=} & |\fleg|\meta{float} & Name used in |\legend| \\
+% \end{tabular}
+% \end{minipage}
+%
+% \medskip
+%
+% \pagebreak[3]
+% Example code:
+% \nobreak\begin{quote}
+% |\documentclass{book}|\\
+% \ldots\\
+% |\usepackage[T1]{fontenc}|\\
+% |\usepackage[english,french,german]{babel}|\\
+% \ldots\\
+% |\usepackage{newfloat}|\\
+% |\DeclareFloatingEnvironment{diagram}|\\
+% |% Set names for the English language|\\
+% |\addto\captionsenglish{%|\\
+% | \renewcommand\diagramname{Diagram}%|\\
+% | \renewcommand\listdiagramname{List of Diagrams}%|\\
+% |}|\\
+% |% Set names for the French language|\\
+% |\addto\captionsfrench{%|\\
+% | \renewcommand\diagramname{Diagramme}%|\\
+% | \renewcommand\listdiagramname{Liste des diagrammes}%|\\
+% |}|\\
+% |% Set names for the German language|\\
+% |\addto\captionsgerman{%|\\
+% | \renewcommand\diagramname{Diagramm}%|\\
+% | \renewcommand\listdiagramname{Liste der Diagramme}%|\\
+% |}|\\
+% \ldots
+% \end{quote}
+%
+% \pagebreak[3]
+% \emph{Note:}
+% As default the names for |\autoref| and |\legend| point to the one used for captions,
+% so these names only need to be set if they should differ from it.
+%
+% \pagebreak[3]
+% \section{Important notes for \LaTeX\ document class maintainers}
+%
+% If you are a maintainer of a \LaTeX\ document class and want to support this package
+% you could tell this package to keep its fingers from your definition of |\chapter| by defining
+% |\new|\-|float@dont@patch@chapter| to anything. (The content of the definition does not matter
+% since the \pkg{newfloat} package only checks if this macro is defined or not.)
+%
+% If |\new|\-|float@dont@patch@chapter| is defined, the \pkg{newfloat} package does not try to patch
+% |\chapter| but assumes that |\@add|\-|chapter|\-|lists|\-|gaps| is already used by the document class inside
+% its definition of |\chapter|, so it only needs to re-define |\@add|\-|chapter|\-|lists|\-|gaps|
+% to use the settings configured by |\De|\-|clare|\-|Float|\-|ing|\-|En|\-|vi|\-|ron|\-|ment|
+% or |\Setup|\-|Float|\-|ing|\-|En|\-|vi|\-|ron|\-|ment|.
+%
+% \medskip
+%
+% \pagebreak[3]
+% Example code:
+% \nobreak\begin{quote}
+% |\newcommand\@chapterlistsgap{10\p@}|\\
+% ||\\
+% |\newcommand\@addchapterlistsgaps{%|\\
+% | % Add a gap to List of Figures and List of Tables|\\
+% | % (This macro will be re-defined if the newfloat package|\\
+% | % is loaded by the user later on.)|\\
+% | \addtocontents{lof}{\protect\addvspace{\@chapterlistsgap}}%|\\
+% | \addtocontents{lot}{\protect\addvspace{\@chapterlistsgap}}%|\\
+% |}|\\
+% ||\\
+% |\newcommand\chapter{%|\\
+% | |\ldots\\
+% | \secdef\@chapter\@schapter}|\\
+% |\def\@chapter[#1]#2{%|\\
+% | |\ldots\\
+% | \@addchapterlistsgaps|\\
+% | |\ldots\\
+% |}|\\
+% ||\\
+% |% Hey newfloat package, don't patch my \chapter!|\\
+% |\def\newfloat@dont@patch@chapter{}|
+% \end{quote}
+%
% \iffalse
% \pagebreak[3]
-% \section{For \LaTeX{} package authors}
+% \section{Notes for \LaTeX{} package authors}
%
-% |\For|\-|Each|\-|Floating|\-|Environment| without \package{newfloat} package:
+% |\For|\-|Each|\-|Floating|\-|Environment| without \pkg{newfloat} package:
% \begin{quote}
% |\newcommand\mypackage@foreachfloat[1]{%|\\
% | \@ifundefined{ForEachFloatingEnvironment}%|\\
@@ -385,7 +483,7 @@
% \begin{quote}
% |\SetupFloatingEnvironment|\marg{environment}|{}|
% \end{quote}
-% or (without \package{newfloat} package loaded):
+% or (without \pkg{newfloat} package loaded):
% \begin{quote}
% |\providecommand\newfloat@list{}|\\
% |\@cons\newfloat@list{|\marg{environment}|}|
@@ -509,11 +607,11 @@
% \fi
%
% \setlength{\parskip}{0pt plus 1pt}
-% \changes{v1.0}{2011/10/30}{First release as \package{newfloat} package,
-% outsourced from the \package{caption3} package and revised}
-% \changes{v1.1}{2013/04/27}{Adapted to the \package{tocloft} package}
+% \changes{v1.0}{2011/10/30}{First release as \pkg{newfloat} package,
+% outsourced from the \pkg{caption3} package and revised}
+% \changes{v1.1}{2013/04/27}{Adapted to the \pkg{tocloft} package}
% \changes{v1.1}{2013/04/27}{New command \cs{PrepareListOf} added}
-% \changes{v1.1d}{2019/03/16}{Adapted to the \package{dgruyter} package}
+% \changes{v1.1d}{2019/03/16}{Adapted to the \pkg{dgruyter} package}
%
% \iffalse
% --------------------------------------------------------------------------- %
@@ -528,9 +626,28 @@
% \pagebreak[3]
% \subsection{Identification}
%
+% We need at least \LaTeX2e\ version 1994/12/01.
% \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}[1994/12/01]
-\ProvidesPackage{newfloat}[2019/09/02 v1.1l Defining new floating environments (AR)]
+% \end{macrocode}
+%
+% Bypass the release declarations in case the \LaTeX\ kernel doesn’t know how to deal with them
+% (as suggested by \url{https://www.latex-project.org/publications/2018-FMi-TUB-tb122mitt-version-rollback.pdf}).
+% \begin{macrocode}
+\providecommand\DeclareRelease[3]{}
+\providecommand\DeclareCurrentRelease[2]{}
+% \end{macrocode}
+%
+% Declare all supported releases.
+% \begin{macrocode}
+\DeclareRelease{v1.0}{2011-10-30}{newfloat_v1.0.sty}
+\DeclareRelease{v1.1}{2013-05-12}{newfloat_v1.1.sty}
+\DeclareCurrentRelease{v1.2}{2023-10-01}
+% \end{macrocode}
+%
+% Identify the current version of the package.
+% \begin{macrocode}
+\ProvidesPackage{newfloat}[2023/10/01 v1.2 Defining new floating environments (AR)]
% \end{macrocode}
%
% \begin{macro}{\newfloat@Info}
@@ -573,7 +690,7 @@
% \pagebreak[3]
% \subsection{Using the keyval package}
%
-% We need the \package{keyval} package for option handling, so we load it here.
+% We need the \pkg{keyval} package for option handling, so we load it here.
% \begin{macrocode}
\RequirePackage{keyval}[1997/11/10]
% \end{macrocode}
@@ -620,10 +737,11 @@
% \changes{v1.1}{2013/04/27}{Revised, only defines stuff yet undefined now}
% \changes{v1.1}{2013/11/03}{Uses \cs{newfloat@capitalize} now}
% \changes{v1.1}{2015/09/16}{Support of \cs{autodot} (offered by the \KOMAScript\ classes) added}
-% \changes{v1.1}{2018/03/04}{Usage of \cs{ifdefined} replaced by \cs{@ifundefined} to improve compatibility with the \package{listings} package}
+% \changes{v1.1}{2018/03/04}{Usage of \cs{ifdefined} replaced by \cs{@ifundefined} to improve compatibility with the \pkg{listings} package}
% \changes{v1.1b}{2018/12/26}{Bugfix: Missing curly braces added}
% \changes{v1.1c}{2019/01/10}{Bugfix: Support of \cs{autodot} fixed}
-% \changes{v1.1k}{2019/09/01}{Adapted to the \class{beamer} document class}
+% \changes{v1.1k}{2019/09/01}{Adapted to the \cls{beamer} document class}
+% \changes{v1.2}{2021/02/28}{Definition of \cs{xxxautorefname} added}
% |\DeclareFloatingEnvironment|\oarg{options}\marg{environment}\oarg{name}\oarg{list name}
% \begin{macrocode}
\newcommand*\DeclareFloatingEnvironment{%
@@ -667,18 +785,19 @@
% but with first letter capitalized
% \begin{macrocode}
\newfloat@capitalize\newfloat@Type{#2}%
- \newfloat@let{#2name}{\newfloat@Type}%
- \newfloat@def{fleg#2}{\@nameuse{#2name}}% legend naming (memoir)
+ \newfloat@let{#2name}{\newfloat@Type}% \caption naming
+ \newfloat@def{#2autorefname}{\@nameuse{#2name}}% \autoref naming (hyperref)
+ \newfloat@def{fleg#2}{\@nameuse{#2name}}% \legend naming (memoir)
% \end{macrocode}
% Legend name in ToC (memoir document class)
% \begin{macrocode}
\newfloat@ifundefined{flegtoc#2}{\@namedef{flegtoc#2}##1{}}%
% \end{macrocode}
% Define the floating environment\par
-% If the \class{tufte} document class is loaded,
+% If the \cls{tufte} document class is loaded,
% |\@tufte@float| and |\end@tufte@float| will be used instead of
% |\@float|, |\end@float|, |\@dblfloat|, and |\end@dblfloat|.\par
-% If the \class{beamer} document class is loaded,
+% If the \cls{beamer} document class is loaded,
% |\beamer@float| and |\end@beamer@float| will be used.
% \begin{macrocode}
\ifcsname @tufte@float\endcsname
@@ -713,8 +832,8 @@
\newfloat@let{list#2name}{\newfloat@tempa}%
% \end{macrocode}
% We undefine |\fst@|\meta{environment} so the new environment
-% will not be recognized as defined by the \package{float} package.
-% (|\fst@|\meta{type} use to hold the float style, see \package{float} package
+% will not be recognized as defined by the \pkg{float} package.
+% (|\fst@|\meta{type} use to hold the float style, see \pkg{float} package
% implementation for details.)
% \begin{macrocode}
\expandafter\let\csname fst@#2\endcsname\@undefined
@@ -768,6 +887,7 @@
% \begin{macro}{\newfloat@listof}
% \changes{v1.1}{2013/04/27}{Revised}
% \changes{v1.1g}{2019/08/28}{Starred variant added}
+% \changes{v1.1n}{2021/02/27}{Uses \cs{newfloat@ext} now instead of \cs{ext@xxx}}
% |\newfloat@listof|\marg{float type}\\
% typesets the list, using |\listoffigure| with patched list name and file extension.
% \begin{macrocode}
@@ -778,7 +898,7 @@
% \end{macrocode}
% \begin{macrocode}
\newcommand*\newfloat@list@of[1]{%
- \@expandtwoargs\newfloat@list@of@{#1}{\@nameuse{ext@#1}}}
+ \@expandtwoargs\newfloat@list@of@{#1}{\newfloat@ext{#1}}}
% \end{macrocode}
% \begin{macrocode}
\newcommand*\newfloat@list@of@[3]{%
@@ -830,12 +950,13 @@
% \end{macro}
%
% \begin{macro}{\newfloat@setoption}
-% \changes{v1.1}{2015/09/15}{Bugfix: \cs{@expandtwoargs} replaced by own expansion so the option value do not get expanded anymore}
+% \changes{v1.1}{2015/09/15}{\cs{@expandtwoargs} replaced by own expansion so the option value do not get expanded anymore}
+% \changes{v1.1m}{2020/10/11}{Usage of \cs{caption@tempa} replaced by \cs{newfloat@tempa}}
% |\newfloat@setoption|\marg{option name}{options}
% \begin{macrocode}
\newcommand*\newfloat@setoption[1]{%
- \edef\caption@tempa{\noexpand\@nameuse{newfloat@set#1}{\newfloat@type}}%
- \caption@tempa}
+ \edef\newfloat@tempa{\noexpand\@nameuse{newfloat@set#1}{\newfloat@type}}%
+ \newfloat@tempa}
% \end{macrocode}
% \end{macro}
%
@@ -896,6 +1017,34 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\newfloat@setautorefname}
+% \changes{v1.2}{2023/10/01}{This macro and corresponding option \opt{autorefname=} added}
+% |\newfloat@setautorefname|\marg{environment}\marg{autoref name}\par
+% This name is used in |\autoref| offered by the \pkg{hyperref} package.
+% \begin{macrocode}
+\newcommand*\newfloat@setautorefname[2]{%
+ \@namedef{#1autorefname}{#2}}
+% \end{macrocode}
+% \begin{macrocode}
+\define@key{@newfloat}{autorefname}{%
+ \newfloat@setoption{autorefname}{#1}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\newfloat@setlegendname}
+% \changes{v1.2}{2023/10/01}{This macro and corresponding option \opt{legendname=} added}
+% |\newfloat@setlegendname|\marg{environment}\marg{legend name}
+% This name is used in |\legend| offered by the \cls{memoir} document class.
+% \begin{macrocode}
+\newcommand*\newfloat@setlegendname[2]{%
+ \@namedef{fleg#1}{#2}}
+% \end{macrocode}
+% \begin{macrocode}
+\define@key{@newfloat}{legendname}{%
+ \newfloat@setoption{legendname}{#1}}
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macro}{\newfloat@setplacement}
% |\newfloat@setplacement|\marg{environment}\marg{float placement}
% \begin{macrocode}
@@ -954,10 +1103,10 @@
\fi
\fi}
% \end{macrocode}
-% Note: Since the \package{hyperref} package with version $<$ 6.82k defines
+% Note: Since the \pkg{hyperref} package with version $<$ 6.82k defines
% |\the|\-|H|\-|figure| and |\the|\-|H|\-|table| with |\new|\-|command|,
% |\newfloat@@setwithin| will yield to an error message when using with an
-% old version of \package{hyperref},
+% old version of \pkg{hyperref},
% e.g. ``\texttt{LaTeX Error: Command \cs{theHfigure} already defined}''.
% \begin{macrocode}
\newcommand*\newfloat@@setwithin[3]{%
@@ -987,26 +1136,36 @@
% \begin{macrocode}
\newcommand*\newfloat@setchapterlistsgaps[2]{%
\edef\@tempa{#2}%
- \def\@tempb{off}%
+ \newfloat@setchapterlistsgaps@{off}{off}{#1}%
+ \newfloat@setchapterlistsgaps@{false}{off}{#1}%
+ \newfloat@setchapterlistsgaps@{on}{on}{#1}%
+ \newfloat@setchapterlistsgaps@{true}{on}{#1}%
+ \ifx\@tempa\newfloat@setchapterlistsgaps@ \else
+ \newfloat@Error{Invalid value `#2' for option `chapterlistsgaps'}%
+ \fi}
+% \end{macrocode}
+% \begin{macrocode}
+\newcommand*\newfloat@setchapterlistsgaps@[3]{%
+ \def\@tempb{#1}%
\ifx\@tempa\@tempb
- \@chapterlistsgap@off{#1}%
- \else
- \def\@tempb{on}%
- \ifx\@tempa\@tempb
- \@chapterlistsgap@on{#1}%
- \else
- \newfloat@Error{Invalid value `#2' for option `chapterlistsgaps'}%
- \fi
+ \newfloat@chapterlistsgap@{#2}{#3}%
+ \let\@tempa\newfloat@setchapterlistsgaps@
\fi}
% \end{macrocode}
% \begin{macrocode}
+\newcommand*\newfloat@chapterlistsgap@[1]{%
+ \@ifundefined{@chapterlistsgap@#1}%
+ {\@gobble}%
+ {\@nameuse{@chapterlistsgap@#1}}}
+% \end{macrocode}
+% \begin{macrocode}
\define@key{@newfloat}{chapterlistsgaps}{%
\def\newfloat@chapterlistsgaps@value{#1}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@removefromreset}
-% This code was taken from the \package{remreset} package
+% This code was taken from the \pkg{remreset} package
% which is part of the `carlisle' package bundle.
% (Copyright 1997 David Carlisle)
% \begin{macrocode}
@@ -1023,6 +1182,7 @@
% \end{macro}
%
% \begin{macro}{\newfloat@announce}
+% \changes{v1.1n}{2021/02/27}{Defines \cs{newfloat@env@xxx} now instead of \cs{newfloat@ext@xxx}}
% |\newfloat@announce|\marg{environment name}\marg{list file extension}
% \begin{macrocode}
\newcommand*\newfloat@announce[2]{%
@@ -1032,10 +1192,10 @@
\@cons\newfloat@@list{{#1}}%
% \end{macrocode}
% \begin{macrocode}
- \newfloat@ifundefined{newfloat@ext@#2}{%
- \@namedef{newfloat@ext@#2}{#1}%
+ \newfloat@ifundefined{newfloat@env@#2}{%
+ \@namedef{newfloat@env@#2}{#1}%
% \end{macrocode}
-% Support of \package{memoir} document class
+% Support of \pkg{memoir} document class
% \begin{macrocode}
\ifcsname c@lofdepth\endcsname
\newfloat@ifundefined{c@#2depth}{%
@@ -1043,7 +1203,7 @@
\setcounter{#2depth}{1}}%
\fi
% \end{macrocode}
-% Support of \package{tocbasic} package
+% Support of \pkg{tocbasic} package
% \begin{macrocode}
\ifcsname addtotoclist\endcsname
\addtotoclist[float]{#2}%
@@ -1053,7 +1213,7 @@
% \begin{macrocode}
}%
% \end{macrocode}
-% Support of \package{titletoc} package
+% Support of \pkg{titletoc} package
% \begin{macrocode}
\ifcsname contentsuse\endcsname
\contentsuse{#1}{#2}%
@@ -1065,6 +1225,15 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\newfloat@ext}
+% \changes{v1.1n}{2021/02/27}{This macro added}
+% |\newfloat@ext|\marg{environment}
+% expands to the file extension used for the given \meta{environment}.
+% \begin{macrocode}
+\newcommand*\newfloat@ext[1]{\@nameuse{ext@#1}}
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macro}{\newfloat@@list}
% |\newfloat@@list| is an \cs{@elt}-list containing the floating environments defined
% with |\Declare|\-|Floating|\-|Environment| only.
@@ -1089,29 +1258,41 @@
% \subsection{\cs{ForEachFloatingEnvironment}}
%
% \begin{macro}{\ForEachFloatingEnvironment}
-% |\ForEachFloatingEnvironment|\marg{code}
-% will execute the given code for each floating environment.
+% |\ForEachFloatingEnvironment|\marg{code with \#1}\par
+% will execute the given code for each (known) floating environment.
% The starred variant will only work for already existing environments,
% i.e.~no hook will be placed inside |\Declare|\-|Floating|\-|Environment|.
% \begin{macrocode}
-\newcommand\ForEachFloatingEnvironment{%
+\newcommand*\ForEachFloatingEnvironment{%
\@ifstar
- {\@ForEachFloatingEnvironment\@gobble}%
- {\@ForEachFloatingEnvironment\@iden}}
+ {\newfloat@foreach\@gobble}%
+ {\newfloat@foreach\@iden}}
% \end{macrocode}
% \begin{macrocode}
-\newcommand\@ForEachFloatingEnvironment[2]{%
+\newcommand\newfloat@foreach[2]{%
\def\@elt##1{#2}%
\newfloat@list
\let\@elt\relax
#1{\newfloat@addtohook{#2}}}
% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\newfloat@addtohook}
+% |\newfloat@addtohook|\marg{code with \#1}\par
+% adds code to the hook called in |\Declare|\-|Floating|\-|Environment|.\par
+% Note: We use |\provide|\-|command| instead of |\new|\-|command| here since the
+% exact same code is defined for |\For|\-|Each|\-|Caption|\-|Type| offered by
+% the \pkg{caption3} package.
% \begin{macrocode}
\providecommand\newfloat@addtohook[1]{%
\toks@=\expandafter{\newfloat@hook{##1}#1}%
\edef\@tempa{\def\noexpand\newfloat@hook####1{\the\toks@}}%
\@tempa}
% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\newfloat@hook}
+% Hook used in |\Declare|\-|Floating|\-|Environment|.
% \begin{macrocode}
\providecommand*\newfloat@hook[1]{}
% \end{macrocode}
@@ -1145,6 +1326,7 @@
%
% \begin{macro}{\newfloat@addtolist}
% \changes{v1.0b}{2012/05/18}{Bugfix: Definition of \cs{@ifchapterlistsgap@}\meta{environment} added}
+% \changes{v1.1n}{2021/02/27}{Defines \cs{newfloat@env@xxx} now instead of \cs{newfloat@ext@xxx}}
% |\newfloat@addtolist|\marg{environment}
% adds an environment to the list of floating environments.
% \begin{macrocode}
@@ -1152,7 +1334,7 @@
\newfloat@ifinlist{#1}{}{%
\ifcsname ext@#1\endcsname
\@cons\newfloat@list{{#1}}%
- \@namedef{newfloat@ext@\@nameuse{ext@#1}}{#1}%
+ \@namedef{newfloat@env@\@nameuse{ext@#1}}{#1}%
\newfloat@let{@ifchapterlistsgap@#1}{\@iden}%
\else
\newfloat@Error{`#1' does not seem to be a floating environment}%
@@ -1201,7 +1383,7 @@
% \begin{macrocode}
\providecommand*\@chapterlistsgap{10\p@}%
% \end{macrocode}
-% If the \package{dgruyter} package is loaded, the default gap is |13pt|.
+% If the \pkg{dgruyter} package is loaded, the default gap is |13pt|.
% \begin{macrocode}
\@ifpackageloaded{dgruyter}{\renewcommand*\@chapterlistsgap{13\p@}}{}%
% \end{macrocode}
@@ -1231,41 +1413,50 @@
%
% \begin{macro}{\@addchapterlistsgaps}
% \changes{v1.0b}{2012/05/18}{Bugfix: Group added to make \cs{@addchapterlistsgap} work correctly}
+% \changes{v1.1n}{2021/02/27}{Uses \cs{newfloat@ext} now instead of \cs{ext@xxx}}
+% \changes{v1.2}{2023/10/01}{A previous definition of this macro will be overwritten if \cs{newfloat@dont@patch@chapter} is defined}
% |\@addchapterlistsgaps|\par
% will add the chapter lists gaps for all floating environments in |\newfloat@list|.
% \begin{macrocode}
+ \ifcsname newfloat@dont@patch@chapter\endcsname
+ \let\@addchapterlistsgaps\@undefined % force a re-definition
+ \fi
+% \end{macrocode}
+% \begin{macrocode}
\providecommand*\@addchapterlistsgaps{%
\begingroup
\def\@elt##1{%
- \@expandtwoargs\@addchapterlistsgap{##1}{\@nameuse{ext@##1}}}%
+ \@expandtwoargs\@addchapterlistsgap{##1}{\newfloat@ext{##1}}}%
\newfloat@list
\endgroup}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@chapterlistsgap@off}
+% \changes{v1.1n}{2021/02/27}{Uses \cs{newfloat@ext} now instead of \cs{ext@xxx}}
% |\@chapterlistsgap@off|\marg{float type}\par
% switches the chapter lists gap off for the given float type.
% Since \KOMAScript{} (still) supports |\float@exts| we need to handle
-% this locally, too, even if |\unsettoc| is offered by the \package{tocbasic} package.
+% this locally, too, even if |\unsettoc| is offered by the \pkg{tocbasic} package.
% (Otherwise our handling could be moved into the |\else| branch.)
% \begin{macrocode}
\providecommand*\@chapterlistsgap@off[1]{%
\expandafter\let\csname @ifchapterlistsgap@#1\endcsname\@gobble
\ifcsname unsettoc\endcsname
- \@expandtwoargs\unsettoc{\@nameuse{ext@#1}}{chapteratlist}%
+ \@expandtwoargs\unsettoc{\newfloat@ext{#1}}{chapteratlist}%
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@chapterlistsgap@on}
+% \changes{v1.1n}{2021/02/27}{Uses \cs{newfloat@ext} now instead of \cs{ext@xxx}}
% |\@chapterlistsgap@off|\marg{float type}\par
% switches the chapter lists gap on for the given float type.
% \begin{macrocode}
\providecommand*\@chapterlistsgap@on[1]{%
\expandafter\let\csname @ifchapterlistsgap@#1\endcsname\@iden
\ifcsname setuptoc\endcsname
- \@expandtwoargs\setuptoc{\@nameuse{ext@#1}}{chapteratlist}%
+ \@expandtwoargs\setuptoc{\newfloat@ext{#1}}{chapteratlist}%
\fi}
% \end{macrocode}
% \end{macro}
@@ -1355,7 +1546,7 @@
% \end{macro}
%
% Process the package options:
-% We use |\setkeys| here instead of |\ProcessOptions|.
+% We use |\set|\-|keys| here instead of |\Process|\-|Options|.
% \begin{macrocode}
\let\@tempc\relax
\@expandtwoargs\setkeys{newfloat}{planb,\@ptionlist{\@currname.\@currext}}%
@@ -1373,13 +1564,22 @@
% \pagebreak[3]
% \subsection{Patching \cs{chapter}}
%
+% Since the \LaTeX\ team has refused to replace the hard coded |10pt| skip inside |\chapter|
+% (for lists of floating environments like |figure| or |table|)
+% with a proper interface~\footnote{I have asked David Carlisle in 2018, Frank Mittelbach in 2020, and Frank again at a later date.},
+% we need to patch |\chapter|. (Sigh!)
+%
+% And since most document class authors takes \cls{article}, \cls{report}, or \cls{book} as template for own classes,
+% they inherit the same problem: Hard coded skips we need to replace with an interface for ourself. (Sigh!)
+%
% \begin{macro}{\newfloat@replace@chapter}
% \changes{v1.1f}{2019/08/25}{Parameter \meta{class name} added to macro}
% \changes{v1.1i}{2019/08/31}{Local definition of \cs{if@chapnum} added}
+% \changes{v1.1o}{2021/02/27}{Support of the \pkg{algorithm2e} package added}
% |\newfloat@replace@chapter|\marg{class name}\marg{original code}\marg{replacement code}\par
% tries to patch |\@chapter| so |\@add|\-|chapter|\-|lists|\-|gaps| will be supported.
% It checks for |\Hy@org@chapter|, too, since the original code will be stored here
-% if the \package{hyperref} package was loaded.
+% if the \pkg{hyperref} package was loaded.
% \begin{macrocode}
\newcommand\newfloat@replace@chapter[3]{%
\begingroup
@@ -1388,18 +1588,21 @@
\let\if@thema\iffalse
\let\if@chapnum\iffalse
\def\@tempa[##1]##2{#2}%
- \ifx\@tempa\@chapter
- \newfloat@InfoNoLine{Document class `#1' detected}%
- \gdef\@chapter[##1]##2{#3}%
- \global\let\newfloat@replace@chapter\newfloat@dont@replace@chapter
- \else\ifx\@tempa\Hy@org@chapter
- \newfloat@InfoNoLine{Document class `#1' detected (Hy)}%
- \gdef\Hy@org@chapter[##1]##2{#3}%
- \global\let\newfloat@replace@chapter\newfloat@dont@replace@chapter
- \fi\fi
+ \newfloat@replace@chapter@\@chapter{original}{#1}{#3}%
+ \newfloat@replace@chapter@\Hy@org@chapter{hyperref}{#1}{#3}%
+ \newfloat@replace@chapter@\algocf@original@chapter{algorithm2e}{#1}{#3}%
\endgroup}
% \end{macrocode}
% \begin{macrocode}
+\newcommand\newfloat@replace@chapter@[4]{%
+ \ifx\@tempa#1%
+ \newfloat@InfoNoLine{Document class `#3' detected (#2)}%
+ \global\def#1[##1]##2{#4}%
+ \global\let\newfloat@replace@chapter\newfloat@dont@replace@chapter
+ \global\let\newfloat@replace@chapter@\@gobblefour
+ \fi}
+% \end{macrocode}
+% \begin{macrocode}
\newcommand\newfloat@dont@replace@chapter[3]{}
% \end{macrocode}
% \begin{macrocode}
@@ -1409,6 +1612,19 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\newfloat@dont@patch@chapter}
+% \changes{v1.2}{2023/10/01}{Detection of this macro added}
+% If |\newfloat@dont@patch@chapter| is defined, we don't try to patch |\chapter|
+% but assume that the document class is already using |\@add|\-|chapter|\-|lists|\-|gaps|
+% inside its definition of |\chapter|.
+% \begin{macrocode}
+\ifcsname newfloat@dont@patch@chapter\endcsname
+ \newfloat@InfoNoLine{\noexpand\newfloat@dont@patch@chapter is set}
+ \let\newfloat@replace@chapter\newfloat@dont@replace@chapter
+\fi
+% \end{macrocode}
+% \end{macro}
+%
% \pagebreak[3]
% \subsubsection{Standard \LaTeX{} document classes}
%
@@ -1532,7 +1748,7 @@
% \pagebreak[3]
% \subsubsection{\KOMAScript{} document classes}
%
-% If a \KOMAScript{} document class or the \package{tocbasic} package is used
+% If a \KOMAScript{} document class or the \pkg{tocbasic} package is used
% we don't need to patch anything.
% Instead we use |\setup|\-|toc| and |\un|\-|set|\-|toc| to setup the
% chapters gap in |\@chapter|\-|lists|\-|gap@on| and |\@chapter|\-|lists|\-|gap@off|.
@@ -1544,7 +1760,7 @@
% \pagebreak[3]
% \subsubsection{memoir document classes}
%
-% If the \package{memoir} document class is used,
+% If the \pkg{memoir} document class is used,
% replacing |\insert|\-|chapter|\-|space| by |\@add|\-|chapter|\-|lists|\-|gaps| is sufficient.
% \begin{macrocode}
\ifcsname insertchapterspace\endcsname
@@ -1715,7 +1931,7 @@
%
% \pagebreak[3]
% \subsubsection{The Springer Verlag document classes}
-% \changes{v1.1f}{2019/08/25}{Support of \package{svmono} and \package{svmult} document classes added}
+% \changes{v1.1f}{2019/08/25}{Support of \pkg{svmono} and \pkg{svmult} document classes added}
%
% \begin{macrocode}
% svmono.cls [2018/06/25 v5.6 Springer Verlag global LaTeX document class for monographs]
@@ -1767,7 +1983,7 @@
%
% \pagebreak[3]
% \subsubsection{The dgruyter package}
-% \changes{v1.1j}{2019/08/31}{Extended support of \package{dgruyter} package added}
+% \changes{v1.1j}{2019/08/31}{Extended support of \pkg{dgruyter} package added}
%
% \begin{macrocode}
% dgruyter.sty [2017/09/19 v2.00 De Gruyter layout]
@@ -1854,10 +2070,11 @@
was already redefined by another package}
\newfloat@InfoNoLine{\string\@chapter\space=\space\meaning\@chapter}
\newfloat@InfoNoLine{\string\Hy@org@chapter\space=\space\meaning\Hy@org@chapter}
+ \newfloat@InfoNoLine{\string\algocf@original@chapter\space=\space\meaning\algocf@original@chapter}
% \end{macrocode}
% Plan B: We patch |\add|\-|to|\-|contents| instead, and keep our fingers crossed
% in the hope that this redefinition actually will fit.
-% (Note: Since \package{biblatex} patches |\add|\-|to|\-|contents| as well we do
+% (Note: Since \pkg{biblatex} patches |\add|\-|to|\-|contents| as well we do
% this using |\At||Begin||Document|.)
% \changes{v1.1f}{2019/08/25}{Plan B will now be done using \cs{AtBeginDocument}}
% \begin{macrocode}
@@ -1895,7 +2112,7 @@
%
% \begin{macro}{\beamer@float}
% \changes{v1.1k}{2019/09/01}{This macro added}
-% Unfortunately the \class{beamer} document class does not offer
+% Unfortunately the \cls{beamer} document class does not offer
% |\beamer@float| and |\end@beamer@float| (yet), so we have to define them
% for ourself.
% (This code was taken from beamerbaselocalstructure.sty [2019/07/23 v3.56] and adapted.)
@@ -1969,7 +2186,7 @@
% \end{macro}
%
% \pagebreak[3]
-% \subsubsection{\package{dgruyter}}
+% \subsubsection{\pkg{dgruyter}}
%
% The De Gruyter layout package (for preparing books for Walter de Gruyter GmbH)
% is defining |\plist@figure| and |\plist@table|, and expects this to be
@@ -1982,9 +2199,9 @@
% \end{macrocode}
%
% \pagebreak[3]
-% \subsubsection{\package{float}}
+% \subsubsection{\pkg{float}}
%
-% If the \package{float} package is used we fill up |\float@exts| with our file
+% If the \pkg{float} package is used we fill up |\float@exts| with our file
% extensions, too. Since this list will be used for inserting chapters gaps
% we only add the ones which are configured for chapters gaps on.\par
% Note: This has to be done |\At|\-|Begin|\-|Document| so the settings for
@@ -2002,7 +2219,7 @@
% \end{macrocode}
%
% \pagebreak[3]
-% \subsubsection{\package{fltpage}}
+% \subsubsection{\pkg{fltpage}}
%
% We define a FP-variant of new floating environments here.
% \begin{macrocode}
@@ -2012,10 +2229,10 @@
% \end{macrocode}
%
% \pagebreak[3]
-% \subsubsection{\package{listings}}
+% \subsubsection{\pkg{listings}}
%
% \begin{macro}{\ext@lstlisting}
-% Since the \package{listings} package do not define |\ext@lst|\-|listing|
+% Since the \pkg{listings} package do not define |\ext@lst|\-|listing|
% but we needed it when |Setup|\-|Floating|\-|Environment{lst|\-|listing}{|\ldots|}|
% will be done by the end user, we define it here.
% \begin{macrocode}
@@ -2024,7 +2241,7 @@
% \end{macro}
%
% \pagebreak[3]
-% \subsubsection{\package{rotating}}
+% \subsubsection{\pkg{rotating}}
%
% We define a sideways-variant of new floating environments here.
% \begin{macrocode}
@@ -2034,7 +2251,7 @@
% \end{macrocode}
%
% \pagebreak[3]
-% \subsubsection{\package{sidecap}}
+% \subsubsection{\pkg{sidecap}}
%
% We define a SC-variant of new floating environments here.
% \begin{macro}{\SC@float}
@@ -2055,7 +2272,7 @@
% \end{macro}
%
% \pagebreak[3]
-% \subsubsection{\package{wrapfig}}
+% \subsubsection{\pkg{wrapfig}}
%
% We define a wrap-variant of new floating environments here.
% \begin{macrocode}
@@ -2074,3 +2291,4 @@
% \Finale
%
\endinput
+