summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/koma-script/source/scrlfile.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/koma-script/source/scrlfile.dtx')
-rw-r--r--macros/latex/contrib/koma-script/source/scrlfile.dtx622
1 files changed, 484 insertions, 138 deletions
diff --git a/macros/latex/contrib/koma-script/source/scrlfile.dtx b/macros/latex/contrib/koma-script/source/scrlfile.dtx
index b52fe0b59e..cc64485ec6 100644
--- a/macros/latex/contrib/koma-script/source/scrlfile.dtx
+++ b/macros/latex/contrib/koma-script/source/scrlfile.dtx
@@ -1,4 +1,4 @@
-% \CheckSum{820}
+% \CheckSum{839}
% \iffalse^^A meta-comment
% ======================================================================
% scrlfile.dtx
@@ -59,12 +59,12 @@
% Right brace \} Tilde \~}
%
% \iffalse
-%%% From File: $Id: scrlfile.dtx 3243 2019-10-07 13:32:53Z kohm $
+%%% From File: $Id: scrlfile.dtx 3399 2019-11-21 09:01:49Z kohm $
%<*dtx>
\ifx\ProvidesFile\undefined\def\ProvidesFile#1[#2]{}\fi
\begingroup
\def\filedate$#1: #2-#3-#4 #5${\gdef\filedate{#2/#3/#4}}
- \filedate$Date: 2019-10-07 15:32:53 +0200 (Mon, 07 Oct 2019) $
+ \filedate$Date: 2019-11-21 10:01:49 +0100 (Thu, 21 Nov 2019) $
\def\filerevision$#1: #2 ${\gdef\filerevision{r#2}}
\filerevision$Revision: 2631 $
\edef\reserved@a{%
@@ -170,22 +170,43 @@
% file. But before we redefine the macro, we test, if the macro was
% defined like we expected. \LaTeX{} will warn, if not.
% \changes{v3.27}{2019/10/06}{\LaTeX{} 2019-10-01 changed the definition}%^^A
+%
+% \changes{v3.28}{2019/11/21}{support for \textsf{memoir}}%^^A
+% With \textsf{memoir} their is a special case. It also redefines
+% \cs{InputIfFileExists}. As shown in the source of the class it does so
+% because \textsf{scrlfile} does it. However it does it not compatible with
+% \textsf{scrlfile} and it does not emulate \textsf{scrlfile} as it do for
+% other packages. So if you try to use \textsf{scrlfile} with memoir,
+% \textsf{scrbase} has to take care to \textsf{memoir}. And in oposit to
+% \textsf{scrlfile} \textsf{memoir} does not always fix the argument order bug
+% of \LaTeX{} but do so only for the implementation of \LaTeX{} 2019-10-01.
+% So in case of \textsf{memoir} we just patch every version of it without
+% testing.
% \begin{macrocode}
-\long\def\reserved@a#1#2{%
- \IfFileExists{#1}%
- {#2\@addtofilelist{#1}\@@input \@filef@und}}%
-\ifx\reserved@a\InputIfFileExists\else
- \expandafter\CheckCommand\expandafter*\expandafter\InputIfFileExists
- \expandafter{%
- \expandafter\protect\csname InputIfFileExists \endcsname
+\@ifclassloaded{memoir}{%
+ \PackageInfo{scrlfile}{class `memoir' detected.\MessageBreak
+ Using a compatible redefinition of \string\InputIfFileExists,\MessageBreak
+ but always robust and with the fix of the\MessageBreak
+ argument order bug even for old versions of the\MessageBreak
+ LaTeX kernel%
}%
- \expandafter\CheckCommand \csname InputIfFileExists \endcsname[2]{%
- \IfFileExists {#1}{%
- \expandafter \@swaptwoargs \expandafter {\@filef@und }%
- {#2\@addtofilelist {#1}\@@input }%
+}{%
+ \long\def\reserved@a#1#2{%
+ \IfFileExists{#1}%
+ {#2\@addtofilelist{#1}\@@input \@filef@und}}%
+ \ifx\reserved@a\InputIfFileExists\else
+ \expandafter\CheckCommand\expandafter*\expandafter\InputIfFileExists
+ \expandafter{%
+ \expandafter\protect\csname InputIfFileExists \endcsname
}%
- }%
-\fi
+ \expandafter\CheckCommand \csname InputIfFileExists \endcsname[2]{%
+ \IfFileExists {#1}{%
+ \expandafter \@swaptwoargs \expandafter {\@filef@und }%
+ {#2\@addtofilelist {#1}\@@input }%
+ }%
+ }%
+ \fi
+}
% \end{macrocode}
% Now we can redefine the macro like described above:
% \begin{macrocode}
@@ -211,15 +232,28 @@
% \end{macrocode}
% \begin{macro}{\scr@input@withhook}
% \changes{v3.27}{2019/03/28}{new (internal)}%^^A
+% \changes{v3.28}{2019/11/21}{support for \textsf{memoir}}%^^A
% We need a new internal, because of expanding \cs{@file@und} before inputting
% the file.
% \begin{macrocode}
-\newcommand{\scr@input@withhook}[3]{%
- \scr@load@hook{before}{#2}%
- #3\@addtofilelist{#2}%
- \@@input #1%
- \scr@load@hook{after}{#2}%
-}%
+\@ifclassloaded{memoir}{%
+ \newcommand{\scr@input@withhook}[3]{%
+ \scr@load@hook{before}{#2}%
+ #3\@addtofilelist{#2}%
+ \@ifundefined{m@matbeginf}{}{\m@matbeginf{#2}}%
+ \@@input #1%
+ \@ifundefined{m@matendf}{}{\m@matendf{#2}}%
+ \@ifundefined{killm@matf}{}{\killm@matf{#2}}%
+ \scr@load@hook{after}{#2}%
+ }%
+}{%
+ \newcommand{\scr@input@withhook}[3]{%
+ \scr@load@hook{before}{#2}%
+ #3\@addtofilelist{#2}%
+ \@@input #1%
+ \scr@load@hook{after}{#2}%
+ }%
+}
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -287,7 +321,7 @@
\scr@replacefile@msg{\csname #1.#4-@aliasname\endcsname.#4}{#1.#4}%
\edef\scr@@onefilewithoptions{%
\noexpand\@onefilewithoptions{\csname #1.#4-@aliasname\endcsname}}%
- \fi
+ \fi
\scr@@onefilewithoptions[{#2}][{#3}]{#4}%
\scr@load@hook{lateafter}{#1.#4}%
}
@@ -399,20 +433,61 @@
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\scr@load@hook}
+% \begin{macro}{\scr@load@hook}
+% \changes{v3.27a}{2019/10/16}{workaround for strange handling of
+% \cs{AtEndOfPackage} hook in \cs{@onefilewithoptions}}%^^A
% This macro simply calls a load-file-hook, either the \emph{before}
% or the \emph{after} one, if the hook exists. After calling the hook
% it will be deleted. First argument is the type of hook
% (\meta{before} or \meta{after}), second argument is a filename.
% \begin{macrocode}
\newcommand*{\scr@load@hook}[2]{%
+% \end{macrocode}
+% \begin{macro}{\scrlfile@cmp@hook}
+% \changes{v3.27a}{2019/10/23}{local macros renamed}
+% \begin{macro}{\scrlfile@hookname}
+% \changes{v3.27a}{2019/10/23}{local macros renamed}
+% Workaround for strange handling of the \cs{AtEndOfPackage} hook in
+% \cs{@onefilewithoptions} (becomes \cs{@empty}, if the package already has
+% been loaded and is not loaded again). This workaround is not nice but
+% smart. Before loading a file it defines a marker macro and undefines it
+% later. To decide whether to define or remove the marker, two local macros
+% are used \cs{scrlfile@hookname} and \cs{scrlfile@cmp@hook}. The first has
+% the name of the current hook from the first argument. The other is a compare
+% string. The first one is also valid while processing the hook. The names are
+% very unique, so we do not reserve them using \cs{newcommand} outside. The
+% name of the marker is less unique. Nevertheless it is not reserved.
+% Note: For recursive loading of files this does not work. But this also does
+% not matter, because it is needed only for packages and classes, which are
+% never loaded recursive.
+% \begin{macrocode}
+ \edef\scrlfile@hookname{#1}%
+ \def\scrlfile@cmp@hook{before}%
+ \ifx\scrlfile@hookname\scrlfile@cmp@hook
+ \expandafter\def\csname #2-l@ading\endcsname{#2}%
+ \fi
+ \let\scrlfile@cmp@hook\@undefined
\@ifundefined{#2-@#1}{}{%
\@nameuse{#2-@#1}%
- \expandafter\let\csname #2-@#1\endcsname=\relax}}
+ \expandafter\let\csname #2-@#1\endcsname\relax
+ }%
+% \end{macrocode}
+% The hook could destroy \cs{scrlfile@hookname} so define it again:
+% \begin{macrocode}
+ \edef\scrlfile@hookname{#1}%
+ \def\scrlfile@cmp@hook{after}%
+ \ifx\scrlfile@hookname\scrlfile@cmp@hook
+ \expandafter\let\csname #2-l@ading\endcsname\@undefined
+ \fi
+ \let\scrlfile@cmp@hook\@undefined
+ \let\scrlfile@hookname\@undefined
+}
% \end{macrocode}
% \end{macro}
+% \end{macro}
+% \end{macro}
%
-% \begin{macro}{\scr@set@load@hook}
+% \begin{macro}{\scr@set@load@hook}
% This command adds stuff to a load-file-hook, either the
% \emph{before} or the \emph{after} one. First argument is the type of
% hook (\meta{before} or \meta{after}), second is a filename. There's
@@ -425,149 +500,420 @@
\@ifundefined{#2-@#1}{\@namedef{#2-@#1}{}}{}%
\expandafter\g@addto@macro\csname #2-@#1\endcsname}
% \end{macrocode}
-% \end{macro}
+% \end{macro}
%
-% \begin{macro}{\BeforeFile}
-% \begin{macro}{\AfterFile}
-% \begin{macro}{\BeforeClass}
-% \begin{macro}{\AfterClass}
-% \changes{v3.20}{2016/04/12}{\cs{@ifnextchar} replaced by
-% \cs{kernel@ifnextchar}}%^^A
-% \changes{v3.20}{2016/04/12}{\cs{@ifstar} durch \cs{kernel@ifstar}
-% ersetzt}%^^A
-% \begin{macro}{\AfterAtEndOfClass}
-% \begin{macro}{\@AfterClass}
-% \begin{macro}{\@@AfterClass}
-% \changes{v3.09}{2011/03/08}{new (internal)}
-% \begin{macro}{\@@@AfterClass}
-% \changes{v3.09}{2011/03/09}{new (internal)}
-% \changes{v3.27}{2019/08/26}{using inside class fixed}
-% \begin{macro}{\@sAfterClass}
-% \begin{macro}{\BeforePackage}
-% \begin{macro}{\AfterPackage}
-% \changes{v3.20}{2016/04/12}{\cs{@ifnextchar} replaced by
-% \cs{kernel@ifnextchar}}%^^A
-% \changes{v3.20}{2016/04/12}{\cs{@ifstar} durch \cs{kernel@ifstar}
-% ersetzt}%^^A
-% \begin{macro}{\AfterAtEndOfPackage}
-% \begin{macro}{\@AfterPackage}
-% \begin{macro}{\@@AfterPackage}
-% \changes{v3.09}{2011/03/08}{new (internal)}
-% \begin{macro}{\@@@AfterPackage}
-% \changes{v3.09}{2011/03/09}{new (internal)}
-% \changes{v3.27}{2019/08/26}{using inside package fixed}
-% \begin{macro}{\@sAfterPackage}
-% These macros add stuff to a load-file-hook of a file, class or
-% package. First argument is the name of the file (with extension),
-% class (without extension) or package (without extension). There's a
-% second argument parsed by wether the macros themself nor
-% \cs{scr@set@load@hook} but \cs{g@addto@macro}. See
-% \cs{scr@set@load@hook} for more information. The star-forms
-% \cs{AfterClass*} and \cs{AfterPackage*} does the action immediate,
-% if the class or package was already loaded.
+% \begin{macro}{\BeforeFile}
+% \begin{macro}{\AfterFile}
+% Just add code to the \emph{before} or \emph{after} hook of a file. The
+% arguments are:
+% \begin{description}
+% \item[\meta{file name}:] mandatory argument with the file name as given by
+% \cs{InputIfFileExists}.
+% \item[\meta{code}:] this argument is not processed by \cs{BeforeFile} or
+% \cs{AfterFile} but the internal \cs{scr@set@load@hook}. It is the code
+% that should be added to either the \emph{before} or the \emph{after} hook.
+% \end{description}
% \begin{macrocode}
\newcommand*{\BeforeFile}{\scr@set@load@hook{before}}
\newcommand*{\AfterFile}{\scr@set@load@hook{after}}
+% \end{macrocode}
+% \end{macro}%^^A \AfterFile
+% \end{macro}%^^A \BeforeFile
+%
+% \begin{macro}{\BeforeClass}
+% \changes{v3.20}{2016/04/12}{\cs{@ifnextchar} replaced by
+% \cs{kernel@ifnextchar}}%^^A
+% \changes{v3.20}{2016/04/12}{\cs{@ifstar} durch \cs{kernel@ifstar}
+% ersetzt}%^^A
+% This is quite simple. It only has to add code to the \emph{before} hook
+% already known by \cs{BeforeFile}. The arguments are:
+% \begin{description}
+% \item[\meta{package name}:] mandatory argument.
+% \item[\meta{code}:] this argument is processed not by \cs{BeforeClass} but
+% by the internal \cs{scr@set@load@hook} (see above), that will add the code
+% to the \emph{before} hook of file \meta{code}\texttt{.cls} (or whatever the
+% package extension is).
+% \end{description}
+% \begin{macrocode}
\newcommand*{\BeforeClass}[1]{%
\scr@set@load@hook{before}{#1.\@clsextension}}
+% \end{macrocode}
+% \end{macro}%^^A \BeforeClass
+%
+% \begin{macro}{\AfterClass}
+% \changes{v3.20}{2016/04/12}{\cs{@ifnextchar} replaced by
+% \cs{kernel@ifnextchar}}%^^A
+% \changes{v3.20}{2016/04/12}{\cs{@ifstar} durch \cs{kernel@ifstar}
+% ersetzt}%^^A
+% \begin{macro}{\AfterAtEndOfClass}
+% These are more complicated. There are five forms:
+% \begin{description}
+% \item[\cs{AfterClass}] corresponds to \cs{AfterFile}. So the code will be
+% added to the usual \emph{after} hook and the code is exexuted before code
+% added by the class itself using \cs{AtEndOfClass}. Argument procession
+% will be done by \cs{@AfterClass}.
+% \item[\cs{AfterAtEndOfClass}] This uses the \emph{lateafter} hook, which
+% is executed after the class has been loaded completely inclusive the
+% execution of \cs{AtEndOfClass} code. However, the code will never be
+% executed, if the class will not be loaded (again). But it does nothing,
+% if the class has already been loaded. The arguments are:
+% \begin{description}
+% \item[\meta{class name}] mandatory argument
+% \item[\meta{code}:] this argument is processed not by \cs{BeforeClass}
+% but by the internal \cs{scr@set@load@hook} (see above), that will add
+% the code to the \emph{lateafter} hook of file \meta{code}\texttt{.cls}
+% (or whatever the class extension is), or by \cs{@gobble}.
+% \end{description}
+% \item[\cs{AfterClass*}] like \cs{AfterClass}, but if loading of the
+% class has already began, the code will be executed immediately. So, if
+% the command is used inside the class it is simply
+% \cs{@firstofone}. Argument procession will be done by \cs{@sAfterClass}.
+% \item[\cs{AfterClass+}] like \cs{AfterClass*}, but the code will be
+% executed immediately only if the class already has been loaded
+% completely or it is used inside \cs{AtEndOfClass}. So inside the class
+% it is similar to \cs{AtEndOfClass}. Argument procession will be done by
+% \cs{@pAfterClass}.
+% \item[\cs{AfterClass!}] like \cs{AfterClass+}, but even inside
+% \cs{AtEndOfClass} the code is executed after every all the
+% \cs{AtEndOfClass} code. Argument procession will be done by
+% \cs{@xAfterClass}. (Some class authors interpret this as the star
+% form of \cs{AfterAtEndOfClass}.)
+% \end{description}
+% \begin{macrocode}
\newcommand*{\AfterClass}{%
\kernel@ifstar {\@sAfterClass}{%
- \kernel@ifnextchar +\@@AfterClass{%
- \kernel@ifnextchar !\@@@AfterClass\@AfterClass
+ \kernel@ifnextchar +\@pAfterClass{%
+ \kernel@ifnextchar !\@xAfterClass\@AfterClass
}%
}%
}
-\newcommand*{\@@@AfterClass}[2]{%
- \begingroup
- \expandafter\ifx\csname #2.\@clsextension-h@@k\endcsname\relax
- \aftergroup\@sAfterClass
- \else
- \aftergroup\AfterAtEndOfClass
- \fi
- \endgroup{#2}%
-}
-\newcommand*{\AfterAtEndOfClass}[1]{%
- \scr@set@load@hook{lateafter}{#1.\@clsextension}}
-\newcommand*{\@@AfterClass}[2]{%
- \begingroup
- \expandafter\ifx\csname #2.\@clsextension-h@@k\endcsname\relax
- \aftergroup\@sAfterClass
- \else
- \aftergroup\@AfterClass
- \fi
- \endgroup{#2}%
-}
+% \end{macrocode}
+% \begin{macro}{\@AfterClass}
+% \cs{AfterClass}\marg{class name}\marg{code}.
+% It uses \cs{scr@set@load@hook} to add \meta{code} to the
+% \emph{after} hook. The second argument will be processed by
+% \cs{scr@set@load@hook}.
+% \begin{macrocode}
\newcommand*{\@AfterClass}[1]{%
\scr@set@load@hook{after}{#1.\@clsextension}}
+% \end{macrocode}
+% \end{macro}%^^A \@AfterClass
+% \begin{macro}{\@sAfterClass}
+% \changes{v3.27a}{2019/10/16}{group removed}%^^A
+% This is the internal implementation of:
+% \cs{AfterClass*}\marg{class name}\marg{code}.
+% It tests, whether or not \LaTeX{} thinks that the class
+% has already been loaded, but this only means whether or not the class
+% loading has already been started. If so, it immediately executes the next
+% argument. If not, is uses \cs{@AfterClass} to execute the \meta{code}
+% after loading the class.
+% \begin{macrocode}
\newcommand*{\@sAfterClass}[1]{%
- \begingroup
- \@ifclassloaded{#1}{%
- \aftergroup\@secondoftwo
+ \@ifclassloaded{#1}{%
+ \@secondoftwo
+ }{%
+ \@AfterClass
+ }%
+ {#1}%
+}
+% \end{macrocode}
+% \end{macro}%^^A \@sAfterClass
+% \begin{macro}{\@pAfterClass}
+% \changes{v3.09}{2011/03/08}{new (internal)}%^^A
+% \changes{v3.27a}{2019/10/15}{renamed from \cs{@@AfterClass}}%^^A
+% \changes{v3.27a}{2019/10/16}{usage of \emph{l@ading} marker}%^^A
+% \changes{v3.27a}{2019/10/16}{group removed}%^^A
+% This is the internal implementation of:
+% \cs{AfterClass+}\marg{class name}\marg{code}.
+% Note, that the plus has not already read. So the arguments are:
+% \begin{description}
+% \item[\texttt{+}:] static plus, to be ignored.
+% \item[\meta{class name}] mandatory argument
+% \item[\meta{code}:] this argument is processed not by \cs{BeforeClass} but
+% by the internal \cs{@sAfterClass} or \cs{@AfterClass} (see above).
+% \end{description}
+% Here we cannot use \LaTeX's test, whether or not the class as already been
+% loaded, because it tests only, if loading of the class has already been
+% started. Here we use an internal information of our \emph{l@ading} marker
+% (see \cs{scr@load@hook}). It is as long defined as a file is read while
+% input. If it is undefined (or \cs{relax}) we can use \cs{@sAfterClass} to
+% either execute \meta{code} immediately or add it to the \emph{after}
+% hook. If is defined (and not \cs{relax}) loading of the class is in progress
+% and \cs{AfterClass} is used to add \meta{code} to the \emph{after} hook. The
+% effect is, that \meta{code} is executed immediately if loading of
+% \meta{class name} has already been finished and after the class if the
+% loading of the \meta{class name} has not already been finished.
+% \begin{macrocode}
+\newcommand*{\@pAfterClass}[2]{%
+ \@ifundefined{#2.\@clsextension-l@ading}{%
+ \@sAfterClass
+ }{%
+ \@AfterClass
+ }%
+ {#2}%
+}
+% \end{macrocode}
+% \end{macro}%^^A \@pAfterClass
+% \begin{macro}{\@xAfterClass}
+% \changes{v3.09}{2011/03/09}{new (internal)}%^^A
+% \changes{v3.27}{2019/08/26}{using inside class fixed}%^^A
+% \changes{v3.27a}{2019/10/15}{renamed from \cs{@@@AfterClass}}%^^A
+% \changes{v3.27a}{2019/10/16}{usage of \emph{l@ading} marker}%^^A
+% \changes{v3.27a}{2019/10/16}{group removed}%^^A
+% This is the internal implementation of:
+% \cs{AfterClass!}\marg{class name}\marg{code}. Note, that the exclamation
+% mark has not already read. So the arguments are:
+% \begin{description}
+% \item[\texttt{!}:] static exclamation mark, to be ignored.
+% \item[\meta{class name}] mandatory argument
+% \item[\meta{code}:] this argument is processed not by \cs{BeforeClass} but
+% by the internal \cs{@sAfterClass} or \cs{@AfterClass} (see above).
+% \end{description}
+% There are two differences to \cs{@pAfterClass}:
+% \begin{enumerate}
+% \item In case of \cs{\meta{class name}.cls-l@ading} is defined (and not
+% \cs{relax}), while loading a class, it used \cs{AfterAtEndOfClass}
+% instead of \cs{AfterClass} to add \meta{code} to the \emph{lateafter}
+% hook instead of the \emph{after} hook.
+% \item In case of \cs{\meta{class name}.cls-l@ading} is undefined (or
+% \cs{relax}) it also has to test, whether or not the class has already
+% been loaded. If so, it uses \cs{@sAfterClass} to execute the \meta{code}
+% immediately, otherwise it uses \cs{AfterAtEndOfClass} to add the
+% \meta{code} to the \emph{lateafter} hook.
+% \end{enumerate}
+% So it is more like (the not existing) \cs{AfterAtEndOfClass+} than
+% \cs{AfterAtEndOfClass*}.
+% \begin{macrocode}
+\newcommand*{\@xAfterClass}[2]{%
+ \@ifundefined{#2.\@clsextension-l@ading}{%
+ \@ifclassloaded{#2}{%
+ \@sAfterClass
}{%
- \aftergroup\@AfterClass
+ \AfterAtEndOfClass
}%
- \endgroup
- {#1}%
+ }{%
+ \AfterAtEndOfClass
+ }%
+ {#2}%
}
+% \end{macrocode}
+% \end{macro}%^^A \@xAfterClass
+% Note that \cs{AfterAtEndOfClass} executed the \meta{code} after each try
+% to load a class, even if the class has already been loaded and you try
+% to load it again.
+% \begin{macrocode}
+\newcommand*{\AfterAtEndOfClass}[1]{%
+ \scr@set@load@hook{lateafter}{#1.\@clsextension}}
+% \end{macrocode}
+% \end{macro}%^^A \AfterAtEndOfClass
+% \end{macro}%^^A \AfterClass
+%
+% \begin{macro}{\BeforePackage}
+% This is quite simple. It only has to add code to the \emph{before} hook
+% already known by \cs{BeforeFile}. The arguments are:
+% \begin{description}
+% \item[\meta{package name}:] mandatory argument.
+% \item[\meta{code}:] this argument is processed not by \cs{BeforePackage} but
+% by the internal \cs{scr@set@load@hook} (see above), that will add the code
+% to the \emph{before} hook of file \meta{code}\texttt{.sty} (or whatever the
+% package extension is).
+% \end{description}
+% \begin{macrocode}
\newcommand*{\BeforePackage}[1]{%
\scr@set@load@hook{before}{#1.\@pkgextension}}
+% \end{macrocode}
+% \end{macro}%^^A \BeforePackage
+%
+% \begin{macro}{\AfterPackage}
+% \changes{v3.20}{2016/04/12}{\cs{@ifnextchar} replaced by
+% \cs{kernel@ifnextchar}}%^^A
+% \changes{v3.20}{2016/04/12}{\cs{@ifstar} durch \cs{kernel@ifstar}
+% ersetzt}%^^A
+% \begin{macro}{\AfterAtEndOfPackage}
+% These are more complicated. There are five forms:
+% \begin{description}
+% \item[\cs{AfterPackage}] corresponds to \cs{AfterFile}. So the code will be
+% added to the usual \emph{after} hook and the code is exexuted before code
+% added by the package itself using \cs{AtEndOfPackage}. Argument procession
+% will be done by \cs{@AfterPackage}.
+% \item[\cs{AfterAtEndOfPackage}] This uses the \emph{lateafter} hook, which
+% is executed after the package has been loaded completely inclusive the
+% execution of \cs{AtEndOfPackage} code. However, the code will never be
+% executed, if the package will not be loaded (again). But it does nothing,
+% if the package has already been loaded. The arguments are:
+% \begin{description}
+% \item[\meta{package name}] mandatory argument
+% \item[\meta{code}:] this argument is processed not by \cs{BeforePackage}
+% but by the internal \cs{scr@set@loaf@hook} (see above), that will add
+% the code to the \emph{lateafter} hook of file \meta{code}\texttt{.sty}
+% (or whatever the package extension is), or by \cs{@gobble}.
+% \end{description}
+% \item[\cs{AfterPackage*}] like \cs{AfterPackage}, but if loading of the
+% package has already began, the code will be executed immediately. So, if
+% the command is used inside the package it is simply
+% \cs{@firstofone}. Argument procession will be done by \cs{@sAfterPackage}.
+% \item[\cs{AfterPackage+}] like \cs{AfterPackage*}, but the code will be
+% executed immediately only if the package already has been loaded
+% completely or it is used inside \cs{AtEndOfPackage}. So inside the package
+% it is similar to \cs{AtEndOfPackage}. Argument procession will be done by
+% \cs{@pAfterPackage}.
+% \item[\cs{AfterPackage!}] like \cs{AfterPackage+}, but even inside
+% \cs{AtEndOfPackage} the code is executed after every all the
+% \cs{AtEndOfPackage} code. Argument procession will be done by
+% \cs{@xAfterPackage}. (Some package authors interpret this as the star
+% form of \cs{AfterAtEndOfPackage}.)
+% \end{description}
+% \begin{macrocode}
\newcommand*{\AfterPackage}{%
\kernel@ifstar {\@sAfterPackage}{%
- \kernel@ifnextchar +\@@AfterPackage{%
- \kernel@ifnextchar !\@@@AfterPackage\@AfterPackage
+ \kernel@ifnextchar +\@pAfterPackage{%
+ \kernel@ifnextchar !\@xAfterPackage\@AfterPackage
}%
}%
}
-\newcommand*{\@@@AfterPackage}[2]{%
- \begingroup
- \expandafter\ifx\csname #2.\@pkgextension-h@@k\endcsname\relax
- \aftergroup\@sAfterPackage
- \else
- \aftergroup\AfterAtEndOfPackage
- \fi
- \endgroup{#2}%
-}
-\newcommand*{\AfterAtEndOfPackage}[1]{%
- \scr@set@load@hook{lateafter}{#1.\@pkgextension}}
-\newcommand*{\@@AfterPackage}[2]{%
- \begingroup
- \expandafter\ifx\csname #2.\@pkgextension-h@@k\endcsname\relax
- \aftergroup\@sAfterPackage
- \else
- \aftergroup\@AfterPackage
- \fi
- \endgroup{#2}%
-}
+% \end{macrocode}
+% \begin{macro}{\@AfterPackage}
+% This is the internal implementation of:
+% \cs{AfterPackage}\marg{package name}\marg{code}.
+% It uses \cs{scr@set@load@hook} to add \meta{code} to the
+% \emph{after} hook. The second argument will be processed by
+% \cs{scr@set@load@hook}.
+% \begin{macrocode}
\newcommand*{\@AfterPackage}[1]{%
\scr@set@load@hook{after}{#1.\@pkgextension}}
+% \end{macrocode}
+% \end{macro}%^^A \@AfterPackage
+% \begin{macro}{\@sAfterPackage}
+% \changes{v3.27a}{2019/10/16}{group removed}%^^A
+% This is the internal implementation of:
+% \cs{AfterPackage*}\marg{package name}\marg{code}.
+% It tests, whether or not \LaTeX{} thinks that the package
+% has already been loaded, but this only means whether or not the package
+% loading has already been started. If so, it immediately executes the next
+% argument. If not, is uses \cs{@AfterPackage} to execute the \meta{code}
+% after loading the package.
+% \begin{macrocode}
\newcommand*{\@sAfterPackage}[1]{%
- \begingroup
- \@ifpackageloaded{#1}{%
- \aftergroup\@secondoftwo
+ \@ifpackageloaded{#1}{%
+ \@secondoftwo
+ }{%
+ \@AfterPackage
+ }%
+ {#1}%
+}
+% \end{macrocode}
+% \end{macro}%^^A \@sAfterPackage
+% \begin{macro}{\@pAfterPackage}
+% \changes{v3.09}{2011/03/08}{new (internal)}%^^A
+% \changes{v3.27a}{2019/10/15}{renamed from \cs{@@AfterPackage}}%^^A
+% \changes{v3.27a}{2019/10/16}{usage of \emph{l@ading} marker}%^^A
+% \changes{v3.27a}{2019/10/16}{group removed}%^^A
+% This is the internal implementation of:
+% \cs{AfterPackage+}\marg{package name}\marg{code}.
+% Note, that the plus has not already read. So the arguments are:
+% \begin{description}
+% \item[\texttt{+}:] static plus, to be ignored.
+% \item[\meta{package name}] mandatory argument
+% \item[\meta{code}:] this argument is processed not by \cs{BeforePackage} but
+% by the internal \cs{@sAfterPackage} or \cs{@AfterPackage} (see above).
+% \end{description}
+% Here we cannot use \LaTeX's test, whether or not the package as already been
+% loaded, because it tests only, if loading of the package has already been
+% started. Here we use an internal information of our \emph{l@ading} marker
+% (see \cs{scr@load@hook}). It is as long defined as a file is read while
+% input. If it is undefined (or \cs{relax}) we can use \cs{@sAfterPackage} to
+% either execute \meta{code} immediately or add it to the \emph{after}
+% hook. If is defined (and not \cs{relax}) loading of the package is in
+% progress and \cs{AfterPackage} is used to add \meta{code} to the
+% \emph{after} hook. The effect is, that \meta{code} is executed immediately
+% if loading of \meta{package name} has already been finished and after the
+% package if the loading of the \meta{package name} has not already been
+% finished.
+% \begin{macrocode}
+\newcommand*{\@pAfterPackage}[2]{%
+ \@ifundefined{#2.\@pkgextension-l@ading}{%
+ \@sAfterPackage
+ }{%
+ \@AfterPackage
+ }%
+ {#2}%
+}
+% \end{macrocode}
+% \end{macro}%^^A \@pAfterPackage
+% \begin{macro}{\@xAfterPackage}
+% \changes{v3.09}{2011/03/09}{new (internal)}%^^A
+% \changes{v3.27}{2019/08/26}{using inside package fixed}%^^A
+% \changes{v3.27a}{2019/10/15}{renamed from \cs{@@@AfterPackage}}%^^A
+% \changes{v3.27a}{2019/10/16}{usage of \emph{l@ading} marker}%^^A
+% \changes{v3.27a}{2019/10/16}{group removed}%^^A
+% This is the internal implementation of:
+% \cs{AfterPackage!}\marg{package name}\marg{code}. Note, that the exclamation
+% mark has not already read. So the arguments are:
+% \begin{description}
+% \item[\texttt{!}:] static exclamation mark, to be ignored.
+% \item[\meta{package name}] mandatory argument
+% \item[\meta{code}:] this argument is processed not by \cs{BeforePackage} but
+% by the internal \cs{@sAfterPackage} or \cs{@AfterPackage} (see above).
+% \end{description}
+% There are two differences to \cs{@pAfterPackage}:
+% \begin{enumerate}
+% \item In case of \cs{\meta{package name}.sty-l@ading} is defined (and not
+% \cs{relax}), to while loading a package, it used \cs{@AfterAtEndOfPackage}
+% instead of \cs{AfterPackage} to add \meta{code} to the \emph{lateafter}
+% hook instead of the \emph{after} hook.
+% \item In case of \cs{\meta{package name}.sty-l@ading} is not defined (or
+% \cs{relax}) it also has to test, whether or not the package has already
+% been loaded. If so, it uses \cs{@sAfterPackage} to execute the \meta{code}
+% immediately, otherwise it uses \cs{@AfterAtEndOfPackage} to add the
+% \meta{code} to the \emph{lateafter} hook.
+% \end{enumerate}
+% So it is more like (the not existing) \cs{AfterAtEndOfPackage+} than
+% \cs{AfterAtEndOfPackage*}.
+% \begin{macrocode}
+\newcommand*{\@xAfterPackage}[2]{%
+ \@ifundefined{#2.\@pkgextension-l@ading}{%
+ \@ifpackageloaded{#2}{%
+ \@sAfterPackage
}{%
- \aftergroup\@AfterPackage
+ \@AfterAtEndOfPackage
}%
- \endgroup
- {#1}%
+ }{%
+ \@AfterAtEndOfPackage
+ }%
+ {#2}%
}
% \end{macrocode}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-%
+% \end{macro}%^^A \@xAfterPackage
+% \begin{macro}{\@AfterAtEndOfPackage}
+% \changes{v3.27a}{2019/10/15}{new (internal)}
+% \changes{v3.27a}{2019/10/16}{group removed}%^^A
+% Note that until 3.27a \cs{AfterAtEndOfPackage} executed the \meta{code}
+% after each try to load a package, even if the package has already been
+% loaded and you've try to load it again. Since 3.27a this is the
+% functionality of \cs{@AfterAtEndOfPackage}. \cs{AfterAtEndOfPackage} now
+% does not do anything for already loaded packages or while loading the
+% package.
+% \begin{macrocode}
+\newcommand*{\AfterAtEndOfPackage}[1]{%
+ \@ifpackageloaded{#1}{%
+ \@ifundefined{#1.\@pkgextension-l@ading}{%
+ \@gobbletwo
+ }{%
+ \@AfterAtEndOfPackage
+ }%
+ }{%
+ \@AfterAtEndOfPackage
+ }%
+ {#1}%
+}
+\newcommand*{\@AfterAtEndOfPackage}[1]{%
+ \scr@set@load@hook{lateafter}{#1.\@pkgextension}%
+}
+% \end{macrocode}
+% \end{macro}%^^A \@AfterAtEndOfPackage
+% \end{macro}%^^A \AfterAtEndOfPackage
+% \end{macro}%^^A \AfterPackage
+%
% \begin{macro}{\PreventPackageFromLoading}
% \changes{v3.08}{2010/11/04}{New}
% \changes{v3.11a}{2012/06/13}{write fault error in \cs{MessageBreak} fixed}