Debian Codegraph @

texmf-dist/source/latex/standardsectioning/standardsectioning.dtx

raw
1 % \iffalse meta-comment
2 % ======================================================================
3 % standardsectioning.dtx
4 % Copyright © 2008–2025 Markus Kohm
5 %
6 % This work is a KOMA-Script spin-off. For the original sources of
7 % KOMA-Script's `float.hak' see file `scrhack.dtx' in the KOMA-Script
8 % sources at <https://sourceforge.net/p/koma-script/code/>.
9 %
10 % Development is taking place as part of `scrhack' at
11 % <https://github.com/komascript/third-party-enhancements>. New issues
12 % should be reported there as well as known issues can be found.
13 %
14 % This work may be distributed and/or modified under the conditions of
15 % the LaTeX Project Public License, version 1.3c of the license.
16 % The latest version of this license is in
17 % http://www.latex-project.org/lppl.txt
18 % and version 1.<3c or later is part of all distributions of LaTeX
19 % version 2005/12/01 or later and of this work.
20 %
21 % This work has the LPPL maintenance status "maintained".
22 %
23 % The Current Maintainer and author of this work is Markus Kohm.
24 %
25 % This work consists of the files `standardsectioning.dtx' and
26 % `README.md'.
27 %
28 % This work also uses code derived from the standard LaTeX classes.
29 % These classes have been released under the LaTeX Project Public
30 % License. For the copyright of the original code see `classes.dtx'
31 % <https://ctan.org/tex-archive/macros/latex/base/classes.dtx>.
32 % Note: For support of the derived code, do not contact the authors of
33 % the original code! They are not responsible for this work.
34 %
35 % The recommended way to install `standardsectioning' is to use
36 % the package manager of your TeX distribution.
37 % ======================================================================
38 %
39 %<*dtx>
40 \ifx\ProvidesExplFile\undefined\def\ProvidesExplFile#1#2#3#4{}\fi
41 \ProvidesExplFile{standardsectioning.dtx}
42 %</dtx>
43 %<*dtx|package>
44 %<package>\ProvidesExplPackage{standardsectioning}
45 {2025-09-11}{0.10}
46 {%
47 %<*dtx>
48 sources and unpack driver of
49 %</dtx>
50 forcing standard class sectioning definitions%
51 }
52 %</dtx|package>
53 %<*dtx>
54 \ifx\documentclass\undefined
55 \input docstrip.tex
56 \generate{%
57 \file{standardsectioning.sty}{%
58 \from{standardsectioning.dtx}{package}%
59 }%
60 }%
61 \else
62 \let\endbatchfile\ExplSyntaxOff
63 \fi
64 \endbatchfile
65 \documentclass[ngerman,USenglish]{koma-script-source-doc}
66 \NewDocElement[%
67 macrolike = true,
68 toplevel = true,
69 idxtype = \textit{var.},
70 idxgroup = Variable,
71 printtype = \textit{var.},
72 ]{Variable}{Variable}
73 \setcounter{IndexColumns}{2}
74 \usepackage{babel}
75 \usepackage{csquotes}
76 \usepackage[style=alphabetic]{biblatex}
77 \begin{filecontents}[force]{\jobname.bib}
78 @manual{pkg:scrhack:manual,
79 author={Markus Kohm},
80 version={3.42},
81 date={2023-07-26},
82 title={Emulating Former \KOMAScript{} Package \pkg*{scrhack}},
83 url={https://mirrors.ctan.org/macros/latex/contrib/scrhack/scrhack.pdf},
84 urldate={2023-07-26},
85 }
86 @online{pkg:koma-script,
87 author={Markus Kohm},
88 version={3.41},
89 date={2023-07-07},
90 title={{\KOMAScript} --- A bundle of versatile classes and packages},
91 url={https://ctan.org/pkg/koma-script},
92 urldate={2023-07-14},
93 note={The \KOMAScript{} bundle provides replacements for the \pkg*{article},
94 \pkg*{report}, and \pkg*{book} classes with emphasis on typography and
95 versatility. There is also a letter class.},
96 }
97 @manual{pkg:koma-script:manual:de,
98 author={Markus Kohm},
99 date={2023-06-16},
100 title={{\KOMAScript}},
101 subtitle={Die Anleitung},
102 url={http://mirrors.ctan.org/macros/latex/contrib/koma-script/scrguide-de.pdf},
103 urldate={2023-07-04},
104 }
105 @manual{pkg:koma-script:manual:en,
106 author={Markus Kohm},
107 date={2023-06-16},
108 title={{\KOMAScript}},
109 subtitle={The Guide},
110 url={http://mirrors.ctan.org/macros/latex/contrib/koma-script/scrguide-en.pdf},
111 urldate={2023-07-14},
112 }
113 \end{filecontents}
114 \addbibresource{\jobname.bib}
115 \setcounter{StandardModuleDepth}{2}
116 \begin{document}
117 \nocite{pkg:koma-script,pkg:koma-script:manual:en,pkg:koma-script:manual:de}
118 \DocInput{standardsectioning.dtx}
119 \end{document}
120 %</dtx>
121 %\fi
122 %
123 % \changes{v0.1}{2023/06/01}{start of \KOMAScript{} spin-off}
124 % \changes{v0.9}{2024/06/06}{first release}
125 %
126 % \GetFileInfo{standardsectioning.dtx}
127 % \title{Using the Sectioning Command Code of the Standard Classes}
128 % \author{\href{mailto:[email protected]}{Markus Kohm}}
129 % \date{Version \filedate{} \fileversion}
130 % \maketitle
131 % \begin{abstract}
132 % A long time ago
133 % \href{https://www.sourceforge.net/project/koma-script}{\KOMAScript} was
134 % more or less just a collection of replacements for the three standard
135 % classes \cls*{article}, \cls*{book} and \cls*{report}. Replacing a
136 % standard class with a
137 % \href{https://www.sourceforge.net/project/koma-script}{\KOMAScript} class
138 % was easy, even if users used a lot of additional packages. Over the years,
139 % the author has added many new features and user interfaces to the
140 % classes. This also led to completely different implementation of the
141 % sectioning commands. But some packages depend on an implementation similar
142 % to the standard classes.
143 %
144 % Package \pkg*{standardsectioning} implements these commands with the code
145 % of the standard classes and also deactivates parts of the
146 % \href{https://www.sourceforge.net/project/koma-script}{\KOMAScript} user
147 % interface, which should not be used with these changes. These are more or
148 % less all commands to configure sectioning commands. It also reverts some
149 % internal macros of
150 % \href{https://www.sourceforge.net/project/koma-script}{\KOMAScript}.
151 % \end{abstract}
152 %
153 % \tableofcontents
154 %
155 %\iffalse
156 %<*doc>
157 %\fi
158 \section{What are the typical reasons for using package
159 \texorpdfstring{\pkg*{standardsectioning}}{standardsectioning} and how to do
160 it?}
161 \label{sec:reasons}
162
163 Sometimes replacing a standard class by a
164 \href{https://komascript.de/}{\KOMAScript} class results in new errors,
165 because of incompatibility of some of the packages or the already existing
166 preamble code with these classes. In such a case, you first should try out
167 package \pkg{scrhack} without passing any option to that package. Package
168 \pkg{scrhack} should be the first package after loading the document class, or
169 even be loaded \emph{before} the document class using \cs{RequirePackage}
170 instead of \cs{usepackage}. If this already fixes the issue, you can try to
171 find out which of the replacements and enhancements loaded by \pkg{scrhack}
172 solved the issue and load only these.
173
174 Only if you cannot fix the issue this kind you can try loading
175 \pkg*{standardsectioning} either also using \pkg{scrhack} with
176 corresponding options (see \cite{pkg:scrhack:manual}) or just loading
177 \pkg*{standardsectioning}.
178
179 Such errors happen, e.g., because
180 \pkg{titlesec}\index{Packages:>\pkg{titlesec}} makes assumptions about the
181 definition of the sectioning commands that simply do not apply to the
182 \href{https://komascript.de/}{\KOMAScript} classes. This leads, e.g., in the
183 following example:
184 \begin{verbatim}
185 \documentclass{scrartcl}
186 \usepackage{titlesec}
187 \begin{document}
188 \section{Test Section}
189 Test text.
190 \end{document}
191 \end{verbatim}
192 to the error message:
193 \begin{verbatim}
194 Package titlesec Error: No format for this command.
195
196 See the titlesec package documentation for explanation.
197 Type H <return> for immediate help.
198 ...
199
200 l.4 \section{Test Section}
201 \end{verbatim}
202 Several other errors can happen with combinations of \pkg{titlesec} and
203 \href{https://komascript.de/}{\KOMAScript} classes. Best solution for this,
204 would be to not use \pkg{titlesec} and instead use the class' interface to
205 configure the sectioning commands, e.g., \cs{RedeclareSectionCommand},
206 \cs{setkomafont}, or redefining \cs{sectionlinesformat}. See
207 \cite{pkg:koma-script:manual:en} or \cite{pkg:koma-script:manual:de} for more
208 information. But if you do not use any of the enhanced sectioning features of
209 the \href{https://komascript.de/}{\KOMAScript} classes, a first-aid workaround
210 would be to load package \pkg*{standardsectioning} immediately \emph{after}
211 the class:
212 \begin{verbatim}
213 \documentclass{scrartcl}
214 \usepackage{standardsectioning}
215 \usepackage{titlesec}
216 \begin{document}
217 \section{Test Section}
218 Test text.
219 \end{document}
220 \end{verbatim}
221 Among other things, this redefines the sectioning commands to be compatible
222 with the standard classes.
223 \begin{description}\sloppy
224 \item[But note:] \leavevmode
225 \marginline{\raisebox{\dimexpr\ht\strutbox-\height\relax}{\Huge\textcolor{red}{!}}}%
226 This also means, that all the enhancements to these commands are broken! You
227 cannot use \cs{DeclareSectionCommand}, \cs{RedeclareSectionCommand},
228 \cs{DeclareNewSectionCommand}, \cs{ProvideSectionCommand},
229 \cs{DeclareSectionCommands}, \cs{RedeclareSectionCommands},
230 \cs{DeclareNewSectionCommands}, or \cs{ProvideSectionCommands} any
231 longer. Other commands like \cs{partformat}, \cs{chapterformat},
232 \cs{sectionformat}, \cs{subsectionformat}, \cs{subsubsectionformat},
233 \cs{paragraphformat}, \cs{subparagraphformat} and many more are not used
234 anymore.
235 \end{description}
236
237 Sometimes a wrapper classes loads a \href{https://komascript.de/}{\KOMAScript}
238 class and than also loads a package like \pkg{titlesec}. To load
239 \pkg*{standardsections} immediately after the class, you should use the
240 generic class hook available from \LaTeX{} 2020-10-01:
241 \begin{verbatim}
242 \AddToHook{class/scrartcl/after}{\RequirePackage{standardsectioning}}
243 \AddToHook{class/scrbook/after}{\RequirePackage{standardsectioning}}
244 \AddToHook{class/scrreprt/after}{\RequirePackage{standardsectioning}}
245 \end{verbatim}
246 These lines should be placed \texttt{before} \cs{documentclass}. If you are
247 using an older \LaTeX{} version you can use
248 \href{https://komascript.de/}{\KOMAScript} package \pkg{scrlfile} to do the
249 same:
250 \begin{verbatim}
251 \RequirePackage{scrlfile}
252 \AfterClass{scrartcl}{\RequirePackage{standardsectioning}}
253 \AfterClass{scrbook}{\RequirePackage{standardsectioning}}
254 \AfterClass{scrreport}{\RequirePackage{standardsectioning}}
255 \end{verbatim}
256 also \emph{before} loading the class.
257
258 \section{How to select the correct sectioning code, if the automatism fails?}
259 \label{sec:options}
260
261 By default, the package uses an automatism to decide which code of which
262 standard class should be used. If the \KOMAScript{} class \cls{scrartcl} is
263 detected, automatically the code of \cls{article} is used. If the
264 \KOMAScript{} class \cls{scrreprt} is detected, automatically the code of
265 \cls{report} is used. If the \KOMAScript{} class \cls{scrbook} is detected,
266 automatically the code of \cls{book} is used. If none of these classes is
267 detected, the existence of two commands is used. If \cs{chapter} is not
268 defined, the code of \cls{article} is used. If \cs{chapter} is defined, but
269 \cs{frontmatter} is not defined, the code of \cls{report} is used. If both
270 \cs{chapter} and \cs{frontmatter} are defined, the code of \cls{book} is used.
271
272 %\DescribeOption{article}
273 %\DescribeOption{book}
274 %\DescribeOption{report}
275 Very seldom this automatism fails and the wrong code is used, which results in
276 error messages or printing mistakes. In this case you can load package
277 \pkg*{standardsectioning} with one of the options \opt{article}, \opt{report}
278 or \opt{book} to force the usage of the sectioning code of either
279 \cls{article}, \cls{report}, or \cls{book}. This could, e.g., be needed, if
280 you are using a class, that defines \cs{chapter} and \cs{frontmatter} but not
281 \cs{if@mainmatter}. In this case, you should use
282 \begin{verbatim}
283 \usepackage[report]{standardsectioning}
284 \end{verbatim}
285 instead of
286 \begin{verbatim}
287 \usepackage{standardsectioning}
288 \end{verbatim}
289 because otherwise the not defined \cs{if@mainmatter} will result in errors,
290 when using \cs{chapter}.
291 % \iffalse
292 %</doc>
293 % \fi
294 %
295 % \MaybeStop{\printbibliography[heading=bibintoc]\PrintIndex}
296 %
297 % \iffalse
298 %<*package>
299 %<@@=standardsectioning>
300 % \fi
301 % \section{Implementation}
302 % \label{sec:implementation}
303 %
304 % \subsection{Messages}
305 % \label{ssec:messages}
306 %
307 % There are some messages, that may be used several times:
308 % \begin{macrocode}
309 \msg_new:nnnn { standardsectioning } { wrong-package-order }
310 {
311 wrong~package~order~detected.
312 }
313 {
314 You've~loaded~this~package~after~package~#1.\iow_newline:
315 But~this~cannot~work.\iow_newline:
316 Loading aborted!
317 }
318
319 \msg_new:nnn { standardsectioning } { deactivate-extended-section-commands }
320 {
321 extended~sectioning~option~handling~deactivated.
322 }
323
324 \msg_new:nnn { standardsectioning } { no-force-with-KOMA-Script-class }
325 {
326 package~option~`#1'~is~ignored~due~to~usage~of~KOMA-Script~class~\KOMAClassName.
327 }
328 % \end{macrocode}
329 %
330 % \subsection{Package order}
331 % \label{ssec:packageorder}
332 %
333 % \pkg{hyperref} must not be loaded, because otherwise deactivation of
334 % \cs{scr@chapter@after@hyperref@patch} would not work.
335 % \begin{macrocode}
336 \@ifpackageloaded { hyperref }
337 {
338 \msg_critical:nnn { standardsectioning } { wrong-package-order }
339 { hyperref }
340 } { }
341 % \end{macrocode}
342 % \pkg{titlesec} must not be loaded, because otherwise the re-definitions
343 % would overwrite the definitions of this package.
344 % \begin{macrocode}
345 \@ifpackageloaded { titlesec }
346 {
347 \msg_critical:nnn { standardsectioning } { wrong-package-order }
348 { titlesec }
349 } { }
350 % \end{macrocode}
351 % \pkg{sectsty} must not be loaded, because otherwise the re-definitions
352 % would overwrite the definitions of this package.
353 % \begin{macrocode}
354 \@ifpackageloaded { sectsty }
355 {
356 \msg_critical:nnnn { standardsectioning } { wrong-package-order }
357 { sectsty }
358 } { }
359 % \end{macrocode}
360 %
361 % \subsection{\KOMAScript{} deactivation code}
362 % \label{ssec:deactivationcode}
363 %
364 % \ExplSyntaxOn
365 % \begin{macro}{\@@_common_komascript_deactivation_code:}
366 % \ExplSyntaxOff
367 % Some deactivation code is common for all \KOMAScript{} classes and
368 % therefore we use an auxiliary function to not need to copy it several
369 % times.
370 % \begin{macrocode}
371 \cs_new:Nn \@@_common_komascript_deactivation_code:
372 {
373 % \end{macrocode}
374 % \begin{macro}{\@startsection}
375 % \changes{v0.10}{2025-09-11}{conditional restore}
376 % \KOMAScript{} classes before v3.49 redefine this internal \LaTeX{} kernel
377 % macro. In this case \cs{scr@saved@startsection} is defined, differs from
378 % \cs{@startsection} and has the definition found before redefining the
379 % original macro. We do nothing else but resetting \cs{@startsection} to this
380 % saved definition.
381 % \begin{macrocode}
382 \cs_if_exist:NT \scr@saved@startsection
383 { \RenewCommandCopy \@startsection \scr@saved@startsection }
384 % \end{macrocode}
385 % \end{macro}
386 % \begin{macro}{\@sect,\@ssect,\@xsect}
387 % \changes{v0.10}{2025-09-11}{conditional restore}
388 % All these should be restored to their original definitions stored in
389 % \cs{scr@latex@\dots}.
390 % \begin{macrocode}
391 \cs_if_exist:NT \scr@latex@sect
392 { \RenewCommandCopy\@sect\scr@latex@sect }
393 \cs_if_exist:NT \scr@latex@ssect
394 { \RenewCommandCopy\@ssect\scr@latex@ssect }
395 \cs_if_exist:NT \scr@latex@xsect
396 { \RenewCommandCopy\@xsect\scr@latex@xsect }
397 % \end{macrocode}
398 % \end{macro}
399 % \begin{command}{\DeclareSectionCommand,\RedeclareSectionCommand,
400 % \DeclareNewSectionCommand,\ProvideSectionCommand,
401 % \DeclareSectionCommands,\RedeclareSectionCommands,
402 % \DeclareNewSectionCommands,\ProvideSectionCommands}
403 % These \KOMAScript{} commands do not make sense any longer after forced
404 % redefinition of \cs{part} \dots{} \cs{subparagraph}. They even would not
405 % work correctly after resetting, e.g., \cs{@startsection}. So best reaction
406 % is to \emph{undefine} them.
407 % \begin{macrocode}
408 \cs_undefine:N \DeclareSectionCommand
409 \cs_undefine:N \DeclareSectionCommands
410 \cs_undefine:N \RedeclareSectionCommand
411 \cs_undefine:N \RedeclareSectionCommands
412 \cs_undefine:N \DeclareNewSectionCommand
413 \cs_undefine:N \DeclareNewSectionCommands
414 \cs_undefine:N \ProvideSectionCommand
415 \cs_undefine:N \ProvideSectionCommands
416 % \end{macrocode}
417 % \end{command}
418 % \begin{macro}{\minisec}
419 % This also has to be undefined, because it also uses internal \KOMAScript{}
420 % definitions, which are deactivated.
421 % \begin{macrocode}
422 \cs_undefine:N \minisec
423 % \end{macrocode}
424 % \end{macro}
425 % \begin{macro}{\scr@chapter@before@hyperref@patch,
426 % \scr@chapter@after@hyperref@patch}
427 % Now, definitions without respecting \pkg{hyperref} are used, so
428 % \pkg{hyperref} should again be able to patch them. So the hack should
429 % deactivate the patch deactivation of the \KOMAScript{} classes.
430 % \begin{macrocode}
431 \cs_gset_eq:NN \scr@chapter@before@hyperref@patch \relax
432 \cs_gset_eq:NN \scr@chapter@after@hyperref@patch \relax
433 % \end{macrocode}
434 % \end{macro}
435 % \begin{macro}{\scr@osectarg}
436 % The \KOMAScript{} classes use this macro to store how to use the optional
437 % argument of section commands. But with the standard class definition the
438 % only possibility is to use it as running head and write it into the table of
439 % contents without any extended handling. So the only value, that makes sense
440 % is 0.
441 % \begin{macrocode}
442 \int_if_zero:nF { \scr@osectarg }
443 {
444 \msg_warning:nn { standardsectioning }
445 { deactivate-extended-section-commands }
446 \cs_gset_eq:NN \scr@osectarg \c_zero_int
447 }
448 % \end{macrocode}
449 % \end{macro}
450 % \begin{macro}{\scr@activate@xsection}
451 % Further changing of the value has to be deactivated.
452 % \begin{macrocode}
453 \renewcommand*{\scr@activate@xsection}[1]{%
454 \int_if_zero:nF { ##1 }
455 {
456 \msg_warning:nn { standardsectioning }
457 { deactivate-extended-section-commands }
458 \cs_gset_eq:NN \scr@osectarg \c_zero_int
459 }
460 }%
461 % \end{macrocode}
462 % \end{macro}
463 % \begin{command}{\partlineswithprefixformat,
464 % \sectionlinesformat,\sectioncatchphraseformat}
465 % These \KOMAScript{} commands are not used any longer. To detect errors,
466 % because of redefining them, we undefine them.
467 % \begin{macrocode}
468 \cs_undefine:N \partlineswithprefixformat
469 \cs_undefine:N \sectionlinesformat
470 \cs_undefine:N \sectioncatchphraseformat
471 % \end{macrocode}
472 % \end{command}
473 % \begin{option}{headings}
474 % The \KOMAScript{} option does not make sense any longer. So it is
475 % deactivated and usage will throw an error.
476 % \begin{macrocode}
477 \RelaxFamilyKey[.\KOMAClassFileName]{KOMA}{headings}%
478 \KOMA@kav@removekey{\KOMAClassFileName}{headings}%
479 % \end{macrocode}
480 % \end{option}
481 % \begin{macro}{\scr@class@titlesec@warning}
482 % The warning about loading \pkg{titlesec} has to be removed, because we do
483 % not expect errors any longer.
484 % \begin{macrocode}
485 \cs_undefine:N \scr@class@titlesec@warning
486 % \end{macrocode}
487 % \begin{macrocode}
488 }
489 % \end{macrocode}
490 % \end{macro}
491 % \end{macro}
492 % \ExplSyntaxOff
493 %
494 % \subsection{Sectioning code of the standard classes}
495 % \label{ssec:standardsectioningcommands}
496 %
497 % \begin{command}{\part,\chapter,\section,\subsection,\subsubsection,
498 % \paragraph,\subparagraph}
499 % These commands are redefined using code from
500 % \href{https://ctan.org/tex-archive/macros/latex/base/classes.dtx}
501 % {\file{classes.dtx}}
502 % 2024/02/08 v1.4n.
503 % Only \cs{newcommand} is replaced by \cs{def} and \texttt{\#} are
504 % doubled. Depending on the class, we use different code:
505 % \ExplSyntaxOn
506 % \begin{macro}{\@@_article_sectioning_code:,\@@_book_sectioning_code:,
507 % \@@_report_sectioning_code:}
508 % \ExplSyntaxOff
509 % \begin{macrocode}
510 \cs_new:Nn \@@_article_sectioning_code:
511 {
512 \def\part{%
513 \if@noskipsec \leavevmode \fi
514 \par
515 \addvspace{4ex}%
516 \@afterindentfalse
517 \secdef\@part\@spart}%
518 \def\@part[##1]##2{%
519 \ifnum \c@secnumdepth >\m@ne
520 \refstepcounter{part}%
521 \addcontentsline{toc}{part}{\thepart\hspace{1em}##1}%
522 \else
523 \addcontentsline{toc}{part}{##1}%
524 \fi
525 {\parindent \z@ \raggedright
526 \interlinepenalty \@M
527 \normalfont
528 \ifnum \c@secnumdepth >\m@ne
529 \Large\bfseries \partname\nobreakspace\thepart
530 \par\nobreak
531 \fi
532 \huge \bfseries ##2%
533 \markboth{}{}\par}%
534 \nobreak
535 \vskip 3ex
536 \@afterheading}%
537 \def\@spart##1{%
538 {\parindent \z@ \raggedright
539 \interlinepenalty \@M
540 \normalfont
541 \huge \bfseries ##1\par}%
542 \nobreak
543 \vskip 3ex
544 \@afterheading}%
545
546 \def\section{\@startsection {section}{1}{\z@}%
547 {-3.5ex \@plus -1ex \@minus -.2ex}%
548 {2.3ex \@plus.2ex}%
549 {\normalfont\Large\bfseries}}%
550 \def\subsection{\@startsection{subsection}{2}{\z@}%
551 {-3.25ex\@plus -1ex \@minus -.2ex}%
552 {1.5ex \@plus .2ex}%
553 {\normalfont\large\bfseries}}%
554 \def\subsubsection{\@startsection{subsubsection}{3}{\z@}%
555 {-3.25ex\@plus -1ex \@minus -.2ex}%
556 {1.5ex \@plus .2ex}%
557 {\normalfont\normalsize\bfseries}}%
558 \def\paragraph{\@startsection{paragraph}{4}{\z@}%
559 {3.25ex \@plus1ex \@minus.2ex}%
560 {-1em}%
561 {\normalfont\normalsize\bfseries}}%
562 \def\subparagraph{\@startsection{subparagraph}{5}{\parindent}%
563 {3.25ex \@plus1ex \@minus .2ex}%
564 {-1em}%
565 {\normalfont\normalsize\bfseries}}%
566 }
567
568 \cs_new:Nn \@@_report_sectioning_code:
569 {
570 \def\part{%
571 \if@openright
572 \cleardoublepage
573 \else
574 \clearpage
575 \fi
576 \thispagestyle{plain}%
577 \if@twocolumn
578 \onecolumn
579 \@tempswatrue
580 \else
581 \@tempswafalse
582 \fi
583 \null\vfil
584 \secdef\@part\@spart}
585
586 \def\@part[##1]##2{%
587 \ifnum \c@secnumdepth >-2\relax
588 \refstepcounter{part}%
589 \addcontentsline{toc}{part}{\thepart\hspace{1em}##1}%
590 \else
591 \addcontentsline{toc}{part}{##1}%
592 \fi
593 \markboth{}{}%
594 {\centering
595 \interlinepenalty \@M
596 \normalfont
597 \ifnum \c@secnumdepth >-2\relax
598 \huge\bfseries \partname\nobreakspace\thepart
599 \par
600 \vskip 20\p@
601 \fi
602 \Huge \bfseries ##2\par}%
603 \@endpart}
604 \def\@spart##1{%
605 {\centering
606 \interlinepenalty \@M
607 \normalfont
608 \Huge \bfseries ##1\par}%
609 \@endpart}
610 \def\@endpart{\vfil\newpage
611 \if@twoside
612 \if@openright
613 \null
614 \thispagestyle{empty}%
615 \newpage
616 \fi
617 \fi
618 \if@tempswa
619 \twocolumn
620 \fi}
621 \def\chapter{\if@openright\cleardoublepage\else\clearpage\fi
622 \thispagestyle{plain}%
623 \global\@topnum\z@
624 \@afterindentfalse
625 \secdef\@chapter\@schapter}
626 \def\@chapter[##1]##2{\ifnum \c@secnumdepth >\m@ne
627 \refstepcounter{chapter}%
628 \typeout{\@chapapp\space\thechapter.}%
629 \addcontentsline{toc}{chapter}%
630 {\protect\numberline{\thechapter}##1}%
631 \else
632 \addcontentsline{toc}{chapter}{##1}%
633 \fi
634 \chaptermark{##1}%
635 \addtocontents{lof}{\protect\addvspace{10\p@}}%
636 \addtocontents{lot}{\protect\addvspace{10\p@}}%
637 \if@twocolumn
638 \@topnewpage[\@makechapterhead{##2}]%
639 \else
640 \@makechapterhead{##2}%
641 \@afterheading
642 \fi}
643 \def\@makechapterhead##1{%
644 \vspace*{50\p@}%
645 {\parindent \z@ \raggedright \normalfont
646 \ifnum \c@secnumdepth >\m@ne
647 \huge\bfseries \@chapapp\space \thechapter
648 \par\nobreak
649 \vskip 20\p@
650 \fi
651 \interlinepenalty\@M
652 \Huge \bfseries ##1\par\nobreak
653 \vskip 40\p@
654 }}
655 \def\@schapter##1{\if@twocolumn
656 \@topnewpage[\@makeschapterhead{##1}]%
657 \else
658 \@makeschapterhead{##1}%
659 \@afterheading
660 \fi}
661 \def\@makeschapterhead##1{%
662 \vspace*{50\p@}%
663 {\parindent \z@ \raggedright
664 \normalfont
665 \interlinepenalty\@M
666 \Huge \bfseries ##1\par\nobreak
667 \vskip 40\p@
668 }}
669 \def\section{\@startsection {section}{1}{\z@}%
670 {-3.5ex \@plus -1ex \@minus -.2ex}%
671 {2.3ex \@plus.2ex}%
672 {\normalfont\Large\bfseries}}
673 \def\subsection{\@startsection{subsection}{2}{\z@}%
674 {-3.25ex\@plus -1ex \@minus -.2ex}%
675 {1.5ex \@plus .2ex}%
676 {\normalfont\large\bfseries}}
677 \def\subsubsection{\@startsection{subsubsection}{3}{\z@}%
678 {-3.25ex\@plus -1ex \@minus -.2ex}%
679 {1.5ex \@plus .2ex}%
680 {\normalfont\normalsize\bfseries}}
681 \def\paragraph{\@startsection{paragraph}{4}{\z@}%
682 {3.25ex \@plus1ex \@minus.2ex}%
683 {-1em}%
684 {\normalfont\normalsize\bfseries}}
685 \def\subparagraph{\@startsection{subparagraph}{5}{\parindent}%
686 {3.25ex \@plus1ex \@minus .2ex}%
687 {-1em}%
688 {\normalfont\normalsize\bfseries}}
689 }
690
691 \cs_new:Nn \@@_book_sectioning_code:
692 {
693 \def\part{%
694 \if@openright
695 \cleardoublepage
696 \else
697 \clearpage
698 \fi
699 \thispagestyle{plain}%
700 \if@twocolumn
701 \onecolumn
702 \@tempswatrue
703 \else
704 \@tempswafalse
705 \fi
706 \null\vfil
707 \secdef\@part\@spart}
708
709 \def\@part[##1]##2{%
710 \ifnum \c@secnumdepth >-2\relax
711 \refstepcounter{part}%
712 \addcontentsline{toc}{part}{\thepart\hspace{1em}##1}%
713 \else
714 \addcontentsline{toc}{part}{##1}%
715 \fi
716 \markboth{}{}%
717 {\centering
718 \interlinepenalty \@M
719 \normalfont
720 \ifnum \c@secnumdepth >-2\relax
721 \huge\bfseries \partname\nobreakspace\thepart
722 \par
723 \vskip 20\p@
724 \fi
725 \Huge \bfseries ##2\par}%
726 \@endpart}
727 \def\@spart##1{%
728 {\centering
729 \interlinepenalty \@M
730 \normalfont
731 \Huge \bfseries ##1\par}%
732 \@endpart}
733 \def\@endpart{\vfil\newpage
734 \if@twoside
735 \if@openright
736 \null
737 \thispagestyle{empty}%
738 \newpage
739 \fi
740 \fi
741 \if@tempswa
742 \twocolumn
743 \fi}
744 \def\chapter{\if@openright\cleardoublepage\else\clearpage\fi
745 \thispagestyle{plain}%
746 \global\@topnum\z@
747 \@afterindentfalse
748 \secdef\@chapter\@schapter}
749 \def\@chapter[##1]##2{\ifnum \c@secnumdepth >\m@ne
750 \if@mainmatter
751 \refstepcounter{chapter}%
752 \typeout{\@chapapp\space\thechapter.}%
753 \addcontentsline{toc}{chapter}%
754 {\protect\numberline{\thechapter}##1}%
755 \else
756 \addcontentsline{toc}{chapter}{##1}%
757 \fi
758 \else
759 \addcontentsline{toc}{chapter}{##1}%
760 \fi
761 \chaptermark{##1}%
762 \addtocontents{lof}{\protect\addvspace{10\p@}}%
763 \addtocontents{lot}{\protect\addvspace{10\p@}}%
764 \if@twocolumn
765 \@topnewpage[\@makechapterhead{##2}]%
766 \else
767 \@makechapterhead{##2}%
768 \@afterheading
769 \fi}
770 \def\@makechapterhead##1{%
771 \vspace*{50\p@}%
772 {\parindent \z@ \raggedright \normalfont
773 \ifnum \c@secnumdepth >\m@ne
774 \if@mainmatter
775 \huge\bfseries \@chapapp\space \thechapter
776 \par\nobreak
777 \vskip 20\p@
778 \fi
779 \fi
780 \interlinepenalty\@M
781 \Huge \bfseries ##1\par\nobreak
782 \vskip 40\p@
783 }}
784 \def\@schapter##1{\if@twocolumn
785 \@topnewpage[\@makeschapterhead{##1}]%
786 \else
787 \@makeschapterhead{##1}%
788 \@afterheading
789 \fi}
790 \def\@makeschapterhead##1{%
791 \vspace*{50\p@}%
792 {\parindent \z@ \raggedright
793 \normalfont
794 \interlinepenalty\@M
795 \Huge \bfseries ##1\par\nobreak
796 \vskip 40\p@
797 }}
798 \def\section{\@startsection {section}{1}{\z@}%
799 {-3.5ex \@plus -1ex \@minus -.2ex}%
800 {2.3ex \@plus.2ex}%
801 {\normalfont\Large\bfseries}}
802 \def\subsection{\@startsection{subsection}{2}{\z@}%
803 {-3.25ex\@plus -1ex \@minus -.2ex}%
804 {1.5ex \@plus .2ex}%
805 {\normalfont\large\bfseries}}
806 \def\subsubsection{\@startsection{subsubsection}{3}{\z@}%
807 {-3.25ex\@plus -1ex \@minus -.2ex}%
808 {1.5ex \@plus .2ex}%
809 {\normalfont\normalsize\bfseries}}
810 \def\paragraph{\@startsection{paragraph}{4}{\z@}%
811 {3.25ex \@plus1ex \@minus.2ex}%
812 {-1em}%
813 {\normalfont\normalsize\bfseries}}
814 \def\subparagraph{\@startsection{subparagraph}{5}{\parindent}%
815 {3.25ex \@plus1ex \@minus .2ex}%
816 {-1em}%
817 {\normalfont\normalsize\bfseries}}
818 }
819 % \end{macrocode}
820 % \end{macro}
821 % \end{command}
822 %
823 % \subsection{Class dependent deactivation and implemention}
824 % \label{ssec:doit}
825 %
826 % If a \KOMAScript{} class has been loaded we need use the common deactivation
827 % code and the \cls*{article} sectioning code.
828 % \ExplSyntaxOn
829 % \begin{macro}{\@@_acticvation_code:}
830 % \ExplSyntaxOff
831 % \begin{macrocode}
832 \cs_new:Nn \@@_activation_code:
833 {
834 \@ifclassloaded { scrartcl }
835 {
836 \@@_common_komascript_deactivation_code:
837 \@@_article_sectioning_code:
838 }
839 {
840 % \end{macrocode}
841 % \begin{command}{\chapterlineswithprefixformat,\chapterlinesformat}
842 % For \cls*{scrbook} and \cls*{scrreprt} we need additional deactivation
843 % code and the \cls*{book} resp. \cls*{report} sectioning code.
844 % \begin{macrocode}
845 \@ifclassloaded { scrbook }
846 {
847 \@@_common_komascript_deactivation_code:
848 \cs_undefine:N \chapterlineswithprefixformat
849 \cs_undefine:N \chapterlinesformat
850 \@@_book_sectioning_code:
851 }
852 {
853 \@ifclassloaded { scrreprt }
854 {
855 \@@_common_komascript_deactivation_code:
856 \cs_undefine:N \chapterlineswithprefixformat
857 \cs_undefine:N \chapterlinesformat
858 \@@_report_sectioning_code:
859 }
860 {
861 % \end{macrocode}
862 % \end{command}
863 % For all other classes, we use a heuristic to either use the sectioning code
864 % of \cls*{article}, \cls*{book}, or \cls*{report}
865 % \begin{macrocode}
866 \cs_if_exist:NTF \chapter
867 {
868 \cs_if_exist:cTF { frontmatter }
869 {
870 \@@_book_sectioning_code:
871 }
872 {
873 \@@_report_sectioning_code:
874 }
875 }
876 {
877 \@@_article_sectioning_code:
878 }
879 }
880 }
881 }
882 }
883 % \end{macrocode}
884 % \end{macro}
885 % \ExplSyntaxOff
886 %
887 % \begin{option}{book,article,report}
888 % These options can be used to force the usage of one of the selection
889 % codes, but only if no \KOMAScript{} class has been used. So in the code
890 % section we first have to test for a \KOMAScript{} class and either throw a
891 % warning or do the redefinition of \cs{@@\_activation\_code:}.
892 % \begin{macrocode}
893 \DeclareKeys
894 {
895 article .meta:nn = { @@/internal } { force=article },
896 article .usage = load,
897 book .meta:nn = { @@/internal } { force=book },
898 book .usage = load,
899 report .meta:nn = { @@/internal } { force=report },
900 report .usage = load,
901 }
902 \keys_define:nn { @@/internal }
903 {
904 force .code =
905 {
906 \cs_if_exist:NTF \KOMAClassName
907 {
908 \msg_warning:nnn { standardsectioning }
909 { no-force-with-KOMA-Script-class }
910 { #1 }
911 }
912 {
913 \cs_set_eq:Nc \@@_activation_code: { @@_#1_sectioning_code: }
914 }
915 }
916 }
917 \ProcessKeyOptions
918 \@@_activation_code:
919 % \end{macrocode}
920 % \end{option}
921 %
922 % \iffalse
923 %</package>
924 % \fi
925 %
926 % \Finale
927 % \PrintChanges
928 %
929 % \endinput
930 % Local Variables:
931 % mode: doctex
932 % ispell-local-dictionary: "en_US"
933 % eval: (flyspell-mode 1)
934 % TeX-master: t
935 % End: