Debian Codegraph @

texmf-dist/source/latex/scrhack/scrhack.dtx

raw
1 % \iffalse meta-comment
2 % ======================================================================
3 % scrhack.dtx
4 % Copyright © 2008–2024 Markus Kohm
5 %
6 % This work is a KOMA-Script spin-off. For the original sources of
7 % KOMA-Script's `scrhack.sty' see file `scrhack.dtx' in the KOMA-Script
8 % sources at <https://sourceforge.net/p/koma-script/code/>.
9 %
10 % Development is taking place as part of `scrhack' at
11 % <https://github.com/komascript/third-party-enhancements>. New issues
12 % should be reported there as well as known issues can be found.
13 %
14 % This work may be distributed and/or modified under the conditions of
15 % the LaTeX Project Public License, version 1.3c of the license.
16 % The latest version of this license is in
17 % http://www.latex-project.org/lppl.txt
18 % and version 1.<3c or later is part of all distributions of LaTeX
19 % version 2005/12/01 or later and of this work.
20 %
21 % This work has the LPPL maintenance status "author-maintained".
22 %
23 % The Current Maintainer and author of this work is Markus Kohm.
24 %
25 % This work consists of the file `scrhack.dtx',
26 % `scrhack-2023-07-07,dtx', and `README.md'.
27 %
28 % The recommended way to install `scrhack' is to use
29 % the package manager of your TeX distribution.
30 % ======================================================================
31 %
32 %<*dtx>
33 \ifx\ProvidesFile\undefined\def\ProvidesFile#1[#2]{}\fi
34 \ProvidesFile{scrhack.dtx}
35 %</dtx>
36 %<package>\providecommand\DeclareRelease[3]{}
37 %<package>\providecommand\DeclareCurrentRelease[2]{}
38 %<package>\DeclareRelease{v3.41}{2023-07-07}{scrhack-2023-07-07.sty}
39 %<package>\DeclareCurrentRelease{}{2023-07-15}
40 %<*dtx|package>
41 %<package>\ProvidesPackage{scrhack}
42 [2024-09-04 v3.42
43 %<dtx> sources and unpack driver of
44 scrhack emulation package]
45 %</dtx|package>
46 %<*dtx>
47 \ifx\documentclass\undefined
48 \input docstrip.tex
49 \generate{%
50 \file{scrhack.sty}{%
51 \from{scrhack.dtx}{package}%
52 }%
53 }%
54 \else
55 \let\endbatchfile\relax
56 \fi
57 \endbatchfile
58 \documentclass[ngerman,USenglish]{koma-script-source-doc}
59 \usepackage{babel}
60 \usepackage{csquotes}
61 \usepackage[style=alphabetic]{biblatex}
62 \begin{filecontents}[force]{\jobname.bib}
63 @online{pkg:koma-script,
64 author={Markus Kohm},
65 version={3.41},
66 date={2023-07-07},
67 title={{\KOMAScript} --- A bundle of versatile classes and packages},
68 url={https://ctan.org/pkg/koma-script},
69 urldate={2023-07-14},
70 note={The \KOMAScript{} bundle provides replacements for the \pkg*{article},
71 \pkg*{report}, and \pkg*{book} classes with emphasis on typography and
72 versatility. There is also a letter class.},
73 }
74 @manual{pkg:koma-script:manual:de,
75 author={Markus Kohm},
76 date={2023-06-16},
77 title={{\KOMAScript}},
78 subtitle={Die Anleitung},
79 url={http://mirrors.ctan.org/macros/latex/contrib/koma-script/scrguide-de.pdf},
80 urldate={2023-07-04},
81 }
82 @manual{pkg:koma-script:manual:en,
83 author={Markus Kohm},
84 date={2023-06-16},
85 title={{\KOMAScript}},
86 subtitle={The Guide},
87 url={http://mirrors.ctan.org/macros/latex/contrib/koma-script/scrguide-en.pdf},
88 urldate={2023-07-14},
89 }
90 @article{latexnews35,
91 author={{The {\LaTeX} Project Team}},
92 shortauthor={TLT},
93 year={2022},
94 month={6},
95 title={Issue 35},
96 journal={{\LaTeX} News},
97 url={http://mirrors.ctan.org/macros/latex/base/ltnews35.pdf},
98 urldate={2023-07-14},
99 }
100 \end{filecontents}
101 \addbibresource{\jobname.bib}
102 \setcounter{StandardModuleDepth}{2}
103 \providecommand*{\seclabel}[1]{\label{sec:#1}}
104 \begin{document}
105 \nocite{pkg:koma-script}
106 \DocInput{scrhack.dtx}
107 \end{document}
108 %</dtx>
109 %\fi
110 %
111 % \changes{v0.1}{2023/07/14}{start of \KOMAScript{} spin-off}
112 %
113 % \GetFileInfo{scrhack.dtx}
114 % \title{Emulating Former \href{https://komascript.de/}{\KOMAScript} Package
115 % \pkg*{scrhack}}
116 % \author{\href{mailto:[email protected]}{Markus Kohm}}
117 % \date{Version \filedate{} \fileversion}
118 % \maketitle
119 % \begin{abstract}
120 % For several years \href{https://komascript.de/}{\KOMAScript} provided a
121 % package \pkg*{scrhack}, that has been made not only to improve the
122 % compatibility of third-party packages with
123 % \href{https://komascript.de/}{\KOMAScript} classes, but also to generally
124 % improve third-party packages. The package consisted not only in the
125 % package file \file{scrhack.sty} but also in several so called \emph{hacks}
126 % as separate files with extension \file{.hak}. In the course of splitting
127 % off former \href{https://komascript.de/}{\KOMAScript} packages from the
128 % \href{https://komascript.de/}{\KOMAScript} collection, it was decided to
129 % create independent packages from the individual hacks. These new
130 % independent packages then serve as replacements for the original packages
131 % they were intended to improve. In addition, to preserve the functionality
132 % of loading the enhancements only when the corresponding original package
133 % is loaded, a new \pkg*{scrhack} was created to do just that.
134 % \end{abstract}
135 %
136 % \tableofcontents
137 %
138 %\iffalse
139 %<*doc>
140 %\fi
141 % \section{History}
142 % \label{sec:history}
143 Some packages from other authors do not work well with
144 \href{https://komascript.de/}{\KOMAScript}. It is often very tedious for the
145 author of \href{https://komascript.de/}{\KOMAScript} to convince the authors
146 of these packages to make specific improvements. This also applies to packages
147 whose development has been discontinued. That's why the \pkg*{scrhack} was
148 created. This package alters the commands and definitions of other to work
149 better with \href{https://komascript.de/}{\KOMAScript}. Some changes are also
150 useful when using other classes.
151
152 In the early days of \href{https://komascript.de/}{\KOMAScript}, users wanted
153 to handle lists of floating environments created with the \pkg{float} package
154 in the same way as the list of figures and list of tables created by
155 \href{https://komascript.de/}{\KOMAScript} itself. At that time the author of
156 \href{https://komascript.de/}{\KOMAScript} contacted the author of
157 \pkg{float} to propose an interface to support such an enhancement. A
158 somewhat modified form of that interface was implemented with the
159 \cs{float@listhead} and \cs{float@addtolists} commands.
160
161 Later it became apparent that these two commands were not flexible enough to
162 fully support all of \href{https://komascript.de/}{\KOMAScript}'s
163 capabilities. Unfortunately, the author of \pkg{float} had already ceased
164 development by that point, so further changes to this package cannot be
165 expected.
166
167 Other package authors have also adopted these two commands, and it became
168 apparent that the implementation in some packages, including \pkg{float},
169 means that all these packages can only be loaded in a specific order, even
170 though they are otherwise unrelated to each other.
171
172 To overcome all these disadvantages and problems,
173 \href{https://komascript.de/}{\KOMAScript} no longer officially supports this
174 old interface. Instead, \href{https://komascript.de/}{\KOMAScript} warns if
175 the old interface is used. At the same time, the \pkg{tocbasic} package has
176 been designed and implemented as a central interface for managing of table of
177 contents and similar content lists. This package provides many more
178 advantages and features than the two old commands.
179
180 Although the effort to use this package is very small, so far the authors of
181 most of the packages that use the old interface have not made any adjustments.
182 Therefore the \KOMAScript author designed a new
183 package \pkg*{scrhack} as part of
184 \href{https://komascript.de/}{\KOMAScript}. That package contained appropriate
185 modifications of the packages
186 \pkg{float}, \pkg{floatrow}, \pkg{listings}, and later on also for
187 \pkg{nomencl} and some others not related to that interface. Merely loading
188 \pkg*{scrhack} was sufficient to make these packages recognize not only the
189 setting of the \href{https://komascript.de/}{\KOMAScript} option \opt{listof},
190 but, e.g., also to react to the language switching features of the
191 \pkg{babel} package. You can find more information
192 about the features available by switching packages to \pkg{tocbasic} in
193 \autocite{pkg:koma-script:manual:en} or \autocite{pkg:koma-script:manual:de}.
194
195 With release of version 3.42 package \pkg*{scrhack} has been removed from
196 \href{https://komascript.de/}{\KOMAScript}. The code of the former package has
197 been split into several standalone packages, that can be loaded individually
198 if needed. However, for compatibility and maybe for convenience there is also
199 a new standalone package \pkg*{scrhack} almost compatible with the old
200 one.
201
202 \section{Using \texorpdfstring{\pkg*{scrhack}}{scrhack}}
203 \seclabel{usage}
204
205 It is recommended to load the \pkg*{scrhack} package using:
206 \begin{verbatim}
207 \usepackage{scrhack}
208 \end{verbatim}
209 as early as possible. In particular, loading should be done before the
210 affected packages. The package also provides several options, one for each
211 hack. Usually the options are named identically to the package, that is
212 patched by the hack. All these options are boolean options. You can switch
213 such an option on assigning value \optvalue{true} or using it without
214 value. You can switch off such an option assigning value
215 \optvalue{false}. Switching off an option means to not automatically load the
216 corresponding enhancement package after the package, that has to be
217 patched. Therefore switching off an option results in not patching the
218 corresponding package.
219
220 \paragraph{Notes:}
221 \begin{itemize}
222 \item From version 3.42, you cannot use \cs{KOMAoptions} or \cs{KOMAoption}
223 any longer to change the options. Instead loading \pkg*{scrhack} again with
224 other options does not result in an option clash, but in a change of the
225 option settings.
226 \item Switching off an option of an already loaded enhancement package is
227 ignored (with warning). It does not unload the enhancement package or switch
228 back to a not patched functionality.
229 \item Switching on an option of a not yet loaded enhancement package would
230 result in loading the enhancement package.
231 \item From version 3.42, you should no longer load package
232 \pkg*{scrhack}. Instead you can and should simply load the individual
233 enhancement package when you need it.
234 \item If you need the old legacy version of \pkg*{scrhack} from
235 \href{https://komascript.de/}{\KOMAScript} 3.41 you can use:
236 \begin{verbatim}
237 \usepackage{scrhack}[=2023-07-07]
238 \end{verbatim}
239 or
240 \begin{verbatim}
241 \usepackage{scrhack}[=v3.41]
242 \end{verbatim}
243 However, this depends on internal packages of
244 \href{https://komascript.de/}{\KOMAScript}.
245 \item The hacks of the legacy version have been frozen. So the
246 hacks may break with packages or \LaTeX{} versions released after
247 2023-07-07. There is no support for such combinations!
248 \item Loading the legacy version more than once with different option setting
249 still results in option clash errors.
250 \end{itemize}
251
252 \paragraph{Available options with \pkg*{scrhack}:}
253 \begin{description}
254 \item[\opt{float=\meta{boolean}}:]
255 \DescribeOption[noprint]{float=\meta{boolean}}%
256 \hfill initial: \optvalue{true}, default: \optvalue{true}\\
257 After package \pkg{float} is loaded, load also package \pkg{floatbytocbasic}
258 to fix the issue explained in \autoref{sec:history}. This also provides the
259 full functionality of \pkg{tocbasic} to \pkg{float}.
260 \item[\opt{floatrow=\meta{boolean}}:]
261 \DescribeOption[noprint]{floatrow=\meta{boolean}}%
262 \hfill initial: \optvalue{true}, default: \optvalue{true}\\
263 After package \pkg{floatrow} is loaded, load also package
264 \pkg{floatbytocbasic} to fix the issue explained in
265 \autoref{sec:history}. This also provides the full functionality of
266 \pkg{tocbasic} to \pkg{floatrow}.
267 \item[\opt{hyperref=\meta{boolean}}:]
268 \DescribeOption[noprint]{hyperref=\meta{boolean}}%
269 \hfill
270 \marginline{\raisebox{\dimexpr\ht\strutbox-\height\relax}{\Huge\textcolor{red}{!}}}%
271 initial: \optvalue{false}, default: \optvalue{true}\\
272 Option \opt{hyperref} is deprecated. It is implemented for compatibility
273 reasons only. Using \opt{hyperref} without value or \opt{hyperref=true}
274 results in a warning. Using \opt{hyperref=false} results in an info only.
275 \item[\opt{listings=\meta{boolean}}:]
276 \DescribeOption[noprint]{listings=\meta{boolean}}%
277 \hfill
278 \marginline{\raisebox{\dimexpr\ht\strutbox-\height\relax}{\Huge\textcolor{red}{!}}}%
279 initial: \optvalue{false}, default: \optvalue{true}\\
280 Option \opt{listings} is deprecated. It is implemented for compatibility
281 reasons only. Using \opt{listings} without value or \opt{listings=true}
282 results in a warning. Using \opt{listings=false} results in an info only.
283 \item[\opt{lscape=\meta{boolean}}:]
284 \DescribeOption[noprint]{lscape=\meta{boolean}}%
285 \hfill initial: \optvalue{true}, default: \optvalue{true}\\
286 After package \pkg{lscape} is loaded, load also package
287 \pkg{lscapeenhanced} to fix an issue with detection of text height for
288 some packages like \pkg{scrlayer} and \pkg{showframe}.
289 \item[\opt{nomencl=\meta{boolean}}:]
290 \DescribeOption[noprint]{nomencl=\meta{boolean}}%
291 \hfill
292 \marginline{\raisebox{\dimexpr\ht\strutbox-\height\relax}{\Huge\textcolor{red}{!}}}%
293 initial: \optvalue{false}, default: \optvalue{true}\\
294 Option \opt{nomencl} is deprecated. It is implemented for compatibility
295 reasons only. Using \opt{nomencl} without value or \opt{nomencl=true}
296 results in a warning. Using \opt{nomencl=false} results in an info only.
297 \item[\opt{setspace=\meta{boolean}}:]
298 \DescribeOption[noprint]{setspace=\meta{boolean}}%
299 \hfill initial: \optvalue{true}, default: \optvalue{true}\\
300 After package \pkg{setspace} is loaded, load also package
301 \pkg{setspaceenhanced} with the same options plus options \opt{byselectfont}
302 and \opt{keepfontsize}.
303 \item[\opt{standardsectioning=\meta{boolean}}:]
304 \DescribeOption[noprint]{standardsectioning=\meta{boolean}}%
305 \hfill initial: \optvalue{false}, default: \optvalue{true}\\
306 Load package \pkg{standardsectioning} to (re-)define the sectioning commands
307 using the code from the standard classes. If \pkg*{scrhack} is loaded
308 \emph{before} any class\footnote{This is detected heuristic by definition of
309 \cs{normalsize}. If \cs{normalsize} contains \cs{@latex@error} no class
310 has been loaded.} the definition is delayed until a class has been loaded.
311 \end{description}
312
313 \paragraph{Available options with the legacy version:}
314 \begin{description}
315 \item[\opt{float=\meta{boolean}}:] \hfill
316 initial: \optvalue{true}, default: \optvalue{true}\\
317 After package \pkg{float} is loaded, load \file{float.hak} to fix the issue
318 explained in \autoref{sec:history}. This also provides the full
319 functionality of \pkg{tocbasic} to \pkg{float}.
320 \item[\opt{floatrow=\meta{boolean}}:] \hfill
321 initial: \optvalue{true}, default: \optvalue{true}\\
322 After package \pkg{floatrow} is loaded, load \file{floatrow.hak} to fix the
323 issue explained in \autoref{sec:history}. This also provides the full
324 functionality of \pkg{tocbasic} to \pkg{floatrow}.
325 \item[\opt{hyperref=\meta{boolean}}:] \hfill
326 initial: \optvalue{true}, default: \optvalue{true}\\
327 Versions of \pkg{hyperref} before 6.79h set the link anchors after the
328 heading of the starred versions of commands like \cs{part*}, \cs{chapter*},
329 etc. instead of before them. Since then, this problem has been resolved at
330 the suggestion of \KOMAScript's author. But because the change took more
331 than a year, a patch was added to \pkg*{scrhack}. Although this can also be
332 deactivated with \opt{hyperref=false}, you should instead use an up-to-date
333 \pkg{hyperref} release. In this case the legacy version of \pkg*{scrhack}
334 automatically deactivates this unnecessary patch.
335 \item[\opt{listings=\meta{boolean}}:] \hfill
336 initial: \optvalue{true}, default: \optvalue{true}\\
337 After package \pkg{listings} is loaded, load \file{listings.hak} to fix the
338 issue explained in \autoref{sec:history}. This also provides the full
339 functionality of \pkg{tocbasic} to old versions of \pkg{listings}. With
340 newer versions, also the legacy version of \pkg*{scrhack} automatically
341 deactivates this unnecessary patch.
342 \item[\opt{lscape=\meta{boolean}}:] \hfill
343 initial: \optvalue{true}, default: \optvalue{true}\\
344 The \pkg{lscape} package defines a \env{landscape} environment to set the
345 page contents, but not the header or footer in landscape mode. Inside this
346 environment, \len{textheight}is set to the value of \len{textwidth}, but
347 \len{textwidth} is not set to the former value of \len{textheight}. This is
348 inconsistent. As far as I know, \len{textwidth} is left unchanged because
349 setting it to \len{textheight} could interfere with other packages or user
350 commands. But changing \len{textheight} also has this potential, and indeed
351 it breaks, for example, \pkg{showframe} and \pkg{scrlayer}. Thus it would be
352 best if \len{textheight} too remained unchanged. After package \pkg{lscape}
353 is loaded, the legacy version of \pkg*{scrhack} loads \file{lscape.hak},
354 that uses the \pkg{xpatch} package to modify the \env{landscape}
355 environment's start macro \cs{landscape} appropriately.
356
357 Incidentally, the \pkg{pdflscape} package also uses \pkg{lscape}, so this
358 option affects the functioning of this package too.
359 \item[\opt{nomencl=\meta{boolean}}:] \hfill
360 initial: \optvalue{true}, default: \optvalue{true}\\
361 After package \pkg{nomencl} is loaded, load \file{nomencl.hak} to fix the
362 issue explained in \autoref{sec:history}. This is a little bit more
363 complicated, because the \pkg*{nomencl} author has also adapted his
364 package to support \pkg{tocbasic}. So additional versions checks are done.
365 \item[\opt{setspace=\meta{boolean}}:] \hfill
366 initial: \optvalue{true}, default: \optvalue{true}\\
367 Some packages assume that the class-internal macro \cs{@ptsize} both is
368 defined and expands to an integer. For compatibility,
369 \href{https://komascript.de/}{\KOMAScript} defines \cs{@ptsize} even if the
370 basic font size is something other than 10\,pt, 11\,pt, or 12\,pt.
371 \href{https://komascript.de/}{\KOMAScript} also allows non-integer font
372 sizes. So \cs{@ptsize} can, of course, also expand to a non-integer number.
373
374 One of the packages that cannot cope with a non-integer \cs{@ptsize} is
375 \pkg{setspace}. Additionally, the values set by this package are always
376 dependent on the basic font size, even if the setting is made in the context
377 of another font size. The legacy version of \pkg{scrhack} loads the hack
378 \file{setspace.hak} after package \pkg{setspace} to solves both problems by
379 redefining \cs{onehalfspacing} and \cs{doublespacing} to set the spacing
380 relative to the actual font size.
381
382 \textbf{Note:} if you use \pkg{setspace} with either the
383 \opt{onehalfspacing} or \opt{doublespacing} option, you must load
384 \pkg*{scrhack} first.
385 \item[\opt{standardsections=\meta{boolean}}] \hfill
386 initial: \optvalue{false}, default: \optvalue{true}\\
387 Various packages assume that the sectioning commands are defined in a
388 specific way, corresponding to the definitions in the standard classes. But
389 for some classes this is not the case. For example, the
390 \href{https://komascript.de/}{\KOMAScript} classes use a completely
391 different implementation to provide many additional features. But this can
392 cause problems for packages that depend on the definition of the standard
393 classes. The legacy version of \pkg*{scrhack} offers the option to force
394 the sectioning commands \cs{part}, \cs{chapter}, \cs{section},
395 \cs{subsection}, \cs{subsubsection}, \cs{paragraph}, and \cs{subparagraph}
396 to be compatible with those in the standard classes. When \cs{chapter} is
397 defined, the definitions are based on those in \cls{book}. When \cs{chapter}
398 is undefined, the definitions of \cls{article} are used.
399
400 If you are using a \href{https://komascript.de/}{\KOMAScript} class, several
401 features of these classes are also deactivated as side effect. For example,
402 the commands to define or modify sectioning commands or option
403 \opt{headings} are no longer available, and commands like \cs{partformat}
404 have different defaults.
405
406 Because this hack has the potential to do more harm than good, it issues
407 several warnings. Also it is not activated simply by loading the legacy
408 version of \pkg*{scrhack} package. If you want to use it, you must explicitly
409 activate this option when you load the package. Late activation or
410 deactivation is not supported.
411
412 Since there are often less invasive solutions to fix the problem of package
413 incompatibilities, using this hack is not recommended. It is provided only
414 as a last resort for emergencies.
415 \end{description}
416 %
417 % \iffalse
418 %</doc>
419 % \fi
420 %
421 % \MaybeStop{\printbibliography[heading=bibintoc]\PrintIndex}
422 %
423 % \iffalse
424 %<*package>
425 %<@@=scrhack>
426 % \fi
427 % \section{Implementation}
428 %
429 % Because \pkg*{scrhack} is not longer a
430 % \href{https://komascript.de/}{\KOMAScript} package, it does not use the
431 % \texttt{KOMA} family for options any longer. Instead it uses the new
432 % \LaTeX{} kernel feature of key-value-options introduced in
433 % \autocite{latexnews35}. So we need at least \LaTeX{} 2022-06-01:
434 % \begin{macrocode}
435 \ifnum 0=\ifcsname IfFormatAtLeastTF\endcsname
436 \IfFormatAtLeastTF{2022-06-01}{1}{0}%
437 \else
438 0%
439 \fi\relax
440 \PackageError{scrhack}{LaTeX kernel too old}{%
441 The package needs at least LaTeX 2022-06-01.\MessageBreak
442 This error is fatal. Loading will be aborted.%
443 }%
444 \endinput
445 \fi
446 \ExplSyntaxOn
447 % \end{macrocode}
448 %
449 % \subsection{Messages}
450 %
451 % We need some messages, that are not specific for only one use-case.
452 % \begin{itemize}
453 % \item If an option is ignored, because it cannot be handled after already
454 % loading the enhancement package. \#1 is the name option, \#2 is the
455 % enhancement package.
456 % \end{itemize}
457 % \begin{macrocode}
458 \msg_new:nnn { scrhack } { option-too-late }
459 {
460 option~`#1'~after~loading~package~`#2'~ignored.
461 }
462 % \end{macrocode}
463 % \begin{itemize}
464 % \item If an option is ignored, because it is deprecated.
465 % \end{itemize}
466 % \begin{macrocode}
467 \msg_new:nnn { scrhack } { deprecated-option }
468 {
469 deprecated~option~`#1'~ignored.
470 }
471 % \end{macrocode}
472 %
473 % \subsection{Emulating \file{float.hak}}
474 % First we declare the options using the new key-value interface:
475 % \begin{macrocode}
476 \DeclareKeys{%
477 float .code = \@@_switch_float:n { #1 },
478 float .default:n = true,
479 float .usage = preamble,
480 }
481 % \end{macrocode}
482 %
483 % \ExplSyntaxOn
484 % \begin{macro}{\__scrhack_switch_float:n}
485 % \ExplSyntaxOff
486 % This is used to switch the state and add or remove the hook if needed. A new
487 % boolean is used to know, whether the hook has been put. Using
488 % \opt{float=true}, if package \pkg{floatbytocbasic} already has been loaded
489 % isn't a foul. So we just write an information to the \file{log}. But using
490 % \opt{float=false}, if package \pkg{floatbytocbasic} already has been loaded
491 % may be wrong. So we use a warning message. We also warn if a not allowed
492 % value is used.
493 % \begin{macrocode}
494 \bool_new:N \@@_float_bool
495
496 \cs_new:Nn \@@_switch_float:n
497 {
498 \str_case_e:nnF { \str_foldcase:n { #1 } }
499 {
500 {true} {
501 \@ifpackageloaded { floatbytocbasic }
502 {
503 \msg_info:nnnn { scrhack } { option-too-late }
504 { float = true } { floatbytocbasic }
505 }
506 {
507 \bool_if:NF \@@_float_bool
508 {
509 \hook_gput_code:nnn { package/float/after } { scrhack }
510 {
511 \RequirePackage { floatbytocbasic }
512 }
513 \bool_gset_true:N \@@_float_bool
514 }
515 }
516 }
517 {false} {
518 \@ifpackageloaded { floatbytocbasic }
519 {
520 \msg_warning:nnnn { scrhack } { option-too-late }
521 { float=false } { floatbytocbasic }
522 }
523 {
524 \bool_if:NT \@@_float_bool
525 {
526 \hook_gremove_code:nn { package/float/after } { scrhack }
527 }
528 \bool_gset_false:N \@s@_float_bool
529 }
530 }
531 }
532 {
533 \msg_warning:nnn { keys } { boolean-values-only } { float }
534 }
535 }
536 \SetKeys{float=true}
537 % \end{macrocode}
538 % \end{macro}
539 % \ExplSyntaxOff
540 %
541 % \subsection{Emulating \file{floatrow.hak}}
542 % First we declare the options using the new key-value interface:
543 % \begin{macrocode}
544 \DeclareKeys{%
545 floatrow .code = \@@_switch_floatrow:n { #1 },
546 floatrow .default:n = true,
547 floatrow .usage = preamble,
548 }
549 % \end{macrocode}
550 %
551 % \ExplSyntaxOn
552 % \begin{macro}{\__scrhack_switch_floatrow:n}
553 % \ExplSyntaxOff
554 % This is used to switch the state and add or remove the hook if needed. A new
555 % boolean is used to know, whether the hook has been put. Using
556 % \opt{floatrow=true}, if package \pkg{floatrowbytocbasic} already has been
557 % loaded isn't a foul. So we just write an information to the \file{log}. But
558 % using \opt{floatrow=false}, if package \pkg{floatrowbytocbasic} already has
559 % been loaded may be wrong. So we use a warning message. We also warn if a not
560 % allowed value is used.
561 % \begin{macrocode}
562 \bool_new:N \@@_floatrow_bool
563
564 \cs_new:Nn \@@_switch_floatrow:n
565 {
566 \str_case_e:nnF { \str_foldcase:n { #1 } }
567 {
568 {true} {
569 \@ifpackageloaded { floatrowbytocbasic }
570 {
571 \msg_info:nnnn { scrhack } { option-too-late }
572 { floatrow = true } { floatrowbytocbasic }
573 }
574 {
575 \bool_if:NF \@@_floatrow_bool
576 {
577 \hook_gput_code:nnn { package/floatrow/after }
578 { scrhack }
579 {
580 \RequirePackage { floatrowbytocbasic }
581 }
582 \bool_gset_true:N \@@_floatrow_bool
583 }
584 }
585 }
586 {false} {
587 \@ifpackageloaded { floatrowbytocbasic }
588 {
589 \msg_warning:nnnn { scrhack } { option-too-late }
590 { floatrow=false } { floatrowbytocbasic }
591 }
592 {
593 \bool_if:NT \@@_floatrow_bool
594 {
595 \hook_gremove_code:nn { package/floatrow/after }
596 { scrhack }
597 }
598 \bool_gset_false:N \@s@_floatrow_bool
599 }
600 }
601 }
602 {
603 \msg_warning:nnn { keys } { boolean-values-only } { floatrow }
604 }
605 }
606 \SetKeys{floatrow=true}
607 % \end{macrocode}
608 % \end{macro}
609 % \ExplSyntaxOff
610 %
611 % \subsection{Emulating \file{hyperref.hak}}
612 %
613 % First we declare the options using the new key-value interface:
614 % \begin{macrocode}
615 \DeclareKeys{%
616 hyperref .code = \@@_switch_hyperref:n { #1 },
617 hyperref .default:n = true,
618 hyperref .usage = preamble,
619 }
620 % \end{macrocode}
621 %
622 % \ExplSyntaxOn
623 % \begin{macro}{\__scrhack_switch_hyperref:n}
624 % \ExplSyntaxOff
625 % This is somehow special, because the hack is deprecated. It only has been
626 % needed for \pkg{hyperref} versions released before 2009-11-24, which would
627 % not work with the \LaTeX{} kernel version needed by this version of
628 % \pkg*{scrhack}. So emulating the hack does not make sense. Instead the
629 % initial value of the option is changed to implicit \optvalue{false} and
630 % switching it on explicitly does result in a warning.
631 % \begin{macrocode}
632 \cs_new:Nn \@@_switch_hyperref:n
633 {
634 \str_case_e:nnF { \str_foldcase:n { #1 } }
635 {
636 {true} {
637 \msg_warning:nnn { scrhack } { deprecated-option }
638 { hyperref=#1 }
639 }
640 {false} {
641 \msg_info:nnn { scrhack } { deprecated-option }
642 { hyperref=#1 }
643 }
644 }
645 {
646 \msg_warning:nnn { keys } { boolean-values-only } { hyperref }
647 }
648 }
649 % \end{macrocode}
650 % \end{macro}
651 % \ExplSyntaxOff
652 %
653 % \subsection{Emulating \file{listings.hak}}
654 % First we declare the options using the new key-value interface:
655 % \begin{macrocode}
656 \DeclareKeys{%
657 listings .code = \@@_switch_listings:n { #1 },
658 listings .default:n = true,
659 listings .usage = preamble,
660 }
661 % \end{macrocode}
662 %
663 % \ExplSyntaxOn
664 % \begin{macro}{\__scrhack_switch_listings:n}
665 % \ExplSyntaxOff
666 % This is somehow special, because the hack is deprecated. It only has
667 % been needed for \pkg{listings} version released before 2024-02-15. So
668 % instead of using any patch hacks, users should update \pkg{listings}. So
669 % emulating the hack does not make sense. Instead the initial value of the
670 % option is changed to implicit \optvalue{false} and switching it on
671 % explicitly does result in a warning.
672 % \begin{macrocode}
673 \cs_new:Nn \@@_switch_listings:n
674 {
675 \str_case_e:nnF { \str_foldcase:n { #1 } }
676 {
677 {true} {
678 \msg_warning:nnn { scrhack } { deprecated-option }
679 { listings=#1 }
680 }
681 {false} {
682 \msg_info:nnn { scrhack } { deprecated-option }
683 { listings=#1 }
684 }
685 }
686 {
687 \msg_warning:nnn { keys } { boolean-values-only } { listings }
688 }
689 }
690 % \end{macrocode}
691 % \end{macro}
692 % \ExplSyntaxOff
693 %
694 % \subsection{Emulating \file{lscape.hak}}
695 % First we declare the options using the new key-value interface:
696 % \begin{macrocode}
697 \DeclareKeys{%
698 lscape .code = \@@_switch_lscape:n { #1 },
699 lscape .default:n = true,
700 lscape .usage = preamble,
701 }
702 % \end{macrocode}
703 %
704 % \ExplSyntaxOn
705 % \begin{macro}{\__scrhack_switch_lscape:n}
706 % \ExplSyntaxOff
707 % This is used to switch the state and add or remove the hook if needed. A new
708 % boolean is used to know, whether the hook has been put. Using
709 % \opt{lscape=true}, if package \pkg{lscapeenhanced} already has been
710 % loaded isn't a foul. So we just write an information to the \file{log}. But
711 % using \opt{lscape=false}, if package \pkg{lscapeenhanced} already has
712 % been loaded may be wrong. So we use a warning message. We also warn if a not
713 % allowed value is used.
714 % \begin{macrocode}
715 \bool_new:N \@@_lscape_bool
716
717 \cs_new:Nn \@@_switch_lscape:n
718 {
719 \str_case_e:nnF { \str_foldcase:n { #1 } }
720 {
721 {true} {
722 \@ifpackageloaded { lscapeenhanced }
723 {
724 \msg_info:nnnn { scrhack } { option-too-late }
725 { lscape = true } { lscapeenhanced }
726 }
727 {
728 \bool_if:NF \@@_lscape_bool
729 {
730 \hook_gput_code:nnn { package/lscape/after }
731 { scrhack }
732 {
733 \RequirePackage { lscapeenhanced }
734 }
735 \bool_gset_true:N \@@_lscape_bool
736 }
737 }
738 }
739 {false} {
740 \@ifpackageloaded { lscapeenhanced }
741 {
742 \msg_warning:nnnn { scrhack } { option-too-late }
743 { lscape=false } { lscapeenhanced }
744 }
745 {
746 \bool_if:NT \@@_lscape_bool
747 {
748 \hook_gremove_code:nn { package/lscape/after }
749 { scrhack }
750 }
751 \bool_gset_false:N \@s@_lscape_bool
752 }
753 }
754 }
755 {
756 \msg_warning:nnn { keys } { boolean-values-only } { lscape }
757 }
758 }
759 \SetKeys{lscape=true}
760 % \end{macrocode}
761 % \end{macro}
762 % \ExplSyntaxOff
763 %
764 % \subsection{Emulating \file{nomencl.hak}}
765 %
766 % First we declare the options using the new key-value interface:
767 % \begin{macrocode}
768 \DeclareKeys{%
769 nomencl .code = \@@_switch_nomencl:n { #1 },
770 nomencl .default:n = true,
771 nomencl .usage = preamble,
772 }
773 % \end{macrocode}
774 %
775 % \ExplSyntaxOn
776 % \begin{macro}{\__scrhack_switch_nomencl:n}
777 % \ExplSyntaxOff
778 % This is somehow special, because the hack is deprecated. It only has been
779 % needed for \pkg{nomencl} versions released before 2019-01-23. So updating
780 % the package would be the better \emph{hack}. So emulating the hack does not
781 % make sense. Instead the initial value of the option is changed to implicit
782 % \optvalue{false} and switching it on explicitly does result in a warning.
783 % \begin{macrocode}
784 \cs_new:Nn \@@_switch_nomencl:n
785 {
786 \str_case_e:nnF { \str_foldcase:n { #1 } }
787 {
788 {true} {
789 \msg_warning:nnn { scrhack } { deprecated-option }
790 { nomencl=#1 }
791 }
792 {false} {
793 \msg_info:nnn { scrhack } { deprecated-option }
794 { nomencl=#1 }
795 }
796 }
797 {
798 \msg_warning:nnn { keys } { boolean-values-only } { nomencl }
799 }
800 }
801 % \end{macrocode}
802 % \end{macro}
803 % \ExplSyntaxOff
804 %
805 %
806 % \subsection{Emulating \file{setspace.hak}}
807 % First we declare the options using the new key-value interface:
808 % \begin{macrocode}
809 \DeclareKeys{%
810 setspace .code = \@@_switch_setspace:n { #1 },
811 setspace .default:n = true,
812 setspace .usage = preamble,
813 }
814 % \end{macrocode}
815 %
816 % \ExplSyntaxOn
817 % \begin{macro}{\__scrhack_switch_setspace:n}
818 % \ExplSyntaxOff
819 % This is used to switch the state and add or remove the hook if needed. A new
820 % boolean is used to know, whether the hook has been put. Using
821 % \opt{setspace=true}, if package \pkg{setspaceenhanced} already has been loaded
822 % isn't a foul. So we just write an information to the \file{log}. But using
823 % \opt{setspace=false}, if package \pkg{setspaceenhanced} already has been loaded
824 % may be wrong. So we use a warning message. We also warn if a not allowed
825 % value is used.
826 % \begin{macrocode}
827 \bool_new:N \@@_setspace_bool
828
829 \cs_new:Nn \@@_switch_setspace:n
830 {
831 \str_case_e:nnF { \str_foldcase:n { #1 } }
832 {
833 {true} {
834 \@ifpackageloaded { setspaceenhanced }
835 {
836 \msg_info:nnnn { scrhack } { option-too-late }
837 { setspace = true } { setspaceenhanced }
838 }
839 {
840 \bool_if:NF \@@_setspace_bool
841 {
842 \hook_gput_code:nnn { package/setspace/after } { scrhack }
843 {
844 \exp_last_unbraced:Ne \RequirePackage
845 {
846 [ \use:c { @raw@[email protected] },
847 byselectfont,
848 keepfontsize ]
849 }
850 { setspaceenhanced }
851 }
852 \bool_gset_true:N \@@_setspace_bool
853 }
854 }
855 }
856 {false} {
857 \@ifpackageloaded { setspaceenhanced }
858 {
859 \msg_warning:nnnn { scrhack } { option-too-late }
860 { setspace=false } { setspaceenhanced }
861 }
862 {
863 \bool_if:NT \@@_setspace_bool
864 {
865 \hook_gremove_code:nn { package/setspace/after } { scrhack }
866 }
867 \bool_gset_false:N \@s@_setspace_bool
868 }
869 }
870 }
871 {
872 \msg_warning:nnn { keys } { boolean-values-only } { setspace }
873 }
874 }
875 \SetKeys{setspace=true}
876 % \end{macrocode}
877 % \end{macro}
878 % \ExplSyntaxOff
879 %
880 % \subsection{Emulating \file{standardsectioning.hak}}
881 % First we declare the options using the new key-value interface:
882 % \begin{macrocode}
883 \DeclareKeys{%
884 standardsections .code = \@@_switch_standardsectioning:n { #1 },
885 standardsections .default:n = true,
886 standardsections .usage = preamble,
887 }
888 % \end{macrocode}
889 %
890 % \ExplSyntaxOn
891 % \begin{macro}{\__scrhack_switch_standardsectioning:n}
892 % \ExplSyntaxOff
893 % This is used to switch the state and add or remove the hook if needed. A new
894 % boolean is used to know, whether the hook has been put. Using
895 % \opt{standardsectioning=true}, if package \pkg{standardsectioning}
896 % already has been loaded isn't a foul. So we just write an information to the
897 % \file{log}. But using \opt{standardsectioning=false}, if package
898 % \pkg{standardsectioning} already has been loaded may be wrong. So
899 % we use a warning message. We also warn if a not allowed value is used.
900 % \begin{macrocode}
901 \bool_new:N \@@_standardsectioning_bool
902
903 \cs_new:Nn \@@_switch_standardsectioning:n
904 {
905 \str_case_e:nnF { \str_foldcase:n { #1 } }
906 {
907 {true} {
908 \@ifpackageloaded { standardsectioning }
909 {
910 \msg_info:nnnn { scrhack } { option-too-late }
911 { standardsectioning = true } { standardsectioning }
912 }
913 {
914 \bool_if:NF \@@_standardsectioning_bool
915 {
916 \str_set:Nx \l_tmpa_str { \cs_meaning:N \normalsize }
917 \str_if_in:NnTF
918 \l_tmpa_str
919 { \@latex@error }
920 {
921 \hook_gput_code:nnn { class/after } { scrhack }
922 {
923 \RequirePackage { standardsectioning }
924 \exp_args:Nnnx \hook_gput_code:nnn
925 { begindocument/before } { scrhack }
926 {
927 \exp_not:N \cs_gset:Npn
928 \exp_after:wN \exp_not:N
929 \cs:w [email protected] \cs_end:
930 {
931 \cs:w [email protected] \cs_end:
932 }
933 }
934 \cs_undefine:c { [email protected] }
935 }
936 \bool_gset_true:N \@@_standardsectioning_bool
937 }
938 {
939 \RequirePackage{ standardsectioning }
940 \bool_gset_false:N \@@_standardsectioning_bool
941 }
942 }
943 }
944 }
945 {false} {
946 \@ifpackageloaded { standardsectioning }
947 {
948 \msg_warning:nnnn { scrhack } { option-too-late }
949 { standardsectioning=false } { standardsectioning }
950 }
951 {
952 \bool_if:NT \@@_standardsectioning_bool
953 {
954 \hook_gremove_code:nn { class/after } { scrhack }
955 }
956 \bool_gset_false:N \@s@_standardsectioning_bool
957 }
958 }
959 }
960 {
961 \msg_warning:nnn { keys } { boolean-values-only } { standardsectioning }
962 }
963 }
964 % \end{macrocode}
965 % \end{macro}
966 % \ExplSyntaxOff
967 %
968 %
969 %
970 % \subsection{Processing the options}
971 % Last but not least, we set the defaults and process the options.
972 % \begin{macrocode}
973 \ExplSyntaxOff
974 \ProcessKeyOptions\relax
975 % \end{macrocode}
976 %
977 % \iffalse
978 %</package>
979 % \fi
980 %
981 % \Finale
982 % \PrintChanges
983 %
984 % \endinput
985 % Local Variables:
986 % mode: doctex
987 % ispell-local-dictionary: "en_US"
988 % eval: (flyspell-mode 1)
989 % TeX-master: t
990 % 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"))
991 % End: