summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/koma-script/scrkernel-version.dtx
blob: cbd3c36b2589f77dfe707724166db82b73920b87 (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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
% \iffalse meta-comment
% ======================================================================
% scrkernel-version.dtx
% Copyright (c) Markus Kohm, 2002-2024
%
% This file 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.md.
% ======================================================================
%%% From File: $Id: scrkernel-version.dtx 4133 2024-10-24 09:54:28Z kohm $
%
% ATTENTION: In this file parts of the code and documentation are before the
% driver. This must be, because this part of the code is needed by the driver
% in this file and most of the other KOMA-Script dtx-files.
%
% \fi^^A meta-comment
%
% \changes{v2.0e}{1994/07/07}{first release of \cls*{scrartcl},
%   \cls*{scrreprt}, and \cls*{scrbook}}
% \changes{v2.95}{2002/06/25}{first version of this file by splitting of
%   \file{scrclass.dtx}}
% \changes{v3.36}{2022/02/11}{switch over from \cls*{scrdoc} to
%   \cls*{koma-script-source-doc}}
% \changes{v3.36}{2022/02/11}{whole implementation documentation in English}
% \changes{v3.99}{2022/10/25}{prepared to generate experimental \KOMAScript~4}
% \changes{v3.40}{2023/04/17}{guide names changed}
%
% \GetFileInfo{scrkernel-version.dtx}
% \title{The Version of the \href{https://komascript.de}{\KOMAScript} Kernel
%   and therefore the Classes and most of the Packages}
% \author{\href{mailto:komascript@gmx.info}{Markus Kohm}}
% \date{Version \fileversion{} of \filedate}
% \maketitle
% \begin{abstract}
%   \filename{} is not only used for the code of all \KOMAScript{} classes and
%   most of the \KOMAScript{} packages. It is also used by most of the
%   installation drivers (\file{ins}-files) for the definition of
%   \KOMAScript{} version.
% \end{abstract}
% \tableofcontents
%
%
% \section{User Manual}
%
% You can find the user documentation of the commands implemented here in the
% \KOMAScript{} manual, either the German \file{scrguide-de.pdf} or the
% English \file{scrguide-en.pdf}.
%
% \MaybeStop{\PrintIndex}
%
% \section{Implementation of the \KOMAScript{} Kernel Version Information}
%
% \begin{command}{\KOMAScriptVersion}
% \changes{v2.95}{2002/06/25}{added}
% The main purpose of this command it to prevent mixture of files of
% different \KOMAScript{} versions. But users can also use this command to
% detect \KOMAScript{}. It is added to the classes and most of the packages
% by the installation drivers. This is done using \file{scrdocstrip.tex} and
% additionally loading this file.
% \begin{macro}{\@CheckKOMAScriptVersion}
% \changes{v2.95}{2002/06/25}{added}
% \changes{v3.42}{2024/04/17}{command is defined only once but \pkg{expl3}
%   hard}
% \changes{v3.42}{2024/04/17}{command is no longer defined in \file{clo}
%   or \file{lco} files}
% Depending on \cs{KOMAScriptVersion} already defined or not, the existing
% definition is compared with the version here or \cs{KOMAScriptVersion} is
% newly and globally defined. This has to work not only in class or package
% files, but also in document files. So \cs{makeatletter} inside a group is
% needed for the internal macros. Additionally a guard \texttt{ignorethis} is
% used, to avoid adding code, that is needed only for the installation driver,
% also to classes or packages. Note, the version check is also done in
% \file{clo} or \file{lco} files, but the macros \cs{@CheckKOMAScriptVersion}
% and \cs{@@CheckKOMAScriptVersion} are not defined in those, because those
% files should not always be loaded by \KOMAScript{} classes or packages,
% which would already define the command.
%    \begin{macrocode}
%<*ignorethis>
\ifx\newcommand\undefined
  \catcode`\@11\relax
  \def\@CheckKOMAScriptVersion#1{%
    \global\KOMAdefVariable{KOMAScriptVersion}{\space\space#1}%
    \expandafter\ifx\csname ifbeta\endcsname\relax
      \def\@defbeta##1 ##2 ##3KOMA-Script{%
        \def\@cmpstrA{##3}\def\@cmpstrB{BETA }%
        \ifx\@cmpstrA\@cmpstrB
          \expandafter\expandafter\expandafter\global
          \expandafter\expandafter\expandafter\let
          \expandafter\csname ifbeta\expandafter\endcsname
          \csname iftrue\endcsname
        \fi
      }\expandafter\@defbeta\KOMAvar@KOMAScriptVersion
    \fi
    \expandafter\ifx\csname ifbeta\endcsname\relax
      \def\@defbeta##1 ##2.##3.##4 KOMA-Script\@nil{%
        \def\@cmpstrA{##4}\def\@cmpstrB{}%
        \ifx\@cmpstrA\@cmpstrB\else
          \expandafter\expandafter\expandafter\global
          \expandafter\expandafter\expandafter\let
          \expandafter\csname ifbeta\expandafter\endcsname
          \csname iftrue\endcsname
        \fi
      }\expandafter\@defbeta\KOMAvar@KOMAScriptVersion. KOMA-Script\@nil
    \fi
    \expandafter\ifx\csname ifbeta\endcsname\relax
      \expandafter\expandafter\expandafter\global
      \expandafter\expandafter\expandafter\let
      \expandafter\csname ifbeta\expandafter\endcsname
      \csname iffalse\endcsname
    \fi
    \let\@CheckKOMAScriptVersion\undefined
    \endinput
  }%
\else
  \makeatletter
%</ignorethis>
%<*class|package>
\providecommand*{\@CheckKOMAScriptVersion}{%
  \begingroup
    \ExplSyntaxOff
    \@@CheckKOMAScriptVersion
}
\providecommand*{\@@CheckKOMAScriptVersion}[1]{%
    \@ifundefined{KOMAScriptVersion}{%
      \gdef\KOMAScriptVersion{#1}%
    }{%
      \def\@tempa{#1}%
      \ifx\KOMAScriptVersion\@tempa\else
        \GenericWarning{\space\@spaces\@spaces\@spaces\@spaces}{%
          Version warning:
          \noexpand\KOMAScriptVersion is 
          `\csname KOMAScriptVersion\endcsname',\MessageBreak
          but `#1' was expected!\MessageBreak
          You should not use classes, packages or files
          from\MessageBreak
          different KOMA-Script versions\@gobble
        }%
      \fi
    }%
  \endgroup
}
%</class|package>
%<*ignorethis>
\fi
%</ignorethis>
%    \end{macrocode}
% Note: Following line will be patched by \file{makebetaorrelase.sh} and
% therefore the syntax or general structure of the line must not be changed!
%    \begin{macrocode}
%<*!v4>
\@CheckKOMAScriptVersion{2024/10/24 v3.43 KOMA-Script}%
%</!v4>
%<v4>  \@nameuse{@CheckKOMAScriptVersion}{2022/10/25 v3.99 ALPHA KOMA-Script}%
%    \end{macrocode}
% \end{macro}
% \end{command}
%
% \iffalse
%<*dtx>
\makeatother
\ProvidesFile{scrkernel-version.dtx}[\KOMAScriptVersion (versions)]
\documentclass[USenglish]{koma-script-source-doc}
\usepackage{babel}
\begin{document}
  \DocInput{scrkernel-version.dtx}
\end{document}
%</dtx>
% \fi
%
% \subsection{Implementation of class and package names and file names}
%
% \begin{description}
% \item[ToDo] Maybe, this should be split in one file for each class. The file
%   extension code should be moved to \file{scrkernel-miscellaneous.dtx}.
% \end{description}
%
% \begin{macro}{\scr@pkgextension}
% \changes{v3.17}{2015/03/17}{added}
% \begin{macro}{\scr@clsextension}
% \changes{v3.17}{2015/03/17}{added}
% \changes{v3.18}{2015/06/17}{fixed}
% Last but not least same like \cs{@pkgextension} and \cs{@clsextension} but
% still valid after the preamble.
%    \begin{macrocode}
%<*class|package>
%<package>\providecommand*{\scr@pkgextension}{\@pkgextension}
%<class>\providecommand*{\scr@clsextension}{\@clsextension}
\AtBeginDocument{%
%<package>  \let\scr@pkgextension\@pkgextension
%<class>  \let\scr@clsextension\@clsextension
}
%</class|package>
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{command}{\KOMAClassFileName}
% \changes{v3.17}{2014/03/12}{added}
% \begin{command}{\KOMAClassName}
% \changes{v2.95}{2004/11/04}{added}
% \begin{command}{\KOMALongClassFileName,\KOMALongClassName}
% \changes{v3.27}{2019/02/16}{added}
% \begin{command}{\ClassName}
% \changes{v2.95}{2004/11/04}{added}
% We define the name of each \KOMAScript{} class and the name of the
% \emph{class} of the class (usually name of the corresponding standard class)
% once. This allows to use code, that outputs the name of the class, for
% several classes without using always class specific code.
%    \begin{macrocode}
%<*class>
%<*!v4>
%<article|(letter&long)>\newcommand*{\KOMAClassName}{scrartcl}
%<report>\newcommand*{\KOMAClassName}{scrreprt}
%<book>\newcommand*{\KOMAClassName}{scrbook}
%<letter&!long>\newcommand*{\KOMAClassName}{scrlttr2}
%<*!long>
\newcommand*{\KOMAClassFileName}{\KOMAClassName.\@clsextension}
\edef\KOMAClassFileName{\KOMAClassFileName}
%</!long>
%</!v4>
\newcommand*{\ClassName}{%
%<article|(letter&long)>  article%
%<report>  report%
%<book>  book%
%<letter&!long>  letter%
}
%<*long>
\newcommand*{\KOMALongClassName}{}
%<*!v4>
%<!letter>\edef\KOMALongClassName{scr\ClassName}
%<letter>\def\KOMALongClassName{scrletter}
%</!v4>
\newcommand*{\KOMALongClassFileName}{\KOMALongClassName.\@clsextension}
\edef\KOMALongClassFileName{\KOMALongClassFileName}
%</long>
%<*v4>
\edef\KOMAClassName{scr\ClassName4}
\edef\KOMAClassFileName{\KOMAClassName.\@clsextension}
%</v4>
%    \end{macrocode}
% \end{command}
% \end{command}
% \end{command}
% \end{command}
%    \begin{macrocode}
%<!long>\ProvidesClass{\KOMAClassName}[%
%<long>\ProvidesClass{\KOMALongClassName}[%
%!KOMAScriptVersion
  document class (\ClassName)%
]
%<*long>
\let\ClassName\relax
%<letter>\providecommand*{\@ptsize}{12}
\expandafter\let\expandafter\KOMAClassName\expandafter\relax
\expandafter\LoadClassWithOptions\expandafter{\KOMAClassName}
%<letter&!v4>\RequirePackage{scrletter}
%<letter&v4>\RequirePackage{scrletter4}
%</long>
%</class>
%    \end{macrocode}
%
%    \begin{macrocode}
%<*package&letter>
%<!v4>\ProvidesPackage{scrletter}[%
%<v4>\ProvidesPackage{scrletter4}[%
%!KOMAScriptVersion
  letter package extending any KOMA-Script class%
]
%</package&letter>
%    \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: