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
|
% \iffalse meta-comment
% ======================================================================
% scrhack.dtx
% Copyright (c) Markus Kohm, 2008-2023
%
% This file is part of the LaTeX2e KOMA-Script bundle.
%
% This work may be distributed and/or modified under the conditions of
% the LaTeX Project Public License, version 1.3c of the license.
% The latest version of this license is in
% http://www.latex-project.org/lppl.txt
% and version 1.<3c or later is part of all distributions of LaTeX
% version 2005/12/01 or later and of this work.
%
% This work has the LPPL maintenance status "author-maintained".
%
% The Current Maintainer and author of this work is Markus Kohm.
%
% This work consists of all files listed in MANIFEST.md.
%
% To create `scrhack.sty' run `tex scrhack.dtx'. Using LaTeX instead
% of TeX would generate the implementation documentation.
% ======================================================================
%%% From File: $Id: scrhack.dtx 4032 2023-04-17 09:45:11Z kohm $
%<package&identify>%%% using: package,identify
%<package&option>%%% using: package,option
%<package&body>%%% using: package,body
%<package&identity>\NeedsTeXFormat{LaTeX2e}[1995/06/01]
%<*dtx>
\ifx\ProvidesFile\undefined\def\ProvidesFile#1[#2]{}\fi
\begingroup
\def\filedate$#1: #2-#3-#4 #5${\gdef\filedate{#2/#3/#4}}
\filedate$Date: 2023-04-17 11:45:11 +0200 (Mo, 17. Apr 2023) $
\def\filerevision$#1: #2 ${\gdef\filerevision{r#2}}
\filerevision$Revision: 4032 $
\endgroup
\ProvidesFile{scrhack.dtx}[\filedate\space\filerevision\space
%</dtx>
%<package&identify>\ProvidesPackage{scrhack}[%
%<hyperref&identify>\ProvidesFile{hyperref.hak}[%
%<float&identify>\ProvidesFile{float.hak}[%
%<floatrow&identify>\ProvidesFile{floatrow.hak}[%
%<listings&identify>\ProvidesFile{listings.hak}[%
%<setspace&identify>\ProvidesFile{setspace.hak}[%
%<lscape&identify>\ProvidesFile{lscape.hak}[%
%<nomencl&identify>\ProvidesFile{nomencl.hak}[%
%<standardsections&identify>\ProvidesFile{standardsections.hak}[%
%<*dtx|identify>
%!KOMAScriptVersion
%<*dtx>
source of
%</dtx>
%<*dtx|package>
package (hacking other packages)%
%</dtx|package>
%<*hack>
%<hack> scrhack part
%<!standardsections> (hacking package
%<hyperref&identify> hyperref)%
%<float&identify> float)%
%<floatrow&identify> floatrow)%
%<listings&identify> listings)%
%<setspace&identify> setspace)%
%<lscape&identify> lscape)%
%<nomencl&identify> nomencl)%
%<standardsections&identify> (defining standard LaTeX class section headings)%
%</hack>
]
%</dtx|identify>
%<*dtx>
\ifx\documentclass\undefined
\input scrdocstrip.tex
\@@input scrkernel-version.dtx
\@@input scrstrip.inc
\KOMAdefVariable{COPYRIGHTFROM}{2008}
\generate{\usepreamble\defaultpreamble
\file{scrhack.sty}{%
\from{scrkernel-version.dtx}{package,scrhack}%
\from{scrhack.dtx}{package,identify}%
\from{scrkernel-basics.dtx}{load}%
\from{scrhack.dtx}{package,option}%
\from{scrhack.dtx}{package,body}%
\from{scrlogo.dtx}{logo}%
}%
\file{hyperref.hak}{%
\from{scrkernel-version.dtx}{file,hyperref.hak}%
\from{scrhack.dtx}{hack,hyperref,identify}%
\from{scrhack.dtx}{hack,hyperref,body}%
}%
\file{float.hak}{%
\from{scrkernel-version.dtx}{file,float.hak}%
\from{scrhack.dtx}{hack,float,identify}%
\from{scrhack.dtx}{hack,float,body}%
}%
\file{floatrow.hak}{%
\from{scrkernel-version.dtx}{file,floatrow.hak}%
\from{scrhack.dtx}{hack,floatrow,identify}%
\from{scrhack.dtx}{hack,floatrow,body}%
}%
\file{listings.hak}{%
\from{scrkernel-version.dtx}{file,listings.hak}%
\from{scrhack.dtx}{hack,listings,identify}%
\from{scrhack.dtx}{hack,listings,body}%
}%
\file{setspace.hak}{%
\from{scrkernel-version.dtx}{file,setspace.hak}%
\from{scrhack.dtx}{hack,setspace,identify}%
\from{scrhack.dtx}{hack,setspace,body}%
}%
\file{lscape.hak}{%
\from{scrkernel-version.dtx}{file,lscape.hak}%
\from{scrhack.dtx}{hack,lscape,identify}%
\from{scrhack.dtx}{hack,lscape,body}%
}%
\file{nomencl.hak}{%
\from{scrkernel-version.dtx}{file,nomencl.hak}%
\from{scrhack.dtx}{hack,nomencl,identify}%
\from{scrhack.dtx}{hack,nomencl,body}%
}%
\file{standardsections.hak}{%
\from{scrkernel-version.dtx}{file,standardsections.hak}%
\from{scrhack.dtx}{hack,standardsections,identify}%
\from{scrhack.dtx}{hack,standardsections,body}%
}%
}
\@@input scrstrop.inc
\else
\let\endbatchfile\relax
\fi
\endbatchfile
\documentclass[USenglish]{koma-script-source-doc}
\usepackage{babel}
\setcounter{StandardModuleDepth}{2}
\begin{document}
\DocInput{scrhack.dtx}
\end{document}
%</dtx>
%\fi
%
% \changes{v3.03}{2009/03/12}{first version ever}
% \changes{v3.36}{2022/02/08}{switch over from \cls*{scrdoc} to
% \cls*{koma-script-source-doc}}
% \changes{v3.36}{2022/02/08}{require package \pkg*{scrlogo} instead of
% defining \cs{KOMAScript}}
% \changes{v3.36}{2022/02/08}{whole implementation documentation in English}
% \changes{v3.40}{2023/04/17}{guide names changed}
%
% \GetFileInfo{scrhack.dtx}
% \title{Patching Third-Party Packages using
% \href{https://komascript.de}{\KOMAScript} Package \pkg*{scrhack}}
% \author{\href{mailto:komascript@gmx.info}{Markus Kohm}}
% \date{Revision \fileversion{} of \filedate}
% \maketitle
% \begin{abstract}
% Some packages from other authors may have problems with \KOMAScript{}. In
% my opinion some packages could be improved. With some packages this makes
% only sense, if \KOMAScript{} was used. With some other packages the
% package author has another opinion. Sometimes proposals was never
% answered. Package \pkg*{scrhack} contains all those improvement proposals
% for other packages. This means, \pkg*{scrhack} redefines macros of packages
% from other authors! The redefinitions are only activated, if those
% packages were loaded. Users may prevent \pkg*{scrhack} from redefining
% macros of individual packages.
% \end{abstract}
% \tableofcontents
%
% \section{User Manual}
%
% You can find the user manuals of \pkg*{scrhack} in the \KOMAScript{} manual,
% either the German \file{scrguide-de.pdf} or the English
% \file{scrguide-en.pdf}.
%
% \MaybeStop{\PrintIndex}
%
% \section{Implementation of \pkg*{scrhack}}
%
% \changes{v3.04b}{2009/08/05}{order of commands/macros and options changed}
%
% \subsection{Optionen}
%
% The package uses \cs{KOMAoptions} of \pkg*{scrkbase}, which is loaded by
% (virtual) \file{scrkbase.ins}.
%
% The options allow the selection of the used manipulations of other
% packages. But all these options are valid only until both \pkg*{scrhack} and
% the other package has been loaded. Later settings are invalid.
%
%
% \subsection{Used Macros and Commands}
% \label{sec:macros}
% \begin{macrocode}
%<*package&body>
% \end{macrocode}
%
% \begin{macro}{\scr@ifexpected}
% Mentioned to do (re)definitions only, if local execution of code does not
% change a command. Concrete, if (local) execution of \marg{test code} of
% \begin{quote}
% \cs{scr@ifexpected}\marg{command}\marg{test code}\marg{then
% code}\marg{else code}
% \end{quote}
% would not result in a change of \cs{\meta{command}}, the \marg{then code}
% will be executed, otherwise the \marg{else code}.
% \begin{description}\item[Note:] \meta{test code} must not have any global
% side effect!\end{description}
% \begin{macrocode}
\newcommand{\scr@ifexpected}[2]{%
\begingroup
\let\@tempa#1
#2
\ifx\@tempa#1
\aftergroup\@firstoftwo
\else
\aftergroup\@secondoftwo
\fi
\endgroup
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\scr@hack@load}
% Conditionally loading of a hack file.
% \begin{quote}
% \cs{scr@hack@load}\marg{extension}\marg{basename}\marg{hack}%
% \marg{true code}\marg{false code}
% \end{quote}
% The first two arguments \marg{} and \marg{extension} and \marg{basename} are
% same to the internal\LaTeX{} kernel command \cs{@ifl@aded}. With \LaTeX{}
% from 2021/11/15 we even could use \cs{@ifl@aded} for the test, because it is
% not restricted to the preamble any more. But because it is restricted with
% older \LaTeX{} kernels, we test the definition of
% \cs{ver@}\meta{basename}\texttt{.}\meta{extension}. If it is defined, we
% also test the definition of \cs{ver@}\meta{basename}\texttt{.hak}. If this
% is not defined, \file{\meta{hack}.hak} is loaded and \meta{true code} is
% executed. Otherwise \meta{false code} is executed. This means: A hack file
% is only loaded, if a class or package (or other file with version) has
% already been loaded, but the hack file has not already been loaded.
% \begin{macrocode}
\newcommand*{\scr@hack@load}[2]{%
\expandafter\ifx\csname ver@#2.#1\endcsname\relax
\expandafter\@secondoftwo
\else
% \end{macrocode}
% Load a hack only once.
% \begin{macrocode}
\expandafter\ifx\csname ver@#2.hak\endcsname\relax
\expandafter\expandafter\expandafter\@firstoftwo
\else
\expandafter\expandafter\expandafter\@secondoftwo
\fi
\fi
{%
\PackageInfo{scrhack}{loading #2 hack}%
\edef\reserved@a{%
\noexpand\makeatletter\noexpand\input{#2.hak}%
\noexpand\catcode`\noexpand\@\the\catcode`\@\relax
}\reserved@a
}{%
\PackageInfo{scrhack}{ignorring #2 hack}%
}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macrocode}
%</package&body>
% \end{macrocode}
%
% \subsection{The \pkg*{hyperref} hack}
%
% Package \pkg{hyperref} places the anchor of the star variant of a heading
% after the heading, but the anchor of the normal variant before the heading
% even if the heading is not numbered because of the value of
% \cnt{secnumdepth}. The hack changes this to more consistent placing always
% before the heading.
%
% \begin{option}{hyperref}
% \changes{v3.12}{2013/03/05}{using \cs{FamilyKeyStateProcessed}}
% \changes{v3.17}{2015/03/09}{defaults by \cs{KOMAExecuteOptions}}
% \begin{macrocode}
%<*package&option>
\KOMA@ifkey{hyperref}{@scrhack@hyperref}%
\KOMAExecuteOptions{hyperref=true}%
%</package&option>
% \end{macrocode}
% \changes{v3.04b}{2009/11/09}{loading \pkg{hyperref} hack earlier}
% \changes{v3.17}{2015/03/09}{auto deactivation for newer versions of
% \pkg{hyperref}}
% \changes{v3.18}{2015/05/22}{newer versions of \KOMAScript{} classes also
% deactivate the the hack}
% \changes{v3.39}{2022/11/11}{initial dot in member argument of \cs{KOMA@key}
% and \cs{KOMAExecuteOptions} removed}
% This is a little bit tricky, because \pkg{hyperref} loads the driver file
% via \cs{AtEndOfPackage} and the hack cannot be loaded before loading the
% driver file. Using \cs{AfterPackage*} would not be good enough therefore,
% because it would load the hack before the driver file. But using
% \cs{AtEndOfPackage} inside \cs{AfterPackage*} should delay the loading
% enough. This also works, if \pkg{hyperref} has already been loaded. In this
% case the code will be executed at the end of \pkg*{scrhack} instead of
% \pkg{hyperref}. This is no problem.
% \begin{macrocode}
%<*package&body>
\BeforePackage{hyperref}{%
\scr@ifundefinedorrelax{hy@insteadofrefstepcounter}{}{%
\PackageInfo{scrhack}{hyperref hack deactivated because of\MessageBreak
detection of KOMA-Script class, that doesn't\MessageBreak
need that hack,}%
\KOMAExecuteOptions[scrhack.sty]{hyperref=false}%
}%
}
\AfterPackage*{hyperref}{%
\if@scrhack@hyperref
\@ifpackagelater{hyperref}{2009/11/24}{%
\PackageInfo{scrhack}{hyperref hack deactivated because of\MessageBreak
detection of hyperref version, that doesn't\MessageBreak
need that hack,}%
\KOMAExecuteOptions[scrhack.sty]{hyperref=false}%
}{%
\AtEndOfPackage{%
\KOMA@key[scrhack.sty]{hyperref}{%
\PackageWarning{scrhack}{option `hyperref=#1' ignored}%
\FamilyKeyStateProcessed
}%
\if@scrhack@hyperref\scr@hack@load\@pkgextension{hyperref}\fi
}%
}%
\fi
}
%</package&body>
% \end{macrocode}
% \end{option}
%
%
% \begin{macro}{\@schapter,\@spart,\@ssect}
% We do not hack \pkg{hyperref} itself, but the driver files. After loading
% \pkg{hyperref} the driver file is also loaded. Moreover, all driver files
% that re-define these commands have to be patched also. So the patch is
% related to the loading of \pkg{hyperref} instead of every single driver
% file. This have already been tested by \cs{scr@hack@load}. So we just have
% to test, whether the definition of these commands are the expected one.
% derzeit den erwarteten Inhalt haben.
% \begin{macrocode}
%<*hyperref&body>
\scr@ifexpected\@schapter{%
\def\@schapter#1{%
\H@old@schapter{#1}%
\begingroup
\let\@mkboth\@gobbletwo
\Hy@GlobalStepCount\Hy@linkcounter
\xdef\@currentHref{\Hy@chapapp*.\the\Hy@linkcounter}%
\Hy@raisedlink{%
\hyper@anchorstart{\@currentHref}\hyper@anchorend
}%
\endgroup
}%
}{%
\PackageInfo{scrhack}{redefining \string\@schapter}%
\def\@schapter#1{%
\begingroup
\let\@mkboth\@gobbletwo
\Hy@GlobalStepCount\Hy@linkcounter
\xdef\@currentHref{\Hy@chapapp*.\the\Hy@linkcounter}%
\Hy@raisedlink{%
\hyper@anchorstart{\@currentHref}\hyper@anchorend
}%
\endgroup
\H@old@schapter{#1}%
}%
}{%
\scr@ifexpected\@schapter{%
\def\@schapter#1{%
\begingroup
\let\@mkboth\@gobbletwo
\Hy@GlobalStepCount\Hy@linkcounter
\xdef\@currentHref{\Hy@chapapp*.\the\Hy@linkcounter}%
\Hy@raisedlink{%
\hyper@anchorstart{\@currentHref}\hyper@anchorend
}%
\endgroup
\H@old@schapter{#1}%
}%
}{}{%
\PackageWarningNoLine{scrhack}{unknown \string\@schapter\space
definition found!\MessageBreak
Maybe you are using a unsupported hyperref version}%
}%
}
\scr@ifexpected\@spart{%
\def\@spart#1{%
\H@old@spart{#1}%
\Hy@GlobalStepCount\Hy@linkcounter
\xdef\@currentHref{part*.\the\Hy@linkcounter}%
\Hy@raisedlink{%
\hyper@anchorstart{\@currentHref}\hyper@anchorend
}%
}%
}{%
\PackageInfo{scrhack}{redefining \string\@spart}%
\def\@spart#1{%
\Hy@GlobalStepCount\Hy@linkcounter
\xdef\@currentHref{part*.\the\Hy@linkcounter}%
\Hy@raisedlink{%
\hyper@anchorstart{\@currentHref}\hyper@anchorend
}%
\H@old@spart{#1}%
}%
}{%
\scr@ifexpected\@spart{%
\def\@spart#1{%
\Hy@GlobalStepCount\Hy@linkcounter
\xdef\@currentHref{part*.\the\Hy@linkcounter}%
\Hy@raisedlink{%
\hyper@anchorstart{\@currentHref}\hyper@anchorend
}%
\H@old@spart{#1}%
}%
}{}{%
\PackageWarningNoLine{scrhack}{unknown \string\@spart\space
definition found!\MessageBreak
Maybe you are using a unsupported hyperref version}%
}%
}
\scr@ifexpected\@ssect{%
\def\@ssect#1#2#3#4#5{%
\H@old@ssect{#1}{#2}{#3}{#4}{#5}%
\phantomsection
}%
}{%
\PackageInfo{scrhack}{redefining \string\@ssect}%
\def\@ssect#1#2#3#4#5{%
\H@old@ssect{#1}{#2}{#3}{#4}{\phantomsection\ignorespaces#5}%
}%
}{%
\scr@ifexpected\@ssect{%
\def\@ssect#1#2#3#4#5{%
\H@old@ssect{#1}{#2}{#3}{#4}{\phantomsection\ignorespaces#5}%
}%
}{}{%
\PackageWarningNoLine{scrhack}{unknown \string\@ssect\space
definition found!\MessageBreak
Maybe you are using a unsupported hyperref version}%
}%
}
%</hyperref&body>
% \end{macrocode}
% \end{macro}
%
%
% \subsection{The \pkg*{floatrow} hack}
%
% Package \pkg{floatrow} insists in using \cs{float@listhead} for the setting
% of the headings. This is not recommended any longer since \KOMAScript~2.95
% from July 2006! The \KOMAScript{} classes will remove the support for
% this very limited approach. Recommended is the usage of \pkg*{tocbasic}. The
% effort to do so, it very small and I do not understand, why package authors
% are not willing to use it. Because the benefit would be a lot.
%
% This hack adds \pkg*{tocbasic} usage to \pkg{floatrow}. Nevertheless it is
% more complicated than adding \pkg*{tocbasic} support into \pkg{floatrow}.
%
% \begin{option}{floatrow}
% \changes{v3.12}{2013/03/05}{using \cs{FamilyKeyStateProcessed}}
% \changes{v3.17}{2015/03/09}{using \cs{KOMAExecuteOptions}}
% \changes{v3.34}{2021/06/03}{deactivation of the \pkg{float} hack}
% \changes{v3.39}{2022/11/11}{initial dot in member argument of \cs{KOMA@key}
% removed}
% \begin{macrocode}
%<*package&option>
\KOMA@ifkey{floatrow}{@scrhack@floatrow}
\KOMAExecuteOptions{floatrow=true}
%</package&option>
%<*package&body>
\AfterPackage*{floatrow}{%
\KOMAoptions{float=false}%
\PackageInfo{scrhack}{option `float' deactivated}%
\KOMA@key[scrhack.sty]{floatrow}{%
\PackageWarning{scrhack}{option `floatrow' ignored}%
\FamilyKeyStateProcessed
}%
\if@scrhack@floatrow\scr@hack@load\@pkgextension{floatrow}\fi
}
%</package&body>
% \end{macrocode}
% \end{option}
%
%
% \begin{command}{\DeclareNewFloatType,\listof}
% \changes{v3.25}{2018/03/16}{using \cs{DeclareTOCStyleEntry}}
% Command \cs{DeclareNewFloatType} is used to define a new float
% environment. We have to add registration of the file extension (third
% argument) with \pkg*{tocbasic}.
% Command \cs{listof} outputs the list of the float environments. Here we
% just use the corresponding macro of \pkg*{tocbasic}.
% \begin{macro}{\float@addtolists}
% The deprecated macro \cs{float@addtolists} is not needed any longer an will
% be reset to the original definition.
% \begin{macrocode}
%<*floatrow&body>
\scr@ifexpected{\DeclareNewFloatType}{%
\long\def\DeclareNewFloatType#1#2{\def\FB@captype{#1}%
\expandafter\edef\csname ftype@#1\endcsname{\the\c@float@type}%
\addtocounter{float@type}{\value{float@type}}%
\@namedef{#1name}{#1}\newcounter{#1}%
\expandafter\edef\csname fnum@#1\endcsname
{\expandafter\noexpand\csname #1name\endcsname\nobreakspace
\expandafter\noexpand\csname the#1\endcsname}%
\@namedef{the#1}{\arabic{#1}}\flnew@ext{lo#1}\@namedef{fps@#1}{tbp}%
\@namedef{l@#1}{\@dottedtocline{1}{1.5em}{2.3em}}%
\caption@setkeys[floatrow]{newfloat}{#2}\let\FR@tmp=\relax
\xdef\@tempa{\noexpand\flrow@types{\the\flrow@types \FR@tmp{#1}}}%
\@tempa}%
}{%
\scr@ifexpected{\listof}{%
\def\listof#1#2{%
\@ifundefined{ext@#1}{\flrow@error{Unknown float style `#1'}}{%
\expandafter\providecommand\csname l@#1\endcsname
{\@dottedtocline{1}{1.5em}{2.3em}}%
\float@listhead{#2}%
\begingroup\setlength{\parskip}{\z@}%
\@starttoc{\@nameuse{ext@#1}}%
\endgroup}}%
}{%
\RequirePackage{tocbasic}%
\PackageInfo{scrhack}{redefining \string\DeclareNewFloatType}%
% \end{macrocode}
% \begin{description}
% \item[Note:] It would be better to first test, if the new extension is
% already in use like done at the \pkg{float} hack. But I don't know the
% \pkg{floatrow} code good enough to make such a change!
% \end{description}
% \begin{macrocode}
\renewcommand\DeclareNewFloatType[2]{\def\FB@captype{#1}%
\expandafter\edef\csname ftype@#1\endcsname{\the\c@float@type}%
\addtocounter{float@type}{\value{float@type}}%
\@namedef{#1name}{#1}\newcounter{#1}%
\expandafter\edef\csname fnum@#1\endcsname
{\expandafter\noexpand\csname #1name\endcsname\nobreakspace
\expandafter\noexpand\csname the#1\endcsname}%
\@namedef{the#1}{\arabic{#1}}\flnew@ext{lo#1}\@namedef{fps@#1}{tbp}%
\DeclareTOCStyleEntry[level=1,numwidth=2.3em,indent=1.5em]{default}{#1}%
\caption@setkeys[floatrow]{newfloat}{#2}\let\FR@tmp=\relax
\xdef\@tempa{\noexpand\flrow@types{\the\flrow@types \FR@tmp{#1}}}%
\@tempa
\xdef\@tempa{\noexpand\addtotoclist[float]{\@nameuse{ext@\FB@captype}}%
\noexpand\setuptoc{\@nameuse{ext@\FB@captype}}{chapteratlist}%
}%
\@tempa
}%
\PackageInfo{scrhack}{redefining \string\listof}%
\renewcommand*\listof[2]{%
\@ifundefined{ext@#1}{\flrow@error{Unknown float style `#1'}}{%
\@ifundefined{l@#1}{\expandafter\let\csname l@#1\endcsname\l@figure
\@ifundefined{l@#1}{%
\DeclareTOCStyleEntry[level=1,numwidth=2.3em,indent=1.5em]
{default}{#1}%
}{}%
}{}%
\listoftoc[{#2}]{\csname ext@#1\endcsname}%
}%
}%
\scr@ifexpected{\float@addtolists}{%
\long\def\float@addtolists#1{%
\def\float@do##1{\addtocontents{##1}{#1}} \the\float@exts}%
}{%
\PackageInfo{scrhack}{undefining \string\float@addtolists}%
\let\float@addtolists\relax
}{%
\PackageWarningNoLine{scrhack}{unkown \string\float@addtolists\space
definition found!\MessageBreak
Maybe you are using a unsupported floatrow version}%
}%
}{%
\PackageWarningNoLine{scrhack}{unknown \string\listof\space
definition found!\MessageBreak
Maybe you are using a unsupported floatrow version}%
}%
}{%
\PackageWarningNoLine{scrhack}{unknown \string\DeclareNewFloatType\space
definition found!\MessageBreak
Maybe you are using a unsupported floatrow version}%
}
%</floatrow&body>
% \end{macrocode}
% \end{macro}
% \end{command}
%
%
% \subsection{The \pkg*{float} hack}
%
% Package \pkg{float} insists in using \cs{float@listhead} for the setting
% of the headings. This is not recommended any longer since \KOMAScript~2.95
% from July 2006! The \KOMAScript{} classes will remove the support for
% this very limited approach. Recommended is the usage of \pkg*{tocbasic}. The
% effort to do so, it very small and I do not understand, why package authors
% are not willing to use it. Because the benefit would be a lot.
%
% This hack adds \pkg*{tocbasic} usage to \pkg{float}. Nevertheless it is
% more complicated than adding \pkg*{tocbasic} support into \pkg{float}.
%
% \begin{option}{float}
% \changes{v3.12}{2013/03/05}{using \cs{FamilyKeyStateProcessed}}
% \changes{v3.17}{2015/03/09}{using \cs{KOMAExecuteOptions}}
% \changes{v3.39}{2022/11/11}{initial dot in member argument of \cs{KOMA@key}
% removed}
% \begin{macrocode}
%<*package&option>
\KOMA@ifkey{float}{@scrhack@float}%
\KOMAExecuteOptions{float=true}%
%</package&option>
%<*package&body>
\AfterPackage*{float}{%
\KOMA@key[scrhack.sty]{float}{%
\PackageWarning{scrhack}{option `float' ignored}%
\FamilyKeyStateProcessed
}%
\if@scrhack@float\scr@hack@load\@pkgextension{float}\fi
}
%</package&body>
% \end{macrocode}
% \end{option}
%
%
% \begin{command}{\newfloat}
% \changes{v3.28}{2019/11/19}{\cs{ifattoclist} replaced by
% \cs{Ifattoclist}}
% \changes{v3.25}{2018/03/16}{using \cs{DeclareTOCStyleEntry}}
% We have to add registration of the file extension (third argument of
% \cs{newfloat}) with \pkg*{tocbasic}.
% \begin{command}{\listof}
% Command \cs{listof} outputs the list of the float environments. Here we
% just use the corresponding macro of \pkg*{tocbasic}.
% \begin{macro}{\float@addtolists}
% The deprecated macro \cs{float@addtolists} is not needed any longer an will
% be reset to the original definition.
% \begin{macrocode}
%<*float&body>
\scr@ifexpected{\newfloat}{%
\long\def\newfloat#1#2#3{\@namedef{ext@#1}{#3}
\let\float@do=\relax
\xdef\@tempa{\noexpand\float@exts{\the\float@exts \float@do{#3}}}%
\@tempa
\floatplacement{#1}{#2}%
\@ifundefined{fname@#1}{\floatname{#1}{#1}}{}
\expandafter\edef\csname ftype@#1\endcsname{\value{float@type}}%
\addtocounter{float@type}{\value{float@type}}
\restylefloat{#1}%
\expandafter\edef\csname fnum@#1\endcsname%
{\expandafter\noexpand\csname fname@#1\endcsname{}
\expandafter\noexpand\csname the#1\endcsname}
\@ifnextchar[%]
{\float@newx{#1}}%
{\@ifundefined{c@#1}{\newcounter{#1}\@namedef{the#1}{\arabic{#1}}}%
{}}}%
}{%
\scr@ifexpected{\listof}{%
\def\listof#1#2{%
\@ifundefined{ext@#1}{\float@error{#1}}{%
\@namedef{l@#1}{\@dottedtocline{1}{1.5em}{2.3em}}%
\float@listhead{#2}%
\begingroup\setlength{\parskip}{\z@}%
\@starttoc{\@nameuse{ext@#1}}%
\endgroup}}%
}{%
\RequirePackage{tocbasic}%
\PackageInfo{scrhack}{redefining \string\newfloat}%
\renewcommand\newfloat[3]{%
\Ifattoclist{#3}{%
\PackageError{scrhack}{extension `#3' already in use}{%
Each extension may be used only once.\MessageBreak
You, the class, or another package already uses extension
`#3'.\MessageBreak
\string\newfloat\space command will be ignored!}%
}{%
\addtotoclist[float]{#3}%
\setuptoc{#3}{chapteratlist}%
\@namedef{ext@#1}{#3}%
\let\float@do=\relax
\xdef\@tempa{\noexpand\float@exts{\the\float@exts \float@do{#3}}}%
\@tempa
\floatplacement{#1}{#2}%
\@ifundefined{fname@#1}{\floatname{#1}{#1}}{}%
\expandafter\edef\csname ftype@#1\endcsname{\value{float@type}}%
\addtocounter{float@type}{\value{float@type}}
\restylefloat{#1}%
\expandafter\edef\csname fnum@#1\endcsname%
{\expandafter\noexpand\csname fname@#1\endcsname{}
\expandafter\noexpand\csname the#1\endcsname}%
\@ifnextchar[%]
{\float@newx{#1}}%
{\@ifundefined{c@#1}{\newcounter{#1}\@namedef{the#1}{\arabic{#1}}}%
{}}}%
}%
\PackageInfo{scrhack}{redefining \string\listof}%
\renewcommand*\listof[2]{%
\@ifundefined{ext@#1}{\float@error{#1}}{%
\@ifundefined{l@#1}{\expandafter\let\csname l@#1\endcsname\l@figure
\@ifundefined{l@#1}{%
\DeclareTOCStyleEntry[level=1,numwidth=2.3em,indent=1.5em]
{default}{#1}%
}{}%
}{}%
\listoftoc[{#2}]{\csname ext@#1\endcsname}%
}%
}%
\scr@ifexpected{\float@addtolists}{%
\long\def\float@addtolists#1{%
\def\float@do##1{\addtocontents{##1}{#1}} \the\float@exts}%
}{%
\PackageInfo{scrhack}{undefining \string\float@addtolists}%
\let\float@addtolists\relax
}{%
\PackageWarningNoLine{scrhack}{unkown \string\float@addtolists\space
definition found!\MessageBreak
Maybe you are using a unsupported float version}%
}%
}{%
\PackageWarningNoLine{scrhack}{unknown \string\listof\space
definition found!\MessageBreak
Maybe you are using a unsupported float version}%
}%
}{%
\PackageWarningNoLine{scrhack}{unknown \string\newfloat\space
definition found!\MessageBreak
Maybe you are using a unsupported float version}%
}
%</float&body>
% \end{macrocode}
% \end{macro}
% \end{command}
% \end{command}
%
%
% \subsection{The \pkg*{listings} hack}
%
% Package \pkg{listing} insists in using \cs{float@listhead} for the setting
% of the headings. This is not recommended any longer since \KOMAScript~2.95
% from July 2006! The \KOMAScript{} classes will remove the support for
% this very limited approach. Recommended is the usage of \pkg*{tocbasic}. The
% effort to do so, it very small and I do not understand, why package authors
% are not willing to use it. Because the benefit would be a lot.
%
% This hack adds \pkg*{tocbasic} usage to \pkg{listings}. Nevertheless it is
% more complicated than adding \pkg*{tocbasic} support into \pkg{listings}.
%
% \begin{option}{listings}
% \changes{v3.12}{2013/03/05}{using \cs{FamilyKeyStateProcessed}}
% \changes{v3.17}{2015/03/09}{using \cs{KOMAExecuteOptions}}
% \changes{v3.39}{2022/11/11}{initial dot in member argument of \cs{KOMA@key}
% removed}
% \begin{macrocode}
%<*package&option>
\KOMA@ifkey{listings}{@scrhack@listings}
\KOMAExecuteOptions{listings=true}
%</package&option>
%<*package&body>
\AfterPackage*{listings}{%
\KOMA@key[scrhack.sty]{listings}{%
\PackageWarning{scrhack}{option `listings' ignored}%
\FamilyKeyStateProcessed
}%
\if@scrhack@listings\scr@hack@load\@pkgextension{listings}\fi
}
%</package&body>
% \end{macrocode}
% \end{option}
%
%
% \begin{macro}{\scr@do@hack@listings}
% \begin{command}{\lstlistoflistings}
% \cs{scr@do@hack@listings} patches \pkg{listings} to use \pkg*{tocbasic} for
% the whole output of the list of listings. This adds several new features to
% \pkg{listings}.
% \begin{macro}{\float@addtolists}
% The deprecated macro \cs{float@addtolists} is not needed any longer an will
% be reset to the original definition. But, because \pkg{listings} delays the
% redefinition with \cs{AtBeginDocument} we have to do the same here.
% \begin{macrocode}
%<*listings&body>
\newcommand*{\scr@do@hack@listings}{%
\RequirePackage{tocbasic}%
\addtotoclist[float]{lol}%
\setuptoc{lol}{chapteratlist}%
\PackageInfo{scrhack}{redefining \string\lstlistoflistings}%
\renewcommand*{\lstlistoflistings}{\listoftoc[{\lstlistlistingname}]{lol}}%
\AtBeginDocument{%
\scr@ifexpected{\float@addtolists}{%
\def\float@addtolists##1{\addtocontents{lol}{##1}}%
}{%
\PackageInfo{scrhack}{undefining \string\float@addtolists}%
\let\float@addtolists\relax
}{%
\scr@ifexpected{\float@addtolists}{%
\def\float@addtolists##1{\addtocontents{lol}{##1}%
\orig@float@addtolists{##1}}%
}{%
\PackageInfo{scrhack}{setting \string\float@addtolists\MessageBreak
to \string\orig@float@addtolists}%
\let\float@addtolists\orig@float@addtolists
}{%
\PackageWarningNoLine{scrhack}{unkown \string\float@addtolists\space
definition found!\MessageBreak
Maybe you are using a unsupported listings version}%
}%
}%
}%
% \end{macrocode}
% \begin{macro}{\lst@makecaption}
% \changes{v3.30}{2020/04/01}{setting of \cs{@captype} added}
% From version~3.30 setting of \cs{@captype} to \texttt{lstlisting} is added
% to \cs{lst@makecaption}. This adds support for usage of
% \cs{raggedlstlistingcaption} (if the user or a package author defines
% it). The change is a little bit dangerous, because it will break, if
% \pkg{listings} would add an argument to \cs{lst@makecaption}.
% \begin{macrocode}
\expandafter\def\expandafter\lst@makecaption\expandafter{%
\expandafter\def\expandafter\@captype\expandafter{%
\expandafter l\expandafter s\expandafter t\expandafter l%
\expandafter i\expandafter s\expandafter t\expandafter i%
\expandafter n\expandafter g\expandafter}\lst@makecaption
}%
\let\scr@do@hack@listings\relax
}
\scr@ifexpected{\lstlistoflistings}{%
\def\lstlistoflistings{\bgroup
\let\contentsname\lstlistlistingname
\let\lst@temp\@starttoc \def\@starttoc##1{\lst@temp{lol}}%
\tableofcontents \egroup}%
}{%
\scr@do@hack@listings
}{%
\scr@ifexpected{\lstlistoflistings}{%
\def\lstlistoflistings{%
\begingroup
\@ifundefined{@restonecoltrue}{}{%
\if@twocolumn
\@restonecoltrue\onecolumn
\else
\@restonecolfalse
\fi
}%
\float@listhead{\lstlistlistingname}%
\parskip\z@\parindent\z@\parfillskip \z@ \@plus 1fil%
\@starttoc{lol}%
\@ifundefined{@restonecoltrue}{}{%
\if@restonecol\twocolumn\fi
}%
\endgroup
}%
}{%
\scr@do@hack@listings
}{%
\PackageWarningNoLine{scrhack}{unknown \string\lstlistoflistings\space
definition found!\MessageBreak
Maybe you are using a unsupported listings version}%
}%
}
%</listings&body>
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{command}
% \end{macro}
%
%
%
% \subsection{The \pkg*{nomencl} hack}
%
% With package \pkg{nomencl} and the \KOMAScript{} classes there is only a
% small disharmony between relating the ToC entry. Nevertheless the package
% can benefit from using \pkg*{tocbasic}.
%
% This hack adds \pkg*{tocbasic} usage to \pkg{nomencl}. This is done using
% \pkg{xpatch} Nevertheless it is much more complicated than adding real
% \pkg*{tocbasic} support into \pkg{nomencl}. The mess is, that every new
% release of \pkg{nomencl} changes the kind of ``support'' of
% \pkg*{tocbasic}. For some versions there isn't any such support. Other
% versions use \pkg*{tocbasic} if it has been loaded. Other versions need an
% option to activate usage of \pkg*{tocbasic}. So don't expect that the
% following hack does the correct thing for every version of \pkg{nomencl}!
%
% \begin{option}{nomencl}
% \changes{v3.23}{2017/03/31}{added}
% \changes{v3.39}{2022/11/11}{initial dot in member argument of \cs{KOMA@key}
% removed}
% \begin{macrocode}
%<*package&option>
\RequirePackage{xpatch}%
\KOMA@ifkey{nomencl}{@scrhack@nomencl}
\KOMAExecuteOptions{nomencl=true}
%</package&option>
%<*package&body>
\AfterPackage*{nomencl}{%
\KOMA@key[scrhack.sty]{nomencl}{%
\PackageWarning{scrhack}{option `nomencl' ignored}%
\FamilyKeyStateProcessed
}%
\if@scrhack@nomencl\scr@hack@load\@pkgextension{nomencl}\fi
}
%</package&body>
% \end{macrocode}
% \end{option}^^A nomencl
%
% \begin{command}{\thenomenclature}
% \changes{v3.23}{2017/03/31}{added}
% Instead of using the several definitions by cases of the several versions of
% \pkg{nomencl} we use a patch, that should remove all such cases and use
% \pkg*{tocbasic} always.
% \begin{macrocode}
%<*nomencl&body>
\RequirePackage{tocbasic}
% \end{macrocode}
% With \pkg{nomencl} > 5.0 this should be all.
% Unfortunately is isn't, because newer versions of \pkg{nomencl} need option
% \opt{tocbasic} to be set. Good luck: It is the default. So the chances
% are good, that with new versions of \pkg{nomencl} usage of \pkg*{tocbasic} is
% the default.
% \begin{macrocode}
\@ifpackagelater{nomencl}{2019/01/01}{%
\PackageInfo{scrhack}{only `tocbasic' loaded for `nomencl'}%
\expandafter\endinput
}{}
% \end{macrocode}
% Otherwise we have to patch it.
% \begin{macrocode}
\addtotoclist[nomencl]{nlo}
\addtotoclist[nomencl]{nls}
\xpatchcmd{\thenomenclature}{%
\@ifundefined{chapter}%
{
\section*{\nomname}
\if@intoc\addcontentsline{toc}{section}{\nomname}\fi%
}%
{
\chapter*{\nomname}
\if@intoc\addcontentsline{toc}{chapter}{\nomname}\fi%
}%
}{%
\scr@hack@nomencl@head
}{%
\PackageInfo{scrhack}{\string\thenomenclature\space successfully patched}%
}{%
% \end{macrocode}
% \changes{v3.26b}{2019/01/23}{new \pkg{nomencl} 5.0}
% From \pkg{nomencl} 5.0 another code is used if the nomenclature is a
% chapter. So we need another patch:
% \begin{macrocode}
\xpatchcmd{\thenomenclature}{%
\@ifundefined{chapter}%
{
\section*{\nomname}
\if@intoc\addcontentsline{toc}{section}{\nomname}\fi%
}%
{
\chapter*{\nomname}
\markboth{\nomname}{\nomname}%
\if@intoc\addcontentsline{toc}{chapter}{\nomname}\fi%
}%
}{%
\scr@hack@nomencl@head
}{%
\PackageInfo{scrhack}{\string\thenomenclature\space successfully patched}%
}{%
% \end{macrocode}
% \changes{v3.26b}{2019/01/23}{prepared for hoply comming \pkg{nomencl}}
% But this code is also wrong, because it breaks manual running heads, e.g.,
% of page style \texttt{myheadings}. So I hope, there will be another code,
% that needs a somehow different patch:
% \begin{macrocode}
\xpatchcmd{\thenomenclature}{%
\@ifundefined{chapter}%
{
\section*{\nomname}
\if@intoc\addcontentsline{toc}{section}{\nomname}\fi%
}%
{
\chapter*{\nomname}
\@mkboth{\nomname}{\nomname}%
\if@intoc\addcontentsline{toc}{chapter}{\nomname}\fi%
}%
}{%
\scr@hack@nomencl@head
}{%
\PackageInfo{scrhack}{\string\thenomenclature\space successfully patched}%
}{%
% \end{macrocode}
% \changes{v3.25}{2019/01/23}{emergency patch added}
% \changes{v3.30}{2020/02/25}{spurious space in warning message removed}
% If this also does not work, we try an emergency patch, that could break
% things.
% \begin{macrocode}
\xpatchcmd{\thenomenclature}{%
\@ifundefined{chapter}%
}{%
\scr@hack@nomencl@head
\@gobbletwo
}{%
\PackageWarning{scrhack}{%
using emergency patch of \string\thenomenclature.\MessageBreak
This could happen if you are using an unknown\MessageBreak
release of package `nomencl'.\MessageBreak
Mostly this patch does work too, but it also could\MessageBreak
break `nomencl`. If this happens, please deactivate\MessageBreak
the `nomencl` hack of `scrhack`%
}%
}{%
\PackageWarning{scrhack}{%
cannot patch \string\thenomenclature.\MessageBreak
This could happen if you are using an unknown\MessageBreak
release of package `nomencl'%
}%
}%
}%
}%
}
%</nomencl&body>
% \end{macrocode}
% \end{command}^^A \thenomenclature
%
% \begin{macro}{\scr@hack@nomencl@head}
% \changes{v3.23}{2017/03/31}{heading of \env{thenomenclature} by
% \pkg*{tocbasic}}
% \changes{v3.31}{2020/07/08}{internal \cs{list@fname} eliminated}
% We don't need an extra group, because \env{thenomenclature} already adds the
% group.
% \begin{macrocode}
%<*nomencl&body>
\newcommand*{\scr@hack@nomencl@head}{%
\providecommand*{\listofnlsname}{\nomname}%
\def\@currext{nls}%
\tocbasic@listhead{\nomname}%
}
%</nomencl&body>
% \end{macrocode}
% \begin{description}
% \item[Note:] Only the heading hooks of \pkg*{tocbasic} are used. The other
% hooks can be set, but would never be used!
% \end{description}
% \end{macro}^^A \scr@hack@nomencl@head
%
% \begin{macro}{\if@intoc}
% \changes{3.23}{2017/03/31}{support of \cs{if@intoc}}
% Generally we have to support \pkg{nomencl}'s option \opt{intoc} and the
% switch \cs{if@intoc}. This is done by (un-)setting \pkg*{tocbasic} feature
% \texttt{totoc}. So additional changes of the feature can be done at first
% after loading both, \pkg{nomencl} and \pkg*{scrhack}. Moreover, later changes
% of \cs{if@intoc} are not recognized.
% \begin{macrocode}
%<*nomencl&body>
\if@intoc
\setuptoc{nls}{totoc}
\fi
%</nomencl&body>
% \end{macrocode}
% \end{macro}
%
%
% \subsection{The \pkg*{setspace} hack}
%
% Package \pkg{setspace} internally uses \cs{@ptsize} in a way, that only
% works as long as \cs{@ptsize} is an integer. But because \KOMAScript{}
% supports non integer font sizes, \cs{@ptsize} can also contain non-integer
% values. Moreover for \opt{11pt}, \LaTeX{} does not use a 11\,pt font but
% a 10.95\,pt font with a \len{baselineskip} of 13.6\,pt, the correct factor
% for, e.g., \cs{onehalfspacing} would be:
% \[ 10{,}95\,\mathrm{pt} \dot 1{,5} / 13{,}6\,\mathrm{pt} \equiv 1{,}208 \]
% But \pkg{setspace} uses 1.213, which would be correct for 11\,pt. Moreover
% the factor is always relative to the base font size and not the current font
% size. Because of this
% \begin{verbatim}
% \documentclass[10pt]{article}
% \usepackage{setspace}
% \begin{document}
% \large\onehalfspacing\raggedright
% Fontsize: \csname f@size\endcsname pt\\
% Normal baselineskip: \csname f@baselineskip\endcsname\\
% baselineskip: \the\baselineskip
% \end{document}
% \end{verbatim}
% results in another \len{baselineskip} than:
% \begin{verbatim}
% \documentclass[11pt]{article}
% \usepackage{setspace}
% \begin{document}
% \large\onehalfspacing\raggedright
% Fontsize: \csname f@size\endcsname pt\\
% Normal baselineskip: \csname f@baselineskip\endcsname\\
% baselineskip: \the\baselineskip
% \end{document}
% \end{verbatim}
% despite both examples use the same font size. So, to make it absolutely
% correct, the factor would have to change with every change of the font
% size. But the hack also does not do so. It just calculates the factor
% depending on the base font size an the current font size. This is enough to
% have the same \len{baselineskip} with both of the examples above.
%
% \begin{option}{setspace}
% \changes{v3.17}{2015/04/16}{added}
% \changes{v3.39}{2022/11/11}{initial dot in member argument of \cs{KOMA@key}
% removed}
% \begin{macrocode}
%<*package&option>
\KOMA@ifkey{setspace}{@scrhack@setspace}
\KOMAExecuteOptions{setspace=true}
%</package&option>
%<*package&body>
\AfterPackage*{setspace}{%
\KOMA@key[scrhack.sty]{setspace}{%
\PackageWarning{scrhack}{option `setspace' ignored}%
\FamilyKeyStateProcessed
}%
\if@scrhack@setspace\scr@hack@load\@pkgextension{setspace}\fi
}
%</package&body>
% \end{macrocode}
% \end{option}
%
%
% \begin{command}{\onehalfspacing}
% \changes{v3.17}{2015/04/16}{added}
% This selects the one half line spacing. I think, a factor with three digits
% for the decimals should be enough.
% \begin{macrocode}
%<*setspace&body>
\scr@ifexpected{\onehalfspacing}{%
\long\def\onehalfspacing{%
\setstretch{1.25}% default
\ifcase \@ptsize \relax % 10pt
\setstretch {1.25}%
\or % 11pt
\setstretch {1.213}%
\or % 12pt
\setstretch {1.241}%
\fi
}%
}{%
\renewcommand*{\onehalfspacing}{%
\@tempdima=\dimexpr (\f@size pt)*1500/
(\dimexpr \f@baselineskip\relax)*\p@/1000\relax
\expandafter\setstretch\expandafter{\strip@pt\@tempdima}%
}%
}{%
% \end{macrocode}
% \changes{v3.39}{2023/03/15}{support for \pkg{setspace} 6.7b added}
% \begin{macrocode}
\scr@ifexpected{\onehalfspacing}{%
\long\def\onehalfspacing{%
\setstretch{1.25}% default
% DPC 6.7b guard \@ptsize
\ifx\@ptsize\@undefined\else
\ifcase \@ptsize \relax % 10pt
\setstretch {1.25}%
\or % 11pt
\setstretch {1.213}%
\or % 12pt
\setstretch {1.241}%
\fi
\fi
}%
}{%
\renewcommand*{\onehalfspacing}{%
\@tempdima=\dimexpr (\f@size pt)*1500/
(\dimexpr \f@baselineskip\relax)*\p@/1000\relax
\expandafter\setstretch\expandafter{\strip@pt\@tempdima}%
}%
}{%
\PackageWarning{scrhack}{unknown \string\onehalfspacing\space
definition found!\MessageBreak
Maybe you are using a unsupported setpace version}%
}%
}
% \end{macrocode}
% \end{command}
% \begin{command}{\doublespacing}
% \changes{v3.17}{2015/04/16}{new}
% This selects the double line spacing. I think, a factor with three digits
% for the decimals should be enough.
% \begin{macrocode}
\scr@ifexpected{\doublespacing}{%
\long\def\doublespacing{%
\setstretch{1.667}% default
\ifcase \@ptsize \relax % 10pt
\setstretch {1.667}%
\or % 11pt
\setstretch {1.618}%
\or % 12pt
\setstretch {1.655}%
\fi
}%
}{%
\renewcommand*{\doublespacing}{%
\@tempdima=\dimexpr (\f@size pt)*2000/
(\dimexpr \f@baselineskip\relax)*\p@/1000\relax
\expandafter\setstretch\expandafter{\strip@pt\@tempdima}%
}%
}{%
% \end{macrocode}
% \changes{v3.39}{2023/03/15}{support for \pkg{setspace} 6.7b added}
% \begin{macrocode}
\scr@ifexpected{\doublespacing}{%
\long\def\doublespacing{%
\setstretch {1.667}% default
% DPC 6.7b guard \@ptsize
\ifx\@ptsize\@undefined\else
\ifcase \@ptsize \relax % 10pt
\setstretch {1.667}%
\or % 11pt
\setstretch {1.618}%
\or % 12pt
\setstretch {1.655}%
\fi
\fi
}%
}{%
\renewcommand*{\doublespacing}{%
\@tempdima=\dimexpr (\f@size pt)*2000/
(\dimexpr \f@baselineskip\relax)*\p@/1000\relax
\expandafter\setstretch\expandafter{\strip@pt\@tempdima}%
}%
}{%
\PackageWarning{scrhack}{unknown \string\doublespacing\space
definition found!\MessageBreak
Maybe you are using a unsupported setpace version}%
}%
}
%</setspace&body>
% \end{macrocode}
% \end{command}
%
%
% \subsection{The \pkg*{lscape} hack}
% \changes{v3.18a}{2015/07/07}{\pkg{lscape} hack added}
%
% The package does change \len{textheight} inside \env{landscape} to the prior
% value of \len{textwidth}, nevertheless is does not change \len{textwidth} to
% the prior value of \len{textheight}. This is at least inconsistent. After
% asking him, David~Carlisle answered, that he does not change
% \len{textwidth}, because this could result in problems. Therefore it is very
% strange, that he does change \cs{textheight}, despite this also to problems,
% e.g., with packages \pkg{showframe} or \pkg*{scrlayer}. So the patch here
% also keeps \len{textheight} unchanged. This also has to take care for
% \pkg{pdflscape}. The patches are done using \pkg{xpatch}.
%
%
% \begin{option}{lscape}
% \changes{v3.18a}{2015/07/07}{added}
% \changes{v3.20}{2016/05/07}{loading \pkg{xpatch} in option part already}
% \changes{v3.39}{2022/11/11}{initial dot in member argument of \cs{KOMA@key}
% removed}
% \begin{macrocode}
%<*package&option>
\RequirePackage{xpatch}%
\KOMA@ifkey{lscape}{@scrhack@lscape}%
\KOMAExecuteOptions{lscape=true}%
%</package&option>
%<*package&body>
\AfterPackage*{lscape}{%
\if@scrhack@lscape\scr@hack@load\@pkgextension{lscape}\else
\KOMA@key[scrhack.sty]{lscape}{%
\PackageWarning{scrhack}{option `lscape' ignored}%
\FamilyKeyStateProcessed
}%
\fi
}
%</package&body>
% \end{macrocode}
% \end{option}
%
% \begin{command}{\landscape}
% \changes{v3.18a}{2015/07/07}{added}
% \changes{v3.20}{2016/05/07}{loading \pkg{xpatch} in option part already}
% This command is the beginning of environment \env{landscape}. This has to be
% patched using \pkg{xpatch}.
% \begin{description}
% \item[Note:] This is a load time option and cannot be changed after loading
% the package!
% \end{description}
% \begin{macrocode}
%<*lscape&body>
\xpatchcmd{\landscape}{\textheight=\vsize}{%
\if@scrhack@lscape
% \end{macrocode}
% \begin{macro}{\@outputpage}
% \changes{v3.18a}{2015/08/11}{added}
% Here the changed value of \len{textheight} is needed for initialization of
% \cs{@colht}. So we patch it to use the new internal \len{scr@LT@textheight}
% instead of \len{textheight}.
% \begin{macrocode}
\scrh@LT@textheight=\vsize
\let\scrh@LT@outputpage\@outputpage
\def\@outputpage{\scrh@LT@outputpage\global\@colht\scrh@LT@textheight}%
\else
\textheight=\vsize
\fi
}{%
\PackageInfo{scrhack}{\string\landscape\space patched to make
\string\textheight\space change optional}%
}{%
\PackageWarning{scrhack}{Cannot patch \string\landscape!\MessageBreak
Maybe you are using a unsupported lscape version}%
\@scrhack@lscapefalse
}
% \end{macrocode}
% \begin{ilength}{\scrh@LT@textheight}
% \changes{v3.18a}{2015/08/11}{new}
% \begin{macrocode}
\newlength{\scrh@LT@textheight}
%</lscape&body>
% \end{macrocode}
% \end{ilength}^^A \scrh@LT@textheight
% \end{macro}^^A \@outputpage
% \end{command}^^A \landscape
%
%
% \subsection{The standard classes sections hack}
% \label{sec:standardsections}
% The \emph{standard classes sections hack} differs from each other
% hack. First of all it does not patch a specific package but the class
% definitions of section commands from \cs{part} till
% \cs{subparagraph}. Additionally it resets several internal \LaTeX{} macros
% which are changed by \KOMAScript{} classes to their original
% definition. Last but not least it is not activated by default, but the user
% has to activate it, if he needs it. The hack has more potential to break
% things than to make things better. Because of this, there is not any support
% for using this hack and the hack shows several warning messages.
%
% \begin{option}{standardsections}
% \begin{macrocode}
%<*package&option>
\KOMA@ifkey{standardsections}{@scrhack@standardsections}
\KOMAExecuteOptions{standardsections=false}
%</package&option>
%<*package&body>
\AtEndOfPackage{%
\if@scrhack@standardsections
\PackageInfo{scrhack}{loading standard classes sections hack}%
\input{standardsections.hak}%
\fi
}
%</package&body>
% \end{macrocode}
% \end{option}^^A standardsections
%
% \begin{command}{\part,\chapter,
% \section,\subsection,\subsubsection,
% \paragraph,\subparagraph}
% The hack redefines all these commands to a definition copied from the
% standard \LaTeX{} classes version v1.4i. Copyright of this code is by the
% \LaTeX3{} Project. The complete, unmodified code can be found on
% \url{https://ctan.org/tex-archive/macros/latex/base/classes.dtx}.
% \begin{macrocode}
%<*standardsections&body>
\PackageWarningNoLine{scrhack}{%
You are loosing every kind of support because of\MessageBreak
using the dangerous standard classes sections hack!\MessageBreak
This hack can break several classes and packages.\MessageBreak
However, sometimes it is needed to make a\MessageBreak
package work%
}%
\PackageInfo{scrhack}{%
Using code from the standard LaTeX classes.\MessageBreak
For more information about this code and the\MessageBreak
license of this code, please see:\MessageBreak
https://ctan.org/tex-archive/macros/latex/base/classes.dtx
}%
\@ifpackageloaded{hyperref}{%
\PackageWarning{scrhack}{this hack should not be loaded after `hyperref'}%
}{}
\@ifpackageloaded{titlesec}{%
\PackageWarning{scrhack}{this hack should not be loaded after `titlesec'}%
}{}
\@ifpackageloaded{sectsty}{%
\PackageWarning{scrhack}{this hack should not be loaded after `sectsty'}%
}{}
\@ifpackageloaded{sectsty}{%
\PackageWarning{scrhack}{this hack should not be loaded after `sectsty'}%
}{}
\scr@ifundefinedorrelax{chapter}{%
% \end{macrocode}
% It seems to be an article class, so we use the code from
% \href{http://mirrors.ctan.org/macros/latex/base/classes.dtx}{\cls*{article}}.
% \begin{macrocode}
\scr@ifundefinedorrelax{c@part}{\newcounter{part}}{}%
\scr@ifundefinedorrelax{c@section}{\newcounter{section}}{}%
\scr@ifundefinedorrelax{c@subsection}{\newcounter{subsection}[section]}{}%
\scr@ifundefinedorrelax{c@subsubsection}{%
\newcounter{subsubsection}[subsection]}{}%
\scr@ifundefinedorrelax{c@paragraph}{%
\newcounter{paragraph}[subsubsection]}{}%
\scr@ifundefinedorrelax{c@subparagraph}{%
\newcounter{subparagraph}[paragraph]}{}%
\renewcommand\thepart {\@Roman\c@part}%
\renewcommand\thesection {\@arabic\c@section}%
\renewcommand\thesubsection {\thesection.\@arabic\c@subsection}%
\renewcommand\thesubsubsection{\thesubsection.\@arabic\c@subsubsection}%
\renewcommand\theparagraph {\thesubsubsection.\@arabic\c@paragraph}%
\renewcommand\thesubparagraph {\theparagraph.\@arabic\c@subparagraph}%
\def\part{%
\if@noskipsec \leavevmode \fi
\par
\addvspace{4ex}%
\@afterindentfalse
\secdef\@part\@spart}%
\def\@part[#1]#2{%
\ifnum \c@secnumdepth >\m@ne
\refstepcounter{part}%
\addcontentsline{toc}{part}{\thepart\hspace{1em}#1}%
\else
\addcontentsline{toc}{part}{#1}%
\fi
{\parindent \z@ \raggedright
\interlinepenalty \@M
\normalfont
\ifnum \c@secnumdepth >\m@ne
\Large\bfseries \partname\nobreakspace\thepart
\par\nobreak
\fi
\huge \bfseries #2%
\markboth{}{}\par}%
\nobreak
\vskip 3ex
\@afterheading}%
\def\@spart#1{%
{\parindent \z@ \raggedright
\interlinepenalty \@M
\normalfont
\huge \bfseries #1\par}%
\nobreak
\vskip 3ex
\@afterheading}%
\def\section{\@startsection {section}{1}{\z@}%
{-3.5ex \@plus -1ex \@minus -.2ex}%
{2.3ex \@plus.2ex}%
{\normalfont\Large\bfseries}}%
\def\subsection{\@startsection{subsection}{2}{\z@}%
{-3.25ex\@plus -1ex \@minus -.2ex}%
{1.5ex \@plus .2ex}%
{\normalfont\large\bfseries}}%
\def\subsubsection{\@startsection{subsubsection}{3}{\z@}%
{-3.25ex\@plus -1ex \@minus -.2ex}%
{1.5ex \@plus .2ex}%
{\normalfont\normalsize\bfseries}}%
\def\paragraph{\@startsection{paragraph}{4}{\z@}%
{3.25ex \@plus1ex \@minus.2ex}%
{-1em}%
{\normalfont\normalsize\bfseries}}%
\def\subparagraph{\@startsection{subparagraph}{5}{\parindent}%
{3.25ex \@plus1ex \@minus .2ex}%
{-1em}%
{\normalfont\normalsize\bfseries}}%
}{%
% \end{macrocode}
% It seems to be either a book or report class.
% \begin{macrocode}
\scr@ifundefinedorrelax{c@part}{\newcounter{part}}{}%
\scr@ifundefinedorrelax{c@chapter}{\newcounter{chapter}}{}%
\scr@ifundefinedorrelax{c@section}{\newcounter{section}[chapter]}{}%
\scr@ifundefinedorrelax{c@subsection}{\newcounter{subsection}[section]}{}%
\scr@ifundefinedorrelax{c@subsubsection}{%
\newcounter{subsubsection}[subsection]}{}%
\scr@ifundefinedorrelax{c@paragraph}{%
\newcounter{paragraph}[subsubsection]}{}%
\scr@ifundefinedorrelax{c@subparagraph}{%
\newcounter{subparagraph}[paragraph]}{}%
\def\@chapapp{\chaptername}%
\scr@ifundefinedorrelax{frontmatter}{%
% \end{macrocode}
% It seems not to be a book class.
% \begin{macrocode}
\def\part{%
\if@openright
\cleardoublepage
\else
\clearpage
\fi
\thispagestyle{plain}%
\if@twocolumn
\onecolumn
\@tempswatrue
\else
\@tempswafalse
\fi
\null\vfil
\secdef\@part\@spart}
\def\@part[#1]#2{%
\ifnum \c@secnumdepth >-2\relax
\refstepcounter{part}%
\addcontentsline{toc}{part}{\thepart\hspace{1em}#1}%
\else
\addcontentsline{toc}{part}{#1}%
\fi
\markboth{}{}%
{\centering
\interlinepenalty \@M
\normalfont
\ifnum \c@secnumdepth >-2\relax
\huge\bfseries \partname\nobreakspace\thepart
\par
\vskip 20\p@
\fi
\Huge \bfseries #2\par}%
\@endpart}
\def\@spart#1{%
{\centering
\interlinepenalty \@M
\normalfont
\Huge \bfseries #1\par}%
\@endpart}
\def\@endpart{\vfil\newpage
\if@twoside
\if@openright
\null
\thispagestyle{empty}%
\newpage
\fi
\fi
\if@tempswa
\twocolumn
\fi}
\def\chapter{\if@openright\cleardoublepage\else\clearpage\fi
\thispagestyle{plain}%
\global\@topnum\z@
\@afterindentfalse
\secdef\@chapter\@schapter}
\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
\refstepcounter{chapter}%
\typeout{\@chapapp\space\thechapter.}%
\addcontentsline{toc}{chapter}%
{\protect\numberline{\thechapter}#1}%
\else
\addcontentsline{toc}{chapter}{#1}%
\fi
\chaptermark{#1}%
\addtocontents{lof}{\protect\addvspace{10\p@}}%
\addtocontents{lot}{\protect\addvspace{10\p@}}%
\if@twocolumn
\@topnewpage[\@makechapterhead{#2}]%
\else
\@makechapterhead{#2}%
\@afterheading
\fi}
\def\@makechapterhead#1{%
\vspace*{50\p@}%
{\parindent \z@ \raggedright \normalfont
\ifnum \c@secnumdepth >\m@ne
\huge\bfseries \@chapapp\space \thechapter
\par\nobreak
\vskip 20\p@
\fi
\interlinepenalty\@M
\Huge \bfseries #1\par\nobreak
\vskip 40\p@
}}
\def\@schapter#1{\if@twocolumn
\@topnewpage[\@makeschapterhead{#1}]%
\else
\@makeschapterhead{#1}%
\@afterheading
\fi}
\def\@makeschapterhead#1{%
\vspace*{50\p@}%
{\parindent \z@ \raggedright
\normalfont
\interlinepenalty\@M
\Huge \bfseries #1\par\nobreak
\vskip 40\p@
}}
\def\section{\@startsection {section}{1}{\z@}%
{-3.5ex \@plus -1ex \@minus -.2ex}%
{2.3ex \@plus.2ex}%
{\normalfont\Large\bfseries}}%
\def\subsection{\@startsection{subsection}{2}{\z@}%
{-3.25ex\@plus -1ex \@minus -.2ex}%
{1.5ex \@plus .2ex}%
{\normalfont\large\bfseries}}%
\def\subsubsection{\@startsection{subsubsection}{3}{\z@}%
{-3.25ex\@plus -1ex \@minus -.2ex}%
{1.5ex \@plus .2ex}%
{\normalfont\normalsize\bfseries}}%
\def\paragraph{\@startsection{paragraph}{4}{\z@}%
{3.25ex \@plus1ex \@minus.2ex}%
{-1em}%
{\normalfont\normalsize\bfseries}}%
\def\subparagraph{\@startsection{subparagraph}{5}{\parindent}%
{3.25ex \@plus1ex \@minus .2ex}%
{-1em}%
{\normalfont\normalsize\bfseries}}%
}{%
% \end{macrocode}
% It seems to be a book class.
% \begin{macrocode}
\scr@ifundefinedorrelax{if@mainmatter}{%
\expandafter\newif\csname if@mainmatter\endcsname
}{}%
\def\frontmatter{%
\cleardoublepage
\@mainmatterfalse
\pagenumbering{roman}}%
\def\mainmatter{%
\cleardoublepage
\@mainmattertrue
\pagenumbering{arabic}}%
\def\backmatter{%
\if@openright
\cleardoublepage
\else
\clearpage
\fi
\@mainmatterfalse}%
\def\part{%
\if@openright
\cleardoublepage
\else
\clearpage
\fi
\thispagestyle{plain}%
\if@twocolumn
\onecolumn
\@tempswatrue
\else
\@tempswafalse
\fi
\null\vfil
\secdef\@part\@spart}%
\def\@part[#1]#2{%
\ifnum \c@secnumdepth >-2\relax
\refstepcounter{part}%
\addcontentsline{toc}{part}{\thepart\hspace{1em}#1}%
\else
\addcontentsline{toc}{part}{#1}%
\fi
\markboth{}{}%
{\centering
\interlinepenalty \@M
\normalfont
\ifnum \c@secnumdepth >-2\relax
\huge\bfseries \partname\nobreakspace\thepart
\par
\vskip 20\p@
\fi
\Huge \bfseries #2\par}%
\@endpart}%
\def\@spart#1{%
{\centering
\interlinepenalty \@M
\normalfont
\Huge \bfseries #1\par}%
\@endpart}%
\def\@endpart{\vfil\newpage
\if@twoside
\if@openright
\null
\thispagestyle{empty}%
\newpage
\fi
\fi
\if@tempswa
\twocolumn
\fi}%
\def\chapter{\if@openright\cleardoublepage\else\clearpage\fi
\thispagestyle{plain}%
\global\@topnum\z@
\@afterindentfalse
\secdef\@chapter\@schapter}%
\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\refstepcounter{chapter}%
\typeout{\@chapapp\space\thechapter.}%
\addcontentsline{toc}{chapter}%
{\protect\numberline{\thechapter}#1}%
\else
\addcontentsline{toc}{chapter}{#1}%
\fi
\else
\addcontentsline{toc}{chapter}{#1}%
\fi
\chaptermark{#1}%
\addtocontents{lof}{\protect\addvspace{10\p@}}%
\addtocontents{lot}{\protect\addvspace{10\p@}}%
\if@twocolumn
\@topnewpage[\@makechapterhead{#2}]%
\else
\@makechapterhead{#2}%
\@afterheading
\fi}%
\def\@makechapterhead#1{%
\vspace*{50\p@}%
{\parindent \z@ \raggedright \normalfont
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\huge\bfseries \@chapapp\space \thechapter
\par\nobreak
\vskip 20\p@
\fi
\fi
\interlinepenalty\@M
\Huge \bfseries #1\par\nobreak
\vskip 40\p@
}}%
\def\@schapter#1{\if@twocolumn
\@topnewpage[\@makeschapterhead{#1}]%
\else
\@makeschapterhead{#1}%
\@afterheading
\fi}%
\def\@makeschapterhead#1{%
\vspace*{50\p@}%
{\parindent \z@ \raggedright
\normalfont
\interlinepenalty\@M
\Huge \bfseries #1\par\nobreak
\vskip 40\p@
}}%
\def\section{\@startsection {section}{1}{\z@}%
{-3.5ex \@plus -1ex \@minus -.2ex}%
{2.3ex \@plus.2ex}%
{\normalfont\Large\bfseries}}%
\def\subsection{\@startsection{subsection}{2}{\z@}%
{-3.25ex\@plus -1ex \@minus -.2ex}%
{1.5ex \@plus .2ex}%
{\normalfont\large\bfseries}}%
\def\subsubsection{\@startsection{subsubsection}{3}{\z@}%
{-3.25ex\@plus -1ex \@minus -.2ex}%
{1.5ex \@plus .2ex}%
{\normalfont\normalsize\bfseries}}%
\def\paragraph{\@startsection{paragraph}{4}{\z@}%
{3.25ex \@plus1ex \@minus.2ex}%
{-1em}%
{\normalfont\normalsize\bfseries}}%
\def\subparagraph{\@startsection{subparagraph}{5}{\parindent}%
{3.25ex \@plus1ex \@minus .2ex}%
{-1em}%
{\normalfont\normalsize\bfseries}}%
}%
}% End of the derived code.
% \end{macrocode}
% \end{command}
%
% \begin{macro}{\@startsection}
% \KOMAScript{} classes redefine this internal \LaTeX{} kernel macro. In this
% case \cs{scr@saved@startsection} is defined, differs from
% \cs{@startsection} and has the definition found before redefining the
% original macro. We do nothing else but resetting \cs{@startsection} to this
% saved definition.
% \begin{macrocode}
\scr@ifundefinedorrelax{scr@saved@startsection}{}{%
\ifx\@startsection\scr@saved@startsection\else
\PackageWarningNoLine{scrhack}{%
Resetting \string\@startsection,\MessageBreak
because of loading standard classes sections hack%
}%
\let\@startsection\scr@saved@startsection
\fi
}
% \end{macrocode}
% \end{macro}^^A \@startsection
%
% \begin{macro}{\@sect,\@ssect,\@xsect}
% All these should be resetted to their original definitions stored in
% \cs{scr@latex@\dots}.
% \begin{macrocode}
\scr@ifundefinedorrelax{scr@latex@sect}{}{%
\ifx\@sect\scr@latex@sect\else
\PackageWarningNoLine{scrhack}{%
Resetting \string\@sect,\MessageBreak
because of loading standard classes sections hack%
}%
\let\@sect\scr@latex@sect
\fi
}
\scr@ifundefinedorrelax{scr@latex@ssect}{}{%
\ifx\@ssect\scr@latex@ssect\else
\PackageWarningNoLine{scrhack}{%
Resetting \string\@ssect,\MessageBreak
because of loading standard classes sections hack%
}%
\let\@sect\scr@latex@ssect
\fi
}
\scr@ifundefinedorrelax{scr@latex@xsect}{}{%
\ifx\@xsect\scr@latex@xsect\else
\PackageWarningNoLine{scrhack}{%
Resetting \string\@xsect,\MessageBreak
because of loading standard classes sections hack%
}%
\let\@sect\scr@latex@sect
\fi
}
% \end{macrocode}
% \end{macro}^^A \@xsect,\@ssect,\@sect
%
% \begin{command}{\DeclareSectionCommand,\RedeclareSectionCommand,
% \DeclareNewSectionCommand,\ProvideSectionCommand,
% \DeclareSectionCommands,\RedeclareSectionCommands,
% \DeclareNewSectionCommands,\ProvideSectionCommands}
% These \KOMAScript{} commands do not make sense any longer after forced
% redefinition of \cs{part} \dots{} \cs{subparagraph}. They even would not
% work correctly after resetting, e.g., \cs{@startsection}. So best reaction
% is to \emph{undefine} them.
% \begin{macrocode}
\scr@ifundefinedorrelax{DeclareSectionCommand}{}{%
\PackageWarningNoLine{scrhack}{%
\string\DeclareSectionCommand\space
and all derivates deactivated,\MessageBreak
because of loading standard classes sections hack%
}%
\let\DeclareSectionCommand\undefined
\let\DeclareSectionCommands\undefined
\let\RedeclareSectionCommand\undefined
\let\RedeclareSectionCommands\undefined
\let\DeclareNewSectionCommand\undefined
\let\DeclareNewSectionCommands\undefined
\let\ProvideSectionCommand\undefined
\let\ProvideSectionCommands\undefined
}
% \end{macrocode}
% \begin{macro}{\scr@chapter@before@hyperref@patch,
% \scr@chapter@after@hyperref@patch}
% Now, definitions without respecting \pkg{hyperref} are used, so
% \pkg{hyperref} should again be able to patch them. So the hack should
% deactivate the patch deactivation of the \KOMAScript{} classes.
% \begin{macrocode}
\let\scr@chapter@before@hyperref@patch\relax
\let\scr@chapter@after@hyperref@patch\relax
% \end{macrocode}
% \end{macro}
% \end{command}
%
% \begin{macro}{\scr@osectarg}
% The \KOMAScript{} classes use this macro to store how to use the optional
% argument of section commands. But with the standard class definition the
% only possibility is to use it as running head and write it into the table of
% contents without any extended handling. So the only value, that makes sense
% is 0.
% \begin{macrocode}
\scr@ifundefinedorrelax{scr@osectarg}{}{%
\def\reserved@a{0}%
\ifx\scr@osectarg\reserved@a\else
\let\scr@osectarg\reserved@a
\PackageWarningNoLine{scrhack}{%
Extended option handling for section commands deactivated,\MessageBreak
because of loading standard classes sections hack%
}%
\fi
}%
% \end{macrocode}
% \begin{macro}{\scr@activate@xsection}
% Further changing of the value has to be deactivated.
% \begin{macrocode}
\scr@ifundefinedorrelax{scr@activate@xsection}{}{%
\renewcommand*{\scr@activate@xsection}[1]{%
\edef\scr@osectarg{#1}\def\reserved@a{0}%
\ifx\scr@osectarg\reserved@a
\else
\let\scr@osectarg\reserved@a
\PackageWarning{scrhack}{%
Because of loading the standard classes\MessageBreak
sections hack, the extended option handling\MessageBreak
of section commands failed%
}%
\fi
}%
}
% \end{macrocode}
% \end{macro}^^A \scr@activate@xsection
% \end{macro}^^A \scr@osectarg
%
% \begin{command}{\partformat,\chapterformat}
% Most \cs{\dots format} macros of \KOMAScript{} are still used, because of
% the redefinition of \cs{@seccntformat}. But \cs{part} and \cs{chapter} are
% defined without using them.
% \begin{macrocode}
\scr@ifundefinedorrelax{partformat}{}{%
\PackageWarningNoLine{scrhack}{%
Usage of \string\partformat\space
deactivated,\MessageBreak
because of loading the standard classes sections hack%
}%
}
\scr@ifundefinedorrelax{chapterformat}{}{%
\PackageWarningNoLine{scrhack}{%
Usage of \string\chapterformat\space
deactivated,\MessageBreak
because of loading the standard classes sections hack%
}%
}
% \end{macrocode}
% \end{command}^^A \chapterformat,\partformat
%
% \begin{command}{\sectionformat,\subsectionformat,\subsubsectionformat,
% \paragraphformat,\subparagraphformat}
% All these commands have to be resetted to not use the automatic dot and to
% add a \cs{quad} instead of an \cs{enskip}.
% \begin{macrocode}
\scr@ifundefinedorrelax{sectionformat}{}{%
\PackageWarningNoLine{scrhack}{%
\string\sectionformat\space set to
`\string\thesection\string\quad',\MessageBreak
because of loading the standard classes sections hack%
}%
\renewcommand*{\sectionformat}{\thesection\quad}%
}
\scr@ifundefinedorrelax{subsectionformat}{}{%
\PackageWarningNoLine{scrhack}{%
\string\subsectionformat\space set to
`\string\thesubsection\string\quad'\MessageBreak
because of loading the standard classes sections hack%
}%
\renewcommand*{\subsectionformat}{\thesubsection\quad}%
}
\scr@ifundefinedorrelax{subsubsectionformat}{}{%
\PackageWarningNoLine{scrhack}{%
\string\subsubsectionformat\space set to
`\string\thesubsubsection\string\quad'\MessageBreak
because of loading the standard classes sections hack%
}%
\renewcommand*{\subsubsectionformat}{\thesubsubsection\quad}%
}
\scr@ifundefinedorrelax{paragraphformat}{}{%
\PackageWarningNoLine{scrhack}{%
\string\paragraphformat\space set to
`\string\theparagraph\string\quad'\MessageBreak
because of loading the standard classes sections hack%
}%
\renewcommand*{\paragraphformat}{\theparagraph\quad}%
}
\scr@ifundefinedorrelax{subparagraphformat}{}{%
\PackageWarningNoLine{scrhack}{%
\string\subparagraphformat\space set to
`\string\thesubparagraph\string\quad'\MessageBreak
because of loading the standard classes sections hack%
}%
\renewcommand*{\subparagraphformat}{\thesubparagraph\quad}%
}
% \end{macrocode}
% \end{command}
%
% \begin{command}{\partlineswithprefixformat,
% \chapterlineswithprefixformat,\chapterlinesformat,
% \sectionlinesformat,\sectioncatchphraseformat}
% These \KOMAScript{} commands are not used any longer.
% \begin{macrocode}
\scr@ifundefinedorrelax{partlineswithprefixformat}{}{%
\PackageWarningNoLine{scrhack}{%
Usage of \string\partlineswithprefixformat\space deactivated,\MessageBreak
because of loading the standard classes sections hack%
}%
}
\scr@ifundefinedorrelax{chapterlineswithprefixformat}{}{%
\PackageWarningNoLine{scrhack}{%
Usage of \string\chapterlineswithprefixformat\space and\MessageBreak
\string\chapterlinesformat\space deactivated,\MessageBreak
because of using standard classes sections hack%
}%
}
\scr@ifundefinedorrelax{sectionlinesformat}{}{%
\PackageWarningNoLine{scrhack}{%
Usage of \string\sectionlinesformat\space and\MessageBreak
\string\sectioncatchphraseformat\space deactivated,\MessageBreak
because of using standard classes sections hack%
}%
}
% \end{macrocode}
% \end{command}^^A \partlineswithprefixformat …
%
% \begin{option}{headings}
% \changes{v3.39}{2022/11/11}{initial dot in member argument of option storage
% commands removed}
% The \KOMAScript{} option does not make sense any longer. So it is
% deactivated and usage will throw an error.
% \begin{macrocode}
\scr@ifundefinedorrelax{KOMAClassName}{}{%
\PackageWarningNoLine{scrhack}{%
KOMA-Script option `headings' removed,\MessageBreak
because of loading standard classes sections hack%
}%
\RelaxFamilyKey[.\KOMAClassFileName]{KOMA}{headings}%
\KOMA@kav@removekey{\KOMAClassFileName}{headings}%
}
% \end{macrocode}
% \end{option}^^A headings
%
% \begin{macro}{\scr@class@titlesec@warning}
% The warning about loading \pkg{titlesec} has to be changes, because we do
% not expect errors any longer.
% \begin{macrocode}
\def\scr@class@titlesec@warning{%
\PackageWarning{scrhack}{%
Usage of `titlesec' should work, because of\MessageBreak
loading the standard classes sections hack.\MessageBreak
However, you should know, there is not any\MessageBreak
support for this combination by the\MessageBreak
KOMA-Script author%
}%
}
%</standardsections&body>
% \end{macrocode}
% \end{macro}^^A \scr@class@titlesec@warning
%
% \subsection{Executing options}
%
% Last but not least the options have to be processed. In the generated
% package this will be done before the commands of \autoref{sec:macros}.
% \begin{macrocode}
%<*package&option>
\KOMAProcessOptions\relax
%</package&option>
% \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:
|