summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/koma-script/source/scrkernel-paragraphs.dtx
blob: 9c65fcd6bd7b0c43c44add78a04d1ea93a48cd7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
% \iffalse meta-comment
% ======================================================================
% scrkernel-paragraphs.dtx
% Copyright (c) Markus Kohm, 2002-2022
%
% This file is part of the LaTeX2e KOMA-Script bundle.
%
% This work may be distributed and/or modified under the conditions of
% the LaTeX Project Public License, version 1.3c of the license.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of LaTeX 
% version 2005/12/01 or later and of this work.
%
% This work has the LPPL maintenance status "author-maintained".
%
% The Current Maintainer and author of this work is Markus Kohm.
%
% This work consists of all files listed in manifest.txt.
% ======================================================================
%%% From File: $Id: scrkernel-paragraphs.dtx 3745 2022-03-07 09:14:34Z kohm $
%<option>%%%            (run: option)
%<body>%%%            (run: body)
%<*dtx>
\ifx\ProvidesFile\undefined\def\ProvidesFile#1[#2]{}\fi
\begingroup
  \def\filedate$#1: #2-#3-#4 #5${\gdef\filedate{#2/#3/#4}}
  \filedate$Date: 2022-03-07 10:14:34 +0100 (Mo, 07. Mär 2022) $
  \def\filerevision$#1: #2 ${\gdef\filerevision{r#2}}
  \filerevision$Revision: 3745 $
  \edef\reserved@a{%
    \noexpand\endgroup
    \noexpand\ProvidesFile{scrkernel-paragraphs.dtx}%
                          [\filedate\space\filerevision\space
                           KOMA-Script
                           (paragraphs)]
  }%
\reserved@a
\documentclass[USenglish]{koma-script-source-doc}
\usepackage{babel}
\setcounter{StandardModuleDepth}{3}
\begin{document}
\DocInput{scrkernel-paragraphs.dtx}
\end{document}
%</dtx>
% \fi
%
% \changes{v2.95}{2002/06/25}{first version after splitting \file{scrclass.dtx}}
% \changes{v3.36}{2022/03/07}{switch over from \cls*{scrdoc} to
%   \cls*{koma-script-source-doc}}
% \changes{v3.36}{2022/03/07}{whole implementation documentation in English}
%
% \GetFileInfo{scrkernel-paragraphs.dtx}
% \title{The Code Related to Paragraph Building and Page Building of
%   \href{https://komascript.de}{\KOMAScript} Classes}
% \author{\href{mailto:komascript@gmx.info}{Markus Kohm}}
% \date{Revision \fileversion{} of \filedate}
% \maketitle
% \begin{abstract}
%   \file{scrkernel-paragraphs.dtx} does all the things about configuration of
%   paragraphs and page breaking. Some of them are very special for
%   \KOMAScript.
% \end{abstract}
% \tableofcontents
%
% \section{User Manual}
%
% You can find the user documentation the commands implemented here in the
% \KOMAScript{} manual, either the German \file{scrguide} or the English
% \file{scrguien}.
%
% \MaybeStop{\PrintIndex}
%
% \section{Implementation of Paragraphs and Pages}
%
% Almost all of this code is for the classes only.
%    \begin{macrocode}
%<*class>
%    \end{macrocode}
%
% \subsection{Options and macros to handle the paragraph layout}
%
% Already from version 2.8i \KOMAScript can handle paragraph skips instead of
% indenting paragraphs. But the corresponding code has changed a lot over the
% years.
%
% \begin{command}{\setparsizes}
% \changes{v2.95}{2004/11/05}{added}
% \changes{v3.17}{2015/03/10}{support for internal option value storage}
% \changes{v3.19}{2015/07/29}{\cs{par@update} should not reset itself to
%   \cs{default@par@update} in the document preamble}
% \begin{macro}{\f@parindent}
% \changes{v2.95}{2004/11/05}{added}
% \begin{macro}{\f@parskip,\f@parfillskip}
% \changes{v2.95}{2004/11/05}{added}
% \changes{v2.95}{2004/11/05}{meaning changed}
% \begin{macro}{\scr@parindent}
% \changes{v2.95}{2004/11/05}{added}
% \begin{macro}{\scr@parskip,\scr@parfillskip}
% \changes{v2.95}{2004/11/05}{added}
% \changes{v2.95}{2004/11/05}{meaning changed}
% Command
% \begin{quote}
%   \cs{setparsizes}\marg{indent}\marg{skip}\marg{fill}
% \end{quote}
% not only sets the three main paragraph parameters of \TeX: \len{parskip},
% \len{parindent}, \len{parfillskip}. Because of option \opt{parskip=relative}
% it has to use a kind of delayed setting of these parameters at least at the
% document preamble. So these settings are not activated until
% \cs{selectfont}. To do so, not the \TeX{} parameters are changed, but the
% current values of the \TeX{} parameters are stored to \cs{f@parindent},
% \cs{f@parskip} and \cs{f@parfillskip} and the new values are stored to
% \cs{scr@parindent}, \cs{scr@parskip} and \cs{scr@parfillskip}
% only. Additionally \cs{par@update} is used to activate these new
% values. Later we will use a hook to automatically execute \cs{par@update}
% with every \cs{selectfont}. The current value storage is initialized twice:
% First immediately and second inside at the end of the class.
% \begin{description}
% \item[ToDo:] Is the second initialization really needed? Wouldn't it be done
%   with the class options? Here user changes are not to be expected, because
%   we are still inside the class and therefore there is no user interaction.
% \end{description}
% \begin{macro}{\par@update}
% \changes{v2.95}{2004/11/05}{added}
% \changes{v3.20}{2016/02/22}{\cs{AtBeginDocument} code added}
% \begin{macro}{\default@par@update}
% \changes{v2.95}{2004/11/05}{added}
% \begin{macro}{\par@updaterelative}
% \changes{v2.95}{2004/11/05}{added}
% \changes{v3.36}{2022/03/07}{using \cs{reserved@a} instead of \cs{@tempa}}
% \begin{macro}{\parindent@update,\parskip@update,\parfillskip@update}
% \changes{v2.95}{2004/11/05}{added}
% \changes{v3.36}{2022/03/07}{using \cs{reserved@a} and \cs{reserved@b}
%   instead if \cs{@tempa} and \cs{@tempb}}
% The initial \cs{par@update} action is to do nothing. But with
% \opt{parskip=relative} it always and after \cs{setparsizes} it once (or in
% the document preamble also always) has to reactivate the new values. This is
% done using \cs{default@par@update} and
% \cs{par@updaterelative}. \cs{default@par@update} is either a do nothing
% (\opt{parskip=absolute}) or \cs{par@updaterelative}
% (\opt{parskip=relative}). \cs{par@updaterelative} does the real update.
% \begin{description}
% \item[ToDo:] Sometimes internally \cs{par@updaterelative} is used instead of
%   \cs{selectfont} to do an immediate update after \cs{setparsizes}. But is
%   this correct? Wouldn't be \cs{selectfont} the correct action, to also
%   reset the definition of \cs{par@update}?
% \item[ToDO:] Does the \cs{AtBeginCode} execution of \cs{par@update} make
%   sense? The \cs{par@update} is done after the initial \cs{normalsize} and
%   the initial \cs{selectfont}. So shouldn't this be enough?
% \end{description}
%    \begin{macrocode}
%<*option>
\newcommand*{\setparsizes}[3]{%
  \edef\f@parindent{\the\parindent}%
  \edef\f@parskip{\the\parskip}%
  \edef\f@parfillskip{\the\parfillskip}%
  \def\scr@parindent{#1}%
  \def\scr@parskip{#2}%
  \def\scr@parfillskip{#3}%
  \def\par@update{%
    \if@atdocument\let\par@update\default@par@update\fi
    \par@updaterelative
  }%
  \KOMA@kav@remove{.\KOMAClassFileName}{parskip}{false}%
  \KOMA@kav@remove{.\KOMAClassFileName}{parskip}{never}%
  \KOMA@kav@remove{.\KOMAClassFileName}{parskip}{full}%
  \KOMA@kav@remove{.\KOMAClassFileName}{parskip}{full-}%
  \KOMA@kav@remove{.\KOMAClassFileName}{parskip}{full+}%
  \KOMA@kav@remove{.\KOMAClassFileName}{parskip}{full*}%
  \KOMA@kav@remove{.\KOMAClassFileName}{parskip}{half}%
  \KOMA@kav@remove{.\KOMAClassFileName}{parskip}{half-}%
  \KOMA@kav@remove{.\KOMAClassFileName}{parskip}{half+}%
  \KOMA@kav@remove{.\KOMAClassFileName}{parskip}{half*}%
}
\newcommand*{\f@parindent}{\the\parindent}
\newcommand*{\f@parskip}{\the\parskip}
\newcommand*{\f@parfillskip}{\the\parfillskip}
\newcommand*{\scr@parindent}{1em}
\newcommand*{\scr@parskip}{\z@}
\newcommand*{\scr@parfillskip}{\z@ \@plus 1fil}
\AtEndOfClass{%
  \edef\f@parindent{\the\parindent}%
  \edef\f@parskip{\the\parskip}%
  \edef\f@parfillskip{\the\parfillskip}%
}
\newcommand*{\par@update}{}
\let\par@update\relax
\newcommand*{\default@par@update}{}
\let\default@par@update\relax
\AtBeginDocument{\par@update}
%</option>
%    \end{macrocode}
% Because of the currently complicated initialization, i.e., when switching
% between \cs{parskip=absolute} and \cs{parskip=relative}, we currently define
% \cs{par@updaterelative} not before the class options has been processed. New
% values are only set, if between the last \cs{setparsizes} and the current
% \cs{par@updaterelative} (e.g. inside \cs{selectfont}) the user has not
% changed the \TeX{} variables. If he has changed the \TeX{} variables instead
% of using \cs{setparsizes} we think, he does not want any other change. And
% because of to be able to do the tests inside a group without permanent
% change of \cs{reserved@a} we use three additional helpers.
%    \begin{macrocode}
%<*body>
\newcommand*{\par@updaterelative}{%
  \begingroup
    \edef\reserved@a{\the\parindent}\ifx\reserved@a\f@parindent
      \aftergroup\parindent@update
%<*trace>
    \else
      \ClassInfo{\KOMAClassName}{\string\parindent\space not changed}%
%</trace>
    \fi
    \edef\reserved@a{\the\parskip}\ifx\reserved@a\f@parskip
      \aftergroup\parskip@update
%<*trace>
    \else
      \ClassInfo{\KOMAClassName}{\string\parskip\space not changed}%
%</trace>
    \fi
    \edef\reserved@a{\the\parfillskip}\ifx\reserved@a\f@parfillskip
      \aftergroup\parfillskip@update
%<*trace>
    \else
      \ClassInfo{\KOMAClassName}{\string\parfillskip\space not changed}%
%</trace>
    \fi
  \endgroup
}
\newcommand*{\parindent@update}{%
  \scr@defaultunits\parindent\scr@parindent
  \begingroup
    \let\reserved@b\endgroup
    \edef\reserved@a{\the\parindent}\ifx\reserved@a\f@parindent\else
      \def\reserved@b{\endgroup\edef\f@parindent{\the\parindent}}%
%<trace>      \ClassInfo{\KOMAClassName}{\string\parindent=\the\parindent}%
    \fi
  \reserved@b
}
\newcommand*{\parskip@update}{%
  \scr@defaultunits\parskip\scr@parskip
  \begingroup
    \let\reserved@b\endgroup
    \edef\reserved@a{\the\parskip}\ifx\reserved@a\f@parskip\else
      \def\reserved@b{\endgroup\edef\f@parskip{\the\parskip}}%
%<trace>      \ClassInfo{\KOMAClassName}{\string\parskip=\the\parskip}%
    \fi
  \reserved@b
}
\newcommand*{\parfillskip@update}{%
  \scr@defaultunits\parfillskip\scr@parfillskip
  \begingroup
    \let\reserved@b\endgroup
    \edef\reserved@a{\the\parfillskip}\ifx\reserved@a\f@parfillskip\else
      \def\reserved@b{\endgroup\edef\f@parfillskip{\the\parfillskip}}%
%<trace>      \ClassInfo{\KOMAClassName}{\string\parfillskip=\the\parfillskip}%
    \fi
  \reserved@b
}
%</body>
%    \end{macrocode}
% \end{macro}^^A \parindent@update,\parskip@update,\parfillskip@update}
% \end{macro}^^A \par@updaterelative
% \end{macro}^^A \default@par@update
% \end{macro}^^A \par@update
% \end{macro}^^A \scr@parskip,\scr@parfillskip
% \end{macro}^^A \scr@parindent
% \end{macro}^^A \f@parskip,\f@parfillskip
% \end{macro}^^A \f@parindent
% \end{command}^^A \setparsizes
%
% \begin{option}{parskip}
% \changes{v2.8i}{2001/07/22}{added}
% \changes{v2.95}{2006/03/11}{changed into \pkg{keyval} option}
% \changes{v3.08}{2010/12/14}{value \opt{\quotechar=never} added}
% \changes{v3.12}{2013/03/05}{using \cs{FamilyKeyState}.}
% \changes{v3.17}{2015/03/10}{using value storage}
% \changes{v3.25}{2017/09/27}{typo fix in \cs{FamilyKeyStateUnknownValue}}
% \changes{v3.26b}{2019/02/01}{\cs{baselineskip} replaced by 1\cs{baselineskip}}
% \begin{option}{parindent,parskip-,parskip+,parskip*,
%                halfparskip,halfparskip-,halfparskip+,halfparskip*}
% \changes{v2.8i}{2001/07/22}{added}
% \changes{v2.95}{2006/03/11}{obsolete}
% \changes{v2.97d}{2007/10/03}{\cs{PackageInfo} replaced by
%   \cs{PackageInfoNoLine}}
% \changes{v3.01a}{2008/11/20}{deprecated}
% Originally we have had nine options for all the paragraph indent and skip
% settings. Using \pkg*{scrbase} we have only one option with additional
% settings for relative and absolute values and paragraph indent without glue
% for paragraph skip.
%    \begin{macrocode}
%<*option>
\KOMA@key{parskip}[true]{%
  \begingroup
    \KOMA@set@ncmdkey{parskip}{@tempa}{%
      {never}{0},%
      {false}{1},{off}{1},{no}{1},%
      {full-}{2},%
      {half-}{3},%
      {full}{4},{true}{4},{on}{4},{yes}{4},%
      {half}{5},%
      {full+}{6},%
      {half+}{7},%
      {full*}{8},%
      {half*}{9},%
      {relative}{10},%
      {absolute}{11}%
    }{#1}%
    \ifx\FamilyKeyState\FamilyKeyStateProcessed
      \aftergroup\FamilyKeyStateProcessed
      \ifcase\number\@tempa% 0
        \endgroup
        \setparsizes{1em}{\z@}{\z@ \@plus 1fil}%
        \KOMA@kav@add{.\KOMAClassFileName}{parskip}{never}%
        \if@atdocument\AfterKOMAoptions{\selectfont}\fi
      \or% 1
        \endgroup
        \setparsizes{1em}{\z@ \@plus \p@}{\z@ \@plus 1fil}%
        \KOMA@kav@add{.\KOMAClassFileName}{parskip}{false}%
        \if@atdocument\AfterKOMAoptions{\selectfont}\fi
      \or% 2
        \endgroup
        \setparsizes{\z@}{1\baselineskip \@plus .1\baselineskip}{%
          \z@ \@plus 1fil}%
        \KOMA@kav@add{.\KOMAClassFileName}{parskip}{full-}%
        \if@atdocument\AfterKOMAoptions{\selectfont}\fi
      \or% 3
        \endgroup
        \setparsizes{\z@}{.5\baselineskip \@plus .5\baselineskip}{%
          \z@ \@plus 1fil}%
        \KOMA@kav@add{.\KOMAClassFileName}{parskip}{half-}%
        \if@atdocument\AfterKOMAoptions{\selectfont}\fi
      \or% 4
        \endgroup
        \setparsizes{\z@}{1\baselineskip \@plus .1\baselineskip}{%
          1em \@plus 1fil}%
        \KOMA@kav@add{.\KOMAClassFileName}{parskip}{full}%
        \if@atdocument\AfterKOMAoptions{\selectfont}\fi
      \or% 5
        \endgroup
        \setparsizes{\z@}{.5\baselineskip \@plus .5\baselineskip}{%
          1em \@plus 1fil}%
        \KOMA@kav@add{.\KOMAClassFileName}{parskip}{half}%
        \if@atdocument\AfterKOMAoptions{\selectfont}\fi
      \or% 6
        \endgroup
        \setparsizes{\z@}{1\baselineskip \@plus .1\baselineskip}{%
          .3333\linewidth\@plus 1fil}%
        \KOMA@kav@add{.\KOMAClassFileName}{parskip}{full+}%
        \if@atdocument\AfterKOMAoptions{\selectfont}\fi
      \or% 7
        \endgroup
        \setparsizes{\z@}{.5\baselineskip \@plus .5\baselineskip}{%
          .3333\linewidth \@plus 1fil}%
        \KOMA@kav@add{.\KOMAClassFileName}{parskip}{half+}%
        \if@atdocument\AfterKOMAoptions{\selectfont}\fi
      \or% 8
        \endgroup
        \setparsizes{\z@}{1\baselineskip \@plus .1\baselineskip}{%
          .25\linewidth \@plus 1fil}%
        \KOMA@kav@add{.\KOMAClassFileName}{parskip}{full*}%
        \if@atdocument\AfterKOMAoptions{\selectfont}\fi
      \or% 9
        \endgroup
        \setparsizes{\z@}{.5\baselineskip \@plus .5\baselineskip}{%
          .25\linewidth \@plus 1fil}%
        \KOMA@kav@add{.\KOMAClassFileName}{parskip}{half*}%
        \if@atdocument\AfterKOMAoptions{\selectfont}\fi
      \or% 10
        \endgroup
        \KOMA@kav@remove{.\KOMAClassFileName}{parskip}{absolute}%
        \KOMA@kav@remove{.\KOMAClassFileName}{parskip}{relative}%
        \KOMA@kav@add{.\KOMAClassFileName}{parskip}{relative}%
        \ifx\par@updaterelative\undefined
          \expandafter\AtEndOfClass
        \else
          \expandafter\@firstofone
        \fi
        {%
          \ifx\par@update\default@par@update
            \let\par@update\par@updaterelative
          \fi
          \let\default@par@update=\par@updaterelative
        }%
      \or%11
        \endgroup
        \KOMA@kav@remove{.\KOMAClassFileName}{parskip}{absolute}%
        \KOMA@kav@remove{.\KOMAClassFileName}{parskip}{relative}%
        \KOMA@kav@add{.\KOMAClassFileName}{parskip}{absolute}%
        \ifx\par@updaterelative\undefined
          \expandafter\AtEndOfClass
        \else
          \expandafter\@firstofone
        \fi
        {%
          \ifx\par@update\default@par@update
            \let\par@update\relax
          \fi
          \let\default@par@update=\relax
        }%
      \else% should never be
        \endgroup
    \fi
  \else
    \endgroup
    \FamilyKeyStateUnknownValue
  \fi
}
\KOMA@DeclareDeprecatedOption{parskip-}{parskip=full-}
\KOMA@DeclareDeprecatedOption{parskip+}{parskip=full+}
\KOMA@DeclareDeprecatedOption{parskip*}{parskip=full*}
\KOMA@DeclareDeprecatedOption{halfparskip}{parskip=half}
\KOMA@DeclareDeprecatedOption{halfparskip-}{parskip=half-}
\KOMA@DeclareDeprecatedOption{halfparskip+}{parskip=half+}
\KOMA@DeclareDeprecatedOption{halfparskip*}{parskip=half*}
\KOMA@DeclareDeprecatedOption{parindent}{parskip=false}
\KOMA@kav@add{.\KOMAClassFileName}{parskip}{false}
\KOMA@kav@add{.\KOMAClassFileName}{parskip}{absolute}
%</option>
%    \end{macrocode}
% \end{option}^^A parindent … halfparskip*
% \end{option}^^A parskip
%
% \changes{v2.8i}{2001/07/22}{don't change \cs{baselinestretch}}
%
% \begin{length}{\lineskip,\normallineskip}
% The minimum line skip.
%    \begin{macrocode}
%<*body>
\setlength{\lineskip}{\p@}
\setlength{\normallineskip}{\p@}
%    \end{macrocode}
% \end{length}
%
% \begin{command}{\selectfont}
% \changes{v2.95}{2004/11/05}{added}
% \changes{v3.33}{2021/01/21}{from \LaTeX{} 2021/06/01 use hook instead of
%   patch}
% \begin{macro}{\scr@selectfont,\scr@new@selectfont}
% \changes{v2.95}{2006/04/14}{added}
% \changes{v3.10}{2010/09/28}{\pkg{everysel} support fixed}
% \changes{v3.10}{2010/09/28}{\pkg{tracefnt} supported}
% \changes{v3.10b}{2011/03/13}{\pkg{everysel} can be loaded inside
%   \cs{begin\{document\}}}
% Because of \opt{parskip=relative} we need a hook to activate the changes of
% the paragraph values. A good place to do so is \cs{selectfont}. With
% \KOMAScript{} 3.00 we needed to patch this command. But from \LaTeX{}
% 2021/06/01 we can use a new generic hook.
% \begin{description}
% \item[Note:] We use 2021/05/01 instead of the official \LaTeX{} release date,
%   because there were relevant earlier \LaTeX{} developer releases with that
%   date.
% \end{description}
%    \begin{macrocode}
\IfLTXAtLeastTF{2021/05/01}{%
  \AddToHook{selectfont}{\par@update}%
  \AfterPackage{everysel}{%
    \IfPackageAtLeastTF{everysel}{2021/01/18}{}{%
      \ClassError{\KOMAClassName}{%
        incompatible `everysel' detected
      }{%
        You are using an old version of `everysel' in combination with a
        LaTeX\MessageBreak
        version >= 2021/06/01 and KOMA-Script >= 3.33. This combination
        is\MessageBreak
        not supported.\MessageBreak
        You could switch back to an older LaTeX using package
        `latexrelease'.\MessageBreak
        But I recommend to update `everysel'%
      }%
    }%
  }%
  \AfterPackage{tracefnt}{%
    \IfPackageAtLeastTF{tracefnt}{2020/12/22}{}{%
      \ClassError{\KOMAClassName}{%
        incompatible `tracefnt' detected
      }{%
        `tracefnt' is a LaTeX base package and therefore should be updated
        together\MessageBreak
        with LaTeX kernel. So this should never happen! Please check
        your\MessageBreak
        LaTeX installation%
      }%
    }%
  }%
}{%
  \newcommand*{\scr@selectfont}{}
  \expandafter\let\expandafter\scr@selectfont\csname selectfont \endcsname
  \BeforePackage{everysel}{%
    \AtBeginDocument{%
      \expandafter\ifx\csname selectfont \endcsname\scr@new@selectfont\else
        \ClassWarningNoLine{\KOMAClassName}{%
          discard change of \string\selectfont}%
      \fi
      \expandafter\let\csname selectfont \endcsname\scr@selectfont
    }%
  }%
  \AfterPackage{everysel}{%
    \scr@ifundefinedorrelax{@EverySelectfont@Init}{%
      \expandafter\ifx\csname selectfont \endcsname\scr@new@selectfont
        \ClassWarningNoLine{\KOMAClassName}{%
          \string\selectfont\space already changed}%
      \else
        \expandafter\g@addto@macro\csname selectfont \endcsname{\par@update}%
        \expandafter\let\expandafter\scr@new@selectfont
          \csname selectfont \endcsname
      \fi
    }{%
      \g@addto@macro\@EverySelectfont@Init{%
        \expandafter\g@addto@macro\csname selectfont \endcsname{\par@update}%
        \expandafter\let\expandafter\scr@new@selectfont
          \csname selectfont \endcsname
      }%
    }%
  }%
  \AfterPackage{tracefnt}{%
    \expandafter\let\expandafter\scr@selectfont\csname selectfont \endcsname
    \expandafter\g@addto@macro\csname selectfont \endcsname{\par@update}%
    \expandafter\let\expandafter\scr@new@selectfont\csname selectfont \endcsname
  }%
  \expandafter\g@addto@macro\csname selectfont \endcsname{\par@update}
  \newcommand*{\scr@new@selectfont}{}
  \expandafter\let\expandafter\scr@new@selectfont\csname selectfont \endcsname
}
%    \end{macrocode}
% \end{macro}^^A \scr@selectfont,\scr@new@selectfont
% \end{command}^^A \selectfont
%
% \begin{macro}{\scr@defaultunits}
% \changes{v2.95}{2004/11/05}{added}
% \changes{v3.19}{2015/08/22}{\cs{setlength} replaced because of \pkg{tikz}}
% \begin{macro}{\scr@@defaultunits}
% \changes{v2.95}{2004/11/05}{added}
% \begin{macro}{\scr@@@defaultunits}
% \changes{v2.95}{2004/11/05}{added}
% \changes{v3.19}{2015/08/22}{\cs{setlength} and \cs{addtolength} replaced
%   because of \pkg{tikz}}
% Above we've already used \cs{scr@defaultunits} inside
% \cs{par@updaterelative}. This is very similar to the \LaTeX{} kernel macro
% \cs{@defaultunits}, but accepts dimensions or skips as first and second
% value.
%    \begin{macrocode}
\newcommand*{\scr@defaultunits}[2]{%
  \begingroup
    \edef\@tempa{#2}%
    \expandafter\scr@@defaultunits\expandafter#1\@tempa plusplus\@nnil
    \edef\@tempa{\noexpand\endgroup\noexpand#1\the\glueexpr #1\relax}%
  \@tempa
}
\newcommand*{\scr@@defaultunits}{}
\def\scr@@defaultunits#1#2plus#3plus#4\@nnil{%
  \ifx\relax#3\relax
    \scr@@@defaultunits#1{}#2minusminus\@nnil
  \else
    \scr@@@defaultunits#1{#2}#3minusminus\@nnil
  \fi
}
\newcommand*{\scr@@@defaultunits}{}
\def\scr@@@defaultunits#1#2#3minus#4minus#5\@nnil{%
  \ifx\relax#2\relax
    \@defaultunits\@tempskipa#3pt\relax\@nnil
    #1\@tempskipa
  \else
    \@defaultunits\@tempskipa\z@\@plus#3pt\relax\@nnil
    #1\@tempskipa
    \@defaultunits\@tempskipa#2pt\relax\@nnil
    \advance#1\@tempskipa
  \fi
  \ifx\relax#4\relax\else
    \@defaultunits\@tempskipa\z@\@minus #4pt\relax\@nnil
    \advance#1\@tempskipa
  \fi
}
%</body>
%    \end{macrocode}
% \end{macro}^^A \scr@@@defaultunits
% \end{macro}^^A \scr@@defaultunits
% \end{macro}^^A \scr@defaultunits
%
% \subsection{Extra list code}
%
% \begin{macro}{\@list@extra}
% \changes{v2.8q}{2001/11/06}{added}
% \changes{v2.95c}{2006/08/03}{\len{parsep} fixed}
% \begin{macro}{\add@extra@listi}
% \changes{v2.9h}{2002/09/03}{added}
% Some parameters of lists have to change, depending on the settings for
% paragraphs.
% \begin{description}
% \item[ToDo:] Move this code to \file{scrkernel-listsandtabulars.dtx} or
%   \file{scrkernel-fontsizes.dtx}.
% \end{description}
%    \begin{macrocode}
%<*body>
\newcommand*{\@list@extra}{%
  \ifdim\parskip>\z@\topsep\z@\parsep\parskip\itemsep\z@\fi
}
\newcommand*{\add@extra@listi}[1]{%
  \expandafter\let\csname #1@listi\endcsname=\@listi
  \def\@listi{\csname #1@listi\endcsname\@list@extra}%
}
%</body>
%    \end{macrocode}
% \end{macro}^^A \@list@extra
% \end{macro}^^A \add@extra@listi
%
% \subsection{Patching other packages}
%
% \begin{macro}{\deferred@thm@head}
% \changes{v3.27}{2019/02/10}{new patch of \textsf{amsthm}}
% Unfortunatly \pkg{amsthm} has a problem if a class handles \len{topsep}
% this way, because it is only prepared for the case, that \len{parskip} and
% \len{parsep} are changed manually without influence to \len{topsep}. So the
% initial distance is missing. To avoid this problem, we need to patch the
% package's internal command \cs{deferred@thm@head}. This is not nice, but
% unfortunaltly needed.
% \begin{description}
% \item[ToDo:] Move this code to the package patch code of
%   \file{scrkernel-miscellaneous.dtx} resp. a new file as noted there.
% \end{description}
%    \begin{macrocode}
%<*body>
\AfterPackage{amsthm}{%
  \RequirePackage{xpatch}%
  \xpatchcmd{\deferred@thm@head}{\addvspace{-\parskip}}{}{%
    \ClassInfoNoLine{\KOMAClassName}{%
      amsthm's \string\deferred@thm@head\space patched}%
  }{%
    \ClassWarningNoLine{\KOMAClassName}{%
      cannot patch amsthm's \string\deferred@thm@head.\MessageBreak
      This could result in wrong spacing before theorem\MessageBreak
      environments defined by package `amsthm'%
    }%
  }%
}
%</body>
%    \end{macrocode}
% \end{macro}
% 
% \subsection{Extra code for font sizes}
%
% \begin{description}
% \item[ToDo:] Move this to \file{scrkernel-fontsizes.dtx}.
% \end{description}
%    \begin{macrocode}
%    \end{macrocode}
%
% \changes{v2.98c}{2008/03/26}{changed to be used in font size files}
% \changes{v3.17}{2015/03/25}{update of paragraph settings}
% \begin{macro}{\@listi}
% \changes{v2.98c}{2008/03/27}{\cs{g@addto@macro} replaced by \cs{l@addto@macro}}
% \changes{v3.01}{2008/11/13}{\cs{@listi} wird auf jeden Fall ausgeführt}
% \begin{macro}{\@listI}
% \begin{macro}{\@listii,\@listiii}
% \changes{v2.98c}{2008/03/27}{\cs{g@addto@macro} replaced by \cs{l@addto@macro}}
% \begin{command}{\footnotesize,\small}
% \changes{v2.9h}{2002/09/03}{improved}
% \changes{v2.98c}{2008/03/27}{\cs{g@addto@macro} replaced by \cs{l@addto@macro}}
%    \begin{macrocode}
%</class>
%<*class|clo>
%<*body|10pt|11pt|12pt>
%<10pt|11pt|12pt>\@ifundefined{@list@extra}{}{%
%<10pt|11pt|12pt>  \expandafter\ifnum\scr@v@is@ge{3.17}\par@updaterelative\fi
  \l@addto@macro{\@listi}{\@list@extra}%
  \let\@listI=\@listi
  \l@addto@macro{\@listii}{\@list@extra}%
  \l@addto@macro{\@listiii}{\@list@extra}%
  \l@addto@macro{\footnotesize}{\protect\add@extra@listi{ftns}}%
  \l@addto@macro{\small}{\protect\add@extra@listi{sml}}%
%<10pt|11pt|12pt>}
%<10pt|11pt|12pt>\@listi
%</body|10pt|11pt|12pt>
%</class|clo>
%<*class>
%    \end{macrocode}
% \end{command}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \subsection{Page layout parameters}
%
% \begin{length}{\columnsep,\columnseprule}
% Initial column separation. Note, we do not support two column letters. So
% this is not initialized for the letter class.
%    \begin{macrocode}
%<*!letter&body>
\setlength{\columnsep}{10\p@}
\setlength{\columnseprule}{\z@}
%</!letter&body>
%    \end{macrocode}
% \end{length}
%
%
% \subsection{Penalties}
%
% The initial values for the penalties are the same as for the standard classes.
%    \begin{macrocode}
%<*body>
\@lowpenalty  = 51
\@medpenalty  =151
\@highpenalty =301
%</body>
%    \end{macrocode}
%
%
%    \begin{macrocode}
%</class>
%    \end{macrocode}
% 
% \Finale
% \PrintChanges
% 
\endinput
% Local Variables:
% mode: doctex
% ispell-local-dictionary: "en_US"
% eval: (flyspell-mode 1)
% TeX-master: t
% TeX-engine: luatex-dev
% eval: (setcar (or (cl-member "Index" (setq-local TeX-command-list (copy-alist TeX-command-list)) :key #'car :test #'string-equal) (setq-local TeX-command-list (cons nil TeX-command-list))) '("Index" "mkindex %s" TeX-run-index nil t :help "makeindex for dtx"))
% End: