summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/koma-script/source/scrkernel-pagestyles.dtx
blob: 63d02d976304276d48f36d82ad375989236c07fd (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
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
% \iffalse meta-comment
% ======================================================================
% scrkernel-pagestyles.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-pagestyles.dtx 3744 2022-03-05 16:30:02Z 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-05 17:30:02 +0100 (Sa, 05. Mär 2022) $
  \def\filerevision$#1: #2 ${\gdef\filerevision{r#2}}
  \filerevision$Revision: 3744 $
  \edef\reserved@a{%
    \noexpand\endgroup
    \noexpand\ProvidesFile{scrkernel-pagestyles.dtx}%
                          [\filedate\space\filerevision\space
                           KOMA-Script source
                           (page styles)]
  }%
\reserved@a
\documentclass[USenglish]{koma-script-source-doc}
\usepackage{babel}
\setcounter{StandardModuleDepth}{3}
\begin{document}
\DocInput{scrkernel-pagestyles.dtx}
\end{document}
%</dtx>
% \fi
%
% \changes{v2.95}{2002/06/25}{first version after splitting \file{scrclass.dtx}}
% \changes{v3.36}{2022/03/05}{switch over from \cls*{scrdoc} to
%   \cls*{koma-script-source-doc}}
% \changes{v3.36}{2022/03/05}{whole implementation documentation in English}
%
% \GetFileInfo{scrkernel-pagestyles.dtx}
% \title{The Code of the Default Page Styles of the
%   \href{https://komascript.de}{\KOMAScript} Classes}
% \author{\href{mailto:komascript@gmx.info}{Markus Kohm}}
% \date{Revision \fileversion{} of \filedate}
% \maketitle
% \begin{abstract}
%   \file{scrkernel-pagestyles.dtx} provides the default page styles of the
%   \KOMAScript{} classes. As already told decades ago, there are plans to
%   remove this code and to require the \KOMAScript{} page style
%   package---namely \pkg*{scrlayer-scrpage}---instead.
% \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 the Page Styles of the \KOMAScript{} Classes}
%
%    \begin{macrocode}
%<*class>
%    \end{macrocode}
%
% \subsection{Options for the separation lines in page head and footer}
%
% \begin{option}{headsepline}
% \changes{v2.95c}{2006/08/11}{arguments of \cs{PassOptonsToPackage} fixed}
% \changes{v2.97c}{2007/04/19}{don't pass \opt{headinclude} to \pkg*{typearea}}
% \changes{v2.98c}{2008/03/26}{set \opt{headinclude}}
% \changes{v3.12}{2013/03/05}{using \cs{FamilyKeyState}}
% \changes{v3.12}{2013/03/05}{if \pkg*{typearea} has not been loaded, pass
%   option to the package}
% \changes{v3.17}{2015/03/10}{using value storage}
% \changes{v3.18a}{2015/07/08}{arguments of \cs{PassOptionsToPackage} fixed
%   again}
% \changes{v3.20}{2015/12/12}{don't pass option to \pkg*{typearea}}
% \begin{macro}{\@hslfalse,\@hsltrue,\if@hsl}
% Optional separation line between page head and text area---in other words:
% below the page head.
%    \begin{macrocode}
%<*option>
\KOMA@ifkey{headsepline}{@hsl}%
\KOMA@kav@add{.\KOMAClassFileName}{headsepline}{false}
%    \end{macrocode}
% \begin{option}{headnosepline}
% \changes{v2.97d}{2007/10/03}{\cs{PackageInfo} replaced by
%   \cs{PackageInfoNoLine}}
%   \changes{v3.01a}{2008/11/20}{deprecated}
%    \begin{macrocode}
\KOMA@DeclareDeprecatedOption{headnosepline}{headsepline=false}
%    \end{macrocode}
% \end{option}^^A headnosepline
% \end{macro}^^A \if@hsl
% \end{option}^^A headsepline
%
%
% \begin{option}{footsepline}
% \changes{v2.0e}{1994/08/14}{missing package at \cs{PassOptionsToPackage}
%   added}
% \changes{v2.95c}{2006/08/11}{arguments of \cs{PassOptionsToPackage} fixed}
% \changes{v2.97c}{2007/04/19}{don't pass \opt{footinclude} to
%   \pkg*{typearea}}
% \changes{v2.98c}{2008/03/26}{set \opt{footinclude}}
% \changes{v3.12}{2013/03/05}{using \cs{FamilyKeyState}}
% \changes{v3.12}{2013/03/05}{if \textsf{typearea} has not been loaded, pass
%   option to package}
% \changes{v3.12}{2013/08/26}{\cs{KOMA@options} replaced by \cs{KOMAoptions}}
% \changes{v3.12}{2013/08/26}{recalculation of typing area}
% \changes{v3.13}{2014/07/07}{no recalculation of typing area}
% \changes{v3.13}{2014/07/07}{\opt{headinclude} mistake fixed}
% \changes{v3.17}{2015/03/10}{using value storage}
% \changes{v3.18a}{2015/07/08}{arguments of \cs{PassOptionsToPackage} fixed
%   again}
% \changes{v3.20}{2015/12/12}{don't pass option to \pkg*{typearea}}
% \begin{macro}{\@fslfalse,\@fsltrue,\if@fsl}
% Optional separation line between text area and page footer---in other words:
% above the page footer.
%    \begin{macrocode}
\KOMA@ifkey{footsepline}{@fsl}%
\KOMA@kav@add{.\KOMAClassFileName}{footsepline}{false}
%    \end{macrocode}
% \begin{option}{footnosepline}
% \changes{v2.97d}{2007/10/03}{\cs{PackageInfo} replaced by
%   \cs{PackageInfoNoLine}}
% \changes{v3.01a}{2008/11/20}{deprecated}
%    \begin{macrocode}
\KOMA@DeclareDeprecatedOption{footnosepline}{footsepline=false}
%</option>
%    \end{macrocode}
% \end{option}^^A footnosepline
% \end{macro}^^A \if@fsl
% \end{option}^^A footsepline
%
% \begin{option}{mpinclude}
% \changes{v2.95}{2002/07/08}{moved to \pkg*{typearea}}
% \end{option}{mpinclude}
%
%
% \subsection{Definition of the standard page styles}
%
%
% \begin{pgstyle}{plain,myheadings,headings}
% \changes{v2.0e}{1994/08/10}{\cls*{scrbook} does not provide single-side page
%   styles}
% \changes{v2.0e}{1994/08/17}{in single-side mode \cs{markboth} replaced by
%   \cs{markright}}
% \changes{v2.1b}{1994/12/31}{in single-side mode \cs{markboth} replaced by
%  \cs{markright}}
% \changes{v2.2a}{1995/02/07}{dot after section number in \cls*{scrbook} and
%   \cls*{scrreprt} removed}
% \changes{v2.2a}{1995/02/07}{using \cs{subsectionmark} in single-side mode
%   with \cls*{scrartcl}}
% \changes{v2.2a}{1995/02/07}{using \cs{sectionmark} in single-side mode with
%   \cls*{scrreprt}}
% \changes{v2.2c}{1995/05/25}{dot after chapter number removed}
% \changes{v2.2c}{1995/05/25}{numbers in running heads support CJK format
%   extension}
% \changes{v2.3a}{1995/07/08}{because \cls{book} from version 1.2v provides
%   option \opt{oneside} single-side page styles added to \cls*{scrbook}}
% \changes{v2.4f}{1996/10/08}{\cs{strut} added to page head}
% \changes{v2.97c}{2007/07/18}{distinguish \opt{twoside} as late as possible}
% \changes{v3.08}{2010/10/28}{\cs{noindent} added before usage of variable
%   \var{nexthead} or \var{nextfoot}}
% \changes{v3.10}{2011/08/31}{using \cs{MakeMarkcase}}
% \changes{v3.28}{2019/11/19}{\cs{ifnumbered} renamed to \cs{Ifnumbered}}
% In difference to the standard classes, the \KOMAScript{} classes use
% pagination in the page footer for all page styles. Also an optional
% separation line below the page head and above the page footer is
% supported. The ugly usage of pool man's upper case for the running head of
% the standard classes is also not used, but optional.
% \begin{macro}{\set@tempdima@hw}
% \changes{v2.8q}{2002/03/28}{added}
% Because with \pkg*{typearea} option \opt{mpinclude} the head should be
% extended to the margin note column, \cs{set@tempdima@hw} sets
% \len{@tempdima} to the corresponding head width.
% \begin{description}
% \item[Note:] Package \pkg*{scrlayer} does not use this code, but allows
%   to configure the width of head and foot independent, which is much
%   better.
% \end{description}
%    \begin{macrocode}
%<*body>
\newcommand*{\set@tempdima@hw}{%
  \setlength{\@tempdima}{\textwidth}%
  \if@mincl
    \addtolength{\@tempdima}{\marginparsep}%
    \addtolength{\@tempdima}{\marginparwidth}%
  \fi
}
%    \end{macrocode}
% \end{macro}^^A \set@tempdima@hw
% \begin{fontelement}{pagenumber}
% \changes{v2.8o}{2001/09/14}{added}
% \begin{fontelement}{pagination}
% \changes{v2.8o}{2001/09/14}{alias added}
% \begin{fontelement}{pageheadfoot}
% \changes{v2.98c}{2008/02/14}{added}
% \begin{fontelement}{pagehead}
% \changes{v2.8o}{2001/09/14}{added with warning added}
% \changes{v2.98c}{2008/02/14}{changed to alias}
% \changes{v2.97c}{2007/09/25}{warning changed}
% \changes{v2.98c}{2008/02/14}{warning changed}
% \begin{fontelement}{pagefoot}
% \changes{v2.8o}{2001/09/14}{alias with warning added}
% \changes{v2.98c}{2008/02/14}{changed to element}
% \changes{v3.13}{2014/01/13}{warning changed}
% \begin{macro}{\pnumfont,\headfont}
% \changes{v2.8c}{2001/06/29}{\cs{normalcolor} added}
% \begin{macro}{\footfont}
% \changes{v2.98c}{2008/02/14}{added}
% All these font settings are deprecated as user commands, but still valid as
% internal macros, used to define font elements. Because of using the old
% macros, we have to define elements manually instead of using \cs{newkomafont}.
%    \begin{macrocode}
\newcommand*{\pnumfont}{\normalfont\normalcolor}
\newcommand*{\headfont}{\normalfont\normalcolor\slshape}
\newcommand*{\footfont}{}
%    \end{macrocode}
%    \begin{macrocode}
\newcommand*{\scr@fnt@pagenumber}{\pnumfont}
\aliaskomafont{pagination}{pagenumber}
\newcommand*{\scr@fnt@pageheadfoot}{\headfont}
\aliaskomafont{pagehead}{pageheadfoot}
%<*letter>
\newcommand*{\scr@fnt@wrn@pagehead}[1]{%
  `pagehead' is only an alias of `pageheadfoot'.\MessageBreak
  Font of page foot will also be changed%
}
\newcommand*{\scr@fnt@pagefoot}{\footfont}
%</letter>
%<*!letter>
\newcommand*{\scr@fnt@pagefoot}{\footfont}
\newcommand*{\scr@fnt@wrn@pagefoot}[1]{%
  This class does not use font element `pagefoot'!\MessageBreak
  Maybe you should load package `scrlayer-scrpage',\MessageBreak
  before using this element%
}
%</!letter>
%    \end{macrocode}
% \end{macro}^^A \footfont
% \end{macro}^^A \pnumfont,\headfont
% \end{fontelement}^^A pagefoot
% \end{fontelement}^^A pagehead
% \end{fontelement}^^A pageheadfoot
% \end{fontelement}^^A pagination
% \end{fontelement}^^A pagenumber
%
% \begin{command}{\pagemark}
% \changes{v2.95}{2006/03/15}{available for all classes}
% \changes{v3.05}{2010/02/05}{group added}
% \begin{command}{\letterpagemark}
% \changes{v3.17}{2015/03/20}{added for \pkg*{scrletter}}
% The pagination used by all classes. Originally this has been defined to
% simplify usage of \pkg{fancyhdr} (instead of
% \pkg[https://www.ctan.org/pkg/koma-script-obsolete]{scrpage2}), because in
% this case you just have to use \cs{pagemark} instead of \cs{thepage} in the
% definitions of the fancy page style to support \KOMAScript. But neither the
% author nor the users of \pkg{fancyhdr} have used it. However, now it is
% useful for \pkg{scrlayer-scrpage} too. And because we use another pagination
% for letters, we define a second command for \pkg*{scrletter}.
%    \begin{macrocode}
%</body>
%</class>
%<*(class|letter)&body>
\newcommand*{%
%<class>  \pagemark
%<package>  \letterpagemark
}{%
  {\usekomafont{pagenumber}{%
%<letter>    \pagename\nobreakspace
    \thepage}}}
%</(class|letter)&body>
%    \end{macrocode}
% \end{command}^^A \letterpagemark
% \end{command}^^A \pagemark
% First of all we have to define the page styles of all classes but the letter
% class.
%    \begin{macrocode}
%<*class&!letter&body>
\renewcommand*{\ps@plain}{%
  \renewcommand*{\@oddhead}{}%
  \let\@evenhead\@oddhead
  \renewcommand*{\@evenfoot}{%
    \set@tempdima@hw\hss\hb@xt@ \@tempdima{\vbox{%
        \if@fsl \hrule \vskip 3\p@ \fi
        \hb@xt@ \@tempdima{{\pagemark\hfil}}}}}%
  \renewcommand*{\@oddfoot}{%
    \set@tempdima@hw\hb@xt@ \@tempdima{\vbox{%
        \if@fsl \hrule \vskip 3\p@ \fi
        \hb@xt@ \@tempdima{{\hfil\pagemark
            \if@twoside\else\hfil\fi}}}}\hss}%
}%
\newcommand*{\ps@headings}{\let\@mkboth\markboth
  \renewcommand*{\@evenhead}{%
    \set@tempdima@hw\hss\hb@xt@ \@tempdima{\vbox{%
        \hb@xt@ \@tempdima{{\headfont\strut\leftmark\hfil}}%
        \if@hsl \vskip 1.5\p@ \hrule \fi}}}%
  \renewcommand*{\@oddhead}{%
    \set@tempdima@hw\hb@xt@ \@tempdima{\vbox{%
        \hb@xt@ \@tempdima{{\headfont\hfil\strut\rightmark
            \if@twoside\else\hfil\fi}}%
        \if@hsl \vskip 1.5\p@ \hrule \fi}}\hss}%
  \renewcommand*{\@evenfoot}{%
    \set@tempdima@hw\hss\hb@xt@ \@tempdima{\vbox{%
        \if@fsl \hrule \vskip 3\p@ \fi
        \hb@xt@ \@tempdima{{\pagemark\hfil}}}}}%
  \renewcommand*{\@oddfoot}{%
    \set@tempdima@hw\hb@xt@ \@tempdima{\vbox{%
        \if@fsl \hrule \vskip 3\p@ \fi
        \hb@xt@ \@tempdima{{\hfil\pagemark
            \if@twoside\else\hfil\fi}}}}\hss}%
%<*article>
  \renewcommand*{\sectionmark}[1]{%
    \if@twoside\expandafter\markboth\else\expandafter\markright\fi
    {\MakeMarkcase{\Ifnumbered{section}{\sectionmarkformat}{}##1}}{}}%
  \renewcommand*{\subsectionmark}[1]{%
    \if@twoside
      \markright{%
        \MakeMarkcase{\Ifnumbered{subsection}{\subsectionmarkformat}{}##1}%
      }%
    \fi
  }%
%</article>
%<*report|book>
  \renewcommand*{\chaptermark}[1]{%
    \if@twoside\expandafter\markboth\else\expandafter\markright\fi
    {\MakeMarkcase{\Ifnumbered{chapter}{%
%<book>        \if@mainmatter
          \chaptermarkformat
%<book>        \fi
      }{}##1}%
    }{}%
  }%
  \renewcommand*{\sectionmark}[1]{%
    \if@twoside
      \markright{\MakeMarkcase{\Ifnumbered{section}{\sectionmarkformat}{}%
        ##1}}%
    \fi
  }%
%</report|book>
}%
\newcommand*{\ps@myheadings}{\let\@mkboth\@gobbletwo
  \renewcommand*{\@evenhead}{%
    \set@tempdima@hw\hss\hb@xt@ \@tempdima{\vbox{%
        \hb@xt@ \@tempdima{{\headfont\strut\leftmark\hfil}}%
        \if@hsl \vskip 1.5\p@ \hrule \fi}}}%
  \renewcommand*{\@oddhead}{%
    \set@tempdima@hw\hb@xt@ \@tempdima{\vbox{%
        \hb@xt@ \@tempdima{{\headfont\hfil\strut\rightmark
            \if@twoside\else\hfil\fi}}%
        \if@hsl \vskip 1.5\p@ \hrule \fi}}\hss}%
  \renewcommand*{\@evenfoot}{%
    \set@tempdima@hw\hss\hb@xt@ \@tempdima{\vbox{%
        \if@fsl \hrule \vskip 3\p@ \fi
        \hb@xt@ \@tempdima{{\pagemark\hfil}}}}}%
  \renewcommand*{\@oddfoot}{%
    \set@tempdima@hw\hb@xt@ \@tempdima{\vbox{%
        \if@fsl \hrule \vskip 3\p@ \fi
        \hb@xt@ \@tempdima{{\hfil\pagemark
            \if@twoside\else\hfil\fi}}}}\hss}%
%<!article>  \renewcommand*{\chaptermark}[1]{}%
%<article>  \renewcommand*{\subsectionmark}[1]{}%
  \renewcommand*{\sectionmark}[1]{}%
}
%</class&!letter&body>
%    \end{macrocode}
% And now the page styles of the letter class.
%    \begin{macrocode}
%<*class&letter&body>
\renewcommand*{\ps@plain}{%
  \renewcommand*{\@oddhead}{%
    \vbox{\vbox{\hsize=\textwidth\hbox to\textwidth{%
          \parbox[b]{\textwidth}{\strut
            \ifnum\@pageat>-1
              \ifnum\@pageat<3
                \ifcase\@pageat\raggedright\or\centering\or\raggedleft\fi
                \pagemark
              \else
                \hfill
              \fi
            \else
              \hfill
            \fi
          }%
        }%
        \if@hsl\kern1pt\rule{\textwidth}{.4pt}\fi
      }%
    }%
  }%
  \let\@evenhead\@oddhead%
  \renewcommand*{\@oddfoot}{%
    \parbox[t]{\textwidth}{%
      \if@fsl
        {%
          \raggedright%
          \vskip-\baselineskip\vskip.4pt
          \hrulefill\\
        }%
      \fi
      \ifnum\@pageat>2
        \ifcase\@pageat\or\or\or\raggedright\or\centering\or\raggedleft\fi
        \strut\pagemark
      \else
        \hfill
      \fi
    }%
  }%
  \let\@evenfoot\@oddfoot
}
\newcommand*{\ps@headings}{\let\@mkboth\markboth
  \renewcommand*{\@oddhead}{%
    \vbox{%
      \vbox{\hsize=\textwidth\hbox to\textwidth{\headfont\noindent
          \usekomavar{nexthead}}}%
      \if@hsl\kern1pt\rule{\textwidth}{.4pt}\fi%
    }%
  }%
  \let\@evenhead\@oddhead
  \renewcommand*{\@oddfoot}{%
    \parbox[t]{\textwidth}{%
      \if@fsl
        {%
          \raggedright%
          \vskip-\baselineskip\vskip.4pt
          \hrulefill\\
        }%
      \fi
      \vbox{\hsize=\textwidth\hbox to\textwidth{\headfont\footfont\noindent
          \usekomavar{nextfoot}}}%
    }%
  }%
  \let\@evenfoot\@oddfoot
}
\newcommand*{\ps@myheadings}{%
  \ps@headings
  \let\@mkboth\@gobbletwo
}
%</class&letter&body>
%    \end{macrocode}
% The letter package already uses \pkg*{scrlayer-scrpage}:
%    \begin{macrocode}
%<*package&letter&body>
\RequirePackage{scrlayer-scrpage}
\newpairofpagestyles{letter}{%
  \clearpairofpagestyles
  \lehead[\ifnum\@pageat=\z@\pagemark\fi]%
         {\usekomavar{nexthead}}%
  \lohead[\ifnum\@pageat=\z@\pagemark\fi]%
         {\usekomavar{nexthead}}%
  \chead[\ifnum\@pageat=\@ne\pagemark\fi]%
        {}%
  \rehead[\ifnum\@pageat=\tw@\pagemark\fi]%
         {}%
  \rohead[\ifnum\@pageat=\tw@\pagemark\fi]%
         {}%
  \lefoot[\ifnum\@pageat=\thr@@\pagemark\fi]%
         {\usekomavar{nextfoot}}%
  \lofoot[\ifnum\@pageat=\thr@@\pagemark\fi]%
         {\usekomavar{nextfoot}}%
  \cfoot[\ifnum\@pageat=4 \pagemark\fi]%
        {}%
  \refoot[\ifnum\@pageat=5 \pagemark\fi]%
         {}%
  \rofoot[\ifnum\@pageat=5 \pagemark\fi]%
         {}%
}
%</package&letter&body>
%    \end{macrocode}
% \end{pgstyle}^^A plain,myheadings,headings
%
% \begin{pgstyle}{notepaper}
% \changes{v3.27}{2019/03/22}{plan added}
% There are plans for \pkg*{scrletter} package to use a new layer
% \texttt{notepaper} to define the notepaper. With this layer it is possible
% to add several separated information blocks everywhere on the first
% page. A \texttt{picture} mode layer is used, because this makes the
% placement easier. It's a background layer, so the page contents are printed
% above. We could also use an odd-side layer, but who knows \dots
%    \begin{macrocode}
%<*package&letter&body&willbe>
\DeclareNewLayer[%
  background,
  mode=picture,
  page,
  align=b,
  contents=\scr@notepaper@printallelements
]{notepaper}
%    \end{macrocode}
% For \cs{scr@notepaper@elements} see \file{scrkernel-notepaper.dtx}.
%
% A second layer is used for the foldmarks. Again it is a picture layer. But
% this time it is an odd-sides-only layer.
%    \begin{macrocode}
\DeclareNewLayer[%
  background,
  mode=picture,
  page,
  align=b,
  contents=\scr@foldmarks@printallelements
]{foldmarks}
%    \end{macrocode}
% For \cs{@hfoldmark} and \cs{@vfoldmark} see \file{scrkernel-notepaper.dtx}.
%
% Last but not least the page style. The foldmarks are below the notepaper.
%    \begin{macrocode}
\DeclareNewPageStyleByLayers{notepaper}{foldmarks,notepaper}  
%</package&letter&body&willbe>
%    \end{macrocode}
% \end{pgstyle}^^A notepaper
%
%
% \subsection{Selection of page styles for special pages}
%
%
% \begin{command}{\titlepagestyle,\indexpagestyle}
% \changes{v2.8d}{2001/07/05}{added}
% For pages with the in-page title and for the first page of the index,
% \KOMAScript{} provides configurable page styles. These are initially
% \pstyle{plain}.
%    \begin{macrocode}
%<*class&!letter&body>
\newcommand*{\titlepagestyle}{plain}
\newcommand*{\indexpagestyle}{plain}
%</class&!letter&body>
%    \end{macrocode}
% \end{command}
% \begin{command}{\partpagestyle}
% \changes{v2.8d}{2001/07/05}{added}
% \changes{v3.00}{2008/08/05}{not with \cls*{scrartcl}}
% \changes{v3.18}{2015/06/10}{indirect by \cs{DeclareSectionCommand}}
% \end{command}
% \begin{command}{\chapterpagestyle}
% \changes{v2.8d}{2001/07/05}{added}
% \changes{v3.18}{2015/05/20}{indirect by \cs{DeclareSectionCommand}}
% \end{command}
%
%
% \subsection{Selection of initial page style}
%
% The initial page style depends on the class:
%    \begin{macrocode}
%<*class&body>
%<report|article|letter>\pagestyle{plain}
%<book>\pagestyle{headings}
%    \end{macrocode}
% But the pagination is always done using Arabic numbers.
%    \begin{macrocode}
\pagenumbering{arabic}
%</class&body>
%    \end{macrocode}
%
% \section{Implementation of Interleaf Pages}
%
% \begin{description}
% \item[ToDo:] Move this code to a new file \file{scrkernel-interleaf.dtx}.
% \end{description}
%
% \begin{option}{cleardoublepage}
% \changes{v2.95}{2004/08/24}{added}
% \changes{v2.96a}{2007/01/03}{value \opt{\quotechar=current} fixed}
% \changes{v2.98c}{2008/03/06}{\cs{def} replaced by \cs{let}, because of
%   option \opt{open}}
% \changes{v3.12}{2013/03/05}{using \cs{FamilyKeyState}}
% \changes{v3.17}{2015/03/10}{using value storage}
% \begin{command}{\cleardoublestandardpage}
% \changes{v2.8a}{2001/06/18}{added}
% \changes{v2.96a}{2007/01/02}{default value added}
% \begin{command}{\cleardoubleusingstyle}
% \changes{v2.95}{2004/08/24}{added}
% \changes{v3.06a}{2010/09/17}{\cs{thispagestyle} replaced by
%   \cs{pagestyle}}
% \begin{command}{\cleardoubleemptypage,\cleardoubleplainpage}
% \changes{v2.8a}{2001/06/18}{added}
% \begin{command}{\cleardoubleoddpage,\cleardoubleoddstandardpage}
% \changes{v2.98c}{2008/03/06}{added}
% \begin{command}{\cleardoubleoddusingstyle}
% \changes{v2.98c}{2008/03/06}{added}
% \changes{v3.06a}{2010/09/17}{\cs{thispagestyle} replaced by
%   \cs{pagestyle}}
% \begin{command}{\cleardoubleoddemptypage,\cleardoubleoddplainpage}
% \changes{v2.98c}{2001/06/18}{added}
% \begin{command}{\cleardoubleevenpage,\cleardoubleevenstandardpage}
% \changes{v2.98c}{2008/03/06}{added}
% \begin{command}{\cleardoubleevenusingstyle}
% \changes{v2.98c}{2008/03/06}{added}
% \changes{v3.06a}{2010/09/17}{\cs{thispagestyle} replaced by
%   \cs{pagestyle}}
% \begin{command}{\cleardoubleevenemptypage,\cleardoubleevenplainpage}
% \changes{v2.98c}{2001/06/18}{added}
% \begin{command}{\cleardoublepage}
% \changes{v2.98c}{2001/06/18}{always redefining it}
% \changes{v2.98c}{2008/04/11}{new default from version 2.98c}
% \changes{v3.13}{2014/03/01}{allow page style \pstyle{headings} as value for
%   class option}
% \changes{v3.28}{2019/11/18}{\cs{ifnotundefined} replaced by
%   \cs{Ifnotundefined}}
% \changes{v3.28}{2019/11/18}{\cs{ifstr} replaced by \cs{Ifstr}}
% With options \opt{twoside} and \opt{openright}, which are both default with
% \cls*{scrbook} and available with \cls*{scrreprt}, \cs{chapter} imply
% \cs{cleardoublepage}. Usually this results in a new odd page and can insert
% an interleaf page. With the standard classes this interleaf page has the
% current active page style and therefore can have a running head and
% pagination. Mainstream typography uses empty pages without running head or
% pagination for interleaf pages. Some users also want a pagination but no
% running head. Option \opt{cleardoublepage} can be used to select all the
% often wishes and also every other page style. The corresponding commands are
% also defined and the option re-defines \cs{cleardoublepage} to use one of
% these additional commands. Similar is for \cs{cleardoubleoddpage} and
% \cs{cleardoubleevenpage}.
%    \begin{macrocode}
%<*(class|scrextend)&option>
\KOMA@key{cleardoublepage}{%
  \begingroup%
    \def\@tempc{%
      \endgroup%
      \KOMA@unknown@keyval{cleardoublepage}{#1}{%
        'current' or any defined pagestyle e.g. 'empty','plain', 'headings'}%
    }%
    \Ifstr{#1}{current}{%
      \def\@tempc{\endgroup%
        \def\cleardoublepage{\cleardoublestandardpage}%
        \def\cleardoubleoddpage{\cleardoubleoddstandardpage}%
        \def\cleardoubleevenpage{\cleardoubleevenstandardpage}%
        \FamilyKeyStateProcessed
        \KOMA@kav@replacevalue{.%
%<package&extend>          scrextend.\scr@pkgextension
%<class>          \KOMAClassFileName
        }{cleardoublepage}{current}%
      }%
    }{%
      \Ifnotundefined{ps@#1}{%
        \def\@tempc{\endgroup%
          \def\cleardoublepage{\cleardoublepageusingstyle{#1}}%
          \def\cleardoubleoddpage{\cleardoubleoddpageusingstyle{#1}}%
          \def\cleardoubleevenpage{\cleardoubleevenpageusingstyle{#1}}%
          \FamilyKeyStateProcessed
          \KOMA@kav@xreplacevalue{.%
%<package&extend>            scrextend.\scr@pkgextension
%<class>            \KOMAClassFileName
          }{cleardoublepage}{#1}%
        }%
      }{%
%    \end{macrocode}
% At class loading time page style \pstyle{headings} is still undefined, but
% should be allowed as value for option \opt{cleardoublepage}.
% \begin{description}
% \item[Note:] Page style \pstyle{plain} is already defined in the \LaTeX{}
%   kernel and therefore does not need special treatment.
% \end{description}
%    \begin{macrocode}
%<*class>
        \ifx\@currname\KOMAClassName
          \ifx\@currext\@clsextension
            \Ifstr{#1}{headings}{%
              \def\@tempc{\endgroup%
                \def\cleardoublepage{\cleardoublepageusingstyle{#1}}%
                \def\cleardoubleoddpage{\cleardoubleoddpageusingstyle{#1}}%
                \def\cleardoubleevenpage{\cleardoubleevenpageusingstyle{#1}}%
                \FamilyKeyStateProcessed
                \KOMA@kav@xreplacevalue{.\KOMAClassFileName}%
                                       {cleardoublepage}{#1}%
              }%
            }{}%
          \fi
        \fi
%</class>
      }%
    }%
  \@tempc
}
\newcommand*{\cleardoubleoddstandardpage}{}
\let\cleardoubleoddstandardpage=\cleardoublepage
\newcommand*{\cleardoubleoddpageusingstyle}[1]{\clearpage
  {\pagestyle{#1}\cleardoubleoddstandardpage}}
\newcommand*{\cleardoubleoddemptypage}{\cleardoubleoddpageusingstyle{empty}}
\newcommand*{\cleardoubleoddplainpage}{\cleardoubleoddpageusingstyle{plain}}
\newcommand*{\cleardoubleevenstandardpage}{%
  \clearpage
  \if@twoside\ifodd\c@page
      \hbox{}\newpage\if@twocolumn\hbox{}\newpage\fi
  \fi\fi
}
\newcommand*{\cleardoubleevenpageusingstyle}[1]{\clearpage
  {\pagestyle{#1}\cleardoubleevenstandardpage}}
\newcommand*{\cleardoubleevenemptypage}{\cleardoubleevenpageusingstyle{empty}}
\newcommand*{\cleardoubleevenplainpage}{\cleardoubleevenpageusingstyle{plain}}
\newcommand*{\cleardoublestandardpage}{\cleardoubleoddstandardpage}
\renewcommand*{\cleardoublepage}{%
  \expandafter\ifnum \@nameuse{scr@v@2.98c}<\scr@compatibility\relax
    \cleardoubleemptypage
  \else
    \cleardoublestandardpage
  \fi
}
\KOMA@kav@add{.%
%<package&extend>  scrextend.\scr@pkgextension
%<class>  \KOMAClassFileName
}{cleardoublepage}{%
  \expandafter\ifnum \scr@v@is@gt{2.98c}empty\else current\fi
}
%    \end{macrocode}
% We expand the value at the end of the class or package.
%    \begin{macrocode}
%<package&extend>\AtEndOfPackage{%
%<class>\AtEndOfClass{%
  \KOMAoptionOf[\expandafter\edef\expandafter\@tempa\@firstofone]%
               {%
%<package&extend>                 scrextend.\scr@pkgextension
%<class>                 \KOMAClassFileName
               }{cleardoublepage}%
  \KOMA@kav@removekey{.%
%<package&extend>    scrextend.\scr@pkgextension
%<class>    \KOMAClassFileName
  }{cleardoublepage}%
  \KOMA@kav@xadd{.%
%<package&extend>    scrextend.\scr@pkgextension
%<class>    \KOMAClassFileName
  }{cleardoublepage}{\@tempa}%
}
\newcommand*{\cleardoubleoddpage}{\cleardoubleoddemptypage}
\newcommand*{\cleardoubleevenpage}{\cleardoubleevenemptypage}
\newcommand*{\cleardoublepageusingstyle}[1]{\clearpage
  {\pagestyle{#1}\cleardoublestandardpage}}
\newcommand*{\cleardoubleemptypage}{\cleardoublepageusingstyle{empty}}
\newcommand*{\cleardoubleplainpage}{\cleardoublepageusingstyle{plain}}
%    \end{macrocode}
% \end{command}^^A \cleardoublepage
% \end{command}^^A \cleardoubleevenplainpage,\cleardoubleevenemptypage
% \end{command}^^A \cleardoubleevenusingstyle
% \end{command}^^A \cleardoubleevenpage,\cleardoubleevenstandardpage
% \end{command}^^A \cleardoubleoddemptypage,\cleardoubleoddplainpage
% \end{command}^^A \cleardoubleoddusingstyle
% \end{command}^^A \cleardoubleoddpage,\cleardoubleoddstandardpage
% \end{command}^^A \cleardoubleemptypage,\cleardoubleplainpage
% \end{command}^^A \cleardoubleusingstyle
% \end{command}^^A \cleardoublestandardpage
% \begin{option}{cleardoubleempty,cleardoubleplain,cleardoublestandard}
% \changes{v2.8a}{2001/06/18}{added}
% \changes{v2.8q}{2001/11/06}{\cs{cleardoublestandardpage} replaced by
%   \cs{cleardoublestandard}}
% \changes{v2.97d}{2007/10/03}{\cs{PackageInfo} replaced by
%   \cs{PackageInfoNoLine}}
% \changes{v3.01a}{2008/11/20}{deprecated}
%    \begin{macrocode}
%<*class>
\KOMA@DeclareDeprecatedOption{cleardoubleempty}{cleardoublepage=empty}
\KOMA@DeclareDeprecatedOption{cleardoubleplain}{cleardoublepage=plain}
\KOMA@DeclareDeprecatedOption{cleardoublestandard}{cleardoublepage=current}
%</class>
%</(class|scrextend)&option>
%    \end{macrocode}
% \end{option}^^A cleardoublestandard,cleardoubleplain,cleardoubleempty
% \end{option}^^A cleardoublepage
%
%
% \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: