summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/koma-script/source/scrlayer-scrpage.dtx
blob: e0b8af619a3f546d8d2d527802cca8e4c647c09d (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
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
% \iffalse^^A meta-comment
% ======================================================================
% scrlayer-scrpage.dtx
% Copyright (c) Markus Kohm, 2012-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 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: scrlayer-scrpage.dtx 3693 2022-02-10 13:20:09Z kohm $
%<identify>%%%            (run: identify)
%<init>%%%            (run: init)
%<options>%%%            (run: options)
%<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-02-10 14:20:09 +0100 (Do, 10. Feb 2022) $
  \def\filerevision$#1: #2 ${\gdef\filerevision{r#2}}
  \filerevision$Revision: 3693 $
  \edef\reserved@a{%
    \noexpand\endgroup
    \noexpand\ProvidesFile{scrlayer-scrpage.dtx}%
                          [\filedate\space\filerevision\space
                           KOMA-Script package source
  }%
\reserved@a
%</dtx>
%<*identify>
%<interface>\NeedsTeXFormat{LaTeX2e}[1995/12/01]
%<interface>\ProvidesPackage{scrlayer-scrpage}[%
%!KOMAScriptVersion
%<interface>  package
%</identify>
%<*dtx|identify>
  (end user interface for scrlayer)]
%</dtx|identify>
%<*dtx>
\ifx\documentclass\undefined
  \input scrdocstrip.tex
  \@@input scrkernel-version.dtx
  \@@input scrstrip.inc
  \KOMAdefVariable{COPYRIGHTFROM}{2012}
  \generate{\usepreamble\defaultpreamble
    \file{scrlayer-scrpage.sty}{%
      \from{scrlayer-scrpage.dtx}{interface,scrpage,identify}%
      \from{scrlayer.dtx}{interface,scrpage,init}%
      \from{scrlayer-scrpage.dtx}{interface,scrpage,init}%
      \from{scrlayer.dtx}{interface,scrpage,options}%
      \from{scrlayer-scrpage.dtx}{interface,scrpage,options}%
      \from{scrlayer.dtx}{interface,scrpage,body}%
      \from{scrlayer-scrpage.dtx}{interface,scrpage,body}%
      \from{scrlogo.dtx}{logo}%
    }%
  }
  \@@input scrstrop.inc
\else
  \let\endbatchfile\relax
\fi
\endbatchfile
\documentclass[USenglish]{koma-script-source-doc}
\usepackage{babel}
\setcounter{StandardModuleDepth}{2}
% We need (foo,bar)
\DeclareRobustCommand*{\pparg}[2]{\texttt(\meta{#1}\texttt,\meta{#2}\texttt)}
% and {foo:bar}
\DeclareRobustCommand*{\mmarg}[2]{%
  \texttt{\char`\{}\meta{#1}\texttt:\meta{#2}\texttt{\char`\}}}
\begin{document}
  \DocInput{scrlayer-scrpage.dtx}
\end{document}
%</dtx>
% \fi^^A meta-comment
%
% \changes{v0.0}{2012/01/01}{start of interface}
% \changes{v3.32}{2020/09/11}{do not use deprecated interface commands}
% \changes{v3.36}{2022/02/09}{switch over from \cls*{scrdoc} to
%   \cls*{koma-script-source-doc}}
% \changes{v3.36}{2022/02/09}{require package \pkg*{scrlogo} instead of
%   defining \cs{KOMAScript}}
% \changes{v3.36}{2022/02/09}{whole implementation documentation in English}
%
% \GetFileInfo{scrlayer-scrpage.dtx}
% \title{The \texttt{scrlayer} Interface of
%   \href{https://komascript.de}{\KOMAScript} Package \pkg*{scrlayer-scrpage}}
% \author{\href{mailto:komascript@gmx.info}{Markus Kohm}}
% \date{Revision \fileversion{} of \filedate}
% \maketitle
% \begin{abstract}
%   This package defines several extensions above \pkg*{scrlayer} for easy
%   handling of pairs of \emph{headings} and \emph{plain} page styles. So this
%   widely is a replacement of the not any longer supported, former
%   \KOMAScript{} package \pkg{scrpage2}.
% \end{abstract}
% \tableofcontents
%
% \section{User Manual}
%
% You can find the user manuals of \pkg*{scrlayer-scrpage} in the \KOMAScript{}
% manual, either the German \file{scrguide} or the English \file{scrguien}.
%
% \MaybeStop{\PrintIndex}
%
%
% \section{Implementation of \pkg*{scrlayer-scrpage}}
% \label{sec:scrlayer-scrpage}
%
% This section if for developers only.
%
%    \begin{macrocode}
%<*interface>
%    \end{macrocode}
% 
%
% \subsection{Initialising some values before the options}
%
%    \begin{macrocode}
%<*init>
%    \end{macrocode}
%
% Initialisation before all options (even the options from
% \file{scrlayer.dtx}).
%
% Currently nothing to do.
%
%    \begin{macrocode}
%</init>
%    \end{macrocode}
%
%
% \subsection{Options}
%
%    \begin{macrocode}
%<*options>
%    \end{macrocode}
% 
% Package \pkg{scrpage2} didn't support \KOMAScript{} options but only
% regular \LaTeX{} package options.  This interface will also support those
% options, but uses \KOMAScript{} options for the implementation.  This
% results in additional features of the interface.
%
% Note, that some options are already defined before this by the common option
% parts of \file{scrlayer.dtx}. All others will follow step by step in the
% main part.
%
% Options \opt{headinclude}, \opt{headexclude}, \opt{footinclude} and
% \opt{footexclude} of package \pkg{scrpage2} are deprecated since
% package version 2.3, 2008-12-08. They won't be supported by the
% \pkg*{scrlayer-scrpage} interface.
%
% Additional initialisation may be done here, but currently this isn't
% needed.
%
%    \begin{macrocode}
%</options>
%    \end{macrocode}
% 
%
% \subsection{Width of header and footer}
%
% \pkg{scrpage2} provided commands \cs{setheadwidth} and \cs{setfootwidth} to
% set the width of the page head or footer different from the width of the
% text area of the page. Optionally those commands allow to setup an
% horizontal offset for the head or footer. This interface provides the same
% feature but prefers to set up the widths and offsets with \KOMAScript{}
% options. Those options will become the primary interface.
%
% \begin{option}{headwidth}
% \changes{v0.9.1757}{2014/04/09}{new: two offsets available}
% \changes{v3.17}{2015/02/25}{new: store the values}
% \begin{option}{footwidth}
% \changes{v0.9.1757}{2014/04/09}{new: two offsets available}
% \changes{v3.15}{2014/12/28}{fix: missing colon in call of
%   \cs{sls@split@at@iicolons}}
% \changes{v3.17}{2015/02/25}{new: store the values}
% \begin{description}
% \item[\texttt{=\meta{special dimensional expression}:\meta{special
%   dimensional expression}}:] see \cs{sls@settowidthof} for information about
%   the syntax of \meta{special dimensional expression}. The width of the page
%   head or footer will be set to the result of the first on, the offset to
%   the result of the second one. If the first one\,---\,the width\,---\,is
%   omitted, the current width will be used. If the second one\,---\,the
%   offset\,---\,is omitted and the width is the width of the text area plus
%   the margin note column, the offset will be set to zero. If the second one
%   is omitted and the width is not the width of the text area plus the margin
%   note column, a special kind of centering will be used.
% \end{description}
% These options may be used to set up the widths of head and foot.
%    \begin{macrocode}
%<*options>
\KOMA@key{headwidth}{%
  \begingroup
    \sls@split@at@iicolons#1:::\@nil
    \ifx\reserved@a\@empty \let\reserved@a\sls@headwidth\fi
    \edef\reserved@a{%
      \noexpand\endgroup
      \noexpand\sls@set@hf@width{head}{\reserved@b}{\reserved@c}{\reserved@a}%
      \noexpand\FamilyKeyStateProcessed
      \noexpand\KOMA@kav@replacevalue{.scrlayer-scrpage.sty}{headwidth}{%
        \reserved@a:\reserved@b:\reserved@c
      }%
    }%
  \reserved@a
}
\KOMA@key{footwidth}{%
  \begingroup
    \sls@split@at@iicolons#1:::\@nil
    \ifx\reserved@a\@empty \let\reserved@a\sls@footwidth\fi
    \edef\reserved@a{%
      \noexpand\endgroup
      \noexpand\sls@set@hf@width{foot}{\reserved@b}{\reserved@c}{\reserved@a}%
      \noexpand\FamilyKeyStateProcessed
      \noexpand\KOMA@kav@replacevalue{.scrlayer-scrpage.sty}{footwidth}{%
        \reserved@a:\reserved@b:\reserved@c
      }%
    }%
  \reserved@a
}
%    \end{macrocode}
% \begin{macro}{\sls@split@at@iicolons}
% \changes{v3.28}{2019/11/18}{\cs{ifstr} renamed to \cs{Ifstr}}
% \begin{description}
% \item[\texttt{\meta{balanced}:\meta{balanced}:\meta{balanced}\cs{@nil}}:]
%   first \meta{balanced} will be stored into \cs{reserved@a}, second into
%   \cs{reserved@b}, third will be eaten and warn about if it is neither empty
%   and nor a colon.
% \end{description}
% This little helper is used, e.g., by options \opt{headwidth} and
% \opt{footwidth}.
%    \begin{macrocode}
\newcommand\sls@split@at@iicolons{}
\def\sls@split@at@iicolons#1:#2:#3:#4\@nil{%
  \Ifstr{#4}{}{}{%
    \Ifstr{#4}{:}{}{%
      \Ifstr{#4}{::}{}{%
        \PackageWarning{scrlayer}{extra `:' found!\MessageBreak
          You've used more than two colons at the argument\MessageBreak
          of a two value option.\MessageBreak
          The extra value(s) will be ignored%
        }%
      }%
    }%
  }%
  \def\reserved@a{#1}%
  \def\reserved@b{#2}%
  \def\reserved@c{#3}%
}%
%    \end{macrocode}
% \end{macro}^^A \sls@split@at@iicolons
% \begin{macro}{\sls@set@hf@width}
% \changes{v0.9.1757}{2014/04/09}{new: two offsets available}
% \changes{v3.28}{2019/11/18}{\cs{ifstr} renamed to \cs{Ifstr}}
% \begin{description}
% \item[\marg{head or foot}:] to complete the macro names for page head or
%   footer, either \texttt{head} or \texttt{foot}.
% \item[\marg{special dimensional expression}:] the offset odd page
% \item[\marg{special dimensional expression}:] the offset even page
% \item[\marg{special dimensional expression}:] the width
% \end{description}
% This helper will generally set up width an offset of either head or footer.
%    \begin{macrocode}
\newcommand*{\sls@set@hf@width}[4]{%
  \sls@settowidthof{\@tempdima}{#4}%
  \ifdim\@tempdima>\paperwidth
    \PackageWarning
      {scrlayer-scrpage}%
      {You've set width of #1 to a value\MessageBreak
        greater than width of page!\MessageBreak%
        I'll reduce width of #1 to width of page}%
    \setlength{\@tempdima}{\paperwidth}%
  \else
    \ifdim\@tempdima<\z@
       \PackageWarning
         {scrlayer-scrpage}%
         {You've set width of #1 to negative value!\MessageBreak%
           I'll set it to 0pt}%
       \setlength{\@tempdima}{\z@}%
     \fi
  \fi
  \expandafter\edef\csname sls@#1width\endcsname{\the\@tempdima}%
  \setlength{\@tempdima}{\textwidth}%
  \addtolength{\@tempdima}{-\csname sls@#1width\endcsname}%
  \Ifstr{#2}{}{%
    \ifdim \csname sls@#1width\endcsname
         = \dimexpr \textwidth+\marginparwidth+\marginparsep\relax
      \setlength{\@tempdimb}{\z@}
    \else
      \if@twoside
        \setlength{\@tempdimb}{.3333333333\@tempdima}%
      \else
        \setlength{\@tempdimb}{.5\@tempdima}%
      \fi
    \fi
  }{%
    \sls@settowidthof{\@tempdimb}{#2}%
  }%
  \Ifstr{#3}{}{%
    \addtolength{\@tempdima}{-\@tempdimb}%
  }{%
    \sls@settowidthof{\@tempdima}{#3}%
    \setlength{\@tempdima}{-\@tempdima}%
  }%
  \ifdim\@tempdimb<\z@
    \setlength{\@tempdimb}{-\@tempdimb}%
    \expandafter\edef\csname sls@odd#1shift\endcsname{-\the\@tempdimb}%
  \else
    \expandafter\edef\csname sls@odd#1shift\endcsname{\the\@tempdimb}%
  \fi
  \ifdim\@tempdima<\z@
    \setlength{\@tempdima}{-\@tempdima}%
    \expandafter\edef\csname sls@even#1shift\endcsname{-\the\@tempdima}%
  \else
    \expandafter\edef\csname sls@even#1shift\endcsname{\the\@tempdima}%
  \fi
}%
%    \end{macrocode}
% \end{macro}^^A \sls@set@hf@width
% \begin{macro}{\sls@headwidth,\sls@oddheadshift,\sls@evenheadshift,
%               \sls@footwidth,\sls@oddfootshift,\sls@evenfootshift}
% To store width and offset of page head an footer, we use macros. Those are
% also used by the options and therefore need to be initialised before option
% usage.
%    \begin{macrocode}
\scr@ifundefinedorrelax{@headwidth}{%
  \newcommand*{\sls@headwidth}{\textwidth}%
  \KOMA@kav@add{.scrlayer-scrpage.sty}{headwidth}{\textwidth:0pt:0pt}%
}{%
  \newcommand*{\sls@headwidth}{\@headwidth}%
  \KOMA@kav@xadd{.scrlayer-scrpage.sty}{headwidth}{\@headwidth:0pt:0pt}%
}%
\newcommand*{\sls@oddheadshift}{0pt}
\newcommand*{\sls@evenheadshift}{0pt}
\scr@ifundefinedorrelax{@footwidth}{%
  \newcommand*{\sls@footwidth}{\textwidth}%
  \KOMA@kav@add{.scrlayer-scrpage.sty}{footwidth}{\textwidth:0pt:0pt}
}{%
  \newcommand*{\sls@footwidth}{\@footwidth}%
  \KOMA@kav@xadd{.scrlayer-scrpage.sty}{footwidth}{\@footwidth:0pt:0pt}
}%
\newcommand*{\sls@oddfootshift}{0pt}
\newcommand*{\sls@evenfootshift}{0pt}
%    \end{macrocode}
% \end{macro}^^A \sls@headwidth … \sls@evenfootshift
%
% \begin{macro}{\sls@settowidthof,\sls@deftowidthof}
% \changes{v3.28}{2019/11/18}{\cs{ifstr} renamed to \cs{Ifstr}}
% the special dimensional expressions may be either one of the strings
% \texttt{paper}, \texttt{text}, \texttt{marginpar},
% \texttt{textwithmarginpar}, \texttt{head}, \texttt{foot},
% \texttt{headtopline}, \texttt{headsepline}, \texttt{footsepline},
% \texttt{footbotline}, or \texttt{page} or a valid dimensional
% expression. But it cannot be both a dimensional expression using symbolic
% values!
%    \begin{macrocode}
\newcommand*{\sls@settowidthof}[2]{%
  \Ifstr{#2}{paper}{%
    \setlength{#1}{\paperwidth}%
  }{%
    \Ifstr{#2}{text}{%
      \setlength{#1}{\textwidth}%
    }{%
      \Ifstr{#2}{marginpar}{%
        \setlength{#1}{\dimexpr \marginparwidth+\marginparsep\relax}%
      }{%
        \Ifstr{#2}{textwithmarginpar}{%
          \setlength{#1}{\dimexpr\textwidth
                                +\marginparwidth
                                +\marginparsep\relax}%
        }{%
          \Ifstr{#2}{head}{%
            \setlength{#1}{\sls@headwidth}%
          }{%
            \Ifstr{#2}{foot}{%
              \setlength{#1}{\sls@footwidth}%
            }{%
              \Ifstr{#2}{headtopline}{%
                \setlength{#1}{\sls@headabove@linelength}%
              }{%
                \Ifstr{#2}{headsepline}{%
                  \setlength{#1}{\sls@headbelow@linelength}%
                }{%
                  \Ifstr{#2}{footsepline}{%
                    \setlength{#1}{\sls@footabove@linelength}%
                  }{%
                    \Ifstr{#2}{footbotline}{%
                      \setlength{#1}{\sls@footbelow@linelength}%
                    }{%
                      \Ifstr{#2}{page}{%
                        \setlength{#1}{\paperwidth}%
                        \begingroup
                        \expandafter\expandafter\expandafter\endgroup
                        \expandafter\ifx\csname ta@bcor\endcsname\relax\else
                          \addtolength{#1}{-\ta@bcor}%
                        \fi
                      }{%
                        \setlength{#1}{\dimexpr #2\relax}%
                      }%
                    }%
                  }%
                }%
              }%
            }%
          }%
        }%
      }%
    }%
  }%
}%
\newcommand*{\sls@deftowidthof}[2]{%
  \Ifstr{#2}{autohead}{%
    \expandafter\def\csname #1\endcsname{\sls@headwidth}%
  }{%
    \Ifstr{#2}{autofoot}{%
      \expandafter\def\csname #1\endcsname{\sls@footwidth}%
    }{%
      \sls@settowidthof{\@tempdima}{#2}%
      \expandafter\edef\csname #1\endcsname{\the\@tempdima}%
    }%
  }%
}%
%</options>
%    \end{macrocode}
% \end{macro}^^A \sls@deftowidthof,\sls@settowidthof
% \end{option}^^A footwidth
% \end{option}^^A footheight
%
% \begin{command}{\setheadwidth,\setfootwidth}
% \changes{v3.36}{2022/02/09}{warning about deprecated command}
% For compatibility with \pkg{scrpage2}, map the commands to the options:
%    \begin{macrocode}
%<*body>
\newcommand*{\setheadwidth}[2][]{%
  \PackageWarning{scrlayer-scrpage}{%
    Command `\string\setheadwidth' is deprecated.\MessageBreak
    I'm using \detokenize{\KOMAoptions{headwidth=#2:#1}} instead,\MessageBreak
    and so should you do}%
  \KOMAoptions{headwidth=#2:#1}%
}%
\newcommand*{\setfootwidth}[2][]{%
  \PackageWarning{scrlayer-scrpage}{%
    Command `\string\setfootwidth' is deprecated.\MessageBreak
    I'm using \detokenize{\KOMAoptions{footwidth=#2:#1}} instead,\MessageBreak
    and so should you do}%
  \KOMAoptions{footwidth=#2:#1}%
}%
%</body>
%    \end{macrocode}
% \end{command}^^A \setheadwidth,\setfootwidth
%
%
% \subsection{Lines in page head and footer}
%
% The interface implements the options \opt{headtopline}, \opt{headsepline},
% \opt{footsepline}, \opt{footbotline}, \opt{plainheadtopline},
% \opt{plainheadsepline}, \opt{plainfootsepline}, \opt{plainfootbotline},
% \opt{ilines}, \opt{clines}, and \opt{olines}, the commands
% \cs{setheadtopline}, \cs{setheadsepline}, \cs{setfootsepline}, and
% \cs{setfootbotline}, and the corresponding \KOMAScript{} font elements of
% package \pkg{scrpage2}. Some of the options are extended to understand
% values.
%
% \begin{option}{headtopline,headsepline,footsepline,footbotline}
% \changes{v3.17}{2015/02/25}{new: store the values}
% \begin{description}
% \item[{\texttt{=\meta{dimensional expression}:\meta{dimensional
%   expression}}:}]
% \end{description}\noindent
% Define thickness and length of the a default separation line between:
% \begin{description}
% \item[\opt{headtopline}:] the top margin of the page and the page head.
% \item[\opt{headsepline}:] the page head and the text area.
% \item[\opt{footsepline}:] the text area and the page footer.
% \item[\opt{footbotline}:] the page footer and the bottom margin.
% \end{description}
% Both \meta{dimensional expression} values may be omitted. In that case
% thickness would be 0.4\,pt, and length would be the width of the page head
% or footer.  If the second argument, the length, has been omitted the
% \texttt{:} may also be omitted.
%    \begin{macrocode}
%<*options>
\KOMA@key{headtopline}[:]{%
  \sls@set@values[headtopline]{head}{above}{#1}%
}
\KOMA@key{headsepline}[:]{%
  \sls@set@values[headsepline]{head}{below}{#1}%
}
\KOMA@key{footsepline}[:]{%
  \sls@set@values[footsepline]{foot}{above}{#1}%
}
\KOMA@key{footbotline}[:]{%
  \sls@set@values[footbotline]{foot}{below}{#1}%
}
%    \end{macrocode}
% \begin{macro}{\sls@set@values}
% \changes{v3.28}{2019/11/18}{\cs{ifstr} renamed to \cs{Ifstr}}
% \begin{description}
% \item[\oarg{option name}:] either empty or the name of the option that sets
%   the line,
% \item[\marg{head or foot}:] either \texttt{head} or \texttt{foot},
% \item[\marg{above or below}:] either \texttt{above} or \texttt{below},
% \item[\mmarg{dimension expression}{dimension expression}:] length an
%   thickness of a line (both are optional).
% \end{description}
% Helper macros for the options to set two macros by two values of one
% option. The two values are separated by a colon.
%    \begin{macrocode}
\newcommand*{\sls@set@values}[4][]{%
  \begingroup
    \Ifstr{#1}{}{%
      \FamilyKeyStateUnknown
    }{%
      \KOMA@set@ifkey{#1}{@tempswa}{#4}%
    }%
    \ifx\FamilyKeyState\FamilyKeyStateProcessed
      \if@tempswa
        \edef\reserved@b{%
          \noexpand\endgroup
          \noexpand\@namedef{sls@#2#3@linethickness}{.4pt}%
          \noexpand\@namedef{sls@#2#3@linelength}{%
            \expandafter\noexpand\csname sls@#2width\endcsname
          }%
        }%
      \else
        \def\reserved@b{%
          \endgroup
          \@namedef{sls@#2#3@linethickness}{0pt}%
          \@namedef{sls@#2#3@linelength}{0pt}%
        }%
      \fi
    \else
      \let\reserved@a\@empty
      \let\reserved@b\@empty
      \sls@split@at@colon#4::\@nil
      \ifx\reserved@a\@empty
        \def\reserved@a{\endgroup\@namedef{sls@#2#3@linethickness}{.4pt}}%
      \else
        \setlength{\@tempdima}{\dimexpr\reserved@a\relax}%
        \edef\reserved@a{%
          \noexpand\endgroup
          \noexpand\@namedef{sls@#2#3@linethickness}{\the\@tempdima}%
        }%
      \fi
      \ifx\reserved@b\@empty
        \def\reserved@b{%
          \reserved@a
          \@namedef{sls@#2#3@linelength}{\@nameuse{sls@#2width}}%
        }%
      \else
        \edef\reserved@b{%
          \noexpand\reserved@a
          \noexpand\sls@deftowidthof{sls@#2#3@linelength}{\reserved@b}%
        }%
      \fi
    \fi
  \reserved@b
  \FamilyKeyStateProcessed
  \Ifstr{#1}{}{}{%
    \KOMA@kav@xreplacevalue{.scrlayer-scrpage.sty}{#1}{%
      \csname sls@#2#3@linethickness\endcsname
      :\csname sls@#2#3@linelength\endcsname
    }%
  }%
}%
%    \end{macrocode}
% \end{macro}^^A \sls@set@values
% \begin{macro}{\sls@split@at@colon}
% \changes{v3.28}{2019/11/18}{\cs{ifstr} renamed to \cs{Ifstr}}
% \begin{description}
% \item[\texttt{\meta{balanced}:\meta{balanced}:\meta{balanced}\cs{@nil}}:]
%   first \meta{balanced} will be stored into \cs{reserved@a}, second into
%   \cs{reserved@b}, third will be eaten and warn about if it is neither empty
%   and nor a colon.
% \end{description}
% This little helper is used, e.g., by options \opt{headwidth} and
% \opt{footwidth}.
%    \begin{macrocode}
\newcommand*{\sls@split@at@colon}{}
\def\sls@split@at@colon#1:#2:#3\@nil{%
  \Ifstr{#3}{}{}{%
    \Ifstr{#3}{:}{}{%
      \PackageWarning{scrlayer}{extra `:' found!\MessageBreak
        You've used more than one colon at the argument\MessageBreak
        of a two value option.\MessageBreak
        The extra value(s) will be ignored%
      }%
    }%
  }%
  \def\reserved@a{#1}%
  \def\reserved@b{#2}%
}%
%    \end{macrocode}
% \end{macro}^^A \sls@split@at@colon
% \begin{macro}{\sls@headabove@linelength,\sls@headabove@linethickness,
%               \sls@headbelow@linelength,\sls@headbelow@linethickness,
%               \sls@footabove@linelength,\sls@footabove@linethickness,
%               \sls@footbelow@linelength,\sls@footbelow@linethickness}
% To store length and thickness of the lines at the page head an footer, we
% use macros. Those are also used by the options and therefore need to be
% initialised before option usage.
%    \begin{macrocode}
\newcommand*{\sls@headabove@linelength}{\sls@headwidth}%
\newcommand*{\sls@headabove@linethickness}{0pt}%
\KOMA@kav@xadd{.scrlayer-scrpage.sty}{headtopline}{%
  \expandafter\noexpand\sls@headabove@linethickness:%
  \expandafter\noexpand\sls@headabove@linelength
}
\newcommand*{\sls@headbelow@linelength}{\sls@headwidth}%
\newcommand*{\sls@headbelow@linethickness}{0pt}%
\KOMA@kav@xadd{.scrlayer-scrpage.sty}{headsepline}{%
  \expandafter\noexpand\sls@headbelow@linethickness:%
  \expandafter\noexpand\sls@headbelow@linelength
}
\newcommand*{\sls@footabove@linelength}{\sls@footwidth}%
\newcommand*{\sls@footabove@linethickness}{0pt}%
\KOMA@kav@xadd{.scrlayer-scrpage.sty}{footsepline}{%
  \expandafter\noexpand\sls@footabove@linethickness:%
  \expandafter\noexpand\sls@footabove@linelength
}
\newcommand*{\sls@footbelow@linelength}{\sls@footwidth}%
\newcommand*{\sls@footbelow@linethickness}{0pt}%
\KOMA@kav@xadd{.scrlayer-scrpage.sty}{footbotline}{%
  \expandafter\noexpand\sls@footbelow@linethickness:%
  \expandafter\noexpand\sls@footbelow@linelength
}
%</options>
%    \end{macrocode}
% \end{macro}^^A \sls@headabove@linelength … \sls@footbelow@linethickness
% \end{option}^^A headtopline … footbotline
%
% \begin{option}{plainheadtopline,plainheadsepline,
%                plainfootsepline,plainfootbotline}
% \begin{macro}{\ifsls@plain@head@above@line,\sls@plain@head@above@linetrue,
%               \sls@plain@head@above@linefalse,
%               \ifsls@plain@head@below@line,\sls@plain@head@below@linetrue,
%               \sls@plain@head@below@linefalse,
%               \ifsls@plain@foot@above@line,\sls@plain@foot@above@linetrue,
%               \sls@plain@foot@above@linefalse,
%               \ifsls@plain@foot@below@line,\sls@plain@foot@below@linetrue,
%               \sls@plain@foot@below@linefalse}
% \begin{description}
% \item[\texttt{=\meta{switch value}}:]
% \end{description}\noindent
% While these only switches the rule on or off, we need only some switches.
%    \begin{macrocode}
%<*options>
\KOMA@ifkey{plainheadtopline}{sls@plain@head@above@line}%
\KOMA@ifkey{plainheadsepline}{sls@plain@head@below@line}%
\KOMA@ifkey{plainfootsepline}{sls@plain@foot@above@line}%
\KOMA@ifkey{plainfootbotline}{sls@plain@foot@below@line}%
%</options>
%    \end{macrocode}
% \end{macro}^^A \ifsls@plain@foot@below@line … \sls@plain@foot@below@linefalse
% \end{option}^^A plainheadtopline … plainfootbotline
%
% \begin{option}{ilines,clines,olines}
% \changes{v3.17}{2015/02/25}{storing values}
% \begin{macro}{\sls@hfline@adjust}
% Maybe it would be more useful to be able to adjust each line on its own or
% at most to define an offset. But \pkg{scrpage2} supports only these
% options. At least we can set the options inside a layer or page style. This
% may help.
%    \begin{macrocode}
%<*options>
\newcommand*{\sls@hfline@adjust}{0}%
\KOMA@kav@add{.scrlayer-scrpage.sty}{ilines}{}
\KOMA@key{ilines}[]{%
  \ifx\relax#1\relax
    \renewcommand*{\sls@hfline@adjust}{0}%
    \FamilyKeyStateProcessed
    \KOMA@kav@removekey{.scrlayer-scrpage.sty}{ilines}%
    \KOMA@kav@removekey{.scrlayer-scrpage.sty}{clines}%
    \KOMA@kav@removekey{.scrlayer-scrpage.sty}{olines}%
    \KOMA@kav@add{.scrlayer-scrpage.sty}{ilines}{}%
  \else
    \def\FamilyKeyStateProcessed{unexpected value}%
  \fi
}
\KOMA@key{clines}[]{%
  \ifx\relax#1\relax
    \renewcommand*{\sls@hfline@adjust}{1}%
    \FamilyKeyStateProcessed
    \KOMA@kav@removekey{.scrlayer-scrpage.sty}{ilines}%
    \KOMA@kav@removekey{.scrlayer-scrpage.sty}{clines}%
    \KOMA@kav@removekey{.scrlayer-scrpage.sty}{olines}%
    \KOMA@kav@add{.scrlayer-scrpage.sty}{clines}{}%
  \else
    \def\FamilyKeyStateProcessed{unexpected value}%
  \fi
}
\KOMA@key{olines}[]{%
  \ifx\relax#1\relax
    \renewcommand*{\sls@hfline@adjust}{2}%
    \FamilyKeyStateProcessed
    \KOMA@kav@removekey{.scrlayer-scrpage.sty}{ilines}%
    \KOMA@kav@removekey{.scrlayer-scrpage.sty}{clines}%
    \KOMA@kav@removekey{.scrlayer-scrpage.sty}{olines}%
    \KOMA@kav@add{.scrlayer-scrpage.sty}{olines}{}%
  \else
    \def\FamilyKeyStateProcessed{unexpected value}%
  \fi
}
\KOMA@kav@add{.scrlayer-scrpage.sty}{ilines}{}
%</options>
%    \end{macrocode}
% \end{macro}^^A \sls@hfline@adjust
% \end{option}^^A ilines … olines
%
% \begin{command}{\setheadtopline,\setheadsepline,
%                 \setfootsepline,\setfootbotline}
% \begin{description}
% \item[\oarg{extended dimensional expression}:] the length of the line; if
%   omitted the length will use the width of the page head or footer while
%   printing the line.
% \item[\marg{dimensional expression}:] the thickness of the line.
% \item[\oarg{code}:] the font selection code for the line. You may use it for
%   any kind of operation, that doesn't change the position, width, height, or
%   depth, e.g., to change the colour of the line.
% \end{description}
%    \begin{macrocode}
%<*body>
\newcommand*{\setheadtopline}{\sls@setline{head}{above}}%
\newcommand*{\setheadsepline}{\sls@setline{head}{below}}%
\newcommand*{\setfootsepline}{\sls@setline{foot}{above}}%
\newcommand*{\setfootbotline}{\sls@setline{foot}{below}}%
%    \end{macrocode}
% \begin{macro}{\sls@setline}
% \changes{v3.20}{2016/04/12}{\cs{@ifnextchar} replaced by
%   \cs{kernel@ifnextchar}}
% \begin{macro}{\sls@@setline}
% \changes{v3.28}{2019/11/18}{\cs{ifstr} renamed to \cs{Ifstr}}
% \begin{macro}{\sls@@@setline}
% \changes{v3.17}[2015/02/27]{internal use of the corresponding options}
% \changes{v3.20}{2016/04/12}{\cs{@ifnextchar} replaced by
%   \cs{kernel@ifnextchar}}
% \changes{v3.28}{2019/11/18}{\cs{ifstr} renamed to \cs{Ifstr}}
% \begin{macro}{\sls@@@@setline}
% \changes{v3.18}{2015/06/17}{explicit reuse of the current length}
% \changes{v3.28}{2019/11/18}{\cs{ifstr} renamed to \cs{Ifstr}}
% Helper to set up the line attributes processing the parameters of the
% commands above.
%    \begin{macrocode}
\newcommand*\sls@setline[2]{%
  \kernel@ifnextchar[%]
  {\sls@@setline{#1}{#2}}{\sls@@@setline{#1#2}}%
}%
\newcommand*{\sls@@setline}{}
\def\sls@@setline#1#2[#3]{%
  \Ifstr{#3}{auto}{%
    \sls@deftowidthof{sls@#1#2@linelength}{#3#1}%
  }{%
    \sls@deftowidthof{sls@#1#2@linelength}{#3}%
  }%
  \sls@@@setline{#1#2}%
}%
\newcommand*{\sls@@@setline}[2]{%
  \edef\@tempa{#2}\edef\@tempb{current}%
  \Ifstr{#2}{}{}{%
    \Ifstr{#2}{current}{}{%
      \setlength{\@tempdima}{#2}%
      \Ifstr{#1}{headabove}{%
        \KOMAExecuteOptions[.scrlayer-scrpage.sty]%
          {headtopline=\@tempdima:\csname sls@#1@linelength\endcsname}%
      }{\Ifstr{#1}{headbelow}{%
          \KOMAExecuteOptions[.scrlayer-scrpage.sty]%
            {headsepline=\@tempdima:\csname sls@#1@linelength\endcsname}%
        }{%
          \Ifstr{#1}{footabove}{%
            \KOMAExecuteOptions[.scrlayer-scrpage.sty]%
              {footsepline=\@tempdima:\csname sls@#1@linelength\endcsname}%
          }{%
            \KOMAExecuteOptions[.scrlayer-scrpage.sty]%
              {footbotline=\@tempdima:\csname sls@#1@linelength\endcsname}%
          }%
        }%
      }%
    }%
  }%
  \PackageWarning{scrlayer-scrpage}{%
    Command deprecated!\MessageBreak
    Usage of `\string\setheadtopline',
    `\string\setheadsepline',\MessageBreak
    `\string\setfootsepline', and `\string\setfootbotline'\MessageBreak
    became deprecated with scrlayer-scrpage.\MessageBreak
    You should use KOMA-Script options\MessageBreak
    `headsepline', `headtopline', `footsepline',\MessageBreak
    or `footbotline' with values\MessageBreak
    `<line thickness>:<line length>' to setup\MessageBreak
    the line length and thickness, and\MessageBreak
    `\string\setkomafont' or `\string\addtokomafont' to\MessageBreak
    setup the colour%
  }%
  \kernel@ifnextchar[%]
  {%
    \sls@@@@setline{#1}%
  }{%
  }%
}%
\newcommand*{\sls@@@@setline}{}
\def\sls@@@@setline#1[#2]{%
  \Ifstr{#1}{headabove}{\setkomafont{headtopline}{#2}}{%
    \Ifstr{#1}{headbelow}{\setkomafont{headsepline}{#2}}{%
      \Ifstr{#1}{footabove}{\setkomafont{footsepline}{#2}}{%
        \setkomafont{footbotline}{#2}%
      }%
    }%
  }%
}%
%    \end{macrocode}
% \end{macro}^^A \sls@setline
% \end{macro}^^A \sls@@setline
% \end{macro}^^A \sls@@@setline
% \end{macro}^^A \sls@@@@setline
% \begin{fontelement}{headtopline,headsepline,footsepline,footbotline}
% These are the font elements used in \cs{sls@hf@rule} to set the rules
% with, i.e., another colour. Note, that those may already be defined and
% become only part of the interface if they are not.
%    \begin{macrocode}
\@ifundefined{scr@fnt@headtopline}{%
  \newkomafont{headtopline}{}%
}{}
\@ifundefined{scr@fnt@headsepline}{%
  \newkomafont{headsepline}{}%
}{}
\@ifundefined{scr@fnt@footsepline}{%
  \newkomafont{footsepline}{}%
}{}
\@ifundefined{scr@fnt@footbotline}{%
  \newkomafont{footbotline}{}%
}{}
%</body>
%    \end{macrocode}
% \end{fontelement}^^A headtopline … footbotline
% \end{command}^^A \setheadtopline … \setfootbotline
%
% \begin{length}{\headheight,\footheight}
% \changes{v3.24}{2017/05/22}{warning depends on option \opt{singlespacing}}
% Some classes set \len{headheight} to a very, very small value. We'll
% warn about that.
% \changes{v3.24}{2017/05/23}{also warn for low \cs{footheight}}
% If the \len{headheight} is OK, we also test for \len{footheight}.
%    \begin{macrocode}
%<*body>
\AtBeginDocument{%
  \ifdim \headheight
         <\if@ps@singlespacing\f@baselineskip\else\baselineskip\fi\relax
    \PackageWarningNoLine{scrlayer-scrpage}{Very small head height
      detected!\MessageBreak
      Using scrlayer-scrpage the head height\MessageBreak
      should be at least \string\baselineskip, which is\MessageBreak
      \if@ps@singlespacing\f@baselineskip\else\the\baselineskip\fi\space 
      currently.\MessageBreak
      But head height is currently
      \the\headheight\space only.\MessageBreak
      You may use\MessageBreak
      \@ifpackageloaded{geometry}{%
        geometry option 
        `head=\if@ps@singlespacing\f@baselineskip\else\the\baselineskip\fi'%
      }{%
        \@ifpackageloaded{typearea}{%
          typearea option `headheight=%
          \if@ps@singlespacing\f@baselineskip\else\the\baselineskip\fi'%
        }{%
          \string\setlength{\string\headheight}%
          {\if@ps@singlespacing\f@baselineskip\else\the\baselineskip\fi}%
        }%
      }\MessageBreak
      \if@ps@singlespacing\else\ifdim \headheight<\f@baselineskip\else
        or load package `scrlayer-scrpage' with\MessageBreak
        option `singlespacing=true'\MessageBreak
      \fi\fi
      to avoid this warning%
    }%
  \else
    \ifdim \footheight
           <\if@ps@singlespacing\f@baselineskip\else\baselineskip\fi\relax
      \PackageWarningNoLine{scrlayer-scrpage}{Very small foot height
        detected!\MessageBreak
        Using scrlayer-scrpage the foot height\MessageBreak
        should be at least \string\baselineskip, which is\MessageBreak
        \if@ps@singlespacing\f@baselineskip\else\the\baselineskip\fi\space 
        currently.\MessageBreak
        But foot height is currently
        \the\footheight\space only.\MessageBreak
        You may use\MessageBreak
        \@ifpackageloaded{typearea}{%
          typearea option `footheight=%
          \if@ps@singlespacing\f@baselineskip\else\the\baselineskip\fi'%
        }{%
          \string\setlength{\string\footheight}%
          {\if@ps@singlespacing\f@baselineskip\else\the\baselineskip\fi}%
        }%
        \MessageBreak
        \if@ps@singlespacing\else\ifdim \footheight<\f@baselineskip\else
          or load package `scrlayer-scrpage' with\MessageBreak
          option `singlespacing=true'\MessageBreak
        \fi\fi
        to avoid this warning%
      }%
    \fi
  \fi
}
%</body>
%    \end{macrocode}
% \end{length}^^A \headheight,\footheight
%
%
% \subsection{Usual \LaTeX{} kernel commands}
%
% \pkg*{scrlayer-scrpage} uses some very usual \LaTeX{} kernel commands, that
% should really behave like the original \LaTeX{} kernel commands do. But some
% packages redefine them without restoring them in the output routine before
% the page head and foot is build. Such a redefinition could break
% \pkg*{scrlayer-scrpage} or even provoke errors. Here we try to make sure,
% that \pkg*{scrlayer-scrpage} uses the correct definitions. Note: This should
% not be needed, if other packages would be more careful.
%
% \begin{command}{\LaTeXcentering,\LaTeXraggedright,\LaTeXraggedleft}
% \changes{v3.27}{2019/04/05}{added}
% \pkg*{scrlayer-scrpage} needs \cs{centering} to center, \cs{raggedright}
% to left align and \cs{raggedleft} to right align the three elements of
% three-part header and footer. \pkg{ragged2e} optionally redefines them. This
% is not perfect but does not break \pkg*{scrlayer-scrpage} completely. But
% \pkg{tabu}\footnote{Note, package \pkg{tabu} is not officially maintained by
%   anyone for several years. Unofficially some members of The \LaTeX{} Team
%   fix some problems related to new \LaTeX{} kernel changes. But the package
%   is without support for all other problems, even if they are known for
%   years. But you have to decide yourself, whether it is a good idea to use
%   such packages.} also redefines them an that breaks \pkg*{scrlayer-scrpage}
% in a way, that even error messages can occur. So from version~3.27
% \pkg*{scrlayer-scrpage} does not longer use \cs{centering}, \cs{raggedright}
% or \cs{raggedleft} but \cs{LaTeXcentering}, \cs{LaTeXraggedright} and
% \cs{LaTeXraggedleft}. With \pkg{ragged2e} and its option
% \opt{newcommands}/\opt{NewCommands} this would be already defined and
% contain the original definition. On all other circumstances the commands
% have to be defined. But these commands should not be defined as part of the
% interface or removing the interface could break other packages like
% \pkg{ragged2e}.
%    \begin{macrocode}
%<*body>
\@ifundefined{LaTeXcentering}{\let\LaTeXcentering\centering}{}
\@ifundefined{LaTeXraggedleft}{\let\LaTeXraggedleft\raggedleft}{}
\@ifundefined{LaTeXraggedright}{\let\LaTeXraggedright\raggedright}{}
%</body>
%    \end{macrocode}
% \end{command}^^A \LaTeXcentering … \LaTeXraggedright
%
%
% \subsection{Style of running heads}
%
% This implements not only options \opt{komastyle} and \opt{standardstyle} of
% \pkg{scrpage2}, but also activates the default style at the end of the
% package and takes care for the correct behave of option \opt{markcase}.
%
% \begin{option}{pagestyleset}
% \begin{description}
% \item[\texttt{=\meta{string}}:] a valid name of a predefined
%   style-set. Currently only \optvalue{KOMA-Script} and \optvalue{standard}
%   are supported. Maybe more will follow.
% \end{description}
% Note, that the following automatic style activation must be before the
% first option usage:
%    \begin{macrocode}
%<*init>
\AtEndOfPackage{%
  \sls@auto@pagestyleset%
}
%    \end{macrocode}
% \begin{macro}{\sls@auto@pagestyleset}
% \changes{v0.9}{2014/01/22}{added}
%    \begin{macrocode}
\newcommand*{\sls@auto@pagestyleset}{%
  \scr@ifundefinedorrelax{KOMAClassName}{%
%<trace>    \PackageInfoNoLine{scrlayer-scrpage}{%
%<trace>      auto-selection of `pagestyleset=standard'}%
    \FamilyExecuteOptions[.scrlayer-scrpage.sty]{KOMA}{pagestyleset=standard}%
  }{%
%<trace>    \PackageInfoNoLine{scrlayer-scrpage}{%
%<trace>      auto-selection of `pagestyleset=KOMA-Script'}%
    \FamilyExecuteOptions[.scrlayer-scrpage.sty]{KOMA}%
    {pagestyleset=KOMA-Script}%
  }%
}
%</init>
%    \end{macrocode}
% \end{macro}^^A \sls@auto@pagestyleset
% \changes{v3.17}{2015/02/25}{storing the values}
%    \begin{macrocode}
%<*options>
\KOMA@key{pagestyleset}{%
  \scr@ifundefinedorrelax{sls@ps@style@#1}{%
    \FamilyKeyStateUnknownValue
  }{%
    \let\sls@auto@pagestyleset\relax
    \@nameuse{sls@ps@style@#1}%
    \FamilyKeyStateProcessed
    \KOMA@kav@replacevalue{.scrlayer-scrpage.sty}{pagestyleset}{#1}%
  }%
}
%    \end{macrocode}
% \begin{macro}{\sls@ps@style@standard,\sls@ps@style@KOMA-Script}
% \changes{v3.28}{2019/11/18}{\cs{ifstr} renamed to \cs{Ifstr}}
% These are the predefined page style sets.
%    \begin{macrocode}
\newcommand*{\sls@ps@style@standard}{%
  \let\MakeMarkcase\MakeUppercase
  \scrlayer@AtEndOfPackage{%
    \pagestyle{scrheadings}%
    \clearpairofpagestyles
    \ihead{\headmark}%
    \ohead{\pagemark}%
    \cfoot[\if@twoside\else\pagemark\fi]{}%
  }%
}%
\expandafter\newcommand\expandafter*\csname sls@ps@style@KOMA-Script\endcsname{%
  \let\MakeMarkcase\@firstofone
  \scrlayer@AtEndOfPackage{%
    \pagestyle{scrheadings}%
    \clearpairofpagestyles
    \ohead{\if@twoside\headmark\fi}%
    \chead{\if@twoside\else\headmark\fi}%
    \ofoot[\if@twoside\pagemark\fi]{\if@twoside\pagemark\fi}%
    \cfoot[\if@twoside\else\pagemark\fi]{\if@twoside\else\pagemark\fi}%
    \scr@ifundefinedorrelax{KOMAClassName}{}{%
      \Ifstr{\KOMAClassName}{scrlttr2}{%
%    \end{macrocode}
% We are using \cls*{scrlttr2}, so we have to initialise the page style
% different:
% \changes{v3.18}{2015/06/24}{missing \cs{lofoot} and \cs{rofoot} added}
%    \begin{macrocode}
        \clearpairofpagestyles
        \lehead[\ifnum\@pageat=\z@\pagemark\fi]
               {\ifnum\@pageat=\z@\pagemark\else\leftmark\fi}%
        \lohead[\ifnum\@pageat=\z@\pagemark\fi]
               {\ifnum\@pageat=\z@\pagemark\else\leftmark\fi}%
        \chead[\ifnum\@pageat=\@ne\pagemark\fi]
              {\ifcase\@pageat \rightmark\or \pagemark\or \rightmark\fi}%
        \rehead[\ifnum\@pageat=\tw@\pagemark\fi]
               {\ifcase\@pageat \leftmark\or \rightmark\or \pagemark
                 \else \rightmark\fi}%
        \rohead[\ifnum\@pageat=\tw@\pagemark\fi]
               {\ifcase\@pageat \leftmark\or \rightmark\or \pagemark
                 \else \rightmark\fi}%
        \lefoot[\ifnum\@pageat=\thr@@\pagemark\fi]
               {\ifnum\@pageat=\thr@@\pagemark\fi}%
        \lofoot[\ifnum\@pageat=\thr@@\pagemark\fi]
               {\ifnum\@pageat=\thr@@\pagemark\fi}%
        \cfoot[\ifnum\@pageat=4 \pagemark\fi]
              {\ifnum\@pageat=4 \pagemark\fi}%
        \refoot[\ifnum\@pageat=5 \pagemark\fi]
               {\ifnum\@pageat=5 \pagemark\fi}%
        \rofoot[\ifnum\@pageat=5 \pagemark\fi]
               {\ifnum\@pageat=5 \pagemark\fi}%
      }{}%
    }%
  }%
}%
%</options>
%    \end{macrocode}
% \end{macro}^^A \sls@ps@style@standard,\sls@ps@style@KOMA-Script
% \end{option}^^A pagestyleset
%
% \begin{option}{komastyle,standardstyle}
% These options are deprecated, but defined for compatibility with
% \pkg{scrpage2}:
%    \begin{macrocode}
%<*options>
\KOMA@DeclareDeprecatedOption[scrlayer-scrpage]{komastyle}{%
  pagestyleset=KOMA-Script}
\KOMA@DeclareDeprecatedOption[scrlayer-scrpage]{standardstyle}{%
  pagestyleset=standard}
%</options>
%    \end{macrocode}
% \end{option}^^A komastyle,standardstyle
%
%
% \subsection{Extended mark mechanisms}
%
% Package options \opt{markuppercase}, \opt{markusedcase}, and
% \opt{nouppercase} of package \pkg{scrpage2} are mapped to \KOMAScript{}
% option \opt{markcase}.
%
% \begin{option}{markuppercase,markusedcase,nouppercase}
% For compatibility with \pkg{scrpage2}.
%    \begin{macrocode}
%<*options>
\KOMA@DeclareDeprecatedOption[scrlayer-scrpage]{markuppercase}{markcase=upper}
\KOMA@DeclareDeprecatedOption[scrlayer-scrpage]{markusedcase}{markcase=used}
\KOMA@DeclareDeprecatedOption[scrlayer-scrpage]{nouppercase}{%
  markcase=ignoreuppercase%
}
%</options>
%    \end{macrocode}
% \end{option}^^A markuppercase … nouppercase
%
%
% \subsection{Expert page style definition interface}
%
% This is the low level interface of \pkg{scrpage2} with \cs{defpagestyle},
% \cs{newpagestyle}, \cs{renewpagestyle}, and \cs{providepagestyle}. We will
% also define is. In difference to \pkg{scrpage2} layers are used. Following
% layers will be defined for each page style:
% \begin{description}
% \item[\texttt{\meta{page style name}.head.above.line}] line above the head
% \item[\texttt{\meta{page style name}.head.odd}] odd page head (only twoside)
% \item[\texttt{\meta{page style name}.head.even}] even page head (only
%   twoside)
% \item[\texttt{\meta{page style name}.head.oneside}] single-side head (only
%   oneside)
% \item[\texttt{\meta{page style name}.head.below}] line below the head
% \item[\texttt{\meta{page style name}.foot.above.line}] line above the footer
% \item[\texttt{\meta{page style name}.foot.odd}] odd page footer (only
%   twoside)
% \item[\texttt{\meta{page style name}.foot.even}] even side footer (only
%   twoside)
% \item[\texttt{\meta{page style name}.foot.oneside}] single-side footer (only
%   oneside)
% \item[\texttt{\meta{page style name}.foot.below.line}] line below the footer
%   (only oneside)
% \end{description}
% Note: \pkg{scrpage2} also provided star versions of the page style
% definition commands, doing the same like the starless versions. This has
% been done for compatibility reasons with deprecated
% \pkg[https://www.ctan.org/pkg/koma-script-obsolete]{scrpage} and has been
% described as to be removed some times. The layer interface doesn't support
% this any longer.
%
%
% \begin{command}{\defpagestyle}
% \changes{v3.28}{2019/11/18}{\cs{ifstr} renamed to \cs{Ifstr}}
% \begin{description}
% \item[\marg{string}:] the name of the page style to be defined (must be
%   fully expandable and expand to a string only).
% \item[\marg{head/foot definition}:] will be used to define the head (see
%   \cs{sls@defhead}).
% \item[\marg{head/foot definition}:] will be used to define the foot (see
%   \cs{sls@deffoot}).
% \end{description}
%    \begin{macrocode}
%<*body>
\newcommand*{\defpagestyle}[3]{%
  \sls@defhead{#1}#2\@empty\@empty\@empty
  \sls@deffoot{#1}#3\@empty\@empty\@empty 
  \DeclarePageStyleByLayers{#1}{%
    #1.head.odd,#1.head.even,#1.head.oneside,%
    #1.head.above.line,#1.head.below.line,%
    #1.foot.odd,#1.foot.even,#1.foot.oneside,%
    #1.foot.above.line,#1.foot.below.line%
  }%
}%
%    \end{macrocode}
% \begin{macro}{\sls@defhead,\sls@@defhead}
% \changes{v3.20}{2016/04/12}{\cs{@ifnextchar} replaced by
%   \cs{kernel@ifnextchar}}
% \begin{macro}{\sls@@@defhead}
% \changes{v0.9}{2014/08/18}{fixed names of layers \texttt{\dots head.odd} and
%   \texttt{\dots head.even}}
% \begin{description}
% \item[\pparg{dimensional expression}{dimensional expression}:] length and
%   thickness of a line (ruler) above the page head. May be omitted and if so
%   the values from option \opt{headtopline} will be used.
% \item[\marg{code}:] will be executed on even pages; used to define the
%   contents of layer \texttt{\meta{page style name}.head.even}.
% \item[\marg{code}:] will be executed on odd pages within two-side layout;
%   used to define the contents of layer \texttt{\meta{page style
%   name}.head.odd}.
% \item[\marg{code}:] will be executed on single-side pages; used to define
%   the contents of layer \texttt{\meta{page style name}.head.oneside}.
% \item[\pparg{dimensional expression}{dimensional expression}:] length and
%   thickness of a line (ruler) below the page head. May be omitted and if so
%   the values from option \opt{headsepline} will be used.
% \end{description}
% Helper to define the head layers.
%    \begin{macrocode}
\newcommand*\sls@defhead[1]{%
  \kernel@ifnextchar(%)
  {\sls@@defhead{#1}}%
  {\sls@@defhead{#1}(\sls@headabove@linelength,\sls@headabove@linethickness)}%
}%
\newcommand*{\sls@@defhead}{}
\def\sls@@defhead#1(#2,#3)#4#5#6{%
  \kernel@ifnextchar(%)
  {\sls@@@defhead{#1}({#2},{#3}){#4}{#5}{#6}}%
  {\sls@@@defhead{#1}%
                 ({#2},{#3})%
                 {#4}{#5}{#6}%
                 (\sls@headbelow@linelength,\sls@headbelow@linethickness)}%
}%
\newcommand*{\sls@@@defhead}{}
\def\sls@@@defhead#1(#2,#3)#4#5#6(#7,#8){%
%    \end{macrocode}
% The lines:
%    \begin{macrocode}
  \DeclareLayer[%
    background,%
    hoffset=\sls@leftmargin{head},%
    voffset=\sls@topmargin+\dp\strutbox,%
    width=\sls@headwidth,%
    height=0pt,%
    align=bl,%
    contents={%
      {\normalfont\usekomafont{pageheadfoot}{\usekomafont{pagehead}{%
            \sls@hf@rule{headtop}{#2}{#3}}}}%
    }%
  ]{#1.head.above.line}%
  \DeclareLayer[%
    background,%
    hoffset=\sls@leftmargin{head},%
    voffset=\sls@topmargin+\headheight-\ht\strutbox+#8,%
    width=\sls@headwidth,%
    height=0pt,%
    align=tl,%
    contents={%
      {\normalfont\usekomafont{pageheadfoot}{\usekomafont{pagehead}{%
            \sls@hf@rule{headsep}{#7}{#8}}}}%
    }%
  ]{#1.head.below.line}%
%    \end{macrocode}
% The odd side, even side and one side:
% \changes{v3.13b}{2014/10/16}{workaround: additional group added to avoid
%   pdf\TeX{} color stack warnings}
%    \begin{macrocode}
  \DeclareLayer[%
    background,evenpage,twoside,%
    head,%
    hoffset=\sls@leftmargin{head},%
    width=\sls@headwidth,%
    contents={%
      \sls@secure@box\headheight{%
        \normalfont{\usekomafont{pageheadfoot}{\usekomafont{pagehead}{#4}}}}}%
  ]{#1.head.even}%
  \DeclareLayer[%
    background,oddpage,twoside,%
    head,%
    hoffset=\sls@leftmargin{head},%
    width=\sls@headwidth,%
    contents={%
      \sls@secure@box\headheight{%
        \normalfont{\usekomafont{pageheadfoot}{\usekomafont{pagehead}{#5}}}}}%
  ]{#1.head.odd}%
  \DeclareLayer[%
    background,oddpage,oneside,%
    head,%
    hoffset=\sls@leftmargin{head},%
    width=\sls@headwidth,%
    contents={%
      \sls@secure@box\headheight{%
        \normalfont{\usekomafont{pageheadfoot}{\usekomafont{pagehead}{#6}}}}}%
  ]{#1.head.oneside}%
}%
%    \end{macrocode}
% \begin{macro}{\sls@deffoot,\sls@@deffoot}
% \changes{v3.20}{2016/04/12}{\cs{@ifnextchar} replaced by
%   \cs{kernel@ifnextchar}}
% \begin{macro}{\sls@@@deffoot}
% \changes{v0.9}{2014/08/18}{fixed names of layers \texttt{\dots foot.odd} and
%   \texttt{\dots foot.even}}
% \begin{description}
% \item[\pparg{dimensional expression}{dimensional expression}:] length and
%   thickness of a line (ruler) above the page footer. May be omitted and if
%   so the values from option \opt{footsepline} will be used.
% \item[\marg{code}:] will be executed on even pages; used to define the
%   contents of layer \texttt{\meta{page style name}.foot.even}.
% \item[\marg{code}:] will be executed on odd pages within two-side layout;
%   used to define the contents of layer \texttt{\meta{page style
%   name}.foot.odd}.
% \item[\marg{code}:] will be executed on single-side pages; used to define
%   the contents of layer \texttt{\meta{page style name}.foot.oneside}.
% \item[\pparg{dimensional expression}{dimensional expression}:] length and
%   thickness of a line (ruler) below the page footer. May be omitted and if
%   so the values from option \opt{footbotline} will be used.
% \end{description}
% Helper to define the foot layers.
%    \begin{macrocode}
\newcommand*\sls@deffoot[1]{%
  \kernel@ifnextchar(%)
  {\sls@@deffoot{#1}}%
  {\sls@@deffoot{#1}(\sls@footabove@linelength,\sls@footabove@linethickness)}%
}%
\newcommand*{\sls@@deffoot}{}
\def\sls@@deffoot#1(#2,#3)#4#5#6{%
  \kernel@ifnextchar(%)
  {\sls@@@deffoot{#1}({#2},{#3}){#4}{#5}{#6}}%
  {\sls@@@deffoot{#1}%
                 ({#2},{#3})%
                 {#4}{#5}{#6}%
                 (\sls@footbelow@linelength,\sls@footbelow@linethickness)}%
}%
\newcommand*{\sls@@@deffoot}{}
\def\sls@@@deffoot#1(#2,#3)#4#5#6(#7,#8){%
%    \end{macrocode}
% The lines:
%    \begin{macrocode}
  \DeclareLayer[%
    foreground,%
    hoffset=\sls@leftmargin{foot},%
    voffset=\sls@topmargin
            +\headheight+\headsep
            +\textheight
            +\footskip-\footheight
            +2\dp\strutbox,%
    width=\sls@footwidth,%
    height=0pt,%
    align=bl,%
    contents={%
      {\normalfont\usekomafont{pageheadfoot}{\usekomafont{pagefoot}{%
            \sls@hf@rule{footsep}{#2}{#3}}}}%
    }%
  ]{#1.foot.above.line}%
  \DeclareLayer[%
    foreground,%
    hoffset=\sls@leftmargin{foot},%
    voffset=\sls@topmargin
            +\headheight+\headsep
            +\textheight
            +\footskip
            +2\dp\strutbox
            +#8,%
    width=\sls@footwidth,%
    height=0pt,%
    align=bl,%
    contents={%
      {\normalfont\usekomafont{pageheadfoot}{\usekomafont{pagefoot}{%
            \sls@hf@rule{footbot}{#7}{#8}}}}%
    }%
  ]{#1.foot.below.line}%
%    \end{macrocode}
% The odd side, even side and one side:
%    \begin{macrocode}
  \DeclareLayer[%
    foreground,evenpage,twoside,%
    foot,%
    hoffset=\sls@leftmargin{foot},%
    width=\sls@footwidth,%
    contents={%
      \sls@secure@box\footheight{%
        \normalfont\usekomafont{pageheadfoot}{\usekomafont{pagefoot}{#4}}}}%
  ]{#1.foot.even}%
  \DeclareLayer[%
    foreground,oddpage,twoside,%
    foot,%
    hoffset=\sls@leftmargin{foot},%
    width=\sls@footwidth,%
    contents={%
      \sls@secure@box\footheight{%
        \normalfont\usekomafont{pageheadfoot}{\usekomafont{pagefoot}{#5}}}}%
  ]{#1.foot.odd}%
  \DeclareLayer[%
    foreground,oddpage,oneside,%
    foot,%
    hoffset=\sls@leftmargin{foot},%
    width=\sls@footwidth,%
    contents={%
      \sls@secure@box\footheight{%
        \normalfont\usekomafont{pageheadfoot}{\usekomafont{pagefoot}{#6}}}}%
  ]{#1.foot.oneside}%
}%
%    \end{macrocode}
% \begin{macro}{\sls@secure@box}
% \changes{v3.34}{2021/05/16}{\LaTeX{} team requested for additional \cs{par}}
% \begin{description}
% \item[\marg{length}:] a \LaTeX{} length, that gives the maximum
%   height + depth of the \meta{content}. It has to be either
%   \cs{headheight} or \cs{footheight}.
% \item[\marg{content}:] what should be output (inside the box).
% \end{description}
% Note, that several length may be changed, to fit.
%    \begin{macrocode}
\newcommand*{\sls@secure@box}[2]{%
  \begingroup
    \setbox\z@\vbox{%
      \ifsls@leavevmode\leavevmode\expandafter\ignorespaces\fi 
      #2\par
    }%
    \ifdim #1<\dimexpr \ht\z@+\dp\z@\relax
      \PackageWarning{scrlayer-scrpage}{%
        \string#1 to low.\MessageBreak
        At least \the\dimexpr \ht\z@+\dp\z@\relax\space needed,\MessageBreak
        but only \the#1 found.\MessageBreak
        \ifsls@autoenlarge
          I'll enlarge \string#1, for further\MessageBreak
          processing, but you should do this yourself,\MessageBreak
        \else
          You should enlarge \string#1,\MessageBreak
        \fi
        e.g.,
        \scr@ifundefinedorrelax{geometry}{%
          \scr@ifundefinedorrelax{typearea}{%
            using\MessageBreak
            \space\space\string\setlength{\string#1}{%
              \the\dimexpr \ht\z@+\dp\z@\relax}\MessageBreak
            in your preamble%
          }{%
            setting typearea's option\MessageBreak
            `\expandafter\@gobble\string#1=\the\dimexpr \ht\z@+\dp\z@\relax'%
          }%
        }{%
          \ifx #1\headheight
            setting geometry's option\MessageBreak
            `head=\the\dimexpr \ht\z@+\dp\z@\relax'%
          \else
            using\MessageBreak
            \space\space\string\setlength{\string#1}{%
              \the\dimexpr \ht\z@+\dp\z@\relax}\MessageBreak
            in your preamble%
          \fi
        }%
        \ifsls@autoenlarge
          .\MessageBreak
          I'll also
          \ifx #1\headheight decrease \string\topmargin
          \else increase \string\footskip\fi
        \fi
      }%
      \ifsls@autoenlarge
        \@tempdima\dimexpr \ht\z@+\dp\z@\relax
        \ifx #1\headheight
          \global\advance\topmargin by \dimexpr #1-(\ht\z@+\dp\z@)\relax
          \dp\z@\dimexpr \dp\z@+\ht\z@+\dp\z@-\headheight\relax
        \else
          \global\advance\footskip by \dimexpr \ht\z@+\dp\z@-#1\relax
        \fi
        \global#1\@tempdima
      \fi
    \fi
    \usebox\z@
  \endgroup
}%
%</body>
%    \end{macrocode}
% \begin{option}{hmode}
% Switch automatically to the horizontal mode before setting a page head or
% page footer element.
%    \begin{macrocode}
%<*options>
\KOMA@ifkey{hmode}{sls@leavevmode}
%</options>
%    \end{macrocode}
% \end{option}^^A hmode
% \begin{option}{autoenlargeheadfoot}
% \changes{v3.25}{2018/01/14}{added}
% Automaticly enlarge vertical size of head or foot if the contents is to
% large. This is the default.
%    \begin{macrocode}
%<*options>
\KOMA@ifkey{autoenlargeheadfoot}{sls@autoenlarge}
\KOMAExecuteOptions{autoenlargeheadfoot=true}
%</options>
%    \end{macrocode}
% \end{option}^^A autoenlargeheadfoot
% \end{macro}^^A \sls@secure@box
% \end{macro}^^A \sls@@@deffoot
% \end{macro}^^A \sls@deffoot,\sls@@deffoot
% \end{macro}^^A \sls@@@defhead
% \end{macro}^^A \sls@defhead,\sls@@defhead
% \begin{command}{\headfont}
% The low level page head font command. It is deprecated to redefine or use
% this and it may already be defined.
% \begin{macro}{\scr@fnt@pagehead}
% \changes{v3.25}{2018/02/05}{don't use \cs{newkomafont} to avoid warning}
% \begin{macro}{\scr@fnt@wrn@pagehead}
% \changes{v0.9}{2014/01/13}{warning always deactivated}
% \begin{macro}{\scr@fnt@pageheadfoot}
%    \begin{macrocode}
%<*body>
\@ifundefined{scr@fnt@pagehead}{%
  \scr@ifundefinedorrelax{scr@fnt@instead@pagehead}{}{%
    \PackageInfo{scrlayer-scrpage}{%
      Makeing stand-alone element `pagehead' from\MessageBreak
      alias to `pageheadfoot'%
    }%
    \let\scr@fnt@instead@pagehead\relax
  }%
  \@ifundefined{@pageheadfont}{%
    \newcommand*{\@pageheadfont}{}%
  }{}%
  \newcommand*{\scr@fnt@pagehead}{\@pageheadfont}%
}{}
\@ifundefined{scr@fnt@pageheadfoot}{%
  \newcommand*{\scr@fnt@pageheadfoot}{\headfont}%
  \@ifundefined{headfont}{%
    \newcommand*{\headfont}{\normalcolor\slshape}%
  }{}
}{}
\scr@ifundefinedorrelax{scr@fnt@wrn@pagehead}{}{%
%<trace>  \PackageInfo{scrlayer-scrpage}{%
%<trace>    deactivating warning for font element\MessageBreak
%<trace>    `pagehead'}%
  \let\scr@fnt@wrn@pagehead\relax
}
%    \end{macrocode}
% \end{macro}^^A \scr@fnt@pageheadfoot
% \end{macro}^^A \scr@fnt@wrn@pagehead
% \end{macro}^^A \scr@fnt@pagehead
% \end{command}^^A \headfont
%
% \begin{command}{\footfont}
% The low level page footer font command. It is deprecated to redefine or use
% this and it may already be defined.
% \begin{macro}{\scr@fnt@pagefoot}
% \begin{macro}{\scr@fnt@wrn@pagefoot}
% \changes{v0.9}{2014/01/13}{warning always deactivated}
%    \begin{macrocode}
\@ifundefined{scr@fnt@pagefoot}{%
  \def\scr@fnt@pagefoot{\footfont}%
  \@ifundefined{footfont}{%
    \newcommand*{\footfont}{}%
  }{}%
}{}
\scr@ifundefinedorrelax{scr@fnt@wrn@pagefoot}{}{%
%<trace>  \PackageInfo{scrlayer-scrpage}{%
%<trace>    deactivating warning for font element\MessageBreak
%<trace>    `pagefoot'}%
  \let\scr@fnt@wrn@pagefoot\relax
}
%    \end{macrocode}
% \end{macro}^^A \scr@fnt@wrn@pagefoot
% \end{macro}^^A \scr@fnt@pagefoot
% \end{command}^^A \footfont
%
% \begin{macro}{\sls@hf@rule}
% \changes{v3.34}{2021/05/16}{\LaTeX{} team requested for additional \cs{par}}
% \begin{description}
% \item[\marg{rule name}:] one of \texttt{headtop}, \texttt{headsep},
%   \texttt{footsep}, or \texttt{footbot}
% \item[\marg{dimensional expression}:] the line length (width)
% \item[\marg{dimensional expression}:] the line thickness (height)
% \end{description}
% Helper to draw the line.
%    \begin{macrocode}
\newcommand*\sls@hf@rule[3]{%
  \begingroup
    \normalfont\usekomafont{#1line}{%
      \vbox to \z@{%
        \kern -\dimexpr #3\relax
        \ifnum \sls@hfline@adjust>\z@ \@tempswatrue \else \@tempswafalse\fi
        \if@twoside\ifodd\value{page}\else
          \ifnum \sls@hfline@adjust<\tw@ \@tempswatrue\else \@tempswafalse\fi
        \fi\fi
        \if@tempswa
          \hskip \z@\@plus 1fill\@minus \paperwidth
        \fi
        \vrule \@width\dimexpr #2\relax \@height\dimexpr #3\relax \@depth\z@
        \ifnum \sls@hfline@adjust<\tw@ \@tempswatrue\else \@tempswafalse\fi
        \if@twoside\ifodd\value{page}\else
          \ifnum \sls@hfline@adjust>\z@ \@tempswatrue \else \@tempswafalse\fi
        \fi\fi
        \if@tempswa
          \hskip \z@\@plus 1fill\@minus \paperwidth\null
        \fi
        \par
      }%
    }%      
  \endgroup
}%
%    \end{macrocode}
% \end{macro}^^A \sls@hf@rule
% \begin{macro}{\sls@topmargin,\sls@leftmargin}
% Two simple helper macros:
%    \begin{macrocode}
\newcommand*{\sls@topmargin}{\dimexpr\topmargin+1in\relax}%
\newcommand*{\sls@leftmargin}[1]{%
  \dimexpr
  \if@twoside
    \ifodd\value{page}
      \oddsidemargin+\csname sls@odd#1shift\endcsname
    \else
      \evensidemargin+\csname sls@even#1shift\endcsname
    \fi
  \else
    \oddsidemargin+\csname sls@odd#1shift\endcsname
  \fi 
  +1in\relax
}%
%</body>
%    \end{macrocode}
% \end{macro}^^A \sls@topmargin … \sls@leftmargin
% \end{command}^^A \defpagestyle
%
% \begin{command}{\newpagestyle}
% \changes{v3.32}{2020/09/11}{test for \pkg{titlesec}}
% For the parameters see \cs{defpagestyle}. Define the pagestyle only, if not
% already defined. Unfortunately \pkg{titlesec} also defines this command. So
% new definition will fail. \textsf{titlesec} uses \cs{providecommand} so if
% the order would be changed, everything would be OK.
%    \begin{macrocode}
%<*body>
\@ifpackageloaded{titlesec}{%
  \@ifundefined{newpagestyle}{}{%
    \@ifpackageloaded{titleps}{}{%
      \PackageWarningNoLine{scrlayer-scrpage}{%
        it seems that package `titlesec' is used\MessageBreak
        and has already defined `\string\newpagestyle'.\MessageBreak
        To avoid this warning message, you should\MessageBreak
        load package `titlesec' not before package\MessageBreak
        `scrlayer-scrpage'. If you need `titlesec'\MessageBreak
        you could load it after `scrlayer-scrpage',\MessageBreak
        but you still would not be able to use\MessageBreak
        the `titlesec' implemenation of\MessageBreak
        `\string\newpagestyle'%
      }%
      \let\newpagestyle\relax
    }%
  }%
}{}
\newcommand*\newpagestyle[3]{%
  \@ifundefined{ps@#1}{\defpagestyle{#1}{#2}{#3}}{%
    \PackageError{scrlayer-scrpage}{Page style `#1' already defined}{%
      Only not yet defined page style may be defined using
      \string\newpagestyle.\MessageBreak
      You may use either \string\renewpagestyle, \string\providepagestyle,
      or \string\defpagestyle\MessageBreak
      with already defined page styles.\MessageBreak
      If you'll continue, your command will be ignored.%
    }%
  }%
}%
%</body>
%    \end{macrocode}
% \end{command}^^A \newpagestyle
%
% \begin{command}{\renewpagestyle}
% \changes{v3.32}{2020/09/11}{test for \textsf{titlesec}}
% For the parameters see \cs{defpagestyle}. Define the pagestyle only, if not
% already defined.  Unfortunately \textsf{titlesec} also defines this
% command. So new definition will fail. \textsf{titlesec} uses
% \cs{providecommand} so if the order would be changed, everything would be OK.
%    \begin{macrocode}
%<*body>
\@ifpackageloaded{titlesec}{%
  \@ifundefined{renewpagestyle}{}{%
    \@ifpackageloaded{titleps}{}{%
      \PackageWarningNoLine{scrlayer-scrpage}{%
        It seems that package `titlesec' is used\MessageBreak
        and has already defined `\string\renewpagestyle'.\MessageBreak
        To avoid this warning message, you should\MessageBreak
        load package `titlesec' not before package\MessageBreak
        `scrlayer-scrpage'. If you need `titlesec'\MessageBreak
        you could load it after `scrlayer-scrpage',\MessageBreak
        but you still would not be able to use\MessageBreak
        the `titlesec' implemenation of\MessageBreak
        `\string\renewpagestyle'%
      }%
      \let\renewpagestyle\relax
    }%
  }%
}{}
\newcommand*\renewpagestyle[3]{%
  \@ifundefined{ps@#1}{%
    \PackageError{scrlayer-scrpage}{Undefined page style `#1'}{%
      Only already defined page style may be re-defined using
      \string\renewpagestyle.\MessageBreak
      You may use either \string\newpagestyle, \string\providepagestyle,
      or \string\defpagestyle\MessageBreak
      with not yet defined page styles.\MessageBreak
      If you'll continue, your command will be ignored.%
    }%
  }{%
    \defpagestyle{#1}{#2}{#3}%
  }%
}%
%</body>
%    \end{macrocode}
% \end{command}^^A \renewpagestyle
%
% \begin{command}{\providepagestyle}
% For the parameters see \cs{defpagestyle}. Define only, if not already defined:
%    \begin{macrocode}
%<*body>
\newcommand*\providepagestyle[3]{%
  \@ifundefined{ps@#1}{%
    \defpagestyle{#1}{#2}{#3}%
  }{%
%<*trace>
    \PackageInfo{scrlayer-scrpage}{%
      page style `#1' already defined.\MessageBreak
      New definition ignored%
    }%
%</trace>
  }%
}
%</body>
%    \end{macrocode}
% \end{command}^^A \providepagestyle
%
%
% \subsection{User page style definition interface}
%
% This is the mid-level interface of \pkg{scrpage2} with \cs{deftripstyle}. As
% in \pkg{scrpage2} we simply use the expert page style definition interface
% to define the new user interface commands. But here the useless starred
% versions will not longer be supported. So users of them have to remove the
% star (nothing else).
%
% \begin{command}{\deftriplepagestyle,\newtriplepagestyle,
%                 \renewtriplepagestyle,\providetriplepagestyle}
% \begin{description}
% \item[\marg{string}:] the name of the page style to be defined (must be
%   fully expandable and expand to a string only).
% \item[\oarg{dimensional expression}:] thickness of a horizontal line above
%   the page head and below the page foot (default: 0\,pt).
% \item[\oarg{dimensional expression}:] thickness of a horizontal line below
%   the page head and above the page foot (default: 0\,pt).
% \item[\marg{code}:] will be expanded left aligned at head of odd pages (with
%   one-side layout all pages are odd) and right aligned at head of even
%   pages.
% \item[\marg{code}:] will be expanded centered at head of odd and even pages.
% \item[\marg{code}:] will be expanded right aligned at head of odd pages
%   (with one-side layout all pages are odd) and left aligned at head of even
%   pages.
% \item[\marg{code}:] will be expanded left aligned at footer of odd pages
%   (with one-side layout all pages are odd) and right aligned at footer of
%   even pages.
% \item[\marg{code}:] will be expanded centered at footer of odd and even
%   pages.
% \item[\marg{code}:] will be expanded right aligned at footer of odd pages
%   (with one-side layout all pages are odd) and left aligned at footer of
%   even pages.
% \end{description}
%    \begin{macrocode}
%<*body>
\newcommand*{\deftriplepagestyle}[1]{%
  \let\@tempa\defpagestyle
  \scrlayer@triplestyle{#1}%
}%
\newcommand*{\newtriplepagestyle}[1]{%
  \let\@tempa\newpagestyle
  \scrlayer@triplestyle{#1}%
}%
\newcommand*{\renewtriplepagestyle}[1]{%
  \let\@tempa\renewpagestyle
  \scrlayer@triplestyle{#1}%
}%
\newcommand*{\providetriplepagestyle}[1]{%
  \let\@tempa\providepagestyle
  \scrlayer@triplestyle{#1}%
}%
%    \end{macrocode}
% \begin{macro}{\scrlayer@triplestyle,\scrlayer@@triplestyle}
% \changes{v3.20}{2016/04/12}{\cs{@ifnextchar} replaced by
%   \cs{kernel@ifnextchar}}
% \begin{macro}{\scrlayer@@@triplestyle}
% Helpers, that do the real work. Parameters are same, but \cs{reserved@a} has
% to be one of \cs{defpagestyle}, \cs{newpagestyle},
% \cs{renewpagestyle}, or \cs{providepagestyle}.
%    \begin{macrocode}
\newcommand*{\scrlayer@triplestyle}[1]{%
  \kernel@ifnextchar[%]
  {\scrlayer@@triplestyle{#1}}%
  {\scrlayer@@triplestyle{#1}[\z@]}%
}
\newcommand*{\scrlayer@@triplestyle}{}
\def\scrlayer@@triplestyle#1[#2]{%
 \kernel@ifnextchar[%]
  {\scrlayer@@@triplestyle{#1}[#2]}%
  {\scrlayer@@@triplestyle{#1}[\z@][#2]}%
}%
\newcommand*{\scrlayer@@@triplestyle}{}
\def\scrlayer@@@triplestyle#1[#2][#3]#4#5#6#7#8#9{%
  \@tempa{#1}{%
    (\sls@headwidth,#2)%
    {%
      \makebox[\z@][l]{#6}\hfill
      \makebox[\z@][c]{#5}\hfill
      \makebox[\z@][r]{#4}%
    }{%
      \makebox[\z@][l]{#4}\hfill
      \makebox[\z@][c]{#5}\hfill
      \makebox[\z@][r]{#6}%
    }{%
      \makebox[\z@][l]{#4}\hfill
      \makebox[\z@][c]{#5}\hfill
      \makebox[\z@][r]{#6}%
    }%
    (\sls@headwidth,#3)%
  }{%
    (\sls@footwidth,#3)%
    {%
      \makebox[\z@][l]{#9}\hfill
      \makebox[\z@][c]{#8}\hfill
      \makebox[\z@][r]{#7}%
    }{%
      \makebox[\z@][l]{#7}\hfill
      \makebox[\z@][c]{#8}\hfill
      \makebox[\z@][r]{#9}%
    }{%
      \makebox[\z@][l]{#7}\hfill
      \makebox[\z@][c]{#8}\hfill
      \makebox[\z@][r]{#9}%
    }%
    (\sls@footwidth,#2)%
  }%
}%
%    \end{macrocode}
% \end{macro}^^A \scrlayer@@@triplestyle
% \end{macro}^^A \scrlayer@triplestyle,\scrlayer@@triplestyle
% \begin{command}{deftripstyle}
% Command \cs{deftripstyle} has been defined for compatibility with
% \pkg{scrpage2} only. It is deprecated now.
% The starred version \cs{deftripstyle*} is deprecated for several
% years and hasn't been described at the manual, it will not longer be
% defined.
%    \begin{macrocode}
\newcommand*{\deftripstyle}{%
  \PackageWarning{scrlayer-scrpage}{%
    Command \string\deftripstyle\space is deprecate.\MessageBreak
    You should replace it by \string\deftriplepagestyle,\MessageBreak
    e.g.,%
  }%
  \let\deftripstyle\deftriplepagestyle
  \deftripstyle
}%
%</body>
%    \end{macrocode}
% \end{command}^^A \deftripstyle
% \end{command}^^A \deftriplepagestyle … \providetriplepagestyle
%
%
% \subsection{Pre-defined page styles interface}
%
% This is the high-level interface of \pkg{scrpage2} with the page style
% \pstyle{scrheadings}, \pstyle{scrplain}, and \pstyle{useheadings}. Those
% will work as expected but will also be extended to support definition of
% additional styles using the same interface.
%
% \begin{command}{\defpairofpagestyles}
% \changes{v3.28}{2019/11/18}{\cs{ifstr} renamed to \cs{Ifstr}}
% \begin{description}
% \item[\oarg{string}:] name of a parent page style, that will be used to
%   initialise the new page style (must be fully expandable and expand to the
%   name of a page style).
% \item[\marg{string}:] name the page style to be defined (must be fully
%   expandable and expand to the name of a page style).
% \item[\marg{code}:] several commands of \cs{ihead}, \cs{chead}, \cs{ohead},
%   \cs{lehead}, \cs{lohead}, \cs{cohead}, \cs{rehead}, \cs{cehead},
%   \cs{rohead}, \cs{ifoot}, \cs{cfoot}, \cs{ofoot}, \cs{lefoot}, \cs{cefoot},
%   \cs{lofoot}, \cs{refoot}, \cs{cofoot}, \cs{rofoot}, \cs{clearscrheadfoot},
%   \cs{clearscrheadings}, \cs{clearscrplain}.
% \end{description}
% Two page styles will be defined using \cs{defpagestyle}, page style named
% with the second argument and page style with the same name but an additional
% prefix ``\pstyle{plain.}''. This will be activated automatically to be the
% plain page style when the first page style will be used. If first argument
% is used this pair of page styles will be used to initialise the head and
% footer of the new. All the other commands are used to define the initial
% fields. Note, if one of those page styles is active, all further commands
% (see 3rd argument) depend on the active page style. If no one is active,
% they depend on page style \pstyle{scrheadings}.
%    \begin{macrocode}
%<*body>
\newcommand*{\defpairofpagestyles}[3][]{%
  \def\reserved@a##1##2##3##4##5##6##7\@nil{##1##2##3##4##5##6}%
  \edef\reserved@a{\expandafter\reserved@a #2xxxxxx\@nil}%
  \Ifstr\reserved@a{plain.}{%
    \PackageError{scrlayer-scrpage}{plain page style `#2' not allowed}{%
      You may not define a plain page style using
      \string\defpairofpagestyles, \string\newpairofpagestyles,
      \string\renewpairofpagestyles, or\MessageBreak
      \string\providepairofpagestyles.  I'd suggest to simply define the
      corresponding\MessageBreak
      non-plain page style to also define the plain one.\MessageBreak
      If you'll continue, your command will be ignored.}%
  }{%
    \sls@init@pair@page@style*{#2}%
    \sls@init@pair@page@style*{plain.#2}%
    \ifx\relax #1\relax\else
      \scr@ifundefinedorrelax{sls@ps@#1@even@left@head}{%
        \PackageError{scrlayer-scrpage}{`#1' not a pair page style}{%
          Only pair page styles may be used to initialise new pairs of page
          styles. So\MessageBreak
          optional argument of \string\defpairofpagestyles,
          \string\newpairofpagestyles,\MessageBreak
          \string\renewpairofpagestyles, or \string\providepairofpagestyle has
          to be a pair\MessageBreak
          page style or should be unused.\MessageBreak
          If you'll continue, the initialisation will be ignored.}%
      }{%
        \sls@init@pair@page@style{#2}{#1}%
        \scr@ifundefinedorrelax{sls@ps@plain.#1@even@left@head}{%
          \sls@init@pair@page@style{plain.#2}{#1}%
        }{%
          \sls@init@pair@page@style{plain.#2}{plain.#1}%
        }%
      }%
    \fi
    \sls@def@pair@page@style@member{#2}%
    \AddToLayerPageStyleOptions{#2}{%
      onselect={%
%    \end{macrocode}
% \changes{v3.15}{2015/01/08}{usage of \cs{DeclarePageStyleAlias} instead of
%   \cs{let}}
%    \begin{macrocode}
        \DeclarePageStyleAlias{plain}{plain.#2}%
        \DeclarePageStyleAlias{headings}{#2}%
        \def\sls@currentheadings{#2}%
        \def\sls@currentplain{plain.#2}%
        #3%
      }%
    }%
    \sls@def@pair@page@style@member{plain.#2}%
    \AddToLayerPageStyleOptions{plain.#2}{%
      onselect={%
%    \end{macrocode}
% \changes{v3.15}{2015/01/08}{usage of \cs{DeclarePageStyleAlias} instead of
%   \cs{let}}
%    \begin{macrocode}
        \DeclarePageStyleAlias{plain}{plain.#2}%
        \DeclarePageStyleAlias{headings}{#2}%
        \def\sls@currentheadings{#2}%
        \def\sls@currentplain{plain.#2}%
        #3%
      },%
      oninit={%
        \expandafter
        \ifx\csname ifsls@plain@head@above@line\expandafter\endcsname
          \csname iftrue\endcsname\else
          \let\sls@headabove@linelength\z@
          \let\sls@headabove@linethickness\z@
        \fi
        \expandafter
        \ifx\csname ifsls@plain@head@below@line\expandafter\endcsname
            \csname iftrue\endcsname\else
          \let\sls@headbelow@linelength\z@
          \let\sls@headbelow@linethickness\z@
        \fi
        \expandafter
        \ifx\csname ifsls@plain@foot@above@line\expandafter\endcsname
            \csname iftrue\endcsname\else
          \let\sls@footabove@linelength\z@
          \let\sls@footabove@linethickness\z@
        \fi
        \expandafter
        \ifx\csname ifsls@plain@foot@below@line\expandafter\endcsname
            \csname iftrue\endcsname\else
          \let\sls@footbelow@linelength\z@
          \let\sls@footbelow@linethickness\z@
        \fi
      }%
    }%
  }%
}%
%    \end{macrocode}
% \begin{macro}{\sls@currentheadings,\sls@currentplain}
% These little helpers will be set up at selection of each pair page style and
% stores the last activated page style pair of the scope.
%    \begin{macrocode}
\newcommand*\sls@currentheadings{scrheadings}%
\newcommand*\sls@currentplain{plain.scrheadings}%
%    \end{macrocode}
% \end{macro}^^A \sls@currentheadings,\sls@currentplain
% \begin{macro}{\sls@init@pair@page@style}
% \changes{v3.20}{2016/04/12}{\cs{ifstar} replaced by \cs{kernel@ifstar}}
% \begin{macro}{\sls@init@@pair@page@style}
% \begin{description}
% \item[\marg{string}:] the name of the page style, that should be initialised
%   to be one member of a page style pair.
% \item[\marg{string}:] the name of a member of a page style pair, that should
%   be used to initialise one the member of a page style pair from first
%   argument.
% \end{description}
% These are two little helpers for \cs{defpairofpagestyles}. The first command
% has two starred versions. With one star the commands for the page style will
% be initialised to \cs{@empty}, with two stars they will become
% \LaTeX-undefined (\cs{relax}).
%
% Note also, that the second argument may either be the plain or the non-plain
% member of the page style pair.
%    \begin{macrocode}
\newcommand*{\sls@init@pair@page@style}{%
  \kernel@ifstar {%
    \kernel@ifstar {%
      \sls@let@pair@page@style\relax
    }{%
      \sls@let@pair@page@style\@empty
    }
  }{%
    \sls@init@@pair@page@style
  }%
}%
\newcommand*{\sls@init@@pair@page@style}[2]{%
  \expandafter\let\csname sls@ps@#1@even@left@head\expandafter\endcsname
  \csname sls@ps@#2@even@left@head\endcsname
  \expandafter\let\csname sls@ps@#1@even@middle@head\expandafter\endcsname
  \csname sls@ps@#2@even@middle@head\endcsname
  \expandafter\let\csname sls@ps@#1@even@right@head\expandafter\endcsname
  \csname sls@ps@#2@even@right@head\endcsname
  \expandafter\let\csname sls@ps@#1@odd@left@head\expandafter\endcsname
  \csname sls@ps@#2@odd@left@head\endcsname
  \expandafter\let\csname sls@ps@#1@odd@middle@head\expandafter\endcsname
  \csname sls@ps@#2@odd@middle@head\endcsname
  \expandafter\let\csname sls@ps@#1@odd@right@head\expandafter\endcsname
  \csname sls@ps@#2@odd@right@head\endcsname
  \expandafter\let\csname sls@ps@#1@even@left@foot\expandafter\endcsname
  \csname sls@ps@#2@even@left@foot\endcsname
  \expandafter\let\csname sls@ps@#1@even@middle@foot\expandafter\endcsname
  \csname sls@ps@#2@even@middle@foot\endcsname
  \expandafter\let\csname sls@ps@#1@even@right@foot\expandafter\endcsname
  \csname sls@ps@#2@even@right@foot\endcsname
  \expandafter\let\csname sls@ps@#1@odd@left@foot\expandafter\endcsname
  \csname sls@ps@#2@odd@left@foot\endcsname
  \expandafter\let\csname sls@ps@#1@odd@middle@foot\expandafter\endcsname
  \csname sls@ps@#2@odd@middle@foot\endcsname
  \expandafter\let\csname sls@ps@#1@odd@right@foot\expandafter\endcsname
  \csname sls@ps@#2@odd@right@foot\endcsname
}%
%    \end{macrocode}
% \end{macro}^^A \sls@init@@pair@page@style
% \begin{macro}{\sls@let@pair@page@style}
% \begin{description}
% \item[\marg{command}:] a single command used to initialise the commands of
%   the page style commands.
% \item[\marg{string}:] the name of a member of a page style pair, that should
%   be used to initialise one the member of a page style pair from first
%   argument.
% \end{description}
% A little helper for \cs{sls@init@pair@page@style}.
%    \begin{macrocode}
\newcommand*{\sls@let@pair@page@style}[2]{%
  \expandafter\let\csname sls@ps@#2@even@left@head\endcsname #1%
  \expandafter\let\csname sls@ps@#2@even@middle@head\endcsname #1%
  \expandafter\let\csname sls@ps@#2@even@right@head\endcsname #1%
  \expandafter\let\csname sls@ps@#2@odd@left@head\endcsname #1%
  \expandafter\let\csname sls@ps@#2@odd@middle@head\endcsname #1%
  \expandafter\let\csname sls@ps@#2@odd@right@head\endcsname #1%
  \expandafter\let\csname sls@ps@#2@even@left@foot\endcsname #1%
  \expandafter\let\csname sls@ps@#2@even@middle@foot\endcsname #1%
  \expandafter\let\csname sls@ps@#2@even@right@foot\endcsname #1%
  \expandafter\let\csname sls@ps@#2@odd@left@foot\endcsname #1%
  \expandafter\let\csname sls@ps@#2@odd@middle@foot\endcsname #1%
  \expandafter\let\csname sls@ps@#2@odd@right@foot\endcsname #1%
}%
%    \end{macrocode}
% \end{macro}^^A \sls@let@pair@page@style
% \end{macro}^^A \sls@init@pair@page@style
% \begin{macro}{\sls@def@pair@page@style@member}
% \changes{v3.24}{2017/05/04}{improved \textsf{bidi} compatibility}
% \changes{v3.27}{2019/04/05}{\cs{centering} replaced by
%   \cs{LaTeXcentering}}
% \changes{v3.27}{2019/04/05}{\cs{raggedright} replaced by
%   \cs{LaTeXraggedright}}
% \changes{v3.27}{2019/04/05}{\cs{raggedleft} replaced by
%   \cs{LaTeXraggedleft}}
% \begin{description}
% \item[\marg{string}:] name of the page style to be defined.
% \end{description}
% A little helper for \cs{defpairofpagestyles}.
%    \begin{macrocode}
\newcommand*{\sls@def@pair@page@style@member}[1]{%
  \defpagestyle{#1}{%
    {%
      \makebox[0pt][\IfRTL{r}{l}]{\parbox{\sls@headwidth}{\LaTeXraggedright
          \strut\@nameuse{sls@ps@#1@even@left@head}\strut}}%
      \parbox{\sls@headwidth}{\LaTeXcentering
        \strut\@nameuse{sls@ps@#1@even@middle@head}\strut}%
      \makebox[0pt][\IfRTL{l}{r}]{\parbox{\sls@headwidth}{\LaTeXraggedleft
          \strut\@nameuse{sls@ps@#1@even@right@head}\strut}}%
    }{%
      \makebox[0pt][\IfRTL{r}{l}]{\parbox{\sls@headwidth}{\LaTeXraggedright
          \strut\@nameuse{sls@ps@#1@odd@left@head}\strut}}%
      \parbox{\sls@headwidth}{\LaTeXcentering
        \strut\@nameuse{sls@ps@#1@odd@middle@head}\strut}%
      \makebox[0pt][\IfRTL{l}{r}]{\parbox{\sls@headwidth}{\LaTeXraggedleft
          \strut\@nameuse{sls@ps@#1@odd@right@head}\strut}}%
    }{%
      \makebox[0pt][\IfRTL{r}{l}]{\parbox{\sls@headwidth}{\LaTeXraggedright
          \strut\@nameuse{sls@ps@#1@odd@left@head}\strut}}%
      \parbox{\sls@headwidth}{\LaTeXcentering
        \strut\@nameuse{sls@ps@#1@odd@middle@head}\strut}%
      \makebox[0pt][\IfRTL{l}{r}]{\parbox{\sls@headwidth}{\LaTeXraggedleft
          \strut\@nameuse{sls@ps@#1@odd@right@head}\strut}}%
    }%
  }{%
    {%
      \makebox[0pt][\IfRTL{r}{l}]{\parbox{\sls@footwidth}{\LaTeXraggedright
          \strut\@nameuse{sls@ps@#1@even@left@foot}\strut}}%
      \parbox{\sls@footwidth}{\LaTeXcentering
        \strut\@nameuse{sls@ps@#1@even@middle@foot}\strut}%
      \makebox[0pt][\IfRTL{l}{r}]{\parbox{\sls@footwidth}{\LaTeXraggedleft
          \strut\@nameuse{sls@ps@#1@even@right@foot}\strut}}%
    }{%
      \makebox[0pt][\IfRTL{r}{l}]{\parbox{\sls@footwidth}{\LaTeXraggedright
          \strut\@nameuse{sls@ps@#1@odd@left@foot}\strut}}%
      \parbox{\sls@footwidth}{\LaTeXcentering
        \strut\@nameuse{sls@ps@#1@odd@middle@foot}\strut}%
      \makebox[0pt][\IfRTL{l}{r}]{\parbox{\sls@footwidth}{\LaTeXraggedleft
          \strut\@nameuse{sls@ps@#1@odd@right@foot}\strut}}%
    }{%
      \makebox[0pt][\IfRTL{r}{l}]{\parbox{\sls@footwidth}{\LaTeXraggedright
          \strut\@nameuse{sls@ps@#1@odd@left@foot}\strut}}%
      \parbox{\sls@footwidth}{\LaTeXcentering
        \strut\@nameuse{sls@ps@#1@odd@middle@foot}\strut}%
      \makebox[0pt][\IfRTL{l}{r}]{\parbox{\sls@footwidth}{\LaTeXraggedleft
          \strut\@nameuse{sls@ps@#1@odd@right@foot}\strut}}%
    }%
  }%
}%
%</body>
%    \end{macrocode}
% \end{macro}^^A \sls@def@pair@page@style@member
% \end{command}^^A \defpairofpagestyles
%
% \begin{command}{\newpairofpagestyles,\renewpairofpagestyles,
%                 \providepairofpagestyles}
% See \cs{defpairofpagestyles} for the arguments.
%    \begin{macrocode}
%<*body>
\newcommand*{\newpairofpagestyles}[3][]{%
  \scr@ifundefinedorrelax{ps@#2}{%
    \@ifundefined{ps@plain.#2}{\defpairofpagestyles[#1]{#2}{#3}}{%
      \PackageError{scrlayer-scrpage}{%
        Plain page style of `#2' already defined}{%
        You may only define a new pair of page styles, if neither the style
        itself\MessageBreak
        nor it's plain page style has already been defined.\MessageBreak
        You may use only \string\defpairofpagestyles\space or
        \string\providepairofpagestyles\space with partly\MessageBreak
        already defined page styles.\MessageBreak
        If you'll continue, your command will be ignored.%
      }%
    }%
  }{%
    \PackageError{scrlayer-scrpage}{%
      Page style `#2' already defined}{%
      You may only define a new pair of page styles, if neither the style
      itself\MessageBreak
      nor it's plain page style has already been defined.\MessageBreak
      You may use either \string\renewpairsofpagestyles,
      \string\defpairofpagestyles, or\MessageBreak
      \string\providepairofpagestyles\space with already defined page
      styles.\MessageBreak
      If you'll continue, your command will be ignored.%
    }%
  }%
}%
\newcommand*{\renewpairofpagestyles}[3][]{%
  \scr@ifundefinedorrelax{ps@#2}{%
    \PackageError{scrlayer-scrpage}{%
      Undefined page style `#2'}{%
      You may only redefine existing pairs of page styles. You may use
      either\MessageBreak
      \string\newpairsofpagestyles, \string\defpairofpagestyles, or
      \string\providepairofpagestyles\MessageBreak
      with not yet defined page styles.\MessageBreak
      If you'll continue, your command will be ignored.%
    }%
  }{%
    \@ifundefined{ps@plain.#2}{%
      \PackageError{scrlayer-scrpage}{%
        Undefined plain page style of `#2'}{%
        You may only redefine existing pairs of page styles. You may use
        either\MessageBreak
        \string\defpairofpagestyles\space or
        \string\providepairofpagestyles\space with partly already
        defined\MessageBreak
        page styles.\MessageBreak
        If you'll continue, your command will be ignored.%
      }%
    }{\defpairofpagestyles[#1]{#2}{#3}}%
  }%
}%
\newcommand*{\providepairofpagestyles}[3][]{%
  \scr@ifundefinedorrelax{ps@#2}{%
    \@ifundefined{ps@plain.#2}{\defpairofpagestyles[#1]{#2}{#3}}{%
%<*trace>
      \PackageInfo{scrlayer-scrpage}{%
        Plain page style of `#2' already\MessageBreak
        defined. Definition ignored}%
%</trace>
    }%
  }{%
%<*trace>
    \PackageInfo{scrlayer-scrpage}{%
      Page style of `#2' already defined.\MessageBreak
      Definition ignored}%
%</trace>
  }%
}%
%</body>
%    \end{macrocode}
% \end{command}^^A \newpairofpagestyles … \providepairofpagestyles
%
%
% \begin{pgstyle}{scrheading,plain.scrheadings}
% We have one predefined pair: \texttt{scrheadings} with plain page style
% \texttt{plain.scrheadings}.
%    \begin{macrocode}
%<*body>
\newpairofpagestyles{scrheadings}{}%
%    \end{macrocode}
% \begin{pgstyle}{scrplain}
% But with package \pkg{scrpage2}
% the plain page style was \texttt{scrplain}. So we make a kind of alias:
%    \begin{macrocode}
\DeclarePageStyleAlias{scrplain}{plain.scrheadings}
%</body>
%    \end{macrocode}
% \end{pgstyle}^^A scrplain
% \end{pgstyle}^^A scrheadings,plain.scrheadings
%
%
% \begin{command}{\ihead,\ohead,\chead,
%                 \lehead,\lohead,\rehead,\rohead,\cehead,\cohead,
%                 \ifoot,\ofoot,\cfoot,
%                 \lefoot,\lofoot,\refoot,\rofoot,\cefoot,\cofoot}
% \changes{v3.14}{2014/09/19}{new star version double the argument}
% \changes{v3.20}{2016/04/12}{\cs{ifstar} replaced by \cs{kernel@ifstar}}
% We also need macros to define the contents of the three part head and
% foot. Each macro defines one of the part of head or foot of the
% \emph{headings} page style member and optional of the \emph{plain} page
% style member.
%    \begin{macrocode}
%<*body>
\newcommand*{\ihead}{\kernel@ifstar {\@dblarg\@@@ihead}{\@ihead}}%
%    \end{macrocode}
% \begin{macro}{\@ihead}
% \changes{v3.20}{2016/04/12}{\cs{@ifnextchar} replaced by
%   \cs{kernel@ifnextchar}}
% \begin{macro}{\@@ihead,\@@@ihead}
% \changes{v3.27}{2019/04/05}{long}
% Two helpers for the previous one to double the command and it's arguments.
%    \begin{macrocode}
\newcommand*{\@ihead}{\kernel@ifnextchar[{\@@@ihead}{\@@ihead}}%
\newcommand{\@@ihead}[1]{\rehead{#1}\lohead{#1}}%
\newcommand{\@@@ihead}[2][]{\rehead[{#1}]{#2}\lohead[{#1}]{#2}}%
%    \end{macrocode}
% \end{macro}^^A \@@ihead,\@@@ihead
% \end{macro}^^A \@ihead
%    \begin{macrocode}
\newcommand*{\ohead}{\kernel@ifstar {\@dblarg\@@@ohead}{\@ohead}}%
%    \end{macrocode}
% \begin{macro}{\@ohead}
% \changes{v3.20}{2016/04/12}{\cs{@ifnextchar} replaced by
%   \cs{kernel@ifnextchar}}
% \begin{macro}{\@@ohead,\@@@ohead}
% \changes{v3.27}{2019/04/05}{long}
% Two helpers for the previous one to double the command and it's arguments.
%    \begin{macrocode}
\newcommand*{\@ohead}{\kernel@ifnextchar[{\@@@ohead}{\@@ohead}}%
\newcommand{\@@ohead}[1]{\lehead{#1}\rohead{#1}}%
\newcommand{\@@@ohead}[2][]{\lehead[{#1}]{#2}\rohead[{#1}]{#2}}%
%    \end{macrocode}
% \end{macro}^^A \@@ohead,\@@@ohead
% \end{macro}^^A \@ohead
%    \begin{macrocode}
\newcommand*{\chead}{\kernel@ifstar {\@dblarg\@@@chead}{\@chead}}%
%    \end{macrocode}
% \begin{macro}{\@chead}
% \changes{v3.20}{2016/04/12}{\cs{@ifnextchar} replaced by
%   \cs{kernel@ifnextchar}}
% \begin{macro}{\@@chead,\@@@chead}
% \changes{v3.27}{2019/04/05}{long}
% Two helpers for the previous one to double the command and it's arguments.
%    \begin{macrocode}
\newcommand*{\@chead}{\kernel@ifnextchar[{\@@@chead}{\@@chead}}%
\newcommand{\@@chead}[1]{\cehead{#1}\cohead{#1}}%
\newcommand{\@@@chead}[2][]{\cehead[{#1}]{#2}\cohead[{#1}]{#2}}%
%    \end{macrocode}
% \end{macro}^^A \@@chead,\@@@chead
% \end{macro}^^A \@chead
%    \begin{macrocode}
\newcommand*{\lehead}{\sls@renewelement{even}{left}{head}}%
\newcommand*{\lohead}{\sls@renewelement{odd}{left}{head}}%
\newcommand*{\rehead}{\sls@renewelement{even}{right}{head}}%
\newcommand*{\rohead}{\sls@renewelement{odd}{right}{head}}%
\newcommand*{\cehead}{\sls@renewelement{even}{middle}{head}}%
\newcommand*{\cohead}{\sls@renewelement{odd}{middle}{head}}%
%    \end{macrocode}
%    \begin{macrocode}
\newcommand*{\ifoot}{\kernel@ifstar {\@dblarg\@@@ifoot}{\@ifoot}}%
%    \end{macrocode}
% \begin{macro}{\@ifoot}
% \changes{v3.20}{2016/04/12}{\cs{@ifnextchar} replaced by
%     \cs{kernel@ifnextchar}}
% \begin{macro}{\@@ifoot,\@@@ifoot}
% \changes{v3.27}{2019/04/05}{long}
% Two helpers for the previous one to double the command and it's arguments.
%    \begin{macrocode}
\newcommand*{\@ifoot}{\kernel@ifnextchar[{\@@@ifoot}{\@@ifoot}}%
\newcommand{\@@ifoot}[1]{\refoot{#1}\lofoot{#1}}%
\newcommand{\@@@ifoot}[2][]{\refoot[{#1}]{#2}\lofoot[{#1}]{#2}}%
%    \end{macrocode}
% \end{macro}^^A \@@ifoot,\@@@ifoot
% \end{macro}^^A \@ifoot
%    \begin{macrocode}
\newcommand*{\ofoot}{\kernel@ifstar {\@dblarg\@@@ofoot}{\@ofoot}}%
%    \end{macrocode}
% \begin{macro}{\@ofoot}
% \changes{v3.20}{2016/04/12}{\cs{@ifnextchar} replaced by
%   \cs{kernel@ifnextchar}}
% \begin{macro}{\@@ofoot,\@@@ofoot}
% \changes{v3.27}{2019/04/05}{long}
% Two helpers for the previous one to double the command and it's arguments.
%    \begin{macrocode}
\newcommand*{\@ofoot}{\kernel@ifnextchar[{\@@@ofoot}{\@@ofoot}}%
\newcommand{\@@ofoot}[1]{\lefoot{#1}\rofoot{#1}}%
\newcommand{\@@@ofoot}[2][]{\lefoot[{#1}]{#2}\rofoot[{#1}]{#2}}%
%    \end{macrocode}
% \end{macro}^^A \@@ofoot,\@@@ofoot
% \end{macro}^^A \@ofoot
%    \begin{macrocode}
\newcommand*{\cfoot}{\kernel@ifstar {\@dblarg\@@@cfoot}{\@cfoot}}%
%    \end{macrocode}
% \begin{macro}{\@cfoot}
% \changes{v3.20}{2016/04/12}{\cs{@ifnextchar} replaced by
%   \cs{kernel@ifnextchar}}
% \begin{macro}{\@@cfoot,\@@@cfoot}
% \changes{v3.27}{2019/04/05}{long}
% Two helpers for the previous one to double the command and it's arguments.
%    \begin{macrocode}
\newcommand*{\@cfoot}{\kernel@ifnextchar[{\@@@cfoot}{\@@cfoot}}%
\newcommand{\@@cfoot}[1]{\cefoot{#1}\cofoot{#1}}%
\newcommand{\@@@cfoot}[2][]{\cefoot[{#1}]{#2}\cofoot[{#1}]{#2}}%
%    \end{macrocode}
% \end{macro}^^A \@@cfoot,\@@@cfoot
% \end{macro}^^A \@cfoot
%    \begin{macrocode}
\newcommand*{\lefoot}{\sls@renewelement{even}{left}{foot}}%
\newcommand*{\lofoot}{\sls@renewelement{odd}{left}{foot}}%
\newcommand*{\refoot}{\sls@renewelement{even}{right}{foot}}%
\newcommand*{\rofoot}{\sls@renewelement{odd}{right}{foot}}%
\newcommand*{\cefoot}{\sls@renewelement{even}{middle}{foot}}%
\newcommand*{\cofoot}{\sls@renewelement{odd}{middle}{foot}}%
%    \end{macrocode}
% \begin{macro}{\sls@renewelement}
% \begin{macro}{\sls@@renewelement}
% \changes{v3.20}{2016/04/12}{\cs{@ifnextchar} replaced by
%   \cs{kernel@ifnextchar}}
% \changes{v3.20}{2016/04/12}{\cs{ifstar} replaced by \cs{kernel@ifstar}}
% \begin{macro}{\sls@@@renewelement,\sls@@@@renewelement,
%               \sls@@renewplainelement}
% \changes{v3.27}{2019/04/05}{long}
% Little helper for several of the above commands.
%    \begin{macrocode}
\newcommand*{\sls@renewelement}[3]{%
  \kernel@ifstar{\@dblarg{\sls@@@@renewelement{#1}{#2}{#3}}}%
                {\sls@@renewelement{#1}{#2}{#3}}%
}%
\newcommand*{\sls@@renewelement}[3]{%
  \kernel@ifnextchar[%]
  {\sls@@@@renewelement{#1}{#2}{#3}}%
  {\sls@@@renewelement{#1}{#2}{#3}}%
}%
\newcommand{\sls@@@renewelement}[4]{%
  \scr@ifundefinedorrelax{sls@ps@\sls@currentheadings @#1@#2@#3}{%
    \@namedef{sls@ps@scrheadings@#1@#2@#3}{#4}%
  }{%
    \@namedef{sls@ps@\sls@currentheadings @#1@#2@#3}{#4}%
  }%
}%
\newcommand*{\sls@@@@renewelement}{}
\long\def\sls@@@@renewelement#1#2#3[#4]#5{%
  \sls@@renewplainelement{#1}{#2}{#3}{#4}%
  \sls@@@renewelement{#1}{#2}{#3}{#5}%
}%
\newcommand{\sls@@renewplainelement}[4]{%
  \scr@ifundefinedorrelax{sls@ps@\sls@currentplain @#1@#2@#3}{%
    \@namedef{sls@ps@plain.scrheadings@#1@#2@#3}{#4}%
  }{%
    \@namedef{sls@ps@\sls@currentplain @#1@#2@#3}{#4}%
  }%
}%
%</body>
%    \end{macrocode}
% \end{macro}^^A \sls@@@renewelement … \sls@@renewplainelement
% \end{macro}^^A \sls@@renewelement
% \end{macro}^^A \sls@renewelement
% \end{command}^^A \ihead … \cofoot
%
%
% \begin{command}{\clearmainofpairofpagestyles}
% \begin{command}{\clearscrheadings}
% \changes{v3.32}{2020/09/11}{deprecation warning added}
% Maybe you want to clear the currently defined head and foot. First
% let's clear only scrheadings pagestyle but not scrplain pagestyle.
% We do this simply using the already known command:
%    \begin{macrocode}
%<*body>
\newcommand*{\clearmainofpairofpagestyles}{%
  \ihead{}\chead{}\ohead{}\ifoot{}\cfoot{}\ofoot{}%
}%
\newcommand*{\clearscrheadings}{%
  \PackageWarning{scrlayer-scrpage}{%
    replacing deprecated \string\clearscrheading\space by\MessageBreak
    \string\clearmainofpairofpagestyles
  }%
  \clearmainofpairofpagestyles
}
%</body>
%    \end{macrocode}
% \end{command}^^A \clearscrheadings
% \end{command}^^A \clearmainofpairofpagestyles
% \begin{command}{\clearplainofpairofpagestyles}
% \begin{command}{\clearscrplain}
% \changes{v3.32}{2020/09/11}{deprecation warning added}
% Now, we use the not recommended feature to set up a plain style:
%    \begin{macrocode}
%<*body>
\newcommand*{\clearplainofpairofpagestyles}{%
  \sls@@renewplainelement{odd}{left}{head}{}%
  \sls@@renewplainelement{odd}{right}{head}{}%
  \sls@@renewplainelement{odd}{middle}{head}{}%
  \sls@@renewplainelement{even}{left}{head}{}%
  \sls@@renewplainelement{even}{right}{head}{}%
  \sls@@renewplainelement{even}{middle}{head}{}%
  \sls@@renewplainelement{odd}{left}{foot}{}%
  \sls@@renewplainelement{odd}{right}{foot}{}%
  \sls@@renewplainelement{odd}{middle}{foot}{}%
  \sls@@renewplainelement{even}{left}{foot}{}%
  \sls@@renewplainelement{even}{right}{foot}{}%
  \sls@@renewplainelement{even}{middle}{foot}{}%
}%
\newcommand*{\clearscrplain}{%
  \PackageWarning{scrlayer-scrpage}{%
    replacing deprecated \string\clearscrplain\space by\MessageBreak
    \string\clearplainofpairofpagestyles
  }%
  \clearplainofpairofpagestyles
}
%</body>
%    \end{macrocode}
% \end{command}^^A \clearscrplain
% \end{command}^^A \clearplainofpairofpagestyles
% \begin{command}{\clearpairofpagestyles}
% \begin{command}{\clearscrheadfoot}
% \changes{v3.32}{2020/09/11}{deprecation warning added}
% Last but not least we clean up both, the main and the plain:
%    \begin{macrocode}
%<*body>
\newcommand*{\clearpairofpagestyles}{%
  \ihead[]{}\chead[]{}\ohead[]{}\ifoot[]{}\cfoot[]{}\ofoot[]{}%
}%
\newcommand*{\clearscrheadfoot}{%
  \PackageWarning{scrlayer-scrpage}{%
    replacing deprecated \string\clearscrheadfoot\space by\MessageBreak
    \string\clearpairofpagestyles
  }%
  \clearpairofpagestyles
}
%</body>
%    \end{macrocode}
% \end{command}^^A \clearscrheadfoot
% \end{command}^^A \clearpairofpagestyles
%
%
% \begin{pgstyle}{useheadings,plain.useheadings}
% Not longer supported:
%    \begin{macrocode}
%<*body>
\newcommand*\ps@useheadings{%
  \PackageWarning{scrlayer-scrpage}{incompatible page style!\MessageBreak
    Page styles like `headings' and `plain'\MessageBreak
    are incompatible with the page styles\MessageBreak
    of scrlayer-scrpage. You shouldn't mix\MessageBreak
    them up. Therefore page style\MessageBreak
    `useheadings' is not longer provided.\MessageBreak
    Usage is deprecated and will be replaced\MessageBreak
    by `scrheadings'%
  }%
  \let\ps@useheadings\ps@scrheadings
  \ps@useheadings
}%
\expandafter\newcommand\expandafter*\csname ps@plain.useheadings\endcsname{%
  \@nameuse{ps@plain.scrheadings}%
}%
%</body>
%    \end{macrocode}
% \end{pgstyle}^^A useheadings,plain.useheadings
%
%    \begin{macrocode}
%</interface>
%    \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: