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
|
% \iffalse meta-comment
% ======================================================================
% scrhack.dtx
% Copyright © 2008–2024 Markus Kohm
%
% This work is a KOMA-Script spin-off. For the original sources of
% KOMA-Script's `scrhack.sty' see file `scrhack.dtx' in the KOMA-Script
% sources at <https://sourceforge.net/p/koma-script/code/>.
%
% Development is taking place as part of `scrhack' at
% <https://github.com/komascript/third-party-enhancements>. New issues
% should be reported there as well as known issues can be found.
%
% 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 the file `scrhack.dtx',
% `scrhack-2023-07-07,dtx', and `README.md'.
%
% The recommended way to install `scrhack' is to use
% the package manager of your TeX distribution.
% ======================================================================
%
%<*dtx>
\ifx\ProvidesFile\undefined\def\ProvidesFile#1[#2]{}\fi
\ProvidesFile{scrhack.dtx}
%</dtx>
%<package>\providecommand\DeclareRelease[3]{}
%<package>\providecommand\DeclareCurrentRelease[2]{}
%<package>\DeclareRelease{v3.41}{2023-07-07}{scrhack-2023-07-07.sty}
%<package>\DeclareCurrentRelease{}{2023-07-15}
%<*dtx|package>
%<package>\ProvidesPackage{scrhack}
[2024-09-04 v3.42
%<dtx> sources and unpack driver of
scrhack emulation package]
%</dtx|package>
%<*dtx>
\ifx\documentclass\undefined
\input docstrip.tex
\generate{%
\file{scrhack.sty}{%
\from{scrhack.dtx}{package}%
}%
}%
\else
\let\endbatchfile\relax
\fi
\endbatchfile
\documentclass[ngerman,USenglish]{koma-script-source-doc}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[style=alphabetic]{biblatex}
\begin{filecontents}[force]{\jobname.bib}
@online{pkg:koma-script,
author={Markus Kohm},
version={3.41},
date={2023-07-07},
title={{\KOMAScript} --- A bundle of versatile classes and packages},
url={https://ctan.org/pkg/koma-script},
urldate={2023-07-14},
note={The \KOMAScript{} bundle provides replacements for the \pkg*{article},
\pkg*{report}, and \pkg*{book} classes with emphasis on typography and
versatility. There is also a letter class.},
}
@manual{pkg:koma-script:manual:de,
author={Markus Kohm},
date={2023-06-16},
title={{\KOMAScript}},
subtitle={Die Anleitung},
url={http://mirrors.ctan.org/macros/latex/contrib/koma-script/scrguide-de.pdf},
urldate={2023-07-04},
}
@manual{pkg:koma-script:manual:en,
author={Markus Kohm},
date={2023-06-16},
title={{\KOMAScript}},
subtitle={The Guide},
url={http://mirrors.ctan.org/macros/latex/contrib/koma-script/scrguide-en.pdf},
urldate={2023-07-14},
}
@article{latexnews35,
author={{The {\LaTeX} Project Team}},
shortauthor={TLT},
year={2022},
month={6},
title={Issue 35},
journal={{\LaTeX} News},
url={http://mirrors.ctan.org/macros/latex/base/ltnews35.pdf},
urldate={2023-07-14},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\setcounter{StandardModuleDepth}{2}
\providecommand*{\seclabel}[1]{\label{sec:#1}}
\begin{document}
\nocite{pkg:koma-script}
\DocInput{scrhack.dtx}
\end{document}
%</dtx>
%\fi
%
% \changes{v0.1}{2023/07/14}{start of \KOMAScript{} spin-off}
%
% \GetFileInfo{scrhack.dtx}
% \title{Emulating Former \href{https://komascript.de/}{\KOMAScript} Package
% \pkg*{scrhack}}
% \author{\href{mailto:komascript@gmx.info}{Markus Kohm}}
% \date{Version \filedate{} \fileversion}
% \maketitle
% \begin{abstract}
% For several years \href{https://komascript.de/}{\KOMAScript} provided a
% package \pkg*{scrhack}, that has been made not only to improve the
% compatibility of third-party packages with
% \href{https://komascript.de/}{\KOMAScript} classes, but also to generally
% improve third-party packages. The package consisted not only in the
% package file \file{scrhack.sty} but also in several so called \emph{hacks}
% as separate files with extension \file{.hak}. In the course of splitting
% off former \href{https://komascript.de/}{\KOMAScript} packages from the
% \href{https://komascript.de/}{\KOMAScript} collection, it was decided to
% create independent packages from the individual hacks. These new
% independent packages then serve as replacements for the original packages
% they were intended to improve. In addition, to preserve the functionality
% of loading the enhancements only when the corresponding original package
% is loaded, a new \pkg*{scrhack} was created to do just that.
% \end{abstract}
%
% \tableofcontents
%
%\iffalse
%<*doc>
%\fi
% \section{History}
% \label{sec:history}
Some packages from other authors do not work well with
\href{https://komascript.de/}{\KOMAScript}. It is often very tedious for the
author of \href{https://komascript.de/}{\KOMAScript} to convince the authors
of these packages to make specific improvements. This also applies to packages
whose development has been discontinued. That's why the \pkg*{scrhack} was
created. This package alters the commands and definitions of other to work
better with \href{https://komascript.de/}{\KOMAScript}. Some changes are also
useful when using other classes.
In the early days of \href{https://komascript.de/}{\KOMAScript}, users wanted
to handle lists of floating environments created with the \pkg{float} package
in the same way as the list of figures and list of tables created by
\href{https://komascript.de/}{\KOMAScript} itself. At that time the author of
\href{https://komascript.de/}{\KOMAScript} contacted the author of
\pkg{float} to propose an interface to support such an enhancement. A
somewhat modified form of that interface was implemented with the
\cs{float@listhead} and \cs{float@addtolists} commands.
Later it became apparent that these two commands were not flexible enough to
fully support all of \href{https://komascript.de/}{\KOMAScript}'s
capabilities. Unfortunately, the author of \pkg{float} had already ceased
development by that point, so further changes to this package cannot be
expected.
Other package authors have also adopted these two commands, and it became
apparent that the implementation in some packages, including \pkg{float},
means that all these packages can only be loaded in a specific order, even
though they are otherwise unrelated to each other.
To overcome all these disadvantages and problems,
\href{https://komascript.de/}{\KOMAScript} no longer officially supports this
old interface. Instead, \href{https://komascript.de/}{\KOMAScript} warns if
the old interface is used. At the same time, the \pkg{tocbasic} package has
been designed and implemented as a central interface for managing of table of
contents and similar content lists. This package provides many more
advantages and features than the two old commands.
Although the effort to use this package is very small, so far the authors of
most of the packages that use the old interface have not made any adjustments.
Therefore the \KOMAScript author designed a new
package \pkg*{scrhack} as part of
\href{https://komascript.de/}{\KOMAScript}. That package contained appropriate
modifications of the packages
\pkg{float}, \pkg{floatrow}, \pkg{listings}, and later on also for
\pkg{nomencl} and some others not related to that interface. Merely loading
\pkg*{scrhack} was sufficient to make these packages recognize not only the
setting of the \href{https://komascript.de/}{\KOMAScript} option \opt{listof},
but, e.g., also to react to the language switching features of the
\pkg{babel} package. You can find more information
about the features available by switching packages to \pkg{tocbasic} in
\autocite{pkg:koma-script:manual:en} or \autocite{pkg:koma-script:manual:de}.
With release of version 3.42 package \pkg*{scrhack} has been removed from
\href{https://komascript.de/}{\KOMAScript}. The code of the former package has
been split into several standalone packages, that can be loaded individually
if needed. However, for compatibility and maybe for convenience there is also
a new standalone package \pkg*{scrhack} almost compatible with the old
one.
\section{Using \texorpdfstring{\pkg*{scrhack}}{scrhack}}
\seclabel{usage}
It is recommended to load the \pkg*{scrhack} package using:
\begin{verbatim}
\usepackage{scrhack}
\end{verbatim}
as early as possible. In particular, loading should be done before the
affected packages. The package also provides several options, one for each
hack. Usually the options are named identically to the package, that is
patched by the hack. All these options are boolean options. You can switch
such an option on assigning value \optvalue{true} or using it without
value. You can switch off such an option assigning value
\optvalue{false}. Switching off an option means to not automatically load the
corresponding enhancement package after the package, that has to be
patched. Therefore switching off an option results in not patching the
corresponding package.
\paragraph{Notes:}
\begin{itemize}
\item From version 3.42, you cannot use \cs{KOMAoptions} or \cs{KOMAoption}
any longer to change the options. Instead loading \pkg*{scrhack} again with
other options does not result in an option clash, but in a change of the
option settings.
\item Switching off an option of an already loaded enhancement package is
ignored (with warning). It does not unload the enhancement package or switch
back to a not patched functionality.
\item Switching on an option of a not yet loaded enhancement package would
result in loading the enhancement package.
\item From version 3.42, you should no longer load package
\pkg*{scrhack}. Instead you can and should simply load the individual
enhancement package when you need it.
\item If you need the old legacy version of \pkg*{scrhack} from
\href{https://komascript.de/}{\KOMAScript} 3.41 you can use:
\begin{verbatim}
\usepackage{scrhack}[=2023-07-07]
\end{verbatim}
or
\begin{verbatim}
\usepackage{scrhack}[=v3.41]
\end{verbatim}
However, this depends on internal packages of
\href{https://komascript.de/}{\KOMAScript}.
\item The hacks of the legacy version have been frozen. So the
hacks may break with packages or \LaTeX{} versions released after
2023-07-07. There is no support for such combinations!
\item Loading the legacy version more than once with different option setting
still results in option clash errors.
\end{itemize}
\paragraph{Available options with \pkg*{scrhack}:}
\begin{description}
\item[\opt{float=\meta{boolean}}:]
\DescribeOption[noprint]{float=\meta{boolean}}%
\hfill initial: \optvalue{true}, default: \optvalue{true}\\
After package \pkg{float} is loaded, load also package \pkg{floatbytocbasic}
to fix the issue explained in \autoref{sec:history}. This also provides the
full functionality of \pkg{tocbasic} to \pkg{float}.
\item[\opt{floatrow=\meta{boolean}}:]
\DescribeOption[noprint]{floatrow=\meta{boolean}}%
\hfill initial: \optvalue{true}, default: \optvalue{true}\\
After package \pkg{floatrow} is loaded, load also package
\pkg{floatbytocbasic} to fix the issue explained in
\autoref{sec:history}. This also provides the full functionality of
\pkg{tocbasic} to \pkg{floatrow}.
\item[\opt{hyperref=\meta{boolean}}:]
\DescribeOption[noprint]{hyperref=\meta{boolean}}%
\hfill
\marginline{\raisebox{\dimexpr\ht\strutbox-\height\relax}{\Huge\textcolor{red}{!}}}%
initial: \optvalue{false}, default: \optvalue{true}\\
Option \opt{hyperref} is deprecated. It is implemented for compatibility
reasons only. Using \opt{hyperref} without value or \opt{hyperref=true}
results in a warning. Using \opt{hyperref=false} results in an info only.
\item[\opt{listings=\meta{boolean}}:]
\DescribeOption[noprint]{listings=\meta{boolean}}%
\hfill
\marginline{\raisebox{\dimexpr\ht\strutbox-\height\relax}{\Huge\textcolor{red}{!}}}%
initial: \optvalue{false}, default: \optvalue{true}\\
Option \opt{listings} is deprecated. It is implemented for compatibility
reasons only. Using \opt{listings} without value or \opt{listings=true}
results in a warning. Using \opt{listings=false} results in an info only.
\item[\opt{lscape=\meta{boolean}}:]
\DescribeOption[noprint]{lscape=\meta{boolean}}%
\hfill initial: \optvalue{true}, default: \optvalue{true}\\
After package \pkg{lscape} is loaded, load also package
\pkg{lscapeenhanced} to fix an issue with detection of text height for
some packages like \pkg{scrlayer} and \pkg{showframe}.
\item[\opt{nomencl=\meta{boolean}}:]
\DescribeOption[noprint]{nomencl=\meta{boolean}}%
\hfill
\marginline{\raisebox{\dimexpr\ht\strutbox-\height\relax}{\Huge\textcolor{red}{!}}}%
initial: \optvalue{false}, default: \optvalue{true}\\
Option \opt{nomencl} is deprecated. It is implemented for compatibility
reasons only. Using \opt{nomencl} without value or \opt{nomencl=true}
results in a warning. Using \opt{nomencl=false} results in an info only.
\item[\opt{setspace=\meta{boolean}}:]
\DescribeOption[noprint]{setspace=\meta{boolean}}%
\hfill initial: \optvalue{true}, default: \optvalue{true}\\
After package \pkg{setspace} is loaded, load also package
\pkg{setspaceenhanced} with the same options plus options \opt{byselectfont}
and \opt{keepfontsize}.
\item[\opt{standardsectioning=\meta{boolean}}:]
\DescribeOption[noprint]{standardsectioning=\meta{boolean}}%
\hfill initial: \optvalue{false}, default: \optvalue{true}\\
Load package \pkg{standardsectioning} to (re-)define the sectioning commands
using the code from the standard classes. If \pkg*{scrhack} is loaded
\emph{before} any class\footnote{This is detected heuristic by definition of
\cs{normalsize}. If \cs{normalsize} contains \cs{@latex@error} no class
has been loaded.} the definition is delayed until a class has been loaded.
\end{description}
\paragraph{Available options with the legacy version:}
\begin{description}
\item[\opt{float=\meta{boolean}}:] \hfill
initial: \optvalue{true}, default: \optvalue{true}\\
After package \pkg{float} is loaded, load \file{float.hak} to fix the issue
explained in \autoref{sec:history}. This also provides the full
functionality of \pkg{tocbasic} to \pkg{float}.
\item[\opt{floatrow=\meta{boolean}}:] \hfill
initial: \optvalue{true}, default: \optvalue{true}\\
After package \pkg{floatrow} is loaded, load \file{floatrow.hak} to fix the
issue explained in \autoref{sec:history}. This also provides the full
functionality of \pkg{tocbasic} to \pkg{floatrow}.
\item[\opt{hyperref=\meta{boolean}}:] \hfill
initial: \optvalue{true}, default: \optvalue{true}\\
Versions of \pkg{hyperref} before 6.79h set the link anchors after the
heading of the starred versions of commands like \cs{part*}, \cs{chapter*},
etc. instead of before them. Since then, this problem has been resolved at
the suggestion of \KOMAScript's author. But because the change took more
than a year, a patch was added to \pkg*{scrhack}. Although this can also be
deactivated with \opt{hyperref=false}, you should instead use an up-to-date
\pkg{hyperref} release. In this case the legacy version of \pkg*{scrhack}
automatically deactivates this unnecessary patch.
\item[\opt{listings=\meta{boolean}}:] \hfill
initial: \optvalue{true}, default: \optvalue{true}\\
After package \pkg{listings} is loaded, load \file{listings.hak} to fix the
issue explained in \autoref{sec:history}. This also provides the full
functionality of \pkg{tocbasic} to old versions of \pkg{listings}. With
newer versions, also the legacy version of \pkg*{scrhack} automatically
deactivates this unnecessary patch.
\item[\opt{lscape=\meta{boolean}}:] \hfill
initial: \optvalue{true}, default: \optvalue{true}\\
The \pkg{lscape} package defines a \env{landscape} environment to set the
page contents, but not the header or footer in landscape mode. Inside this
environment, \len{textheight}is set to the value of \len{textwidth}, but
\len{textwidth} is not set to the former value of \len{textheight}. This is
inconsistent. As far as I know, \len{textwidth} is left unchanged because
setting it to \len{textheight} could interfere with other packages or user
commands. But changing \len{textheight} also has this potential, and indeed
it breaks, for example, \pkg{showframe} and \pkg{scrlayer}. Thus it would be
best if \len{textheight} too remained unchanged. After package \pkg{lscape}
is loaded, the legacy version of \pkg*{scrhack} loads \file{lscape.hak},
that uses the \pkg{xpatch} package to modify the \env{landscape}
environment's start macro \cs{landscape} appropriately.
Incidentally, the \pkg{pdflscape} package also uses \pkg{lscape}, so this
option affects the functioning of this package too.
\item[\opt{nomencl=\meta{boolean}}:] \hfill
initial: \optvalue{true}, default: \optvalue{true}\\
After package \pkg{nomencl} is loaded, load \file{nomencl.hak} to fix the
issue explained in \autoref{sec:history}. This is a little bit more
complicated, because the \pkg*{nomencl} author has also adapted his
package to support \pkg{tocbasic}. So additional versions checks are done.
\item[\opt{setspace=\meta{boolean}}:] \hfill
initial: \optvalue{true}, default: \optvalue{true}\\
Some packages assume that the class-internal macro \cs{@ptsize} both is
defined and expands to an integer. For compatibility,
\href{https://komascript.de/}{\KOMAScript} defines \cs{@ptsize} even if the
basic font size is something other than 10\,pt, 11\,pt, or 12\,pt.
\href{https://komascript.de/}{\KOMAScript} also allows non-integer font
sizes. So \cs{@ptsize} can, of course, also expand to a non-integer number.
One of the packages that cannot cope with a non-integer \cs{@ptsize} is
\pkg{setspace}. Additionally, the values set by this package are always
dependent on the basic font size, even if the setting is made in the context
of another font size. The legacy version of \pkg{scrhack} loads the hack
\file{setspace.hak} after package \pkg{setspace} to solves both problems by
redefining \cs{onehalfspacing} and \cs{doublespacing} to set the spacing
relative to the actual font size.
\textbf{Note:} if you use \pkg{setspace} with either the
\opt{onehalfspacing} or \opt{doublespacing} option, you must load
\pkg*{scrhack} first.
\item[\opt{standardsections=\meta{boolean}}] \hfill
initial: \optvalue{false}, default: \optvalue{true}\\
Various packages assume that the sectioning commands are defined in a
specific way, corresponding to the definitions in the standard classes. But
for some classes this is not the case. For example, the
\href{https://komascript.de/}{\KOMAScript} classes use a completely
different implementation to provide many additional features. But this can
cause problems for packages that depend on the definition of the standard
classes. The legacy version of \pkg*{scrhack} offers the option to force
the sectioning commands \cs{part}, \cs{chapter}, \cs{section},
\cs{subsection}, \cs{subsubsection}, \cs{paragraph}, and \cs{subparagraph}
to be compatible with those in the standard classes. When \cs{chapter} is
defined, the definitions are based on those in \cls{book}. When \cs{chapter}
is undefined, the definitions of \cls{article} are used.
If you are using a \href{https://komascript.de/}{\KOMAScript} class, several
features of these classes are also deactivated as side effect. For example,
the commands to define or modify sectioning commands or option
\opt{headings} are no longer available, and commands like \cs{partformat}
have different defaults.
Because this hack has the potential to do more harm than good, it issues
several warnings. Also it is not activated simply by loading the legacy
version of \pkg*{scrhack} package. If you want to use it, you must explicitly
activate this option when you load the package. Late activation or
deactivation is not supported.
Since there are often less invasive solutions to fix the problem of package
incompatibilities, using this hack is not recommended. It is provided only
as a last resort for emergencies.
\end{description}
%
% \iffalse
%</doc>
% \fi
%
% \MaybeStop{\printbibliography[heading=bibintoc]\PrintIndex}
%
% \iffalse
%<*package>
%<@@=scrhack>
% \fi
% \section{Implementation}
%
% Because \pkg*{scrhack} is not longer a
% \href{https://komascript.de/}{\KOMAScript} package, it does not use the
% \texttt{KOMA} family for options any longer. Instead it uses the new
% \LaTeX{} kernel feature of key-value-options introduced in
% \autocite{latexnews35}. So we need at least \LaTeX{} 2022-06-01:
% \begin{macrocode}
\ifnum 0=\ifcsname IfFormatAtLeastTF\endcsname
\IfFormatAtLeastTF{2022-06-01}{1}{0}%
\else
0%
\fi\relax
\PackageError{scrhack}{LaTeX kernel too old}{%
The package needs at least LaTeX 2022-06-01.\MessageBreak
This error is fatal. Loading will be aborted.%
}%
\endinput
\fi
\ExplSyntaxOn
% \end{macrocode}
%
% \subsection{Messages}
%
% We need some messages, that are not specific for only one use-case.
% \begin{itemize}
% \item If an option is ignored, because it cannot be handled after already
% loading the enhancement package. \#1 is the name option, \#2 is the
% enhancement package.
% \end{itemize}
% \begin{macrocode}
\msg_new:nnn { scrhack } { option-too-late }
{
option~`#1'~after~loading~package~`#2'~ignored.
}
% \end{macrocode}
% \begin{itemize}
% \item If an option is ignored, because it is deprecated.
% \end{itemize}
% \begin{macrocode}
\msg_new:nnn { scrhack } { deprecated-option }
{
deprecated~option~`#1'~ignored.
}
% \end{macrocode}
%
% \subsection{Emulating \file{float.hak}}
% First we declare the options using the new key-value interface:
% \begin{macrocode}
\DeclareKeys{%
float .code = \@@_switch_float:n { #1 },
float .default:n = true,
float .usage = preamble,
}
% \end{macrocode}
%
% \ExplSyntaxOn
% \begin{macro}{\__scrhack_switch_float:n}
% \ExplSyntaxOff
% This is used to switch the state and add or remove the hook if needed. A new
% boolean is used to know, whether the hook has been put. Using
% \opt{float=true}, if package \pkg{floatbytocbasic} already has been loaded
% isn't a foul. So we just write an information to the \file{log}. But using
% \opt{float=false}, if package \pkg{floatbytocbasic} already has been loaded
% may be wrong. So we use a warning message. We also warn if a not allowed
% value is used.
% \begin{macrocode}
\bool_new:N \@@_float_bool
\cs_new:Nn \@@_switch_float:n
{
\str_case_e:nnF { \str_foldcase:n { #1 } }
{
{true} {
\@ifpackageloaded { floatbytocbasic }
{
\msg_info:nnnn { scrhack } { option-too-late }
{ float = true } { floatbytocbasic }
}
{
\bool_if:NF \@@_float_bool
{
\hook_gput_code:nnn { package/float/after } { scrhack }
{
\RequirePackage { floatbytocbasic }
}
\bool_gset_true:N \@@_float_bool
}
}
}
{false} {
\@ifpackageloaded { floatbytocbasic }
{
\msg_warning:nnnn { scrhack } { option-too-late }
{ float=false } { floatbytocbasic }
}
{
\bool_if:NT \@@_float_bool
{
\hook_gremove_code:nn { package/float/after } { scrhack }
}
\bool_gset_false:N \@s@_float_bool
}
}
}
{
\msg_warning:nnn { keys } { boolean-values-only } { float }
}
}
\SetKeys{float=true}
% \end{macrocode}
% \end{macro}
% \ExplSyntaxOff
%
% \subsection{Emulating \file{floatrow.hak}}
% First we declare the options using the new key-value interface:
% \begin{macrocode}
\DeclareKeys{%
floatrow .code = \@@_switch_floatrow:n { #1 },
floatrow .default:n = true,
floatrow .usage = preamble,
}
% \end{macrocode}
%
% \ExplSyntaxOn
% \begin{macro}{\__scrhack_switch_floatrow:n}
% \ExplSyntaxOff
% This is used to switch the state and add or remove the hook if needed. A new
% boolean is used to know, whether the hook has been put. Using
% \opt{floatrow=true}, if package \pkg{floatrowbytocbasic} already has been
% loaded isn't a foul. So we just write an information to the \file{log}. But
% using \opt{floatrow=false}, if package \pkg{floatrowbytocbasic} already has
% been loaded may be wrong. So we use a warning message. We also warn if a not
% allowed value is used.
% \begin{macrocode}
\bool_new:N \@@_floatrow_bool
\cs_new:Nn \@@_switch_floatrow:n
{
\str_case_e:nnF { \str_foldcase:n { #1 } }
{
{true} {
\@ifpackageloaded { floatrowbytocbasic }
{
\msg_info:nnnn { scrhack } { option-too-late }
{ floatrow = true } { floatrowbytocbasic }
}
{
\bool_if:NF \@@_floatrow_bool
{
\hook_gput_code:nnn { package/floatrow/after }
{ scrhack }
{
\RequirePackage { floatrowbytocbasic }
}
\bool_gset_true:N \@@_floatrow_bool
}
}
}
{false} {
\@ifpackageloaded { floatrowbytocbasic }
{
\msg_warning:nnnn { scrhack } { option-too-late }
{ floatrow=false } { floatrowbytocbasic }
}
{
\bool_if:NT \@@_floatrow_bool
{
\hook_gremove_code:nn { package/floatrow/after }
{ scrhack }
}
\bool_gset_false:N \@s@_floatrow_bool
}
}
}
{
\msg_warning:nnn { keys } { boolean-values-only } { floatrow }
}
}
\SetKeys{floatrow=true}
% \end{macrocode}
% \end{macro}
% \ExplSyntaxOff
%
% \subsection{Emulating \file{hyperref.hak}}
%
% First we declare the options using the new key-value interface:
% \begin{macrocode}
\DeclareKeys{%
hyperref .code = \@@_switch_hyperref:n { #1 },
hyperref .default:n = true,
hyperref .usage = preamble,
}
% \end{macrocode}
%
% \ExplSyntaxOn
% \begin{macro}{\__scrhack_switch_hyperref:n}
% \ExplSyntaxOff
% This is somehow special, because the hack is deprecated. It only has been
% needed for \pkg{hyperref} versions released before 2009-11-24, which would
% not work with the \LaTeX{} kernel version needed by this version of
% \pkg*{scrhack}. So emulating the hack does not make sense. Instead the
% initial value of the option is changed to implicit \optvalue{false} and
% switching it on explicitly does result in a warning.
% \begin{macrocode}
\cs_new:Nn \@@_switch_hyperref:n
{
\str_case_e:nnF { \str_foldcase:n { #1 } }
{
{true} {
\msg_warning:nnn { scrhack } { deprecated-option }
{ hyperref=#1 }
}
{false} {
\msg_info:nnn { scrhack } { deprecated-option }
{ hyperref=#1 }
}
}
{
\msg_warning:nnn { keys } { boolean-values-only } { hyperref }
}
}
% \end{macrocode}
% \end{macro}
% \ExplSyntaxOff
%
% \subsection{Emulating \file{listings.hak}}
% First we declare the options using the new key-value interface:
% \begin{macrocode}
\DeclareKeys{%
listings .code = \@@_switch_listings:n { #1 },
listings .default:n = true,
listings .usage = preamble,
}
% \end{macrocode}
%
% \ExplSyntaxOn
% \begin{macro}{\__scrhack_switch_listings:n}
% \ExplSyntaxOff
% This is somehow special, because the hack is deprecated. It only has
% been needed for \pkg{listings} version released before 2024-02-15. So
% instead of using any patch hacks, users should update \pkg{listings}. So
% emulating the hack does not make sense. Instead the initial value of the
% option is changed to implicit \optvalue{false} and switching it on
% explicitly does result in a warning.
% \begin{macrocode}
\cs_new:Nn \@@_switch_listings:n
{
\str_case_e:nnF { \str_foldcase:n { #1 } }
{
{true} {
\msg_warning:nnn { scrhack } { deprecated-option }
{ listings=#1 }
}
{false} {
\msg_info:nnn { scrhack } { deprecated-option }
{ listings=#1 }
}
}
{
\msg_warning:nnn { keys } { boolean-values-only } { listings }
}
}
% \end{macrocode}
% \end{macro}
% \ExplSyntaxOff
%
% \subsection{Emulating \file{lscape.hak}}
% First we declare the options using the new key-value interface:
% \begin{macrocode}
\DeclareKeys{%
lscape .code = \@@_switch_lscape:n { #1 },
lscape .default:n = true,
lscape .usage = preamble,
}
% \end{macrocode}
%
% \ExplSyntaxOn
% \begin{macro}{\__scrhack_switch_lscape:n}
% \ExplSyntaxOff
% This is used to switch the state and add or remove the hook if needed. A new
% boolean is used to know, whether the hook has been put. Using
% \opt{lscape=true}, if package \pkg{lscapeenhanced} already has been
% loaded isn't a foul. So we just write an information to the \file{log}. But
% using \opt{lscape=false}, if package \pkg{lscapeenhanced} already has
% been loaded may be wrong. So we use a warning message. We also warn if a not
% allowed value is used.
% \begin{macrocode}
\bool_new:N \@@_lscape_bool
\cs_new:Nn \@@_switch_lscape:n
{
\str_case_e:nnF { \str_foldcase:n { #1 } }
{
{true} {
\@ifpackageloaded { lscapeenhanced }
{
\msg_info:nnnn { scrhack } { option-too-late }
{ lscape = true } { lscapeenhanced }
}
{
\bool_if:NF \@@_lscape_bool
{
\hook_gput_code:nnn { package/lscape/after }
{ scrhack }
{
\RequirePackage { lscapeenhanced }
}
\bool_gset_true:N \@@_lscape_bool
}
}
}
{false} {
\@ifpackageloaded { lscapeenhanced }
{
\msg_warning:nnnn { scrhack } { option-too-late }
{ lscape=false } { lscapeenhanced }
}
{
\bool_if:NT \@@_lscape_bool
{
\hook_gremove_code:nn { package/lscape/after }
{ scrhack }
}
\bool_gset_false:N \@s@_lscape_bool
}
}
}
{
\msg_warning:nnn { keys } { boolean-values-only } { lscape }
}
}
\SetKeys{lscape=true}
% \end{macrocode}
% \end{macro}
% \ExplSyntaxOff
%
% \subsection{Emulating \file{nomencl.hak}}
%
% First we declare the options using the new key-value interface:
% \begin{macrocode}
\DeclareKeys{%
nomencl .code = \@@_switch_nomencl:n { #1 },
nomencl .default:n = true,
nomencl .usage = preamble,
}
% \end{macrocode}
%
% \ExplSyntaxOn
% \begin{macro}{\__scrhack_switch_nomencl:n}
% \ExplSyntaxOff
% This is somehow special, because the hack is deprecated. It only has been
% needed for \pkg{nomencl} versions released before 2019-01-23. So updating
% the package would be the better \emph{hack}. So emulating the hack does not
% make sense. Instead the initial value of the option is changed to implicit
% \optvalue{false} and switching it on explicitly does result in a warning.
% \begin{macrocode}
\cs_new:Nn \@@_switch_nomencl:n
{
\str_case_e:nnF { \str_foldcase:n { #1 } }
{
{true} {
\msg_warning:nnn { scrhack } { deprecated-option }
{ nomencl=#1 }
}
{false} {
\msg_info:nnn { scrhack } { deprecated-option }
{ nomencl=#1 }
}
}
{
\msg_warning:nnn { keys } { boolean-values-only } { nomencl }
}
}
% \end{macrocode}
% \end{macro}
% \ExplSyntaxOff
%
%
% \subsection{Emulating \file{setspace.hak}}
% First we declare the options using the new key-value interface:
% \begin{macrocode}
\DeclareKeys{%
setspace .code = \@@_switch_setspace:n { #1 },
setspace .default:n = true,
setspace .usage = preamble,
}
% \end{macrocode}
%
% \ExplSyntaxOn
% \begin{macro}{\__scrhack_switch_setspace:n}
% \ExplSyntaxOff
% This is used to switch the state and add or remove the hook if needed. A new
% boolean is used to know, whether the hook has been put. Using
% \opt{setspace=true}, if package \pkg{setspaceenhanced} already has been loaded
% isn't a foul. So we just write an information to the \file{log}. But using
% \opt{setspace=false}, if package \pkg{setspaceenhanced} already has been loaded
% may be wrong. So we use a warning message. We also warn if a not allowed
% value is used.
% \begin{macrocode}
\bool_new:N \@@_setspace_bool
\cs_new:Nn \@@_switch_setspace:n
{
\str_case_e:nnF { \str_foldcase:n { #1 } }
{
{true} {
\@ifpackageloaded { setspaceenhanced }
{
\msg_info:nnnn { scrhack } { option-too-late }
{ setspace = true } { setspaceenhanced }
}
{
\bool_if:NF \@@_setspace_bool
{
\hook_gput_code:nnn { package/setspace/after } { scrhack }
{
\exp_last_unbraced:Ne \RequirePackage
{
[ \use:c { @raw@opt@setspace.sty },
byselectfont,
keepfontsize ]
}
{ setspaceenhanced }
}
\bool_gset_true:N \@@_setspace_bool
}
}
}
{false} {
\@ifpackageloaded { setspaceenhanced }
{
\msg_warning:nnnn { scrhack } { option-too-late }
{ setspace=false } { setspaceenhanced }
}
{
\bool_if:NT \@@_setspace_bool
{
\hook_gremove_code:nn { package/setspace/after } { scrhack }
}
\bool_gset_false:N \@s@_setspace_bool
}
}
}
{
\msg_warning:nnn { keys } { boolean-values-only } { setspace }
}
}
\SetKeys{setspace=true}
% \end{macrocode}
% \end{macro}
% \ExplSyntaxOff
%
% \subsection{Emulating \file{standardsectioning.hak}}
% First we declare the options using the new key-value interface:
% \begin{macrocode}
\DeclareKeys{%
standardsections .code = \@@_switch_standardsectioning:n { #1 },
standardsections .default:n = true,
standardsections .usage = preamble,
}
% \end{macrocode}
%
% \ExplSyntaxOn
% \begin{macro}{\__scrhack_switch_standardsectioning:n}
% \ExplSyntaxOff
% This is used to switch the state and add or remove the hook if needed. A new
% boolean is used to know, whether the hook has been put. Using
% \opt{standardsectioning=true}, if package \pkg{standardsectioning}
% already has been loaded isn't a foul. So we just write an information to the
% \file{log}. But using \opt{standardsectioning=false}, if package
% \pkg{standardsectioning} already has been loaded may be wrong. So
% we use a warning message. We also warn if a not allowed value is used.
% \begin{macrocode}
\bool_new:N \@@_standardsectioning_bool
\cs_new:Nn \@@_switch_standardsectioning:n
{
\str_case_e:nnF { \str_foldcase:n { #1 } }
{
{true} {
\@ifpackageloaded { standardsectioning }
{
\msg_info:nnnn { scrhack } { option-too-late }
{ standardsectioning = true } { standardsectioning }
}
{
\bool_if:NF \@@_standardsectioning_bool
{
\str_set:Nx \l_tmpa_str { \cs_meaning:N \normalsize }
\str_if_in:NnTF
\l_tmpa_str
{ \@latex@error }
{
\hook_gput_code:nnn { class/after } { scrhack }
{
\RequirePackage { standardsectioning }
\exp_args:Nnnx \hook_gput_code:nnn
{ begindocument/before } { scrhack }
{
\exp_not:N \cs_gset:Npn
\exp_after:wN \exp_not:N
\cs:w ver@standardsectioning.sty \cs_end:
{
\cs:w ver@standardsectioning.sty \cs_end:
}
}
\cs_undefine:c { var@standardsectioning.sty }
}
\bool_gset_true:N \@@_standardsectioning_bool
}
{
\RequirePackage{ standardsectioning }
\bool_gset_false:N \@@_standardsectioning_bool
}
}
}
}
{false} {
\@ifpackageloaded { standardsectioning }
{
\msg_warning:nnnn { scrhack } { option-too-late }
{ standardsectioning=false } { standardsectioning }
}
{
\bool_if:NT \@@_standardsectioning_bool
{
\hook_gremove_code:nn { class/after } { scrhack }
}
\bool_gset_false:N \@s@_standardsectioning_bool
}
}
}
{
\msg_warning:nnn { keys } { boolean-values-only } { standardsectioning }
}
}
% \end{macrocode}
% \end{macro}
% \ExplSyntaxOff
%
%
%
% \subsection{Processing the options}
% Last but not least, we set the defaults and process the options.
% \begin{macrocode}
\ExplSyntaxOff
\ProcessKeyOptions\relax
% \end{macrocode}
%
% \iffalse
%</package>
% \fi
%
% \Finale
% \PrintChanges
%
% \endinput
% Local Variables:
% mode: doctex
% ispell-local-dictionary: "en_US"
% eval: (flyspell-mode 1)
% TeX-master: t
% 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:
|