Debian Codegraph @

texmf-dist/source/latex/koma-script/scrkernel-sections.dtx

raw
1 % \iffalse meta-comment
2 % ======================================================================
3 % scrkernel-sections.dtx
4 % Copyright (c) Markus Kohm, 2002-2025
5 %
6 % This file is part of the LaTeX2e KOMA-Script bundle.
7 %
8 % This work may be distributed and/or modified under the conditions of
9 % the LaTeX Project Public License, version 1.3c of the license.
10 % The latest version of this license is in
11 % http://www.latex-project.org/lppl.txt
12 % and version 1.3c or later is part of all distributions of LaTeX
13 % version 2005/12/01 or later and of this work.
14 %
15 % This work has the LPPL maintenance status "author-maintained".
16 %
17 % The Current Maintainer and author of this work is Markus Kohm.
18 %
19 % This work consists of all files listed in MANIFEST.md.
20 % ======================================================================
21 %%% From File: $Id: scrkernel-sections.dtx 4253 2025-12-31 12:09:32Z kohm $
22 % The runs of run-time file generation:
23 %<preidentify>%%% (run: preidentify)
24 % - everything that is needed before selfidentification of resulting files
25 % (unused)
26 %<identify>%%% (run: identify)
27 % - everything that is needed for selfidentification of resulting files
28 % (unused)
29 %<prepare>%%% (run: prepare)
30 % - everything that is needed to define options
31 %<option>%%% (run: option)
32 % - definition of options
33 %<execoption>%%% (run: execoption)
34 % - initial option executions up to \KOMAProcessOptions
35 %<body>%%% (run: body)
36 % - everything, that should be done after \KOMAProcessOptions
37 %<exit>%%% (run: exit)
38 % - everything, that should be done immediately before leaving the file
39 %<*dtx>
40 \ifx\ProvidesFile\undefined\def\ProvidesFile#1[#2]{}\fi
41 \begingroup
42 \def\filedate$#1: #2-#3-#4 #5${\gdef\filedate{#2/#3/#4}}
43 \filedate$Date: 2025-12-31 13:09:32 +0100 (Mi, 31. Dez 2025) $
44 \def\filerevision$#1: #2 ${\gdef\filerevision{r#2}}
45 \filerevision$Revision: 4253 $
46 \edef\reserved@a{%
47 \noexpand\endgroup
48 \noexpand\ProvidesFile{scrkernel-sections.dtx}%
49 [\filedate\space\filerevision\space
50 KOMA-Script source (disposition)]
51 }%
52 \reserved@a
53 \documentclass[USenglish]{koma-script-source-doc}
54 \usepackage{babel}
55 \setcounter{StandardModuleDepth}{3}
56 \begin{document}
57 \DocInput{scrkernel-sections.dtx}
58 \end{document}
59 %</dtx>
60 % \fi
61 %
62 % \changes{v2.3h}{1996/01/20}{configurable font sized for headings}
63 % \changes{v2.95}{2002/06/26}{first version after splitting \file{scrclass.dtx}}
64 % \changes{v3.15}{2014/12/09}{reordered code in \file{scrkernel-sections.dtx}}
65 % \changes{v3.36}{2022/03/08}{switch over from \cls*{scrdoc} to
66 % \cls*{koma-script-source-doc}}
67 % \changes{v3.36}{2022/03/21}{the whole implementation documentation in English}
68 % \changes{v3.40}{2023/04/17}{guide names changed}
69 %
70 % \GetFileInfo{scrkernel-sections.dtx}
71 % \title{The Code for Parts, Chapters, Sections etc.\@ of
72 % \href{https://komascript.de}{\KOMAScript} Classes}
73 % \author{\href{mailto:[email protected]}{Markus Kohm}}
74 % \date{Revision \fileversion{} of \filedate}
75 % \maketitle
76 % \begin{abstract}
77 % \file{scrkernel-sections.dtx} implements all the options, macros and user
78 % commands used for the sectioning of documents.
79 % \end{abstract}
80 % \tableofcontents
81 %
82 % \section{User Manual}
83 %
84 % You can find the user documentation the commands implemented here in the
85 % \KOMAScript{} manual, either the German \file{scrguide-de.pdf} or the
86 % English \file{scrguide-en.pdf}.
87 %
88 % \MaybeStop{\PrintIndex}
89 %
90 % \section{Implementation of Parts, Chapters, Section etc.}
91 %
92 % The letter class does not provide sectioning.
93 % \begin{macrocode}
94 %<*class&!letter>
95 % \end{macrocode}
96 %
97 % \begin{macro}{@maybeasf}
98 % \changes{v2.8e}{2001/07/10}{removed}
99 % \end{macro}
100 %
101 % \subsection{Interleaf pages}
102 %
103 % With \cls*{scrbook} and \cls*{scrreprt} chapters can optionally (or by
104 % default) start automatically on a odd page. So if the last page before
105 % already was an odd page, we have to insert a so called interleaf page. The
106 % main handling of interleaf pages is already defined in
107 % \file{scrkernel-pagestyles.dtx} (but there is a ToDo note to move is to a
108 % new file). Here we only support the optional selection of the start page of
109 % a chapter.
110 %
111 % \begin{option}{open}
112 % \changes{v2.98c}{2008/03/06}{added}
113 % \changes{v3.12}{2013/03/05}{using \cs{FamilyKeyState}}
114 % \changes{v3.17}{2015/03/09}{using internal value storage}
115 % \changes{v3.18}{2015/05/22}{initialization using \opt{headings}}
116 % \changes{v3.39}{2022/11/11}{initial dot removed from member argument of
117 % option storage commands}
118 % \begin{macro}{\@openrighttrue,\@openrightfalse,\if@openright}
119 % The option supports three values:
120 % \begin{center}
121 % \begin{tabular}{llll}
122 % \opt{open} & \cs{if@openright} & \cs{cleardoublestandardpage} &
123 % meaning\\\hline
124 % \opt{=any} & \cs{iffalse} & \cs{cleardoubleoddstandardpage} &
125 % chapters on any page\\
126 % \opt{=right} & \cs{iftrue} & \cs{cleardoubleoddstandardpage} &
127 % chapters on odd pages\\
128 % \opt{=left} & \cs{iftrue} & \cs{cleardoubleevenstandardpage} &
129 % chapters on even pages\\
130 % \end{tabular}
131 % \end{center}
132 % \begin{macrocode}
133 %<*book|report>
134 %<*prepare>
135 \newif\if@openright
136 %<report>\@openrightfalse
137 %<book>\@openrighttrue
138 %</prepare>
139 %<*option>
140 \KOMA@key{open}{%
141 \KOMA@set@ncmdkey{open}{@tempa}{%
142 {any}{0},%
143 {right}{1},%
144 {left}{2}%
145 }{#1}%
146 \ifx\FamilyKeyState\FamilyKeyStateProcessed
147 \KOMA@kav@xreplacevalue{\KOMAClassFileName}{open}{#1}%
148 \KOMA@kav@remove{\KOMAClassFileName}{headings}{openany}%
149 \KOMA@kav@remove{\KOMAClassFileName}{headings}{openright}%
150 \KOMA@kav@remove{\KOMAClassFileName}{headings}{openleft}%
151 \ifcase \@tempa\relax
152 \KOMA@kav@add{\KOMAClassFileName}{headings}{openany}%
153 \@openrightfalse
154 \renewcommand*{\cleardoublestandardpage}{\cleardoubleoddstandardpage}%
155 \or
156 \KOMA@kav@add{\KOMAClassFileName}{headings}{openright}%
157 \@openrighttrue
158 \renewcommand*{\cleardoublestandardpage}{\cleardoubleoddstandardpage}%
159 \or
160 \KOMA@kav@add{\KOMAClassFileName}{headings}{openleft}%
161 \@openrighttrue
162 \renewcommand*{\cleardoublestandardpage}{\cleardoubleevenstandardpage}%
163 \fi
164 \fi
165 }
166 %</option>
167 %<*execoption>
168 %<book>\KOMAExecuteOptions{headings=openright}
169 %<report>\KOMAExecuteOptions{headings=openany}
170 %</execoption>
171 % \end{macrocode}
172 % \end{macro}^^A \if@openright
173 % \end{option}^^A open
174 %
175 % \begin{option}{openright,openany}
176 % \changes{v2.98c}{2008/03/05}{obsolete}
177 % \changes{v3.01a}{2008/11/21}{standard instead of obsolete}
178 % Two deprecated options of \KOMAScript{} 2.
179 % \begin{macrocode}
180 %<*option>
181 \KOMA@DeclareStandardOption{openright}{open=right}
182 \KOMA@DeclareStandardOption{openany}{open=any}
183 %</option>
184 %</book|report>
185 % \end{macrocode}
186 % \end{option}^^A openright,openany
187 %
188 %
189 % \subsection{Numbers and the auto dot feature}
190 %
191 % Not only parts, chapter, section etc.\@ are numbered. But several other
192 % numbers are related to these numbers. The feature we define here is also
193 % known as the auto dot feature.
194 %
195 % \begin{option}{numbers}
196 % \changes{v2.98c}{2008/03/07}{added}
197 % \changes{v3.12}{2013/03/05}{using \cs{FamilyKeyState}}
198 % \changes{v3.17}{2015/03/09}{using internal value storage}
199 % \changes{v3.39}{2022/11/11}{initial dot removed from member argument of
200 % option storage commands}
201 % \begin{macro}{\scr@dotchangeatdocument}
202 % \changes{v2.98c}{2008/03/07}{added}
203 % The \opt{numbers} option provides several settings for the dot at the end of
204 % such numbers. But because the setting is always document global, this option
205 % cannot be changed inside the document, but in the document preamble only. If
206 % you try to change it inside the document, the error of
207 % \cs{scr@dotchangedatdocument} will be raised. Currently following values to
208 % the option are supported:
209 % \begin{center}
210 % \begin{tabular}{ll}
211 % \opt{numbers} & meaning\\\hline
212 % \opt{=auto} & automatically detect, if the dot has to be added\\
213 % \opt{=enddot} & always use a dot at the end\\
214 % \opt{=noenddot}& don't use a dot at the end\\
215 % \end{tabular}
216 % \end{center}
217 % The criterion for automatically adding a dot is: Does any sectioning number
218 % contain something else but an Arabic number for a number portion?
219 % \begin{macrocode}
220 %<*prepare>
221 \newcommand*{\scr@dotchangeatdocument}[1]{%
222 \ClassError{\KOMAClassName}{%
223 change of end dot feature after \string\begin{document}%
224 }{%
225 You've tried to set `numbers=#1' after \string\begin{document},\MessageBreak
226 but this option is only allowed at the document preamble.\MessageBreak
227 See KOMA-Script manual for more information about.%
228 }%
229 }
230 %</prepare>
231 %<*option>
232 \KOMA@key{numbers}{%
233 \KOMA@set@ncmdkey{numbers}{@tempa}{%
234 {autoendperiod}{0},{autoenddot}{0},{auto}{0},%
235 {endperiod}{1},{withendperiod}{1},{periodatend}{1},%
236 {enddot}{1},{withenddot}{1},{dotatend}{1},%
237 {noendperiod}{2},{noperiodatend}{2},%
238 {noenddot}{2},{nodotatend}{2}%
239 }{#1}%
240 \ifx\FamilyKeyState\FamilyKeyStateProcessed
241 \KOMA@kav@xreplacevalue{\KOMAClassFileName}{numbers}{#1}%
242 \ifcase \@tempa\relax
243 \if@atdocument\scr@dotchangeatdocument{#1}\else
244 \let\scr@altsecnumhook\@empty
245 \fi
246 \or
247 \if@atdocument\scr@dotchangeatdocument{#1}\else
248 \let\scr@altsecnumhook\scr@altsecnumhooktrue
249 \fi
250 \or
251 \if@atdocument\scr@dotchangeatdocument{#1}\else
252 \let\scr@altsecnumhook\scr@altsecnumhookfalse
253 \fi
254 \fi
255 \fi
256 }
257 %</option>
258 %<execoption>\KOMAExecuteOptions{numbers=autoendperiod}
259 % \end{macrocode}
260 % \end{macro}^^A \scr@dotchangeatdocument
261 % \end{option}^^A numbers
262 %
263 % \begin{option}{pointednumbers,pointlessnumbers}
264 % \changes{v2.3h}{1995/01/19}{added}
265 % \changes{v2.4g}{1996/11/04}{option name fixed}
266 % \changes{v2.4g}{1996/11/04}{immediate setting \cs{@altsecnumformatfalse}
267 % to \cs{@altsecnumformattrue}}
268 % \changes{v2.98c}{2008/03/07}{obsolete}
269 % \changes{v3.01a}{2008/11/20}{deprecated}
270 % \changes{v3.99}{2022/11/16}{removed from \KOMAScript~4}
271 % Two deprecated options.
272 % \begin{macrocode}
273 %<*option&!v4>
274 \KOMA@DeclareDeprecatedOption{pointednumbers}{numbers=enddot}
275 \KOMA@DeclareDeprecatedOption{pointlessnumbers}{numbers=noenddot}
276 %</option&!v4>
277 % \end{macrocode}
278 % \end{option}^^A pointednumbers,pointlessnumbers
279 %
280 % \begin{command}{\autodot}
281 % \changes{v2.7}{2001/01/03}{added}
282 % \begin{macro}{\@altsecnumformattrue,\@altsecnumformatfalse,\if@altsecnumformat}
283 % \changes{v2.3c}{1995/08/06}{added}
284 % \begin{macro}{\@autodottrue,\@autodotfalse,\if@autodot}
285 % \changes{v2.8e}{2001/07/10}{added}
286 % \changes{v2.9k}{2003/01/12}{write to \cs{@mainaux}}
287 % \changes{v2.95}{2004/01/15}{write to \cs{@mainaux} just before closing the
288 % file}
289 % \changes{v2.96a}{2006/12/07}{using \cs{immediate}}
290 % \changes{v3.00}{2008/10/07}{global}
291 % \changes{v3.20}{2016/03/25}{using \cs{csname}\dots\cs{endcsname}}
292 % Depending on \cs{if@altsecnumformat} \cs{autodot} shows a dot or nothing.
293 % \begin{description}
294 % \item[ToDo:] Add an optional look forward feature to also not add a dot, if
295 % the next character is a punctuation character, e.g. a dot, semicolon,
296 % comma etc.
297 % \end{description}
298 % \cs{if@autodot} is the current result of the inspection of all sectioning
299 % numbers. If it is \cs{iftrue}, switching on the dot will be written to the
300 % main \file{aux}-file.
301 % \begin{macrocode}
302 %<*prepare>
303 \newif\if@altsecnumformat\@altsecnumformatfalse
304 \newif\if@autodot
305 \renewcommand*{\@autodottrue}{\global\let\if@autodot\iftrue}
306 \renewcommand*{\@autodotfalse}{\global\let\if@autodot\iffalse}
307 \@autodotfalse
308 %</prepare>
309 %<*body>
310 \BeforeClosingMainAux{%
311 \if@autodot\if@filesw\immediate\write\@mainaux{%
312 \string\global\string\csname\space @altsecnumformattrue\string\endcsname}%
313 \fi\fi}
314 %</body>
315 % \end{macrocode}
316 % \end{macro}^^A \if@autodot
317 % \end{macro}^^A \if@altsecnumformat
318 %
319 % \begin{macro}{\scr@altsecnumhook,\scr@altsecnumhooktrue,\scr@altsecnumhookfalse}
320 % \changes{v2.98c}{2008/03/07}{added}
321 % Used by option \opt{numbers} for (de-)activation of the dot in the document
322 % preamble and to overwrite the setting found in the \file{aux}-file.
323 % \begin{description}
324 % \item[Note:] The hook is executed after reading the main \file{aux}-file. So
325 % the overwriting of the setting does work. It is needed as long a boolean
326 % switch is used, because otherwise option \opt{numbers=auto} would not be
327 % able to reset option \opt{numbers=enddot} ot \opt{numbers=noenddot}. With
328 % this code we simply can use an empty \cs{scr@altsecnumhook} for
329 % \opt{numbers=auto} and two compellent definitions for the other cases.
330 % \end{description}
331 % \begin{macrocode}
332 %<*prepare>
333 \newcommand*{\scr@altsecnumhook}{}
334 \AtBeginDocument{\scr@altsecnumhook}
335 \newcommand*{\scr@altsecnumhooktrue}{%
336 \@altsecnumformattrue\global\let\@altsecnumformatfalse\@altsecnumformattrue
337 }
338 \newcommand*{\scr@altsecnumhookfalse}{%
339 \@altsecnumformatfalse\global\let\@altsecnumformattrue\@altsecnumformatfalse
340 }
341 %</prepare>
342 % \end{macrocode}
343 % \end{macro}^^A \scr@altsecnumhook,\scr@altsecnumhooktrue,\scr@altsecnumhookfalse
344 %
345 % \begin{macro}{\@maybeautodot,\@@maybeautodot}
346 % \changes{v2.8e}{2001/07/10}{added}
347 % \changes{v3.00}{2008/10/07}{not any longer needed \cs{aftergroup} removed}
348 % We scan a \cs{the\meta{counter}} command to decide, if the automatic dot has
349 % to be added (later). It sets \cs{@autodottrue}, if there is any kind of
350 % alphabetic or Roman numbering command inside the one time expansion of the
351 % \cs{the\meta{counter}} given as argument.
352 % \begin{description}
353 % \item[Note:] This is a heuristic only. It would, e.g., fail, if you are
354 % using another macro, that expands to the output of the counter, e.g.,
355 %\begin{verbatim}
356 % \def\myalph{\alph}\def\thesection{\myalph{section}}
357 %\end{verbatim}
358 % However, it seems that the heuristic is so good, that in more than twenty
359 % years nobody has complained about.
360 % \end{description}
361 % \begin{macrocode}
362 %<*body>
363 \newcommand{\@maybeautodot}[1]{\if@autodot\else\begingroup%
364 \expandafter\@@maybeautodot #1\@stop\endgroup\fi
365 }
366 \newcommand*{\@@maybeautodot}[1]{%
367 \ifx #1\@stop\let\@@maybeautodot\relax
368 \else
369 \ifx #1\Alph \@autodottrue\fi
370 \ifx #1\alph \@autodottrue\fi
371 \ifx #1\Roman \@autodottrue\fi
372 \ifx #1\roman \@autodottrue\fi
373 \ifx #1\@Alph \@autodottrue\fi
374 \ifx #1\@alph \@autodottrue\fi
375 \ifx #1\@Roman \@autodottrue\fi
376 \ifx #1\@roman \@autodottrue\fi
377 \ifx #1\romannumeral \@autodottrue\fi
378 \fi
379 \@@maybeautodot
380 }
381 %</body>
382 % \end{macrocode}
383 % \end{macro}^^A \@maybeautodot,\@@maybeautodot
384 %
385 % \begin{macrocode}
386 %<*body>
387 \newcommand*\autodot{\if@altsecnumformat.\fi}
388 %</body>
389 % \end{macrocode}
390 % \end{command}^^A \autodot
391 %
392 %
393 % \subsection{Definition and handling of sectioning commands}
394 %
395 % Some of the \LaTeX{} kernel features are used here too. But almost none of
396 % these features is enough to implement all the functionality of \KOMAScript{}
397 % classes. So we redefine several of the \LaTeX{} kernel macros to extend them
398 % and define several new features.
399 % \begin{description}
400 % \item[ToDo:] Don't redefine \LaTeX{} kernel macros, but define new macros
401 % for the interface. Maybe this should also be swapped to a new package used
402 % by the classes.
403 % \end{description}
404 %
405 % \begin{counter}{secnumdepth}
406 % The counter rules down to which section level the headings should be
407 % numbered.
408 % \begin{description}
409 % \item[ToDo:] Move this behind the declaration of the section levels to be
410 % able to use symbolic value \cs{subsectionnumdepth}. It is not related to
411 % the auto dot feature.
412 % \end{description}
413 % \begin{macrocode}
414 %<*body>
415 %<book|report>\setcounter{secnumdepth}{2}
416 %<article>\setcounter{secnumdepth}{3}
417 %</body>
418 % \end{macrocode}
419 % \end{counter}
420 %
421 %
422 % \begin{command}{\ifnumbered,\Ifnumbered}
423 % \changes{v3.12}{2013/12/16}{added}
424 % \changes{v3.28}{2019/11/19}{\cs{ifnumbered} renamed to \cs{Ifnumbered}}
425 % \begin{command}{\ifunnumbered,\Ifunnumbered}
426 % \changes{v3.12}{2013/12/16}{added}
427 % \changes{v3.28}{2019/11/19}{\cs{ifunnumbered} renamed to \cs{Ifunnumbered}}
428 % Commands
429 % \begin{quote}\raggedright
430 % \cs{Ifnumbered}\marg{section level name}\marg{numbered}\marg{not numbered}\\
431 % \cs{Ifunnumbered}\marg{section level name}\marg{not numbered}\marg{numbered}\\
432 % \end{quote}
433 % If \meta{section level name} has to be numbered, execute code \meta{numbered}
434 % otherwise execute code \meta{not numbered}.
435 % \begin{macrocode}
436 %<*body>
437 \providecommand*{\ifnumbered}{%
438 \ClassWarning{\KOMAClassName}{Usage of deprecated command
439 `\string\ifnumbered'.\MessageBreak
440 The command has been renamed because of a\MessageBreak
441 recommendation of The LaTeX Project Team.\MessageBreak
442 Please replace `\string\ifnumbered' by `\string\Ifnumbered'%
443 }%
444 \Ifnumbered
445 }
446 \newcommand*{\Ifnumbered}[1]{%
447 \if@currentusenumber
448 \scr@ifundefinedorrelax{#1numdepth}{%
449 \expandafter\@secondoftwo
450 }{%
451 \expandafter\ifnum \@nameuse{#1numdepth}>\c@secnumdepth
452 \expandafter\expandafter\expandafter\@secondoftwo
453 \else
454 \expandafter\expandafter\expandafter\@firstoftwo
455 \fi
456 }%
457 \else
458 \expandafter\@secondoftwo
459 \fi
460 }
461 \providecommand*{\ifunnumbered}{%
462 \ClassWarning{\KOMAClassName}{Usage of deprecated command
463 `\string\ifunnumbered'.\MessageBreak
464 The command has been renamed because of a\MessageBreak
465 recommendation of The LaTeX Project Team.\MessageBreak
466 Please replace `\string\ifunnumbered' by `\string\Ifunnumbered'%
467 }%
468 \Ifunnumbered
469 }
470 \newcommand*{\Ifunnumbered}[1]{%
471 \Ifnumbered{#1}{\@secondoftwo}{\@firstoftwo}%
472 }
473 %</body>
474 % \end{macrocode}
475 % \end{command}^^A \Ifunnumbered
476 % \end{command}^^A \ifnumbered
477 %
478 %
479 % \begin{macro}{\scr@activate@xsection,\scr@osectarg}
480 % \changes{v3.10}{2011/08/30}{added}
481 % Option \opt{headings=optiontotocandhead}, \opt{headings=optiontotoc} and
482 % \opt{headings=optiontohead} used
483 % \begin{quote}
484 % \cs{scr@activate@xsection}\marg{value}
485 % \end{quote}
486 % with the values 3, 2 and 1 to activate the extended optional argument. This
487 % sets \cs{scr@osectarg} to the corresponding value. The initial value 0
488 % deactivates the extended optional argument.
489 % \begin{description}
490 % \item[ToDo:] Do we really need \cs{scr@activate@xsection}, that is used
491 % inside option \opt{headings} only?
492 % \end{description}
493 % \begin{macrocode}
494 %<*prepare>
495 \newcommand*{\scr@osectarg}{0}
496 \newcommand*{\scr@activate@xsection}[1]{%
497 \renewcommand*{\scr@osectarg}{#1}%
498 }
499 %</prepare>
500 % \end{macrocode}
501 % \end{macro}^^A \scr@activate@xsection,\scr@osectarg
502 %
503 %
504 % \begin{macro}{\@startsection}
505 % \changes{v3.13a}{2014/09/11}{re-definition for extended optional argument}
506 % \changes{v3.49}{2025/09/11}{no longer redefined or used}
507 % \changes{v3.49}{2025/09/11}{warning message added if used}
508 % \changes{v3.50}{2025/12/31}{improved workaround for \pkg{babel} catcode
509 % issues}
510 % We add a warning message to the very beginning of \cs{@startsection}. So
511 % if a package or any other preamble code or the user himself uses
512 % \cs{@startsection} there will be an information about the caveats.
513 % \begin{macrocode}
514 %<*body>
515 \ExplSyntaxOn
516 \msg_new:nnnn { \KOMAClassName } { sectioning-features-not-available }
517 {
518 Usage~of~\token_to_str:N #1 detected.\\
519 Note,~the~sectioning~of~\KOMAClassName\ does~neither~use~nor~
520 support~the~usage~of~\token_to_str:N #1 command.\\
521 This~means,~that~none~of~the~KOMA-Script~features~
522 for~headings~is~available~for~the~heading~\msg_line_context:.\\
523 If~you~need~additional~sectioning~commands,~
524 you~should~define~them~using~\token_to_str:N \DeclareNewSectionCommand\
525 instead.
526 }
527 { See~the~KOMA-Script~user~manual~for~more~information. }
528 \cctab_new:c { c_ \KOMAClassName _cmdhook_cctab }
529 \cctab_gsave_current:c { c_ \KOMAClassName _cmdhook_cctab }
530 \hook_gput_code:nnn { begindocument / end } { . }
531 {
532 \cctab_begin:c { c_ \KOMAClassName _cmdhook_cctab }
533 \exp_args:Nne
534 \hook_gput_code:nnn { cmd / @startsection / before } { \KOMAClassName }
535 {
536 \msg_warning:nnn { \KOMAClassName }
537 { sectioning-features-not-available }
538 { \@startsection }
539 }
540 \cctab_end:
541 }
542 \hook_gset_rule:nnnn { begindocument / end } { . } < { babel }
543 \ExplSyntaxOff
544 %</body>
545 % \end{macrocode}
546 % \end{macro}
547 %
548 % \begin{macro}{\scr@saved@startsection}
549 % \changes{v3.13a}{2014/09/11}{added}
550 % \changes{v3.20}{2016/04/12}{supporting \pkg{amsgen}}
551 % \changes{v3.49}{2025/09/11}{removed}
552 % \end{macro}
553 %
554 % \begin{macro}{\@sect}
555 % \changes{v3.49}{2025/09/11}{\cs{@sect} replaced by \cs{scr@sect}}
556 % \end{macro}^^A \@sect
557 % \begin{macro}{\scr@latex@sect}
558 % \changes{v3.27}{2019/07/24}{added to be used by \pkg*{scrhack}}
559 % \changes{v3.49}{2025/09/11}{removed}
560 % \end{macro}^^A \@scr@latex@sect
561 %
562 % \begin{macro}{\@ssect}
563 % \changes{v3.49}{2025/09/11}{\cs{@ssect} replaced by \cs{scr@ssect}}
564 % \end{macro}
565 % \begin{macro}{\scr@latex@ssect}
566 % \changes{v3.27}{2019/07/24}{added to be used by \pkg*{scrhack})}
567 % \changes{v3.30}{2020/02/25}{orphan space removed}
568 % \changes{v3.49}{2025/09/11}{removed}
569 % \end{macro}
570 %
571 % \begin{macro}{\@xsect}
572 % \changes{v3.49}{2025/09/11}{\cs{@xsect} replaced by \cs{scr@xsect}}
573 % \end{macro}
574 % \begin{macro}{\scr@latex@xsect}
575 % \changes{v3.27}{2019/07/24}{added to be used by \pkg*{scrhack}}
576 % \changes{v3.49}{2025/09/11}{removed}
577 % \end{macro}
578 %
579 % \begin{macro}{\scr@startsection}
580 % \changes{v3.13a}{2014/09/11}{added}
581 % \changes{v3.18}{2015/05/22}{using \cs{numexpr} for argument 2}
582 % \changes{v3.18}{2015/05/22}{using \cs{glueexpr} for arguments 3--5}
583 % \changes{v3.20}{2016/04/12}{\cs{@ifstar} replaced by \cs{kernel@ifstar}}
584 % \changes{v3.26}{2018/09/18}{supporting \opt{afterindent}}
585 % \begin{macro}{\startsection@sectionname,\startsection@secnumdepth,
586 % \startsection@indent,\startsection@beforeskip,
587 % \startsection@afterskip,\startsection@afterindent,
588 % \@startsection@runintrue,\@startsection@runinfalse,
589 % \if@startsection@runin}
590 % \changes{v3.26}{2018/05/14}{added}
591 % The \cs{@startsection} of the \LaTeX{} kernel does not provide all the
592 % features we need for \KOMAScript. And the generic hooks of \LaTeX{} do not
593 % allow to change it wide enough. So we either have to use \pkg{xparse} to
594 % patch it very much or we have to define our own version. In this case
595 % patching is too fragile, so we define and use \cs{scr@startsection}.
596 % \begin{description}
597 % \item[Note:] Package \pkg{amsgen} redefines \cs{@ifstar}. The new version
598 % does not ignore white spaces. So testing the original definition using
599 % \cs{@ifstar} may fail. It is better to use \cs{kernel@ifstar}.
600 % \item[ToDo:] All the testing here doesn't make much sense, because we are
601 % inside a class and packages like \pkg{amsgen} should not yet have been
602 % loaded. So the test only needs to test, if the \LaTeX{} kernel has been
603 % changed.
604 % \item[ToDo:] Because we now use our own command, we do not need to use
605 % argument \#2-\#6. Instead of these we can just use the properties
606 % depending on argument \#1 and the style of the sectioning
607 % command. Changing this would simplify the code a lot! So this should be
608 % the next step in development of the sectioning commands.
609 % \item[Note:] In our own \cs{scr@startsection} the macros
610 % \cs{startsection@sectionname}, \cs{startsection@secnumdepth},
611 % \cs{startsection@indent}, \cs{startsection@beforeskip},
612 % \cs{startsection@afterskip}, \cs{if@afterindent},
613 % \cs{if@startsection@runin}, and \cs{startsection@afterindent} are valid
614 % from executing the do hook \dhook{heading/postinit}. So they can be used
615 % inside all the hooks.
616 % \item[Note:] \cs{startsection@indent}, \cs{startsection@beforeskip},
617 % \cs{startsection@afterskip} and \cs{startsection@afterindent} are either
618 % skips or \cs{glueexpr}, that can be used like skips.
619 % \item[Note:] \cs{startsection@beforeskip} and \cs{startsection@afterskip}
620 % are effective values already. Not special treatment for negative or
621 % positive values must be done.
622 % \item[Note:] \cs{if@startsection@runin}
623 % are either \cs{iftrue} or \cs{iffalse}.
624 % \item[Note:] \cs{if@startsection@indentafter} does not exist and is not
625 % needed, because \cs{if@afterindent} is already valid and also either
626 % \cs{iftrue} or \cs{iffalse}.
627 % \item[Note:] Using one of the \cs{startsection@\dots}
628 % resp. \cs{if@startsection@\dots} macros outside \cs{scr@startsection} is
629 % not allowed and the result is unspecified. Inside \cs{scr@startsection}
630 % they have to be interpreted as constants, so changing them is not allowed!
631 % \end{description}
632 % \begin{macrocode}
633 %<*body>
634 \newcommand*{\scr@startsection}[6]{%
635 \ExecuteDoHook{heading/preinit/#1}%
636 \if@noskipsec \leavevmode \fi
637 \par
638 \@tempskipa \glueexpr #4\relax
639 \@ifundefined{scr@#1@afterindent}{%
640 \def\startsection@afterindent##1##2##3{##3}%
641 }{%
642 \expandafter\let\expandafter\startsection@afterindent
643 \csname scr@#1@afterindent\endcsname
644 }%
645 \startsection@afterindent{\@afterindenttrue}{\@afterindentfalse}{%
646 \@afterindenttrue
647 \ifdim \@tempskipa <\z@
648 \@tempskipa -\@tempskipa \@afterindentfalse
649 \fi
650 }%
651 \def\startsection@sectionname{#1}%
652 \def\startsection@secnumdepth{\numexpr #2\relax}%
653 \def\startsection@indent{\glueexpr #3\relax}%
654 \let\startsection@beforeskip\@tempskipa
655 \@ifundefined{scr@#1@runin}{%
656 \def\scr@sect@runin##1##2##3{##3}%
657 }{%
658 \expandafter\let\expandafter\scr@sect@runin
659 \csname scr@#1@runin\endcsname
660 }%
661 \scr@sect@runin{%
662 \def\startsection@afterskip{\glueexpr #3\relax}%
663 \expandafter\let\csname if@startsection@runin\expandafter\endcsname
664 \csname iftrue\endcsname
665 }{%
666 \def\startsection@afterskip{\glueexpr #3\relax}%
667 \expandafter\let\csname if@startsection@runin\expandafter\endcsname
668 \csname iffalse\endcsname
669 }{%
670 \ifdim \glueexpr #5\relax <\z@
671 \def\startsection@afterskip{\glueexpr (#3)*\m@ne\relax}%
672 \expandafter\let\csname if@startsection@runin\expandafter\endcsname
673 \csname iftrue\endcsname
674 \else
675 \def\startsection@afterskip{\glueexpr #3\relax}%
676 \expandafter\let\csname if@startsection@runin\expandafter\endcsname
677 \csname iffalse\endcsname
678 \fi
679 }%
680 \ExecuteDoHook{heading/postinit/#1}%
681 \if@nobreak
682 \everypar{}%
683 \else
684 \addpenalty\@secpenalty\addvspace\@tempskipa
685 \fi
686 \kernel@ifstar {%
687 \ExecuteDoHook{heading/branch/star/#1}%
688 \def\scr@s@ct@@nn@m@{#1}%
689 \scr@ssect{\glueexpr #3\relax}{\glueexpr #4\relax}{\glueexpr #5\relax}{#6}%
690 }{%
691 \ExecuteDoHook{heading/branch/nostar/#1}%
692 \scr@section@dblarg{%
693 \scr@sect{#1}{\numexpr #2\relax}{\glueexpr #3\relax}{\glueexpr #4\relax}%
694 {\glueexpr #5\relax}{#6}%
695 }%
696 }%
697 }
698 % \end{macrocode}
699 % \begin{macro}{\scr@sect@runin}
700 % \changes{v3.26}{2018/09/18}{added}
701 % Depending on sectioning feature \opt{runin} the macro expands to the first
702 % argument, if a in-text heading aka run-in heading has to used, the second
703 % argument, if a free-standing heading has to be used, or the third argument,
704 % of run-in or free-standing depends on the sign of \opt{afterskip}. The
705 % initial definition is depending on the sign of \opt{afterskip}. This initial
706 % definition is also done inside \cs{@xsect}. \cs{scr@startsection} also
707 % redefines \cs{scr@sect@runin}. So it should always be the currently valid
708 % definition, even if \cs{scr@startsection} is used with a section command,
709 % that does not provide all the variable of \KOMAScript.
710 % \begin{macrocode}
711 \newcommand*{\scr@sect@runin}[3]{#3}
712 % \end{macrocode}
713 % \end{macro}^^A \scr@sect@runin
714 % \begin{macro}{\scr@startsection@ulm@error}
715 % \changes{v3.26}{2018/05/14}{added}
716 % This is the initial error message for using one of the internal macros
717 % before \cs{scr@startsection}. This should never happen.
718 % \begin{macrocode}
719 \newcommand*{\scr@startsection@ulm@error}[1]{%
720 \ClassError{\KOMAClassName}{%
721 \string#1 undefined outside of \string\scr@startsection
722 }{%
723 A KOMA-Script macro for package authors have been used outside
724 the\MessageBreak
725 specified definition scope.\MessageBreak
726 See `scrkernel-sections.dtx' for more information.%
727 }%
728 }
729 \newcommand*\startsection@sectionname{%
730 \scr@startsection@ulm@error\startsection@sectionname}
731 \newcommand*\startsection@secnumdepth{%
732 \scr@startsection@ulm@error\startsection@secnumdepth}
733 \newcommand*\startsection@indent{%
734 \scr@startsection@ulm@error\startsection@indent}
735 \newcommand*\startsection@beforeskip{%
736 \scr@startsection@ulm@error\startsection@beforeskip}
737 \newcommand*\startsection@afterskip{%
738 \scr@startsection@ulm@error\startsection@afterskip}
739 \newcommand*{\if@startsection@runin}{%
740 \scr@startsection@ulm@error\if@startsection@runin}
741 \newif\if@startsection@runin
742 \newcommand*\startsection@afterindent{%
743 \scr@startsection@ulm@error\startsection@afterindent}
744 % \end{macrocode}
745 % \end{macro}^^A \scr@startsection@ulm@error
746 % \end{macro}^^A \startsection@sectionname … \scr@startsection@runin
747 % \begin{macro}{\At@startsection}
748 % \changes{v3.14}{2014/09/11}{added}
749 % \changes{v3.27}{2019/02/04}{using \cs{AddtoDoHook}}
750 % \changes{v3.27}{2019/02/04}{deprecated}
751 % This is deprecated now. You should use the corresponding
752 % \dhook{heading/postinit} do hook. However the do hooks are command specific,
753 % but the argument of \cs{At@startsection} is style specific.
754 % \begin{macrocode}
755 \newcommand*{\At@startsection}[1]{%
756 \ClassInfo{\KOMAClassName}{%
757 Usage of deprecated command `\string\At@startsection'
758 mapped to\MessageBreak
759 `\string\AddtoDoHook{heading/postinit}
760 {...\string\@gobble}'%
761 }%
762 \AddtoDoHook{heading/postinit}{\scr@doonlyifstyleofargis{#1}{section}}%
763 }
764 % \end{macrocode}
765 % \begin{macro}{\scr@doonlyifstyleofargis}
766 % \changes{v3.27}{2019/02/04}{added}
767 % Execute the first argument only, of the style of the third argument is the
768 % second argument.
769 % \begin{macrocode}
770 \newcommand*{\scr@doonlyifstyleofargis}[3]{%
771 \IfSectionCommandStyleIs{#3}{#2}{#1}{}%
772 }
773 % \end{macrocode}
774 % \end{macro}^^A \scr@doonlyifstyleofargis
775 % \end{macro}^^A \At@startsection
776 % \begin{macro}{\Before@ssect}
777 % \changes{v3.14}{2014/09/11}{added}
778 % \changes{v3.27}{2019/02/04}{using \cs{AddtoDoHook}}
779 % \changes{v3.27}{2019/02/04}{deprecated}
780 % \changes{v3.35}{2021/10/15}{\cs{ClassWarning} instead of \cs{ClassInfo}}
781 % \changes{v3.35}{2021/10/15}{Usage of \cs{scr@doonlyifstyleofargis} fixed}
782 % This is deprecated now. You should use the corresponding
783 % \dhook{heading/branch/star} do hook. However the do hooks are command
784 % specific, but the argument of \cs{Before@ssect} is style specific.
785 % \begin{macrocode}
786 \newcommand*{\Before@ssect}[1]{%
787 \ClassWarning{\KOMAClassName}{%
788 Usage of deprecated command `\string\Before@ssect'
789 mapped to\MessageBreak
790 `\string\AddtoDoHook{heading/branch/star}%
791 {...\string\@gobble}'%
792 }%
793 \AddtoDoHook{heading/branch/star}{\scr@doonlyifstyleofargis{#1}{section}}%
794 }
795 % \end{macrocode}
796 % \end{macro}^^A \Before@ssect
797 % \begin{macro}{\Before@sect}
798 % \changes{v3.14}{2014/09/11}{added}
799 % \changes{v3.27}{2019/02/04}{using \cs{AddtoDoHook}}
800 % \changes{v3.27}{2019/02/04}{deprecated}
801 % \changes{v3.35}{2021/10/15}{\cs{ClassWarning} instead of \cs{ClassInfo}}
802 % \changes{v3.35}{2021/10/15}{Usage of \cs{scr@doonlyifstyleofargis} fixed}
803 % This is deprecated now. You should use the corresponding
804 % \dhook{heading/branch/nostar} do hook. However the do hooks are command
805 % specific, but the argument of \cs{Before@sect} is style specific.
806 % \begin{macrocode}
807 \newcommand*{\Before@sect}[1]{%
808 \ClassWarning{\KOMAClassName}{%
809 Usage of deprecated command `\string\Before@sect'
810 mapped to\MessageBreak
811 `\string\AddtoDoHook{heading/branch/nostar}%
812 {...\string\@gobble}'%
813 }%
814 \AddtoDoHook{heading/branch/nostar}{\scr@doonlyifstyleofargis{#1}{section}}%
815 }
816 % \end{macrocode}
817 % \end{macro}^^A \Before@sect
818 % \begin{macro}{\scr@section@dblarg,\scr@section@xdblarg}
819 % \changes{v3.13a}{2014/09/11}{added}
820 % Similar to the \LaTeX{} kernel macros \cs{@dblarg} and \cs{@xdblarg} but
821 % preserve the definition of \cs{scr@osectarg}. So changes of
822 % \cs{scr@osectarg} inside the definition of the command of the first
823 % argument, are locally to the execution of that command.
824 % \begin{macrocode}
825 \newcommand{\scr@section@dblarg}[1]{%
826 \kernel@ifnextchar[%]
827 {#1}%
828 {\scr@section@xdblarg{#1}}%
829 }
830 \newcommand{\scr@section@xdblarg}[2]{%
831 \begingroup
832 \edef\reserved@a{%
833 \unexpanded{\endgroup\let\scr@osectarg\z@#1[{#2}]{#2}\def\scr@osectarg}%
834 {\scr@osectarg}}%
835 \reserved@a
836 }
837 %</body>
838 % \end{macrocode}
839 % \end{macro}^^A \scr@section@dblarg,\scr@section@xdblarg
840 % \end{macro}^^A \scr@startsection
841 %
842 % \begin{command}{\UseNumberUsageError}
843 % \changes{v3.27}{2019/02/02}{added}
844 % \begin{command}{\IfUseNumber}
845 % \changes{v3.27}{2019/02/02}{error if used outside sectioning command}
846 % Command \cs{IfUseNumner} is defined only inside sectioning commands. Using
847 % it outside is not specified. To report an error in this case, it should be
848 % set to \cs{UseNumberUsageError} outside a sectioning command.
849 % \begin{macrocode}
850 %<*body>
851 \newcommand*{\UseNumberUsageError}[2]{%
852 \ClassError{\KOMAClassName}{%
853 \string\IfUseNumber\space not allowed%
854 }{%
855 You cannot use \string\IfUseNumber\space outside a heading.\MessageBreak
856 If you'd continue, I'll ignore both arguments, because I do not
857 know\MessageBreak
858 whether to use the first or the second argument.%
859 }%
860 }
861 \newcommand*{\IfUseNumber}[2]{}%
862 \let\IfUseNumber\UseNumberUsageError
863 %</body>
864 % \end{macrocode}
865 % \end{command}^^A \IfUseNumnr
866 % \end{command}^^A \UseNumberUsageError
867 %
868 %
869 % \begin{command}{\SecDef}
870 % \changes{v3.13a}{2014/09/11}{added}
871 % \changes{v3.20}{2016/04/12}{\cs{@ifstar} replaced by \cs{kernel@ifstar}}
872 % \begin{command}{\secdef}
873 % \changes{v3.13a}{2014/09/11}{re-definition because of extended optional argument}
874 % \begin{macrocode}
875 %<*body>
876 \newcommand*{\SecDef}[2]{\kernel@ifstar{#2}{\scr@section@dblarg{#1}}}
877 \CheckCommand*{\secdef}[2]{\@ifstar{#2}{\@dblarg{#1}}}
878 \let\secdef\SecDef
879 %</body>
880 % \end{macrocode}
881 % \end{command}^^A \secdef
882 % \end{command}^^A \SecDef
883 %
884 % \begin{macro}{\scr@sect}
885 % \changes{v3.10}{2011/08/30}{re-definition because of extended optional argument}
886 % \changes{v3.10}{2011/08/30}{using
887 % \cs{csname}\texttt{add\#1tocentry}\cs{endcsname}
888 % resp. \cs{addtocentrydefault}}
889 % \changes{v3.18}{2015/05/20}{defines \cs{IfUsePrefixLine} locally}
890 % \changes{v3.18}{2015/05/22}{using \cs{numexpr} for argument 2}
891 % \changes{v3.18}{2015/05/22}{using \cs{gluexpr} for arguments 3--5}
892 % \changes{v3.19}{2015/07/17}{using \cs{sectionlinesformat} and
893 % \cs{sectioncatchphraseformat}}
894 % \changes{v3.27}{2019/07/08}{new optional \opt{nonumber}}
895 % \changes{v3.30}{2020/02/25}{orphan spaces removed}
896 % \changes{v3.49}{2025/09/11}{\cs{@sect} replaced by \cs{scr@sect}}
897 % Because we want to support the extended optional argument for all commands
898 % defined using \cs{@startsection} we also have to redefine \cs{@sect}. Once
899 % again several security tests are done, before redefining an internal
900 % \LaTeX{} kernel macro.
901 % \begin{description}
902 % \item[ToDo:] It would be better not to redefine an internal \LaTeX{} kernel
903 % macro, but use a own definition in our own \cs{scr@startsection}. But in
904 % this case packages, that use \cs{@sect} would not automatically support
905 % several \KOMAScript{} features.
906 % \item[Note:] \cs{chapter} and \cs{part} do not use \cs{@sect} but
907 % \cs{SecDef}.
908 % \end{description}
909 % \begin{macrocode}
910 %<*body>
911 \def\scr@sect#1#2#3#4#5#6[#7]#8{%
912 \ifnum \scr@osectarg=\z@
913 \@scr@tempswafalse
914 \else
915 \scr@istest#7=\@nil
916 \fi
917 \@currentusenumbertrue
918 \if@scr@tempswa
919 \setkeys{KOMAarg.section}{tocentry={#8},head={#8},reference={#8},#7}%
920 \else
921 \ifcase \scr@osectarg\relax
922 \setkeys{KOMAarg.section}{tocentry={#7},head={#7},reference={#7}}%
923 \or
924 \setkeys{KOMAarg.section}{tocentry={#8},head={#7},reference={#8}}%
925 \or
926 \setkeys{KOMAarg.section}{tocentry={#7},head={#8},reference={#7}}%
927 \or
928 \setkeys{KOMAarg.section}{tocentry={#7},head={#7},reference={#7}}%
929 \fi
930 \fi
931 % \end{macrocode}
932 % \changes{v3.23}{2017/02/04}{support for \pkg{minitoc}}
933 % \changes{v3.23}{2017/03/24}{usage of \cs{ext@figure} and \cs{ext@table}
934 % instead of \texttt{lof} and \texttt{lot}}
935 % Add the \texttt{xsect} entries to \texttt{lof} and \texttt{lot}. Note, that
936 % the original \cs{starsection} tests of \pkg{minitoc} has a bug and so
937 % does not work. And the original code of \pkg{minitoc} has hard coded
938 % \texttt{lot} and \texttt{lof} instead of \cs{ext@figure} and
939 % \cs{ext@table}. This is a fixed one:
940 % \begin{macrocode}
941 \scr@ifundefinedorrelax{scr@mt@saved@sect}{}{%
942 \expandafter\ifx\csname #1\endcsname\section
943 \addcontentsline{\ext@figure}{xsect}{\@currenttocentry}%
944 \addcontentsline{\ext@table}{xsect}{\@currenttocentry}%
945 \fi
946 \expandafter\ifx\csname #1\endcsname\starsection\relax
947 \addcontentsline{\ext@figure}{xsect}{\@currenttocentry}%
948 \addcontentsline{\ext@table}{xsect}{\@currenttocentry}%
949 \fi
950 }%
951 \let\IfUsePrefixLine\@secondoftwo
952 \ifcase
953 \if@currentusenumber
954 \ifnum \numexpr #2\relax>\c@secnumdepth \z@\else \@ne\fi
955 \else
956 \z@
957 \fi
958 \let\@svsec\@empty
959 % \end{macrocode}
960 % \changes{v3.31}{2020/06/02}{execute counter reset list}
961 % Even for not numbered sections, the reset list für the section counter has
962 % to be executed.
963 % \begin{macrocode}
964 %<!v4> \expandafter\ifnum\scr@v@is@ge{3.31}\relax
965 \begingroup
966 \let\@elt\@stpelt
967 \csname cl@#1\endcsname
968 \endgroup
969 %<!v4> \fi
970 % \end{macrocode}
971 % \changes{v3.31}{2020/06/02}{\cs{hy@insteadofrefstepcounter} added}
972 % At this point we have to make sure, that the \pkg{hyperref} code for not
973 % increasing a counter is executed.
974 % \begin{macrocode}
975 \hy@insteadofrefstepcounter{#1}%
976 \else
977 \refstepcounter{#1}%
978 \expandafter\@maybeautodot\csname the#1\endcsname
979 \protected@edef\@svsec{\@seccntformat{#1}\relax}%
980 \fi
981 % \end{macrocode}
982 % \changes{v3.26}{2018/09/18}{support for \cs{scr@sect@runin}}
983 % \changes{v3.27}{2019/02/02}{\cs{IfUseNumber} defined locally}
984 % \begin{macrocode}
985 \ifdim
986 \scr@sect@runin{\z@}{\p@}{\glueexpr #5\relax}>\z@
987 \begingroup
988 \ifx\@svsec\@empty
989 \let\IfUseNumber\@secondoftwo
990 \else
991 \let\IfUseNumber\@firstoftwo
992 \fi
993 % \end{macrocode}
994 % \changes{v3.21}{2016/06/12}{missing \cs{nobreak} added}
995 % \changes{v3.27}{2019/02/02}{\cs{scr@do@at} added}
996 % \begin{macrocode}
997 \ExecuteDoHook{heading/begingroup/#1}%
998 #6{\nobreak\interlinepenalty \@M
999 \sectionlinesformat{#1}{\glueexpr #3\relax}\@svsec{#8}\@@par}%
1000 \ExecuteDoHook{heading/endgroup/#1}%
1001 \endgroup
1002 %<*trace>
1003 \ClassInfo{\KOMAClassName}{%
1004 head=`\detokenize\expandafter{\@currentheadentry}'\MessageBreak
1005 tocentry=`\detokenize\expandafter{\@currenttocentry}'\MessageBreak
1006 reference=`\detokenize\expandafter{\@currentlabelname}'}%
1007 %</trace>
1008 \expandafter\csname #1mark\expandafter\endcsname\expandafter{\@currentheadentry}%
1009 \ifx\@currenttocentry\@empty\else
1010 \scr@ifundefinedorrelax{add#1tocentry}{%
1011 \expandafter\gdef\csname add#1tocentry\endcsname##1##2{%
1012 \addtocentrydefault{#1}{##1}{##2}%
1013 }%
1014 }{}%
1015 \ifcase
1016 \if@currentusenumber
1017 \ifnum \numexpr #2\relax>\c@secnumdepth \z@\else \@ne\fi
1018 \else
1019 \z@
1020 \fi
1021 \csname add#1tocentry\endcsname{}{\@currenttocentry}%
1022 \else
1023 % \end{macrocode}
1024 % \changes{v3.31}{2020/06/06}{using \cs{\dots tocformat}}%
1025 % \begin{description}
1026 % \item[ToDo:] Move \cs{autodot} to the definition of \cs{\dots tocformat}.
1027 % \end{description}
1028 % \begin{macrocode}
1029 \@ifundefined{#1tocformat}{%
1030 \expandafter\gdef\csname #1tocformat\endcsname
1031 {\csname the#1\endcsname}%
1032 }{}%
1033 \csname add#1tocentry\endcsname{\csname #1tocformat\endcsname}{%
1034 \@currenttocentry}%
1035 \fi
1036 \fi
1037 \else
1038 % \end{macrocode}
1039 % \changes{v3.21}{2016/06/12}{missing \cs{nobreak} added}
1040 % \changes{v3.27}{2019/02/02}{\cs{ExecuteDoHook} added}
1041 % \begin{macrocode}
1042 \def\@svsechd{%
1043 \ifx\@svsec\@empty
1044 \let\IfUseNumber\@secondoftwo
1045 \else
1046 \let\IfUseNumber\@firstoftwo
1047 \fi
1048 \ExecuteDoHook{heading/begingroup/#1}%
1049 #6{\nobreak\sectioncatchphraseformat{#1}{\glueexpr #3\relax}\@svsec{#8}}%
1050 %<*trace>
1051 \ClassInfo{\KOMAClassName}{%
1052 head=`\detokenize\expandafter{\@currentheadentry}'\MessageBreak
1053 tocentry=`\detokenize\expandafter{\@currenttocentry}'\MessageBreak
1054 reference=`\detokenize\expandafter{\@currentlabelname}'}%
1055 %</trace>
1056 \expandafter\csname #1mark\expandafter\endcsname
1057 \expandafter{\@currentheadentry}%
1058 \ifx\@currenttocentry\@empty\else
1059 \scr@ifundefinedorrelax{add#1tocentry}{%
1060 \expandafter\gdef\csname add#1tocentry\endcsname####1####2{%
1061 \addtocentrydefault{#1}{####1}{####2}%
1062 }%
1063 }{}%
1064 \ifcase
1065 \if@currentusenumber
1066 \ifnum \numexpr #2\relax>\c@secnumdepth \z@\else \@ne\fi
1067 \else
1068 \z@
1069 \fi
1070 \csname add#1tocentry\endcsname{}{\@currenttocentry}%
1071 \else
1072 % \end{macrocode}
1073 % \changes{v3.31}{2020/06/06}{using \cs{\dots tocformat}}%
1074 % \begin{description}
1075 % \item[ToDo:] Move \cs{autodot} to the definition of \cs{\dots tocformat}.
1076 % \end{description}
1077 % \begin{macrocode}
1078 \@ifundefined{#1tocformat}{%
1079 \expandafter\gdef\csname #1tocformat\endcsname
1080 {\csname the#1\endcsname}%
1081 }{}%
1082 \csname add#1tocentry\endcsname{\csname #1tocformat\endcsname}{%
1083 \@currenttocentry}%
1084 \fi
1085 \fi
1086 \ExecuteDoHook{heading/endgroup/#1}%
1087 }%
1088 \fi
1089 \let\IfUsePrefixLine\scr@IfUsePrefixLineWarning
1090 \scr@xsect{\glueexpr #5\relax}%
1091 }
1092 % \end{macrocode}
1093 % \begin{macro}{\scr@ds@tocentry,\@currenttocentry}
1094 % \changes{v3.10}{2011/08/30}{added}
1095 % \changes{v3.22}{2016/07/12}{\cs{scr@ds@tocentry} renamed to \cs{@currenttocentry}}
1096 % \begin{macro}{\scr@ds@head,\@currentheadentry}
1097 % \changes{v3.10}{2011/08/30}{added}
1098 % \changes{v3.22}{2016/07/12}{\cs{scr@ds@head} renamed to \cs{@currentheadentry}}
1099 % \begin{macro}{\@currentlabelname}
1100 % \changes{v3.22}{2016/07/12}{added}
1101 % \begin{macro}{\@scr@tempswatrue,\@scr@tempswafalse,\if@scr@tempswa}
1102 % \changes{v3.10}{2011/08/30}{added}
1103 % \begin{macro}{\@currentusenumbertrue,\@currentusenumberfalse,\if@currentusenumber}
1104 % \changes{v3.27}{2019/07/08}{added}
1105 % \begin{macro}{\scr@istest}
1106 % \changes{v3.10}{2011/08/30}{added}
1107 % We are using several \pkg*{scrbase} options to handle the extended
1108 % optional argument features.
1109 % \begin{description}
1110 % \item[ToDo:] Is there a general initialization hook to make additional such
1111 % options at package author level possible?
1112 % \end{description}
1113 % \begin{macrocode}
1114 \DefineFamily{KOMAarg}
1115 \DefineFamilyMember[.section]{KOMAarg}
1116 \providecommand*\@currenttocentry{}
1117 \providecommand*\@currentheadentry{}
1118 \providecommand*\@currentlabelname{}
1119 \FamilyStringKey[.section]{KOMAarg}{tocentry}{\@currenttocentry}
1120 \FamilyStringKey[.section]{KOMAarg}{head}{\@currentheadentry}
1121 \NewHook{\KOMAClassName/option/section/reference/fallback}%
1122 \DefineFamilyKey[.section]{KOMAarg}{reference}{%
1123 \scr@ifundefinedorrelax{NR@gettitle}{%
1124 \scr@ifundefinedorrelax{GetTitleString}{%
1125 % \end{macrocode}
1126 % \changes{v3.41}{2023/06/29}{substitute definition of \cs{@currentlabelname}
1127 % changed}
1128 % \changes{v3.46}{2025/06/10}{substitute definition of \cs{@currentlabelname}
1129 % changed}
1130 % \changes{v3.46}{2025/06/10}{allow star and optional argument for \cs{label},
1131 % \cs{index}, \cs{glossary} and \cs{zlabel} when disabling}
1132 % This case is complicated. Up to \LaTeX{} 2022/11/01 it was good enough to
1133 % use:
1134 % \begin{verbatim}
1135 % \def\@currentlabelname{#1}
1136 % \end{verbatim}
1137 % But from \LaTeX{} 2023/06/01 the kernel definition of \cs{label}
1138 % additionally writes \cs{@currentlabelname} to the \file{aux}-file. So this
1139 % breaks, if \cs{label} is part of the argument, because it results in an
1140 % infinite expansion loop. To avoid this, the code has been changed. To
1141 % remove \cs{label}, \cs{index}, \cs{glossary}.
1142 % \begin{description}
1143 % \item[ToDo:] The current \cs{@currentlabelname} code is only a workaround
1144 % for \href{https://sourceforge.net/p/koma-script/tickets/55/}{issue 55}.
1145 % Maybe using an empty value would be better. But in this case, what to do
1146 % with \cs{TG@gettitle} and \cs{ztitlerefsetup}?
1147 % \end{description}
1148 % \begin{macrocode}
1149 \begingroup
1150 \DeclareExpandableDocumentCommand{\label}{som}{}%
1151 \DeclareExpandableDocumentCommand{\index}{som}{}%
1152 \DeclareExpandableDocumentCommand{\glossary}{som}{}%
1153 \DeclareExpandableDocumentCommand{\zlabel}{som}{}%
1154 \scr@ifundefinedorrelax{UseHook}{}{%
1155 \UseHook{\KOMAClassName/option/section/reference/fallback}%
1156 }%
1157 \let\protect\noexpand
1158 \edef\@currentlabelname{\expandafter\detokenize{#1}}%
1159 \expandafter\expandafter\expandafter\endgroup
1160 \expandafter\def\expandafter\@currentlabelname\expandafter{%
1161 \@currentlabelname}%
1162 }{%
1163 \GetTitleString{#1}%
1164 \let\@currentlabelname\GetTitleStringResult
1165 }%
1166 }{%
1167 \NR@gettitle{#1}%
1168 }%
1169 \scr@ifundefinedorrelax{TR@gettitle}{}{%
1170 \expandafter\TR@gettitle\expandafter{\@currentlabelname}%
1171 }%
1172 \scr@ifundefinedorrelax{ztitlerefsetup}{}{%
1173 \ztitlerefsetup{title=\@currentlabelname}%
1174 }%
1175 \FamilyKeyStateProcessed
1176 }
1177 \FamilyInverseBoolKey[.section]{KOMAarg}{nonumber}{@currentusenumber}
1178 \newcommand*{\scr@istest}{}
1179 \def\scr@istest#1=#2\@nil{%
1180 \ifx\relax#2\relax\@scr@tempswafalse\else\@scr@tempswatrue\fi
1181 }
1182 \newif\if@scr@tempswa
1183 % \end{macrocode}
1184 % \end{macro}^^A \scr@istest
1185 % \end{macro}^^A \if@currentusenumber
1186 % \end{macro}^^A \if@scr@tempswa
1187 % \end{macro}^^A \@currentlabelname
1188 % \end{macro}^^A \scr@ds@head,\@currentheadentry
1189 % \end{macro}^^A \scr@ds@tocentry,\@currenttocentry
1190 %
1191 % \begin{command}{\sectionlinesformat,\sectioncatchphraseformat}
1192 % \changes{v3.19}{2015/07/17}{added}
1193 % Headings with style \texttt{section} can either be free-standing or
1194 % in-line. Free-standing headings are printed using:
1195 % \begin{quote}
1196 % \cs{sectionlinesformat}\marg{level name}\marg{indent}\marg{number}\marg{text}
1197 % \end{quote}
1198 % The in-line headings are printed using:
1199 % \begin{quote}
1200 % \cs{sectioncatchphraseformat}\marg{level name}\marg{indent}\marg{number}\marg{text}
1201 % \end{quote}
1202 % The \meta{level name} can also be interpreted as the section command
1203 % name. The \meta{indent} is the horizontal indent of the first line of the
1204 % heading. The \meta{number} is either empty for not numbered headings or the
1205 % formatted number to be used. \meta{text} is the formatted text to be
1206 % used. Formatted text means, the fonts are already set and \cs{@@par} for the
1207 % end of paragraph already has been added to the \meta{text} of
1208 % \cs{sectionlinesformat}. But if the user uses more paragraphs than this
1209 % final one, the user is responsible to prevent page breaks!
1210 % \begin{description}
1211 % \item[Note:] Argument \meta{indent} is a kind of design mistake. It would
1212 % have been better to get the indent by the attributes of the \meta{level
1213 % name}. However having an argument makes it easier for users to redefine
1214 % the command.
1215 % \end{description}
1216 % \begin{macrocode}
1217 \newcommand{\sectionlinesformat}[4]{%
1218 \@hangfrom{\hskip #2#3}{#4}%
1219 }
1220 \newcommand{\sectioncatchphraseformat}[4]{%
1221 \hskip #2#3#4%
1222 }
1223 % \end{macrocode}
1224 % \end{command}^^A \sectionlinesformat,\sectioncatchphraseformat
1225 % \end{macro}^^A \scr@sect
1226 %
1227 % \begin{macro}{\scr@ssect}
1228 % \changes{v3.19}{2015/07/17}{re-definition because of several new features}
1229 % \changes{v3.49}{2025/09/11}{\cs{@ssect} renamed to \cs{scr@ssect}}
1230 % The star variant of section commands do not use \cs{@sect} but
1231 % \cs{@ssect}. Here we have the problem, that the command name argument is
1232 % missing. The whole definition is very similar to \cs{@sect} but without a
1233 % number, ToC entry or running head.
1234 % \begin{description}
1235 % \item[Note:] We do not have to support an extended optional argument,
1236 % because there isn't an optional argument.
1237 % \item[Note:] \cs{chapter} and \cs{part} do not use \cs{@ssect} but
1238 % \cs{SecDef}.
1239 % \end{description}
1240 % \begin{macrocode}
1241 \def\scr@ssect#1#2#3#4#5{%
1242 \scr@ifundefinedorrelax{scr@s@ct@@nn@m@}{%
1243 \ClassWarning{\KOMAClassName}{Incompatible usage of
1244 \string\scr@ssect\space detected.\MessageBreak
1245 You've used the KOMA-Script implementation of
1246 \string\scr@ssect\MessageBreak
1247 from within a non compatible caller, that does not\MessageBreak
1248 \string\scr@s@ct@@nn@m@\space locally.\MessageBreak
1249 This could result in several error messages}%
1250 \def\scr@s@ct@@nn@m@{\string\scr@s@ct@@nn@m@}%
1251 }{%
1252 % \end{macrocode}
1253 % \changes{v3.31}{2020/06/02}{execute counter reset list}
1254 % Even for not numbered sections, the reset list für the corresponding section
1255 % counter has to be executed.
1256 % \begin{macrocode}
1257 %<!v4> \expandafter\ifnum\scr@v@is@ge{3.31}\relax
1258 \begingroup
1259 \let\@elt\@stpelt
1260 \csname cl@\scr@s@ct@@nn@m@\endcsname
1261 \endgroup
1262 %<!v4> \fi
1263 }%
1264 % \end{macrocode}
1265 % \changes{v3.26}{2018/09/18}{support for \cs{scr@sect@runin}}
1266 % \changes{v3.27}{2019/02/02}{defining \cs{IfUseNumber} locally}
1267 % \begin{macrocode}
1268 \ifdim
1269 \scr@sect@runin{\z@}{\p@}{\glueexpr #3\relax}>\z@
1270 \begingroup
1271 \let\IfUseNumber\@secondoftwo
1272 % \end{macrocode}
1273 % \changes{v3.21}{2016/06/12}{missing \cs{nobreak} added}
1274 % \changes{v3.27}{2019/02/02}{\cs{ExecuteDoHook} added}
1275 % \begin{macrocode}
1276 \edef\reserved@a{%
1277 \noexpand\ExecuteDoHook{heading/begingroup/\scr@s@ct@@nn@m@}%
1278 }\reserved@a
1279 #4{\nobreak\interlinepenalty \@M
1280 \expandafter\sectionlinesformat\expandafter{\scr@s@ct@@nn@m@}%
1281 {\glueexpr #1\relax}\@empty{#5}\@@par}%
1282 \edef\reserved@a{%
1283 \noexpand\ExecuteDoHook{heading/endgroup/\scr@s@ct@@nn@m@}%
1284 }\reserved@a
1285 \endgroup
1286 \else
1287 \edef\@svsechd{%
1288 \unexpanded{\let\IfUseNumber\@secondoftwo}%
1289 \noexpand\ExecuteDoHook{heading/begingroup/\scr@s@ct@@nn@m@}%
1290 \unexpanded{#4}{%
1291 % \end{macrocode}
1292 % \changes{v3.21}{2016/06/12}{missing \cs{nobreak} added}
1293 % \begin{macrocode}
1294 \noexpand\nobreak
1295 \noexpand\sectioncatchphraseformat{\scr@s@ct@@nn@m@}%
1296 \unexpanded{{\glueexpr #1\relax}\@empty{#5}}%
1297 }%
1298 \noexpand\ExecuteDoHook{heading/endgroup/\scr@s@ct@@nn@m@}%
1299 }%
1300 \fi
1301 \let\scr@s@ct@@nn@m@\relax
1302 \scr@xsect{\glueexpr #3\relax}%
1303 }
1304 %</body>
1305 % \end{macrocode}
1306 % \end{macro}^^A \scr@ssect
1307 %
1308 % \begin{macro}{\scr@xsect}
1309 % \begin{macrocode}
1310 %<*body>
1311 \def\scr@xsect#1{%
1312 \@ifundefined{scr@sect@runin}{%
1313 \def\scr@sect@runin##1##2##3{##3}%
1314 }%
1315 \@tempskipa #1\relax
1316 \ifdim \scr@sect@runin{\z@}{\p@}{\@tempskipa}>\z@
1317 \par \nobreak
1318 \vskip \@tempskipa
1319 \@afterheading
1320 \else
1321 \@nobreakfalse
1322 \global\@noskipsectrue
1323 \everypar{%
1324 \if@noskipsec
1325 \global\@noskipsecfalse
1326 {\setbox\z@\lastbox}%
1327 \clubpenalty\@M
1328 \begingroup \@svsechd \endgroup
1329 \unskip
1330 \@tempskipa #1\relax
1331 \ifdim \@tempskipa<\z@
1332 \hskip -\@tempskipa
1333 \else
1334 \hskip \@tempskipa
1335 \fi
1336 \else
1337 \clubpenalty \@clubpenalty
1338 \everypar{}%
1339 \fi}%
1340 \fi
1341 \def\scr@sect@runin##1##2##3{##3}%
1342 \ignorespaces
1343 }
1344 %</body>
1345 % \end{macrocode}
1346 % \end{macro}^^A \scr@xsect
1347 %
1348 % \begin{command}{\IfUsePrefixLine}
1349 % \changes{v3.18}{2015/06/09}{added}
1350 % \begin{macro}{\scr@IfUsePrefixLineWarning}
1351 % \changes{v3.18}{2015/06/09}{added}
1352 % This command makes sense inside the section commands only. But users often
1353 % tried to use it outside instead of \cs{ifnumbered}. This mostly has resulted
1354 % in a undefined command sequence error users did not understand. So now, we
1355 % use an internal definition to be uses outside the section commands, that
1356 % results in a warning with more information about the mistake and that does
1357 % neither use the first nor the second argument (instead of using both of them).
1358 % \begin{macrocode}
1359 %<*body>
1360 \newcommand*{\scr@IfUsePrefixLineWarning}[2]{%
1361 \ClassWarning{\KOMAClassName}{%
1362 Usage of \string\IfUsePrefixLine\space outside
1363 section command\MessageBreak
1364 style makes no sense, because the behaviour not only\MessageBreak
1365 depends on class options but also on the run-time\MessageBreak
1366 section command style.\MessageBreak
1367 Neither the then-code nor the else-code will be\MessageBreak
1368 executed.\MessageBreak
1369 You may change this and avoid the warning by LOCALLY\MessageBreak
1370 setting \string\IfUsePrefixLine\space to either
1371 \string\@firstoftwo\space or\MessageBreak
1372 \string\@secondoftwo\space before using it%
1373 }%
1374 }
1375 \newcommand*{\IfUsePrefixLine}[2]{}
1376 \let\IfUsePrefixLine\scr@IfUsePrefixLineWarning
1377 %</body>
1378 % \end{macrocode}
1379 % \end{macro}^^A \scr@IfUsePrefixLineWarning
1380 % \end{command}^^A \IfUsePrefixLine
1381 %
1382 %
1383 % \begin{command}{\raggedsection}
1384 % \changes{v2.3h}{1996/01/20}{added}
1385 % Should be either \cs{raggedleft}, \cs{raggedright}, \cs{centering} or
1386 % empty. Empty means no change, which is usually justified. Users could also
1387 % use other alignment/justification commands like the commands of package
1388 % \pkg{ragged2e}. The initial value is \cs{raggedright}.
1389 % \begin{description}
1390 % \item[Note:] We are here in the class. So usually \cs{raggedright} is the
1391 % \cs{raggedright} of the \LaTeX{} kernel. This also means: no hyphenation.
1392 % \item[Note:] We define is already here, because it is not only used for
1393 % style \texttt{section} but also as initial default of the \emph{higher
1394 % level} styles.
1395 % \end{description}
1396 % \begin{macrocode}
1397 %<*body>
1398 \newcommand*{\raggedsection}{}
1399 \let\raggedsection\raggedright
1400 %</body>
1401 % \end{macrocode}
1402 % \end{command}^^A \raggedsection
1403 %
1404 %
1405 % All the options of \cs{DeclareSectionCommand} are options of family
1406 % \texttt{KOMAarg} member \texttt{.dsc}.
1407 % \begin{macrocode}
1408 %<*body>
1409 \DefineFamily{KOMAarg}
1410 \DefineFamilyMember[.dsc]{KOMAarg}
1411 % \end{macrocode}
1412 % \begin{command}{\DeclareSectionCommandStyleOption}
1413 % \changes{v3.17}{2015/03/23}{added}
1414 % \begin{command}{\AddToSectionCommandOptionsDoList,\RelaxSectionCommandOptions}
1415 % \changes{v3.20}{2015/11/18}{added}
1416 % \begin{macro}{\@AddToSectionCommandOptionsDoList,\scr@dsc@doopts}
1417 % \changes{v3.20}{2015/11/18}{added}
1418 % The basic command to define a section command style option is:
1419 % \begin{quote}
1420 % \cs{DeclareSectionCommandStyleOption}\marg{style}\marg{option}\marg{definition}
1421 % \end{quote}
1422 % Is similar to a corresponding \cs{DefineFamilyKey}. But the option
1423 % definition is not done immediately but added to
1424 % \cs{scr@dsc@style@\meta{style}@options} which is executed later inside
1425 % \cs{DeclareSectionCommand} after detection of the \opt{style} option. The
1426 % option is also added to the \emph{section command options do list} of
1427 % \cs{scr@dsc@doopts} using
1428 % \begin{quote}
1429 % \cs{AddToSectionCommandOptionsDoList}\marg{option}
1430 % \end{quote}
1431 % This is used, e.g., to relax all options inside \cs{DeclareSectionCommand}
1432 % using \cs{RelaxSectionCommandOptions} to not have options defined, that are
1433 % used by one style, while declaring a command of another style, that does not
1434 % support the option.
1435 % \begin{description}
1436 % \item[Note:] We also could have used another option member for every style
1437 % to avoid such problems. With \LaTeX3 also usage of
1438 % \pkg[https://www.ctan.org/pkg/l3kernel]{l3keys}, which provides a kind of
1439 % hierarchical options, would have been possible.
1440 % \end{description}
1441 % \begin{macrocode}
1442 \newcommand*{\DeclareSectionCommandStyleOption}[3]{%
1443 \AddToSectionCommandOptionsDoList{#2}%
1444 \expandafter\g@addto@macro\csname scr@dsc@style@#1@options\endcsname{%
1445 \DefineFamilyKey[.dsc]{KOMAarg}{#2}{#3}%
1446 }%
1447 }
1448 \newcommand*{\AddToSectionCommandOptionsDoList}[1]{%
1449 \kernel@ifnextchar [%]
1450 {\@AddToSectionCommandOptionListWithDefault{#1}}%
1451 {\l@addto@macro\scr@dsc@doopts{\do{#1}}}%
1452 }
1453 \newcommand*{\@AddToSectionCommandOptionListWithDefault}{}
1454 \def\@AddToSectionCommandOptionListWithDefault#1[#2]{%
1455 \l@addto@macro\scr@dsc@doopts{\do[{#2}]{#1}}
1456 }%
1457 \newcommand*{\scr@dsc@doopts}{}
1458 \newcommand*{\RelaxSectionCommandOptions}{%
1459 \begingroup
1460 \def\do@endgroup{\endgroup}%
1461 \def\do{%
1462 \kernel@ifnextchar [%]
1463 {\@do}%
1464 {\@do[]}%
1465 }%
1466 \def\@do[##1]##2{%
1467 \l@addto@macro\do@endgroup{\RelaxFamilyKey[.dsc]{KOMAarg}{##2}}%
1468 }%
1469 \scr@dsc@doopts
1470 \do@endgroup
1471 }
1472 % \end{macrocode}
1473 % \end{macro}^^A \@AddToSectionCommandOptionsListWithDefault,\scr@dsc@dooptions
1474 % \end{command}^^A \AddToSectionCommandOptionsDoList,\RelaxSectionCommandOptions
1475 % \end{command}^^A \DeclareSectionCommandStyleOption
1476 % We provide several kinds of options:
1477 % \begin{command}{\DeclareSectionCommandDummyOption}
1478 % \changes{v3.17}{2015/03/23}{added}
1479 % \changes{v3.20}{2015/11/18}{removed}
1480 % \end{command}^^A \DeclareSectionCommandDummyOption
1481 % \begin{command}{\DeclareSectionCommandStyleLengthOption,
1482 % \DeclareSectionCommandStyleNumberOption,
1483 % \DeclareSectionCommandStyleFontOption}
1484 % \changes{v3.17}{2015/03/23}{added}
1485 % \changes{v3.20}{2016/04/25}{argument expansion}
1486 % \changes{v3.38}{2022/09/16}{copy option added}
1487 % All these commands have the four arguments:
1488 % \begin{quote}
1489 % \marg{style}\marg{option}\marg{prefix}\marg{postfix}
1490 % \end{quote}
1491 % Most of the commands all correspond to \pkg*{scrbase} option declaration
1492 % commands:
1493 % \begin{center}
1494 % \begin{tabular}{lll}
1495 % \cs{DeclareSectionCommand} & \pkg*{scrbase} & meaning \\\hline
1496 % \cs{DeclareSectionCommandStyleLengthOption}
1497 % & \cs{FamilyLengthMacroKey} & length option\\
1498 % \cs{DeclareSectionCommandStyleNumberOption}
1499 % & \cs{FamilyCounterMacroKey} & numerical option\\
1500 % \cs{DeclareSectionCommandStyleFontOption}
1501 % & & font element option\\
1502 % \end{tabular}
1503 % \end{center}
1504 % The \meta{macro} of the corresponding \pkg*{scrbase} command is build by
1505 % \meta{prefix}\cs{scr@dsc@current}\meta{postfix}. For
1506 % \cs{DeclareSectionCommandStyleOption} the build name is the font
1507 % element instead. However, before using (setting) the option,
1508 % \cs{scr@dsc@current} has to be defined to be \meta{level name}
1509 % (aka \emph{section command name}). Depending on \cs{ifscr@dsc@expandtopt}
1510 % (see option \opt{expandtopt}) lengths given as argument to the option of
1511 % \cs{DeclareSectionCommandStyleLengthOption} is expanded to a \texttt{pt}
1512 % value instead of used as it is.
1513 % \begin{macrocode}
1514 \newcommand*{\DeclareSectionCommandStyleLengthOption}[4]{%
1515 \DeclareSectionCommandStyleOption{#1}{#2}{%
1516 \protected@edef\reserved@a{%
1517 \noexpand\FamilySetLength{KOMAarg}{#2}{\noexpand\@tempskipa}{##1}%
1518 }\reserved@a
1519 \ifx\FamilyKeyState\FamilyKeyStateProcessed
1520 \ifscr@dsc@expandtopt
1521 \expandafter\edef\csname #3\scr@dsc@current#4\endcsname{%
1522 \the\@tempskipa}%
1523 \else
1524 \expandafter\edef\csname #3\scr@dsc@current#4\endcsname{##1}%
1525 \fi
1526 \fi
1527 }%
1528 \DeclareSectionCommandStyleOption{#1}{#2:}{%
1529 \scr@ifundefinedorrelax{#3##1#4}{\FamilyKeyStateUnknownValue}{%
1530 \ifscr@dsc@expandtopt
1531 \setlength{\@tempskipa}{\@nameuse{#3##1#4}}%
1532 \expandafter\edef\csname #3\scr@dsc@current#4\endcsname{\the\@tempskipa}%
1533 \else
1534 \@namedef{#3\scr@dsc@current#4}{\@nameuse{#3##1#4}}%
1535 \fi
1536 \FamilyKeyStateProcessed
1537 }%
1538 }%
1539 }
1540 \newcommand*{\DeclareSectionCommandStyleNumberOption}[4]{%
1541 \DeclareSectionCommandStyleOption{#1}{#2}{%
1542 \protected@edef\reserved@a{%
1543 \noexpand\FamilySetCounterMacro{KOMAarg}{#2}{\noexpand\reserved@a}{##1}
1544 }\reserved@a
1545 \ifx\FamilyKeyState\FamilyKeyStateProcessed
1546 \expandafter\let\csname #3\scr@dsc@current#4\endcsname\reserved@a
1547 \fi
1548 }%
1549 \DeclareSectionCommandStyleOption{#1}{#2:}{%
1550 \scr@ifundefinedorrelax{#3##1#4}{\FamilyKeyStateUnknownValue}{%
1551 \ifscr@dsc@expandtopt
1552 \@tempcnta=\@nameuse{#3##1#4}%
1553 \expandafter\edef\csname #3\scr@dsc@current#4\endcsname{\the\@tempcnta}%
1554 \else
1555 \@namedef{#3\scr@dsc@current#4}{\@nameuse{#3##1#4}}%
1556 \fi
1557 \FamilyKeyStateProcessed
1558 }%
1559 }%
1560 }
1561 \newcommand*{\DeclareSectionCommandStyleFontOption}[4]{%
1562 \DeclareSectionCommandStyleOption{#1}{#2}{%
1563 \IfExistskomafont{#3\scr@dsc@current#4}{%
1564 \setkomafont
1565 }{%
1566 \newkomafont
1567 }{#3\scr@dsc@current#4}{##1}%
1568 \FamilyKeyStateProcessed
1569 }%
1570 \DeclareSectionCommandStyleOption{#1}{#2:}{%
1571 \IfExistskomafont{#3##1#4}{%
1572 \IfExistskomafont{#3\scr@dsc@current#4}{%
1573 \setkomafont
1574 }{%
1575 \newkomafont
1576 }{#3\scr@dsc@current#4}{\usekomafont{#3##1#4}}%
1577 \FamilyKeyStateProcessed
1578 }{\FamilyKeyStateUnknownValue}%
1579 }%
1580 }
1581 % \end{macrocode}
1582 % \end{command}^^A \DeclareSectionCommandStyleLengthOption …
1583 % \begin{command}{\DeclareSectionCommandStyleFuzzyOption}
1584 % \changes{v3.26}{2018/09/18}{added}
1585 % \changes{v3.28}{2019/11/18}{\cs{ifstr} renamed to \cs{Ifstr}}
1586 % \changes{v3.38}{2022/09/16}{copy option added}
1587 % We also have a kind of fuzzy option. A fuzzy option defined by
1588 % \begin{quote}
1589 % \cs{DeclareSectionCommandStyleFuzzyOption}\meta{style}\meta{option}%
1590 % \meta{prefix}\meta{postfix}\meta{also}
1591 % \end{quote}
1592 % is an option, that provides three values: \texttt{true} (and the aliases
1593 % \texttt{on} and \texttt{yes}), \texttt{false} (and the aliases \texttt{off}
1594 % and \texttt{no}), and a third one \meta{also}. It defines a macro with the
1595 % name \meta{prefix}\cs{scr@dsc@current}\meta{postfix} and three arguments. If
1596 % the option is true, the macro expands to the first argument. If the option
1597 % is false, the macro expands to the second argument. If the option is
1598 % \meta{also} the macro expands to the third argument.
1599 % \begin{macrocode}
1600 \newcommand*{\DeclareSectionCommandStyleFuzzyOption}[5]{%
1601 \DeclareSectionCommandStyleOption{#1}{#2}{%
1602 \FamilySetBool{KOMAarg}{#2}{@tempswa}{##1}%
1603 \ifx\FamilyKeyState\FamilyKeyStateProcessed
1604 \if@tempswa
1605 \expandafter\def\csname #3\scr@dsc@current#4\endcsname
1606 ####1####2####3{####1}%
1607 \else
1608 \expandafter\def\csname #3\scr@dsc@current#4\endcsname
1609 ####1####2####3{####2}%
1610 \fi
1611 \else
1612 \Ifstr{##1}{#5}{%
1613 \expandafter\def\csname #3\scr@dsc@current#4\endcsname
1614 ####1####2####3{####3}%
1615 \FamilyKeyStateProcessed
1616 }{}%
1617 \fi
1618 }%
1619 \DeclareSectionCommandStyleOption{#1}{#2:}{%
1620 \scr@ifundefinedorrelax{#3##1#4}{\FamilyKeyStateUnknownValue}{%
1621 \ifscr@dsc@expandtopt
1622 \expandafter\let\csname #3\scr@dsc@current#4\expandafter\endcsname
1623 \csname #3##1#4\endcsname
1624 \else
1625 \expandafter\def\csname #3\scr@dsc@current#4\endcsname{%
1626 \@nameuse{#3##1#4}%
1627 }%
1628 \fi
1629 \FamilyKeyStateProcessed
1630 }%
1631 }%
1632 }
1633 % \end{macrocode}
1634 % \end{command}^^A \DeclareSectionCommandStyleFuzzyOptions
1635 %
1636 % These types of options are used to define all the options of a style, e.g.,
1637 % \begin{macro}{\scr@dsc@style@section@options}
1638 % \changes{v3.17}{2015/03/23}{added}
1639 % the option declarations of style \texttt{section}:
1640 % \begin{macrocode}
1641 \newcommand*{\scr@dsc@style@section@options}{}
1642 % \end{macrocode}
1643 % \begin{description}
1644 % \item[\opt{indent=\meta{length}}:]
1645 % the left indent of the heading.
1646 % \end{description}
1647 % \begin{macrocode}
1648 \DeclareSectionCommandStyleLengthOption{section}
1649 {indent}{scr@}{@sectionindent}
1650 % \end{macrocode}
1651 % \begin{description}
1652 % \item[\opt{afterindent=\meta{fuzzy}}:]
1653 % \changes{v3.26}{2018/09/18}{option \opt{afterindent}}
1654 % fuzzy logic. A boolean value states whether to indent the first line
1655 % after the heading. With additional \opt{afterindent=bysign} the decision
1656 % depends on the sign of \opt{beforeskip}. Negative values of
1657 % \opt{beforeskip} result in no paragraph indent.
1658 % \end{description}
1659 % \begin{macrocode}
1660 \DeclareSectionCommandStyleFuzzyOption{section}
1661 {afterindent}{scr@}{@afterindent}
1662 {bysign}
1663 % \end{macrocode}
1664 % \begin{description}
1665 % \item[\opt{beforeskip=\meta{length}}:]
1666 % The vertical distance before the heading. If \opt{afterindent=bysign}, the
1667 % absolute value of \meta{length} is used. Otherwise the \meta{length} can
1668 % also be negative to move up the heading.
1669 % \end{description}
1670 % \begin{macrocode}
1671 \DeclareSectionCommandStyleLengthOption{section}
1672 {beforeskip}{scr@}{@beforeskip}
1673 % \end{macrocode}
1674 % \begin{description}
1675 % \item[\opt{runin=\meta{fuzzy}}:]
1676 % \changes{v3.26}{2018/09/18}{option \opt{runin}}
1677 % fuzzy logic. A boolean value states whether the heading is run-in (or
1678 % free-standing). With additional \opt{runin=bysign} the decision depends on
1679 % the sign of \opt{afterskip}. Negative values of \opt{afterskip} result in
1680 % a run-in heading.
1681 % \end{description}
1682 % \begin{macrocode}
1683 \DeclareSectionCommandStyleFuzzyOption{section}
1684 {runin}{scr@}{@runin}
1685 {bysign}
1686 % \end{macrocode}
1687 % \begin{description}
1688 % \item[\opt{afterskip=\meta{length}}:]
1689 % In case of a run-in heading (see option \opt{runin}) the horizontal
1690 % distance after the heading. In case of a free-standing heading the
1691 % vertical distance after the heading. If the run-in heading is activated by
1692 % a negative \meta{length}, the absolute value is used. Otherwise the
1693 % \meta{length} can also be negative, which usually does not make much
1694 % sense.
1695 % \end{description}
1696 % \begin{macrocode}
1697 \DeclareSectionCommandStyleLengthOption{section}
1698 {afterskip}{scr@}{@afterskip}
1699 % \end{macrocode}
1700 % \begin{description}
1701 % \item[\opt{font=\meta{font settings}}:]
1702 % The font setting for the font element of the heading.
1703 % \end{description}
1704 % \begin{macrocode}
1705 \DeclareSectionCommandStyleFontOption{section}{font}{}{}
1706 % \end{macrocode}
1707 % \end{macro}^^A \scr@dsc@style@section@options
1708 % \begin{macro}{\scr@dsc@def@style@section@command}
1709 % \changes{v3.18}{2015/05/21}{added}
1710 % \changes{v3.20}{2016/01/19}{inline section test fixed}
1711 % Macro
1712 % \begin{quote}
1713 % \cs{scr@dsc@def@style@section@command}\marg{command name}
1714 % \end{quote}
1715 % defines a section command \cs{\meta{command name}} of style
1716 % \texttt{section}.
1717 % \begin{description}
1718 % \item[Note:] Here we already use our own \cs{scr@startsection} instead of
1719 % \cs{@startsection}. So maybe not redefining \cs{@startsection} or
1720 % redefining \cs{@startsection} only optionally wouldn't be a big step.
1721 % \end{description}
1722 % \begin{macrocode}
1723 \newcommand*{\scr@dsc@def@style@section@command}[1]{%
1724 \@namedef{#1}{%
1725 \scr@startsection{#1}%
1726 {\csname #1numdepth\endcsname}%
1727 {\csname scr@#1@sectionindent\endcsname}%
1728 {\csname scr@#1@beforeskip\endcsname}%
1729 {\csname scr@#1@afterskip\endcsname}%
1730 {%
1731 \ifdim\glueexpr\csname scr@#1@afterskip\endcsname >\z@
1732 %<!v4> \expandafter\ifnum\scr@v@is@gt{2.96}\relax
1733 \setlength{\parfillskip}{\z@ plus 1fil}%
1734 %<!v4> \fi
1735 \fi
1736 \raggedsection\normalfont\sectfont\nobreak
1737 \usekomafont{#1}%
1738 }%
1739 }%
1740 }
1741 % \end{macrocode}
1742 % \end{macro}^^A \scr@dsc@def@style@section@command
1743 %
1744 % \begin{macro}{\scr@dsc@style@chapter@options}
1745 % \changes{v3.17}{2015/03/23}{added}
1746 % Now, the option declaration of style \texttt{chapter} (similar, but not the
1747 % same):
1748 % \begin{macrocode}
1749 %<*book|report>
1750 \newcommand*{\scr@dsc@style@chapter@options}{}
1751 % \end{macrocode}
1752 % \begin{description}
1753 % \item[\opt{pagestyle=\meta{name}}:]
1754 % The page style, that should be used for the starting page of the chapter
1755 % like outline level.
1756 % \end{description}
1757 % \begin{macrocode}
1758 \DeclareSectionCommandStyleOption{chapter}{pagestyle}{%
1759 \@namedef{\scr@dsc@current pagestyle}{#1}%
1760 \FamilyKeyStateProcessed
1761 }%
1762 % \end{macrocode}
1763 % \begin{description}
1764 % \item[\opt{afterindent=\meta{fuzzy}}:]
1765 % \changes{v3.26}{2018/09/18}{option \opt{afterindent}}
1766 % fuzzy logic. A boolean value states whether to indent the first line
1767 % after the heading. With additional \opt{afterindent=bysign} the decision
1768 % depends on the sign of \opt{beforeskip}. Negative values of
1769 % \opt{beforeskip} result in no paragraph indent.
1770 % \end{description}
1771 % \begin{macrocode}
1772 \DeclareSectionCommandStyleFuzzyOption{chapter}
1773 {afterindent}{scr@}{@afterindent}
1774 {bysign}
1775 % \end{macrocode}
1776 % \begin{description}
1777 % \item[\opt{beforeskip=\meta{length}}:]
1778 % The vertical distance before the heading. If \opt{afterindent=bysign}, the
1779 % absolute value of \meta{length} is used. Otherwise the \meta{length} can
1780 % also be negative to move up the heading.
1781 % \end{description}
1782 % \begin{macrocode}
1783 \DeclareSectionCommandStyleLengthOption{chapter}
1784 {beforeskip}{scr@}{@beforeskip}
1785 % \end{macrocode}
1786 % \begin{description}
1787 % \item[\opt{innerskip=\meta{length}}:]
1788 % The vertical distance between the prefix line and the text (if a prefix
1789 % line is used).
1790 % \end{description}
1791 % \begin{macrocode}
1792 \DeclareSectionCommandStyleLengthOption{chapter}
1793 {innerskip}{scr@}{@innerskip}
1794 % \end{macrocode}
1795 % \begin{description}
1796 % \item[\opt{afterskip=\meta{length}}:]
1797 % The vertical distance after the heading.
1798 % \end{description}
1799 % \begin{macrocode}
1800 \DeclareSectionCommandStyleLengthOption{chapter}
1801 {afterskip}{scr@}{@afterskip}
1802 % \end{macrocode}
1803 % \begin{description}
1804 % \item[\opt{font=\meta{font settings}}:]
1805 % The font setting for the font element of the heading.
1806 % \end{description}
1807 % \begin{macrocode}
1808 \DeclareSectionCommandStyleFontOption{chapter}{font}{}{}
1809 % \end{macrocode}
1810 % \begin{description}
1811 % \item[\opt{prefixfont=\meta{font settings}}:]
1812 % The font setting for the font element of the prefix line of the heading.
1813 % \end{description}
1814 % \begin{macrocode}
1815 \DeclareSectionCommandStyleFontOption{chapter}{prefixfont}{}{prefix}
1816 % \end{macrocode}
1817 % \end{macro}^^A \scr@dsc@style@chapter@options
1818 % \begin{macro}{\scr@dsc@def@style@chapter@command}
1819 % \changes{v3.18}{2015/05/22}{added}
1820 % Macro
1821 % \begin{quote}
1822 % \cs{scr@dsc@def@style@chapter@command}\marg{command name}
1823 % \end{quote}
1824 % defines a section command \cs{\meta{command name}} of style
1825 % \texttt{chapter}. We need some more macros to be initialized than with
1826 % \cs{scr@dsc@def@style@section@command}.
1827 % \begin{description}
1828 % \item[ToDo:] Make a more generic (and general) interface for this.
1829 % \end{description}
1830 % \begin{macrocode}
1831 \newcommand*{\scr@dsc@def@style@chapter@command}[1]{%
1832 \@namedef{#1}{\scr@startchapter{#1}}%
1833 \@namedef{@#1}{\scr@@startchapter{#1}}%
1834 \@namedef{@s#1}{\scr@@startschapter{#1}}%
1835 \@namedef{@make#1head}{\scr@makechapterhead{#1}}%
1836 \@namedef{@makes#1head}{\scr@makeschapterhead{#1}}%
1837 \@namedef{@@make#1head}{\scr@@makechapterhead{#1}}%
1838 \@namedef{@@makes#1head}{\scr@@makeschapterhead{#1}}%
1839 \@namedef{set#1preamble}{\set@preamble{#1}}%
1840 }
1841 %</book|report>
1842 % \end{macrocode}
1843 % \begin{macro}{\scr@dsc@style@chapter@subcommands}
1844 % \changes{v3.30}{2020/04/08}{added}
1845 % Internal name list of additional commands to be defined for style
1846 % \texttt{chapter} commands. This is used, to decide, if a new section command
1847 % declaration is really new or already redefines some commands. This should
1848 % help to avoid, e.g., defining a new chapter command \cs{schapter}, if
1849 % \cs{chapter} is already defines, because \cs{schapter} would redefine the
1850 % \cs{@schapter} of \cs{chapter}.
1851 % \begin{macrocode}
1852 \newcommand*{\scr@dsc@style@chapter@subcommands}[1]{%
1853 @#1,@s#1,@make#1head,@makes#1head,@@make#1head,@@makes#1head,set#1preamble%
1854 }
1855 % \end{macrocode}
1856 % \end{macro}^^A \scr@dsc@style@chapter@subcommands
1857 % \end{macro}^^A \scr@dsc@def@style@chapter@command
1858 %
1859 % \begin{macro}{\scr@dsc@style@part@options}
1860 % \changes{v3.17}{2015/03/23}{added}
1861 % Now the options for style \texttt{part} (very similar to \texttt{chapter}):
1862 % \begin{macrocode}
1863 \newcommand*{\scr@dsc@style@part@options}{}
1864 % \end{macrocode}
1865 % \begin{description}
1866 % \item[\opt{pagestyle=\meta{name}}:]
1867 % The page style, that should be used for the starting page of the chapter
1868 % like outline level.
1869 % \end{description}
1870 % \begin{macrocode}
1871 %<*report|book>
1872 \DeclareSectionCommandStyleOption{part}{pagestyle}{%
1873 \@namedef{\scr@dsc@current pagestyle}{#1}%
1874 \FamilyKeyStateProcessed
1875 }%
1876 %</report|book>
1877 % \end{macrocode}
1878 % \begin{description}
1879 % \item[\opt{afterindent=\meta{fuzzy}}:]
1880 % \changes{v3.26}{2018/09/18}{option \opt{afterindent}}
1881 % fuzzy logic. A boolean value states whether to indent the first line
1882 % after the heading. With additional \opt{afterindent=bysign} the decision
1883 % depends on the sign of \opt{beforeskip}. Negative values of
1884 % \opt{beforeskip} result in no paragraph indent.
1885 % \end{description}
1886 % \begin{macrocode}
1887 \DeclareSectionCommandStyleFuzzyOption{part}
1888 {afterindent}{scr@}{@afterindent}
1889 {bysign}
1890 % \end{macrocode}
1891 % \begin{description}
1892 % \item[\opt{beforeskip=\meta{length}}:]
1893 % The vertical distance before the heading. If \opt{afterindent=bysign}, the
1894 % absolute value of \meta{length} is used. Otherwise the \meta{length} can
1895 % also be negative to move up the heading.
1896 % \end{description}
1897 % \begin{macrocode}
1898 \DeclareSectionCommandStyleLengthOption{part}
1899 {beforeskip}{scr@}{@beforeskip}
1900 % \end{macrocode}
1901 % \begin{description}
1902 % \item[\opt{innerskip=\meta{length}}:]
1903 % The vertical distance between the prefix line and the text (if a prefix
1904 % line is used).
1905 % \end{description}
1906 % \begin{macrocode}
1907 %<*book|report>
1908 \DeclareSectionCommandStyleLengthOption{part}
1909 {innerskip}{scr@}{@innerskip}
1910 %</book|report>
1911 % \end{macrocode}
1912 % \begin{description}
1913 % \item[\opt{afterskip=\meta{length}}:]
1914 % The vertical distance after the heading.
1915 % \end{description}
1916 % \begin{macrocode}
1917 \DeclareSectionCommandStyleLengthOption{part}
1918 {afterskip}{scr@}{@afterskip}
1919 % \end{macrocode}
1920 % \begin{description}
1921 % \item[\opt{font=\meta{font settings}}:]
1922 % The font setting for the font element of the heading.
1923 % \end{description}
1924 % \begin{macrocode}
1925 \DeclareSectionCommandStyleFontOption{part}{font}{}{}
1926 % \end{macrocode}
1927 % \begin{description}
1928 % \item[\opt{prefixfont=\meta{font settings}}:]
1929 % The font setting for the font element of the prefix line of the heading.
1930 % \end{description}
1931 % \begin{macrocode}
1932 \DeclareSectionCommandStyleFontOption{part}{prefixfont}{}{prefix}
1933 % \end{macrocode}
1934 % \end{macro}^^A \scr@dsc@style@part@options
1935 % \begin{macro}{\scr@dsc@def@style@part@command}
1936 % \changes{v3.18}{2015/05/23}{added}
1937 % Macro
1938 % \begin{quote}
1939 % \cs{scr@dsc@def@style@part@command}\marg{command name}
1940 % \end{quote}
1941 % defines a section command \cs{\meta{command name}} of style
1942 % \texttt{part}. This looks like a mixture of
1943 % \cs{scr@dsc@def@style@section@command} and
1944 % \cs{scr@dsc@def@style@chapter@command}.
1945 % \begin{description}
1946 % \item[ToDo:] Make a more generic (and general) interface for this.
1947 % \end{description}
1948 % \begin{macrocode}
1949 \newcommand*{\scr@dsc@def@style@part@command}[1]{%
1950 \@namedef{#1}{\scr@startpart{#1}}%
1951 \@namedef{@#1}{\scr@@startpart{#1}}%
1952 \@namedef{@s#1}{\scr@@startspart{#1}}%
1953 %<book|report> \@namedef{@end#1}{\scr@@endpart{#1}}%
1954 %<book|report> \@namedef{set#1preamble}{\set@preamble{#1}}%
1955 }
1956 % \end{macrocode}
1957 % \begin{macro}{\scr@dsc@style@part@subcommands}
1958 % \changes{v3.30}{2020/04/08}{added}
1959 % Internal name list of additional commands to be defined for style
1960 % \texttt{part} commands.
1961 % \begin{macrocode}
1962 \newcommand*{\scr@dsc@style@part@subcommands}[1]{%
1963 @#1,@s#1,@end#1,set#1preamble%
1964 }
1965 % \end{macrocode}
1966 % \end{macro}^^A \scr@dsc@style@part@subcommands
1967 % \end{macro}^^A \scr@dsc@def@style@part@command
1968 %
1969 % \begin{macro}{\scr@dsc@style@section@neededoptionstest}
1970 % \changes{v3.17}{2015/03/24}{added}
1971 % \changes{v3.24}{2017/04/25}{initial values of \opt{indent} and
1972 % \opt{font}}
1973 % \changes{v3.26}{2018/09/18}{supporting \opt{runin} and \opt{afterindent}}
1974 % This macro checks, that all attributes needed for the definition of a
1975 % section command (with style \texttt{section}) are properly setup. If not, an
1976 % error is reported and the definition is prevented (using
1977 % \cs{aftergroup}\cs{@gobbletwo} inside \cs{scr@declaresectioncommanderror}).
1978 % \begin{macrocode}
1979 \newcommand*{\scr@dsc@style@section@neededoptionstest}{%
1980 \scr@ifundefinedorrelax{scr@\scr@dsc@current @sectionindent}{%
1981 \scr@declaresectioncommandwarning{\scr@dsc@current}%
1982 {section indent}{indent}{0pt}%
1983 {\@namedef{scr@\scr@dsc@current @sectionindent}{0pt}}%
1984 }{}%
1985 \scr@ifundefinedorrelax{scr@\scr@dsc@current @beforeskip}{%
1986 \scr@declaresectioncommanderror{\scr@dsc@current}%
1987 {before section skip}{beforeskip}%
1988 }{}%
1989 \scr@ifundefinedorrelax{scr@\scr@dsc@current @afterskip}{%
1990 \scr@declaresectioncommanderror{\scr@dsc@current}%
1991 {after section skip}{afterskip}%
1992 }{}%
1993 \IfExistskomafont{\scr@dsc@current}{}{%
1994 \scr@declaresectioncommandwarning{\scr@dsc@current}%
1995 {font}{font}{\normalsize}%
1996 {\newkomafont{\scr@dsc@current}{\normalsize}}%
1997 }%
1998 \scr@ifundefinedorrelax{scr@\scr@dsc@current @runin}{%
1999 \l@addto@macro\local@endgroup{%
2000 \ClassInfo{\KOMAClassName}
2001 {using compatibility default `runin=bysign'\MessageBreak
2002 for `\expandafter\string\csname \scr@dsc@current\endcsname}%
2003 \expandafter\gdef\csname scr@\scr@dsc@current @runin\endcsname
2004 ##1##2##3{##3}%
2005 }%
2006 }{}%
2007 \scr@ifundefinedorrelax{scr@\scr@dsc@current @afterindent}{%
2008 \l@addto@macro\local@endgroup{%
2009 \ClassInfo{\KOMAClassName}
2010 {using compatibility default `afterindent=bysign'\MessageBreak
2011 for `\expandafter\string\csname \scr@dsc@current\endcsname}%
2012 \expandafter\gdef\csname scr@\scr@dsc@current @afterindent\endcsname
2013 ##1##2##3{##3}%
2014 }%
2015 }{}%
2016 }
2017 % \end{macrocode}
2018 % \end{macro}^^A \scr@dsc@style@section@neededoptionstest
2019 %
2020 % \begin{macro}{\scr@dsc@style@chapter@neededoptionstest}
2021 % \changes{v3.17}{2015/03/24}{added}
2022 % \changes{v3.24}{2017/04/25}{initial values for all but level
2023 % \texttt{chapter}}
2024 % \changes{v3.28}{2019/11/18}{\cs{ifstr} renamed to \cs{Ifstr}}
2025 % This macro checks, that all attributes needed for the definition of a
2026 % chapter command (with style \texttt{chapter}) are properly setup. If not, an
2027 % error is reported and the definition is prevented (using
2028 % \cs{aftergroup}\cs{@gobbletwo} inside \cs{scr@declaresectioncommanderror}).
2029 % \begin{macrocode}
2030 %<*book|report>
2031 \newcommand*{\scr@dsc@style@chapter@neededoptionstest}{%
2032 \scr@ifundefinedorrelax{\scr@dsc@current pagestyle}{%
2033 \Ifstr{\scr@dsc@current}{chapter}{%
2034 \scr@declaresectioncommanderror{\scr@dsc@current}%
2035 {initial page style}{pagestyle}%
2036 }{%
2037 \scr@declaresectioncommandwarning{\scr@dsc@current}%
2038 {initial page style}{pagestyle}%
2039 {\chapterpagestyle}%
2040 {\@namedef{\scr@dsc@current pagestyle}{\chapterpagestyle}}%
2041 }%
2042 }{}%
2043 \scr@ifundefinedorrelax{scr@\scr@dsc@current @innerskip}{%
2044 \Ifstr{\scr@dsc@current}{chapter}{%
2045 \scr@declaresectioncommanderror{\scr@dsc@current}%
2046 {inner chapter skip}{innerskip}%
2047 }{%
2048 \scr@declaresectioncommandwarning{\scr@dsc@current}%
2049 {inner chapter skip}{innerskip}%
2050 {\scr@chapter@innerskip}%
2051 {\@namedef{scr@\scr@dsc@current @innerskip}{\scr@chapter@innerskip}}%
2052 }%
2053 }{}%
2054 \scr@ifundefinedorrelax{scr@\scr@dsc@current @beforeskip}{%
2055 \Ifstr{\scr@dsc@current}{chapter}{%
2056 \scr@declaresectioncommanderror{\scr@dsc@current}%
2057 {before chapter skip}{beforeskip}%
2058 }{%
2059 \scr@declaresectioncommandwarning{\scr@dsc@current}%
2060 {before chapter skip}{beforeskip}%
2061 {\scr@chapter@beforeskip}%
2062 {\@namedef{scr@\scr@dsc@current @beforeskip}{\scr@chapter@beforeskip}}%
2063 }%
2064 }{}%
2065 \scr@ifundefinedorrelax{scr@\scr@dsc@current @afterskip}{%
2066 \Ifstr{\scr@dsc@current}{chapter}{%
2067 \scr@declaresectioncommanderror{\scr@dsc@current}%
2068 {after chaper skip}{afterskip}%
2069 }{%
2070 \scr@declaresectioncommandwarning{\scr@dsc@current}%
2071 {after chaper skip}{afterskip}%
2072 {\scr@chapter@afterskip}%
2073 {\@namedef{scr@\scr@dsc@current @afterskip}{\scr@chapter@afterskip}}%
2074 }%
2075 }{}%
2076 \IfExistskomafont{\scr@dsc@current}{}{%
2077 \Ifstr{\scr@dsc@current}{chapter}{%
2078 \scr@declaresectioncommanderror{\scr@dsc@current}{font}{font}%
2079 }{%
2080 \scr@declaresectioncommandwarning{\scr@dsc@current}%
2081 {font}{font}%
2082 {\usekomafont{chapter}}%
2083 {\newkomafont{\scr@dsc@current}{\usekomafont{chapter}}}%
2084 }%
2085 }%
2086 \IfExistskomafont{\scr@dsc@current prefix}{}{%
2087 \Ifstr{\scr@dsc@current}{chapter}{%
2088 \scr@declaresectioncommanderror{\scr@dsc@current}%
2089 {prefix line font}{prefixfont}%
2090 }{%
2091 \scr@declaresectioncommandwarning{\scr@dsc@current}%
2092 {prefix line font}{prefixfont}%
2093 {\usekomafont{chapterprefix}}%
2094 {\newkomafont{\scr@dsc@current prefix}{\usekomafont{chapterprefix}}}%
2095 }%
2096 }{}%
2097 \scr@ifundefinedorrelax{scr@\scr@dsc@current @afterindent}{%
2098 \l@addto@macro\local@endgroup{%
2099 \ClassInfo{\KOMAClassName}
2100 {using compatibility default `afterindent=bysign'\MessageBreak
2101 for `\expandafter\string\csname \scr@dsc@current\endcsname}%
2102 \expandafter\gdef\csname scr@\scr@dsc@current @afterindent\endcsname
2103 ##1##2##3{##3}%
2104 }%
2105 }{}%
2106 }
2107 %</book|report>
2108 % \end{macrocode}
2109 % \end{macro}^^A \scr@dsc@style@chapter@neededoptionstest
2110 %
2111 % \begin{macro}{\scr@dsc@style@part@neededoptionstest}
2112 % \changes{v3.17}{2015/03/24}{added}
2113 % \changes{v3.24}{2017/04/25}{initial values for all but level \texttt{part}}
2114 % \changes{v3.28}{2019/11/18}{\cs{ifstr} renamed to \cs{Ifstr}}
2115 % This macro checks, that all attributes needed for the definition of a
2116 % part command (with style \texttt{part}) are properly setup. If not, an
2117 % error is reported and the definition is prevented (using
2118 % \cs{aftergroup}\cs{@gobbletwo} inside \cs{scr@declaresectioncommanderror}).
2119 % \begin{macrocode}
2120 \newcommand*{\scr@dsc@style@part@neededoptionstest}{%
2121 %<*book|report>
2122 \scr@ifundefinedorrelax{\scr@dsc@current pagestyle}{%
2123 \Ifstr{\scr@dsc@current}{part}{%
2124 \scr@declaresectioncommanderror{\scr@dsc@current}%
2125 {initial page style}{pagestyle}%
2126 }{%
2127 \scr@declaresectioncommandwarning{\scr@dsc@current}%
2128 {initial page style}{pagestyle}%
2129 {\partpagestyle}%
2130 {\@namedef{\scr@dsc@current pagestyle}{\partpagestyle}}%
2131 }%
2132 }{}%
2133 \scr@ifundefinedorrelax{scr@\scr@dsc@current @innerskip}{%
2134 \Ifstr{\scr@dsc@current}{part}{%
2135 \scr@declaresectioncommanderror{\scr@dsc@current}%
2136 {inner part skip}{innerskip}%
2137 }{%
2138 \scr@declaresectioncommandwarning{\scr@dsc@current}%
2139 {inner part skip}{innerskip}%
2140 {\scr@part@innerskip}%
2141 {\@namedef{scr@\scr@dsc@current @innerskip}{\scr@part@innerskip}}%
2142 }%
2143 }{}%
2144 %</book|report>
2145 \scr@ifundefinedorrelax{scr@\scr@dsc@current @beforeskip}{%
2146 \Ifstr{\scr@dsc@current}{part}{%
2147 \scr@declaresectioncommanderror{\scr@dsc@current}%
2148 {before part skip}{beforeskip}%
2149 }{%
2150 \scr@declaresectioncommandwarning{\scr@dsc@current}%
2151 {before part skip}{beforeskip}%
2152 {\scr@part@beforeskip}%
2153 {\@namedef{scr@\scr@dsc@current @beforeskip}{\scr@part@beforeskip}}%
2154 }%
2155 }{}%
2156 \scr@ifundefinedorrelax{scr@\scr@dsc@current @afterskip}{%
2157 \Ifstr{\scr@dsc@current}{part}{%
2158 \scr@declaresectioncommanderror{\scr@dsc@current}%
2159 {after part skip}{afterskip}%
2160 }{%
2161 \scr@declaresectioncommandwarning{\scr@dsc@current}%
2162 {after part skip}{afterskip}%
2163 {\scr@part@afterskip}%
2164 {\@namedef{scr@\scr@dsc@current @afterskip}{\scr@part@afterskip}}%
2165 }%
2166 }{}%
2167 \IfExistskomafont{\scr@dsc@current}{}{%
2168 \Ifstr{\scr@dsc@current}{part}{%
2169 \scr@declaresectioncommanderror{\scr@dsc@current}{font}{font}%
2170 }{%
2171 \scr@declaresectioncommandwarning{\scr@dsc@current}{font}{font}%
2172 {\usekomafont{part}}%
2173 {\newkomafont{\scr@dsc@current}{\usekomafont{part}}}%
2174 }%
2175 }{}%
2176 \IfExistskomafont{\scr@dsc@current prefix}{}{%
2177 \Ifstr{\scr@dsc@current}{part}{%
2178 \scr@declaresectioncommanderror{\scr@dsc@current}%
2179 {number font}{prefixfont}%
2180 }{%
2181 \scr@declaresectioncommandwarning{\scr@dsc@current}%
2182 {number font}{prefixfont}%
2183 {\usekomafont{partprefix}}%
2184 {\newkomafont{\scr@dsc@current prefix}{\usekomafont{partprefix}}}%
2185 }%
2186 }{}%
2187 \scr@ifundefinedorrelax{scr@\scr@dsc@current @afterindent}{%
2188 \l@addto@macro\local@endgroup{%
2189 \ClassInfo{\KOMAClassName}{%
2190 using compatibility default
2191 %<article> `afterindent=false'\MessageBreak
2192 %<book|report> `afterindent=true'\MessageBreak
2193 for `\expandafter\string\csname \scr@dsc@current\endcsname}%
2194 \expandafter\gdef\csname scr@\scr@dsc@current @afterindent\endcsname
2195 ##1##2##3%
2196 %<article> {##2}%
2197 %<book|report> {##1}%
2198 }%
2199 }{}%
2200 }
2201 % \end{macrocode}
2202 % \end{macro}^^A \scr@dsc@style@part@neededoptionstest
2203 %
2204 % \begin{macro}{\scr@dsc@parametersonlytrue,\scr@dsc@parametersonlyfalse,
2205 % \ifscr@dsc@parametersonly}
2206 % \changes{v3.17}{2015/03/24}{added}
2207 % \changes{v3.20}{2015/11/18}{dummy options removed}
2208 % In the first option pass of \cs{DeclareSectionCommand} this is set to true,
2209 % if the \opt{style} option is used without value, to change the settings of a
2210 % command without running \cs{scr@dsc@def@style@\meta{style}@command} and
2211 % therefore without defining the command itself.
2212 % \begin{description}
2213 % \item[ToDo:] Is this a not documented feature? What's the sense?
2214 % \end{description}
2215 % \begin{macrocode}
2216 \newif\ifscr@dsc@parametersonly
2217 % \end{macrocode}
2218 % \end{macro}^^A \ifscr@dsc@parametersonly
2219 %
2220 % \begin{command}{\DeclareSectionCommand}
2221 % \changes{v3.15}{2014/11/21}{added}
2222 % \changes{v3.17}{2015/03/23}{re-implemented because of style depending
2223 % options}
2224 % \changes{v3.18}{2015/05/22}{\cs{scr@dsc@def@style@\dots @command}
2225 % defines style depending macros}
2226 % \changes{v3.20}{2015/10/03}{using \cs{DeclareTOCStyleEntry}}
2227 % The main command to define new section commands or redefine existing section
2228 % commands. Incidentally it also defines the corresponding ToC entry command.
2229 % \begin{quote}
2230 % \cs{DeclareSectionCommand}\oarg{options}\marg{command name}
2231 % \end{quote}
2232 % is used to define \cs{\meta{command name}}. The \meta{options} are used to
2233 % specify the behave of the command. It is declared as optional
2234 % argument. However for new commands not all the options are really optional.
2235 % \begin{description}
2236 % \item[Note:] Don't forget to declare all options, that are defined for
2237 % \cs{DeclareSectionCommand} also for \cs{ProvideSectionCommands}!
2238 % \end{description}
2239 % \begin{macrocode}
2240 \newcommand*{\DeclareSectionCommand}[2][]{%
2241 \edef\scr@dsc@current{#2}%
2242 % \end{macrocode}
2243 % The first pass to get the:
2244 % \begin{description}
2245 % \item[\opt{style=\meta{name}}:]
2246 % style of the section command.
2247 % \end{description}
2248 % \begin{macrocode}
2249 \scr@dsc@parametersonlyfalse
2250 \DefineFamilyKey[.dsc]{KOMAarg}{style}{%
2251 \IfArgIsEmpty{##1}{%
2252 \scr@dsc@parametersonlytrue
2253 \FamilyKeyStateProcessed
2254 }{%
2255 \scr@ifundefinedorrelax{scr@dsc@def@style@##1@command}{%
2256 \FamilyKeyStateUnknownValue
2257 }{%
2258 \@namedef{scr@\scr@dsc@current @style}{##1}%
2259 \FamilyKeyStateProcessed
2260 }%
2261 }%
2262 }%
2263 % \end{macrocode}
2264 % \begin{description}
2265 % \item[\opt{tocstyle=\meta{name}}:] \changes{v3.20}{2015/11/12}{early
2266 % evaluation of option \opt{tocstyle}} \changes{v3.27}{2019/10/02}{prefix
2267 % for storing directory style changed} style of the ToC entry. From
2268 % \pkg*{tocbasic} 3.27 the style name macro has been changed from
2269 % \cs{scr@dte@\meta{level name}@style} to \cs{scr@tso@\meta{level
2270 % name}@style}.
2271 % \begin{description}
2272 % \item[ToDo:] Don't support deprecated \cs{scr@dte@\meta{level name}@style}
2273 % any longer.
2274 % \end{description}
2275 % \end{description}
2276 % \begin{macrocode}
2277 \DefineFamilyKey[.dsc]{KOMAarg}{tocstyle}{%
2278 \IfArgIsEmpty{##1}{%
2279 \@ifundefined{scr@dte@\scr@dsc@current @style}{}{%
2280 \expandafter\let\csname scr@dte@\scr@dsc@current @style\endcsname
2281 \relax
2282 }%
2283 \expandafter\let\csname scr@tso@\scr@dsc@current @style\endcsname
2284 \relax
2285 \FamilyKeyStateProcessed
2286 }{%
2287 \scr@ifundefinedorrelax{scr@dte@def@l@##1}{%
2288 \FamilyKeyStateUnknownValue
2289 }{%
2290 \@namedef{scr@dte@\scr@dsc@current @style}{##1}%
2291 \@namedef{scr@tso@\scr@dsc@current @style}{##1}%
2292 \FamilyKeyStateProcessed
2293 }%
2294 }%
2295 }%
2296 % \end{macrocode}
2297 % \begin{description}
2298 % \item[\texttt{@else@=\meta{value}}:]
2299 % \changes{v3.20}{2015/11/18}{early evaluation of option \opt{tocstyle}}
2300 % All other options are ignored using the \opt{@else@} option, which simply
2301 % accepts every option. So the first pass does not report any unknown
2302 % options.
2303 % \end{description}
2304 % \begin{macrocode}
2305 \DefineFamilyKey[.dsc]{KOMAarg}{@else@}{%
2306 %<*trace>
2307 \typeout{TRACE: ignoring option `@else@=\detokenize{##1}'}%
2308 \typeout{TRACE:
2309 \string\scr@key@atlist=`\detokenize\expandafter{\scr@key@atlist}'}%
2310 \typeout{TRACE:
2311 \string\scr@key@name=`\detokenize\expandafter{\scr@key@name}'}%
2312 \typeout{TRACE:
2313 \string\scr@key@value=`\detokenize\expandafter{\scr@key@value}'}%
2314 %</trace>
2315 \FamilyKeyStateProcessed
2316 }%
2317 \FamilyExecuteOptions[.dsc]{KOMAarg}{#1}%
2318 % \end{macrocode}
2319 % \changes{v3.20}{2015/11/18}{Resetting options after first pass}
2320 % After the first pass we have to reset these options.
2321 % \begin{macrocode}
2322 \RelaxFamilyKey[.dsc]{KOMAarg}{@else@}%
2323 \RelaxFamilyKey[.dsc]{KOMAarg}{tocstyle}%
2324 \RelaxFamilyKey[.dsc]{KOMAarg}{style}%
2325 \begingroup
2326 \scr@ifundefinedorrelax{scr@\scr@dsc@current @style}{%
2327 \scr@declaresectioncommanderror{\scr@dsc@current}
2328 {section command style}{style}%
2329 }{}%
2330 \endgroup
2331 \@firstofone{%
2332 % \end{macrocode}
2333 % \changes{v3.20}{2015/11/12}{dummy options for main pass removed}
2334 % Now, we know the style and can activate all the options of the style.
2335 % \begin{macrocode}
2336 \@nameuse{scr@dsc@style@\@nameuse{scr@\scr@dsc@current @style}@options}%
2337 % \end{macrocode}
2338 % And initialize the ToC style.
2339 % \begin{macrocode}
2340 \scr@ifundefinedorrelax{scr@tso@\scr@dsc@current @style}{%
2341 \scr@ifundefinedorrelax{l@\scr@dsc@current}{%
2342 \@namedef{scr@tso@\scr@dsc@current @style}{default}%
2343 }{}%
2344 }{}%
2345 % \end{macrocode}
2346 % \changes{v3.20}{2016/04/12}{\cs{@ifnextchar} replaced by
2347 % \cs{kernel@ifnextchar}}
2348 % \changes{v3.21}{2016/06/12}{support for prefix \opt{tocentry} instead of
2349 % \opt{toc}}
2350 % We also have to define options for all the ToC style options by adding the
2351 % prefix \opt{toc} to the names of these options. This also means a ToC style
2352 % option \opt{style} must not exist (because we already have an option
2353 % \opt{tocstyle}). This is the main reason, \cs{DeclareTOCStyleEntry} has not
2354 % such an option but a corresponding argument. Additionally ToC style options
2355 % should never start with \opt{toc} (because of the ugly resulting
2356 % \opt{toctoc\dots}).
2357 % \begin{macrocode}
2358 \let\scr@dsc@tocstyle@options\@empty
2359 \let\scr@dsc@extra@relax@opts\@empty
2360 \scr@ifundefinedorrelax{scr@tso@\scr@dsc@current @style}{%
2361 \expandafter\let
2362 \csname scr@tso@\scr@dsc@current @style\expandafter\endcsname
2363 \csname scr@dte@\scr@dsc@current @style\endcsname
2364 }{}%
2365 \scr@ifundefinedorrelax{scr@tso@\scr@dsc@current @style}{}{%
2366 \begingroup
2367 \def\scr@dte@current{#2}%
2368 \edef\reserved@a{%
2369 \noexpand\@ExecuteTOCEntryStyleInitCode{%
2370 \@nameuse{scr@tso@\scr@dsc@current @style}%
2371 }{\scr@dsc@current}%
2372 }\reserved@a
2373 \def\do@endgroup{\endgroup}%
2374 \def\do##1{%
2375 \l@addto@macro\do@endgroup{%
2376 \l@addto@macro\scr@dsc@extra@relax@opts{%
2377 \RelaxFamilyKey[.dsc]{KOMAarg}{toc##1}%
2378 \RelaxFamilyKey[.dsc]{KOMAarg}{tocentry##1}%
2379 }%
2380 }%
2381 \kernel@ifnextchar[%]
2382 {\@dodefault{##1}}%
2383 {\@donodefault{##1}}%
2384 }%
2385 \def\@donodefault##1{%
2386 \l@addto@macro\do@endgroup{%
2387 \DefineFamilyKey[.dsc]{KOMAarg}{toc##1}{%
2388 \l@addto@macro{\scr@dsc@tocstyle@options}{##1={####1},}%
2389 \FamilyKeyStateProcessed
2390 }%
2391 \DefineFamilyKey[.dsc]{KOMAarg}{tocentry##1}{%
2392 \l@addto@macro{\scr@dsc@tocstyle@options}{##1={####1},}%
2393 \FamilyKeyStateProcessed
2394 }%
2395 }%
2396 }%
2397 \def\@dodefault##1[##2]{%
2398 \l@addto@macro\do@endgroup{%
2399 \DefineFamilyKey[.dsc]{KOMAarg}{toc##1}[##2]{%
2400 \l@addto@macro{\scr@dsc@tocstyle@options}{##1={####1},}%
2401 \FamilyKeyStateProcessed
2402 }%
2403 \DefineFamilyKey[.dsc]{KOMAarg}{tocentry##1}[##2]{%
2404 \l@addto@macro{\scr@dsc@tocstyle@options}{##1={####1},}%
2405 \FamilyKeyStateProcessed
2406 }%
2407 }%
2408 }%
2409 \scr@dte@doopts
2410 \do@endgroup
2411 }%
2412 % \end{macrocode}
2413 % Make option \opt{style} and \opt{tocstyle} (fast) dummies, because they
2414 % already have been handled completely.
2415 % \begin{macrocode}
2416 \DefineFamilyKey[.dsc]{KOMAarg}{style}{\FamilyKeyStateProcessed}%
2417 \DefineFamilyKey[.dsc]{KOMAarg}{tocstyle}{\FamilyKeyStateProcessed}%
2418 % \end{macrocode}
2419 % Some options exist for all section command styles and therefore are defined
2420 % here and not a part of the style options:
2421 % \begin{description}
2422 % \item[\opt{expandtopt=\meta{boolean}}:]
2423 % If \texttt{true} all lengths are expanded at setting time to unit pt
2424 % instead of used unchanged. With this, the lengths are not depending on the
2425 % font size of usage time but on the current font size.
2426 % \end{description}
2427 % \begin{macrocode}
2428 \FamilyBoolKey[.dsc]{KOMAarg}{expandtopt}{scr@dsc@expandtopt}%
2429 \scr@dsc@expandtoptfalse
2430 % \end{macrocode}
2431 % \begin{description}
2432 % \item[\opt{increaselevel=\meta{number}}:]
2433 % Automatically increase \opt{level} by \meta{number} (with default 1). This
2434 % is needed for \cs{DeclareSectionCommands} and therefore only defined if
2435 % \cs{scr@local@levelincrease} is defined.
2436 % \end{description}
2437 % \begin{macrocode}
2438 \scr@ifundefinedorrelax{scr@local@levelincrease}{%
2439 \RelaxFamilyKey[.dsc]{KOMAarg}{increaselevel}%
2440 }{%
2441 \FamilyCounterMacroKey[.dsc]{KOMAarg}{increaselevel}[1]%
2442 {\scr@local@levelincrease}%
2443 }%
2444 % \end{macrocode}
2445 % \begin{description}
2446 % \item[\opt{level=\meta{number}}:]
2447 % The numerical outline level of the command.
2448 % \end{description}
2449 % \begin{macrocode}
2450 \scr@ifundefinedorrelax{scr@local@leveloffset}{%
2451 \edef\reserved@a{%
2452 \noexpand\FamilyCounterMacroKey[.dsc]{KOMAarg}{level}{%
2453 \expandafter\noexpand\csname \scr@dsc@current numdepth\endcsname}%
2454 }\reserved@a
2455 }{%
2456 \edef\reserved@a{%
2457 \noexpand\DefineFamilyKey[.dsc]{KOMAarg}{level}{%
2458 \noexpand\FamilySetCounterMacro{KOMAarg}{level}{%
2459 \expandafter\noexpand\csname \scr@dsc@current numdepth\endcsname
2460 }%
2461 \unexpanded{%
2462 {\numexpr ##1+\scr@local@leveloffset\relax}%
2463 \edef\scr@local@leveloffset{%
2464 \the\numexpr\scr@local@leveloffset+\scr@local@levelincrease\relax
2465 }%
2466 }%
2467 }%
2468 }\reserved@a
2469 }%
2470 % \end{macrocode}
2471 % \begin{description}
2472 % \item[\opt{counterwithout=\meta{name}}:]
2473 % \changes{v3.19}{2015/09/09}{option \opt{counterwithout}}
2474 % The counter of this command should not depend on the counter
2475 % \cnt{name} any longer.
2476 % \end{description}
2477 % \begin{macrocode}
2478 \FamilyStringKey[.dsc]{KOMAarg}{counterwithout}{\scr@local@counterwithout}%
2479 \let\scr@local@counterwithout\relax
2480 % \end{macrocode}
2481 % \begin{description}
2482 % \item[\opt{counterwithin=\meta{name}}:]
2483 % The counter of this command depends on the counter \cnt{name}.
2484 % \end{description}
2485 % \begin{macrocode}
2486 \FamilyStringKey[.dsc]{KOMAarg}{counterwithin}{\scr@local@counterwithin}%
2487 \let\scr@local@counterwithin\relax
2488 % \end{macrocode}
2489 % \begin{description}
2490 % \item[\opt{toclevel=\meta{number}}:]
2491 % The numerical ToC entry level. Default is \opt{level}. This option exists
2492 % only, if the ToC style supports it. But because with
2493 % \cs{DeclareSectionCommands} we need an offset for this (similar to the
2494 % increase of \opt{level}). So we have to redefine it in case of existing
2495 % \cs{scr@local@tocleveloffset}.
2496 % \end{description}
2497 % \begin{macrocode}
2498 \scr@ifundefinedorrelax{scr@local@tocleveloffset}{}{%
2499 \scr@ifundefinedorrelax{[email protected]@toclevel}{%
2500 }{%
2501 \DefineFamilyKey[.dsc]{KOMAarg}{toclevel}{%
2502 \edef\reserved@a{%
2503 \noexpand\l@addto@macro{\noexpand\scr@dsc@tocstyle@options}{%
2504 level=\the\numexpr ##1+\scr@local@tocleveloffset\relax,%
2505 }%
2506 }\reserved@a
2507 \edef\scr@local@tocleveloffset{%
2508 \the\numexpr\scr@local@tocleveloffset+\scr@local@levelincrease\relax
2509 }%
2510 \FamilyKeyStateProcessed
2511 }%
2512 }%
2513 }%
2514 % \end{macrocode}
2515 % \changes{v3.20}{2015/11/12}{only temporary definition of options}
2516 % The main pass of options execution. Afterwards reset all the options.
2517 % \begin{macrocode}
2518 \FamilyExecuteOptions[.dsc]{KOMAarg}{#1}%
2519 \scr@dsc@extra@relax@opts
2520 \let\scr@dsc@extra@relax@opts\relax
2521 \RelaxSectionCommandOptions
2522 \RelaxFamilyKey[.dsc]{KOMAarg}{style}%
2523 \RelaxFamilyKey[.dsc]{KOMAarg}{tocstyle}%
2524 \RelaxFamilyKey[.dsc]{KOMAarg}{expandtopt}%
2525 \scr@ifundefinedorrelax{scr@local@levelincrease}{}{%
2526 \RelaxFamilyKey[.dsc]{KOMAarg}{increaselevel}%
2527 }%
2528 \RelaxFamilyKey[.dsc]{KOMAarg}{level}%
2529 \RelaxFamilyKey[.dsc]{KOMAarg}{counterwithin}%
2530 % \end{macrocode}
2531 % Now, we can test, if all needed options has been defined.
2532 % \changes{v3.27}{2019/02/07}{\opt{level} must no be -\cs{maxdimen}}
2533 % Also test, that \opt{level} is not -\len{maxdimen}, because this value is
2534 % used internally to switch of numbering locally.
2535 % \begin{macrocode}
2536 \begingroup
2537 \def\local@endgroup{\endgroup}%
2538 \scr@ifundefinedorrelax{\scr@dsc@current numdepth}{%
2539 \scr@declaresectioncommanderror{\scr@dsc@current}{section level}{level}%
2540 }{%
2541 \expandafter\ifnum \csname #2numdepth\endcsname>-\maxdimen
2542 \@nameuse{scr@dsc@style@%
2543 \@nameuse{scr@\scr@dsc@current @style}%
2544 @neededoptionstest}%
2545 \else
2546 \ClassError{\KOMAClassName}{%
2547 `level' must be > -\the\numexpr\maxdimen\relax
2548 }{%
2549 KOMA-Script internally sets `secnumdepth' to
2550 -\the\numexpr\maxdimen\relax\space
2551 to locally switch of\MessageBreak
2552 the numbering, i.e., inside running heads.\MessageBreak
2553 Because of this, you can define section commands with\MessageBreak
2554 `level' greater than -\the\numexpr\maxdimen\relax\space only.%
2555 }%
2556 \let\local@endgroup\endgroup
2557 \aftergroup\@gobbletwo
2558 \fi
2559 }%
2560 \local@endgroup
2561 % \end{macrocode}
2562 % If the configuration is compete, we are ready for the (re-)definition of the
2563 % command.
2564 % \begin{macrocode}
2565 \@firstofone{%
2566 % \end{macrocode}
2567 % \changes{v3.20}{2015/10/15}{missing \cs{expandafter} added}
2568 % First of all we need a counter:
2569 % \begin{macrocode}
2570 \@ifundefined{c@#2}{\newcounter{#2}}{}%
2571 \ifx\scr@local@counterwithout\relax
2572 \else\ifx\scr@local@counterwithout\@empty
2573 \else
2574 \@removefromreset{#2}{\scr@local@counterwithout}%
2575 \fi
2576 \@namedef{the#2}{\arabic{#2}}%
2577 \fi
2578 \ifx\scr@local@counterwithin\relax
2579 \else\ifx\scr@local@counterwithin\@empty
2580 \@namedef{the#2}{\arabic{#2}}%
2581 \else
2582 \@removefromreset{#2}{\scr@local@counterwithin}%
2583 \@addtoreset{#2}{\scr@local@counterwithin}%
2584 \expandafter\def\csname the#2\expandafter\endcsname\expandafter{%
2585 \csname the\scr@local@counterwithin\endcsname.\arabic{#2}}%
2586 \fi
2587 \fi
2588 \@ifundefined{#2format}{%
2589 \@namedef{#2format}{\csname the#2\endcsname\autodot\enskip}%
2590 }{}%
2591 % \end{macrocode}
2592 % \changes{v3.44}{2025/05/14}{add the section command to the internal l3seq}
2593 % Then the command itself (but only, if the \opt{style} was not empty):
2594 % \begin{macrocode}
2595 \ifscr@dsc@parametersonly
2596 \ClassInfo{\KOMAClassName}{%
2597 not defining `\expandafter\string\csname #2\endcsname' due
2598 to\MessageBreak
2599 empty section style option%
2600 }%
2601 \else
2602 \scr@ifundefinedorrelax{%
2603 scr@dsc@def@style@\@nameuse{scr@#2@style}@command%
2604 }{%
2605 \ClassWarning{\KOMAClassName}{%
2606 not defining `\expandafter\string\csname #2\endcsname'
2607 due\MessageBreak
2608 to not yet defined section style\MessageBreak
2609 `\@nameuse{scr@#2@style}'%
2610 }%
2611 }{%
2612 \@nameuse{scr@dsc@def@style@\@nameuse{scr@#2@style}@command}{#2}%
2613 \UseName{__scrkernel_put_section_command:n}{#2}%
2614 }%
2615 \fi
2616 % \end{macrocode}
2617 % We also need commands for the running head and a corresponding number
2618 % formatting. With \pkg*{scrlayer} this can and should be done using
2619 % \cs{DeclareSectionNumberDepth}. Otherwise we do it step by step.
2620 % \changes{v3.15a}{2015/01/21}{\cs{endskip} instead of \cs{enskip}}
2621 % \begin{macrocode}
2622 \@ifundefined{DeclareSectionNumberDepth}{%
2623 \@ifundefined{#2markformat}{%
2624 \@namedef{#2markformat}{\csname the#2\endcsname\autodot\enskip}%
2625 }{}%
2626 \@ifundefined{#2mark}{%
2627 \expandafter\let\csname #2mark\endcsname\@gobble
2628 }{}%
2629 }{%
2630 \DeclareSectionNumberDepth{#2}{\csname #2numdepth\endcsname}%
2631 }%
2632 % \end{macrocode}
2633 % We also need macros to generate and print the ToC entry.
2634 % \begin{macrocode}
2635 \expandafter\providecommand\expandafter*%
2636 \csname add#2tocentry\endcsname[2]{%
2637 \addtocentrydefault{#2}{##1}{##2}%
2638 }%
2639 \scr@ifundefinedorrelax{scr@tso@#2@style}{%
2640 \expandafter\let\csname scr@tso@#2@style\expandafter\endcsname
2641 \csname scr@dte@#2@style\endcsname
2642 }{}%
2643 \scr@ifundefinedorrelax{scr@tso@#2@style}{%
2644 }{%
2645 \DeclareTOCStyleEntry[\scr@dsc@tocstyle@options]{%
2646 \@nameuse{scr@tso@#2@style}%
2647 }{#2}%
2648 }%
2649 \scr@ifundefinedorrelax{l@#2}{%
2650 \DeclareTOCStyleEntry[\scr@dsc@tocstyle@options]{default}{#2}%
2651 }{}%
2652 % \end{macrocode}
2653 % \changes{v3.20}{2015/0/07}{support for ToC levels with \pkg{hyperref}}
2654 % \changes{v3.26}{2018/06/27}{overwrite ToC levels of \pkg{hyperref}}
2655 % \changes{v3.26}{2018/06/27}{fallback handling of gaps in the bookmark
2656 % levels}
2657 % \changes{v3.44}{2025/05/14}{new code giving up compatibility with LaTeX
2658 % before 2022-06-01}
2659 % And we need extra code for \pkg{hyperref} and the bookmarks.
2660 % \begin{macrocode}
2661 \expandafter\let\csname toclevel@#2\expandafter\endcsname
2662 \csname #2tocdepth\endcsname
2663 }%
2664 }%
2665 \let\scr@dsc@current\relax
2666 }
2667 % \end{macrocode}
2668 % \begin{macro}{\cs{\_\_scrkernel\_seq\_put\_unique:Nn}}
2669 % \changes{v3.44}{2025/05/14}{added}
2670 % A variant of \cs{seq\_put\_left:NN} that puts the new item only to the left,
2671 % if it does not yet exist in the sequence.
2672 % \begin{macrocode}
2673 \ExplSyntaxOn
2674 \cs_new:Nn \__scrkernel_seq_put_unique:Nn
2675 {
2676 \seq_if_in:NnF #1 { #2 }
2677 { \seq_put_left:Nn #1 { #2 } }
2678 }
2679 % \end{macrocode}
2680 % \end{macro}
2681 % \begin{macro}{\cs{g\_\_scrkernel\_section\_command\_seq},
2682 % \cs{\_\_scrkernel\_put\_section\_command:n},
2683 % \cs{\_\_scrkernel\_sort\_section\_commands\_by\_numdepth:},
2684 % \cs{\_\_scrkernel\_sort\_section\_commands\_by\_tocdepth:},
2685 % \cs{\_\_scrkernel\_sort\_section\_commands\_by\_toclevel:}}
2686 % We store the names of all sectioning commands in an l3seq and also
2687 % provide sorting of the sequence either by the numbering depth or the depth
2688 % of the corresponding ToC entries. Sorting by \pkg{hyperref}'s toclevel is
2689 % also supported, but usually should be the same.
2690 % \begin{macrocode}
2691 \seq_new:N \g__scrkernel_section_command_seq
2692
2693 \cs_new:Nn \__scrkernel_put_section_command:n
2694 {
2695 \__scrkernel_seq_put_unique:Nn \g__scrkernel_section_command_seq { #1 }
2696 }
2697
2698 \cs_new:Npn \__scrkernel_sort_section_commands_by_numdepth:
2699 {
2700 \seq_sort:Nn \g__scrkernel_section_command_seq
2701 {
2702 \int_compare:nNnTF
2703 { \use:c { ##2numdepth } } < { \use:c { ##1numdepth } }
2704 { \sort_return_swapped: }
2705 { \sort_return_same: }
2706 }
2707 }
2708
2709 \cs_new:Npn \__scrkernel_sort_section_commands_by_tocdepth:
2710 {
2711 \seq_sort:Nn \g__scrkernel_section_command_seq
2712 {
2713 \int_compare:nNnTF
2714 { \use:c { ##2tocdepth } } < { \use:c { ##1tocdepth } }
2715 { \sort_return_swapped: }
2716 { \sort_return_same: }
2717 }
2718 }
2719
2720 \cs_new:Npn \__scrkernel_sort_section_commands_by_toclevel:
2721 {
2722 \seq_sort:Nn \g__scrkernel_section_command_seq
2723 {
2724 \cs_if_exist:cF { toclevel@##1 }
2725 { \cs_set_eq:cc { toclevel@##1 } { ##1tocdepth } }
2726 \cs_if_exist:cF { toclevel@##2 }
2727 { \cs_set_eq:cc { toclevel@##2 } { ##2tocdepth } }
2728 \int_compare:nNnTF
2729 { \use:c { ##2tocdepth } } < { \use:c { ##1tocdepth } }
2730 { \sort_return_swapped: }
2731 { \sort_return_same: }
2732 }
2733 }
2734 % \end{macrocode}
2735 % \end{macro}
2736 % \changes{v3.44}{2025/05/14}{new generation/fix of \pkg{hyperref}'s toclevel}
2737 % \changes{v3.45}{2025/06/04}{run the toclevel fix only if \pkg{hyperref} is
2738 % loaded but not \pkg{bookmark}}
2739 % From version 3.44 we define \pkg{hyperref}'s toclevels at several times:
2740 % \begin{itemize}
2741 % \item when defining a new sectioning command,
2742 % \item for the usual sectioning commands after loading \pkg{hyperref},
2743 % \end{itemize}
2744 % Additionally we test inside \cs{begin{document}} if the levels are different
2745 % from the depth. If package \pkg{bookmark} has not been loaded until the end
2746 % of \cs{begin{document}} we also renumber the levels if needed.
2747 % \begin{macrocode}
2748 \hook_gput_code:nnn { package / hyperref / after } { . }
2749 {
2750 \clist_map_inline:nn
2751 { part, chapter,
2752 section, subsection, subsubsection,
2753 paragraph, subparagraph }
2754 {
2755 \cs_if_exist:cT { #1tocdepth }
2756 {
2757 \int_compare:nNnF
2758 { \use:c { toclevel@#1 } } = { \use:c { #1tocdepth } }
2759 {
2760 \ClassWarningNoLine{ \KOMAClassName }
2761 {
2762 It~seems~hyperref~or~another~package~before~changed
2763 \MessageBreak
2764 \exp_args:NNc \string\use:c{toclevel@#1}~from~
2765 \use:c{#1tocdepth}~to\use:c{toclevel@#1}.
2766 \MessageBreak
2767 Reverting%
2768 }
2769 \cs_set_eq:cc { toclevel@#1 } { #1tocdepth }
2770 }
2771 }
2772 }
2773 }
2774 \hook_gput_code:nnn { begindocument } { . }
2775 {
2776 \seq_map_inline:Nn \g__scrkernel_section_command_seq
2777 {
2778 \int_compare:nNnF
2779 { \use:c{ toclevel@#1 } } = { \use:c { #1tocdepth } }
2780 {
2781 \ClassWarningNoLine { \KOMAClassName }
2782 {
2783 Unexpected~change~of~hyperref~toclevel~of~#1.\MessageBreak
2784 \exp_args:NNc \string\use:c{toclevel@#1}=\use:c{toclevel@#1}
2785 !=
2786 \use:c{#1tocdepth}=\exp_args:NNc \string\use:c{#1tocdepth}.
2787 \MessageBreak
2788 Cross~your~fingers!
2789 }
2790 }
2791 }
2792 }
2793 \hook_gput_code:nnn { begindocument / end } { . }
2794 {
2795 \IfPackageLoadedT { hyperref }
2796 {
2797 \IfPackageLoadedF { bookmark }
2798 {
2799 \__scrkernel_emergency_toclevel_cleanup:
2800 \BeforeStartingTOC[\ext@toc]{\__scrkernel_emergency_toclevel_cleanup:}
2801 }
2802 }
2803 }
2804
2805 \cs_new:Npn \__scrkernel_emergency_toclevel_cleanup:
2806 {
2807 \ClassInfo{\KOMAClassName}{running~emergency~toclevel~cleanup}
2808 \group_begin:
2809 \tl_clear:N \l_tmpa_tl
2810 \__scrkernel_sort_section_commands_by_toclevel:
2811 \seq_map_inline:Nn \g__scrkernel_section_command_seq
2812 {
2813 \tl_if_empty:NF \l_tmpa_tl
2814 {
2815 \int_compare:nNnT
2816 { \use:c { toclevel@##1 } } > { \l_tmpa_int + 1 }
2817 {
2818 \ClassWarningNoLine { \KOMAClassName }
2819 {
2820 Trying~emergency~fix~for~bookmark~level~gap,
2821 \MessageBreak
2822 because~toclevel~of~##1~(\use:c{toclevel@##1})~
2823 is~more~than~1
2824 \MessageBreak
2825 greater~than~toclevel~of~\l_tmpa_tl\space
2826 (\int_use:N\l_tmpa_int).\MessageBreak
2827 Note:~This~fix~can~fail~and~you~should~load
2828 \MessageBreak
2829 package~bookmark~to~avoid~issues~with~such~gaps%
2830 }
2831 \cs_gset:cpe { toclevel@##1 }
2832 { \int_eval:n { \l_tmpa_int + 1 } }
2833 }
2834 }
2835 \tl_set:Nn \l_tmpa_tl { ##1 }
2836 \int_set:Nn \l_tmpa_int { \use:c { toclevel@##1 } }
2837 }
2838 \group_end:
2839 }
2840 \ExplSyntaxOff
2841 % \end{macrocode}
2842 %
2843 % \begin{macro}{\scr@declaresectioncommanderror}
2844 % \changes{v3.15}{2014/11/21}{added}
2845 % It there were not enough options to \cs{DeclareSectionCommand} to define the
2846 % command, we report an error and also execute
2847 % \cs{aftergroup}\cs{@gobbletwo}. So the |\@firstofone{…}| code after
2848 % |\endgroup| resp. |\local@endgroup| inside \cs{DeclareSectionCommand} that
2849 % defines the new section command etc. will never be used in such a case.
2850 % \begin{macrocode}
2851 \newcommand*{\scr@declaresectioncommanderror}[3]{%
2852 \ClassError{\KOMAClassName}{%
2853 #2 of \expandafter\string\csname #1\endcsname\space unknown%
2854 }{%
2855 Please use option `#3' to declare the #2.\MessageBreak
2856 If you'll continue, declaration will be ignored%
2857 }%
2858 \let\local@endgroup\endgroup
2859 \aftergroup\@gobbletwo
2860 }
2861 % \end{macrocode}
2862 % \end{macro}^^A \scr@declaresectioncommanderror
2863 % \begin{macro}{\scr@declaresectioncommandwarning}
2864 % \changes{v3.24}{2017/04/25}{added}
2865 % Sometimes a warning and extension of \cs{local@endgroup} is enough.
2866 % \begin{macrocode}
2867 \newcommand*{\scr@declaresectioncommandwarning}[5]{%
2868 \ClassInfo{\KOMAClassName}{%
2869 #2 of \expandafter\string\csname #1\endcsname\space unknown.\MessageBreak
2870 You should use option `#3' if you\MessageBreak
2871 do not want to use the default value\MessageBreak
2872 `\detokenize{#4}'%
2873 }%
2874 \l@addto@macro\local@endgroup{#5}%
2875 }
2876 % \end{macrocode}
2877 % \end{macro}^^A \scr@declaresectioncommandwarning
2878 % \end{command}^^A \DeclareSectionCommand
2879 %
2880 %
2881 % \begin{command}{\DeclareNewSectionCommand}
2882 % \changes{v3.15}{2014/11/21}{added}
2883 % \changes{v3.25}{2018/03/10}{additional tests and errors about
2884 % \cs{the\dots}, \cs{\dots mark}, \cs{\dots format},
2885 % \cs{\dots markformat}}
2886 % \changes{v3.30}{2020/04/08}{orphan spaces removed}
2887 % This is similar to \cs{DeclareSectionCommand} but reports an error, if the
2888 % command or a main helper already exist. So it can be used for new commands
2889 % only.
2890 % \begin{macrocode}
2891 \newcommand*{\DeclareNewSectionCommand}[2][]{%
2892 \@ifundefined{#2}{%
2893 \@tempswatrue
2894 \let\reserved@b\@empty
2895 \@for \reserved@a:=the#2,#2mark,#2format,#2markformat\do{%
2896 \expandafter\scr@ifundefinedorrelax\expandafter{\reserved@a}{}{%
2897 \@tempswafalse
2898 \edef\reserved@b{\expandafter\string\csname \reserved@a\endcsname}%
2899 }%
2900 }%
2901 \if@tempswa
2902 % \end{macrocode}
2903 % \changes{v3.30}{2020/04/08}{extended test for really new}
2904 % After the general user commands, we just have to detect the style \dots
2905 % \begin{macrocode}
2906 \expandafter\let\expandafter\scr@dsc@current
2907 \csname scr@tso@##2@style\endcsname
2908 \DefineFamilyKey[.dsc]{KOMAarg}{style}{%
2909 \edef\scr@dsc@current{##1}%
2910 \FamilyKeyStateProcessed
2911 }%
2912 \DefineFamilyKey[.dsc]{KOMAarg}{@else@}{\FamilyKeyStateProcessed}%
2913 \FamilyExecuteOptions[.dsc]{KOMAarg}{#1}%
2914 \RelaxFamilyKey[.dsc]{KOMAarg}{@else@}%
2915 \RelaxFamilyKey[.dsc]{KOMAarg}{style}%
2916 \@tempswatrue
2917 % \end{macrocode}
2918 % \dots{} to gut through the \cs{scr@dsc@style@\meta{style}@subcommands} and
2919 % test, if one of them exists.
2920 % \begin{macrocode}
2921 \@ifundefined{scr@dsc@current}{}{%
2922 \scr@ifundefinedorrelax{scr@dsc@style@\scr@dsc@current @subcommands}{%
2923 }{%
2924 \edef\reserved@b{%
2925 \csname scr@dsc@style@\scr@dsc@current @subcommands\endcsname{#2}%
2926 }%
2927 \expandafter\@for\expandafter\reserved@a\expandafter:\expandafter=%
2928 \reserved@b\do{%
2929 \expandafter\scr@ifundefinedorrelax\expandafter{\reserved@a}{}{%
2930 \@tempswafalse
2931 \edef\reserved@b{%
2932 \expandafter\string\csname \reserved@a\endcsname}%
2933 }%
2934 }%
2935 }
2936 }%
2937 \let\scr@dsc@current\relax
2938 \fi
2939 \if@tempswa
2940 % \end{macrocode}
2941 % If not, we can use \cs{DeclareSectionCommand}. Otherwise just report an
2942 % error.
2943 % \begin{macrocode}
2944 \DeclareSectionCommand[{#1}]{#2}%
2945 \else
2946 \ClassError{\KOMAClassName}{%
2947 command `\reserved@b' already defined%
2948 }{%
2949 You've tried to define the section command `\expandafter\string\csname
2950 #2\endcsname' newly.\MessageBreak
2951 Such a section command needs an additional new command
2952 `\reserved@b',\MessageBreak
2953 but this already exists. So you cannot define
2954 `\expandafter\string\csname #2\endcsname' newly.\MessageBreak
2955 Maybe you should use one of \string\DeclareSectionCommand,
2956 \string\RedeclareSectionCommand,\MessageBreak
2957 or \string\ProvideSectionCommand.\MessageBreak
2958 If you'll continue, the command will be ignored.%
2959 }%
2960 \fi
2961 }{%
2962 \ClassError{\KOMAClassName}{%
2963 command `\expandafter\string\csname #2\endcsname' already defined%
2964 }{%
2965 You've tried to define the section command `\expandafter\string\csname
2966 #2\endcsname' newly,\MessageBreak
2967 but a command or something else with this name already
2968 exists.\MessageBreak
2969 Maybe you should use one of \string\DeclareSectionCommand,
2970 \string\RedeclareSectionCommand,\MessageBreak
2971 or \string\ProvideSectionCommand.\MessageBreak
2972 If you'll continue, the command will be ignored.%
2973 }%
2974 }%
2975 }
2976 % \end{macrocode}
2977 % \end{command}^^A \DeclareNewSectionCommand
2978 %
2979 % \begin{command}{\RedeclareSectionCommand}
2980 % \changes{v3.15}{2014/11/21}{added}
2981 % This is much easier than \cs{DeclareNewSectionCommand} because it tests only
2982 % for the main command and uses \cs{DeclareSectionCommand} if the main command
2983 % already exists. So all the additional commands and main helpers do not need
2984 % to exist.
2985 % \begin{macrocode}
2986 \newcommand*{\RedeclareSectionCommand}[2][]{%
2987 \@ifundefined{#2}{%
2988 \ClassError{\KOMAClassName}{%
2989 command `\expandafter\string\csname #2\endcsname' not defined%
2990 }{%
2991 You've tried to re-define the section command `\expandafter\string\csname
2992 #2\endcsname',\MessageBreak
2993 but a command with this name does not exists.\MessageBreak
2994 Maybe you should use one of \string\DeclareSectionCommand,
2995 \string\DeclareNewSectionCommand,\MessageBreak
2996 or \string\ProvideSectionCommand.\MessageBreak
2997 If you'll continue, the command will be irgnored.%
2998 }%
2999 }{%
3000 \DeclareSectionCommand[{#1}]{#2}%
3001 }%
3002 }
3003 % \end{macrocode}
3004 % \end{command}^^A \RedeclareSectionCommand
3005 %
3006 % \begin{command}{\ProvideSectionCommand}
3007 % \changes{v3.15}{2014/11/21}{added}
3008 % This is much easier than \cs{DeclareNewSectionCommand} because currently it
3009 % tests only for the command itself but nor for the helpers.
3010 % \begin{description}
3011 % \item[ToDo:] This is dangerous, because
3012 % e.g. |\ProvideSectionCommand{schapter}| would break \cs{chapter} (because
3013 % of \cs{@schapter}). So maybe it should do the same tests as
3014 % \cs{DeclareNewSectionCommand} and at least warn.
3015 % \end{description}
3016 % Basierend auf |\DeclareSectionCommand| wird eine Gliederungsanweisung
3017 % definiert, wenn sie zuvor noch nicht existierte. Wichtig zu bemerken ist,
3018 % dass die ganzen Hilfsanweisungen bereits existieren dürfen.
3019 % \begin{macrocode}
3020 \newcommand*{\ProvideSectionCommand}[2][]{%
3021 \@ifundefined{#2}{%
3022 \DeclareSectionCommand[{#1}]{#2}%
3023 }{%
3024 \ClassInfo{\KOMAClassName}{%
3025 \string\ProvideSectionCommand{#1} ignored%
3026 }%
3027 }%
3028 }
3029 % \end{macrocode}
3030 % \end{command}^^A \ProvideSectionCommand
3031 %
3032 % \begin{command}{\DeclareSectionCommands}
3033 % \changes{v3.15}{2014/12/03}{added}
3034 % \changes{v3.26}{2018/08/29}{using \cs{scr@trim@spaces}}
3035 % Based on \cs{DeclareSectionCommand} this one can be used to define several
3036 % commands at once. The commands are given as a comma-separated list of
3037 % commands. There is one additional option \opt{increaselevel=\meta{number}}
3038 % to add \meta{number} to the \opt{level} at each call of
3039 % \cs{DeclareSectionCommand} but the first one. The definition of this option
3040 % is done inside \cs{DeclareSectionCommand} if \cs{scr@local@levelincrease} is
3041 % defined. Because of the first run, we initialize it with 0. The same has to
3042 % be done for \cs{scr@local@leveloffset} and \cs{scr@local@tocleveloffset}.
3043 % At the end we also have to un-define these local commands. Otherwise later
3044 % usage of \cs{DeclareSectionCommand} would be detected as part of
3045 % \cs{DeclareSectionCommands}.
3046 % \begin{macrocode}
3047 \newcommand*{\DeclareSectionCommands}[2][]{%
3048 \edef\reserved@a{#2}%
3049 \def\scr@local@levelincrease{\z@}%
3050 \def\scr@local@leveloffset{\z@}%
3051 \def\scr@local@tocleveloffset{\z@}%
3052 \@for\reserved@a:=\reserved@a\do{%
3053 \scr@trim@spaces\reserved@a
3054 \edef\reserved@a{%
3055 \unexpanded{\DeclareSectionCommand[{#1}]}{\reserved@a}%
3056 }%
3057 \reserved@a
3058 }%
3059 \let\scr@local@levelincrease\relax
3060 \let\scr@local@leveloffset\relax
3061 \let\scr@local@tocleveloffset\relax
3062 }
3063 % \end{macrocode}
3064 % \end{command}^^A \DeclareSectionCommands
3065 %
3066 % \begin{command}{\DeclareNewSectionCommands}
3067 % \changes{v3.15}{2014/12/03}{added}
3068 % \changes{v3.26}{2018/08/29}{using \cs{scr@trim@spaces}}
3069 % Because of \opt{increaselevel} we cannot simply use
3070 % \cs{DeclareNewSectionCommand} inside, but have to use
3071 % \cs{DeclareSectionCommand} even for already defined commands (but
3072 % nevertheless report an error).
3073 % \begin{description}
3074 % \item[ToDo:] Is this really the correct error action? Does it really matter,
3075 % if \opt{increaselevel} would be wrong after already reporting an error?
3076 % \end{description}
3077 % \begin{macrocode}
3078 \newcommand*{\DeclareNewSectionCommands}[2][]{%
3079 \edef\reserved@a{#2}%
3080 \def\scr@local@levelincrease{\z@}%
3081 \def\scr@local@leveloffset{\z@}%
3082 \def\scr@local@tocleveloffset{\z@}%
3083 \@for\reserved@a:=\reserved@a\do{%
3084 \scr@trim@spaces\reserved@a
3085 \@ifundefined{\reserved@a}{}{%
3086 \ClassError{\KOMAClassName}{%
3087 command `\expandafter\string\csname\reserved@a\endcsname' already
3088 defined%
3089 }{%
3090 You've tried to define the section command
3091 `\expandafter\string\csname\reserved@a\endcsname' newly,\MessageBreak
3092 but a command, token, box or length with this name already
3093 exists.\MessageBreak
3094 Maybe you should use one of \string\DeclareSectionCommand,
3095 \string\RedeclareSectionCommand,\MessageBreak
3096 or \string\ProvideSectionCommand.\MessageBreak
3097 Nevertheless, if you'll continue, the command will be defined.%
3098 }%
3099 }%
3100 \edef\reserved@a{%
3101 \unexpanded{\DeclareSectionCommand[{#1}]}{\reserved@a}%
3102 }%
3103 \reserved@a
3104 }%
3105 \let\scr@local@levelincrease\relax
3106 \let\scr@local@leveloffset\relax
3107 \let\scr@local@tocleveloffset\relax
3108 }
3109 % \end{macrocode}
3110 % \end{command}^^A \DeclareNewSectionCommands
3111 %
3112 % \begin{command}{\RedeclareSectionCommands}
3113 % \changes{v3.15}{2014/12/03}{added}
3114 % \changes{v3.26}{2018/08/29}{using \cs{scr@trim@spaces}}
3115 % Because of \opt{increaselevel} we cannot simply use
3116 % \cs{RedeclareSectionCommand} inside, but have to use
3117 % \cs{DeclareSectionCommand} even for not yet defined commands (but
3118 % nevertheless report an error).
3119 % \begin{description}
3120 % \item[ToDo:] Is this really the correct error action? Does it really matter,
3121 % if \opt{increaselevel} would be wrong after already reporting an error?
3122 % \end{description}
3123 % \begin{macrocode}
3124 \newcommand*{\RedeclareSectionCommands}[2][]{%
3125 \edef\reserved@a{#2}%
3126 \def\scr@local@levelincrease{\z@}%
3127 \def\scr@local@leveloffset{\z@}%
3128 \def\scr@local@tocleveloffset{\z@}%
3129 \@for\reserved@a:=\reserved@a\do{%
3130 \scr@trim@spaces\reserved@a
3131 \@ifundefined{\reserved@a}{%
3132 \ClassError{\KOMAClassName}{%
3133 command `\expandafter\string\csname\reserved@a\endcsname' not defined%
3134 }{%
3135 You've tried to re-define the section command
3136 `\expandafter\string\csname\reserved@a\endcsname',\MessageBreak
3137 but a command with this name does not exists.\MessageBreak
3138 Maybe you should use one of \string\DeclareSectionCommand,
3139 \string\DeclareNewSectionCommand,\MessageBreak
3140 or \string\ProvideSectionCommand.\MessageBreak
3141 Nevertheless, if you'll continue, the command will be defined.%
3142 }%
3143 }{}%
3144 \edef\reserved@a{%
3145 \unexpanded{\DeclareSectionCommand[{#1}]}{\reserved@a}%
3146 }%
3147 \reserved@a
3148 }%
3149 \let\scr@local@levelincrease\relax
3150 \let\scr@local@leveloffset\relax
3151 \let\scr@local@tocleveloffset\relax
3152 }
3153 % \end{macrocode}
3154 % \end{command}^^A \RedeclareSectionCommands
3155 %
3156 % \begin{command}{\ProvideSectionCommands}
3157 % \changes{v3.15}{2014/12/03}{added}
3158 % \changes{v3.17}{2015/03/23}{re-implemented because of style depending
3159 % options}
3160 % \changes{v3.26}{2018/08/29}{using \cs{scr@trim@spaces}}
3161 % This is the real problematic case, because \opt{increaselevel} should be
3162 % used even for commands, that must not be defined. However, maybe a solution
3163 % like this should be used for the two previous commands too.
3164 % \begin{macrocode}
3165 \newcommand*{\ProvideSectionCommands}[2][]{%
3166 \edef\reserved@a{#2}%
3167 \def\scr@local@levelincrease{\z@}%
3168 \def\scr@local@leveloffset{\z@}%
3169 \def\scr@local@tocleveloffset{\z@}%
3170 \@for\reserved@a:=\reserved@a\do{%
3171 \scr@trim@spaces\reserved@a
3172 \@ifundefined{\reserved@a}{%
3173 \edef\reserved@a{%
3174 \unexpanded{\DeclareSectionCommand[{#1}]}{\reserved@a}%
3175 }%
3176 \reserved@a
3177 }{%
3178 % \end{macrocode}
3179 % If the command already exists, process options \opt{level}, \opt{toclevel}
3180 % and \opt{increaselevel} and ignore all others using an \opt{@else@} option.
3181 % \begin{macrocode}
3182 \DefineFamilyKey[.dsc]{KOMAarg}{@else@}{\FamilyKeyStateProcessed}%
3183 \FamilyCounterMacroKey[.dsc]{KOMAarg}{increaselevel}[1]%
3184 {\scr@local@levelincrease}%
3185 \DefineFamilyKey[.dsc]{KOMAarg}{level}{%
3186 \FamilySetCounterMacro{KOMAarg}{level}{\reserved@b}{##1}%
3187 \edef\scr@local@leveloffset{%
3188 \the\numexpr\scr@local@leveloffset+\scr@local@levelincrease\relax
3189 }%
3190 }%
3191 \DefineFamilyKey[.dsc]{KOMAarg}{toclevel}{%
3192 \FamilySetCounterMacro{KOMAarg}{toclevel}{\reserved@b}{##1}%
3193 \edef\scr@local@tocleveloffset{%
3194 \the\numexpr\scr@local@tocleveloffset+\scr@local@levelincrease\relax
3195 }%
3196 }%
3197 \FamilyExecuteOptions[.dsc]{KOMAarg}{#1}%
3198 \RelaxFamilyKey[.dsc]{KOMAarg}{toclevel}%
3199 \RelaxFamilyKey[.dsc]{KOMAarg}{level}%
3200 \RelaxFamilyKey[.dsc]{KOMAarg}{increaselevel}%
3201 \RelaxFamilyKey[.dsc]{KOMAarg}{@else@}%
3202 }%
3203 }%
3204 \let\scr@local@levelincrease\relax
3205 \let\scr@local@leveloffset\relax
3206 \let\scr@local@tocleveloffset\relax
3207 }
3208 %</body>
3209 % \end{macrocode}
3210 % \end{command}^^A \ProvideSectionCommands
3211 %
3212 % \begin{command}{\IfSectionCommandStyleIs}
3213 % \changes{v3.27}{2019/02/04}{added}
3214 % Test whether ot not the section command of argument 1 has the style of
3215 % argument 2. If so: use argument 3, of not: use argument 4.
3216 % \begin{macrocode}
3217 %<*body>
3218 \newcommand*{\IfSectionCommandStyleIs}[2]{%
3219 \scr@ifundefinedorrelax{#1}{%
3220 \ClassError{\KOMAClassName}{%
3221 \expandafter\string\csname #1\endcsname\space not defined}{%
3222 You cannot compare the section command style of an undefined command.}%
3223 }{%
3224 \scr@ifundefinedorrelax{scr@#1@style}{%
3225 \ClassError{\KOMAClassName}{%
3226 \expandafter\string\csname #1\endcsname\space not a valid section
3227 command%
3228 }{%
3229 You cannot detect the section command style of a command, that
3230 has\MessageBreak
3231 never been defined as a section command by KOMA-Script.%
3232 }%
3233 }%
3234 }%
3235 \scr@ifundefinedorrelax{scr@dsc@def@style@#2@command}{%
3236 \ClassError{\KOMAClassName}{%
3237 unknown section command style `#2'%
3238 }{}%
3239 }%
3240 \Ifstr{\@nameuse{scr@#1@style}}{#2}%
3241 }
3242 %</body>
3243 % \end{macrocode}
3244 % \end{command}
3245 %
3246 % \begin{option}{bookmarkpackage}
3247 % \changes{v3.26}{2018/06/27}{added}
3248 % \changes{v3.39}{2022/11/11}{initial dot removed from member argument of
3249 % option storage commands}
3250 % \changes{v3.44}{2025/05/14}{using generic hooks}
3251 % Package \pkg{hyperref} has problems with bookmark level gaps. So if
3252 % either the users omits a heading level or defines a heading with a level
3253 % that distinguish more than one from the previous or following level, there
3254 % would be a problem. One recommended solution for this would be to use
3255 % package \pkg{bookmark}. So if we load this package, we can use the same
3256 % value for bookmark levels and TOC levels even within
3257 % \cls*{scrartcl}. Nevertheless we allow the user to decide not to use
3258 % \pkg{bookmark}, but then it is not my fault, if something strange
3259 % happens.
3260 % \begin{macrocode}
3261 %<*option>
3262 \KOMA@ifkey{bookmarkpackage}{@scr@autoloadbookmarkpackage}
3263 \@scr@autoloadbookmarkpackagetrue
3264 \KOMA@kav@add{\KOMAClassFileName}{bookmarkpackage}{true}
3265 \AddToHook{package/hyperref/after}{%
3266 \AddToHook{begindocument/before}[\KOMAClassName]{%
3267 \IfPackageLoadedF{bookmark}{%
3268 \if@scr@autoloadbookmarkpackage
3269 % \end{macrocode}
3270 % \changes{v3.42}{2024/06/04}{load \pkg{bookmark} only if available}
3271 % Now we test for existing package file \file{bookmark.sty}. If it does not
3272 % exist, we show a warning an deactivate option \opt{bookmarkpackage}.
3273 % \begin{macrocode}
3274 \IfFileExists{bookmark.sty}{}{%
3275 \ClassWarningNoLine{\KOMAClassName}{%
3276 Using `bookmark' together with `hyperref' is
3277 recommended,\MessageBreak
3278 because of handling of possible bookmark level gaps.\MessageBreak
3279 However, the package seems not to be installed and\MessageBreak
3280 therefore cannot be loaded automatically.\MessageBreak
3281 It is recommended to install package `bookmark'!\MessageBreak
3282 However, you can avoid this warning without\MessageBreak
3283 installation of package `bookmark', if you'd
3284 deactivate\MessageBreak
3285 automatically loading of `bookmark' using KOMA-Script\MessageBreak
3286 option `bookmarkpackage=false' before
3287 \string\begin{document}%
3288 }%
3289 \@scr@autoloadbookmarkpackagefalse
3290 \KOMA@kav@replacevalue{\KOMAClassFileName}{bookmarkpackage}{false}%
3291 }%
3292 \fi
3293 \if@scr@autoloadbookmarkpackage
3294 % \end{macrocode}
3295 % \changes{v3.27}{2019/06/26}{try to translate \pkg{hyperref} driver to
3296 % \pkg{bookmark} driver option}
3297 % The name of the \pkg{hyperref} driver is in \cs{Hy@driver}. But
3298 % \pkg{bookmark} does not provide the same drivers, so we try to translate
3299 % the currently known \pkg{hyperref} drivers to \pkg{bookmark}
3300 % drivers. Also we do not load \pkg{bookmark} with a driver option but
3301 % define \pkg{bookmark}'s \cs{BookmarkDriverDefault}.
3302 % \begin{macrocode}
3303 \scr@ifundefinedorrelax{Hy@driver}{%
3304 \ClassWarning{\KOMAClassName}{%
3305 `hyperref' loaded but `\string\Hy@driver' undefined.\MessageBreak
3306 This should not happen!\MessageBreak
3307 Maybe `hyperref' not loaded or unknown version?%
3308 }%
3309 }{%
3310 % \end{macrocode}
3311 % \changes{v3.28}{2019/11/18}{\cs{ifstr} renamed to \cs{Ifstr}}
3312 % Note: \texttt{hpdftex}, \texttt{hluatex}, \texttt{hxetex} and \texttt{hvtex}
3313 % do not need to be translated, because they are autodetected by
3314 % \pkg{bookmark} as well. \texttt{hypertex}, \texttt{hdviwindo},
3315 % \texttt{htex4ht} and \texttt{latex2html} are not known by \pkg{bookmark},
3316 % so we stay with the default (usually \texttt{dvips}).
3317 % \begin{macrocode}
3318 \Ifstr{\Hy@driver}{hdvips}{%
3319 \providecommand*{\BookmarkDriverDefault}{dvips}%
3320 }{%
3321 \Ifstr{\Hy@driver}{hdvipdfm}{%
3322 \providecommand*{\BookmarkDriverDefault}{dvipdfm}%
3323 }{%
3324 \Ifstr{\Hy@driver}{hdvipson}{%
3325 \providecommand*{\BookmarkDriverDefault}{dvipsone}%
3326 }{%
3327 \Ifstr{\Hy@driver}{htexture}{%
3328 \providecommand*{\BookmarkDriverDefault}{textures}%
3329 }{%
3330 }%
3331 }%
3332 }%
3333 }%
3334 }%
3335 \ClassInfo{\KOMAClassName}{%
3336 loading recommended package `bookmark'.\MessageBreak
3337 Using `bookmark' together with `hyperref' is
3338 recommended,\MessageBreak
3339 because of handling of possible bookmark level gaps.\MessageBreak
3340 You can avoid loading `bookmark' with KOMA-Script
3341 option\MessageBreak
3342 `bookmarkpackage=false' before \string\begin{document}
3343 and\MessageBreak
3344 you can avoid this message adding:\MessageBreak
3345 \space\space\string\usepackage
3346 \scr@ifundefinedorrelax{BookmarkDriverDefault}{}{%
3347 [\BookmarkDriverDefault]%
3348 }{bookmark}\MessageBreak
3349 before \string\begin{document}%
3350 }%
3351 % \end{macrocode}
3352 % \changes{v3.33}{2021/02/17}{workaround for catcode changes of
3353 % \pkg{babel-spanish}}
3354 % For \pkg{babel-spanish} we need to deactivate quoting before loading
3355 % \pkg{bookmark}.
3356 % \begin{macrocode}
3357 \@ifundefined{es@quoting}{%
3358 \RequirePackage{bookmark}%
3359 }{%
3360 \ifx\es@quoting\activatequoting
3361 \ClassInfo{\KOMAClassName}{%
3362 temporary deactivation of babel-spanish quoting
3363 }%
3364 \deactivatequoting
3365 \RequirePackage{bookmark}%
3366 \ClassInfo{\KOMAClassName}{%
3367 reactivation of babel-spanish quoting
3368 }%
3369 \activatequoting
3370 \else
3371 \RequirePackage{bookmark}%
3372 \fi
3373 }%
3374 % \end{macrocode}
3375 % \changes{v3.26b}{2019/01/17}{workaround for \cs{@beginmainauxhook} added}
3376 % \changes{v3.38}{2022/10/04}{\pkg{auxhook} not needed with newer
3377 % \pkg{hyperref}}
3378 % \changes{v3.99}{2024/02/10}{no workaround for old \pkg{hyperref}}
3379 % Sometimes \pkg{auxhook} is not able to recognize that it cannot use a
3380 % patch of \cs{document} to execute \cs{@beginmainauxhook} if it is loaded via
3381 % \cs{AtBeginDocument}. In this case we do it here.
3382 % \begin{macrocode}
3383 %<*!v4>
3384 \@ifpackagelater{hyperref}{2022/09/22}{}{%
3385 \ifx\@beginmainauxhook\relax
3386 \else
3387 \if@filesw
3388 \ClassWarning{\KOMAClassName}{%
3389 seems someone has broken package `auxhook'.\MessageBreak
3390 Usually this happens, if `auxhook' is loaded or
3391 used\MessageBreak
3392 implicitly or explicitly by patching
3393 \string\document%
3394 \scr@ifundefinedorrelax{AtEndPreamble}{}{%
3395 \MessageBreak
3396 or via etoolbox command \string\AtEndPreamble%
3397 }.\MessageBreak
3398 Trying an emergency workaround.\MessageBreak
3399 You can avoid this warning adding:\MessageBreak
3400 \space\space\string\usepackage{auxhook}\MessageBreak
3401 before \string\begin{document}%
3402 }%
3403 \@beginmainauxhook
3404 \fi
3405 \fi
3406 }%
3407 %</!v4>
3408 \fi
3409 }%
3410 }%
3411 }
3412 %</option>
3413 % \end{macrocode}
3414 % \end{option}^^A bookmarkpackage
3415 %
3416 %
3417 % \subsection{Preambles of parts or chapters}
3418 %
3419 % The \KOMAScript{} classes \cls*{scrbook} and \cls*{scrreprt} provide
3420 % preambles above and below the headings of parts and chapters. The preamble
3421 % above is printed into the usual distance above the headings. It does not
3422 % increase this distance to avoid \emph{jumping headings}. However here we
3423 % have only the generic code for preambles. The user commands are defined by
3424 % \cs{scr@dsc@style@chapter@command} and \cs{scr@dsc@style@part@command}.
3425 %
3426 % \begin{macro}{\use@preamble}
3427 % \changes{v2.8p}{2001/09/25}{added}
3428 % Used as a general macro to print the stored preamble code and clean the
3429 % storage. Preambles are only printed, if the storage is defined. But an empty
3430 % defined storage would be printed. The argument is the name of the storage,
3431 % e.g., \texttt{chapter@o}, \texttt{chapter@u}, \texttt{part@o},
3432 % \texttt{part@u}.
3433 % \begin{macrocode}
3434 %<*book|report>
3435 %<*body>
3436 \newcommand*{\use@preamble}[1]{%
3437 \@ifundefined{#1@preamble}{}{%
3438 \@nameuse{#1@preamble}%
3439 \global\expandafter\let\csname#1@preamble\endcsname=\relax
3440 }%
3441 }
3442 % \end{macrocode}
3443 % \end{macro}
3444 % \begin{macro}{\set@preamble}
3445 % \changes{v2.8p}{2001/09/25}{added}
3446 % \changes{v3.20}{2016/04/12}{\cs{@ifnextchar} replaced by
3447 % \cs{kernel@ifnextchar}}
3448 % Macro
3449 % \begin{quote}
3450 % \cs{set@preamble}\marg{level name}\oarg{position}\oarg{width}\marg{text}
3451 % \end{quote}
3452 % defines a preamble code stored into \cs{\meta{preamble name}@preamble}. The
3453 % \meta{preamble name} is build depending on the \meta{level name} and the
3454 % \meta{position}. The \meta{position} is a combination of vertical and
3455 % horizontal position and used to generate not only the \meta{preamble name}
3456 % but also options for the \cs{parbox} used to encapsulate the \meta{text}
3457 % into a preamble code. The \meta{width} is also used for the \cs{parbox}.
3458 % \begin{description}
3459 % \item[Note:] The definition of a preamble is global and the definition of a
3460 % new preamble of the same \meta{preamble name} overwrite an existing one.
3461 % \end{description}
3462 % \begin{macro}{\set@@preamble}
3463 % \changes{v2.8p}{2001/09/25}{added}
3464 % \changes{v3.20}{2016/04/12}{\cs{@ifnextchar} replaced by
3465 % \cs{kernel@ifnextchar}}
3466 % \begin{macro}{\set@@@preamble}
3467 % \changes{v2.8p}{2001/09/25}{added}
3468 % \begin{macro}{\set@@@@preamble}
3469 % \changes{v2.8p}{2001/09/25}{added}
3470 % \changes{v2.8q}{2001/11/27}{missing brace added}
3471 % \changes{v3.12}{2012/10/16}{allow \texttt{o} as alias for \texttt{b}}
3472 % \changes{v3.12a}{2014/02/14}{\texttt{b} fixed}
3473 % We need a lot of helpers because of not using \pkg*{xparse} but having
3474 % several optional arguments. At least one optional argument? If not use an
3475 % empty default for the first one and \len{hsize} for the second one.
3476 % \begin{macrocode}
3477 \newcommand*{\set@preamble}[1]{%
3478 \kernel@ifnextchar [%]
3479 {\set@@preamble{#1}}{\set@@@preamble{#1}[][\hsize]}%
3480 }
3481 % \end{macrocode}
3482 % Or even two optional argument? If not use default \len{hsize}.
3483 % \begin{macrocode}
3484 \newcommand*{\set@@preamble}{}
3485 \def\set@@preamble#1[#2]{%
3486 \kernel@ifnextchar [%]
3487 {\set@@@preamble{#1}[{#2}]}{\set@@@preamble{#1}[{#2}][\hsize]}%
3488 }
3489 % \end{macrocode}
3490 % From here we know all optional arguments and have to process the composite
3491 % \meta{position}.
3492 % \begin{macrocode}
3493 \newcommand{\set@@@preamble}{}
3494 \long\def\set@@@preamble#1[#2][#3]#4{%
3495 \begingroup
3496 \def\prmbl@pos{#2}\let\prmbl@hpos\relax\let\prmbl@vpos\relax
3497 \expandafter \@tfor \expandafter \@tempa
3498 \expandafter :\expandafter =\prmbl@pos
3499 \do{%
3500 \if \@tempa l%
3501 \set@preamble@hpos{0}{#2}%
3502 \fi%
3503 \if \@tempa c%
3504 \set@preamble@hpos{1}{#2}%
3505 \fi%
3506 \if \@tempa r%
3507 \set@preamble@hpos{2}{#2}%
3508 \fi%
3509 \if \@tempa u%
3510 \set@preamble@vpos{0}{#2}%
3511 \fi%
3512 \if \@tempa b%
3513 \set@preamble@vpos{0}{#2}%
3514 \fi
3515 \if \@tempa o%
3516 \set@preamble@vpos{1}{#2}%
3517 \fi%
3518 \if \@tempa t%
3519 \set@preamble@vpos{1}{#2}%
3520 \fi
3521 }%
3522 % \end{macrocode}
3523 % If the horizontal or vertical position is still unclear use defaults.
3524 % \begin{macrocode}
3525 \@ifundefined{prmbl@hpos}{\def\prmbl@hpos{0}}{}%
3526 \@ifundefined{prmbl@vpos}{\def\prmbl@vpos{0}}{}%
3527 % \end{macrocode}
3528 % From the vertical position we can build the \meta{preamble name} and the
3529 % vertical position of the \cs{parbox} the horizontal is used for the
3530 % horizontal skip before and after the \cs{parbox}.
3531 % \begin{macrocode}
3532 \ifcase\prmbl@hpos
3533 \ifcase\prmbl@vpos
3534 \set@@@@preamble{#1@u}{t}{#3}{}{\hfil}{#4}%
3535 \else
3536 \set@@@@preamble{#1@o}{b}{#3}{}{\hfil}{#4}%
3537 \fi
3538 \or
3539 \ifcase\prmbl@vpos
3540 \set@@@@preamble{#1@u}{t}{#3}{\hfil}{\hfil}{#4}%
3541 \else
3542 \set@@@@preamble{#1@o}{b}{#3}{\hfil}{\hfil}{#4}%
3543 \fi
3544 \else
3545 \ifcase\prmbl@vpos
3546 \set@@@@preamble{#1@u}{t}{#3}{\hfil}{}{#4}%
3547 \else
3548 \set@@@@preamble{#1@o}{b}{#3}{\hfil}{}{#4}%
3549 \fi
3550 \fi
3551 \endgroup
3552 }
3553 % \end{macrocode}
3554 % Last but not least add the horizontal aligned \cs{parbox} to the preamble
3555 % storage.
3556 % \begin{macrocode}
3557 \newcommand{\set@@@@preamble}[6]{%
3558 \expandafter\gdef\csname #1@preamble\endcsname{%
3559 \hbox to\hsize{#4\parbox[{#2}]{#3}{#6\par}#5\par}%
3560 }%
3561 }
3562 % \end{macrocode}
3563 % \begin{macro}{\set@preamble@hpos}
3564 % \changes{v2.8q}{2001/09/25}{added}
3565 % Either store the horizontal preamble position if not yet defined or if
3566 % already defined but illegal report it as an error.
3567 % \begin{macrocode}
3568 \newcommand*{\set@preamble@hpos}[2]{%
3569 \@ifundefined{prbml@hpos}{%
3570 \def\prmbl@hpos{#1}%
3571 }{%
3572 \ifnum \prmbl@hpos=0\relax\else%
3573 \ClassError{\KOMAClassName}{%
3574 inconsistent hpos options%
3575 }{%
3576 You've said `#2' as position option. But you have
3577 to\MessageBreak
3578 use only one of `l', `r', or `c' not two of
3579 these.\MessageBreak
3580 If you'll continue only first hpos option will be
3581 used%
3582 }%
3583 \fi
3584 }%
3585 }
3586 % \end{macrocode}
3587 % \end{macro}^^A \set@preamble@hpos
3588 % \begin{macro}{\set@preamble@vpos}
3589 % \changes{v2.8q}{2001/09/25}{added}
3590 % Either store the vertical position if not yet defined or if already defined
3591 % but illegal report it as an error.
3592 % \begin{macrocode}
3593 \newcommand*{\set@preamble@vpos}[2]{%
3594 \@ifundefined{prbml@vpos}{%
3595 \def\prmbl@vpos{#1}%
3596 }{%
3597 \ifnum \prmbl@vpos=0\relax\else%
3598 \ClassError{\KOMAClassName}{%
3599 inconsistent vpos options%
3600 }{%
3601 You've said `#2' as position option. But you have
3602 to\MessageBreak
3603 use only one of `t', `o', `b', or `u' not two of
3604 these.\MessageBreak
3605 If you'll continue only first vpos option will be
3606 used%
3607 }%
3608 \fi
3609 }%
3610 }
3611 %</body>
3612 %</book|report>
3613 % \end{macrocode}
3614 % \end{macro}^^A \set@preamble@vpos
3615 % \end{macro}^^A \set@@@@preamble
3616 % \end{macro}^^A \set@@@preamble
3617 % \end{macro}^^A \set@@preamble
3618 % \end{macro}^^A \set@preamble
3619 %
3620 %
3621 % \subsection{Deprecated code for the ToC}
3622 %
3623 % Before using \pkg*{tocbasic} we needed additional code for our extended
3624 % version of \cs{@dottedtocline}. However this has been removed in
3625 % \KOMAScript~v3.36.
3626 %
3627 % \begin{macro}{\bprot@dottedtocline}
3628 % \changes{v2.96a}{2006/11/30}{added}
3629 % \changes{v3.27}{2019/02/25}{deprecated}
3630 % \changes{v3.36}{2022/03/15}{removed}
3631 % \end{macro}
3632 %
3633 %
3634 % \subsection{Rough structuring of books}
3635 %
3636 % Some books have a kind of rough structuring into front matter, main matter
3637 % and back matter. This has consequences for the page numbering and the
3638 % numbering of headings and other elements.
3639 %
3640 % \begin{macro}{\@mainmattertrue,\@mainmatterfalse,\if@mainmatter}
3641 % For the numbering of headings and other elements we only need to know
3642 % whether we are in the main matter or not, because chapters outside the main
3643 % matter do not provide a number. A boolean switch is best for this. By
3644 % default we already start with the main matter.
3645 % \begin{macrocode}
3646 %<*book>
3647 %<*body>
3648 \newif\if@mainmatter\@mainmattertrue
3649 % \end{macrocode}
3650 % \end{macro}^^A \@mainmattertrue,\if@mainmatter
3651 %
3652 % \begin{command}{\frontmatter}
3653 % \changes{v2.4e}{1996/07/02}{support for \opt{open\quotechar=any}}
3654 % \changes{v2.5h}{1999/12/29}{support for \opt{twoside}}
3655 % \changes{v3.00}{2008/09/27}{\cs{cleardoublepage} replaced by
3656 % \cs{cleardoubleoddpage}}
3657 % \changes{v3.49}{2025/10/28}{star variant added}
3658 % \changes{v3.49}{2025/10/28}{optional argument added}
3659 % Switching to the front matter always needs a new odd page, because we
3660 % change the page numbering to lowercase Roman numbers. From \KOMAScript{}
3661 % v3.49 there is also a star form without changing the page numbering style.
3662 % \begin{description}
3663 % \item[Note:] Because of using \cs{tl\_if\_blank:TF} instead of
3664 % \cs{IfValueTF} we have the correct order to make patches replacing
3665 % \cs{pagenumbering} by \cs{@gobble} still work.
3666 % \end{description}
3667 % \begin{macrocode}
3668 \ExplSyntaxOn
3669 \NewDocumentCommand\frontmatter{so}{
3670 \if@twoside\cleardoubleoddpage\else\clearpage\fi
3671 \@mainmatterfalse
3672 \IfBooleanF{#1}{
3673 \tl_if_novalue:nTF {#2}
3674 {\pagenumbering{roman}}
3675 {\tl_if_blank:nF {#2}{\pagenumbering{#2}}}
3676 }
3677 }
3678 % \end{macrocode}
3679 % \end{command}^^A \frontmatter
3680 % \begin{command}{\mainmatter}
3681 % \changes{v2.4e}{1996/07/02}{support for \opt{open\quotechar=any}}
3682 % \changes{v2.5h}{1999/12/29}{support for \opt{twoside}}
3683 % \changes{v3.00}{2008/09/27}{\cs{cleardoublepage} replaced by
3684 % \cs{cleardoubleoddpage}}
3685 % \changes{v3.49}{2025/10/28}{star variant added}
3686 % \changes{v3.49}{2025/10/28}{optional argument added}
3687 % Switching back to main matter always needs a new odd page, because we
3688 % change the page numbering to Arabic numbers. From \KOMAScript{} v3.49
3689 % there is also a star form without changing the page numbering style.
3690 % \begin{macrocode}
3691 \NewDocumentCommand\mainmatter{so}{%
3692 \if@twoside\cleardoubleoddpage\else\clearpage\fi
3693 \@mainmattertrue
3694 \IfBooleanF{#1}{
3695 \tl_if_novalue:nTF {#2}
3696 {\pagenumbering{arabic}}%
3697 {\tl_if_blank:nF {#2}{\pagenumbering{#2}}}
3698 }
3699 }
3700 % \end{macrocode}
3701 % \end{command}^^A \mainmatter
3702 % \begin{command}{\backmatter}
3703 % \changes{v3.00}{2008/09/27}{\cs{cleardoublepage} replaced by
3704 % \cs{cleardoubleoddpage}}
3705 % \changes{v3.49}{2025/10/28}{star variant added}
3706 % \changes{v3.49}{2025/10/28}{optional argument added}
3707 % Only with \opt{open=right} we start a new odd page when starting the back
3708 % matter.
3709 % \begin{description}
3710 % \item[ToDo:] This does not make any sense, because the page numbering is not
3711 % changed. And it seems to be even wrong for \opt{open=left}! So why does
3712 % \cls*{book} use this and why shall we do so too?
3713 % \end{description}
3714 % \begin{macrocode}
3715 \NewDocumentCommand\backmatter{sO{}}{%
3716 \if@openright\cleardoubleoddpage\else\clearpage\fi\@mainmatterfalse
3717 \IfBooleanF{#1}{
3718 \tl_if_blank:nF {#2}{\pagenumbering{#2}}
3719 }
3720 }
3721 \ExplSyntaxOff
3722 %</body>
3723 %</book>
3724 % \end{macrocode}
3725 % \end{command}
3726 %
3727 %
3728 % \subsection{Appendix}
3729 %
3730 % The classes (except \cls*{scrlttr2}) does provide an appendix switch,
3731 % similar but not identical to the standard classes.
3732 %
3733 % \begin{command}{\appendix}
3734 % Activation of the appendix switch over to numbering of chapters
3735 % resp. sections with uppercase letters.
3736 % \changes{v2.2d}{1995/05/28}{\cls*{scrartcl} doesn't have a chapter
3737 % counter}
3738 % \changes{v2.3c}{1995/08/06}{alternative section numbering in appendix}
3739 % \changes{v2.8}{2001/06/15}{new \cs{appendixmore}}
3740 % \changes{v2.8e}{2001/07/10}{\cs{@altsecnumformattrue} removed}
3741 % \changes{v2.8o}{2001/09/19}{initial \cs{par} added}
3742 % \changes{v2.95}{2006/07/04}{\cs{newcommand*} replaced by \cs{gdef}}
3743 % \changes{v2.95}{2006/07/04}{simplified usage of \cs{appendixmore}}
3744 % \changes{v3.20}{2016/12/05}{improved warning}
3745 % \changes{v3.28}{2019/11/18}{\cs{ifstr} renamed to \cs{Ifstr}}
3746 % \changes{v3.34}{2021/04/30}{\LaTeX{} hook added}
3747 % \changes{v3.46}{2025/08/13}{local redefinition of \cs{@chapapp} inside ToCs
3748 % added}
3749 % \begin{command}{\appendixmore}
3750 % \changes{v2.8}{2001/06/15}{added}
3751 % \cs{appendixmore} is deprecated with \LaTeX{} 2020/10/01 (or newer) but
3752 % still executed as a kind of hook.
3753 % \begin{macrocode}
3754 %<*body>
3755 \newcommand*\appendix{%
3756 \Ifstr{\@currenvir}{appendix}{%
3757 \ClassWarning{\KOMAClassName}{%
3758 You are using
3759 `\string\begin{appendix}...\string\end{appendix}'.\MessageBreak
3760 You should note, that `\string\appendix' is a mostly
3761 globally\MessageBreak
3762 working command not an enviroment with only local\MessageBreak
3763 effects. Therefore `\string\end{appendix}' will neither\MessageBreak
3764 switch back to normal section numbering nor finish\MessageBreak
3765 every other effect of `\string\begin{appendix}'.\MessageBreak
3766 Nevertheless, some effects may end with\MessageBreak
3767 `\string\end{appendix}' and the document may become\MessageBreak
3768 inconsistent.\MessageBreak
3769 Because of this, you should remove `\string\end{appendix}'\MessageBreak
3770 and replace `\string\begin{appendix}' by command\MessageBreak
3771 `\string\appendix'%
3772 }%
3773 }{}%
3774 \par
3775 %<*article>
3776 \setcounter{section}{0}%
3777 \setcounter{subsection}{0}%
3778 \gdef\thesection{\@Alph\c@section}%
3779 %</article>
3780 %<*report|book>
3781 \setcounter{chapter}{0}%
3782 \setcounter{section}{0}%
3783 \gdef\@chapapp{\appendixname}%
3784 \addtocontents{\ext@toc}{\def\protect\@chapapp{\protect\appendixname}}%
3785 \doforeachtocfile[float]{%
3786 \addtocontents{\@currext}{\def\protect\@chapapp{\protect\appendixname}}%
3787 }%
3788 \gdef\thechapter{\@Alph\c@chapter}%
3789 %</report|book>
3790 \UseOneTimeHook{\KOMAClassName/appendix}%
3791 \csname appendixmore\endcsname
3792 }
3793 %</body>
3794 %<*prepare>
3795 \NewHook{\KOMAClassName/appendix}
3796 %</prepare>
3797 % \end{macrocode}
3798 % \end{command}
3799 % \end{command}
3800 %
3801 %
3802 % \subsection{Parts}
3803 %
3804 % \begin{macro}{\@thepart}
3805 % \changes{v2.8e}{2001/07/10}{removed}
3806 % \end{macro}
3807 %
3808 % The definition of parts depends on the class.
3809 %
3810 % \begin{fontelement}{partnumber,part}
3811 % \changes{v2.8o}{2001/09/14}{pre-added as macro}
3812 % \changes{v2.8p}{2001/09/23}{added}
3813 % \changes{v2.96a}{2006/12/02}{undocumented support for last macro expects an
3814 % argument}
3815 % \begin{fontelement}{partprefix}
3816 % \changes{v3.18}{2015/06/10}{alias added}
3817 % Definition of the font elements used by \cs{part}. The settings are done by
3818 % option \texttt{headings} later. Everything is prepared before this option is
3819 % used the first time. The elements are defined manually because of
3820 % compatibility with \KOMAScript~v2.8o before font elements has been
3821 % implemented in \KOMAScript~v2.8p.
3822 % \begin{macrocode}
3823 %<*prepare>
3824 \newcommand*{\size@part}{}
3825 \newcommand*{\scr@fnt@part}{\size@part}
3826 \newcommand*{\size@partnumber}{}
3827 \newcommand*{\scr@fnt@partnumber}{\size@partnumber}
3828 \aliaskomafont{partprefix}{partnumber}
3829 %</prepare>
3830 % \end{macrocode}
3831 % \end{fontelement}^^A partprefix
3832 % \end{fontelement}^^A partnumber,part
3833 %
3834 %
3835 % \begin{command}{\partheadstartvskip,\partheadendvskip}
3836 % \changes{v2.95a}{2006/07/10}{added}
3837 % \changes{v3.15}{2014/11/24}{\cls*{scrartcl} defines and uses
3838 % \cs{scr@part@beforeskip} resp. \cs{scr@part@afterskip}}
3839 % \begin{command}{\partheadmidvskip}
3840 % \changes{v2.95a}{2006/07/10}{added}
3841 % \begin{command}{\parheademptypage}
3842 % \changes{v3.02}{2009/01/01}{added}
3843 % These commands are the distance before and after a part heading, between the
3844 % prefix line and the text line of the heading and also the empty retro page
3845 % of a part.
3846 %
3847 % \begin{macro}{\scr@part@sectionbeforeskip,\scr@part@beforeskip}
3848 % \changes{v3.15}{2014/11/24}{added}
3849 % \changes{v3.17}{2015/03/25}{\cs{scr@part@sectionbeforeskip} renamed to
3850 % \cs{scr@part@beforeskip}}
3851 % \begin{macro}{\scr@part@sectionafterskip,\scr@part@sectionbeforeskip}
3852 % \changes{v3.15}{2014/11/24}{added}
3853 % \changes{v3.17}{2015/03/25}{\cs{scr@part@sectionafterskip} renamed to
3854 % \cs{scr@part@afterskip}}
3855 % \begin{macro}{\scr@part@sectionindent}
3856 % \changes{v3.15}{2014/11/24}{added}
3857 % \changes{v3.17}{2015/03/24}{removed}
3858 % \end{macro}^^A \scr@part@sectionindent
3859 % \begin{macro}{\scr@part@innerskip}
3860 % \changes{v3.17}{2015/03/24}{added}
3861 % \begin{macro}{\scr@part@style}
3862 % \changes{v3.15}{2014/11/24}{added}
3863 % All the skips and the page style are used by \cs{DeclareSectionCommand}
3864 % resp. the style \texttt{part}. We define it as early as possible. Even the
3865 % style of \cs{part} is already defined here.
3866 % \begin{description}
3867 % \item[ToDo:] Do we need them in the \texttt{prepare} run or can we move then
3868 % even to the \texttt{body} run?
3869 % \item[ToDo:] Do we really need to define \cs{scr@part@style}?
3870 % \end{description}
3871 % \begin{macrocode}
3872 %<*prepare>
3873 \newcommand*{\scr@part@beforeskip}{%
3874 %<article> 4ex
3875 % \end{macrocode}
3876 % \begin{description}
3877 % \item[Note:] The |+\baselineskip| is needed, to stay as compatible as
3878 % possible with prior definitions of \cs{chapterheadstartvskip}.
3879 % \end{description}
3880 % \begin{macrocode}
3881 %<report|book> \z@ \@plus 1fil + \baselineskip
3882 }
3883 %<book|report>\newcommand*{\scr@part@innerskip}{20\p@}
3884 \newcommand*{\scr@part@afterskip}{%
3885 %<article> 3ex
3886 %<report|book> \z@ \@plus 1fil
3887 }
3888 \newcommand*{\scr@part@style}{part}
3889 % \end{macrocode}
3890 % \end{macro}^^A \scr@part@style
3891 % \end{macro}^^A \scr@part@afterskip
3892 % \end{macro}^^A \scr@part@innerskip
3893 % \end{macro}^^A \scr@part@beforeskip
3894 % \begin{macrocode}
3895 \newcommand*{\partheadstartvskip}{%
3896 %<article> \addvspace{\@tempskipa}%
3897 %<report|book> \null\vskip-\baselineskip\vskip\@tempskipa
3898 }
3899 \newcommand*{\partheadmidvskip}{%
3900 \par\nobreak
3901 %<book|report> \vskip\@tempskipa
3902 }
3903 \newcommand*{\partheadendvskip}{%
3904 %<article> \vskip\@tempskipa
3905 %<report|book> \vskip\@tempskipa\newpage
3906 }
3907 %<*report|book>
3908 \newcommand*{\partheademptypage}{%
3909 \if@twoside\if@openright
3910 \null%
3911 \thispagestyle{empty}%
3912 \newpage
3913 \fi\fi
3914 }
3915 %</report|book>
3916 %</prepare>
3917 % \end{macrocode}
3918 % \end{command}^^A \partheademptypage
3919 % \end{command}^^A \partheadmidvskip
3920 % \end{command}^^A \partheadstartvskip,\partheadendvskip
3921 %
3922 %
3923 % \begin{macro}{\scr@startpart}
3924 % \changes{v2.8d}{2001/07/05}{using \cs{partpagestyle}}
3925 % \changes{v2.8p}{2001/09/27}{preamble above heading}
3926 % \changes{v3.13a}{2014/09/11}{using \cs{SecDef}}
3927 % \changes{v3.18}{2015/05/23}{added}
3928 % \changes{v3.19}{2015/08/25}{ignoring empty \cs{partpagestyle}}
3929 % \changes{v3.26}{2018/10/14}{supporting option \opt{afterindent}}
3930 % \changes{v3.28}{2019/11/18}{\cs{ifstr} renamed to \cs{Ifstr}}
3931 % The macro
3932 % \begin{quote}
3933 % \cs{scr@startpart}\marg{part command name}
3934 % \end{quote}
3935 % is now part of the style \texttt{part}. However, the main parts
3936 % of the code are from the original definition of \cs{part}. It has only one
3937 % argument: The name of the part command, i.e., \texttt{part}. All arguments
3938 % to the part command will be processed later.
3939 % \begin{macrocode}
3940 %<*body>
3941 \newcommand*{\scr@startpart}[1]{%
3942 \ExecuteDoHook{heading/preinit/#1}%
3943 %<article> \par
3944 %<*book|report>
3945 \if@openright\cleardoublepage\else\clearpage\fi
3946 \scr@ifundefinedorrelax{#1pagestyle}{}{%
3947 \Ifstr{#1pagestyle}{}{}{%
3948 \thispagestyle{\@nameuse{#1pagestyle}}%
3949 }%
3950 }%
3951 \if@twocolumn
3952 \onecolumn
3953 \@tempswatrue
3954 \else
3955 \@tempswafalse
3956 \fi
3957 %</book|report>
3958 \@tempskipa=\glueexpr\@nameuse{scr@#1@beforeskip}\relax
3959 \@ifundefined{scr@#1@afterindent}{\@afterindentfalse}{%
3960 \csname scr@#1@afterindent\endcsname
3961 {\@afterindenttrue}{\@afterindentfalse}{%
3962 \@afterindenttrue
3963 \ifdim\@tempskipa<\z@
3964 \@tempskipa=-\@tempskipa
3965 \@afterindentfalse
3966 \fi
3967 }%
3968 }%
3969 \ExecuteDoHook{heading/postinit/#1}%
3970 \partheadstartvskip
3971 %<*book|report>
3972 \vbox to\z@{\vss\use@preamble{#1@o}\strut\par}%
3973 \vskip-\baselineskip\nobreak
3974 %</book|report>
3975 \expandafter\SecDef\csname @#1\expandafter\endcsname\csname @s#1\endcsname
3976 }
3977 % \end{macrocode}
3978 %
3979 % \begin{macro}{\scr@@startpart}
3980 % \changes{v2.8q}{2001/11/13}{\cs{@parskipfalse}\cs{@parskip@indent}}
3981 % \changes{v2.95}{2002/08/13}{\cs{centering} and \cs{@parskipfalse}%
3982 % \cs{@parskip@indent} switched}
3983 % \changes{v2.95}{2004/11/05}{\cs{@parskipfalse} and \cs{@parskip@indent}
3984 % replaced}
3985 % \changes{v3.18}{2015/05/23}{added}
3986 % \changes{v3.27}{2019/07/08}{support for option \opt{nonumber}}
3987 % The macro
3988 % \begin{quote}
3989 % \cs{scr@@startpart}\marg{part command name}\oarg{extended optional
3990 % argument}\marg{part heading}
3991 % \end{quote}
3992 % is now part of the style \texttt{part}. However, the main parts
3993 % of the code are from the original definition of \cs{@part}. Therefore it has
3994 % the mandatory and optional arguments of a non-star variant of, i.e.,
3995 % \cs{part} but an additional first argument.
3996 % \begin{description}
3997 % \item[Note:] \meta{extended optional argument} is named as optional, however
3998 % here it is already mandatory, because it is a delimited argument.
3999 % \end{description}
4000 % \begin{macrocode}
4001 \newcommand{\scr@@startpart}{}
4002 \long\def\scr@@startpart#1[#2]#3{%
4003 \ExecuteDoHook{heading/branch/nostar/#1}%
4004 % \end{macrocode}
4005 % \changes{v3.10}{2011/08/30}{extended optional argument}
4006 % First of all, depending in \opt{headings=optionto\dots} we have different
4007 % defaults for the options.
4008 % \begin{macrocode}
4009 \ifnum \scr@osectarg=\z@
4010 \@scr@tempswafalse
4011 \else
4012 \scr@istest#2=\@nil
4013 \fi
4014 \@currentusenumbertrue
4015 \if@scr@tempswa
4016 \setkeys{KOMAarg.section}{tocentry={#3},head={#3},reference={#3},#2}%
4017 \else
4018 \ifcase \scr@osectarg\relax
4019 \setkeys{KOMAarg.section}{tocentry={#2},head={#2},reference={#2}}%
4020 \or
4021 \setkeys{KOMAarg.section}{tocentry={#3},head={#2},reference={#3}}%
4022 \or
4023 \setkeys{KOMAarg.section}{tocentry={#2},head={#3},reference={#2}}%
4024 \or
4025 \setkeys{KOMAarg.section}{tocentry={#2},head={#2},reference={#2}}%
4026 \fi
4027 \fi
4028 % \end{macrocode}
4029 % \changes{v2.8e}{2001/07/10}{using \cs{@maybeautodot}}
4030 % \changes{v3.28}{2019/11/19}{\cs{ifnumbered} renamed to
4031 % \cs{Ifnumbered}}
4032 % \changes{v3.31}{2020/06/02}{\cs{@maybeautodot}\cs{thepart} removed}
4033 % For numbered headings we have to increase the counter and write a process
4034 % information to the \file{log} and the terminal.
4035 % \begin{macrocode}
4036 \Ifnumbered{#1}{%
4037 \refstepcounter{#1}%
4038 \expandafter\@maybeautodot\csname the#1\endcsname
4039 \typeout{#1 \csname the#1\endcsname.}%
4040 % \end{macrocode}
4041 % \changes{v3.08}{2010/11/01}{using \cs{addparttocentry}}
4042 % \changes{v3.18}{2015/05/20}{using \cs{add\meta{Name}tocentry} for
4043 % \cs{typeout}}
4044 % \changes{v3.31}{2020/06/06}{using \cs{\dots tocformat}}
4045 % And if the ToC entry is not empty add a numbered entry to the table of
4046 % contents.
4047 % \begin{description}
4048 % \item[ToDo:] Move \cs{autodot} to the definition of \cs{\dots tocformat}.
4049 % \end{description}
4050 % \begin{macrocode}
4051 \ifx\@currenttocentry\@empty\else
4052 \@ifundefined{#1tocformat}{%
4053 \expandafter\gdef\csname #1tocformat\endcsname
4054 {\csname the#1\endcsname}%
4055 }{}%
4056 \scr@ifundefinedorrelax{add#1tocentry}{%
4057 \addtocentrydefault{#1}%
4058 }{%
4059 \@nameuse{add#1tocentry}%
4060 }{\csname\@ifundefined{#1tocformat}{the#1}{#1tocformat}\endcsname}%
4061 {\@currenttocentry}%
4062 \fi
4063 }{%
4064 % \end{macrocode}
4065 % \changes{v3.18}{2015/05/23}{execute counter reset list for not numbered
4066 % headings}
4067 % For not numbered headings we still have to process the reset list of the
4068 % counter and write a process information to the \file{log} and the terminal.
4069 % \begin{macrocode}
4070 %<!v4> \expandafter\ifnum\scr@v@is@ge{3.18}\relax
4071 \begingroup
4072 \let\@elt\@stpelt
4073 \csname cl@#1\endcsname
4074 \endgroup
4075 %<!v4> \fi
4076 \typeout{#1 without number}%
4077 % \end{macrocode}
4078 % \changes{v3.08}{2010/11/01}{using \cs{addparttocentry}}
4079 % \changes{v3.18}{2015/05/23}{generalized \cs{addparttocentry}}
4080 % And before writing a not numbered entry to the table of contents we have to
4081 % execute also the \pkg{hyperref} hook \cs{hy@insteadofrefstepcounter}.
4082 % \begin{description}
4083 % \item[Note:] \pkg*{scrhack} uses the existence of this command to detect a
4084 % \KOMAScript{} class. Shouldn't this be changed using, e.g.,
4085 % \cs{KOMAClassName}?
4086 % \end{description}
4087 % \begin{macrocode}
4088 \ifx\@currenttocentry\@empty\else
4089 \hy@insteadofrefstepcounter{#1}%
4090 \scr@ifundefinedorrelax{add#1tocentry}{%
4091 \addtocentrydefault{#1}%
4092 }{%
4093 \@nameuse{add#1tocentry}%
4094 }{}{\@currenttocentry}%
4095 \fi
4096 }%
4097 % \end{macrocode}
4098 % \changes{v2.2c}{1995/05/25}{support for CJK}
4099 % \changes{v2.4b}{1996/03/29}{\cs{size@partnumer} replaced by
4100 % \cs{size@partnumber}}
4101 % \changes{v2.8p}{2001/09/22}{\cs{sectfont} used before \cs{size@part} or
4102 % \cs{size@partnumber}}
4103 % \changes{v2.8q}{2002/02/28}{\cs{nobreak} after \cs{sectfont}}
4104 % \changes{v3.18}{2015/05/23}{\cs{size@\dots} replaced by \cs{usekomafont}}
4105 % \changes{v3.21}{2016/06/12}{missing \cs{nobreak} added}
4106 % \changes{v3.25}{2017/09/07}{defining \cs{IfUseNumber} locally}
4107 % \changes{v3.25}{2017/09/07}{\cs{sectfont} replaced by \cs{usekomafont}}
4108 % \changes{v3.25}{2017/09/07}{using \cs{partlineswithprefixformat}}
4109 % \changes{v3.25}{2018/02/12}{using correct fontelement}
4110 % \changes{v3.28}{2019/11/19}{\cs{ifnumbered} renamed to
4111 % \cs{Ifnumbered}}
4112 % Now the main printing code.
4113 % \begin{description}
4114 % \item[ToDo:] This code is almost the same as \cs{scr@@startchapter}. Only
4115 % the procession of the reset list was there already with
4116 % \KOMAScript~v3.15. And in \cs{scr@@startchapter} we are using
4117 % \cs{@make\meta{name}head} here. So maybe we should do the same here and
4118 % really use the same definition instead of having it twice.
4119 % \end{description}
4120 % \begin{macrocode}
4121 \begingroup
4122 \def\IfUseNumber{\Ifnumbered{#1}}%
4123 \ExecuteDoHook{heading/begingroup/#1}%
4124 \setparsizes{\z@}{\z@}{\z@\@plus 1fil}\par@updaterelative
4125 \raggedpart
4126 \normalfont\usekomafont{disposition}{\nobreak
4127 \IfUseNumber{%
4128 \partlineswithprefixformat{#1}{%
4129 \usekomafont{#1prefix}{\nobreak\@nameuse{#1format}}%
4130 %<book|report> \setlength{\@tempskipa}{\@nameuse{scr@#1@innerskip}}%
4131 \partheadmidvskip
4132 }{%
4133 \usekomafont{#1}{\nobreak\interlinepenalty \@M#3\strut\@@par}%
4134 }%
4135 }{%
4136 \partlineswithprefixformat{#1}{}{%
4137 \usekomafont{#1}{\nobreak\interlinepenalty \@M#3\strut\@@par}%
4138 }
4139 }%
4140 % \end{macrocode}
4141 % \changes{v3.10}{2011/08/30}{using\cs{@mkboth{}{}} if \cs{partmark} is
4142 % \cs{@gobble}}
4143 % The running head.
4144 % \begin{macrocode}
4145 \expandafter\ifx\csname #1mark\endcsname\@gobble
4146 \@mkboth{}{}%
4147 \else
4148 \csname #1mark\expandafter\endcsname\expandafter{\@currentheadentry}%
4149 \fi
4150 }%
4151 \ExecuteDoHook{heading/endgroup/#1}%
4152 \endgroup
4153 % \end{macrocode}
4154 % The final distance.
4155 % \begin{macrocode}
4156 %<*article>
4157 \nobreak
4158 \@tempskipa=\glueexpr\@nameuse{scr@#1@afterskip}\relax\relax
4159 \ifdim\@tempskipa<\z@\@tempskipa-\@tempskipa\fi
4160 \partheadendvskip
4161 %</article>
4162 %<book|report> \@nameuse{@end#1}%
4163 % \end{macrocode}
4164 % \changes{v3.26}{2018/10/14}{using \@cs{@afterheading} with
4165 % \cls*{scrbook} or \cls*{scrreprt}}
4166 % And \cs{@afterheading} for all classes.
4167 % \begin{macrocode}
4168 \@afterheading
4169 }
4170 % \end{macrocode}
4171 % \end{macro}^^A \scr@@startpart
4172 %
4173 % \begin{macro}{\scr@@startspart}
4174 % \changes{v2.4n}{1997/05/28}{added \cs{chaptermark} resp.
4175 % \cs{sectionmark} to star variant}
4176 % \changes{v2.6a}{2000/01/20}{using \cs{@mkboth} to delete the running head}
4177 % \changes{v2.8q}{2001/11/13}{\cs{@parskipfalse}\cs{@parskip@indent}}
4178 % \changes{v2.95}{2002/08/13}{\cs{centering} and
4179 % \cs{@parskipfalse}\cs{@parskip@indent} swapped}
4180 % \changes{v2.95}{2004/11/05}{\cs{@parskipfalse} and\cs{@parskip@indent}
4181 % replaced}
4182 % \changes{v3.18}{2015/05/23}{added}
4183 % The macro
4184 % \begin{quote}
4185 % \cs{scr@@startspart}\marg{part command name}\marg{part heading}
4186 % \end{quote}
4187 % is now part of the style \texttt{part}. However, the main parts
4188 % of the code are from the original definition of \cs{@spart}. Therefore it has
4189 % the mandatory argument of a star variant of, i.e., \cs{part} but an
4190 % additional first argument.
4191 % \begin{macrocode}
4192 \newcommand{\scr@@startspart}[2]{%
4193 \ExecuteDoHook{heading/branch/star/#1}%
4194 % \end{macrocode}
4195 % Some users don't learn to use \cs{addpart} for not numbered parts with entry
4196 % to the table of contents but insist in using \cs{addcontentsline}. Despite
4197 % this should not be used, because at least \cs{addparttocentry} should be
4198 % used, we tolerate this by using our \pkg{hyperref} hook.
4199 % \begin{description}
4200 % \item[ToDo:] I don't understand why \pkg{hyperref} uses a group here and
4201 % locally sets \cs{@mkboth} to \cs{@gobbletwo}. However, I've copied this.
4202 % \end{description}
4203 % \begin{macrocode}
4204 \begingroup
4205 \let\@mkboth\@gobbletwo
4206 \hy@insteadofrefstepcounter{#1}%
4207 \endgroup
4208 % \end{macrocode}
4209 % \changes{v3.21}{2016/06/12}{missing \cs{nobreak} added}
4210 % \changes{v3.25}{2017/09/07}{difining \cs{IfUseNumber} locally}
4211 % \changes{v3.25}{2017/09/07}{\cs{sectfont} replaced by \cs{usekomafont}}
4212 % \changes{v3.25}{2017/09/07}{using \cs{partlineswithprefixformat}}
4213 % Now the printing similar to \cs{scr@@startpart}.
4214 % \begin{macrocode}
4215 \begingroup
4216 \let\IfUseNumber\@secondoftwo
4217 \ExecuteDoHook{heading/begingroup/#1}%
4218 \setparsizes{\z@}{\z@}{\z@\@plus 1fil}\par@updaterelative
4219 \raggedpart
4220 \normalfont\usekomafont{disposition}{%
4221 \nobreak
4222 \partlineswithprefixformat{#1}{}{%
4223 \usekomafont{#1}{\nobreak\interlinepenalty \@M#2\strut\@@par}%
4224 }%
4225 \@mkboth{}{}%
4226 }%
4227 \ExecuteDoHook{heading/endgroup/#1}%
4228 \endgroup
4229 %<*article>
4230 \nobreak
4231 \@tempskipa=\glueexpr\csname scr@#1@afterskip\endcsname\relax\relax
4232 \ifdim\@tempskipa<\z@\@tempskipa-\@tempskipa\fi
4233 \partheadendvskip
4234 \@afterheading
4235 %</article>
4236 %<book|report> \@nameuse{@end#1}%
4237 }
4238 % \end{macrocode}
4239 % \end{macro}^^A \scr@@startspart
4240 %
4241 % \begin{command}{\partlineswithprefixformat}
4242 % \changes{v3.25}{2017/09/07}{added}
4243 % Command
4244 % \begin{quote}
4245 % \cs{partlineswithprefixformat}\marg{command name}\marg{number}\marg{text}
4246 % \end{quote}
4247 % is used to print a part heading with a prefix line. \meta{number} is the
4248 % completely formatted prefix line inclusive the vertical distance below. The
4249 % \meta{text} is the text of the heading also formatted and with final
4250 % \cs{@@par}. But if the user uses more paragraphs than this final one, the
4251 % user is responsible to prevent page breaks!
4252 % \begin{macrocode}
4253 \newcommand{\partlineswithprefixformat}[3]{%
4254 #2#3%
4255 }
4256 % \end{macrocode}
4257 % \end{command}^^A \partlineswithprefixformat
4258 %
4259 % \begin{macro}{\scr@@endpart}
4260 % \changes{v2.3g}{1996/01/14}{\cs{@endpart} not defined for \cls*{scrartcl}}
4261 % \changes{v2.4e}{1996/07/02}{supporting option \opt{openany}}
4262 % \changes{v2.6c}{2000/06/10}{\cs{@endpart} respects \opt{open\quotechar=right}}
4263 % \changes{v2.8p}{2001/09/27}{\cs{vbox} added}
4264 % \changes{v2.8p}{2001/09/27}{\cs{@part@preamble} replaced by \cs{use@preamble}}
4265 % \changes{v3.02}{2009/01/01}{using \cs{partheademptypage}}
4266 % \changes{v3.18}{2015/05/23}{added}
4267 % Before \KOMAScript~v3.18 this code was part of \cs{part}. \cls*{scrbook} and
4268 % \cls*{scrreprt} use this macro to finalize the heading, e.g., print a
4269 % preamble, to the final distance or new page and add an empty retro
4270 % page. \cls*{scrartcl} does not have such a command, because with
4271 % \cls*{scrartcl} parts are simple headings not pages. As usual the argument
4272 % is the name of the part command, e.g., \texttt{part}.
4273 % \begin{macrocode}
4274 %<*book|report>
4275 \newcommand*{\scr@@endpart}[1]{%
4276 \vbox to\z@{\use@preamble{#1@u}\vss}%
4277 \@tempskipa=\glueexpr\csname scr@#1@afterskip\endcsname\relax\relax
4278 \ifdim\@tempskipa<\z@\@tempskipa-\@tempskipa\fi
4279 \partheadendvskip
4280 \partheademptypage
4281 \if@tempswa
4282 \twocolumn
4283 \fi
4284 }
4285 %</book|report>
4286 % \end{macrocode}
4287 % \end{macro}^^A \scr@@endpart
4288 % \end{macro}^^A \scr@startpart
4289 %
4290 %
4291 % \begin{macro}{\hy@insteadofrefstepcounter}
4292 % \changes{v3.18}{2015/05/22}{added to be used by \pkg{hyperref}}
4293 % \begin{macro}{\scr@chapter@before@hyperref@patch}
4294 % \changes{v3.27}{2019/07/24}{added to be used by \pkg*{scrhack}}
4295 % \begin{macro}{\scr@chapter@after@hyperref@patch}
4296 % \changes{v3.27}{2019/07/24}{added to be used by \pkg*{scrhack}}
4297 % \changes{v3.32}{2020/09/11}{\cs{AfterPackage!} replaced by
4298 % \cs{AfterAtEndOfPackage}}
4299 % Usually \pkg{hyperref} uses \cs{refstepcounter} to process extra codes for
4300 % anchors and bookmarks. However, if a not numbered heading is used,
4301 % \pkg{hyperref} cannot use \cs{refstepcounter} but still has to add
4302 % code. Usually \pkg{hyperref} patchs several commands like \cs{@chapter},
4303 % \cs{@schapter}, \cs{@part}, \cs{@spart} etc. to do so. But I think, it would
4304 % be better to provide a hook for this, \pkg*{hyperref} can change. So we've
4305 % designed \cs{hy@insteadofrefstepcounter}. Unfortunately \pkg{hyperref}
4306 % currently does not care for this, but still does its patches. So we need to
4307 % prevent \pkg{hyperref} from doing so and additionally define
4308 % \cs{hy@insteadofrefstepcounter} ourselves. But because \cs{autoref} is
4309 % nonsense for not numbered headings, I do not use \cs{Hy@chapapp} for
4310 % \cs{Hy@MakeCurrentHrefAuto}.
4311 % \begin{description}
4312 % \item[ToDo:] Explain the Oberdiek support team, what we are doing here and
4313 % what they should do.
4314 % \end{description}
4315 % \begin{macrocode}
4316 \newcommand*{\hy@insteadofrefstepcounter}[1]{}
4317 \let\hy@insteadofrefstepcounter\@gobble
4318 \newcommand*{\scr@chapter@before@hyperref@patch}{%
4319 \let\scr@orig@chapter\@chapter
4320 \let\scr@orig@schapter\@schapter
4321 \let\scr@orig@addchap\@addchap
4322 }
4323 \BeforePackage{hyperref}{\scr@chapter@before@hyperref@patch}
4324 \newcommand*{\scr@chapter@after@hyperref@patch}{%
4325 \let\@chapter\scr@orig@chapter
4326 \let\@schapter\scr@orig@schapter
4327 \let\@addchap\scr@orig@addchap
4328 \ifx\hy@insteadofrefstepcounter\@gobble
4329 \renewcommand*{\hy@insteadofrefstepcounter}[1]{%
4330 \Hy@MakeCurrentHrefAuto{##1*}%
4331 \Hy@raisedlink{%
4332 \hyper@anchorstart{\@currentHref}\hyper@anchorend
4333 }%
4334 }%
4335 \fi
4336 }
4337 \AfterAtEndOfPackage{hyperref}{\scr@chapter@after@hyperref@patch}
4338 % \end{macrocode}
4339 % \end{macro}^^A \scr@after@hyperref@patch
4340 % \end{macro}^^A \scr@before@hyperref@patch
4341 % \end{macro}^^A \hy@insteadofrefstepcounter
4342 %
4343 % \begin{command}{\addparttocentry}
4344 % \changes{v3.08}{2010/11/01}{added}
4345 % We do not use \cs{addcontentsline} directly for the entries to the table of
4346 % contents. Using
4347 % \begin{quote}
4348 % \cs{addparttocentry}\marg{number}\marg{text}
4349 % \end{quote}
4350 % allows easy manipulation of such entries and additional actions. If the
4351 % \meta{number} is completely empty no number should be used. Internally the
4352 % generic \cs{addtocentrydefault} it used, which uses \cs{nonumberline}
4353 % instead of \cs{numberline} in this case. See \file{scrkernel-listsof.dtx}
4354 % for more information.
4355 % \begin{macrocode}
4356 \newcommand*{\addparttocentry}[2]{%
4357 \addtocentrydefault{part}{#1}{#2}%
4358 }
4359 % \end{macrocode}
4360 % \end{command}^^A \addparttocentry
4361 %
4362 %
4363 % \begin{command}{\part}
4364 % \changes{v3.18}{2015/05/23}{indirect definition}
4365 % \begin{macro}{\@part,\@spart,\@endpart}
4366 % \changes{v3.18}{2015/05/23}{indirect definition}
4367 % \begin{command}{\setpartpreamble}
4368 % \changes{v2.8f}{2001/07/12}{added}
4369 % \changes{v2.8p}{2001/09/27}{using \cs{use@preamble}}
4370 % \changes{v3.18}{2015/05/23}{indirect definition}
4371 % \begin{macro}{\part@preamble,\part@u@preamble}
4372 % \changes{v2.8p}{2001/09/27}{added}
4373 % \changes{v2.8p}{2001/09/27}{\cs{part@preamble} renamed to \cs{part@u@preamble}}
4374 % \changes{v3.12a}{2014/02/14}{name fixed}
4375 % \changes{v3.18}{2015/05/23}{indirect definition}
4376 % \begin{macro}{\part@o@preamble}
4377 % \changes{v2.8p}{2001/09/27}{added}
4378 % \changes{v3.12a}{2014/02/14}{name fixed}
4379 % \changes{v3.18}{2015/05/23}{indirect definition}
4380 % All these commands and macros are not defined explicitly but by using
4381 % \cs{DeclareSectionCommand} later. See also
4382 % \cs{scr@dsc@def@style@part@command} and \cs{setpartpreamble}.
4383 % \end{macro}^^A \part@o@preamble
4384 % \end{macro}^^A \part@u@preamble
4385 % \end{command}^^A \setpartpreamble
4386 % \end{macro}^^A \@part,\@spart,\@endpart
4387 % \end{command}^^A \part
4388 %
4389 % \begin{command}{\addpart}
4390 % \changes{v2.8c}{2001/06/29}{added}
4391 % \changes{v2.8d}{2001/07/05}{using \cs{partpagestyle}}
4392 % \changes{v2.95a}{2006/07/10}{support of preamble added}
4393 % \changes{v3.11b}{2012/07/29}{missing negativ \cs{vskip} added}
4394 % \changes{v3.13a}{2014/09/11}{using \cs{SecDef}}
4395 % \changes{v3.15a}{2015/01/22}{distance adaption}
4396 % \changes{v3.18}{2015/05/25}{redefinition}
4397 % \begin{macro}{\@addpart}
4398 % \changes{v2.8c}{2001/06/29}{added}
4399 % \changes{v2.8l}{2001/08/17}{first ToC then output}
4400 % \changes{v2.95}{2004/07/20}{support for running head}
4401 % \changes{v3.00}{2008/07/01}{\pkg{hyperref} workaround}
4402 % \changes{v3.08}{2010/11/02}{using \cs{addparttocentry}}
4403 % \changes{v3.10}{2011/08/30}{extended optional argument}
4404 % \changes{v3.10}{2011/08/30}{using \cs{@mkboth{}{}} if \cs{partmark} is
4405 % \cs{@gobble}}
4406 % \changes{v3.17}{2015/04/20}{using \cs{addpartmark} but never \cs{@mkboth}}
4407 % \changes{v3.18}{2015/05/25}{redefinition}
4408 % \begin{macro}{\@saddpart}
4409 % \changes{v2.8c}{2001/06/29}{added}
4410 % \changes{v3.18}{2015/05/25}{redefinition}
4411 % The improved not numbered version of \cs{part}. Note: This could also be
4412 % done using the extended optional argument of \cs{part} and option
4413 % \opt{nonumber=true}. So this command becomes more and more deprecated.
4414 % \begin{macrocode}
4415 \newcommand\addpart{%
4416 \SecDef\@addpart\@saddpart
4417 }
4418 \newcommand*{\@addpart}{}
4419 \long\def\@addpart[#1]#2{%
4420 \edef\reserved@a{%
4421 \unexpanded{%
4422 \part[{#1}]{#2}%
4423 \c@secnumdepth=
4424 }\the\c@secnumdepth\relax
4425 }%
4426 \c@secnumdepth=\numexpr \partnumdepth-1\relax
4427 \reserved@a
4428 }
4429 \newcommand{\@saddpart}[1]{%
4430 \part*{#1}%
4431 \addpartmark{}%
4432 }
4433 % \end{macrocode}
4434 % \end{macro}^^A \@saddpart
4435 % \end{macro}^^A \@addpart
4436 % \end{command}^^A \addpart
4437 %
4438 %
4439 % \begin{macro}{\l@part}
4440 % \changes{v2.97c}{2007/06/21}{\cs{sectfont}\cs{large} replaced by font
4441 % element \fnt{partentry}}
4442 % \changes{v2.97c}{2007/06/21}{using font element \fnt{partentrypagenumber}}
4443 % \changes{v3.15}{2014/12/23}{using \cs{parttocdepth} and
4444 % \cs{scr@part@numwidth}}
4445 % \changes{v3.20}{2015/10/06}{replaced by usage of ToC style}
4446 % \begin{macro}{\scr@part@tocindent}
4447 % \changes{v3.15}{2014/12/02}{added}
4448 % \changes{v3.18}{2015/06/09}{indirect by \cs{DeclareSectionCommand}}
4449 % \end{macro}^^A \scr@part@tocindent
4450 % \begin{macro}{\scr@part@tocnumwidth}
4451 % \changes{v3.15}{2014/12/02}{added}
4452 % \changes{v3.18}{2015/06/09}{indirect by\cs{DeclareSectionCommand}}
4453 % These macros are not longer defined explicitly but by
4454 % \cs{DeclareTOCEntryStyle} and indirectly by \cs{DeclareSectionCommand}.
4455 % \end{macro}
4456 % \end{macro}^^A \l@part
4457 %
4458 %
4459 % \begin{counter}{part}
4460 % \begin{command}{\thepart}
4461 % \begin{command}{\partformat}
4462 % \changes{v2.3c}{1995/08/06}{auto dot feature}
4463 % \changes{v2.5f}{1999/02/14}{orphan spaces removed}
4464 % \changes{v2.7h}{2001/04/22}{missing backslash of \cs{autodot} fixed}
4465 % Because we don't use the default Arabic numbering, we still define the
4466 % counter for \cs{part}, it's printing and the formatting explicitly.
4467 % \begin{macrocode}
4468 \newcounter{part}
4469 \renewcommand*{\thepart}{\@Roman\c@part}
4470 \newcommand*{\partformat}{\partname~\thepart\autodot}
4471 % \end{macrocode}
4472 % \end{command}^^A \partformat
4473 % \end{command}^^A \thepart
4474 % \end{counter}{part}
4475 %
4476 %
4477 % \begin{command}{\partname}
4478 % \changes{v3.36}{2022/03/15}{explicit definition for English languages}
4479 % The name of a part used for the prefix line and maybe for the ToC entry.
4480 % \begin{macrocode}
4481 \newcommand*\partname{Part}
4482 \providecaptionname{american,australian,british,canadian,english,newzealand,%
4483 UKenglish,ukenglish,USenglish,usenglish}\partname{Part}
4484 % \end{macrocode}
4485 % \end{command}^^A \partname
4486 %
4487 %
4488 % \begin{command}{\partmark}
4489 % \changes{v2.9r}{2004/07/20}{added}
4490 % \changes{v3.18}{2015/05/24}{default changed from \cs{@gobble} to
4491 % \cs{@mkboth{}{}}}
4492 % Initially \cs{part} should simply empty the left and right mark if an
4493 % automatic running head is used. This is independent from the page style.
4494 % \begin{macrocode}
4495 \newcommand*{\partmark}[1]{\@mkboth{}{}}
4496 % \end{macrocode}
4497 % \end{command}^^A \partmark
4498 %
4499 % \begin{command}{\addpartmark}
4500 % \changes{v3.17}{2015/04/20}{added}
4501 % \changes{v3.18}{2015/05/24}{depends on \cs{partnumdepth}}
4502 % To be used to add the marks with \cs{addpart}. Locally we define
4503 % \cs{if@mainmatter}, because it makes life easier for users or package
4504 % authors, who (re-)define \cs{partmark}.
4505 % \begin{macrocode}
4506 \newcommand*\addpartmark[1]{%
4507 \begingroup
4508 \expandafter\let\csname if@mainmatter\expandafter\endcsname
4509 \csname iffalse\endcsname
4510 \c@secnumdepth=\numexpr \partnumdepth-1\relax
4511 \partmark{#1}%
4512 \endgroup
4513 }
4514 % \end{macrocode}
4515 % \end{command}^^A \addpartmark
4516 %
4517 %
4518 % \begin{command}{\raggedpart}
4519 % \changes{v2.95a}{2006/07/10}{added}
4520 % Style \texttt{part} does not use \cs{raggedsection} but
4521 % \cs{raggedpart}. However for \cls*{scrartcl} the default is the same. But
4522 % \cls*{scrbook} and \cls*{scrreprt} use \cs{centering} as default.
4523 % \begin{description}
4524 % \item[Note:] Because of using \cs{let} inside a class, \cs{raggedright}
4525 % should be without hyphenation when we define \cs{raggedpart}.
4526 % \end{description}
4527 % \begin{macrocode}
4528 \newcommand*{\raggedpart}{}
4529 %<article>\let\raggedpart\raggedsection
4530 %<report|book>\let\raggedpart\centering
4531 % \end{macrocode}
4532 % \end{command}
4533 %
4534 % \begin{fontelement}{partentry}
4535 % \changes{v2.97c}{2007/06/21}{added}
4536 % \changes{v3.06}{2010/06/09}{\fnt{sectioning} replaced by \fnt{disposition}}
4537 % \cs{part} entries to the table of contents are \cs{large}.
4538 % \begin{macrocode}
4539 \newkomafont{partentry}{\usekomafont{disposition}\large}
4540 % \end{macrocode}
4541 % \end{fontelement}
4542 %
4543 % \begin{fontelement}{partentrypagenumber}
4544 % \changes{v2.97c}{2007/06/21}{added}
4545 % The page number of the ToC entry should be unchanged.
4546 % \begin{macrocode}
4547 \newkomafont{partentrypagenumber}{}
4548 %</body>
4549 % \end{macrocode}
4550 % \end{fontelement}
4551 %
4552 %
4553 % \subsection{Chapters}
4554 %
4555 % Classes \cls*{scrbook} and \cls*{scrreprt} provide chapters. These are
4556 % realized by \cs{DeclareSectionCommand} and the \texttt{chapter} style. The
4557 % style is represented by \cs{scr@dsc@def@style@chapter@command} and several
4558 % helpers.
4559 % \begin{description}
4560 % \item[Note:] Package \pkg{hyperref} is not really compatible with
4561 % \KOMAScript{} classes, because it redefines \cs{@schapter} and
4562 % \cs{@chapter} incompatible. However, currently \KOMAScript{} has a build
4563 % in workaround for this. But this workaround itself depends on internal
4564 % code of \pkg{hyperref}. It would be better, if \pkg{hyperref} would
4565 % provide an interface for class authors and would redefine internal macros
4566 % of classes only as fallback if classes do not use this
4567 % interface. \KOMAScript{} also provides an alternative. \pkg*{hyperref}
4568 % could redefine a single command \cs{hy@insteadofrefstepcounter}.
4569 % \item[Note:] Any package, that changes internal macros like \cs{@chapter},
4570 % \cs{@schapter}, \cs{@makechapterhead}, \cs{@makeschapterhead} is
4571 % incompatible with \KOMAScript{} classes. Neither \KOMAScript{} nor the
4572 % \KOMAScript{} author is responsible for this. Package authors are welcome
4573 % to ask for interfaces they need, e.g., a good idea would be to define a
4574 % own headings style.
4575 % \end{description}
4576 %
4577 % \begin{option}{chapterprefix}
4578 % \changes{v2.8}{2001/06/15}{added}
4579 % \changes{v2.95c}{2006/08/21}{changed to \pkg{keyval} option}
4580 % \changes{v3.18}{2015/05/22}{option correlates with style not level}
4581 % \changes{v3.39}{2022/11/11}{initial dot removed from member argument of
4582 % option storage commands}
4583 % \begin{macro}{\@chapterprefixtrue,\@chapterprefixfalse,\if@chapterprefix}
4584 % Initially \KOMAScript{} does not use the enormous chapter headings with
4585 % prefix line ``Chapter \meta{number}'' but a more subtle one. However, either
4586 % \opt{chapterprefix} or \opt{headings=twolinechapter} can be used to
4587 % reactivate the prefix line. The current setting is available via the boolean
4588 % switch \cs{if@chapterprefix}.
4589 % \begin{macrocode}
4590 %<*book|report>
4591 %<prepare>\newif\if@chapterprefix
4592 %<*option>
4593 \KOMA@key{chapterprefix}[true]{%
4594 \KOMA@set@ifkey{chapterprefix}{@chapterprefix}{#1}%
4595 \ifx\FamilyKeyState\FamilyKeyStateProcessed
4596 \KOMA@kav@replacebool{\KOMAClassFileName}%
4597 {chapterprefix}{@chapterprefix}%
4598 \KOMA@kav@remove{\KOMAClassFileName}%
4599 {headings}{twolinechapter}%
4600 \KOMA@kav@remove{\KOMAClassFileName}%
4601 {headings}{onelinechapter}%
4602 \KOMA@kav@xadd{\KOMAClassFileName}%
4603 {headings}{%
4604 \if@chapterprefix twolinechapter\else onelinechapter\fi
4605 }%
4606 \fi
4607 }
4608 \KOMA@kav@add{\KOMAClassFileName}{headings}{onelinechapter}%
4609 % \end{macrocode}
4610 % \begin{option}{nochapterprefix}
4611 % \changes{v2.8}{2001/06/15}{added}
4612 % \changes{v2.95c}{2006/08/21}{obsolete}
4613 % \changes{v3.01a}{2008/11/20}{deprecated}
4614 % \changes{v3.99}{2022/11/16}{removed from \KOMAScript~4}
4615 % Deprecated option for compatibility with \KOMAScript~2.9u only.
4616 % \begin{macrocode}
4617 %<!v4>\KOMA@DeclareDeprecatedOption{nochapterprefix}{chapterprefix=false}
4618 %</option>
4619 % \end{macrocode}
4620 % \end{option}^^A nochapterprefix
4621 % \end{macro}^^A \if@chapterprefix
4622 % \end{option}^^A chapterprefix
4623 %
4624 %
4625 % \begin{option}{appendixprefix}
4626 % \changes{v2.8}{2001/06/15}{added}
4627 % \changes{v2.95c}{2006/08/21}{re-implementation as \pkg{keyval} option}
4628 % \changes{v3.12}{2013/03/05}{usage of \cs{FamilyKeyState}}
4629 % \changes{v3.17}{2015/03/09}{internal value storage}
4630 % \changes{v3.34}{2021/04/30}{usage of \LaTeX{} hook, if available}
4631 % \changes{v3.34}{2021/04/30}{new value \opt{\quotechar=default} with \LaTeX{}
4632 % hooks}
4633 % \changes{v3.39}{2022/11/11}{initial dot removed from member argument of
4634 % option storage commands}
4635 % \changes{v3.44}{2025/05/13}{code for \LaTeX{} before 2020-10-01 removed}
4636 % If the appendix chapters should be with or without prefix line independent
4637 % from the chapters of the main part, option \opt{appendixprefix} can be
4638 % used. This does not set up a new boolean but just activates or deactivates
4639 % the boolean for chapters inside \cs{appendix}. From \KOMAScript{} v3.34 and
4640 % \LaTeX{} 2020/10/01 this is done using a new \LaTeX{} hook. Otherwise still
4641 % \cs{appendixmore} is used. Default is, using the settings for chapters.
4642 % \begin{macrocode}
4643 %<*option>
4644 \KOMA@key{appendixprefix}[true]{%
4645 \Ifstr{#1}{default}{%
4646 \KOMA@kav@removekey{\KOMAClassFileName}{appendixprefix}%
4647 \KOMA@kav@remove{\KOMAClassFileName}{headings}{twolineappendix}%
4648 \KOMA@kav@remove{\KOMAClassFileName}{headings}{onelineappendix}%
4649 \IfHookEmptyTF{\KOMAClassName/appendix}{}{%
4650 \RemoveFromHook{\KOMAClassName/appendix}[appendixprefix]%
4651 }%
4652 \FamilyKeyStateProcessed
4653 }{%
4654 \KOMA@set@ifkey{appendixprefix}{@tempswa}{#1}%
4655 \ifx\FamilyKeyState\FamilyKeyStateProcessed
4656 \KOMA@kav@xreplacevalue{\KOMAClassFileName}{appendixprefix}{#1}%
4657 \KOMA@kav@remove{\KOMAClassFileName}{headings}{twolineappendix}%
4658 \KOMA@kav@remove{\KOMAClassFileName}{headings}{onelineappendix}%
4659 \IfHookEmptyTF{\KOMAClassName/appendix}{}{%
4660 \RemoveFromHook{\KOMAClassName/appendix}[appendixprefix]%
4661 }%
4662 \if@tempswa
4663 \KOMA@kav@add{\KOMAClassFileName}{headings}{twolineappendix}%
4664 \AddToHook{\KOMAClassName/appendix}[appendixprefix]%
4665 {\@chapterprefixtrue}%
4666 \else
4667 \KOMA@kav@add{\KOMAClassFileName}{headings}{onelineappendix}%
4668 \AddToHook{\KOMAClassName/appendix}[appendixprefix]%
4669 {\@chapterprefixfalse}%
4670 \fi
4671 \fi
4672 }%
4673 }%
4674 % \end{macrocode}
4675 % \begin{option}{noappendixprefix}
4676 % \changes{v2.8}{2001/06/15}{added}
4677 % \changes{v2.95c}{2006/08/21}{obsolete}
4678 % \changes{v3.01a}{2008/11/20}{deprecated}
4679 % \changes{v3.99}{2022/11/16}{removed from \KOMAScript~4}
4680 % \begin{macrocode}
4681 %<!v4>\KOMA@DeclareDeprecatedOption{noappendixprefix}{appendixprefix=false}
4682 %</option>
4683 % \end{macrocode}
4684 % \end{option}^^A noappendixprefix
4685 % \end{option}^^A appendixprefix
4686 %
4687 %
4688 % \begin{fontelement}{chapter}
4689 % \changes{v2.8o}{2001/09/14}{added}
4690 % \changes{v2.96a}{2006/12/02}{undocumented support for last macro expects an
4691 % argument}
4692 % \begin{fontelement}{chapterprefix}
4693 % \changes{v2.8o}{2001/09/14}{added by macro}
4694 % \changes{v2.96a}{2006/12/02}{added}
4695 % Definition of the font elements used by \cs{chapter}. The settings are done
4696 % by option \opt{headings} later. Everything is prepared before this option
4697 % is used the first time. The manual definition is used, because of
4698 % compatibility with \KOMAScript{} 2.9u. However, using the old macros is
4699 % deprecated and not supported any longer.
4700 % \begin{macrocode}
4701 %<*prepare>
4702 \newcommand*{\size@chapter}{}
4703 \newcommand*{\scr@fnt@chapter}{\size@chapter}
4704 \newcommand*{\size@chapterprefix}{\size@chapter}
4705 \newcommand*{\scr@fnt@chapterprefix}{\size@chapterprefix}
4706 %</prepare>
4707 % \end{macrocode}
4708 % \end{fontelement}^^A chapterprefix
4709 % \end{fontelement}^^A chapter
4710 %
4711 %
4712 % \begin{command}{\chapterheadstartvskip}
4713 % \changes{v3.15}{2014/11/24}{defining and using \cs{scr@chapter@beforeskip}}
4714 % \begin{command}{\chapterheadmidvskip}
4715 % \changes{v3.15}{2014/11/20}{added}
4716 % \changes{v3.17}{2015/03/25}{defining and using \cs{scr@chapter@innerskip}}
4717 % \begin{command}{\chapterheadendvskip}
4718 % \changes{v3.11c}{2013/02/13}{\cs{chapterheadstartvskip} and
4719 % \cs{chapterheadendvskip} removed from \cls*{scrartcl}}
4720 % \changes{v3.15}{2014/11/24}{defining and using \cs{scr@chapter@afterskip}}
4721 % \changes{v3.15}{2014/12/10}{\cs{vspace} replaced by \cs{vskip} because of
4722 % \cs{lastskip}}
4723 % These commands are the distance before a chapter heading, between the
4724 % prefix line and the text line of the heading and after the chapter heading.
4725 % \cs{chapterheadmidvskip} is only used with option \opt{chapterprefix}
4726 % resp. \opt{headings=twolinechapter}.
4727 %
4728 % \begin{macro}{\scr@chapter@sectionbeforeskip,\scr@chapter@beforeskip}
4729 % \changes{v3.15}{2014/11/24}{added}
4730 % \changes{v3.17}{2015/03/25}{\cs{scr@chapter@sectionbeforeskip} renamed to
4731 % \cs{scr@chapter@beforeskip}}
4732 % \begin{macro}{\scr@chapter@innerskip}
4733 % \changes{v3.17}{2015/03/25}{added}
4734 % \begin{macro}{\scr@chapter@sectionafterskip,\scr@chapter@afterskip}
4735 % \changes{v3.15}{2014/11/24}{added}
4736 % \changes{v3.17}{2015/03/25}{\cs{scr@chapter@sectionafterskip} renamed to
4737 % \cs{scr@chapter@afterskip}}
4738 % \begin{macro}{\scr@chapter@sectionindent}
4739 % \changes{v3.15}{2014/11/24}{added}
4740 % \changes{v3.17}{2015/04/24}{removed}
4741 % \end{macro}^^A \scr@chapter@sectionindent
4742 % \begin{macro}{\scr@chapter@style}
4743 % \changes{v3.15}{2014/11/24}{added}
4744 % All the skips and the page style are used by \cs{DeclareSectionCommand}
4745 % resp. the style \texttt{chapter}. We define it as early as possible. Even the
4746 % style of \cs{chapter} is already defined here.
4747 % \begin{description}
4748 % \item[ToDo:] Do we need them in the \texttt{prepare} run or can we move then
4749 % even to the \texttt{body} run?
4750 % \item[ToDo:] Do we really need to define \cs{scr@chapter@style}?
4751 % \end{description}
4752 % \begin{macrocode}
4753 %<*prepare>
4754 \newcommand*{\scr@chapter@beforeskip}{\z@}
4755 \let\scr@chapter@beforeskip\z@
4756 \newcommand*{\scr@chapter@afterskip}{\z@}
4757 \let\scr@chapter@afterskip\z@
4758 \newcommand*{\scr@chapter@innerskip}{\z@}
4759 \let\scr@chapter@innerskip\z@
4760 \newcommand*{\scr@chapter@style}{chapter}
4761 % \end{macrocode}
4762 % \end{macro}^^A \scr@chapter@style
4763 % \end{macro}^^A \scr@chapter@afterskip
4764 % \end{macro}^^A \scr@chapter@innerskip
4765 % \end{macro}^^A \scr@chapter@beforeskip
4766 % \begin{macrocode}
4767 \newcommand*{\chapterheadstartvskip}{\vspace{\@tempskipa}}
4768 \newcommand*{\chapterheadendvskip}{\vskip\@tempskipa}
4769 \newcommand*{\chapterheadmidvskip}{\par\nobreak\vskip\@tempskipa}
4770 %</prepare>
4771 % \end{macrocode}
4772 % \end{command}^^A \chapterheadendvskip
4773 % \end{command}^^A \chapterheadmidvskip
4774 % \end{command}^^A \chapterheadstartvskip
4775 %
4776 %
4777 % \begin{macro}{\scr@startchapter}
4778 % \changes{v3.18}{2015/05/22}{added}
4779 % \changes{v3.19}{2015/08/25}{ignore empty page styles}
4780 % The macro
4781 % \begin{quote}
4782 % \cs{scr@startchapter}\marg{chapter command name}
4783 % \end{quote}
4784 % is now part of the style \texttt{chapter}. However, the main parts
4785 % of the code are from the original definition of \cs{chapter}. It has only one
4786 % argument: The name of the chapter command, i.e., \texttt{chapter}. All
4787 % arguments to the part command will be processed later.
4788 % \begin{macrocode}
4789 %<*body>
4790 \newcommand*{\scr@startchapter}[1]{%
4791 \ExecuteDoHook{heading/preinit/#1}%
4792 \if@openright\cleardoublepage\else\clearpage\fi
4793 \scr@ifundefinedorrelax{#1pagestyle}{}{%
4794 \Ifstr{#1pagestyle}{}{}{%
4795 \thispagestyle{\@nameuse{#1pagestyle}}%
4796 }%
4797 }%
4798 \global\@topnum\z@
4799 \@ifundefined{scr@#1@afterindent}{\@afterindentfalse}{%
4800 \csname scr@#1@afterindent\endcsname
4801 {\@afterindenttrue}{\@afterindentfalse}{%
4802 \@afterindenttrue
4803 \@ifundefined{scr@#1@beforeskip}{\@afterindentfalse}{%
4804 \ifdim\glueexpr\@nameuse{scr@#1@beforeskip}\relax<\z@
4805 \@afterindentfalse
4806 \fi
4807 }%
4808 }%
4809 }%
4810 \ExecuteDoHook{heading/postinit/#1}%
4811 \expandafter\SecDef\csname @#1\expandafter\endcsname\csname @s#1\endcsname
4812 }
4813 % \end{macrocode}
4814 %
4815 % \begin{macro}{\scr@@startchapter}
4816 % \changes{v3.18}{2015/05/22}{added}
4817 % The macro
4818 % \begin{quote}
4819 % \cs{scr@@startchapter}\marg{chapter command name}\oarg{extended optional
4820 % argument}\marg{chapter heading}
4821 % \end{quote}
4822 % is now part of the style \texttt{chapter}. However, the main parts
4823 % of the code are from the original definition of \cs{@chapter}. Therefore it
4824 % has the mandatory and optional arguments of a non-star variant of, i.e.,
4825 % \cs{chapter} but an additional first argument.
4826 % \begin{description}
4827 % \item[Note:] \meta{extended optional argument} is named as optional, however
4828 % here it is already mandatory, because it is a delimited argument.
4829 % \end{description}
4830 % \begin{macrocode}
4831 \newcommand*{\scr@@startchapter}{}
4832 \def\scr@@startchapter#1[#2]#3{%
4833 \ExecuteDoHook{heading/branch/nostar/#1}%
4834 % \end{macrocode}
4835 % \changes{v3.10}{2011/08/30}{extended optional argument}
4836 % \changes{v3.27}{2019/07/08}{option \opt{nonumber} added}
4837 % First of all, depending in \opt{headings=optionto\dots} we have different
4838 % defaults for the options.
4839 % \begin{macrocode}
4840 \ifnum \scr@osectarg=\z@
4841 \@scr@tempswafalse
4842 \else
4843 \scr@istest#2=\@nil
4844 \fi
4845 \@currentusenumbertrue
4846 \if@scr@tempswa
4847 \setkeys{KOMAarg.section}{tocentry={#3},head={#3},reference={#3},#2}%
4848 \else
4849 \ifcase \scr@osectarg\relax
4850 \setkeys{KOMAarg.section}{tocentry={#2},head={#2},reference={#2}}%
4851 \or
4852 \setkeys{KOMAarg.section}{tocentry={#3},head={#2},reference={#3}}%
4853 \or
4854 \setkeys{KOMAarg.section}{tocentry={#2},head={#3},reference={#2}}%
4855 \or
4856 \setkeys{KOMAarg.section}{tocentry={#2},head={#2},reference={#2}}%
4857 \fi
4858 \fi
4859 % \end{macrocode}
4860 % \changes{v2.8e}{2001/07/10}{using \cs{@maybeautodot}}
4861 % \changes{v3.08}{2010/11/01}{using \cs{addchaptertocentry}}
4862 % \changes{v3.18}{2015/05/20}{using \cs{add\meta{name}tocentry}}
4863 % \changes{v3.18}{2015/05/22}{using \meta{name} instead of \cs{@chapapp}
4864 % in \cs{typeout}}
4865 % \changes{v3.28}{2019/11/19}{\cs{ifnumbered} renamed to
4866 % \cs{Ifnumbered}}
4867 % For numbered headings we have to increase the counter and write a process
4868 % information to the \file{log} and the terminal.
4869 % \begin{macrocode}
4870 \Ifnumbered{#1}{%
4871 %<book> \if@mainmatter
4872 \@tempswatrue
4873 %<book> \else\@tempswafalse\fi
4874 }{\@tempswafalse}%
4875 \if@tempswa
4876 \refstepcounter{#1}%
4877 \expandafter\@maybeautodot\csname the#1\endcsname
4878 \typeout{#1 \csname the#1\endcsname.}%
4879 \ifx\@currenttocentry\@empty\else
4880 % \end{macrocode}
4881 % \changes{v3.31}{2020/06/06}{using \cs{\dots tocformat}}%
4882 % \begin{description}
4883 % \item[ToDo]: Move \cs{autodot} to the definition of \cs{\dots tocformat}.
4884 % \end{description}
4885 % \begin{macrocode}
4886 \@ifundefined{#1tocformat}{%
4887 \expandafter\gdef\csname #1tocformat\endcsname
4888 {\csname the#1\endcsname}%
4889 }{}%
4890 \scr@ifundefinedorrelax{add#1tocentry}{%
4891 \addtocentrydefault{#1}%
4892 }{%
4893 \@nameuse{add#1tocentry}%
4894 }{\csname\@ifundefined{#1tocformat}{the#1}{#1tocformat}\endcsname}%
4895 {\@currenttocentry}%
4896 \fi
4897 \else
4898 % \end{macrocode}
4899 % For not numbered headings we still have to process the reset list of the
4900 % counter and write a process information to the \file{log} and the terminal.
4901 % \begin{macrocode}
4902 %<!v4> \expandafter\ifnum\scr@v@is@ge{3.15}\relax
4903 \begingroup
4904 \let\@elt\@stpelt
4905 \csname cl@#1\endcsname
4906 \endgroup
4907 %<!v4> \fi
4908 \typeout{#1 without number}%
4909 \ifx\@currenttocentry\@empty\else
4910 % \end{macrocode}
4911 % And before writing a not numbered entry to the table of contents we have to
4912 % execute also the \pkg{hyperref} hook \cs{hy@insteadofrefstepcounter}.
4913 % \begin{description}
4914 % \item[Note:] \pkg*{scrhack} uses the existence of this command to detect a
4915 % \KOMAScript{} class. Shouldn't this be changed using, e.g.,
4916 % \cs{KOMAClassName}?
4917 % \end{description}
4918 % \begin{macrocode}
4919 \hy@insteadofrefstepcounter{#1}%
4920 \scr@ifundefinedorrelax{add#1tocentry}{%
4921 \addtocentrydefault{#1}%
4922 }{%
4923 \@nameuse{add#1tocentry}%
4924 }{}{\@currenttocentry}%
4925 \fi
4926 \fi
4927 % \end{macrocode}
4928 % Set the mark for the running head. Here we have to do a one step expansion
4929 % of \cs{@currentheadentry}, because otherwise it would change with every
4930 % \cs{section}, \cs{subsection} \dots
4931 % \begin{macrocode}
4932 \csname #1mark\expandafter\endcsname\expandafter{\@currentheadentry}%
4933 % \end{macrocode}
4934 % \changes{v2.8g}{2001/07/18}{support for \cs{float@addtolists}}
4935 % \changes{v3.43}{2024/10/24}{support for \cs{float@addtolists} removed}
4936 % \changes{v3.28}{2019/11/19}{\cs{iftocfeature} replaced by \cs{Iftocfeature}}
4937 % Depending on feature \texttt{chapteratlist} we have to add a vertical space
4938 % to other directories. And for compatibility we also support the deprecated
4939 % \cs{float@addtolists} but not without warning.
4940 % \begin{description}
4941 % \item[ToDo:] Why do we add the gap here but also use \cs{addcontentsline}
4942 % in \cs{addchaptertocentry}? Is this a bug? Should this be standardized?
4943 % \end{description}
4944 % \begin{macrocode}
4945 \ifdim \@chapterlistsgap>\z@
4946 \doforeachtocfile{%
4947 \Iftocfeature{\@currext}{chapteratlist}{%
4948 \addtocontents{\@currext}{\protect\addvspace{\@chapterlistsgap}}%
4949 }{}%
4950 }%
4951 \expandafter\ifnum \scr@v@is@lt{3.43}\relax
4952 \@ifundefined{float@addtolists}{}{%
4953 \scr@float@addtolists@warning
4954 \float@addtolists{\protect\addvspace{\@chapterlistsgap}}%
4955 }%
4956 \fi
4957 \fi
4958 % \end{macrocode}
4959 % \changes{v3.18}{2015/05/22}{\cs{@makechapterhead} replaced by
4960 % \cs{@make\meta{Name}head}}
4961 % \changes{v3.36}{2022/03/16}{warning about deprecated \cs{@makechapterhead}}
4962 % Setting the heading itself is more or less a call of \cs{@make\meta{command
4963 % name}head}.
4964 % \begin{description}
4965 % \item[ToDo:] Using \cs{scr@makechapterhead}\marg{command name} would be the
4966 % better solution. However in this case, every redefinition of
4967 % \cs{@makechapterhead} would be ignored. So currently we support such
4968 % deprecated redefinition of internal macro \cs{@makechapterhead} for
4969 % \cs{chapter}. But this will be changed in future.
4970 % \end{description}
4971 % \begin{macrocode}
4972 \scr@t@st@nd@w@rn@m@k@ch@pt@rh@@d{#1}%
4973 \if@twocolumn
4974 \if@at@twocolumn
4975 \@nameuse{@make#1head}{#3}%
4976 \else
4977 % \end{macrocode}
4978 % \changes{v3.46}{2025/08/19}{vertical alignment of chapters in twocolumn
4979 % mode improved}
4980 % Here we have a problem or even two. First: Inside \cs{@topnewpage} the
4981 % paragraph settings are reset like with \cs{parboxrestore}. So we need to
4982 % store the settings outside and restore them inside. Restoring \cs{parskip}
4983 % usually would be enough, but we do the whole thing. Second: \cs{@topnewpage}
4984 % is output before \cs{topskip} us used. But here we need \cs{topskip} be used
4985 % first. So we need to compensate this by extra \cs{vskip} before and the
4986 % content.
4987 % \begin{macrocode}
4988 \edef\scr@restoreparsetup{%
4989 \parskip\the\parskip
4990 \parfillskip\the\parfillskip
4991 \parindent\the\parindent
4992 }%
4993 \@topnewpage[%
4994 %<!v4> \expandafter\ifnum\scr@v@is@ge{3.46}\relax
4995 \scr@restoreparsetup
4996 \vskip\topskip
4997 %<!v4> \fi
4998 \@nameuse{@make#1head}{#3\ifhmode\strut\fi}%
4999 %<!v4> \expandafter\ifnum\scr@v@is@ge{3.46}\relax
5000 \vskip\dimeval{\ht\strutbox-\dp\strutbox-\topskip+\parskip}%
5001 %<!v4> \fi
5002 ]%
5003 \fi
5004 \else
5005 \@nameuse{@make#1head}{#3}%
5006 \fi
5007 % \end{macrocode}
5008 % \changes{v3.18}{2015/05/21}{always using \cs{@afterheading}}
5009 % And finally the end of every outline command.
5010 % \begin{macrocode}
5011 \@afterheading
5012 }
5013 % \end{macrocode}
5014 % \begin{macro}{\scr@t@st@nd@w@rn@m@k@ch@pt@rh@@d}
5015 % \changes{v3.36}{2022/03/16}{added}
5016 % The test and warning used inside \cs{scr@@startchapter}.
5017 % \begin{macrocode}
5018 %<!v4>\expandafter\ifnum\scr@v@is@ge{3.36}%
5019 \newcommand*{\scr@t@st@nd@w@rn@m@k@ch@pt@rh@@d}[1]{%
5020 \Ifstr{#1}{chapter}{%
5021 \begingroup
5022 \def\reserved@a{\scr@makechapterhead{chapter}}%
5023 \ifx\@makechapterhead\reserved@a\else
5024 \ClassWarningNoLine{\KOMAClassName}{%
5025 Redefinition of \string\@makechapterhead\space detected.\MessageBreak
5026 Note: KOMA-Script does use styles for commands like\MessageBreak
5027 \string\chapter. Currently it internally still provides and\MessageBreak
5028 uses \string\@makechapterhead, but a completely different\MessageBreak
5029 definition compared to the standard classes.\MessageBreak
5030 So redefining or using internal \string\@makechapterhead\MessageBreak
5031 by users or package authors may already break\MessageBreak
5032 KOMA-Script and will not work with a coming version,\MessageBreak
5033 that will remove this deprecated code}%
5034 \let\scr@t@st@nd@w@rn@m@k@ch@pt@rh@@d\@gobbble
5035 \fi
5036 \endgroup
5037 }{}%
5038 }
5039 %<!v4>\else
5040 %<!v4> \let\scr@t@st@nd@w@rn@m@k@ch@pt@rh@@d\@gobble
5041 %<!v4>\fi
5042 % \end{macrocode}
5043 % \end{macro}^^A \scr@t@st@nd@w@rn@m@k@ch@pt@rh@@d
5044 % \end{macro}^^A \scr@@startchapter
5045 %
5046 % \begin{macro}{\scr@@startschapter}
5047 % \changes{v3.18}{2015/05/22}{added}
5048 % The macro
5049 % \begin{quote}
5050 % \cs{scr@@startschapter}\marg{chapter command name}\marg{chapter heading}
5051 % \end{quote}
5052 % is now part of the style \texttt{chapter}. However, the main parts
5053 % of the code are from the original definition of \cs{@schapter}. Therefore it
5054 % has the mandatory argument of a star variant of, i.e., \cs{chapter} but an
5055 % additional first argument.
5056 % \begin{macrocode}
5057 \newcommand*{\scr@@startschapter}[2]{%
5058 \ExecuteDoHook{heading/branch/star/#1}%
5059 % \end{macrocode}
5060 % Some users don't learn to use \cs{addchapter} for not numbered parts with
5061 % entry to the table of contents but insist in using
5062 % \cs{addcontentsline}. Despite this should not be used, because at least
5063 % \cs{addchaptertocentry} should be used, we tolerate this by using our
5064 % \pkg{hyperref} hook.
5065 % \begin{description}
5066 % \item[ToDo:] I don't understand why \pkg{hyperref} uses a group here and
5067 % locally sets \cs{@mkboth} to \cs{@gobbletwo}. However, I've copied this.
5068 % \end{description}
5069 % \begin{macrocode}
5070 \begingroup
5071 \let\@mkboth\@gobbletwo
5072 \hy@insteadofrefstepcounter{#1}%
5073 \endgroup
5074 % \end{macrocode}
5075 % Setting the heading itself is more or less a call of \cs{@makes\meta{command
5076 % name}head}.
5077 % \begin{description}
5078 % \item[ToDo:] Using \cs{scr@makeschapterhead}\marg{command name} would be the
5079 % better solution. However in this case, every redefinition of
5080 % \cs{@makeschapterhead} would be ignored. So currently we support such
5081 % deprecated redefinition of internal macro \cs{@makeschapterhead} for
5082 % \cs{chapter}. But this will be changed in future.
5083 % \end{description}
5084 % \begin{macrocode}
5085 \scr@t@st@nd@w@rn@m@ks@ch@pt@rh@@d{#1}%
5086 \if@twocolumn
5087 \if@at@twocolumn
5088 \@nameuse{@makes#1head}{#2}%
5089 \else
5090 % \end{macrocode}
5091 % \changes{v3.46}{2025/08/19}{vertical alignment of chapters in twocolumn
5092 % mode improved}
5093 % Here we have a problem or even two. First: Inside \cs{@topnewpage} the
5094 % paragraph settings are reset like with \cs{parboxrestore}. So we need to
5095 % store the settings outside and restore them inside. Restoring \cs{parskip}
5096 % usually would be enough, but we do the whole thing. Second: \cs{@topnewpage}
5097 % is output before \cs{topskip} us used. But here we need \cs{topskip} be used
5098 % first. So we need to compensate this by extra \cs{vskip} before and the
5099 % content.
5100 % \begin{macrocode}
5101 \edef\scr@restoreparsetup{%
5102 \parskip\the\parskip
5103 \parfillskip\the\parfillskip
5104 \parindent\the\parindent
5105 }%
5106 \@topnewpage[%
5107 %<!v4> \expandafter\ifnum\scr@v@is@ge{3.46}\relax
5108 \scr@restoreparsetup
5109 \vskip\topskip
5110 %<!v4> \fi
5111 \@nameuse{@makes#1head}{#2\ifhmode\strut\fi}%
5112 %<!v4> \expandafter\ifnum\scr@v@is@ge{3.46}\relax
5113 \vskip\dimeval{\ht\strutbox-\dp\strutbox-\topskip+\parskip}%
5114 %<!v4> \fi
5115 ]%
5116 \fi
5117 \else
5118 \@nameuse{@makes#1head}{#2}%
5119 \fi
5120 % \end{macrocode}
5121 % \changes{v3.18}{2015/05/21}{always using \cs{@afterheading}}
5122 % And finally the end of every outline command.
5123 % \begin{macrocode}
5124 \@afterheading
5125 }
5126 % \end{macrocode}
5127 % \begin{macro}{\scr@t@st@nd@w@rn@m@ks@ch@pt@rh@@d}
5128 % \changes{v3.36}{2022/03/16}{added}
5129 % The test and warning used inside \cs{scr@@startschapter}.
5130 % \begin{macrocode}
5131 %<!v4>\expandafter\ifnum\scr@v@is@ge{3.36}%
5132 \newcommand*{\scr@t@st@nd@w@rn@m@ks@ch@pt@rh@@d}[1]{%
5133 \Ifstr{#1}{chapter}{%
5134 \begingroup
5135 \def\reserved@a{\scr@makeschapterhead{chapter}}%
5136 \ifx\@makeschapterhead\reserved@a\else
5137 \ClassWarningNoLine{\KOMAClassName}{%
5138 Redefinition of \string\@makeschapterhead\space detected.\MessageBreak
5139 Note: KOMA-Script does use styles for commands like\MessageBreak
5140 \string\chapter. Currently it internally still provides and\MessageBreak
5141 uses \string\@makeschapterhead, but a completely different\MessageBreak
5142 definition compared to the standard classes.\MessageBreak
5143 So redefining or using internal \string\@makeschapterhead\MessageBreak
5144 by users or package authors may already break\MessageBreak
5145 KOMA-Script and will not work with a coming version,\MessageBreak
5146 that will remove this deprecated code}%
5147 \let\scr@t@st@nd@w@rn@m@ks@ch@pt@rh@@d\@gobble
5148 \fi
5149 \endgroup
5150 }{}%
5151 }
5152 %<!v4>\else
5153 %<!v4> \let\scr@t@st@nd@w@rn@m@ks@ch@pt@rh@@d\@gobble
5154 %<!v4>\fi
5155 % \end{macrocode}
5156 % \end{macro}^^A \scr@t@st@nd@w@rn@m@ks@ch@pt@rh@@d
5157 % \end{macro}^^A \scr@@startschapter
5158 %
5159 %% \begin{macro}{\@at@twocolumntrue,\@at@twocolumnfalse,\if@at@twocolumn}
5160 % \changes{v2.7b}{2001/01/05}{added}
5161 % \begin{macro}{\scr@topnewpage}
5162 % \changes{v2.7b}{2001/01/05}{added}
5163 % \changes{v2.8q}{2001/11/27}{braces fixed}
5164 % \begin{macro}{\@topnewpage}
5165 % \changes{v2.7b}{2001/01/05}{added}
5166 % \changes{v2.7g}{2001/04/17}{missing \cs{long} added}
5167 % In the code above we use \cs{if@at@twocolumn} to detect, if we already
5168 % inside the optional argument of \cs{twocolumn}. A clean definition of this
5169 % feature would redefine \LaTeX{} command \cs{twocolumn}. Here we use the ugly
5170 % hack to redefine the internal macro \cs{@topnewpage} of the \LaTeX{} kernel
5171 % instead. This macro is used to print the optional argument. So we can add
5172 % switching on and of the boolean switch before and after it. With this,
5173 % packages can simply use chapter commands also inside the optional argument
5174 % of \cs{twocolumn} instead of need to use an internal command like
5175 % \cs{@makechapterhead}.
5176 % \begin{macrocode}
5177 \newif\if@at@twocolumn
5178 \newcommand*\scr@topnewpage{}
5179 \let\scr@topnewpage\@topnewpage
5180 \long\def\@topnewpage[#1]{%
5181 \@at@twocolumntrue\scr@topnewpage[{#1}]\@at@twocolumnfalse
5182 }
5183 % \end{macrocode}
5184 % \end{macro}^^A \@topnewpage
5185 % \end{macro}^^A \scr@topnewpage
5186 % \end{macro}^^A \if@at@twocolumn
5187 %
5188 % \begin{macro}{\scr@makechapterhead}
5189 % \changes{v2.7b}{2001/01/05}{support for chapter preamble}
5190 % \changes{v2.8p}{2001/09/25}{support for different kinds of preambles}
5191 % \changes{v3.15}{2014/12/10}{\cs{nobreak} removed}
5192 % \changes{v3.18}{2015/05/22}{added}
5193 % \begin{macro}{\scr@@makechapterhead}
5194 % \changes{v3.18}{2015/05/22}{added}
5195 % \changes{v2.8q}{2002/04/18}{\cs{raggedsection} also for the prefix}
5196 % \changes{v2.9p}{2003/06/28}{setting \cs{parfillskip} to \cs{fill}}
5197 % \changes{v2.96a}{2006/12/02}{distance after the prefix line only if prefix line}
5198 % \changes{v2.97b}{2007/03/09}{\cs{endgraf} fixed}
5199 % \changes{v3.15}{2014/11/20}{re-implementation}
5200 % \changes{v3.15}{2014/12/09}{\cs{raggedchapter} replaced by \cs{raggedsection}}
5201 % \changes{v3.17}{2015/04/03}{using \cs{usefontofkomafont} for initial font
5202 % changed}
5203 % Macros
5204 % \begin{quote}\raggedright
5205 % \cs{scr@makechapterhead}\marg{chapter command name}\marg{heading}\\
5206 % \cs{scr@@makechapterhead}\marg{chapter command name}\marg{heading}
5207 % \end{quote}
5208 % are used inside the definition of style \texttt{chapter} and replace
5209 % \cs{@makechapterhead} resp. \cs{@@makechapterhead} there. So they have one
5210 % more argument than \cs{@makechapterhead} of the standard classes.
5211 % \begin{macrocode}
5212 \newcommand*{\scr@makechapterhead}[2]{%
5213 \use@chapter@o@preamble{#1}%
5214 \@nameuse{@@make#1head}{#2}%
5215 \use@preamble{#1@u}%
5216 }
5217 \newcommand*{\scr@@makechapterhead}[2]{%
5218 % \end{macrocode}
5219 % \changes{v3.22}{2016/12/21}{\cs{@afterindentrue} if \opt{beforeskip} is
5220 % positive}
5221 % \changes{v3.26}{2018/09/18}{using \opt{afterindent}}
5222 % Depending on \opt{afterindent} we set \cs{if@afterindent} and set the
5223 % initial vertical skip using \cs{@tempskipa} and \cs{chapterheadstartvskip}.
5224 % \begin{macrocode}
5225 \@tempskipa=\glueexpr \csname scr@#1@beforeskip\endcsname\relax\relax
5226 \csname scr@#1@afterindent\endcsname
5227 {\@afterindenttrue}{\@afterindentfalse}{%
5228 \ifdim\@tempskipa<\z@\@tempskipa-\@tempskipa\else
5229 %<!v4> \expandafter\ifnum\scr@v@is@ge{3.22}
5230 \@afterindenttrue
5231 %<!v4> \fi
5232 \fi
5233 }%
5234 \chapterheadstartvskip
5235 % \end{macrocode}
5236 % \changes{v3.19}{2015/08/02}{using \cs{chapterlinesformat} and
5237 % \cs{chapterlineswithprefixformat}}
5238 % \changes{v3.19}{2015/08/02}{using font element \fnt{disposition} instead of
5239 % \cs{sectfont}}
5240 % \changes{v3.19a}{2015/10/03}{missing local definition of \cs{IfUseNumber}
5241 % added}
5242 % \changes{v3.20}{2015/12/23}{setting \cs{parfillskip} to \texttt{\cs{z@} plus
5243 % 1fil}}
5244 % \changes{v3.27}{2019/02/02}{setting of \cs{parindent} and \cs{parfillskip}
5245 % moved}
5246 % \changes{v3.27}{2019/02/02}{\cs{ExecuteDoHook} added}
5247 % \changes{v3.28}{2019/11/19}{\cs{ifnumbered} renamed to
5248 % \cs{Ifnumbered}}
5249 % For the heading itself a group is used. Using group braces instead of
5250 % \cs{begingroup} makes it possible to do a very ugly hack inside a
5251 % redefinition of \cs{chapterheadstartvskip}. Nevertheless, such hacks are not
5252 % recommended.
5253 % \begin{macrocode}
5254 {%
5255 \def\IfUseNumber{\Ifnumbered{#1}}%
5256 %<book> \if@mainmatter\else\let\IfUseNumber\@secondoftwo\fi
5257 \ExecuteDoHook{heading/begingroup/#1}%
5258 \if@chapterprefix
5259 \let\IfUsePrefixLine\@firstoftwo
5260 \else
5261 \let\IfUsePrefixLine\@secondoftwo
5262 \fi
5263 \setlength{\parindent}{\z@}\setlength{\parfillskip}{\z@ plus 1fil}%
5264 \normalfont\usekomafont{disposition}{%
5265 \usekomafont{#1}{%
5266 \settoheight{\@tempskipa}{%
5267 {\usekomafont{#1prefix}{%
5268 \vrule \@width\z@ \@height\csname scr@#1@innerskip\endcsname}}%
5269 }%
5270 \raggedchapter
5271 \IfUseNumber{%
5272 \IfUsePrefixLine{%
5273 \chapterlineswithprefixformat{#1}%
5274 {{\usekomafont{#1prefix}{\csname #1format\endcsname%
5275 \setlength{\@tempskipa}{\csname scr@#1@innerskip\endcsname}%
5276 \chapterheadmidvskip}}}%
5277 {\interlinepenalty \@M#2\@@par}%
5278 }{%
5279 \chapterlinesformat{#1}%
5280 {\csname #1format\endcsname}%
5281 {\interlinepenalty \@M#2\@@par}%
5282 }%
5283 }{%
5284 \IfUsePrefixLine{%
5285 \chapterlineswithprefixformat{#1}%
5286 {}%
5287 {\interlinepenalty \@M#2\@@par}%
5288 }{%
5289 \chapterlinesformat{#1}%
5290 {}%
5291 {\interlinepenalty \@M#2\@@par}%
5292 }%
5293 }%
5294 }%
5295 }%
5296 \ExecuteDoHook{heading/endgroup/#1}%
5297 }%
5298 \nobreak\par\nobreak
5299 % \end{macrocode}
5300 % \changes{v3.26}{2018/09/20}{no absolute value}
5301 % Last but not least the final skip.
5302 % \begin{description}
5303 % \item[Note:] \cs{@afterheading} will be added by \cs{scr@@startchapter}.
5304 % \end{description}
5305 % \begin{macrocode}
5306 \@tempskipa=\glueexpr \csname scr@#1@afterskip\endcsname\relax\relax
5307 \chapterheadendvskip
5308 }
5309 % \end{macrocode}
5310 % \end{macro}^^A \scr@makechapterhead
5311 % \end{macro}^^A \scr@@makechapterhead
5312 %
5313 % \begin{macro}{\scr@makeschapterhead}
5314 % \changes{v3.18}{2015/05/22}{added}
5315 % \begin{macro}{\scr@@makeschapterhead}
5316 % \changes{v2.9p}{2003/06/28}{to \cs{parfillskip} to \cs{fill}}
5317 % \changes{v2.9q}{2004/03/24}{same braces like \cs{@@makechapterhead}}
5318 % \changes{v3.15}{2014/12/09}{\cs{raggedchapter} replaced by
5319 % \cs{raggedsection}}
5320 % \changes{v3.18}{2015/05/22}{added}
5321 % \changes{v3.19}{2015/08/02}{same changes like \cs{scr@@makechapterhead}}
5322 % \changes{v3.20}{2015/12/23}{setting \cs{parfillskip} to \texttt{\cs{z@} plus
5323 % 1fil}}
5324 % \changes{v3.25}{2017/09/07}{\cs{IfUseNumber} fixed}
5325 % \changes{v3.26}{2018/09/20}{no absolute of \opt{afterskip}}
5326 % Macros
5327 % \begin{quote}\raggedright
5328 % \cs{scr@makeschapterhead}\marg{chapter command name}\marg{heading}\\
5329 % \cs{scr@@makeschapterhead}\marg{chapter command name}\marg{heading}
5330 % \end{quote}
5331 % are used inside the definition of style \texttt{chapter} and replace
5332 % \cs{@makeschapterhead} resp. \cs{@@makeschapterhead} there. So they have one
5333 % more argument than \cs{@makeschapterhead} of the standard classes.
5334 % \begin{macrocode}
5335 \newcommand*{\scr@makeschapterhead}[2]{%
5336 \use@chapter@o@preamble{#1}%
5337 \@nameuse{@@makes#1head}{#2}%
5338 \use@preamble{#1@u}%
5339 }
5340 \newcommand*{\scr@@makeschapterhead}[2]{%
5341 % \end{macrocode}
5342 % \changes{v3.22}{2016/12/21}{\cs{@afterindentrue} if positive
5343 % \opt{beforeskip}}
5344 % \changes{v3.26}{2018/09/18}{supporting \opt{afterindent}}
5345 % This is a simplified version of \cs{scr@@makechapterhead}.
5346 % \begin{macrocode}
5347 \@tempskipa=\glueexpr \csname scr@#1@beforeskip\endcsname\relax\relax
5348 \csname scr@#1@afterindent\endcsname
5349 {\@afterindenttrue}{\@afterindentfalse}{%
5350 \ifdim\@tempskipa<\z@\@tempskipa-\@tempskipa\else
5351 %<!v4> \expandafter\ifnum\scr@v@is@ge{3.22}
5352 \@afterindenttrue
5353 %<!v4> \fi
5354 \fi
5355 }%
5356 \chapterheadstartvskip
5357 {%
5358 \let\IfUseNumber\@secondoftwo
5359 \ExecuteDoHook{heading/begingroup/#1}%
5360 \if@chapterprefix
5361 \let\IfUsePrefixLine\@firstoftwo
5362 \else
5363 \let\IfUsePrefixLine\@secondoftwo
5364 \fi
5365 \setlength{\parindent}{\z@}\setlength{\parfillskip}{\z@ plus 1fil}%
5366 \normalfont\usekomafont{disposition}{%
5367 \usekomafont{#1}{%
5368 \raggedchapter
5369 \IfUsePrefixLine{%
5370 \chapterlineswithprefixformat{#1}%
5371 {}%
5372 {\interlinepenalty \@M#2\@@par}%
5373 }{%
5374 \chapterlinesformat{#1}%
5375 {}%
5376 {\interlinepenalty \@M#2\@@par}%
5377 }%
5378 }%
5379 }%
5380 \ExecuteDoHook{heading/endgroup/#1}%
5381 }%
5382 \nobreak\par\nobreak
5383 \@tempskipa=\glueexpr \csname scr@#1@afterskip\endcsname\relax\relax
5384 \chapterheadendvskip
5385 }
5386 % \end{macrocode}
5387 % \end{macro}^^A \scr@@makeschapterhead
5388 % \end{macro}^^A \scr@makeschapterhead
5389 %
5390 % \begin{command}{\chapterlinesformat,\chapterlineswithprefixformat}
5391 % \changes{v3.19}{2015/08/02}{added}
5392 % Commands
5393 % \begin{quote}\raggedright
5394 % \cs{chapterlinesformat}\marg{command name}\marg{number}\marg{text}\\
5395 % \cs{chapterlineswithprefixformat}\marg{command name}\marg{number}\marg{text}
5396 % \end{quote}
5397 % are used to print a chapter heading either a free standing one or a free
5398 % stranding one with prefix line. \meta{number} is the completely formatted
5399 % prefix line inclusive the vertical distance below. The \meta{text} is the
5400 % text of the heading also formatted and with final \cs{@@par}. But if the
5401 % user used more paragraphs than this is final one, the user is responsible to
5402 % prevent page breaks!
5403 % \begin{macrocode}
5404 \newcommand{\chapterlinesformat}[3]{%
5405 \@hangfrom{#2}{#3}%
5406 }
5407 \newcommand{\chapterlineswithprefixformat}[3]{%
5408 #2#3%
5409 }
5410 % \end{macrocode}
5411 % \end{command}^^A \chapterlinesformat,\chapterlineswithprefixformat
5412 %
5413 % \begin{macro}{\use@chapter@o@preamble}
5414 % \changes{v3.15}{2014/12/08}{distances adapted}
5415 % \changes{v3.15a}{2015/02/02}{avoiding \texttt{overfull \cs{vbox}}}
5416 % \changes{v3.18}{2015/05/20}{using command depending distances and warnings}
5417 % \changes{v3.18}{2015/05/22}{has an argument and prints the preamble of the
5418 % command instead of the style}
5419 % Used by \cs{scr@makechapterhead} and \cs{scr@makeschapterhead} to set the
5420 % preamble above chapter headings.
5421 % \begin{macrocode}
5422 \newcommand*{\use@chapter@o@preamble}[1]{%
5423 {%
5424 \settoheight{\@tempdima}{%
5425 \@tempskipa=\glueexpr \csname scr@#1@beforeskip\endcsname\relax\relax
5426 \ifdim\@tempskipa<\z@\@tempskipa-\@tempskipa\fi
5427 \vbox{\chapterheadstartvskip}%
5428 }%
5429 \settodepth{\@tempdimb}{%
5430 \@tempskipa=\glueexpr \csname scr@#1@beforeskip\endcsname\relax\relax
5431 \ifdim\@tempskipa<\z@\@tempskipa-\@tempskipa\fi
5432 \vbox{\chapterheadstartvskip}%
5433 }%
5434 \addtolength{\@tempdima}{\@tempdimb}%
5435 \setbox\z@\vbox{%
5436 \use@preamble{#1@o}%
5437 }%
5438 \setlength{\@tempdimb}{\ht0}%
5439 \addtolength{\@tempdimb}{\dp0}%
5440 \vbox to \z@{%
5441 \vskip-\baselineskip
5442 \vbox to \@tempdima{%
5443 \vfill
5444 \box\z@
5445 }%
5446 \vss
5447 }\vskip-\parskip\vskip-\baselineskip
5448 \ifdim \@tempdimb>\@tempdima%
5449 \addtolength{\@tempdimb}{-\@tempdima}%
5450 \ifdim\@tempdimb<\vfuzz
5451 \ClassInfo{\KOMAClassName}{%
5452 preamble before #1 is \the\@tempdimb\space to high.\MessageBreak
5453 Tolerated without warning because of\MessageBreak
5454 \string\vfuzz\space = \the\vfuzz\space >= \the\@tempdimb
5455 }%
5456 \else
5457 \ClassWarning{\KOMAClassName}{%
5458 preamble before #1 is \the\@tempdimb\space to high.\MessageBreak
5459 To avoid the overfull \string\vbox\space you may
5460 change\MessageBreak
5461 the `beforeskip' value using
5462 \string\RedeclareSectionCommand\MessageBreak
5463 at the preamble of your document.\MessageBreak
5464 You may also change \string\setchapterpreamble\MessageBreak
5465 before the command, which generates the message
5466 about\MessageBreak
5467 an overfull \string\vbox
5468 }%
5469 \fi
5470 \fi%
5471 }%
5472 }
5473 % \end{macrocode}
5474 % \end{macro}^^A \use@chapter@o@preamble
5475 % \end{macro}^^A \scr@startchapter
5476 %
5477 % \begin{command}{\addchaptertocentry}
5478 % \changes{v3.08}{2010/11/01}{added}
5479 % \changes{v3.12}{2013/09/24}{support for \cs{if@chaptertolists}}
5480 % \changes{v3.12}{2013/09/24}{using\cs{addxcontentsline}}
5481 % \changes{v3.28}{2019/11/19}{\cs{iftocfeature} replaced by
5482 % \cs{Iftocfeature}}
5483 % \changes{v3.43}{2024/10/24}{\cs{float@addtolists} warning removed}
5484 % We do not use \cs{addcontentsline} directly for the entries to the table of
5485 % contents. Using
5486 % \begin{quote}
5487 % \cs{addchaptertocentry}\marg{number}\marg{text}
5488 % \end{quote}
5489 % allows easy manipulation of such entries and additional actions. If the
5490 % \meta{number} is completely empty no number should be used. Internally the
5491 % generic \cs{addtocentrydefault} it used, which uses \cs{nonumberline}
5492 % instead of \cs{numberline} in this case. See \file{scrkernel-listsof.dtx}
5493 % for more information.
5494 % \begin{description}
5495 % \item[ToDo:] Here we also do the entries to other directories. But we have
5496 % also code for this in \cs{scr@@startchapter} at least for the vertical
5497 % space. Shouldn't we combine both places to one place? And shouldn't this
5498 % be done here only, because of handling of user calls of
5499 % \cs{addchaptertocentry}?
5500 % \end{description}
5501 % \begin{macrocode}
5502 \newcommand*{\addchaptertocentry}[2]{%
5503 \addtocentrydefault{chapter}{#1}{#2}%
5504 \if@chaptertolists
5505 \doforeachtocfile{%
5506 \Iftocfeature{\@currext}{chapteratlist}{%
5507 \addxcontentsline{\@currext}{chapteratlist}[{#1}]{#2}%
5508 }{}%
5509 }%
5510 \fi
5511 }
5512 % \end{macrocode}
5513 % \end{command}^^A \addchaptertocentry
5514 %
5515 % \begin{macro}{\@chapter,\@makechapterhead,\@@makechapterhead,
5516 % \@schapter,\@makeschapterhead,\@@makeschapterhead}
5517 % \changes{v3.18}{2015/05/22}{indirect by \cs{DeclareSectionCommand}}
5518 % \begin{command}{\setchapterpreamble}
5519 % \changes{v2.7b}{2001/01/05}{added}
5520 % \changes{v3.18}{2015/05/22}{indirect by \cs{DeclareSectionCommand}}
5521 % \begin{macro}{\chapter@u@preamble,\chapter@o@preamble}
5522 % \changes{v2.8p}{2001/09/25}{added}
5523 % \changes{v3.18}{2015/05/22}{indirect by \cs{DeclareSectionCommand}}
5524 % All these commands and macros are not defined explicitly but by using
5525 % \cs{DeclareSectionCommand} later. See also
5526 % \cs{scr@dsc@def@style@chapter@command} and \cs{setchapterpreamble}.
5527 % \end{macro}^^A \chapter@u@preamble,\chapter@o@preamble
5528 % \end{command}^^A \setchapterpreamble
5529 % \end{macro}^^A \@chapter … \@@makeschapterhead
5530 %
5531 % \begin{command}{\addchap}
5532 % \changes{v2.0e}{1994/08/10}{\cs{sectdef} replaced by h \cs{secdef}}
5533 % \changes{v2.0e}{1994/08/10}{\cs{addcontensline} replaced by
5534 % \cs{addcontentsline}}
5535 % \changes{v2.0e}{1994/08/10}{\cs{@makechapterhead} replaced by
5536 % \cs{@makeschapterhead}}
5537 % \changes{v2.0e}{1994/08/10}{\cs{afterheadings} replaced by
5538 % \cs{@afterheading}}
5539 % \changes{v2.1a}{1994/10/29}{argument of \cs{chaptermark} removed from
5540 % \cls*{scrbook}}
5541 % \changes{v2.0e}{1994/10/12}{several \cs{markboth} replaced by
5542 % \cs{sectionmark}}
5543 % \changes{v2.2b}{1995/03/20}{several \cs{chaptermark} replaced by
5544 % \cs{@mkboth}}
5545 % \changes{v2.8d}{2001/07/05}{using \cs{chapterpagestyle}}
5546 % \changes{v3.08}{2010/11/01}{using \cs{addchaptertocentry}}
5547 % \changes{v3.10}{2011/08/30}{extended optional argument}
5548 % \changes{v3.13a}{2014/09/11}{using \cs{SecDef}}
5549 % \changes{v3.18}{2015/05/22}{redefinition}
5550 % \begin{macro}{\@addchap}
5551 % \changes{v3.12}{2013/02/26}{using \cs{addchapmark}}
5552 % \changes{v3.17}{2015/04/20}{expanding \cs{scr@ds@head} in \cs{addchapmark}}
5553 % \changes{v3.18}{2015/05/22}{redefinition}
5554 % \begin{macro}{\@saddchap}
5555 % \changes{v3.12}{2013/02/26}{using \cs{addchapmark}}
5556 % \changes{v3.18}{2015/05/22}{redefinition}
5557 % Since \KOMAScript{} 3.18 using
5558 % \begin{quote}
5559 % \cs{addchap}\oarg{head or ToC entry}\marg{heading}
5560 % \end{quote}
5561 % is very similar to
5562 % |\chapter[nonumber=true,…]{…}| but also works if the extended optional
5563 % argument is not activated. And
5564 % \begin{quote}
5565 % \cs{addchap*}\marg{heading}
5566 % \end{quote}
5567 % is just a \cs{chapter*}\marg{heading} with additional |\addchapmark{}| to
5568 % empty the running head.
5569 % \begin{description}
5570 % \item[Note:] Because of simply manipulating \cnt{secnumdepth} this should
5571 % also work with packages like \pkg{hyperref} as long as they support
5572 % chapters without numbering.
5573 % \end{description}
5574 % \begin{macrocode}
5575 \newcommand\addchap{%
5576 \SecDef\@addchap\@saddchap
5577 }%
5578 \newcommand*{\@addchap}{}%
5579 \long\def\@addchap[#1]#2{%
5580 \edef\reserved@a{%
5581 \unexpanded{%
5582 \chapter[{#1}]{#2}%
5583 \c@secnumdepth=
5584 }\the\c@secnumdepth\relax
5585 }%
5586 \c@secnumdepth=\numexpr \chapternumdepth-1\relax
5587 \reserved@a
5588 }
5589 \newcommand{\@saddchap}[1]{%
5590 \chapter*{#1}%
5591 \addchapmark{}%
5592 }%
5593 % \end{macrocode}
5594 % \changes{v2.7e}{2001/04/16}{braces fixed}
5595 % \changes{v2.7f}{2001/04/17}{braces fixed}
5596 % \changes{v2.8q}{2001/11/17}{using \cs{AfterPackage} to test for
5597 % \pkg{hyperref} version}
5598 % \changes{v3.27a}{2019/11/11}{warning fixed}
5599 % \begin{description}
5600 % \item[ToDo:] Unfortunately \pkg{hyperref} until version 6.71a has a big fat
5601 % bug. It redefines the internal \KOMAScript{} macro \cs{@addchap} without
5602 % testing the definition. From version 6.71b this is done only, if a very
5603 % old \KOMAScript{} is used. However, I would prefer removing all such code
5604 % from \pkg{hyperref}. Currently we warn, if such an old \pkg{hyperref} is
5605 % used. But this will be removed in future.
5606 % \end{description}
5607 % \begin{macrocode}
5608 %<*book>
5609 \AfterPackage{hyperref}{%
5610 \@ifpackagelater{hyperref}{2001/02/19}{}{%
5611 \ClassWarningNoLine{\KOMAClassName}{%
5612 You are using an old version of the hyperref package!\MessageBreak%
5613 This version has a buggy hack in many drivers,\MessageBreak%
5614 causing \string\addchap\space to behave strangely.\MessageBreak%
5615 Please update hyperref to at least version 6.71b%
5616 }%
5617 }%
5618 }
5619 %</book>
5620 %</body>
5621 % \end{macrocode}
5622 % \end{macro}^^A \@saddchap
5623 % \end{macro}^^A \@addchap
5624 % \end{command}^^A \addchap
5625 %
5626 %
5627 % \begin{macro}{\l@chapter}
5628 % \changes{v2.9k}{2003/01/02}{supporting option \opt{tocleft}}
5629 % \changes{v2.96b}{2006/11/30}{prevent page break between chapter entry and
5630 % parent}
5631 % \changes{v2.96b}{2006/11/30}{prevent page break between chapter entry and
5632 % child}
5633 % \changes{v2.97c}{2007/06/21}{\cs{sectfont} replaced by font element
5634 % \fnt{chapterentry}}
5635 % \changes{v2.97c}{2007/06/21}{using font element
5636 % \fnt{chapterentrypagenumber}}
5637 % \changes{v2.97c}{2007/06/21}{re-implemented to support left aligned entries}
5638 % \changes{v3.15}{2014/12/22}{using \cs{chaptertocdepth} and
5639 % \cs{scr@chapter@tocnumwidth}}
5640 % \changes{v3.15}{2014/12/10}{initial skip with \cs{addvspace} instead of
5641 % \cs{vskip}}
5642 % \changes{v3.20}{2015/10/06}{re-implemented using ToC styles}
5643 % \begin{macro}{\scr@chapter@tocindent}
5644 % \changes{v3.15}{2014/12/02}{added}
5645 % \changes{v3.18}{2015/05/20}{indirect definition by \cs{DeclareSectionCommand}}
5646 % \changes{v3.20}{2015/11/06}{really used}
5647 % \end{macro}^^A \scr@chapter@tocindent
5648 % \begin{macro}{\scr@chapter@tocnumwidth}
5649 % \changes{v3.15}{2014/12/02}{added}
5650 % \changes{v3.18}{2015/05/20}{indirect definition by \cs{DeclareSectionCommand}}
5651 % \end{macro}
5652 % \begin{option}{chapterentrydots}
5653 % \changes{v3.15}{2014/12/10}{added}
5654 % Option
5655 % \begin{quote}
5656 % \opt{chapterentrydots=\meta{boolean}}
5657 % \end{quote}
5658 % is the main difference of ToC entry style \texttt{chapter} to ToC entry
5659 % style \texttt{tocline}. It activates the dots between the entry text and the
5660 % page number.
5661 % \begin{description}
5662 % \item[ToDo:] This should be moved to \file{scrkernel-tocstyle.dtx}.
5663 % \end{description}
5664 % \begin{macrocode}
5665 %<*option>
5666 \KOMA@ifkey{chapterentrydots}{@chapterentrywithdots}
5667 %</option>
5668 % \end{macrocode}
5669 % \end{option}^^A chapterentrydots
5670 % \begin{command}{\raggedchapterentry}
5671 % \changes{v2.97c}{2007/06/21}{added}
5672 % \changes{v3.20}{2016/02/23}{removed}
5673 % \changes{v3.21}{2016/06/06}{see \file{scrkernel-tocstyle.dtx},
5674 % style \texttt{tocline}, option \opt{raggedentrytext}}
5675 % The initial setting of option \opt{raggedtext} of chapter ToC entry style
5676 % \texttt{tocline} resp. \texttt{chapter}.
5677 % \begin{description}
5678 % \item[ToDo:] Do we really need this definition? Every definition but
5679 % \cs{raggedright} results in justified text. So not defining it would be
5680 % almost the same. It just would not reserve the macro. But this could be
5681 % done in \file{scrkernel-tocstyle.dtx}.
5682 % \end{description}
5683 % \begin{macrocode}
5684 %<*body>
5685 \newcommand*{\raggedchapterentry}{}
5686 % \end{macrocode}
5687 % \end{command}^^A \raggedchapterentry
5688 % \end{macro}^^A \l@chapter
5689 %
5690 % \begin{macro}{\l@chapteratlist}
5691 % \changes{v2.96a}{2006/12/03}{added}
5692 % This is used for chapter entries to other directories by the table of
5693 % contents. By default it uses \cs{l@chapter}. But users can redefine it
5694 % using, i.e., \cs{DeclareTOCStyleEntry}. However in this case they have to
5695 % setup all the attributes/options on their own.
5696 % \begin{macrocode}
5697 \newcommand*{\l@chapteratlist}{\l@chapter}
5698 % \end{macrocode}
5699 % \end{macro}^^A \l@chapteratlist
5700 %
5701 % \begin{counter}{chapter}
5702 % \begin{command}{\thechapter}
5703 % \begin{command}{\chapterformat}
5704 % \changes{v2.3c}{1995/08/06}{auto dot feature}
5705 % \changes{v2.7}{2000/01/03}{white space replaced by \cs{enskip}}
5706 % \changes{v2.8}{2001/06/15}{\cs{chapappifprefix} added}
5707 % \changes{v2.8o}{2001/09/19}{\cs{chapappifprefix} replaced by
5708 % \cs{chapappifchapterprefix}}
5709 % \changes{v2.96a}{2006/12/02}{\cs{mbox} added}
5710 % \changes{v3.17}{2015/03/08}{\cs{enskip} not in prefix line mode}
5711 % \begin{command}{\chaptermarkformat}
5712 % \changes{v2.3a}{1995/07/08}{space after chapter number increased}
5713 % \changes{v2.3c}{1995/08/06}{auto dot feature}
5714 % \changes{v2.8}{2001/06/15}{\cs{chapappifprefix} added}
5715 % \changes{v2.8o}{2001/09/19}{\cs{chapappifprefix} replaced by
5716 % \cs{chapappifchapterprefix}}
5717 % \changes{v3.03a}{2009/04/03}{tilde replaced by \cs{nobreakspace} for better
5718 % \pkg{babel-spanish} support}
5719 % The counter would also be defined by \cs{DeclareSectionCommand}. But because
5720 % of handling \cs{frontmatter} and \cs{backmatter} and prefix lines we cannot
5721 % use the default definition of the formatting. So we define it already before
5722 % calling \cs{DeclareSectionCommand} for \cs{chapter}.
5723 % \begin{macrocode}
5724 \newcounter{chapter}
5725 \renewcommand*{\thechapter}{\@arabic\c@chapter}
5726 \newcommand*{\chapterformat}{%
5727 \mbox{\chapappifchapterprefix{\nobreakspace}\thechapter\autodot
5728 \IfUsePrefixLine{}{\enskip}}%
5729 }
5730 \newcommand*\chaptermarkformat{\chapappifchapterprefix{\ }%
5731 \thechapter\autodot\enskip}
5732 % \end{macrocode}
5733 % \end{command}^^A \chaptermarkformat
5734 % \end{command}^^A \chapterformat
5735 % \end{command}^^A \thechapter
5736 % \end{counter}^^A chapter
5737 %
5738 %
5739 % \begin{command}{\chaptername}
5740 % \changes{v3.36}{2022/03/15}{explicit definition for English languages}
5741 % The name of a chapter, e.g., used for the prefix line and maybe for the ToC
5742 % entry.
5743 % \begin{macrocode}
5744 \newcommand*\chaptername{Chapter}
5745 \providecaptionname{american,australian,british,canadian,english,newzealand,%
5746 UKenglish,ukenglish,USenglish,usenglish}\chaptername{Chapter}
5747 % \end{macrocode}
5748 % \end{command}^^A \chaptername
5749 %
5750 %
5751 % \begin{command}{\appendixname}
5752 % \changes{v3.36}{2022/03/15}{explicit definition for English languages}
5753 % The same for appendix chapters.
5754 % \begin{macrocode}
5755 \newcommand*\appendixname{Appendix}
5756 \providecaptionname{american,australian,british,canadian,english,newzealand,%
5757 UKenglish,ukenglish,USenglish,usenglish}\appendixname{Appendix}
5758 % \end{macrocode}
5759 % \end{command}^^A \appendixname
5760 %
5761 %
5762 % \begin{command}{\chapappifprefix}
5763 % \changes{v2.8}{2001/06/15}{added}
5764 % \changes{v2.8o}{2001/09/19}{deprecated}
5765 % \changes{v3.36}{2022/03/18}{removed}
5766 % \begin{description}
5767 % \item[Note:] Command \cs{chapappifprefix} has been removed in \KOMAScript{}
5768 % v3.36, because it is deprecated from \KOMAScript{} v2.8o and there never has
5769 % been a compatibility switch for versions before \KOMAScript{} v2.9.
5770 % \end{description}
5771 % \end{command}^^A \chapappifprefix
5772 %
5773 %
5774 % \begin{command}{\chapappifchapterprefix}
5775 % \changes{v2.8o}{2001/09/19}{added}
5776 % \changes{v3.18}{2015/06/09}{using \cs{IfChapterUsePrefixLine}}
5777 % \begin{command}{\IfChapterUsesPrefixLine}
5778 % \changes{v3.18}{2015/06/09}{added}
5779 % \begin{command}{\chapapp}
5780 % \changes{v2.8}{2001/06/15}{added}
5781 % \begin{macro}{\@chapapp}
5782 % The \LaTeX{} standard classes provide an internal macro \cs{@chapapp} that
5783 % is either \cs{chaptername} or \cs{appendixname} depending on whether we are
5784 % inside or outside the appendix. For compatibility with lots of packages
5785 % \KOMAScript{} does provide this too. But for the user level this is
5786 % cumbersome. So \KOMAScript{} does also provide a \emph{read only specified}
5787 % user command \cs{chapapp}. \KOMAScript{} itself uses \cs{chapapp} inside
5788 % \begin{quote}
5789 % \cs{chapappifchapterprefix}\marg{then string}
5790 % \end{quote}
5791 % that outputs \cs{then string} prefixed by \cs{chapapp} only, if
5792 % \opt{chapterprefix} (resp. \opt{headings=twolinechapter}) has been activated
5793 % and therefore a chapter prefix line has to be used. A more general version
5794 % \cs{chapterifchapterprefix} is
5795 % \begin{quote}
5796 % \cs{IfChapterUsesPrefixLine}\marg{then code}\marg{else code}
5797 % \end{quote}
5798 % that executes \cs{then code} if a chapter prefix line has to be used and
5799 % \cs{else code} otherwise (both without extra prefix).
5800 % \begin{macrocode}
5801 \newcommand*{\chapappifchapterprefix}[1]{%
5802 \IfChapterUsesPrefixLine{\chapapp#1}{}%
5803 }
5804 \newcommand*{\IfChapterUsesPrefixLine}{%
5805 \if@chapterprefix\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi
5806 }
5807 \newcommand*{\chapapp}{\@chapapp}
5808 \newcommand*\@chapapp{\chaptername}
5809 % \end{macrocode}
5810 % \end{macro}^^A \@chapapp
5811 % \end{command}^^A \chapapp
5812 % \end{command}^^A \IfChapterUsePrefixLine
5813 % \end{command}^^A \chapappifchapterprefix
5814 %
5815 %
5816 % \begin{command}{\chaptermark}
5817 % Before selecting a page style with automatic running head, \cs{chapter}
5818 % should simply not change the left or right mark.
5819 % \begin{description}
5820 % \item[ToDo:] Do we really need this or would the later
5821 % \cs{DeclareSectionCommand} be enough to do the initial definition?
5822 % \end{description}
5823 % \begin{macrocode}
5824 \newcommand*\chaptermark[1]{}
5825 % \end{macrocode}
5826 % \end{command}
5827 %
5828 % \begin{command}{\addchapmark}
5829 % \changes{v3.12}{2013/03/26}{added}
5830 % \cs{addchap} and marks for running heads are a little bit more
5831 % complicated. Currently we are using a local redefinition of
5832 % \cs{if@mainmatter} and setting of \cnt{secnumdept} to switch of numbering
5833 % and then using \cs{chaptermark}. So the \cs{chaptermark} definition should
5834 % always respect at least one of these settings.
5835 % \begin{description}
5836 % \item[Note:] The ToDo note at \cs{chaptermark} is not relevant for this
5837 % definition.
5838 % \end{description}
5839 % \begin{macrocode}
5840 \newcommand*\addchapmark[1]{%
5841 \begingroup
5842 \expandafter\let\csname if@mainmatter\expandafter\endcsname
5843 \csname iffalse\endcsname
5844 \c@secnumdepth=\numexpr \chapternumdepth-1\relax
5845 \chaptermark{#1}%
5846 \endgroup
5847 }
5848 % \end{macrocode}
5849 % \end{command}^^A \addchapmark
5850 %
5851 %
5852 % \begin{command}{\raggedchapter}
5853 % \changes{v3.15}{2014/12/09}{added}
5854 % Style \texttt{chapter} does not use \cs{raggedsection} but
5855 % \cs{raggedchapter}. However, the initial value is \cs{raggedsection}, so a
5856 % change of \cs{raggedsection} would also change the initial behave of
5857 % \cs{raggedchapter}. Nevertheless the alignment of chapters in independent
5858 % from the alignment of sections, if wanted.
5859 % \begin{macrocode}
5860 \newcommand*{\raggedchapter}{\raggedsection}
5861 % \end{macrocode}
5862 % \end{command}
5863 %
5864 %
5865 % \begin{fontelement}{chapterentry}
5866 % \changes{v2.97c}{2007/06/21}{added}
5867 % \changes{v3.06}{2010/06/09}{font element \fnt{sectioning} replaced by
5868 % \fnt{disposition}}
5869 % \cs{chapter} entries to the table of contents initially using
5870 % \fnt{disposition}, the basic font of all outlines.
5871 % \begin{macrocode}
5872 \newkomafont{chapterentry}{\usekomafont{disposition}}
5873 % \end{macrocode}
5874 % \end{fontelement}
5875 %
5876 % \begin{fontelement}{chapterentrypagenumber}
5877 % \changes{v2.97c}{2007/06/21}{added}
5878 % The page number of \cs{chapter} entries to the table of contents is
5879 % initially the same as the entry at whole.
5880 % \begin{macrocode}
5881 \newkomafont{chapterentrypagenumber}{}
5882 % \end{macrocode}
5883 % \end{fontelement}
5884 %
5885 % \begin{fontelement}{chapterentrydots}
5886 % \changes{v3.15}{2014/12/10}{added}
5887 % \changes{v3.27}{2019/10/28}{\cs{normalfont} removed}
5888 % If the optional dots for \cs{chapter} entries to the table of contents are
5889 % used, we can change the font of the dots also. It is used for the
5890 % \texttt{linefill} of \pkg*{tocbasic} ToC entry style \texttt{chapter}, that
5891 % uses ToC entry style \texttt{tocline} where the line filler is always
5892 % prefixed by \cs{normalfont}\cs{normalsize}. So the setting is relative to
5893 % this. The color is relative to the color of \fnt{chapterentry}.
5894 % \begin{macrocode}
5895 \newkomafont{chapterentrydots}{}
5896 %</body>
5897 %</book|report>
5898 % \end{macrocode}
5899 % \end{fontelement}
5900 %
5901 %
5902 % \subsection{Section, subsections and more}
5903 %
5904 % The outline levels of sections, subsections, subsubsection, paragraphs and
5905 % subparagraphs are all very similar. There are only some special treatments
5906 % of sections with \cls*{scrartcl}, because there \cs{section} is a high-level
5907 % command.
5908 %
5909 % \begin{fontelement}{section,subsection,subsubsection,
5910 % paragraph,subparagraph}
5911 % \changes{v2.8o}{2001/09/14}{added}
5912 % Definition of the font elements used by \cs{section}, \cs{subsection},
5913 % \cs{subsubsection}, \cs{paragraph} and \cs{subparagraph}. The settings are
5914 % done by option \texttt{headings} later. Everything is prepared before this
5915 % option is used the first time. The definition of the font element is done
5916 % manually to stay compatible with old \KOMAScript{} versions using another
5917 % internal macro than the default of \cs{newkomafont}.
5918 % \begin{macrocode}
5919 %<*prepare>
5920 \newcommand*{\size@section}{}
5921 \newcommand*{\scr@fnt@section}{\size@section}
5922 \newcommand*{\size@subsection}{}
5923 \newcommand*{\scr@fnt@subsection}{\size@subsection}
5924 \newcommand*{\size@subsubsection}{}
5925 \newcommand*{\scr@fnt@subsubsection}{\size@subsubsection}
5926 \newcommand*{\size@paragraph}{}
5927 \newcommand*{\scr@fnt@paragraph}{\size@paragraph}
5928 \newcommand*{\size@subparagraph}{}
5929 \newcommand*{\scr@fnt@subparagraph}{\size@subparagraph}
5930 %</prepare>
5931 % \end{macrocode}
5932 % \end{fontelement}^^A section … subparagraph
5933 %
5934 %
5935 % \begin{macro}{\l@section}
5936 % \changes{v2.9k}{2003/01/02}{supporting option \opt{tocleft}}
5937 % \changes{v2.96b}{2006/11/30}{preventing page break between section entry and
5938 % parent}
5939 % \changes{v2.96b}{2006/11/30}{preventing page break between section entry and
5940 % child}
5941 % \changes{v2.97c}{2007/06/21}{\cs{sectfont} replaced by font element
5942 % \fnt{sectionentry}}
5943 % \changes{v2.97c}{2007/06/21}{using font element
5944 % \fnt{sectionentrypagenumber}}
5945 % \changes{v2.97c}{2007/06/21}{re-implemented to support left aligned entries}
5946 % \changes{v3.15}{2014/11/24}{using \cs{sectiontocdepth},
5947 % \cs{scr@section@tocindent} and \cs{scr@section@tocnumwidth}}
5948 % \changes{v3.20}{2015/10/06}{re-implemented using ToC styles}
5949 % \begin{option}{sectionentrydots}
5950 % \changes{v3.15}{2014/12/10}{added}
5951 % With \cls*{scrartcl} option
5952 % \begin{quote}
5953 % \opt{sectionentrydots=\meta{boolean}}
5954 % \end{quote}
5955 % is the main difference of ToC entry style \texttt{section} to ToC entry
5956 % style \texttt{tocline}. It activates the dots between the entry text and the
5957 % page number.
5958 % \begin{description}
5959 % \item[ToDo:] This should be moved to \file{scrkernel-tocstyle.dtx}.
5960 % \end{description}
5961 % \begin{macrocode}
5962 %<*article>
5963 %<*option>
5964 \KOMA@ifkey{sectionentrydots}{@sectionentrywithdots}
5965 %</option>
5966 % \end{macrocode}
5967 % \end{option}^^A sectionentrydots
5968 % \begin{command}{\raggedsectionentry}
5969 % \changes{v2.97c}{2007/06/21}{added}
5970 % \changes{v3.20}{2016/02/23}{removed}
5971 % The initial setting of option \opt{raggedtext} of section ToC entry style
5972 % \texttt{tocline} resp. \texttt{section}.
5973 % \begin{description}
5974 % \item[ToDo:] Do we really need this definition? Every definition but
5975 % \cs{raggedright} results in justified text. So not defining it would be
5976 % almost the same. It just would not reserve the macro. But this could be
5977 % done in \file{scrkernel-tocstyle.dtx}.
5978 % \end{description}
5979 % \begin{macrocode}
5980 %<*body>
5981 \newcommand*{\raggedsectionentry}{}
5982 %</body>
5983 %</article>
5984 % \end{macrocode}
5985 % \end{command}^^A \raggedsectionentry
5986 % \end{macro}^^A \l@section
5987 %
5988 %
5989 % \begin{command}{\addsec}
5990 % \changes{v2.0e}{1994/10/12}{several \cs{markboth} replaced by
5991 % \cs{sectionmark}}
5992 % \changes{v2.2b}{1995/03/20}{\cs{sectionmark} replaced by \cs{@mkboth}}
5993 % \changes{v2.3h}{1995/01/21}{also available with \cls*{scrbook} and
5994 % \cls*{scrreprt}}
5995 % \changes{v2.4g}{1996/11/04}{\cs{section*} moved because of page breaks in
5996 % the table of contents}
5997 % \changes{v2.5d}{1998/01/03}{\cs{@mkboth} replaced by conditional
5998 % \cs{markright}}
5999 % \changes{v2.7a}{2001/01/04}{supporting \pkg{hyperref}}
6000 % \changes{v3.13a}{2014/09/11}{using \cs{SecDef}}
6001 % \begin{macro}{\@addsec}
6002 % \changes{v3.10}{2011/08/30}{using \cs{addsectiontocentry}}
6003 % \changes{v3.10}{2011/08/30}{extended optional argument}
6004 % \changes{v3.12}{2013/02/26}{using \cs{addsecmark}}
6005 % \changes{v3.18}{2015/05/22}{redefinition}
6006 % \begin{macro}{\@saddsec}
6007 % \changes{v3.12}{2013/02/26}{using \cs{addsecmark}}
6008 % \changes{v3.17}{2015/04/20}{expanding \cs{scr@ds@head} in \cs{addsecmark}}
6009 % Since \KOMAScript{} 3.18 using
6010 % \begin{quote}
6011 % \cs{addsec}\oarg{head or ToC entry}\marg{heading}
6012 % \end{quote}
6013 % is very similar to
6014 % |\section[nonumber=true,…]{…}| but also works if the extended optional
6015 % argument is not activated. And
6016 % \begin{quote}
6017 % \cs{addsec*}\marg{heading}
6018 % \end{quote}
6019 % is just a \cs{section*}\marg{heading} with additional |\addsecmark{}| to
6020 % empty the running head.
6021 % \begin{description}
6022 % \item[Note:] Because of simply manipulating \cnt{secnumdepth} this should
6023 % also work with packages like \pkg{hyperref} as long as they support
6024 % sections without numbering.
6025 % \end{description}
6026 % \begin{macrocode}
6027 %<*body>
6028 \newcommand\addsec{\SecDef\@addsec\@saddsec}
6029 \newcommand*{\@addsec}{}
6030 \def\@addsec[#1]#2{%
6031 \edef\reserved@a{%
6032 \unexpanded{%
6033 \section[{#1}]{#2}%
6034 \c@secnumdepth=
6035 }\the\c@secnumdepth\relax
6036 }%
6037 \c@secnumdepth=\numexpr \sectionnumdepth-1\relax
6038 \reserved@a
6039 }
6040 \newcommand*{\@saddsec}[1]{%
6041 \section*{#1}\addsecmark{}%
6042 }
6043 % \end{macrocode}
6044 % \end{macro}^^A \@saddsec
6045 % \end{macro}^^A \@addsec
6046 % \end{command}^^A \addsec
6047 %
6048 %
6049 % \begin{command}{\minisec}
6050 % \changes{v2.8q}{2002/02/28}{\cs{nobreak} after \cs{sectfont} added}
6051 % \changes{v2.9o}{2003/01/31}{\cs{nobreak} after group end}
6052 % \changes{v2.96a}{2006/11/30}{initial value of \cs{parfillskip} depending on
6053 % \opt{version}}
6054 % \changes{v2.96a}{2006/12/03}{not needed \cs{nobreak} removed}
6055 % \changes{v3.13a}{2014/08/07}{handling of distances of immediate following
6056 % headings like \cs{@startsection}}
6057 % \changes{v3.26}{2018/05/14}{missing \cs{interlinepenalty}\cs{@M} added}
6058 % \begin{fontelement}{minisec}
6059 % \changes{v2.8o}{2001/09/14}{using font element \fnt{minisec}}
6060 % \changes{v3.21}{2016/06/12}{missing \cs{nobreak} added}
6061 % \cs{minisec} is a very special additional outline of \KOMAScript. It is
6062 % always free standing but without numbering. Something like
6063 % \cs{sectionlinesformat} is not supported currently. Also entries to the
6064 % table of contents or marks for an automatic running head are not
6065 % supported. However a dedicated font element is provided.
6066 % \begin{macrocode}
6067 \newkomafont{minisec}{}
6068 \newcommand\minisec[1]{%
6069 %<!v4> \expandafter\ifnum\scr@v@is@lt{3.13a}\relax
6070 %<!v4> \@afterindentfalse \vskip 1.5ex
6071 %<!v4> \else
6072 \if@noskipsec \leavevmode \fi
6073 \par
6074 \@afterindentfalse
6075 \if@nobreak
6076 \everypar{}%
6077 \else
6078 \addpenalty\@secpenalty\addvspace{1.5ex}%
6079 \fi
6080 %<!v4> \fi
6081 {\parindent \z@
6082 %<!v4> \expandafter\ifnum\scr@v@is@gt{2.96}\relax
6083 \setlength{\parfillskip}{\z@ plus 1fil}%
6084 %<!v4> \fi
6085 \raggedsection\normalfont\sectfont\nobreak
6086 \usekomafont{minisec}{\nobreak\interlinepenalty \@M #1\par\nobreak}%
6087 }\nobreak
6088 \@afterheading
6089 }
6090 % \end{macrocode}
6091 % \end{fontelement}^^A minisec
6092 % \end{command}^^A \minisec
6093 %
6094 %
6095 % \begin{command}{\addsectiontocentry,\addsubsectiontocentry,
6096 % \addsubsubsectiontocentry,
6097 % \addparagraphtocentry,\addsubparagraphtocentry}
6098 % \changes{v3.10}{2011/08/30}{added}
6099 % We do not use \cs{addcontentsline} directly for the entries to the table of
6100 % contents. Using
6101 % \begin{quote}\raggedright
6102 % \cs{addsectiontocentry}\marg{number}\marg{text}\\
6103 % \cs{addsubsectiontocentry}\marg{number}\marg{text}\\
6104 % \cs{addsubsubsectiontocentry}\marg{number}\marg{text}\\
6105 % \cs{addparagraphtocentry}\marg{number}\marg{text}\\
6106 % \cs{addsubparagraphtocentry}\marg{number}\marg{text}\\
6107 % \end{quote}
6108 % allows easy manipulation of such entries and additional actions. If the
6109 % \meta{number} is completely empty no number should be used. Internally the
6110 % generic \cs{addtocentrydefault} it used, which uses \cs{nonumberline}
6111 % instead of \cs{numberline} in this case. See \file{scrkernel-listsof.dtx}
6112 % for more information.
6113 % \begin{description}
6114 % \item[ToDo:] Should this be moved to \file{scrkernel-listsof.dtx} or even to
6115 % \file{scrkernel-tocstyle.dtx}?
6116 % \item[ToDo:] Are these really needed or would the implicit definition by the
6117 % later \cs{DeclareSectionCommand} be enough as it is already used for
6118 % \cs{addsubsubsectiontocentry}?
6119 % \end{description}
6120 % \begin{macrocode}
6121 \newcommand*{\addsectiontocentry}[2]{%
6122 \addtocentrydefault{section}{#1}{#2}%
6123 }
6124 \newcommand*{\addsubsectiontocentry}[2]{%
6125 \addtocentrydefault{subsection}{#1}{#2}%
6126 }
6127 \newcommand*{\addparagraphtocentry}[2]{%
6128 \addtocentrydefault{paragraph}{#1}{#2}%
6129 }
6130 \newcommand*{\addsubparagraphtocentry}[2]{%
6131 \addtocentrydefault{subparagraph}{#1}{#2}%
6132 }
6133 % \end{macrocode}
6134 % \end{command}
6135 %
6136 %
6137 % \begin{counter}{section}
6138 % \begin{command}{\thesection}
6139 % \changes{v2.97e}{2007/11/23}{chapter number prefix only in main matter}
6140 % \changes{v3.03b}{2009/06/09}{\cs{relax} replaced by white space for better
6141 % support of \pkg{hyperref}}
6142 % \changes{v3.27}{2019/06/26}{using \cs{scr@v@is@gt}}
6143 % \begin{command}{\sectionmarkformat}
6144 % \changes{v2.3a}{1995/07/08}{space after number increased}
6145 % \changes{v2.3c}{1995/08/06}{auto dot feature}
6146 % \begin{counter}{subsection}
6147 % \begin{command}{\thesubsection}
6148 % \begin{command}{\subsectionmarkformat}
6149 % \changes{v2.3a}{1995/07/08}{space after number increased}
6150 % \changes{v2.3c}{1995/08/06}{auto dot feature}
6151 % \begin{counter}{subsubsection}
6152 % \begin{command}{\thesubsubsection}
6153 % \begin{counter}{paragraph}
6154 % \begin{command}{\theparagraph}
6155 % \begin{counter}{subparagraph}
6156 % \begin{command}{\thesubparagraph}
6157 % The counter would also be defined by \cs{DeclareSectionCommand}. But because
6158 % of handling \cs{frontmatter} and \cs{backmatter} and prefix lines we cannot
6159 % use the default definition of the formatting of \cnt{section}. So we define
6160 % it already before calling \cs{DeclareSectionCommand} for \cs{section}.
6161 % \begin{description}
6162 % \item[ToDo:] Do we really need the explicit definition of \cnt{subsection},
6163 % \cnt{subsubsection}, \cnt{paragraph}, and \cnt{subparagraph} of would the
6164 % implicit definition by \cs{DeclareSectionCommand} be enough for these.
6165 % \end{description}
6166 % \begin{macrocode}
6167 %<*book|report>
6168 \newcounter{section}[chapter]
6169 \renewcommand*\thesection{%
6170 %<*book>
6171 %<!v4> \expandafter\ifnum\scr@v@is@gt{2.97d}%
6172 \if@mainmatter\thechapter.\fi
6173 %<!v4> \else
6174 %</book>
6175 \thechapter.%
6176 %<book&!v4> \fi
6177 \@arabic\c@section
6178 }
6179 %</book|report>
6180 %<*article>
6181 \newcounter{section}
6182 \renewcommand*{\thesection}{\@arabic\c@section}
6183 %</article>
6184 \newcommand*\sectionmarkformat{\thesection\autodot\enskip}
6185 \newcounter{subsection}[section]
6186 \renewcommand*{\thesubsection}{\thesection.\@arabic\c@subsection}
6187 %<*article>
6188 \newcommand*\subsectionmarkformat{\thesubsection\autodot\enskip}
6189 %</article>
6190 \newcounter{subsubsection}[subsection]
6191 \renewcommand*{\thesubsubsection}{%
6192 \thesubsection.\@arabic\c@subsubsection
6193 }
6194 \newcounter{paragraph}[subsubsection]
6195 \renewcommand*{\theparagraph}{\thesubsubsection.\@arabic\c@paragraph}
6196 \newcounter{subparagraph}[paragraph]
6197 \renewcommand*{\thesubparagraph}{%
6198 \theparagraph.\@arabic\c@subparagraph
6199 }
6200 % \end{macrocode}
6201 % \begin{macro}{\@seccntformat}
6202 % \changes{v2.3c}{1995/08/06}{CJK support extended}
6203 % \changes{v2.9p}{2004/01/07}{\cs{protect} added}
6204 % \changes{v2.97}{2007/01/24}{workaround for the ugly \cs{protect}}
6205 % \changes{v3.17}{2015/02/23}{using \cs{\dots format} if exists}
6206 % \changes{v3.17}{2015/03/31}{using \cs{protect} for \cs{\dots format}}
6207 % \begin{command}{\othersectionlevelsformat}
6208 % \changes{v2.7}{2000/01/03}{added}
6209 % \changes{v2.7}{2000/01/03}{\cs{quad} replaced by \cs{enskip}}
6210 % \changes{v2.7i}{2001/05/17}{\cs{let} replaced by \cs{def}}
6211 % \changes{v2.97}{2007/01/24}{three arguments instead of only one}
6212 % With \KOMAScript~2 \cs{othersectionlevelsformat} has had only one argument,
6213 % the \cs{…format} command of the level. But with there has been expansion
6214 % issues. So we have had to change the definition to
6215 % \begin{quote}
6216 % \cs{othersectionlevelsformat}\marg{level name}\marg{ignore
6217 % command}\marg{the command}
6218 % \end{quote}
6219 % Users who use or redefine \cs{othersectionlevelsformat} should always ignore
6220 % the \meta{ignore command}. It is used to internally handle deprecated
6221 % definitions of \cs{othersectionlevelsformat} with only one
6222 % argument. \meta{level name} is the name of the level command, e.g.,
6223 % |subsubsection|. \meta{the command} is the \cs{the…} command corresponding
6224 % with \marg{level name}. See the definition of \cs{@seccntformat} for more
6225 % information about the internal usage of \cs{othersectionlevelsformat}.
6226 % \begin{description}
6227 % \item[ToDo:] Can we somehow change this for \KOMAScript~4 to no longer
6228 % support the second argument (unless a low compatibility level is used)?
6229 % \end{description}
6230 % \begin{macrocode}
6231 \newcommand*{\othersectionlevelsformat}[3]{#3\autodot\enskip}
6232 \renewcommand*{\@seccntformat}[1]{%
6233 %<!v4> \expandafter\ifnum\scr@v@is@lt{3.17}\relax
6234 %<!v4> \protect\othersectionlevelsformat{#1}{%
6235 %<!v4> \expandafter\aftergroup\noexpand\@gobble}{\csname the#1\endcsname}%
6236 %<!v4> \else
6237 \scr@ifundefinedorrelax{#1format}{%
6238 \protect\othersectionlevelsformat{#1}{%
6239 \expandafter\aftergroup\noexpand\@gobble}{\csname the#1\endcsname}%
6240 }{\expandafter\protect\csname #1format\endcsname}%
6241 %<!v4> \fi
6242 }
6243 % \end{macrocode}
6244 % \end{command}^^A \othersectonlevelsformat
6245 % \end{macro}^^A \@seccntformat
6246 % \end{command}^^A \thesubparagraph
6247 % \end{counter}^^A subparagraph
6248 % \end{command}^^A \theparagraph
6249 % \end{counter}^^A paragraph
6250 % \end{command}^^A \thesubsubsection
6251 % \end{counter}^^A subsubsection
6252 % \end{command}^^A \subsectionformat
6253 % \end{command}^^A \thesubsection
6254 % \end{counter}^^A subsection
6255 % \end{command}^^A \sectionformat
6256 % \end{command}^^A \thesection
6257 % \end{counter}^^A section
6258 %
6259 %
6260 % \begin{command}{\addsecmark}
6261 % \changes{v3.12}{2013/03/26}{added}
6262 % \cs{addsec} and marks for running heads are a little bit
6263 % complicated. Currently we are using a local setting of \cnt{secnumdept} to
6264 % switch of numbering and then using \cs{sectionmark}. So the \cs{sectionmark}
6265 % definition should always respect \cnt{secnumdepth}.
6266 % \begin{macrocode}
6267 \newcommand*\addsecmark[1]{%
6268 \begingroup
6269 \c@secnumdepth=\numexpr \sectionnumdepth-1\relax
6270 \sectionmark{#1}%
6271 \endgroup
6272 }
6273 % \end{macrocode}
6274 % \end{command}^^A \addsecmark
6275 %
6276 %
6277 % \begin{fontelement}{sectionentry}
6278 % \changes{v2.97c}{2007/06/21}{added}
6279 % \changes{v3.06}{2010/06/09}{font element \fnt{sectioning} replaced by
6280 % \fnt{disposition}}
6281 % With \cls*{scrartcl} \cs{section} entries to the table of contents initially
6282 % using \fnt{disposition}, the basic font of all outlines.
6283 % \begin{macrocode}
6284 %<*article>
6285 \newkomafont{sectionentry}{\usekomafont{disposition}}
6286 % \end{macrocode}
6287 % \end{fontelement}
6288 %
6289 % \begin{fontelement}{sectionentrypagenumber}
6290 % \changes{v2.97c}{2007/06/21}{added}
6291 % The page number of \cs{section} entries to the table of contents is
6292 % initially the same as the entry at whole with \cls*{scrartcl}.
6293 % \begin{macrocode}
6294 \newkomafont{sectionentrypagenumber}{}
6295 % \end{macrocode}
6296 % \end{fontelement}
6297 %
6298 % \begin{fontelement}{sectionentrydots}
6299 % \changes{v3.15}{2014/12/10}{added}
6300 % \changes{v3.27}{2019/10/28}{\cs{normalfont} removed}
6301 % If the optional dots for \cs{section} entries to the table of contents are
6302 % used, we can change the font of the dots also. It is used for the
6303 % \texttt{linefill} of \pkg*{tocbasic} ToC entry style \texttt{section}, that
6304 % uses ToC entry style \texttt{tocline} where the line filler is always
6305 % prefixed by \cs{normalfont}\cs{normalsize}. So the setting is relative to
6306 % this. The color is relative to the color of \fnt{sectionentry}.
6307 % \begin{macrocode}
6308 \newkomafont{sectionentrydots}{}
6309 %</article>
6310 % \end{macrocode}
6311 % \end{fontelement}
6312 %
6313 %
6314 % \begin{command}{\partnumdepth,\chapternumdepth,
6315 % \sectionnumdepth,\subsectionnumdepth,\subsubsectionnumdepth,
6316 % \paragraphnumdepth,\subparagraphnumdepth,
6317 % \parttocdepth,\chaptertocdepth
6318 % \sectiontocdepth,\subsectiontocdepth,\subsubsectiontocdepth,
6319 % \paragraphtocdepth,\subparagraphtocdepth}
6320 % \changes{v3.12}{2013/12/16}{added}
6321 % \changes{v3.15}{2014/12/09}{indirect definition by
6322 % \cs{DeclareSectionCommand}}
6323 % The section numbering levels, to be compared with counter
6324 % \cnt{secnumdepth}, and the table of contents entry levels, to be compared
6325 % with counter \cs{tocdepth}, of all outline commands defined by the
6326 % \KOMAScript{} classes.
6327 % \begin{description}
6328 % \item[Note:] These are specified to be \emph{read only}. They are defined by
6329 % \cs{DeclareSectionCommand}.
6330 % \end{description}
6331 % \end{command}^^A \partnumdepth … \subparagraphtocdepth
6332 %
6333 % \begin{command}{\part}
6334 % \changes{v3.18}{2015/05/25}{indirect definition by \cs{DeclareSectionCommand}}
6335 % \changes{v3.26}{2018/06/27}{definition moved behind \cs{section} because of
6336 % bookmark level workaround}
6337 % \begin{command}{\chapter}
6338 % \changes{v2.8d}{2001/07/05}{using \cs{chapterpagestyle}}
6339 % \changes{v3.18}{2015/05/20}{indirect definition by \cs{DeclareSectionCommand}}
6340 % \begin{command}{\section}
6341 % \changes{v2.8p}{2001/09/22}{\cs{sectfont} before \cs{size@section}}
6342 % \changes{v2.8q}{2002/02/28}{\cs{nobreak} after \cs{sectfont} added}
6343 % \changes{v2.96a}{2006/11/30}{initial value of \cs{parfillskip} depending on
6344 % option \opt{version}}
6345 % \changes{v2.96a}{2006/12/03}{not needed \cs{nobreak} removed}
6346 % \changes{v3.13a}{2014/09/11}{using \cs{scr@startsection}}
6347 % \changes{v3.15}{2014/11/24}{indirect definition by \cs{DeclareSectionCommand}}
6348 % \begin{command}{\subsection}
6349 % \changes{v2.8p}{2001/09/22}{\cs{sectfont} before \cs{size@subsection}}
6350 % \changes{v2.8q}{2002/02/28}{\cs{nobreak} after \cs{sectfont} added}
6351 % \changes{v2.96a}{2006/11/30}{initial value of \cs{parfillskip} depending on
6352 % option \opt{version}}
6353 % \changes{v2.96a}{2006/12/03}{not needed \cs{nobreak} removed}
6354 % \changes{v3.13a}{2014/09/11}{using \cs{scr@startsection}}
6355 % \changes{v3.15}{2014/11/24}{indirect definition by \cs{DeclareSectionCommand}}
6356 % \begin{command}{\subsubsection}
6357 % \changes{v2.3d}{1995/08/19}{with \cls*{scrartcl} also numbered and added to
6358 % ToC}
6359 % \changes{v2.8p}{2001/09/22}{\cs{sectfont} added before
6360 % \cs{size@subsubsection}}
6361 % \changes{v2.8q}{2002/02/28}{\cs{nobreak} added after \cs{sectfont}}
6362 % \changes{v2.96a}{2006/11/30}{initial value of \cs{parfillskip} depending on
6363 % option \opt{version}}
6364 % \changes{v2.96a}{2006/12/03}{not needed \cs{nobreak} removed}
6365 % \changes{v3.13a}{2014/09/11}{using \cs{scr@startsection}}
6366 % \changes{v3.15}{2014/11/24}{indirect definition by \cs{DeclareSectionCommand}}
6367 % \begin{command}{\paragraph}
6368 % \changes{v2.8p}{2001/09/22}{\cs{sectfont} added before
6369 % \cs{size@paragraph}}
6370 % \changes{v2.8q}{2002/02/28}{\cs{nobreak} added after \cs{sectfont}}
6371 % \changes{v2.96a}{2006/12/03}{not needed \cs{nobreak} removed}
6372 % \changes{v3.15}{2014/11/24}{indirect definition by \cs{DeclareSectionCommand}}
6373 % \begin{command}{\subparagraph}
6374 % \changes{v2.8p}{2001/09/22}{\cs{sectfont} added before
6375 % \cs{size@subparagraph}}
6376 % \changes{v2.8q}{2002/02/28}{\cs{nobreak} added after \cs{sectfont}}
6377 % \changes{v2.96a}{2006/12/03}{not needed \cs{nobreak} removed}
6378 % \changes{v3.13a}{2014/09/11}{using \cs{scr@startsection}}
6379 % \changes{v3.15}{2014/11/24}{indirect definition by \cs{DeclareSectionCommand}}
6380 % \changes{v3.15}{2014/11/24}{\cs{parindent} replaced by \cs{scr@parindent}}
6381 % Commands \cs{part}, \cs{chapter}, \cs{section}, \cs{subsection},
6382 % \cs{subsubection}, \cs{paragraph} and \cs{subparagraph} are defined using
6383 % \cs{DeclareSectionCommand}. The definition of \cs{part} must be \emph{after}
6384 % \cs{section} because of the bookmark level workaround (see definition of
6385 % \cs{DelcareSectionCommand}. The declaration of \cs{chapter} uses only those
6386 % settings that do not depend on options, because settings by class options
6387 % must no be overwritten here. So all settings that do depend on class options
6388 % have to be initialized before the options (see the \texttt{prepare} code of
6389 % such options above). For the lower levels this is only the case for the font.
6390 % \begin{macrocode}
6391 %<*book|report>
6392 \DeclareSectionCommand[%
6393 style=chapter,%
6394 level=\z@,%
6395 pagestyle=plain,%
6396 tocstyle=chapter,%
6397 tocindent=\z@,%
6398 tocnumwidth=1.5em%
6399 ]{chapter}
6400 %</book|report>
6401 \DeclareSectionCommand[%
6402 style=section,%
6403 level=1,%
6404 indent=\z@,%
6405 beforeskip=-3.5ex \@plus -1ex \@minus -.2ex,%
6406 afterskip=2.3ex \@plus.2ex,%
6407 tocstyle=section,%
6408 %<book|report> tocindentfollows=chapter,%
6409 %<article> tocindent=0pt,%
6410 %<book|report> tocindent=1.5em,%
6411 %<article> tocnumwidth=1.5em%
6412 %<book|report> tocnumwidth=2.3em%
6413 ]{section}
6414 \DeclareSectionCommand[%
6415 style=part,%
6416 %<article> level=\z@,%
6417 %<report|book> level=\m@ne,%
6418 %<report|book> pagestyle=plain,%
6419 tocstyle=part,%
6420 toclevel=\m@ne,%
6421 tocindent=\z@,%
6422 tocnumwidth=2em%
6423 ]{part}
6424 \DeclareSectionCommand[%
6425 style=section,%
6426 level=2,%
6427 indent=\z@,%
6428 beforeskip=-3.25ex\@plus -1ex \@minus -.2ex,%
6429 afterskip=1.5ex \@plus .2ex,%
6430 %<article> tocstyle=subsection,%
6431 %<book|report> tocstyle=section,%
6432 %<article> tocindent=1.5em,%
6433 %<book|report> tocindent=3.8em,%
6434 %<article> tocnumwidth=2.3em%
6435 %<book|report> tocnumwidth=3.2em%
6436 ]{subsection}
6437 \DeclareSectionCommand[%
6438 style=section,%
6439 level=3,%
6440 indent=\z@,%
6441 beforeskip=-3.25ex\@plus -1ex \@minus -.2ex,%
6442 afterskip=1.5ex \@plus .2ex,%
6443 %<article> tocstyle=subsection,%
6444 %<book|report> tocstyle=section,%
6445 %<article> tocindent=3.8em,%
6446 %<book|report> tocindent=7.0em,%
6447 %<article> tocnumwidth=3.2em%
6448 %<book|report> tocnumwidth=4.1em%
6449 ]{subsubsection}
6450 \DeclareSectionCommand[%
6451 style=section,%
6452 level=4,%
6453 indent=\z@,%
6454 beforeskip=3.25ex \@plus1ex \@minus.2ex,%
6455 afterskip=-1em,%
6456 %<article> tocstyle=subsection,%
6457 tocindentfollows=subsubsection,%
6458 %<book|report> tocstyle=section,%
6459 %<article> tocindent=7.0em,%
6460 %<book|report> tocindent=10em,%
6461 %<article> tocnumwidth=4.1em%
6462 %<book|report> tocnumwidth=5em%
6463 ]{paragraph}
6464 \DeclareSectionCommand[%
6465 style=section,%
6466 level=5,%
6467 indent=\scr@parindent,%
6468 beforeskip=3.25ex \@plus1ex \@minus .2ex,%
6469 afterskip=-1em,%
6470 %<article> tocstyle=subsection,%
6471 %<book|report> tocstyle=section,%
6472 %<article> tocindent=10em,%
6473 %<book|report> tocindent=12em,%
6474 %<article> tocnumwidth=5em%
6475 %<book|report> tocnumwidth=6em%
6476 ]{subparagraph}
6477 %<!v4>\expandafter\ifnum\scr@v@is@lt{3.15}\relax
6478 %<!v4> \let\scr@subparagraph@sectionindent\parindent
6479 %<!v4>\else
6480 \def\scr@subparagraph@sectionindent{\scr@parindent}%
6481 %<!v4>\fi
6482 %</body>
6483 % \end{macrocode}
6484 % \end{command}^^A \subparagraph
6485 % \end{command}^^A \paragraph
6486 % \end{command}^^A \subsubsection
6487 % \end{command}^^A \subsection
6488 % \end{command}^^A \section
6489 % \end{command}^^A \chapter
6490 % \end{command}^^A \part
6491 %
6492 %
6493 % \subsection{Fonts}
6494 %
6495 % The font settings of dedicated elements of the the corresponding section
6496 % levels already have been done. But there are also some elements that do not
6497 % correspond with a single section level.
6498 %
6499 % \begin{fontelement}{disposition,sectioning}
6500 % \changes{v2.95b}{2006/07/30}{added}
6501 % \changes{v3.39}{2023/04/04}{also with \pkg*{scrextend} as documented}
6502 % \begin{macro}{\sectfont}
6503 % \changes{v2.8c}{2001/06/29}{\cs{normalcolor} added}
6504 % \changes{v3.12}{2013/11/11}{earlier definition to support option
6505 % \opt{headings\quotechar=standardclasses}}
6506 % \changes{v3.20}{2016/01/29}{\cs{sffamily} replaced by \cs{@gr@gsffamily}}
6507 % \changes{v3.39}{2023/04/04}{\cs{@gr@gsfamily} replaced by \cs{maybesffamily}}
6508 % This element is not only used by all section levels before the dedicated
6509 % element of the single level is used. It is also used by other elements like
6510 % the \fnt{chaptertocentry}. The command \cs{sectfont} instead of the
6511 % \cs{newkomafont} default is used for compatibility only. So it is specified
6512 % as internal. Using it as user command is deprecated!
6513 % \begin{macrocode}
6514 %</class&!letter>
6515 %<*(class&!letter)|(package&extend)>
6516 %<*prepare>
6517 \newcommand*{\sectfont}{\normalcolor\maybesffamily\bfseries}
6518 %</prepare>
6519 %</(class&!letter)|(package&extend)>
6520 %<*book|report|article|extend>
6521 %<*body>
6522 \newcommand*{\scr@fnt@disposition}{\sectfont}
6523 \aliaskomafont{sectioning}{disposition}
6524 %</body>
6525 %</book|report|article|extend>
6526 % \end{macrocode}
6527 % \end{macro}^^A \sectfont
6528 % \end{fontelement}^^A disposition, sectioning
6529 %
6530 %
6531 % \begin{option}{headings}
6532 % \changes{v2.3h}{1996/01/20}{Size of \cs{chapter} decreased by one grade
6533 % step}
6534 % \changes{v2.3h}{1996/01/20}{using \cs{chapterheadstartvskip} and
6535 % \cs{chapterheadendvskip}}
6536 % \changes{v2.7c}{2000/01/19}{vertical distance after chapters slightly
6537 % changed and glue added}
6538 % \changes{v2.98c}{2008/03/10}{added}
6539 % \changes{v3.10}{2011/08/30}{extended optional argument}
6540 % \changes{v3.12}{2013/03/05}{using \cs{FamilyKeyState}}
6541 % \changes{v3.12}{2013/08/26}{\cs{KOMA@options} replaced by \cs{KOMAoptions}}
6542 % \changes{v3.12}{2013/11/11}{value \opt{\quotechar=standardclasses} added}
6543 % \changes{v3.15}{2014/11/24}{using \cs{scr@chapter@beforeskip} and
6544 % \cs{scr@chapter@afterskip}}
6545 % \changes{v3.17}{2015/03/09}{using internal value storage}
6546 % \changes{v3.18}{2015/05/20}{values of \cs{scr@chapter@beforeskip} negative}
6547 % \changes{v3.39}{2022/11/11}{initial dot removed from member argument of
6548 % option storage commands}
6549 % Option \opt{headings} is the main switch for the headings of all outlines.
6550 % It provides the following values:
6551 % \begin{macrocode}
6552 %<*class&!letter>
6553 %<*option>
6554 \KOMA@key{headings}{%
6555 \KOMA@set@ncmdkey{headings}{@tempa}{%
6556 % \end{macrocode}
6557 % \begin{description}
6558 % \item[\opt{=big}:] use big sized headings. This also changes the distances
6559 % of chapter and redefined \cs{chapterheadstartvskip} and
6560 % \cs{chapterheadendvskip} (\cls*{scrbook} and \cls*{scrreprt} only).
6561 % \end{description}
6562 % \begin{macrocode}
6563 {big}{0},%
6564 % \end{macrocode}
6565 % \begin{description}
6566 % \item[\opt{=normal}:] use medium sized headings. This also changes the
6567 % distances of chapter and redefined \cs{chapterheadstartvskip} and
6568 % \cs{chapterheadendvskip} (\cls*{scrbook} and \cls*{scrreprt} only).
6569 % \end{description}
6570 % \begin{macrocode}
6571 {normal}{1},%
6572 % \end{macrocode}
6573 % \begin{description}
6574 % \item[\opt{=small}:] use small sized headings. This also changes the
6575 % distances of chapter and redefined \cs{chapterheadstartvskip} and
6576 % \cs{chapterheadendvskip} (\cls*{scrbook} and \cls*{scrreprt} only).
6577 % \end{description}
6578 % \begin{macrocode}
6579 {small}{2},%
6580 % \end{macrocode}
6581 % \begin{description}
6582 % \item[\opt{=openany}:] same as \opt{open=any} for \cls*{scrbook} and
6583 % \cls*{scrreprt}.
6584 % \end{description}
6585 % \begin{macrocode}
6586 %<*book|report>
6587 {openany}{3},%
6588 % \end{macrocode}
6589 % \begin{description}
6590 % \item[\opt{=openright}:] same as \opt{open=right} for \cls*{scrbook} and
6591 % \cls*{scrreprt}.
6592 % \end{description}
6593 % \begin{macrocode}
6594 {openright}{4},%
6595 % \end{macrocode}
6596 % \begin{description}
6597 % \item[\opt{=openleft}:] same as \opt{open=left} for \cls*{scrbook} and
6598 % \cls*{scrreprt}.
6599 % \end{description}
6600 % \begin{macrocode}
6601 {openleft}{5},%
6602 % \end{macrocode}
6603 % \begin{description}
6604 % \item[\opt{=twolinechapter}:] use chapter headings with two lines. The first
6605 % line is a kind of prefix line with the number and a prefix text only. The
6606 % second one is the heading text.
6607 % \end{description}
6608 % \begin{macrocode}
6609 {twolinechapter}{6},{chapterprefix}{6},{chapterwithprefix}{6},%
6610 {chapterwithprefixline}{6},%
6611 % \end{macrocode}
6612 % \begin{description}
6613 % \item[\opt{=onelinechapter}:] use chapter headings without the prefix line.
6614 % \end{description}
6615 % \begin{macrocode}
6616 {onelinechapter}{7},{nochapterprefix}{7},{chapterwithoutprefix}{7},%
6617 {chapterwithoutprefixline}{7},%
6618 % \end{macrocode}
6619 % \begin{description}
6620 % \item[\opt{=twolineappendix}:] use chapter headings with two lines in the
6621 % appendix. This overwrites \opt{headings=onelinechapter} for the chapters
6622 % of the appendix.
6623 % \end{description}
6624 % \begin{macrocode}
6625 {twolineappendix}{8},{appendixprefix}{8},{appendixwithprefix}{8},%
6626 {appendixwithprefixline}{8},%
6627 % \end{macrocode}
6628 % \begin{description}
6629 % \item[\opt{=onelineappendix}:] use chapter headings without prefix line in
6630 % the appendix. This overwrites \opt{headings=twolinechapter} for the
6631 % chapters of the appendix.
6632 % \end{description}
6633 % \begin{macrocode}
6634 {onelineappendix}{9},{noappendixprefix}{9},{appendixwithoutprefix}{9},%
6635 {appendixwithoutprefixline}{9},%
6636 %</book|report>
6637 % \end{macrocode}
6638 % \begin{description}
6639 % \item[\opt{=optiontotocandhead}:] activates the extended option handling of
6640 % all outline commands and uses an unspecified optional argument as default
6641 % of for the running head and the ToC entry.
6642 % \end{description}
6643 % \begin{macrocode}
6644 {optiontotocandhead}{10},{optiontoheadandtoc}{10},%
6645 % \end{macrocode}
6646 % \begin{description}
6647 % \item[\opt{=optiontotoc}:] activates the extended option handling of all
6648 % outline commands and uses an unspecified optional argument as default for
6649 % the ToC entry only.
6650 % \end{description}
6651 % \begin{macrocode}
6652 {optiontotoc}{11},%
6653 % \end{macrocode}
6654 % \begin{description}
6655 % \item[\opt{=optiontohead}:] activated the extended option handling of all
6656 % outline commands and uses an unspecified optional argument as default fot
6657 % the running head.
6658 % \end{description}
6659 % \begin{macrocode}
6660 {optiontohead}{12},%
6661 % \end{macrocode}
6662 % \begin{description}
6663 % \item[\opt{=standardclasses}:] reconfigure headings (at least the fonts) to
6664 % look more like the headings of the standard classes than the defaults of
6665 % \KOMAScript.
6666 % \end{description}
6667 % \begin{macrocode}
6668 {standardclasses}{13}%
6669 }{#1}%
6670 \ifx\FamilyKeyState\FamilyKeyStateProcessed
6671 \ifcase \@tempa\relax% big
6672 \KOMA@kav@remove{\KOMAClassFileName}{headings}{big}%
6673 \KOMA@kav@remove{\KOMAClassFileName}{headings}{normal}%
6674 \KOMA@kav@remove{\KOMAClassFileName}{headings}{small}%
6675 \KOMA@kav@remove{\KOMAClassFileName}{headings}{standardclasses}%
6676 \KOMA@kav@add{\KOMAClassFileName}{headings}{big}%
6677 % \end{macrocode}
6678 % First of all we handle the three size values.
6679 % \begin{description}
6680 % \item[Note:] These are redefining \cs{chapterheadstartvkip} and
6681 % \cs{chapterheadendvskip}.
6682 % \item[Note:] The |+\baselineskip+\parskip| is needed to stay compatible with
6683 % old version of \KOMAScript{} not providing \cs{DeclareSectionCommand}. They
6684 % are regarded inside setting of the preamble to print heading with
6685 % |beforeskip=0pt| at the very beginning of the text area.
6686 % \end{description}
6687 % \begin{macrocode}
6688 %<*book|report>
6689 \renewcommand*{\scr@chapter@beforeskip}{-3.3\baselineskip-\parskip}%
6690 \renewcommand*{\scr@chapter@afterskip}{%
6691 1.725\baselineskip \@plus .115\baselineskip \@minus .192\baselineskip
6692 }%
6693 \renewcommand*{\scr@chapter@innerskip}{.5\baselineskip}%
6694 \renewcommand*{\chapterheadstartvskip}{\vspace{\@tempskipa}}%
6695 \renewcommand*{\chapterheadendvskip}{%
6696 %<!v4> \expandafter\ifnum\scr@v@is@lt{3.15}\vspace\@tempskipa\else
6697 \vskip\@tempskipa
6698 %<!v4> \fi
6699 }%
6700 \renewcommand*{\chapterheadmidvskip}{\par\nobreak\vskip\@tempskipa}%
6701 %</book|report>
6702 \setkomafont{part}{\Huge}%
6703 \setkomafont{partnumber}{\huge}%
6704 %<book|report> \setkomafont{chapter}{\huge}%
6705 %<book|report> \setkomafont{chapterprefix}{\size@chapter}%
6706 \setkomafont{section}{\Large}%
6707 \setkomafont{subsection}{\large}%
6708 \setkomafont{subsubsection}{\normalsize}%
6709 \setkomafont{paragraph}{\normalsize}%
6710 \setkomafont{subparagraph}{\normalsize}%
6711 \or % normal
6712 \KOMA@kav@remove{\KOMAClassFileName}{headings}{big}%
6713 \KOMA@kav@remove{\KOMAClassFileName}{headings}{normal}%
6714 \KOMA@kav@remove{\KOMAClassFileName}{headings}{small}%
6715 \KOMA@kav@remove{\KOMAClassFileName}{headings}{standardclasses}%
6716 \KOMA@kav@add{\KOMAClassFileName}{headings}{normal}%
6717 %<*book|report>
6718 \renewcommand*{\scr@chapter@beforeskip}{-3\baselineskip-\parskip}%
6719 \renewcommand*{\scr@chapter@afterskip}{%
6720 1.5\baselineskip \@plus .1\baselineskip \@minus .167\baselineskip
6721 }%
6722 \renewcommand*{\scr@chapter@innerskip}{.5\baselineskip}%
6723 \renewcommand*{\chapterheadstartvskip}{\vspace{\@tempskipa}}%
6724 \renewcommand*{\chapterheadendvskip}{%
6725 %<!v4> \expandafter\ifnum\scr@v@is@lt{3.15}\vspace\@tempskipa\else
6726 \vskip\@tempskipa
6727 %<!v4> \fi
6728 }%
6729 \renewcommand*{\chapterheadmidvskip}{\par\nobreak\vskip\@tempskipa}%
6730 %</book|report>
6731 \setkomafont{part}{\huge}%
6732 \setkomafont{partnumber}{\huge}%
6733 %<*book|report>
6734 \setkomafont{chapter}{\LARGE}%
6735 \setkomafont{chapterprefix}{\size@chapter}%
6736 \setkomafont{section}{\Large}%
6737 \setkomafont{subsection}{\large}%
6738 %</book|report>
6739 %<*article>
6740 \setkomafont{section}{\large}%
6741 \setkomafont{subsection}{\normalsize}%
6742 %</article>
6743 \setkomafont{subsubsection}{\normalsize}%
6744 \setkomafont{paragraph}{\normalsize}%
6745 \setkomafont{subparagraph}{\normalsize}%
6746 \or % small
6747 \KOMA@kav@remove{\KOMAClassFileName}{headings}{big}%
6748 \KOMA@kav@remove{\KOMAClassFileName}{headings}{normal}%
6749 \KOMA@kav@remove{\KOMAClassFileName}{headings}{small}%
6750 \KOMA@kav@remove{\KOMAClassFileName}{headings}{standardclasses}%
6751 \KOMA@kav@add{\KOMAClassFileName}{headings}{small}%
6752 %<*book|report>
6753 \renewcommand*{\scr@chapter@beforeskip}{-2.8\baselineskip-\parskip}%
6754 \renewcommand*{\scr@chapter@afterskip}{%
6755 1.35\baselineskip \@plus 0.09\baselineskip \@minus .15\baselineskip
6756 }%
6757 \renewcommand*{\scr@chapter@innerskip}{.5\baselineskip}%
6758 \renewcommand*{\chapterheadstartvskip}{\vspace{\@tempskipa}}%
6759 \renewcommand*{\chapterheadendvskip}{%
6760 %<!v4> \expandafter\ifnum\scr@v@is@lt{3.15}\vspace\@tempskipa\else
6761 \vskip\@tempskipa
6762 %<!v4> \fi
6763 }%
6764 \renewcommand*{\chapterheadmidvskip}{\par\nobreak\vskip\@tempskipa}%
6765 %</book|report>
6766 \setkomafont{part}{\LARGE}%
6767 \setkomafont{partnumber}{\LARGE}%
6768 %<*book|report>
6769 \setkomafont{chapter}{\Large}%
6770 \setkomafont{chapterprefix}{\size@chapter}%
6771 \setkomafont{section}{\large}%
6772 %</book|report>
6773 %<*article>
6774 \setkomafont{section}{\normalsize}%
6775 %</article>
6776 \setkomafont{subsection}{\normalsize}%
6777 \setkomafont{subsubsection}{\normalsize}%
6778 \setkomafont{paragraph}{\normalsize}%
6779 \setkomafont{subparagraph}{\normalsize}%
6780 % \end{macrocode}
6781 % \cls*{scrbook} and \cls*{scrreprt} also provide settings that are delegated
6782 % to option \opt{open}.
6783 % \begin{macrocode}
6784 \or % openany
6785 %<*book|report>
6786 \KOMAoptions{open=any}%
6787 %</book|report>
6788 \or % openright
6789 %<*book|report>
6790 \KOMAoptions{open=right}%
6791 %</book|report>
6792 \or % openleft
6793 %<*book|report>
6794 \KOMAoptions{open=left}%
6795 %</book|report>
6796 % \end{macrocode}
6797 % \cls*{scrbook} and \cls*{scrreprt} also provide settings that are delegated
6798 % to option \opt{chapterprefix} and \opt{appendixprefix}.
6799 % \begin{macrocode}
6800 \or % twolinechapter
6801 %<*book|report>
6802 \KOMAoptions{chapterprefix=true}%
6803 %</book|report>
6804 \or % onelinechapter
6805 %<*book|report>
6806 \KOMAoptions{chapterprefix=false}%
6807 %</book|report>
6808 \or % twolineappendix
6809 %<*book|report>
6810 \KOMAoptions{appendixprefix=true}%
6811 %</book|report>
6812 \or % onelineappendix
6813 %<*book|report>
6814 \KOMAoptions{appendixprefix=false}%
6815 %</book|report>
6816 % \end{macrocode}
6817 % We have also options to handle the extended optional argument.
6818 % \begin{macrocode}
6819 \or % optiontotocandhead
6820 \KOMA@kav@remove{\KOMAClassFileName}{headings}{optiontotocandhead}%
6821 \KOMA@kav@remove{\KOMAClassFileName}{headings}{optiontotoc}%
6822 \KOMA@kav@remove{\KOMAClassFileName}{headings}{optiontohead}%
6823 \KOMA@kav@add{\KOMAClassFileName}{headings}{optiontotocandhead}%
6824 \scr@activate@xsection{3}%
6825 \or % optiontotoc
6826 \KOMA@kav@remove{\KOMAClassFileName}{headings}{optiontotocandhead}%
6827 \KOMA@kav@remove{\KOMAClassFileName}{headings}{optiontotoc}%
6828 \KOMA@kav@remove{\KOMAClassFileName}{headings}{optiontohead}%
6829 \KOMA@kav@add{\KOMAClassFileName}{headings}{optiontotoc}%
6830 \scr@activate@xsection{2}%
6831 \or % optiontohead
6832 \KOMA@kav@remove{\KOMAClassFileName}{headings}{optiontotocandhead}%
6833 \KOMA@kav@remove{\KOMAClassFileName}{headings}{optiontotoc}%
6834 \KOMA@kav@remove{\KOMAClassFileName}{headings}{optiontohead}%
6835 \KOMA@kav@add{\KOMAClassFileName}{headings}{optiontohead}%
6836 \scr@activate@xsection{1}%
6837 % \end{macrocode}
6838 % Last but not least the option to activate the standard class emulation of
6839 % headings.
6840 % \begin{macrocode}
6841 \or % standardclasses
6842 \KOMA@kav@remove{\KOMAClassFileName}{headings}{big}%
6843 \KOMA@kav@remove{\KOMAClassFileName}{headings}{normal}%
6844 \KOMA@kav@remove{\KOMAClassFileName}{headings}{small}%
6845 \KOMA@kav@remove{\KOMAClassFileName}{headings}{standardclasses}%
6846 \KOMA@kav@add{\KOMAClassFileName}{headings}{standardclasses}%
6847 %<*book|report>
6848 \renewcommand*{\scr@chapter@beforeskip}{-50\p@}%
6849 \renewcommand*{\scr@chapter@afterskip}{40\p@}%
6850 \renewcommand*{\scr@chapter@innerskip}{20\p@}%
6851 \renewcommand*{\chapterheadstartvskip}{\vspace{\@tempskipa}}%
6852 \renewcommand*{\chapterheadendvskip}{\vskip\@tempskipa}%
6853 \renewcommand*{\chapterheadmidvskip}{\par\nobreak\vskip\@tempskipa}%
6854 \setkomafont{part}{\Huge}%
6855 \setkomafont{partnumber}{\huge}%
6856 \setkomafont{chapter}{\Huge}%
6857 \setkomafont{chapterprefix}{\huge}%
6858 %</book|report>
6859 %<*article>
6860 \setkomafont{part}{\huge}%
6861 \setkomafont{partnumber}{\Large}%
6862 %</article>
6863 \setkomafont{section}{\Large}%
6864 \setkomafont{subsection}{\large}%
6865 \setkomafont{subsubsection}{\normalsize}%
6866 \setkomafont{paragraph}{\normalsize}%
6867 \setkomafont{subparagraph}{\normalsize}%
6868 \renewcommand*{\sectfont}{\bfseries}%
6869 %<book|report> \KOMAoptions{open=right,chapterprefix=true}%
6870 \fi
6871 \fi
6872 }
6873 \KOMA@kav@add{\KOMAClassFileName}{headings}{big}
6874 %<book|report>\KOMA@kav@add{\KOMAClassFileName}{headings}{onelinechapter}
6875 % \end{macrocode}
6876 % \end{option}^^A headings
6877 %
6878 % \begin{option}{bigheadings,normalheadings,smallheadings}
6879 % \changes{v2.3h}{1996/01/20}{added}
6880 % \changes{v2.4g}{1996/11/04}{option name fixed}
6881 % \changes{v2.98c}{2008/03/10}{obsolete}
6882 % \changes{v3.01a}{2008/11/20}{deprecated}
6883 % \changes{v3.99}{2022/11/16}{removed from \KOMAScript~4}
6884 % \begin{macro}{\@bigheadings,\@normalheadings,\@smallheadings}
6885 % \changes{v2.98c}{2008/03/10}{removed}
6886 % \end{macro}^^A \@bigheadings … \@smallheadings
6887 % We also have some deprecated options.
6888 % \begin{macrocode}
6889 %<*!v4>
6890 \KOMA@DeclareDeprecatedOption{bigheadings}{headings=big}
6891 \KOMA@DeclareDeprecatedOption{normalheadings}{headings=normal}
6892 \KOMA@DeclareDeprecatedOption{smallheadings}{headings=small}
6893 %</!v4>
6894 %</option>
6895 % \end{macrocode}
6896 % \end{option}^^A smallheading,normalheadings,bigheadings
6897 %
6898 % \begin{macrocode}
6899 %</class&!letter>
6900 % \end{macrocode}
6901 %
6902 % \Finale
6903 % \PrintChanges
6904 %
6905 \endinput
6906 % Local Variables:
6907 % mode: doctex
6908 % ispell-local-dictionary: "en_US"
6909 % eval: (flyspell-mode 1)
6910 % TeX-master: t
6911 % TeX-engine: luatex-dev
6912 % 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"))
6913 % End: