summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/koma-script/source/scrlfile.dtx
blob: a9a65ef46a5b70a490231a0bddbc342eef43b985 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
% \iffalse^^A meta-comment
% ======================================================================
% scrlfile.dtx
% Copyright (c) Markus Kohm, 2002-2022
%
% This file is part of the work `scrlfile' which is part of the LaTeX2e
% KOMA-Script bundle.
%
% This work may be distributed and/or modified under the conditions of
% the LaTeX Project Public License, version 1.3c of the license.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of LaTeX 
% version 2005/12/01 or later and of this work.
%
% This work has the LPPL maintenance status "author-maintained".
%
% The Current Maintainer and author of this work is Markus Kohm.
%
% This work consists of all files listed in manifest.txt.
% ======================================================================
%%% From File: $Id: scrlfile.dtx 3688 2022-02-10 08:26:37Z 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: 2022-02-10 09:26:37 +0100 (Do, 10. Feb 2022) $
  \def\filerevision$#1: #2 ${\gdef\filerevision{r#2}}
  \filerevision$Revision: 3688 $
  \edef\reserved@a{%
    \noexpand\endgroup
    \noexpand\ProvidesFile{scrlfile.dtx}%
                          [\filedate\space\filerevision\space
                           KOMA-Script package source
  }%
\reserved@a
%</dtx>
%<package>\ProvidesPackage{scrlfile}[%
%!KOMAScriptVersion
%<package>  package 
  (file load hooks)]
%<*dtx>
\ifx\documentclass\undefined
  \input scrdocstrip.tex
  \@@input scrkernel-version.dtx
  \@@input scrstrip.inc
  \KOMAdefVariable{COPYRIGHTFROM}{2002}
  \generate{\usepreamble\defaultpreamble
    \file{scrlfile.sty}{%
      \from{scrlfile.dtx}{package}%
      \from{scrlogo.dtx}{logo}%
    }%
  }
  \batchinput{scrlfile-hook.dtx}
  \batchinput{scrlfile-patcholdlatex.dtx}
  \@@input scrstrop.inc
\else
  \let\endbatchfile\relax
\fi
\endbatchfile
\documentclass[USenglish]{koma-script-source-doc}
\usepackage{babel}
\setcounter{StandardModuleDepth}{1}
\begin{document}
  \DocInput{scrlfile.dtx}
\end{document}
%</dtx>
% \fi^^A meta-comment
%
% \changes{v2.95}{2002/06/11}{First version split from hugh scrclass.dtx}
% \changes{v3.24}{2017/05/06}{standalone manual removed}
% \changes{v3.32}{2020/09/11}{new implementation based on
%   \pkg*{scrlfile-hook} and \pkg*{scrlfile-patcholdlatex}}
% \changes{v3.36}{2022/02/03}{switch over from \cls*{scrdoc} to
%   \cls*{koma-script-source-doc}}
% \changes{v3.36}{2022/02/03}{using \file{scrlogo.dtx} to define the logo}
%
% \GetFileInfo{scrlfile.dtx}
% \title{File Loading Hooks with \href{https://komascript.de}{\KOMAScript}
%   Package \pkg*{scrlfile}}
% \author{\href{mailto:komascript@gmx.info}{Markus Kohm}}
% \date{Revision \fileversion{} of \filedate}
% \maketitle
% \begin{abstract}
%   This package is the compatibility layer over \texttt{scrlfile-hook} and
%   \texttt{scrlfile-patcholdlatex}. It provides package and class hook
%   handling independent from the used \LaTeX{} release.
% \end{abstract}
% \tableofcontents
%
%
% \section{User Manual}
%
% You can find the user manual of \pkg*{scrlfile} in the \KOMAScript{} manual,
% either the German \file{scrguide} or the English \file{scrguien}.
% Here you can find interim documentation only (before it is added to the
% \KOMAScript{} manual).
%
% \DescribeOption{withdeprecated}
% Package option \opt{withdeprecated} enables the definition of deprecated
% commands \cs{AfterClass+}, \cs{AfterPackage+}, \cs{AfterClass!} and
% \cs{AfterPackage!}. All of them will be emulated by \cs{AfterAtEndOClass*}
% and \cs{AfterAtEndOfPackage*} so they are not completely compatible with the
% original deprecated commands.
%
% Users of classes or package, that use such deprecated commands can load
% \pkg*{scrlfile} already before the class using:
%\begin{verbatim}
% \RequirePackage[withdeprecated]{scrlfile}
%\end{verbatim}%
% or adding option \opt{withdeprecated} to the global options of
% \cs{documentclass}. Note, this is not a key-value option. It cannot be
% changed after loading \pkg*{scrlfile}.
%
% \MaybeStop{\PrintIndex}
%
% \section{Implementation of \pkg*{scrlfile}}
%
% We need to load one of the packages \pkg*{scrlfile-hook},
% \pkg*{scrlfile-kook-3.34}, \pkg*{scrlfile-patcholdlatex}.
% \changes{v3.33}{2021/02/09}{do not test for existence of \cs{AddToHook} any
% longer, but \cs{IfFormatAtLeastTF} and the format version}%
% We cannot do the decision by testing the existence of macro \cs{AddToHook},
% because package \pkg{latexrelease} does not rollback to prior format
% versions good enough. Instead of undefining the macro and so really
% reverting to the definition of \LaTeX{} kernels prior to 2020/10/01 it only
% redefines it to a do-nothing macro. Because of this and similar issues with
% \pkg{latexrelease} cannot (or only with provision) be used to simulate a
% real old \LaTeX{} kernel, i.e. for testing. So the only valid test for the
% existence of the wanted \cs{AddToHook} would be to test the definite
% definition of \cs{AddToHook} and the existence of the hooks we are
% using. But, because this is to much effort, we simply test the format
% version. Nevertheless, we know, this may fail!
%    \begin{macrocode}
\@ifundefined{IfFormatAtLeastTF}{%
  \RequirePackage{scrlfile-patcholdlatex}%
  \RequirePackage{xparse}%
%    \end{macrocode}
% \changes{v3.33}{2021/02/16}{workaround for \pkg{latexrelease} bug}
% Explicitly switch of \pkg{expl3} syntax because of a
% \pkg{latexrelease} bug related to the usage of \pkg{xparse-2020-10-01} in
% version 2020-02-02.
% \changes{v3.35}{2021/10/31}{new variant because of \LaTeX{} kernel change}
%    \begin{macrocode}
  \ExplSyntaxOff
}{%
  \IfFormatAtLeastTF{2020/10/01}{%
    \IfFormatAtLeastTF{2021/11/15}{%
      \RequirePackage{scrlfile-hook}%
    }{%
      \RequirePackage{scrlfile-hook-3.34}%
    }%
  }{%
    \RequirePackage{scrlfile-patcholdlatex}%
    \RequirePackage{xparse}%
%    \end{macrocode}
% Explicitly switch of \pkg{expl3} syntax because of a
% \pkg{latexrelease} bug in version 2020-02-02.
%    \begin{macrocode}
    \ExplSyntaxOff
  }%
}
%    \end{macrocode}
%
% \begin{option}{withdeprecated}
% \changes{v3.32}{2020/09/11}{added}
% Depending on this option we implement addition deprecated commands.
%    \begin{macrocode}
\DeclareOption{withdeprecated}{%
%    \end{macrocode}
%
% \begin{command}[noindex]{\AfterClass+,\AfterClass!}
% \cs{scrlfile@AfterClass} is used in the sub-packages to store the original
% \cs{AfterClass} and can be used to redefine \cs{AfterClass} to handle the
% plus and the exclamation mark variant.
%    \begin{macrocode}
  \RenewDocumentCommand\AfterClass{}{%
%    \end{macrocode}
%^^A Hack for correct line numbers in the index:
%^^A - end environment,
%^^A - do index entries
%^^A - fix vertical spaces
%^^A - restart environment without printing and indexing
% \end{command}
% \SpecialMainCommandIndex{\AfterClass+}
% \SpecialMainCommandIndex{\AfterClass\quotechar!}
% \vskip-\dimexpr 2.2\baselineskip+\parskip\relax
% \begin{command}[noindex,noprint]{\AfterClass+,\AfterClass!}
%    \begin{macrocode}
    \kernel@ifnextchar +%
      {\scrlfile@emulatedeprecated{Class}}%
      {%
        \kernel@ifnextchar !%
          {\scrlfile@emulatedeprecated{Class}}%
          \scrlfile@AfterClass
      }%
  }
%    \end{macrocode}
% \end{command}
%
% \begin{command}[noindex]{\AfterPackage+,\AfterPackage!}
% \cs{scrlfile@AfterPackage} is used in the sub-packages to store the original
% \cs{AfterPackage} and can be used to redefine \cs{AfterPackage} to handle
% the plus and the exclamation mark variant.
%    \begin{macrocode}
  \RenewDocumentCommand\AfterPackage{}{%
%    \end{macrocode}
%^^A Hack for correct line numbers in the index:
%^^A - end environment,
%^^A - do index entries
%^^A - fix vertical spaces
%^^A - restart environment without printing and indexing
% \end{command}
% \SpecialMainCommandIndex{\AfterPackage+}
% \SpecialMainCommandIndex{\AfterPackage\quotechar!}
% \vskip-\dimexpr 2.2\baselineskip+\parskip\relax
% \begin{command}[noindex,noprint]{\AfterPackage+,\AfterPackage!}
%    \begin{macrocode}
    \kernel@ifnextchar +%
      {\scrlfile@emulatedeprecated{Package}}%
      {%
        \kernel@ifnextchar !%
          {\scrlfile@emulatedeprecated{Package}}%
          \scrlfile@AfterPackage
      }%
  }
%    \end{macrocode}
% \end{command}
%
% \begin{macro}{\scrlfile@emulatedeprecated}
% \changes{v3.32}{2020/09/11}{added}
% This emulates \cs{AfterClass+}, \cs{AfterPackage+}, \cs{AfterClass!} and
% \cs{AfterPackage!} using \cs{AfterAtEndOfClass} or
% \cs{AfterAtEndOfPackage}. Note, that both, the plus and the exclamation mark
% variants, are emulated by the star variant of \cs{AfterAtEndOfClass}
% resp. \cs{AfterAtEndOfPackage}. So the emulation is not perfect.
%    \begin{macrocode}
  \newcommand*{\scrlfile@emulatedeprecated}[2]{%
    \PackageWarning{scrlfile}{%
      emulating deprecated \expandafter\string\csname After#1#2\endcsname
      \space by\MessageBreak
      \expandafter\string\csname AfterAtEndOf#1*\endcsname.\MessageBreak
      Note, this may fail, so you should not use\MessageBreak
      \expandafter\string\csname After#1#2\endcsname
    }%
    \csname AfterAtEndOf#1\endcsname*%
  }
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
}
%    \end{macrocode}
% \end{option}
%
% Now, we just have to execute and process the options.
%    \begin{macrocode}
\ExecuteOptions{}
\ProcessOptions\relax
%    \end{macrocode}
%
% \Finale
% \PrintChanges
% 
% \endinput
% Local Variables:
% mode: doctex
% ispell-local-dictionary: "en_US"
% eval: (flyspell-mode 1)
% TeX-master: t
% TeX-engine: luatex-dev
% eval: (setcar (or (cl-member "Index" (setq-local TeX-command-list (copy-alist TeX-command-list)) :key #'car :test #'string-equal) (setq-local TeX-command-list (cons nil TeX-command-list))) '("Index" "mkindex %s" TeX-run-index nil t :help "makeindex for dtx"))
% End: