| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% File: kvoptions.dtx |
| 4 |
% Version: 2022-06-15 v3.15 |
| 5 |
% Info: Key value format for package options |
| 6 |
% |
| 7 |
% Copyright (C) |
| 8 |
% 2004, 2006, 2007, 2009-2011 Heiko Oberdiek |
| 9 |
% 2016-2022 Oberdiek Package Support Group |
| 10 |
% https://github.com/ho-tex/kvoptions/issues |
| 11 |
% |
| 12 |
% This work may be distributed and/or modified under the |
| 13 |
% conditions of the LaTeX Project Public License, either |
| 14 |
% version 1.3c of this license or (at your option) any later |
| 15 |
% version. This version of this license is in |
| 16 |
% https://www.latex-project.org/lppl/lppl-1-3c.txt |
| 17 |
% and the latest version of this license is in |
| 18 |
% https://www.latex-project.org/lppl.txt |
| 19 |
% and version 1.3 or later is part of all distributions of |
| 20 |
% LaTeX version 2005/12/01 or later. |
| 21 |
% |
| 22 |
% This work has the LPPL maintenance status "maintained". |
| 23 |
% |
| 24 |
% The Current Maintainers of this work are |
| 25 |
% Heiko Oberdiek and the Oberdiek Package Support Group |
| 26 |
% https://github.com/ho-tex/kvoptions/issues |
| 27 |
% |
| 28 |
% This work consists of the main source file kvoptions.dtx |
| 29 |
% and the derived files |
| 30 |
% kvoptions.sty, kvoptions.pdf, kvoptions.ins, kvoptions.drv, |
| 31 |
% kvoptions-patch.sty, example-mycolorsetup.sty, |
| 32 |
% kvoptions-test1.tex, kvoptions-test2.tex, |
| 33 |
% kvoptions-test3.tex, kvoptions-test4.tex, |
| 34 |
% kvoptions-test4.sty. |
| 35 |
% |
| 36 |
% Distribution: |
| 37 |
% CTAN:macros/latex/contrib/kvoptions/kvoptions.dtx |
| 38 |
% CTAN:macros/latex/contrib/kvoptions/kvoptions.pdf |
| 39 |
% |
| 40 |
% Unpacking: |
| 41 |
% (a) If kvoptions.ins is present: |
| 42 |
% tex kvoptions.ins |
| 43 |
% (b) Without kvoptions.ins: |
| 44 |
% tex kvoptions.dtx |
| 45 |
% (c) If you insist on using LaTeX |
| 46 |
% latex \let\install=y\input{kvoptions.dtx} |
| 47 |
% (quote the arguments according to the demands of your shell) |
| 48 |
% |
| 49 |
% Documentation: |
| 50 |
% (a) If kvoptions.drv is present: |
| 51 |
% latex kvoptions.drv |
| 52 |
% (b) Without kvoptions.drv: |
| 53 |
% latex kvoptions.dtx; ... |
| 54 |
% The class ltxdoc loads the configuration file ltxdoc.cfg |
| 55 |
% if available. Here you can specify further options, e.g. |
| 56 |
% use A4 as paper format: |
| 57 |
% \PassOptionsToClass{a4paper}{article} |
| 58 |
% |
| 59 |
% Programm calls to get the documentation (example): |
| 60 |
% pdflatex kvoptions.dtx |
| 61 |
% makeindex -s gind.ist kvoptions.idx |
| 62 |
% pdflatex kvoptions.dtx |
| 63 |
% makeindex -s gind.ist kvoptions.idx |
| 64 |
% pdflatex kvoptions.dtx |
| 65 |
% |
| 66 |
% Installation: |
| 67 |
% TDS:tex/latex/kvoptions/kvoptions.sty |
| 68 |
% TDS:tex/latex/kvoptions/kvoptions-patch.sty |
| 69 |
% TDS:doc/latex/kvoptions/kvoptions.pdf |
| 70 |
% TDS:doc/latex/kvoptions/example-mycolorsetup.sty |
| 71 |
% TDS:source/latex/kvoptions/kvoptions.dtx |
| 72 |
% |
| 73 |
%<*ignore> |
| 74 |
\begingroup |
| 75 |
\catcode123=1 % |
| 76 |
\catcode125=2 % |
| 77 |
\def\x{LaTeX2e}% |
| 78 |
\expandafter\endgroup |
| 79 |
\ifcase 0\ifx\install y1\fi\expandafter |
| 80 |
\ifx\csname processbatchFile\endcsname\relax\else1\fi |
| 81 |
\ifx\fmtname\x\else 1\fi\relax |
| 82 |
\else\csname fi\endcsname |
| 83 |
%</ignore> |
| 84 |
%<*install> |
| 85 |
\input docstrip.tex |
| 86 |
\Msg{************************************************************************} |
| 87 |
\Msg{* Installation} |
| 88 |
\Msg{* Package: kvoptions 2022-06-15 v3.15 Key value format for package options (HO)} |
| 89 |
\Msg{************************************************************************} |
| 90 |
|
| 91 |
\keepsilent |
| 92 |
\askforoverwritefalse |
| 93 |
|
| 94 |
\let\MetaPrefix\relax |
| 95 |
\preamble |
| 96 |
|
| 97 |
This is a generated file. |
| 98 |
|
| 99 |
Project: kvoptions |
| 100 |
Version: 2022-06-15 v3.15 |
| 101 |
|
| 102 |
Copyright (C) |
| 103 |
2004, 2006, 2007, 2009-2011 Heiko Oberdiek |
| 104 |
2016-2022 Oberdiek Package Support Group |
| 105 |
|
| 106 |
This work may be distributed and/or modified under the |
| 107 |
conditions of the LaTeX Project Public License, either |
| 108 |
version 1.3c of this license or (at your option) any later |
| 109 |
version. This version of this license is in |
| 110 |
https://www.latex-project.org/lppl/lppl-1-3c.txt |
| 111 |
and the latest version of this license is in |
| 112 |
https://www.latex-project.org/lppl.txt |
| 113 |
and version 1.3 or later is part of all distributions of |
| 114 |
LaTeX version 2005/12/01 or later. |
| 115 |
|
| 116 |
This work has the LPPL maintenance status "maintained". |
| 117 |
|
| 118 |
The Current Maintainers of this work are |
| 119 |
Heiko Oberdiek and the Oberdiek Package Support Group |
| 120 |
https://github.com/ho-tex/kvoptions/issues |
| 121 |
|
| 122 |
|
| 123 |
This work consists of the main source file kvoptions.dtx |
| 124 |
and the derived files |
| 125 |
kvoptions.sty, kvoptions.pdf, kvoptions.ins, kvoptions.drv, |
| 126 |
kvoptions-patch.sty, example-mycolorsetup.sty, |
| 127 |
kvoptions-test1.tex, kvoptions-test2.tex, |
| 128 |
kvoptions-test3.tex, kvoptions-test4.tex, |
| 129 |
kvoptions-test4.sty. |
| 130 |
|
| 131 |
\endpreamble |
| 132 |
\let\MetaPrefix\DoubleperCent |
| 133 |
|
| 134 |
\generate{% |
| 135 |
\file{kvoptions.ins}{\from{kvoptions.dtx}{install}}% |
| 136 |
\file{kvoptions.drv}{\from{kvoptions.dtx}{driver}}% |
| 137 |
\usedir{tex/latex/kvoptions}% |
| 138 |
\file{kvoptions.sty}{\from{kvoptions.dtx}{package}}% |
| 139 |
\file{kvoptions-patch.sty}{\from{kvoptions.dtx}{patch}}% |
| 140 |
\usedir{doc/latex/kvoptions}% |
| 141 |
\file{example-mycolorsetup.sty}{\from{kvoptions.dtx}{example}}% |
| 142 |
% \usedir{doc/latex/kvoptions/test}% |
| 143 |
% \file{kvoptions-test1.tex}{\from{kvoptions.dtx}{test1}}% |
| 144 |
% \file{kvoptions-test2.tex}{\from{kvoptions.dtx}{test2}}% |
| 145 |
% \file{kvoptions-test3.tex}{\from{kvoptions.dtx}{test3}}% |
| 146 |
% \file{kvoptions-test4.tex}{\from{kvoptions.dtx}{test4}}% |
| 147 |
% \file{kvoptions-test4.sty}{\from{kvoptions.dtx}{test4pkg}}% |
| 148 |
} |
| 149 |
|
| 150 |
\catcode32=13\relax% active space |
| 151 |
\let =\space% |
| 152 |
\Msg{************************************************************************} |
| 153 |
\Msg{*} |
| 154 |
\Msg{* To finish the installation you have to move the following} |
| 155 |
\Msg{* files into a directory searched by TeX:} |
| 156 |
\Msg{*} |
| 157 |
\Msg{* kvoptions.sty, kvoptions-patch.sty} |
| 158 |
\Msg{*} |
| 159 |
\Msg{* To produce the documentation run the file `kvoptions.drv'} |
| 160 |
\Msg{* through LaTeX.} |
| 161 |
\Msg{*} |
| 162 |
\Msg{* Happy TeXing!} |
| 163 |
\Msg{*} |
| 164 |
\Msg{************************************************************************} |
| 165 |
|
| 166 |
\endbatchfile |
| 167 |
%</install> |
| 168 |
%<*ignore> |
| 169 |
\fi |
| 170 |
%</ignore> |
| 171 |
%<*driver> |
| 172 |
\NeedsTeXFormat{LaTeX2e} |
| 173 |
\ProvidesFile{kvoptions.drv}% |
| 174 |
[2022-06-15 v3.15 Key value format for package options (HO)]% |
| 175 |
\documentclass{ltxdoc} |
| 176 |
\usepackage{holtxdoc}[2011/11/22] |
| 177 |
\begin{document} |
| 178 |
\DocInput{kvoptions.dtx}% |
| 179 |
\end{document} |
| 180 |
%</driver> |
| 181 |
% \fi |
| 182 |
% |
| 183 |
% |
| 184 |
% |
| 185 |
% \GetFileInfo{kvoptions.drv} |
| 186 |
% |
| 187 |
% \title{The \xpackage{kvoptions} package} |
| 188 |
% \date{2022-06-15 v3.15} |
| 189 |
% \author{Heiko Oberdiek\thanks |
| 190 |
% {Please report any issues at \url{https://github.com/ho-tex/kvoptions/issues}}} |
| 191 |
% |
| 192 |
% \maketitle |
| 193 |
% |
| 194 |
% \begin{abstract} |
| 195 |
% This package is intended for package authors who want to |
| 196 |
% use options in key value format for their package options. |
| 197 |
% \end{abstract} |
| 198 |
% |
| 199 |
% \tableofcontents |
| 200 |
% |
| 201 |
% \def\M#1{\texttt{\{}\meta{#1}\texttt{\}}} |
| 202 |
% \def\O#1{\texttt{[}\meta{#1}\texttt{]}} |
| 203 |
% |
| 204 |
% \section{Introduction} |
| 205 |
% |
| 206 |
% First I want to recommend the very good review article |
| 207 |
% ``A guide to key-value methods'' by Joseph Wright \cite{tb94wright}. |
| 208 |
% It introduces the different key-value packages and compares them. |
| 209 |
% |
| 210 |
% \subsection{The beginning} |
| 211 |
% |
| 212 |
% This package \xpackage{kvoptions} addresses class or package writers |
| 213 |
% that want to allow their users to specify options |
| 214 |
% as key value pairs, e.g.: |
| 215 |
% \begin{quote} |
| 216 |
% |\documentclass[verbose=false,name=me]{myclass}|\\ |
| 217 |
% |\usepackage[format=print]{mylayout}| |
| 218 |
% \end{quote} |
| 219 |
% Prominent example is package \xpackage{hyperref}, |
| 220 |
% probably the first package that offers this service. |
| 221 |
% It's \cs{ProcessOptionsWithKV} is often copied und |
| 222 |
% used in other packages, e.g. package \xpackage{helvet} |
| 223 |
% that uses this interface for its option \xoption{scaled}. |
| 224 |
% |
| 225 |
% However copying code is not the most modern software |
| 226 |
% development technique. And \xpackage{hyperref}'s |
| 227 |
% code for \cs{ProcessOptionsWithKV} was changed |
| 228 |
% to fix bugs. The version used in other packages |
| 229 |
% depends on the time of copying and the awareness |
| 230 |
% of \xpackage{hyperref}'s changes. |
| 231 |
% Now the code is sourced out into this package and |
| 232 |
% available for other package or class writers. |
| 233 |
% |
| 234 |
% \subsection{Overview} |
| 235 |
% |
| 236 |
% Package \xpackage{kvoptions} connects package |
| 237 |
% \xpackage{\emph{k}ey\emph{v}al} |
| 238 |
% with \LaTeX's package and class \emph{options}: |
| 239 |
% \begin{center} |
| 240 |
% \def\T#1{\bfseries #1} |
| 241 |
% \renewcommand{\arraystretch}{1.5} |
| 242 |
% \begin{tabular}{l|l|l} |
| 243 |
% \T{Package \xpackage{keyval}} |
| 244 |
% & \T{Package \xpackage{kvoptions}} |
| 245 |
% & \T{\LaTeX\ kernel} |
| 246 |
% \\ |
| 247 |
% \hline |
| 248 |
% \cs{define@key} |
| 249 |
% & |
| 250 |
% \renewcommand*{\arraystretch}{1}^^A |
| 251 |
% \begin{tabular}[t]{@{}l@{}} |
| 252 |
% \cs{DeclareVoidOption}\\ |
| 253 |
% \cs{DeclareStringOption}\\ |
| 254 |
% \cs{DeclareBoolOption}\\ |
| 255 |
% \cs{DeclareComplementaryOption}\\ |
| 256 |
% \cs{DisableKeyvalOption} |
| 257 |
% \end{tabular} |
| 258 |
% & \cs{DeclareOption} |
| 259 |
% \\ |
| 260 |
% \hline |
| 261 |
% & \cs{DeclareDefaultOption} |
| 262 |
% & \cs{DeclareOption*} |
| 263 |
% \\ |
| 264 |
% \hline |
| 265 |
% & \cs{ProcessKeyvalOptions} |
| 266 |
% & \cs{ProcessOptions*} |
| 267 |
% \\ |
| 268 |
% \hline |
| 269 |
% & Option \xoption{patch} |
| 270 |
% & |
| 271 |
% \renewcommand*{\arraystretch}{1}^^A |
| 272 |
% \begin{tabular}[t]{@{}l@{}} |
| 273 |
% Class/package\\ |
| 274 |
% option system |
| 275 |
% \end{tabular} |
| 276 |
% \\ |
| 277 |
% \hline |
| 278 |
% & \cs{SetupKeyvalOptions} & |
| 279 |
% \\ |
| 280 |
% \end{tabular} |
| 281 |
% \end{center} |
| 282 |
% |
| 283 |
% \hypersetup{bookmarksopenlevel=3} |
| 284 |
% \section{Usage} |
| 285 |
% |
| 286 |
% \subsection{Process options} |
| 287 |
% |
| 288 |
% \subsubsection{\cs{ProcessKeyvalOptions}} |
| 289 |
% |
| 290 |
% \begin{declcs}{ProcessKeyvalOptions}\,\M{family}\\ |
| 291 |
% \cs{ProcessKeyvalOptions} \* |
| 292 |
% \end{declcs} |
| 293 |
% This command evaluates the global or local options of |
| 294 |
% the package that are defined with \xpackage{keyval}'s |
| 295 |
% interface within the family \meta{family}. It acts the |
| 296 |
% same way as \LaTeX's \cs{ProcessOptions*}. In a package |
| 297 |
% unknown global options are ignored, in a class they |
| 298 |
% are added to the unknown option list. The known global |
| 299 |
% options and all local options are passed to \xpackage{keyval}'s |
| 300 |
% \cs{setkeys} command for executing the options. |
| 301 |
% Unknown options are reported to the user by an error. |
| 302 |
% |
| 303 |
% If the family name happens to be the same as the name |
| 304 |
% of the package or class where \cs{ProcessKeyvalOptions} |
| 305 |
% is used or the family name has previously been setup by |
| 306 |
% \cs{SetupKeyvalOptions}, then \cs{ProcessKeyvalOptions} |
| 307 |
% knows the family name already and you can use the star form |
| 308 |
% without mandatory argument. |
| 309 |
% |
| 310 |
% \subsubsection{\cs{ProcessLocalKeyvalOptions}} |
| 311 |
% |
| 312 |
% \begin{declcs}{ProcessLocalKeyvalOptions}\,\M{family}\\ |
| 313 |
% \cs{ProcessLocalKeyvalOptions} \* |
| 314 |
% \end{declcs} |
| 315 |
% This macro has the same syntax and works similar as |
| 316 |
% \cs{ProcessKeyvalOptions}. However it ignores |
| 317 |
% global options and only processes the local package options. |
| 318 |
% Therefore it only can be used inside a package. |
| 319 |
% An error is thrown, if it is used inside a class. |
| 320 |
% |
| 321 |
% Neither of the following macros are necessary for |
| 322 |
% \cs{ProcessKeyvalOptions{}}. They just help the package/class |
| 323 |
% author in common tasks. |
| 324 |
% |
| 325 |
% \subsubsection{\cs{SetupKeyvalOptions}}\label{setup} |
| 326 |
% |
| 327 |
% \begin{declcs}{SetupKeyvalOptions}\,\texttt{\{}\\ |
| 328 |
% \hspace{1.5em}|family|\,|=|\,\meta{family}|,|\\ |
| 329 |
% \hspace{1.5em}|prefix|\,|=|\,\meta{prefix}\\ |
| 330 |
% \hspace{1.5em}|setkeys|\,|=|\,\meta{setkeys command}\\ |
| 331 |
% \texttt{\}} |
| 332 |
% \end{declcs} |
| 333 |
% This command allows to configure the default assumptions |
| 334 |
% that are based on the current package or class name. |
| 335 |
% \LaTeX\ remembers this name in \cs{@currname}. The syntax |
| 336 |
% description of the default looks a little weird, therefor |
| 337 |
% an example is given for a package or class named |foobar|. |
| 338 |
% \begin{quote} |
| 339 |
% \begin{tabular}{@{}l|ll|l@{}} |
| 340 |
% Key & Default & (example) & Used by\\ |
| 341 |
% \hline |
| 342 |
% \rule{0pt}{1.2\ht\csname @arstrutbox\endcsname}^^A |
| 343 |
% |family| & \meta{\cs{@currname}} & (|foobar|) |
| 344 |
% & \cs{ProcessKeyvalOptions*} \\ |
| 345 |
% &&& \cs{DeclareBoolOption} \\ |
| 346 |
% &&& \cs{DeclareStringOption} \\ |
| 347 |
% \hline |
| 348 |
% \rule{0pt}{1.2\ht\csname @arstrutbox\endcsname}^^A |
| 349 |
% |prefix| & \meta{\cs{@currname}}|@| & (|foobar@|) |
| 350 |
% & \cs{DeclareBoolOption} \\ |
| 351 |
% &&& \cs{DeclareStringOption} \\ |
| 352 |
% &&& \cs{DeclareVoidOption} \\ |
| 353 |
% \hline |
| 354 |
% \rule{0pt}{1.2\ht\csname @arstrutbox\endcsname}^^A |
| 355 |
% |setkeys| & \cs{setkeys} & (\cs{kvsetkeys}) |
| 356 |
% & \cs{ProcessKeyvalOptions} \\ |
| 357 |
% &&& \cs{ProcessLocalKeyvalOptions} |
| 358 |
% \end{tabular} |
| 359 |
% \end{quote} |
| 360 |
% Key |setkeys| was added in version 3.9. The original |
| 361 |
% \cs{setkeys} of package \xpackage{keyval} is not reentrant. |
| 362 |
% If an option is processed by this \cs{setkeys}, then |
| 363 |
% the option should not call \cs{setkeys} again with a |
| 364 |
% different family. Otherwise the next options of the |
| 365 |
% first \cs{setkeys} call are processed with the wrong |
| 366 |
% family. With key |setkeys| the macro \cs{kvsetkeys} |
| 367 |
% can be set that does not have the problem of the |
| 368 |
% original \cs{setkeys} of package {keyval}. |
| 369 |
% |
| 370 |
% Probably \cs{setkeys} of package \xpackage{xkeyval} |
| 371 |
% is safe in this respect. But I haven't made a full |
| 372 |
% analysis. At least it does not have the problem |
| 373 |
% of the original \cs{setkeys}. |
| 374 |
% |
| 375 |
% \subsection{Option declarations} |
| 376 |
% |
| 377 |
% The options for \cs{ProcessKeyvalOptions} are defined |
| 378 |
% by \xpackage{keyval}'s \cs{define@key}. |
| 379 |
% Common purposes of such keys are boolean switches, they |
| 380 |
% enable or disable something. Or they store a name or some kind of |
| 381 |
% string in a macro. The following commands help the user. He |
| 382 |
% declares what he wants and \xpackage{kvoptions} take care of |
| 383 |
% the key definition, resource allocation and initialization. |
| 384 |
% |
| 385 |
% In order to avoid name clashes of macro names, internal |
| 386 |
% commands are prefixed. Both the prefix and the family |
| 387 |
% name for the defined keys can be configured by |
| 388 |
% \cs{SetupKeyvalOptions}. |
| 389 |
% |
| 390 |
% \subsubsection{\cs{DeclareStringOption}} |
| 391 |
% |
| 392 |
% \begin{declcs}{DeclareStringOption}\,\O{init}\,\M{key}\,\O{default} |
| 393 |
% \end{declcs} |
| 394 |
% A macro is created that remembers the value of the key \meta{key}. |
| 395 |
% The name of the macro consists of the option name \meta{key} that |
| 396 |
% is prefixed by the prefix (see \ref{setup}). |
| 397 |
% The initial contents of the |
| 398 |
% macro can be given by the first optional argument \meta{init}. |
| 399 |
% The default is empty. |
| 400 |
% |
| 401 |
% The the option \meta{key} is defined. The option code |
| 402 |
% just stores its value in the macro. If the optional argument |
| 403 |
% at the end of \cs{DeclareStringOption} is given, then option |
| 404 |
% \meta{key} is defined with the default \meta{default}. |
| 405 |
% |
| 406 |
% Example for a package with the following two lines: |
| 407 |
% \begin{quote} |
| 408 |
% |\ProvidesPackage{foobar}|\\ |
| 409 |
% |\DeclareStringOption[me]{name}| |
| 410 |
% \end{quote} |
| 411 |
% Then \cs{DeclareStringOption} defines the macro with content |me|, |
| 412 |
% note \LaTeX\ complains if the name of the macro already exists: |
| 413 |
% \begin{quote} |
| 414 |
% |\newcommand*{\foobar@name}{me}| |
| 415 |
% \end{quote} |
| 416 |
% The option definition is similar to: |
| 417 |
% \begin{quote} |
| 418 |
% |\define@key{foobar}{name}{%|\\ |
| 419 |
% | \renewcommand*{\foobar@name}{#1}%|\\ |
| 420 |
% |}| |
| 421 |
% \end{quote} |
| 422 |
% |
| 423 |
% \subsubsection{\cs{DeclareBoolOption}} |
| 424 |
% |
| 425 |
% \begin{declcs}{DeclareBoolOption}\,\O{init}\,\M{key} |
| 426 |
% \end{declcs} |
| 427 |
% A boolean switch is generated, initialized by value \meta{init} |
| 428 |
% and the corresponding key \meta{key} is defined. If the |
| 429 |
% initialization value is not given, |false| is used as default. |
| 430 |
% |
| 431 |
% The internal actions of \cs{DeclareBoolOption} are shown below. |
| 432 |
% The example is given for a package author who has the following |
| 433 |
% two lines in his package/class: |
| 434 |
% \begin{quote} |
| 435 |
% |\ProvidesPackage{foobar}|\\ |
| 436 |
% |\DeclareBoolOption{verbose}| |
| 437 |
% \end{quote} |
| 438 |
% First a new switch is created: |
| 439 |
% \begin{quote} |
| 440 |
% |\newif\iffoobar@verbose| |
| 441 |
% \end{quote} |
| 442 |
% and initialized: |
| 443 |
% \begin{quote} |
| 444 |
% |\foobar@verbosefalse| |
| 445 |
% \end{quote} |
| 446 |
% Finally the key is defined: |
| 447 |
% \begin{quote} |
| 448 |
% |\define@key{foobar}{verbose}[true]{|\dots|}| |
| 449 |
% \end{quote} |
| 450 |
% The option code configures the boolean option in the following way: |
| 451 |
% If the author specifies |true| or |false| then the switch is |
| 452 |
% turned on or off respectivly. Also the option can be given without |
| 453 |
% explicit value. Then the switch is enabled. |
| 454 |
% Other values are reported as errors. |
| 455 |
% |
| 456 |
% Now the switch is ready to use in the package/class, e.g.: |
| 457 |
% \begin{quote} |
| 458 |
% |\iffoobar@verbose|\\ |
| 459 |
% \qquad\textit{\% print verbose message}\\ |
| 460 |
% |\else|\\ |
| 461 |
% \qquad\textit{\% be quiet}\\ |
| 462 |
% |\fi| |
| 463 |
% \end{quote} |
| 464 |
% Users of package \cs{ifthen} can use the switch as |
| 465 |
% boolean: |
| 466 |
% \begin{quote} |
| 467 |
% |\boolean{foobar@verbose}| |
| 468 |
% \end{quote} |
| 469 |
% |
| 470 |
% \subsubsection{\cs{DeclareComplementaryOption}} |
| 471 |
% |
| 472 |
% \begin{declcs}{DeclareComplementaryOption}\,\M{key}\,\M{parent} |
| 473 |
% \end{declcs} |
| 474 |
% Sometimes contrasting names are used to characterize the |
| 475 |
% two states of a boolean switch, for example \xoption{draft} |
| 476 |
% vs.\@ \xoption{final}. Both options behave like boolean |
| 477 |
% options but they do not need two different switches, they |
| 478 |
% should share one. \cs{DeclareComplementaryOption} allows this. |
| 479 |
% The option \meta{key} shares the switch of option \meta{parent}. |
| 480 |
% Example: |
| 481 |
% \begin{quote} |
| 482 |
% |\DeclareBoolOption{draft}|\\ |
| 483 |
% |\DeclareComplementaryOption{final}{draft}| |
| 484 |
% \end{quote} |
| 485 |
% Then |final| sets the switch of \xoption{draft} to |false|, and |
| 486 |
% |final=false| enables the \xoption{draft} switch. |
| 487 |
% |
| 488 |
% \subsubsection{\cs{DeclareVoidOption}} |
| 489 |
% |
| 490 |
% \begin{declcs}{DeclareVoidOption}\,\M{key}\,\M{code} |
| 491 |
% \end{declcs} |
| 492 |
% \cs{ProcessKeyvalOptions} can be extended to recognize |
| 493 |
% options that are declared in traditional way by \cs{DeclareOption}. |
| 494 |
% But in case of the error that the user specifies a value, then |
| 495 |
% this option would not recognized as key value option because |
| 496 |
% of \cs{DeclareOption} and not detected as traditional option |
| 497 |
% because of the value part. The user would get an unknown option |
| 498 |
% error, difficult to understand. |
| 499 |
% |
| 500 |
% \cs{DeclareVoidOption} solves |
| 501 |
% this problem. It defines the option \meta{key} as key value option. |
| 502 |
% If the user specifies a value, a warning is given and the |
| 503 |
% value is ignored. |
| 504 |
% |
| 505 |
% The code part \meta{code} is stored in a macro. |
| 506 |
% The name of the macro consists of the option name \meta{key} that |
| 507 |
% is prefixed by the prefix (see \ref{setup}). |
| 508 |
% If the option is set, the macro will be executed. During the |
| 509 |
% execution \cs{CurrentOption} is available with the current key name. |
| 510 |
% |
| 511 |
% \subsubsection{\cs{DeclareDefaultOption}} |
| 512 |
% |
| 513 |
% \begin{declcs}{DeclareDefaultOption}\,\M{code} |
| 514 |
% \end{declcs} |
| 515 |
% \begin{sloppypar} |
| 516 |
% This command does not define a specific key, it is the equivalent |
| 517 |
% to \LaTeX's \cs{DeclareOption*}. It allows the specification |
| 518 |
% of a default action \meta{code} that is invoked if an unknown option |
| 519 |
% is found. |
| 520 |
% While \meta{code} is called, |
| 521 |
% macro \cs{CurrentOption} contains the current option string. |
| 522 |
% In addition \cs{CurrentOptionValue} contains the value part |
| 523 |
% if the option string is parsable as key value pair, otherwise |
| 524 |
% it is \cs{relax}. \cs{CurrentOptionKey} contains the key of |
| 525 |
% the key value pair, or the whole option string, if it misses |
| 526 |
% the equal sign. |
| 527 |
% \end{sloppypar} |
| 528 |
% |
| 529 |
% Inside packages typical default actions are to pass unknown |
| 530 |
% options to another package. Or an error message can be thrown |
| 531 |
% by \cs{@unknownoptionerror}. This is the original error |
| 532 |
% message that \LaTeX\ gives for unkown package options. |
| 533 |
% This error message is easier to understand for the user |
| 534 |
% as the error message from package \xpackage{keyval} that |
| 535 |
% is given otherwise. |
| 536 |
% |
| 537 |
% A Class ignores unknown options and puts them on the |
| 538 |
% unused option list. Let \LaTeX\ do the job and just |
| 539 |
% call \cs{OptionNotUsed}. Or the options can be passed to |
| 540 |
% another class that is later loaded. |
| 541 |
% |
| 542 |
% \subsubsection{Local options} |
| 543 |
% |
| 544 |
% \begin{declcs}{DeclareLocalOption} \M{option}\\ |
| 545 |
% \cs{DeclareLocalOptions} \M{option list} |
| 546 |
% \end{declcs} |
| 547 |
% Both macros mark package options as local options. That means |
| 548 |
% that they are ignored by \cs{ProcessKeyvalOptions} if they are given |
| 549 |
% as global options. \cs{DeclareLocalOptions} takes one option, |
| 550 |
% \cs{DeclareLocalOptions} expects a comma separated list of options. |
| 551 |
% |
| 552 |
% \subsubsection{Dynamic options} |
| 553 |
% |
| 554 |
% Options of \LaTeX's package/class system are cleared |
| 555 |
% in \cs{ProcessOptions}. They modify the static model |
| 556 |
% of a package. For example, depending on option \xoption{bookmarks} |
| 557 |
% package \xpackage{hyperref} loads differently. |
| 558 |
% |
| 559 |
% Options, however, |
| 560 |
% defined by \xpackage{keyval}'s \cs{define@key} remain |
| 561 |
% defined, if the options are processed by \cs{setkeys}. |
| 562 |
% Therefore these options can also be used to model |
| 563 |
% the dynamic behaviour of a package. For example, in |
| 564 |
% \xpackage{hyperref} the link colors can be changed |
| 565 |
% everywhere until the end in |\end{document}|. |
| 566 |
% |
| 567 |
% However package \xpackage{color} that adds color support |
| 568 |
% is necessary and it |
| 569 |
% cannot be loaded after |\begin{document}|. Option \xoption{colorlinks} |
| 570 |
% that loads \xpackage{color} should be active until |\begin{document}| |
| 571 |
% and die in some way if it is too late for loading packages. |
| 572 |
% With \cs{DisableKeyvalOption} the package/class author can |
| 573 |
% specify and configure the death of an option and controls |
| 574 |
% the life period of the option. |
| 575 |
% |
| 576 |
% \subsubsection{\cs{DisableKeyvalOption}} |
| 577 |
% |
| 578 |
% \begin{declcs}{DisableKeyvalOption}\,\O{options}\,\M{family}\,\M{key} |
| 579 |
% \\[0.5ex] |
| 580 |
% \meta{options}:\\ |
| 581 |
% \hspace{1.5em}^^A |
| 582 |
% \begin{tabular}[t]{@{}l@{ \texttt{=} }l@{\qquad}>{default: }l@{}} |
| 583 |
% |action| & |undef|, |warning|, |error|, or |ignore| |
| 584 |
% & |undef| |
| 585 |
% \\ |
| 586 |
% \multicolumn{1}{@{}l}{|global| or |local|} & & |global| |
| 587 |
% \\ |
| 588 |
% |package| or |class| & \meta{name} |
| 589 |
% \\ |
| 590 |
% \end{tabular}^^A |
| 591 |
% \end{declcs} |
| 592 |
% \cs{DisableKeyvalOption} can be called to mark the end when |
| 593 |
% the option \meta{key} is no longer useful. The behaviour of |
| 594 |
% an option after its death can be configured by \xoption{action}: |
| 595 |
% \begin{description} |
| 596 |
% \item[\texttt{undef}:] The option will be undefined, |
| 597 |
% If it is called, \cs{setkeys} reports an error because |
| 598 |
% of unknown key. |
| 599 |
% \item[\texttt{error} or \texttt{warning}:] Use of the |
| 600 |
% option will cause an error or warning message. |
| 601 |
% Also these actions require that exclusivly either the |
| 602 |
% package or class name is given in options \xoption{package} |
| 603 |
% or \xoption{class}. |
| 604 |
% \item[\texttt{ignore}:] The use of the option will silently |
| 605 |
% be ignored. |
| 606 |
% \end{description} |
| 607 |
% The option's death can be limited to the end of the current |
| 608 |
% group, if option \xoption{local} is given. Default is |
| 609 |
% \xoption{global}. |
| 610 |
% |
| 611 |
% The package/class author can wish the end of the option |
| 612 |
% already during the package loading, then he will have |
| 613 |
% static behaviour. In case of dynamic options \cs{DisableKeyvalOption} |
| 614 |
% can be executed everywhere, also outside the package. Therefore |
| 615 |
% the family name and the package/class name is usually unknown for |
| 616 |
% \cs{DisableKeyvalOption}. Therefore the argument for the family |
| 617 |
% name is mandatory and for some actions the package/class name |
| 618 |
% must be provided. |
| 619 |
% |
| 620 |
% Usually a macro would configure the option death, Example: |
| 621 |
%\begin{quote} |
| 622 |
%\begin{verbatim} |
| 623 |
%\ProvidesPackage{foobar} |
| 624 |
%\DeclareBoolOption{color} |
| 625 |
%\DeclareStringOption[red]{emphcolor} |
| 626 |
%\ProcessKeyvalOptions* |
| 627 |
% |
| 628 |
%\newcommand*{\foobar@DisableOption}[2]{% |
| 629 |
% \DisableKeyvalueOption[ |
| 630 |
% action={#1}, |
| 631 |
% package=foobar |
| 632 |
% ]{foobar}{#2}% |
| 633 |
%} |
| 634 |
% |
| 635 |
%\iffoobar@color |
| 636 |
% \RequirePackage{color} |
| 637 |
% \renewcommand*{\emph}[1]{\textcolor{\foobar@emphcolor}{#1}} |
| 638 |
%\else |
| 639 |
% % Option emphcolor is not wrong, if we have color support. |
| 640 |
% % otherwise the option has no effect, but we don't want to |
| 641 |
% % remove it. Therefore action 'ignore' is the best choice: |
| 642 |
% \foobar@DisableOption{ignore}{emphcolor} |
| 643 |
%\fi |
| 644 |
%% No we don't need the option 'color'. |
| 645 |
%\foobar@DisableOption{warning}{color} |
| 646 |
% |
| 647 |
%% With color support option 'emphcolor' will dynamically |
| 648 |
%% change the color of \emph statements. |
| 649 |
%\end{verbatim} |
| 650 |
%\end{quote} |
| 651 |
% |
| 652 |
% \subsubsection{\cs{AddToKeyvalOption}} |
| 653 |
% |
| 654 |
% \begin{declcs}{AddToKeyvalOption}\,\M{family}\,\M{key}\,\M{code}\\ |
| 655 |
% \cs{AddToKeyvalOption} \*\,\M{key}\,\M{code} |
| 656 |
% \end{declcs} |
| 657 |
% The code for an existing key \meta{key} of family \meta{family} is |
| 658 |
% extended by code \meta{code}. In the starred form the current |
| 659 |
% family setting is used, see \cs{ProcessKeyvalOptions*}. |
| 660 |
% |
| 661 |
% \subsection{Global vs. local options} |
| 662 |
% |
| 663 |
% Options that are given for \cs{documentclass} are called |
| 664 |
% global options. They are known to the class and all packages. |
| 665 |
% A package may make use of a global option and marks it as |
| 666 |
% used. The advantage for the user is the freedom to specify |
| 667 |
% options both in the \cs{documentclass} or \cs{usepackage} |
| 668 |
% commands. |
| 669 |
% |
| 670 |
% However global options are shared with the class options |
| 671 |
% and options of all other packages. Thus there can be the |
| 672 |
% same option with different semantics for different |
| 673 |
% packages and classes. As example, package \xpackage{bookmark} |
| 674 |
% knows option \xoption{open} that specifies whether the bookmarks |
| 675 |
% are opened or closed initially. It's values are |true| or |false|. |
| 676 |
% Since KOMA-Script version 3.00 the KOMA classes also introduces |
| 677 |
% option \xoption{open} with values |right| and |any| and a |
| 678 |
% complete different meaning. |
| 679 |
% |
| 680 |
% Such conflicts can be resolved by marking all or part of options |
| 681 |
% as local by \cs{DeclareLocalOption} or \cs{DeclareLocalOptions}. |
| 682 |
% Then the packages ignores global occurences of these options. |
| 683 |
% Package \xpackage{kvoptions} provides two methods: |
| 684 |
% \begin{itemize} |
| 685 |
% \item \cs{ProcessLocalKeyvalOptions} automatically uses all options |
| 686 |
% as local options. It ignores all global options. |
| 687 |
% \item \cs{DeclareLocalOption} or \cs{DeclareLocalOptions} marks |
| 688 |
% options as local options. \cs{ProcessKeyvalOptions} will then |
| 689 |
% ignore global occurences for these local options. |
| 690 |
% \end{itemize} |
| 691 |
% Since version 1.5 package \xpackage{bookmark} uses the latter |
| 692 |
% method. It checks global and local option places for driver options |
| 693 |
% and limits all other options as local options. Thus the class |
| 694 |
% option \xoption{open} of KOMA-Script is not misread as |
| 695 |
% option for package \xpackage{bookmark}. |
| 696 |
% |
| 697 |
% \subsection{Summary of internal macros} |
| 698 |
% |
| 699 |
% The \cs{Declare}\texttt{\dots Option} commands define |
| 700 |
% macros, additionally to the macros generated by the key definition. |
| 701 |
% These macros can be used by the package/class author. |
| 702 |
% The name of the macros starts with the prefix \meta{prefix} |
| 703 |
% that can be configured by \cs{SetupKeyvalOptions}. |
| 704 |
% \begin{center} |
| 705 |
% \def\prefix{\cs{}\meta{prefix}\meta{key}}^^A |
| 706 |
% \def\Hline{^^A |
| 707 |
% \hline |
| 708 |
% \rule{0pt}{1.2\ht\csname @arstrutbox\endcsname}^^A |
| 709 |
% }^^A |
| 710 |
% \begin{tabular}{@{}l|>{\ttfamily}l|l@{}} |
| 711 |
% Declare \meta{key} & \textrm{Defined macro} & Description\\ |
| 712 |
% \Hline |
| 713 |
% \cs{DeclareStringOption} |
| 714 |
% & \prefix & holds the string\\ |
| 715 |
% \Hline |
| 716 |
% \cs{DeclareBoolOption} |
| 717 |
% & \cs{if}\meta{prefix}\meta{key}& boolean switch\\ |
| 718 |
% &\prefix false& disable switch\\ |
| 719 |
% &\prefix true& enable switch\\ |
| 720 |
% \Hline |
| 721 |
% \cs{DeclareComplementaryOption} |
| 722 |
% & \prefix false& enable parent switch\\ |
| 723 |
% & \prefix true& disable parent switch\\ |
| 724 |
% \Hline |
| 725 |
% \cs{DeclareVoidOption} |
| 726 |
% & \prefix & holds the action |
| 727 |
% \end{tabular} |
| 728 |
% \end{center} |
| 729 |
% |
| 730 |
% \subsection{\plainTeX} |
| 731 |
% |
| 732 |
% Package \xpackage{keyval} is also usable in \plainTeX\ with |
| 733 |
% the help of file \xfile{miniltx.tex}. Some features of this |
| 734 |
% package \xpackage{kvoptions} might also be useful for \plainTeX. |
| 735 |
% If \LaTeX\ is not found, \cs{ProcessKeyvalOptions} and option |
| 736 |
% \xoption{patch} are disabled. Before using the option declaration |
| 737 |
% commands \cs{Declare...Option}, \cs{SetupKeyvalOptions} must be |
| 738 |
% used. |
| 739 |
% |
| 740 |
% \hypersetup{bookmarksopenlevel=1} |
| 741 |
% |
| 742 |
% \section{Example} |
| 743 |
% |
| 744 |
% The following example defined a package that serves some |
| 745 |
% private color management. A boolean option \xoption{print} enables |
| 746 |
% print mode without colors. An option \xoption{emph} redefines |
| 747 |
% \cs{emph} to print in the given color. And the driver |
| 748 |
% can be specified by option \xoption{driver}. |
| 749 |
% |
| 750 |
% \begin{macrocode} |
| 751 |
%<*example> |
| 752 |
% Package identification |
| 753 |
% ----------------------- |
| 754 |
\NeedsTeXFormat{LaTeX2e} |
| 755 |
\ProvidesPackage{example-mycolorsetup}[2019/11/29 Managing my colors] |
| 756 |
|
| 757 |
\RequirePackage{iftex} |
| 758 |
\RequirePackage{kvoptions} |
| 759 |
|
| 760 |
% Option declarations |
| 761 |
% ------------------- |
| 762 |
|
| 763 |
\SetupKeyvalOptions{ |
| 764 |
family=MCS, |
| 765 |
prefix=MCS@ |
| 766 |
} |
| 767 |
% Use a shorter family name and prefix |
| 768 |
|
| 769 |
% Option print |
| 770 |
\DeclareBoolOption{print} |
| 771 |
% is the same as |
| 772 |
% \DeclareBoolOption[false]{print} |
| 773 |
|
| 774 |
% Option driver |
| 775 |
\ifpdf |
| 776 |
\DeclareStringOption[pdftex]{driver} |
| 777 |
\else |
| 778 |
\DeclareStringOption[dvips]{driver} |
| 779 |
\fi |
| 780 |
|
| 781 |
% Alternative interface for driver options |
| 782 |
\DeclareVoidOption{dvips}{\SetupDriver} |
| 783 |
\DeclareVoidOption{dvipdfm}{\SetupDriver} |
| 784 |
\DeclareVoidOption{pdftex}{\SetupDriver} |
| 785 |
% In \SetupDriver we take the current option \CurrentOption |
| 786 |
% and pass it to the driver option. |
| 787 |
% The \expandafter commands expand \CurrentOption at the |
| 788 |
% time, when \SetupDriver is executed and \CurrentOption |
| 789 |
% has the correct meaning. |
| 790 |
\newcommand*{\SetupDriver}{% |
| 791 |
\expandafter\@SetupDriver\expandafter{\CurrentOption}% |
| 792 |
} |
| 793 |
\newcommand*{\@SetupDriver}[1]{% |
| 794 |
\setkeys{MCS}{driver={#1}}% |
| 795 |
} |
| 796 |
|
| 797 |
% Option emph |
| 798 |
% An empty value means, we want to have no color for \emph. |
| 799 |
% If the user specifies option emph without value, the red is used. |
| 800 |
\DeclareStringOption{emph}[red] |
| 801 |
% is the same as |
| 802 |
% \DeclareStringOption[]{emph}[red] |
| 803 |
|
| 804 |
% Default option rule |
| 805 |
\DeclareDefaultOption{% |
| 806 |
\ifx\CurrentOptionValue\relax |
| 807 |
\PackageWarningNoLine{\@currname}{% |
| 808 |
Unknown option `\CurrentOption'\MessageBreak |
| 809 |
is passed to package `color'% |
| 810 |
}% |
| 811 |
% Pass the option to package color. |
| 812 |
% Again it is better to expand \CurrentOption. |
| 813 |
\expandafter\PassOptionsToPackage |
| 814 |
\expandafter{\CurrentOption}{color}% |
| 815 |
\else |
| 816 |
% Package color does not take options with values. |
| 817 |
% We provide the standard LaTeX error. |
| 818 |
\@unknownoptionerror |
| 819 |
\fi |
| 820 |
} |
| 821 |
|
| 822 |
% Process options |
| 823 |
% --------------- |
| 824 |
\ProcessKeyvalOptions* |
| 825 |
|
| 826 |
% Implementation depending on option values |
| 827 |
% ----------------------------------------- |
| 828 |
% Code for print mode |
| 829 |
\ifMCS@print |
| 830 |
\PassOptionsToPackage{monochrome}{color} |
| 831 |
% tells package color to use black and white |
| 832 |
\fi |
| 833 |
|
| 834 |
\RequirePackage[\MCS@driver]{color} |
| 835 |
% load package color with the correct driver |
| 836 |
|
| 837 |
% \emph setup |
| 838 |
\ifx\MCS@emph\@empty |
| 839 |
% \@empty is a predefined macro with empty contents. |
| 840 |
% the option value of option emph is empty, thus |
| 841 |
% we do not want a redefinition of \emph. |
| 842 |
\else |
| 843 |
\renewcommand*{\emph}[1]{% |
| 844 |
\textcolor{\MCS@emph}{#1}% |
| 845 |
} |
| 846 |
\fi |
| 847 |
%</example> |
| 848 |
% \end{macrocode} |
| 849 |
% |
| 850 |
% \section{Package options} |
| 851 |
% |
| 852 |
% The package \xpackage{kvoptions} knows two package options |
| 853 |
% \xoption{patch} and \xoption{debugshow}. |
| 854 |
% The options of package \xpackage{kvoptions} are intended |
| 855 |
% for authors, not for package/class writers. Inside a package |
| 856 |
% it is too late for option \xoption{patch} and \xoption{debugshow} |
| 857 |
% enables some messages that are perhaps useful for the debugging |
| 858 |
% phase. Also \LaTeX\ is unhappy if a package is loaded |
| 859 |
% later again with options that are previously not given. |
| 860 |
% Thus package and class authors, stay with |\RequirePackage{kvoptions}| |
| 861 |
% without options. |
| 862 |
% |
| 863 |
% Option \xoption{patch} loads package \xpackage{kvoptions-patch}. |
| 864 |
% |
| 865 |
% \subsection{Package \xpackage{kvoptions-patch}} |
| 866 |
% |
| 867 |
% \begin{description} |
| 868 |
% \item[Change in version v3.14:] \xpackage{kvoptions-patch} is not compatible with a |
| 869 |
% \LaTeX\ 2020-10-01 or newer and will abort loading if it detects it! |
| 870 |
% \end{description} |
| 871 |
% |
| 872 |
% \LaTeX's system of package/class options has some severe limitations |
| 873 |
% that especially affects the value part if options are used as |
| 874 |
% pair of key and value. |
| 875 |
% \begin{itemize} |
| 876 |
% \item Spaces are removed, regardless where: |
| 877 |
% \begin{quote} |
| 878 |
% |\documentclass[box=0 0 400 600]{article}| |
| 879 |
% \end{quote} |
| 880 |
% Now each package will see |box=00400600| as global option. |
| 881 |
% \item In the previous case also braces would not help: |
| 882 |
% \begin{quote} |
| 883 |
% |\documentclass[box={0 0 400 600}]{article}| |
| 884 |
% \end{quote} |
| 885 |
% The result is an error message: |
| 886 |
% \begin{quote} |
| 887 |
% |! LaTeX Error: Missing \begin{document}.| |
| 888 |
% \end{quote} |
| 889 |
% As local option, however, it works if the package |
| 890 |
% knows about key value options (By using this package, for example). |
| 891 |
% \item The requirements on robustness are extremly high. |
| 892 |
% \LaTeX\ expands the option. All that will not work as environment |
| 893 |
% name will break also as option. Even a \cs{relax} will generate |
| 894 |
% an error message: |
| 895 |
% \begin{quote} |
| 896 |
% |! Missing \endcsname inserted.| |
| 897 |
% \end{quote} |
| 898 |
% Of course, \LaTeX\ does not use its protecting mechanisms. |
| 899 |
% On contrary \cs{protect} itself will cause errors. |
| 900 |
% \item The options are expanded. But perhaps the package will |
| 901 |
% do that, because it has to setup some things before? |
| 902 |
% Example \xpackage{hyperref}: |
| 903 |
% \begin{quote} |
| 904 |
% |\usepackage[pdfauthor=M\"uller]{hyperref}| |
| 905 |
% \end{quote} |
| 906 |
% Package \xpackage{hyperref} does not see |M\"uller| but |
| 907 |
% its expansion and it does not like it, you get many warnings |
| 908 |
% \begin{quote} |
| 909 |
% |Token not allowed in a PDFDocEncoded string| |
| 910 |
% \end{quote} |
| 911 |
% And the title becomes: |Mu127uller|. |
| 912 |
% Therefore such options must usually be given after package |
| 913 |
% \xpackage{hyperref} |
| 914 |
% is loaded: |
| 915 |
% \begin{quote} |
| 916 |
% |\usepackage{hyperref}|\\ |
| 917 |
% |\hypersetup{pdfauthor=Fran\c coise M\"uller}| |
| 918 |
% \end{quote} |
| 919 |
% As package option it will even break with |Fran\c coise| |
| 920 |
% because of the cedilla |\c c|, it is not robust enough. |
| 921 |
% \end{itemize} |
| 922 |
% For users that do not want with this limitations the package |
| 923 |
% offers package \xoption{kvoptions-patch}. It patches \LaTeX's option system |
| 924 |
% and tries to teach it also to handle options that are given |
| 925 |
% as pairs of key and value and to prevent expansion. |
| 926 |
% It can already be used at the very beginning, before \cs{documentclass}: |
| 927 |
% \begin{quote} |
| 928 |
% |\RequirePackage{kvoptions-patch}|\\ |
| 929 |
% |\documentclass[pdfauthor=Fran\c coise M\"uller]{article}|\\ |
| 930 |
% |\usepackage{hyperref}| |
| 931 |
% \end{quote} |
| 932 |
% The latest time is before the package where you want to use |
| 933 |
% problematic values: |
| 934 |
% \begin{quote} |
| 935 |
% |\usepackage{kvoptions-patch}|\\ |
| 936 |
% |\usepackage[Fran\c coise M\"uller]{hyperref}| |
| 937 |
% \end{quote} |
| 938 |
% Some remarks: |
| 939 |
% \begin{itemize} |
| 940 |
% \item The patch requires \eTeX, its \cs{unexpanded} feature |
| 941 |
% is much too nice. It is possible to work around using token |
| 942 |
% registers. But the code becomes longer, slower, more difficult |
| 943 |
% to read and maintain. The package without option \xoption{patch} |
| 944 |
% works and will work without \eTeX. |
| 945 |
% \item The code for the patch is quite long, there are many test |
| 946 |
% cases. Thus the probability for bugs is probably not too small. |
| 947 |
% \item Since 2008/10/18 v3.0 package \xpackage{kvoptions-patch} is |
| 948 |
% available. Before option \xoption{patch} of package \xpackage{kvoptions} |
| 949 |
% must be used instead. I think, the solution as standalone package |
| 950 |
% \xpackage{kvoptions-patch} is cleaner and avoids option clashes. |
| 951 |
% \end{itemize} |
| 952 |
% |
| 953 |
% \subsection{Option \xoption{debugshow}} |
| 954 |
% |
| 955 |
% The name of this option follows the convention of packages |
| 956 |
% \xpackage{multicol}, \xpackage{tabularx}, and \xpackage{tracefnt}. |
| 957 |
% Currently it prints the setting of boolean options, declared |
| 958 |
% by \cs{DeclareBoolOption} in the \xfile{.log} file, if that |
| 959 |
% boolean option is used. |
| 960 |
% You can activate the option by |
| 961 |
% \begin{itemize} |
| 962 |
% \item |\PassOptionsToPackage{debugshow}{kvoptions}|\\ |
| 963 |
% Put this somewhere before package \xpackage{kvoptions} is |
| 964 |
% loaded first, e.g. before \cs{documentclass}. |
| 965 |
% \item |\RequirePackage[debugshow]{kvoptions}|\\ |
| 966 |
% Before \cs{documentclass} even an author has to use |
| 967 |
% \cs{RequirePackage}. \cs{usepackage} only works after |
| 968 |
% \cs{documentclass}. |
| 969 |
% \end{itemize} |
| 970 |
% The preferred method is \cs{PassOptionsToPackage}, because |
| 971 |
% it does not force the package loading and does not disturb, |
| 972 |
% if the package is not loaded later at all. |
| 973 |
% |
| 974 |
% \section{Limitations} |
| 975 |
% |
| 976 |
% \subsection{Compatibility} |
| 977 |
% \subsubsection{Package \xpackage{kvoptions-patch} vs. package \xpackage{xkvltxp}} |
| 978 |
% |
| 979 |
% Package \xpackage{xkvltxp} from the \xpackage{xkeyval} project |
| 980 |
% has the same goal as package \xpackage{kvoptions-patch} |
| 981 |
% and to patch \LaTeX's kernel commands in order to get better support |
| 982 |
% for key value options. |
| 983 |
% Of course they cannot be used both. The user must decide, which |
| 984 |
% method he prefers. Package \xpackage{kvoptions-patch} aborts itself, |
| 985 |
% if it detects that \xpackage{xkvltxp} is |
| 986 |
% already loaded. |
| 987 |
% |
| 988 |
% However package \xpackage{xkvltxp} and \xpackage{kvoptions} |
| 989 |
% can be used together, example: |
| 990 |
% \begin{quote} |
| 991 |
% |\usepackage{xkvltxp}|\\ |
| 992 |
% |\usepackage[...]{foobar} % |\texttt{\itshape foobar using kvoptions} |
| 993 |
% \end{quote} |
| 994 |
% The other way should work, too. |
| 995 |
% |
| 996 |
% Package \xpackage{kvoptions-patch} tries to catch more situations |
| 997 |
% and to be more robust. |
| 998 |
% For example, during the comparison of options it normalizes |
| 999 |
% them by removing spaces around |=| and the value. Thus the |
| 1000 |
% following is not reported as option clash: |
| 1001 |
% \begin{quote} |
| 1002 |
%\begin{verbatim} |
| 1003 |
%\RequirePackage{kvoptions-patch} |
| 1004 |
%\documentclass{article} |
| 1005 |
% |
| 1006 |
%\usepackage[scaled=0.7]{helvet} |
| 1007 |
%\usepackage[scaled = 0.7]{helvet} |
| 1008 |
% |
| 1009 |
%\begin{document} |
| 1010 |
%\end{document} |
| 1011 |
%\end{verbatim} |
| 1012 |
% \end{quote} |
| 1013 |
% |
| 1014 |
% \subsection{Limitations} |
| 1015 |
% |
| 1016 |
% \subsubsection{Option comparisons} |
| 1017 |
% |
| 1018 |
% In some situations \LaTeX\ compares option lists, e.g. option clash check, |
| 1019 |
% \cs{@ifpackagewith}, or \cs{@ifclasswith}. Apart from catcode and |
| 1020 |
% sanitizing problems of option \xoption{patch}, there is another problem. |
| 1021 |
% \LaTeX\ does not know about the type and default values of |
| 1022 |
% options in key value style. Thus an option clash is reported, |
| 1023 |
% even if the key value has the same meaning: |
| 1024 |
% \begin{quote} |
| 1025 |
% |\usepackage[scaled]{helvet} %| \texttt{\textit{default is }.95}\\ |
| 1026 |
% |\usepackage[.95]{helvet}|\\ |
| 1027 |
% |\usepackage[0.95]{helvet}| |
| 1028 |
% \end{quote} |
| 1029 |
% |
| 1030 |
% \subsubsection{Option list parsing with package \xpackage{kvoptions-patch}} |
| 1031 |
% |
| 1032 |
% With package \xpackage{kvoptions-patch} the range of possible values |
| 1033 |
% in key value specifications is much large, for example |
| 1034 |
% the comma can be used, if enclosed in curly braces. |
| 1035 |
% |
| 1036 |
% Other packages, especially the packages that uses their |
| 1037 |
% own process option code can be surprised to find tokens |
| 1038 |
% inside options that they do not expect and errors would |
| 1039 |
% be the consequence. To avoid errors the options, especially |
| 1040 |
% the unused option list is sanitized. That means the list |
| 1041 |
% will only contain tokens with catcode 12 (other) and |
| 1042 |
% perhaps spaces (catcode 10). This allows a safe parsing |
| 1043 |
% for other packages. But a comma in the value part is |
| 1044 |
% no longer protected by curly braces because they have lost |
| 1045 |
% their special meaning. This is the price for compatibility. |
| 1046 |
% |
| 1047 |
% Example: |
| 1048 |
% \begin{quote} |
| 1049 |
% |\RequirePackage{kvoptions-patch}|\\ |
| 1050 |
% |\documentclass[a={a,b,c},b]{article}|\\ |
| 1051 |
% |\begin{document}|\\ |
| 1052 |
% |\end{document}| |
| 1053 |
% \end{quote} |
| 1054 |
% Result: |
| 1055 |
% \begin{quote} |
| 1056 |
% |LaTeX Warning: Unused global option(s):|\\ |
| 1057 |
% | [a={a,c},b].| |
| 1058 |
% \end{quote} |
| 1059 |
% |
| 1060 |
% \StopEventually{ |
| 1061 |
% } |
| 1062 |
% |
| 1063 |
% \section{Implementation} |
| 1064 |
% \subsection{Disabling the patches for newer LaTeX} |
| 1065 |
% \xpackage{kvoptions-patch} is not compatible with \LaTeX{} 2020-10-01 and newer |
| 1066 |
% so it is disabled and issues a warning. |
| 1067 |
% \begin{macrocode} |
| 1068 |
%<*patch> |
| 1069 |
\providecommand\IfFormatAtLeastTF{\@ifl@t@r\fmtversion} |
| 1070 |
\IfFormatAtLeastTF{2020/10/01}{\PackageWarning{kvoptions-patch}% |
| 1071 |
{kvoptions-patch is not compatible with \MessageBreak |
| 1072 |
LaTeX \fmtversion\MessageBreak Loading is aborted}{}}{} |
| 1073 |
\IfFormatAtLeastTF{2020/10/01}{\endinput}{} |
| 1074 |
%</patch> |
| 1075 |
% \end{macrocode} |
| 1076 |
|
| 1077 |
% \subsection{Preamble} |
| 1078 |
% |
| 1079 |
% \begin{macrocode} |
| 1080 |
%<*package> |
| 1081 |
% \end{macrocode} |
| 1082 |
% |
| 1083 |
% \paragraph{Reload check and identification.} |
| 1084 |
% Reload check, especially if the package is not used with \LaTeX. |
| 1085 |
% \begin{macrocode} |
| 1086 |
\begingroup\catcode61\catcode48\catcode32=10\relax% |
| 1087 |
\catcode13=5 % ^^M |
| 1088 |
\endlinechar=13 % |
| 1089 |
\catcode35=6 % # |
| 1090 |
\catcode39=12 % ' |
| 1091 |
\catcode44=12 % , |
| 1092 |
\catcode45=12 % - |
| 1093 |
\catcode46=12 % . |
| 1094 |
\catcode58=12 % : |
| 1095 |
\catcode64=11 % @ |
| 1096 |
\catcode123=1 % { |
| 1097 |
\catcode125=2 % } |
| 1098 |
\expandafter\let\expandafter\x\csname [email protected]\endcsname |
| 1099 |
\ifx\x\relax % plain-TeX, first loading |
| 1100 |
\else |
| 1101 |
\def\empty{}% |
| 1102 |
\ifx\x\empty % LaTeX, first loading, |
| 1103 |
% variable is initialized, but \ProvidesPackage not yet seen |
| 1104 |
\else |
| 1105 |
\expandafter\ifx\csname PackageInfo\endcsname\relax |
| 1106 |
\def\x#1#2{% |
| 1107 |
\immediate\write-1{Package #1 Info: #2.}% |
| 1108 |
}% |
| 1109 |
\else |
| 1110 |
\def\x#1#2{\PackageInfo{#1}{#2, stopped}}% |
| 1111 |
\fi |
| 1112 |
\x{kvoptions}{The package is already loaded}% |
| 1113 |
\aftergroup\endinput |
| 1114 |
\fi |
| 1115 |
\fi |
| 1116 |
\endgroup% |
| 1117 |
% \end{macrocode} |
| 1118 |
% Package identification: |
| 1119 |
% \begin{macrocode} |
| 1120 |
\begingroup\catcode61\catcode48\catcode32=10\relax% |
| 1121 |
\catcode13=5 % ^^M |
| 1122 |
\endlinechar=13 % |
| 1123 |
\catcode35=6 % # |
| 1124 |
\catcode39=12 % ' |
| 1125 |
\catcode40=12 % ( |
| 1126 |
\catcode41=12 % ) |
| 1127 |
\catcode44=12 % , |
| 1128 |
\catcode45=12 % - |
| 1129 |
\catcode46=12 % . |
| 1130 |
\catcode47=12 % / |
| 1131 |
\catcode58=12 % : |
| 1132 |
\catcode64=11 % @ |
| 1133 |
\catcode91=12 % [ |
| 1134 |
\catcode93=12 % ] |
| 1135 |
\catcode123=1 % { |
| 1136 |
\catcode125=2 % } |
| 1137 |
\expandafter\ifx\csname ProvidesPackage\endcsname\relax |
| 1138 |
\def\x#1#2#3[#4]{\endgroup |
| 1139 |
\immediate\write-1{Package: #3 #4}% |
| 1140 |
\xdef#1{#4}% |
| 1141 |
}% |
| 1142 |
\else |
| 1143 |
\def\x#1#2[#3]{\endgroup |
| 1144 |
#2[{#3}]% |
| 1145 |
\ifx#1\@undefined |
| 1146 |
\xdef#1{#3}% |
| 1147 |
\fi |
| 1148 |
\ifx#1\relax |
| 1149 |
\xdef#1{#3}% |
| 1150 |
\fi |
| 1151 |
}% |
| 1152 |
\fi |
| 1153 |
\expandafter\x\csname [email protected]\endcsname |
| 1154 |
\ProvidesPackage{kvoptions}% |
| 1155 |
[2022-06-15 v3.15 Key value format for package options (HO)]% |
| 1156 |
% \end{macrocode} |
| 1157 |
% |
| 1158 |
% \paragraph{Catcodes} |
| 1159 |
% |
| 1160 |
% \begin{macrocode} |
| 1161 |
\begingroup\catcode61\catcode48\catcode32=10\relax% |
| 1162 |
\catcode13=5 % ^^M |
| 1163 |
\endlinechar=13 % |
| 1164 |
\catcode123=1 % { |
| 1165 |
\catcode125=2 % } |
| 1166 |
\catcode64=11 % @ |
| 1167 |
\def\x{\endgroup |
| 1168 |
\expandafter\edef\csname KVO@AtEnd\endcsname{% |
| 1169 |
\endlinechar=\the\endlinechar\relax |
| 1170 |
\catcode13=\the\catcode13\relax |
| 1171 |
\catcode32=\the\catcode32\relax |
| 1172 |
\catcode35=\the\catcode35\relax |
| 1173 |
\catcode61=\the\catcode61\relax |
| 1174 |
\catcode64=\the\catcode64\relax |
| 1175 |
\catcode123=\the\catcode123\relax |
| 1176 |
\catcode125=\the\catcode125\relax |
| 1177 |
}% |
| 1178 |
}% |
| 1179 |
\x\catcode61\catcode48\catcode32=10\relax% |
| 1180 |
\catcode13=5 % ^^M |
| 1181 |
\endlinechar=13 % |
| 1182 |
\catcode35=6 % # |
| 1183 |
\catcode64=11 % @ |
| 1184 |
\catcode123=1 % { |
| 1185 |
\catcode125=2 % } |
| 1186 |
\def\TMP@EnsureCode#1#2{% |
| 1187 |
\edef\KVO@AtEnd{% |
| 1188 |
\KVO@AtEnd |
| 1189 |
\catcode#1=\the\catcode#1\relax |
| 1190 |
}% |
| 1191 |
\catcode#1=#2\relax |
| 1192 |
} |
| 1193 |
\TMP@EnsureCode{1}{14}% ^^A (comment) |
| 1194 |
\TMP@EnsureCode{2}{14}% ^^A (comment) |
| 1195 |
\TMP@EnsureCode{33}{12}% ! |
| 1196 |
\TMP@EnsureCode{39}{12}% ' |
| 1197 |
\TMP@EnsureCode{40}{12}% ( |
| 1198 |
\TMP@EnsureCode{41}{12}% ) |
| 1199 |
\TMP@EnsureCode{42}{12}% * |
| 1200 |
\TMP@EnsureCode{44}{12}% , |
| 1201 |
\TMP@EnsureCode{45}{12}% - |
| 1202 |
\TMP@EnsureCode{46}{12}% . |
| 1203 |
\TMP@EnsureCode{47}{12}% / |
| 1204 |
\TMP@EnsureCode{58}{12}% : |
| 1205 |
\TMP@EnsureCode{62}{12}% > |
| 1206 |
\TMP@EnsureCode{91}{12}% [ |
| 1207 |
\TMP@EnsureCode{93}{12}% ] |
| 1208 |
\TMP@EnsureCode{94}{7}% ^ (superscript) |
| 1209 |
\TMP@EnsureCode{96}{12}% ` |
| 1210 |
\edef\KVO@AtEnd{\KVO@AtEnd\noexpand\endinput} |
| 1211 |
% \end{macrocode} |
| 1212 |
% |
| 1213 |
% \paragraph{External resources.} |
| 1214 |
% The package extends the support for key value pairs of |
| 1215 |
% package \cs{keyval} to package options. Thus the package |
| 1216 |
% needs to be loaded anyway. and we use it for |
| 1217 |
% \cs{SetupKeyvalOptions}. AFAIK this does not disturb |
| 1218 |
% users of \xpackage{xkeyval}. |
| 1219 |
% \begin{macrocode} |
| 1220 |
\@ifundefined{define@key}{% |
| 1221 |
\RequirePackage{keyval}\relax |
| 1222 |
}{} |
| 1223 |
% \end{macrocode} |
| 1224 |
% |
| 1225 |
% Macro \cs{DeclareLocalOptions} parses a comma separated key list |
| 1226 |
% and uses \cs{comma@parse} of package \xpackage{kvsetkeys}, |
| 1227 |
% version 1.3. |
| 1228 |
% \begin{macrocode} |
| 1229 |
\RequirePackage{ltxcmds}[2010/12/02] |
| 1230 |
\RequirePackage{kvsetkeys}[2007/09/29] |
| 1231 |
% \end{macrocode} |
| 1232 |
% |
| 1233 |
% \paragraph{Provide macros for \plainTeX.} |
| 1234 |
% \begin{macrocode} |
| 1235 |
\@ifundefined{@x@protect}{% |
| 1236 |
\def\@x@protect#1\fi#2#3{% |
| 1237 |
\fi\protect#1% |
| 1238 |
}% |
| 1239 |
\let\@typeset@protect\relax |
| 1240 |
}{} |
| 1241 |
\@ifundefined{@currname}{% |
| 1242 |
\def\@currname{}% |
| 1243 |
}{} |
| 1244 |
\@ifundefined{@currext}{% |
| 1245 |
\def\@currext{}% |
| 1246 |
}{} |
| 1247 |
% \end{macrocode} |
| 1248 |
% |
| 1249 |
% \paragraph{Options} |
| 1250 |
% Option \xoption{debugshow} enables additional lines of |
| 1251 |
% code that prints information into the \xfile{.log} |
| 1252 |
% file. |
| 1253 |
% \begin{macrocode} |
| 1254 |
\DeclareOption{debugshow}{\catcode\@ne=9 } |
| 1255 |
% \end{macrocode} |
| 1256 |
% |
| 1257 |
% \begin{macrocode} |
| 1258 |
\DeclareOption{patch}{% |
| 1259 |
\AtEndOfPackage{% |
| 1260 |
\RequirePackage{kvoptions-patch}[2019/11/29]% |
| 1261 |
}% |
| 1262 |
} |
| 1263 |
% \end{macrocode} |
| 1264 |
% |
| 1265 |
% Optionen auswerten: |
| 1266 |
% \begin{macrocode} |
| 1267 |
\ProcessOptions\relax |
| 1268 |
% \end{macrocode} |
| 1269 |
% |
| 1270 |
% \subsection{Option declaration macros} |
| 1271 |
% |
| 1272 |
% \subsubsection{\cs{SetupKeyvalOptions}} |
| 1273 |
% |
| 1274 |
% The family for the key value pairs can be setup once |
| 1275 |
% and is remembered later. |
| 1276 |
% The package name seems a reasonable default for the |
| 1277 |
% family key, if it is not set by the package author. |
| 1278 |
% |
| 1279 |
% \begin{macro}{\KVO@family} |
| 1280 |
% We cannot store the family setting in one macro, |
| 1281 |
% because the package should be usable for many |
| 1282 |
% other packages, too. Thus we remember the family |
| 1283 |
% setting in a macro, whose name contains the |
| 1284 |
% package name with extension, a key in \LaTeX's |
| 1285 |
% class/package system. |
| 1286 |
% \begin{macrocode} |
| 1287 |
\define@key{KVO}{family}{% |
| 1288 |
\expandafter\edef\csname KVO@family@% |
| 1289 |
\@currname.\@currext\endcsname{#1}% |
| 1290 |
} |
| 1291 |
\def\KVO@family{% |
| 1292 |
\@ifundefined{KVO@family@\@currname.\@currext}{% |
| 1293 |
\@currname |
| 1294 |
}{% |
| 1295 |
\csname KVO@family@\@currname.\@currext\endcsname |
| 1296 |
}% |
| 1297 |
} |
| 1298 |
% \end{macrocode} |
| 1299 |
% \end{macro} |
| 1300 |
% |
| 1301 |
% \begin{macro}{\KVO@prefix} |
| 1302 |
% The value settings of options that are declared by \cs{DeclareBoolOption} |
| 1303 |
% and \cs{DeclareStringOption} need to be saved in macros. |
| 1304 |
% in the first case this is a switch \cs{if}\meta{prefix}\meta{key}, |
| 1305 |
% in the latter case a macro \cs{}\meta{prefix}\meta{key}. |
| 1306 |
% The prefix can be configured, by \xoption{prefix} that is declared |
| 1307 |
% here. The default is the package name with |@| appended. |
| 1308 |
% \begin{macrocode} |
| 1309 |
\define@key{KVO}{prefix}{% |
| 1310 |
\expandafter\edef\csname KVO@prefix@% |
| 1311 |
\@currname.\@currext\endcsname{#1}% |
| 1312 |
} |
| 1313 |
\def\KVO@prefix{% |
| 1314 |
\ltx@ifundefined{KVO@prefix@\@currname.\@currext}{% |
| 1315 |
\@currname @% |
| 1316 |
}{% |
| 1317 |
\csname KVO@prefix@\@currname.\@currext\endcsname |
| 1318 |
}% |
| 1319 |
} |
| 1320 |
% \end{macrocode} |
| 1321 |
% \end{macro} |
| 1322 |
% |
| 1323 |
% \begin{macrocode} |
| 1324 |
\define@key{KVO}{setkeys}{% |
| 1325 |
\expandafter\def\csname KVO@setkeys@% |
| 1326 |
\@currname.\@currext\endcsname{#1}% |
| 1327 |
} |
| 1328 |
% \end{macrocode} |
| 1329 |
% \begin{macro}{\KVO@setkeys} |
| 1330 |
% \begin{macrocode} |
| 1331 |
\def\KVO@setkeys{% |
| 1332 |
\ltx@IfUndefined{KVO@setkeys@\@currname.\@currext}{% |
| 1333 |
\setkeys |
| 1334 |
}{% |
| 1335 |
\csname KVO@setkeys@\@currname.\@currext\endcsname |
| 1336 |
}% |
| 1337 |
} |
| 1338 |
% \end{macrocode} |
| 1339 |
% \end{macro} |
| 1340 |
% |
| 1341 |
% \begin{macro}{\SetupKeyvalOptions} |
| 1342 |
% The argument of \cs{SetupKeyvalOptions} expects a key value |
| 1343 |
% list, known keys are \xoption{family} and \xoption{prefix}. |
| 1344 |
% \begin{macrocode} |
| 1345 |
\newcommand*{\SetupKeyvalOptions}{% |
| 1346 |
\kvsetkeys{KVO}% |
| 1347 |
} |
| 1348 |
% \end{macrocode} |
| 1349 |
% \end{macro} |
| 1350 |
% |
| 1351 |
% \subsubsection{\cs{DeclareBoolOption}} |
| 1352 |
% |
| 1353 |
% \begin{macro}{\DeclareBoolOption} |
| 1354 |
% Usually options of boolean type can be given by the |
| 1355 |
% user without value and this means a setting to \emph{true}. |
| 1356 |
% We follow this convention here. Also it simplifies the |
| 1357 |
% user interface. |
| 1358 |
% |
| 1359 |
% The switch is created and initialized with \emph{false}. |
| 1360 |
% The default setting can be overwritten by the optional |
| 1361 |
% argument. |
| 1362 |
% |
| 1363 |
% \LaTeX's \cs{newif} does not check for already defined |
| 1364 |
% macros, therefore we add this check here to prevent |
| 1365 |
% the user from accidently redefining of \TeX's primitives |
| 1366 |
% and other macros. |
| 1367 |
% \begin{macrocode} |
| 1368 |
\newcommand*{\DeclareBoolOption}[2][false]{% |
| 1369 |
\KVO@ifdefinable{if\KVO@prefix#2}{% |
| 1370 |
\KVO@ifdefinable{\KVO@prefix#2true}{% |
| 1371 |
\KVO@ifdefinable{\KVO@prefix#2false}{% |
| 1372 |
\csname newif\expandafter\endcsname |
| 1373 |
\csname if\KVO@prefix#2\endcsname |
| 1374 |
\@ifundefined{\KVO@prefix#2#1}{% |
| 1375 |
\PackageWarning{kvoptions}{% |
| 1376 |
Initialization of option `#2' failed,\MessageBreak |
| 1377 |
cannot set boolean option to `#1',\MessageBreak |
| 1378 |
use `true' or `false', now using `false'% |
| 1379 |
}% |
| 1380 |
}{% |
| 1381 |
\csname\KVO@prefix#2#1\endcsname |
| 1382 |
}% |
| 1383 |
\begingroup |
| 1384 |
\edef\x{\endgroup |
| 1385 |
\noexpand\define@key{\KVO@family}{#2}[true]{% |
| 1386 |
\noexpand\KVO@boolkey{\@currname}% |
| 1387 |
\ifx\@currext\@clsextension |
| 1388 |
\noexpand\@clsextension |
| 1389 |
\else |
| 1390 |
\noexpand\@pkgextension |
| 1391 |
\fi |
| 1392 |
{\KVO@prefix}{#2}{####1}% |
| 1393 |
}% |
| 1394 |
}% |
| 1395 |
\x |
| 1396 |
}% |
| 1397 |
}% |
| 1398 |
}% |
| 1399 |
} |
| 1400 |
% \end{macrocode} |
| 1401 |
% \end{macro} |
| 1402 |
% |
| 1403 |
% \begin{macro}{\DeclareComplementaryOption} |
| 1404 |
% The first argument is the key name, the second the |
| 1405 |
% key that must be a boolean option with the same |
| 1406 |
% current family and prefix. A new switch is not |
| 1407 |
% created for the new key, we have already a switch. |
| 1408 |
% Instead we define switch setting commands to work |
| 1409 |
% on the parent switch. |
| 1410 |
% \begin{macrocode} |
| 1411 |
\newcommand*{\DeclareComplementaryOption}[2]{% |
| 1412 |
\@ifundefined{if\KVO@prefix#2}{% |
| 1413 |
\PackageError{kvoptions}{% |
| 1414 |
Cannot generate option code for `#1',\MessageBreak |
| 1415 |
parent switch `#2' does not exist% |
| 1416 |
}{% |
| 1417 |
You are inside % |
| 1418 |
\ifx\@currext\@clsextension class\else package\fi\space |
| 1419 |
`\@currname.\@currext'.\MessageBreak |
| 1420 |
`\KVO@family' is used as familiy % |
| 1421 |
for the keyval options.\MessageBreak |
| 1422 |
`\KVO@prefix' serves as prefix % |
| 1423 |
for internal switch macros.\MessageBreak |
| 1424 |
\MessageBreak |
| 1425 |
\@ehc |
| 1426 |
}% |
| 1427 |
}{% |
| 1428 |
\KVO@ifdefinable{\KVO@prefix#1true}{% |
| 1429 |
\KVO@ifdefinable{\KVO@prefix#1false}{% |
| 1430 |
\expandafter\let\csname\KVO@prefix#1false\expandafter\endcsname |
| 1431 |
\csname\KVO@prefix#2true\endcsname |
| 1432 |
\expandafter\let\csname\KVO@prefix#1true\expandafter\endcsname |
| 1433 |
\csname\KVO@prefix#2false\endcsname |
| 1434 |
% \end{macrocode} |
| 1435 |
% The same code part as in \cs{DeclareBoolOption} can |
| 1436 |
% now be used. |
| 1437 |
% \begin{macrocode} |
| 1438 |
\begingroup |
| 1439 |
\edef\x{\endgroup |
| 1440 |
\noexpand\define@key{\KVO@family}{#1}[true]{% |
| 1441 |
\noexpand\KVO@boolkey{\@currname}% |
| 1442 |
\ifx\@currext\@clsextension |
| 1443 |
\noexpand\@clsextension |
| 1444 |
\else |
| 1445 |
\noexpand\@pkgextension |
| 1446 |
\fi |
| 1447 |
{\KVO@prefix}{#1}{####1}% |
| 1448 |
}% |
| 1449 |
}% |
| 1450 |
\x |
| 1451 |
}% |
| 1452 |
}% |
| 1453 |
}% |
| 1454 |
} |
| 1455 |
% \end{macrocode} |
| 1456 |
% \end{macro} |
| 1457 |
% |
| 1458 |
% \begin{macro}{\KVO@ifdefinable} |
| 1459 |
% Generate the command token LaTeX's \cs{@ifdefinable} expects. |
| 1460 |
% \begin{macrocode} |
| 1461 |
\def\KVO@ifdefinable#1{% |
| 1462 |
\expandafter\@ifdefinable\csname #1\endcsname |
| 1463 |
} |
| 1464 |
% \end{macrocode} |
| 1465 |
% \end{macro} |
| 1466 |
% |
| 1467 |
% \begin{macro}{\KVO@boolkey} |
| 1468 |
% We check explicitly for |true| and |false| to prevent |
| 1469 |
% the user from accidently calling other macros. |
| 1470 |
% \begin{quote} |
| 1471 |
% \begin{tabular}{@{}ll@{}} |
| 1472 |
% |#1|& package/class name\\ |
| 1473 |
% |#2|& |\@pkgextension|/|\@clsextension|\\ |
| 1474 |
% |#3|& prefix \\ |
| 1475 |
% |#4|& key name\\ |
| 1476 |
% |#5|& new value |
| 1477 |
% \end{tabular} |
| 1478 |
% \end{quote} |
| 1479 |
% \begin{macrocode} |
| 1480 |
\def\KVO@boolkey#1#2#3#4#5{% |
| 1481 |
\edef\KVO@param{#5}% |
| 1482 |
\ltx@onelevel@sanitize\KVO@param |
| 1483 |
\ifx\KVO@param\KVO@true |
| 1484 |
\expandafter\@firstofone |
| 1485 |
\else |
| 1486 |
\ifx\KVO@param\KVO@false |
| 1487 |
\expandafter\expandafter\expandafter\@firstofone |
| 1488 |
\else |
| 1489 |
\ifx#2\@clsextension |
| 1490 |
\expandafter\ClassWarning |
| 1491 |
\else |
| 1492 |
\expandafter\PackageWarning |
| 1493 |
\fi |
| 1494 |
{#1}{% |
| 1495 |
Value `\KVO@param' is not supported by\MessageBreak |
| 1496 |
option `#4'% |
| 1497 |
}% |
| 1498 |
\expandafter\expandafter\expandafter\@gobble |
| 1499 |
\fi |
| 1500 |
\fi |
| 1501 |
{% |
| 1502 |
^^A\ifx#2\@clsextension |
| 1503 |
^^A \expandafter\ClassInfo |
| 1504 |
^^A\else |
| 1505 |
^^A \expandafter\PackageInfo |
| 1506 |
^^A\fi |
| 1507 |
^^A{#1}{[option] #4=\KVO@param}% |
| 1508 |
\csname#3#4\KVO@param\endcsname |
| 1509 |
}% |
| 1510 |
} |
| 1511 |
% \end{macrocode} |
| 1512 |
% \end{macro} |
| 1513 |
% \begin{macro}{\KVO@true} |
| 1514 |
% \begin{macro}{\KVO@false} |
| 1515 |
% The macros \cs{KVO@true} and \cs{KVO@false} are used |
| 1516 |
% for string comparisons. After \cs{ltx@onelevel@sanitize} |
| 1517 |
% we have only tokens with catcode 12 (other). |
| 1518 |
% \begin{macrocode} |
| 1519 |
\def\KVO@true{true} |
| 1520 |
\def\KVO@false{false} |
| 1521 |
\ltx@onelevel@sanitize\KVO@true |
| 1522 |
\ltx@onelevel@sanitize\KVO@false |
| 1523 |
% \end{macrocode} |
| 1524 |
% \end{macro} |
| 1525 |
% \end{macro} |
| 1526 |
% |
| 1527 |
% \subsubsection{\cs{DeclareStringOption}} |
| 1528 |
% |
| 1529 |
% \begin{macro}{\DeclareStringOption} |
| 1530 |
% \begin{macrocode} |
| 1531 |
\newcommand*{\DeclareStringOption}[2][]{% |
| 1532 |
\@ifnextchar[{% |
| 1533 |
\KVO@DeclareStringOption{#1}{#2}@% |
| 1534 |
}{% |
| 1535 |
\KVO@DeclareStringOption{#1}{#2}{}[]% |
| 1536 |
}% |
| 1537 |
} |
| 1538 |
% \end{macrocode} |
| 1539 |
% \end{macro} |
| 1540 |
% \begin{macro}{\KVO@DeclareStringOption} |
| 1541 |
% \begin{macrocode} |
| 1542 |
\def\KVO@DeclareStringOption#1#2#3[#4]{% |
| 1543 |
\KVO@ifdefinable{\KVO@prefix#2}{% |
| 1544 |
\@namedef{\KVO@prefix#2}{#1}% |
| 1545 |
\begingroup |
| 1546 |
\ifx\\#3\\% |
| 1547 |
\toks@{}% |
| 1548 |
\else |
| 1549 |
\toks@{[{#4}]}% |
| 1550 |
\fi |
| 1551 |
\edef\x{\endgroup |
| 1552 |
\noexpand\define@key{\KVO@family}{#2}\the\toks@{% |
| 1553 |
^^A\begingroup |
| 1554 |
^^A \toks@{####1}% |
| 1555 |
^^A \ifx\@currext\@clsextension |
| 1556 |
^^A \noexpand\ClassInfo |
| 1557 |
^^A \else |
| 1558 |
^^A \noexpand\PackageInfo |
| 1559 |
^^A \fi |
| 1560 |
^^A {\@currname}{% |
| 1561 |
^^A [option] #2={\noexpand\the\toks@}% |
| 1562 |
^^A }% |
| 1563 |
^^A\endgroup |
| 1564 |
\noexpand\def |
| 1565 |
\expandafter\noexpand\csname\KVO@prefix#2\endcsname{####1}% |
| 1566 |
}% |
| 1567 |
}% |
| 1568 |
\x |
| 1569 |
}% |
| 1570 |
} |
| 1571 |
% \end{macrocode} |
| 1572 |
% \end{macro} |
| 1573 |
% |
| 1574 |
% \subsubsection{\cs{DeclareVoidOption}} |
| 1575 |
% |
| 1576 |
% \begin{macro}{\DeclareVoidOption} |
| 1577 |
% \begin{macrocode} |
| 1578 |
\newcommand*{\DeclareVoidOption}[2]{% |
| 1579 |
\begingroup |
| 1580 |
\let\next\@gobbletwo |
| 1581 |
\KVO@ifdefinable{\KVO@prefix#1}{% |
| 1582 |
\let\next\@firstofone |
| 1583 |
}% |
| 1584 |
\expandafter\endgroup |
| 1585 |
\next{% |
| 1586 |
\begingroup |
| 1587 |
\edef\x{\endgroup |
| 1588 |
\noexpand\define@key{\KVO@family}{#1}[\KVO@VOID@]{% |
| 1589 |
\noexpand\KVO@voidkey{\@currname}% |
| 1590 |
\ifx\@currext\@clsextension |
| 1591 |
\noexpand\@clsextension |
| 1592 |
\else |
| 1593 |
\noexpand\@pkgextension |
| 1594 |
\fi |
| 1595 |
{#1}% |
| 1596 |
{####1}% |
| 1597 |
\expandafter\noexpand\csname\KVO@prefix#1\endcsname |
| 1598 |
}% |
| 1599 |
}% |
| 1600 |
\x |
| 1601 |
\begingroup |
| 1602 |
\toks@{#2}% |
| 1603 |
\expandafter\endgroup |
| 1604 |
\expandafter\def |
| 1605 |
\csname\KVO@prefix#1\expandafter\endcsname |
| 1606 |
\expandafter{\the\toks@}% |
| 1607 |
}% |
| 1608 |
} |
| 1609 |
\def\KVO@VOID@{@VOID@} |
| 1610 |
% \end{macrocode} |
| 1611 |
% \end{macro} |
| 1612 |
% \begin{macro}{\KVO@voidkey} |
| 1613 |
% \begin{tabular}{@{}ll@{}} |
| 1614 |
% |#1|& package/class name\\ |
| 1615 |
% |#2|& |\@pkgextension|/|\@clsextension|\\ |
| 1616 |
% |#3|& key name\\ |
| 1617 |
% |#4|& default (|@VOID@|)\\ |
| 1618 |
% |#5|& macro with option code |
| 1619 |
% \end{tabular} |
| 1620 |
% \begin{macrocode} |
| 1621 |
\def\KVO@voidkey#1#2#3#4{% |
| 1622 |
\def\CurrentOption{#3}% |
| 1623 |
\begingroup |
| 1624 |
\def\x{#4}% |
| 1625 |
\expandafter\endgroup |
| 1626 |
\ifx\x\KVO@VOID@ |
| 1627 |
\else |
| 1628 |
\ifx#2\@clsextension |
| 1629 |
\expandafter\ClassWarning |
| 1630 |
\else |
| 1631 |
\expandafter\PackageWarning |
| 1632 |
\fi |
| 1633 |
{#1}{% |
| 1634 |
Unexpected value for option `#3'\MessageBreak |
| 1635 |
is ignored% |
| 1636 |
}% |
| 1637 |
\fi |
| 1638 |
^^A\ifx#2\@clsextension |
| 1639 |
^^A \expandafter\ClassInfo |
| 1640 |
^^A\else |
| 1641 |
^^A \expandafter\PackageInfo |
| 1642 |
^^A\fi |
| 1643 |
^^A{#1}{[option] #3}% |
| 1644 |
} |
| 1645 |
% \end{macrocode} |
| 1646 |
% \end{macro} |
| 1647 |
% |
| 1648 |
% \subsubsection{\cs{DeclareDefaultOption}} |
| 1649 |
% |
| 1650 |
% \begin{macro}{\DeclareDefaultOption} |
| 1651 |
% \begin{macrocode} |
| 1652 |
\newcommand*{\DeclareDefaultOption}{% |
| 1653 |
\@namedef{KVO@default@\@currname.\@currext}% |
| 1654 |
} |
| 1655 |
% \end{macrocode} |
| 1656 |
% \end{macro} |
| 1657 |
% |
| 1658 |
% \subsubsection{\cs{DeclareLocalOptions}} |
| 1659 |
% |
| 1660 |
% \begin{macro}{\DeclareLocalOptions} |
| 1661 |
% \begin{macrocode} |
| 1662 |
\newcommand*{\DeclareLocalOptions}[1]{% |
| 1663 |
\comma@parse{#1}\KVO@DeclareLocalOption |
| 1664 |
} |
| 1665 |
% \end{macrocode} |
| 1666 |
% \end{macro} |
| 1667 |
% \begin{macro}{\KVO@DeclareLocalOption} |
| 1668 |
% \begin{macrocode} |
| 1669 |
\def\KVO@DeclareLocalOption#1{% |
| 1670 |
\expandafter\def\csname KVO@local@\KVO@family @#1\endcsname{}% |
| 1671 |
} |
| 1672 |
% \end{macrocode} |
| 1673 |
% \end{macro} |
| 1674 |
% |
| 1675 |
% \subsection{Dynamic options} |
| 1676 |
% |
| 1677 |
% \subsubsection{\cs{DisableKeyvalOption}} |
| 1678 |
% |
| 1679 |
% \begin{macrocode} |
| 1680 |
\SetupKeyvalOptions{% |
| 1681 |
family=KVOdyn,% |
| 1682 |
prefix=KVOdyn@% |
| 1683 |
} |
| 1684 |
\DeclareBoolOption[true]{global} |
| 1685 |
\DeclareComplementaryOption{local}{global} |
| 1686 |
\DeclareStringOption[undef]{action} |
| 1687 |
\let\KVOdyn@name\relax |
| 1688 |
\let\KVOdyn@ext\@empty |
| 1689 |
\define@key{KVOdyn}{class}{% |
| 1690 |
\def\KVOdyn@name{#1}% |
| 1691 |
\let\KVOdyn@ext\@clsextension |
| 1692 |
} |
| 1693 |
\define@key{KVOdyn}{package}{% |
| 1694 |
\def\KVOdyn@name{#1}% |
| 1695 |
\let\KVOdyn@ext\@pkgextension |
| 1696 |
} |
| 1697 |
\newcommand*{\DisableKeyvalOption}[3][]{% |
| 1698 |
\begingroup |
| 1699 |
\kvsetkeys{KVOdyn}{#1}% |
| 1700 |
\def\x{\endgroup}% |
| 1701 |
\@ifundefined{KVO@action@\KVOdyn@action}{% |
| 1702 |
\PackageError{kvoptions}{% |
| 1703 |
Unknown disable action % |
| 1704 |
`\expandafter\strip@prefix\meaning\KVOdyn@action'\MessageBreak |
| 1705 |
for option `#3' in keyval family '#2'% |
| 1706 |
}\@ehc |
| 1707 |
}{% |
| 1708 |
\csname KVO@action@\KVOdyn@action\endcsname{#2}{#3}% |
| 1709 |
}% |
| 1710 |
\x |
| 1711 |
} |
| 1712 |
\def\KVO@action@undef#1#2{% |
| 1713 |
\edef\x{\endgroup |
| 1714 |
\ifKVOdyn@global\global\fi |
| 1715 |
\let |
| 1716 |
\expandafter\noexpand\csname KV@#1@#2\endcsname |
| 1717 |
\relax |
| 1718 |
\ifKVOdyn@global\global\fi |
| 1719 |
\let |
| 1720 |
\expandafter\noexpand\csname KV@#1@#2@default\endcsname |
| 1721 |
\relax |
| 1722 |
}% |
| 1723 |
^^A\PackageInfo{kvoptions}{% |
| 1724 |
^^A [option] key `#2' of family `#1'\MessageBreak |
| 1725 |
^^A is disabled (undef, \ifKVOdyn@global global\else local\fi)% |
| 1726 |
^^A}% |
| 1727 |
} |
| 1728 |
\def\KVO@action@ignore#1#2{% |
| 1729 |
\edef\x{\endgroup |
| 1730 |
\ifKVOdyn@global\global\fi |
| 1731 |
\let |
| 1732 |
\expandafter\noexpand\csname KV@#1@#2\endcsname |
| 1733 |
\noexpand\@gobble |
| 1734 |
\ifKVOdyn@global\global\fi |
| 1735 |
\let |
| 1736 |
\expandafter\noexpand\csname KV@#1@#2@default\endcsname |
| 1737 |
\noexpand\@empty |
| 1738 |
}% |
| 1739 |
^^A\PackageInfo{kvoptions}{% |
| 1740 |
^^A [option] key `#2' of family `#1'\MessageBreak |
| 1741 |
^^A is disabled (ignore, \ifKVOdyn@global global\else local\fi)% |
| 1742 |
^^A}% |
| 1743 |
} |
| 1744 |
\def\KVO@action@error{% |
| 1745 |
\KVO@do@action{error}% |
| 1746 |
} |
| 1747 |
\def\KVO@action@warning{% |
| 1748 |
\KVO@do@action{warning}% |
| 1749 |
} |
| 1750 |
% \end{macrocode} |
| 1751 |
% \begin{tabular}{@{}ll@{}} |
| 1752 |
% |#1|& |error| or |warning|\\ |
| 1753 |
% |#2|& \meta{family}\\ |
| 1754 |
% |#3|& \meta{key}\\ |
| 1755 |
% \end{tabular} |
| 1756 |
% \begin{macrocode} |
| 1757 |
\def\KVO@do@action#1#2#3{% |
| 1758 |
\ifx\KVOdyn@name\relax |
| 1759 |
\PackageError{kvoptions}{% |
| 1760 |
Action type `#1' needs package/class name\MessageBreak |
| 1761 |
for key `#3' in family `#2'% |
| 1762 |
}\@ehc |
| 1763 |
\else |
| 1764 |
\edef\x{\endgroup |
| 1765 |
\noexpand\define@key{#2}{#3}[]{% |
| 1766 |
\expandafter\noexpand\csname KVO@disable@#1\endcsname |
| 1767 |
{\KVOdyn@name}\noexpand\KVOdyn@ext{#3}% |
| 1768 |
}% |
| 1769 |
\ifKVOdyn@global |
| 1770 |
\global\let |
| 1771 |
\expandafter\noexpand\csname KV@#2@#3\endcsname |
| 1772 |
\expandafter\noexpand\csname KV@#2@#3\endcsname |
| 1773 |
\global\let |
| 1774 |
\expandafter\noexpand\csname KV@#2@#3@default\endcsname |
| 1775 |
\expandafter\noexpand\csname KV@#2@#3@default\endcsname |
| 1776 |
\fi |
| 1777 |
}% |
| 1778 |
^^A\ifx\KVOdyn@ext\@clsextension |
| 1779 |
^^A \expandafter\ClassInfo |
| 1780 |
^^A\else |
| 1781 |
^^A \expandafter\PackageInfo |
| 1782 |
^^A\fi |
| 1783 |
^^A{\KVOdyn@name}{% |
| 1784 |
^^A [option] key `#3' of family `#2'\MessageBreak |
| 1785 |
^^A is disabled (#1, \ifKVOdyn@global global\else local\fi)% |
| 1786 |
^^A}% |
| 1787 |
\fi |
| 1788 |
} |
| 1789 |
\def\KVO@disable@error#1#2#3{% |
| 1790 |
\ifx#2\@clsextension |
| 1791 |
\expandafter\ClassError |
| 1792 |
\else |
| 1793 |
\expandafter\PackageError |
| 1794 |
\fi |
| 1795 |
{#1}{% |
| 1796 |
Option `#3' is given too late,\MessageBreak |
| 1797 |
now the option is ignored% |
| 1798 |
}\@ehc |
| 1799 |
} |
| 1800 |
\def\KVO@disable@warning#1#2#3{% |
| 1801 |
\ifx#2\@clsextension |
| 1802 |
\expandafter\ClassWarning |
| 1803 |
\else |
| 1804 |
\expandafter\PackageWarning |
| 1805 |
\fi |
| 1806 |
{#1}{% |
| 1807 |
Option `#3' is already consumed\MessageBreak |
| 1808 |
and has no effect% |
| 1809 |
}% |
| 1810 |
} |
| 1811 |
% \end{macrocode} |
| 1812 |
% |
| 1813 |
% \subsection{Change option code} |
| 1814 |
% |
| 1815 |
% \subsubsection{\cs{AddToKeyvalOption}} |
| 1816 |
% |
| 1817 |
% \begin{macro}{\AddToKeyvalOption} |
| 1818 |
% \begin{macrocode} |
| 1819 |
\newcommand*{\AddToKeyvalOption}{% |
| 1820 |
\@ifstar{% |
| 1821 |
\begingroup |
| 1822 |
\edef\x{\endgroup |
| 1823 |
\noexpand\KVO@AddToKeyvalOption{\KVO@family}% |
| 1824 |
}% |
| 1825 |
\x |
| 1826 |
}% |
| 1827 |
\KVO@AddToKeyvalOption |
| 1828 |
} |
| 1829 |
% \end{macrocode} |
| 1830 |
% \end{macro} |
| 1831 |
% \begin{macro}{\KVO@AddToKeyvalOption} |
| 1832 |
% \begin{macrocode} |
| 1833 |
\def\KVO@AddToKeyvalOption#1#2{% |
| 1834 |
\@ifundefined{KV@#1@#2}{% |
| 1835 |
\PackageWarning{kvoptions}{% |
| 1836 |
Key `#2' of family `#1' does not exist.\MessageBreak |
| 1837 |
Ignoring \string\AddToKeyvalOption |
| 1838 |
}% |
| 1839 |
\@gobble |
| 1840 |
}{% |
| 1841 |
\edef\KVO@next{% |
| 1842 |
\noexpand\KVO@@AddToKeyvalOption |
| 1843 |
\expandafter\noexpand\csname KV@#1@#2\endcsname |
| 1844 |
}% |
| 1845 |
\afterassignment\KVO@next |
| 1846 |
\def\KVO@temp##1% |
| 1847 |
}% |
| 1848 |
} |
| 1849 |
% \end{macrocode} |
| 1850 |
% \end{macro} |
| 1851 |
% \begin{macro}{\KVO@@AddToKeyvalOption} |
| 1852 |
% \begin{macrocode} |
| 1853 |
\def\KVO@@AddToKeyvalOption#1{% |
| 1854 |
\begingroup |
| 1855 |
\toks@\expandafter{#1{##1}}% |
| 1856 |
\toks@\expandafter{\the\expandafter\toks@\KVO@temp{##1}}% |
| 1857 |
\edef\x{\endgroup |
| 1858 |
\noexpand\def\noexpand#1####1{\the\toks@}% |
| 1859 |
}% |
| 1860 |
\x |
| 1861 |
} |
| 1862 |
% \end{macrocode} |
| 1863 |
% \end{macro} |
| 1864 |
% |
| 1865 |
% \subsection{Process options} |
| 1866 |
% |
| 1867 |
% \subsubsection{Get global options} |
| 1868 |
% |
| 1869 |
% Package \xpackage{xkeyval} removes options with equal signs from |
| 1870 |
% the global options (\cs{@classoptionslist}). The effect is that |
| 1871 |
% other packages and classes will not see these global options anymore. |
| 1872 |
% A bug-report was answered that this behaviour is ``by design''. |
| 1873 |
% Thus I call it a design bug. Now getting the global options require |
| 1874 |
% an algorithm instead of a simple macro call. |
| 1875 |
% \begin{macrocode} |
| 1876 |
%</package> |
| 1877 |
%<*package|patch> |
| 1878 |
% \end{macrocode} |
| 1879 |
% \begin{macro}{\KVO@IfDefThen} |
| 1880 |
% Call |#2| if command |#1| is defined and not \cs{relax}. |
| 1881 |
% (Package \xpackage{kvoptions-patch} does not load |
| 1882 |
% package \xpackage{ltxcmds}.) |
| 1883 |
% \begin{macrocode} |
| 1884 |
\def\KVO@IfDefThen#1#2{% |
| 1885 |
\ifx#1\ltx@undefined |
| 1886 |
\else |
| 1887 |
\ifx#1\relax |
| 1888 |
\else |
| 1889 |
#2% |
| 1890 |
\fi |
| 1891 |
\fi |
| 1892 |
}% |
| 1893 |
% \end{macrocode} |
| 1894 |
% \end{macro} |
| 1895 |
% \begin{macro}{\KVO@GetClassOptionsList} |
| 1896 |
% \begin{macrocode} |
| 1897 |
\def\KVO@GetClassOptionsList{% |
| 1898 |
\let\KVO@classoptionslist\@classoptionslist |
| 1899 |
\KVO@IfDefThen\@classoptionslist{% |
| 1900 |
\KVO@IfDefThen\XKV@documentclass{% |
| 1901 |
\ifx\XKV@documentclass\ltx@empty |
| 1902 |
\else |
| 1903 |
\KVO@IfDefThen\XKV@classoptionslist{% |
| 1904 |
\ifx\XKV@classoptionslist\ltx@empty |
| 1905 |
\else |
| 1906 |
\let\KVO@classoptionslist\XKV@classoptionslist |
| 1907 |
\fi |
| 1908 |
}% |
| 1909 |
\fi |
| 1910 |
}% |
| 1911 |
}% |
| 1912 |
}% |
| 1913 |
% \end{macrocode} |
| 1914 |
% \end{macro} |
| 1915 |
% \begin{macrocode} |
| 1916 |
%</package|patch> |
| 1917 |
%<*package> |
| 1918 |
% \end{macrocode} |
| 1919 |
% |
| 1920 |
% \subsubsection{\cs{ProcessKeyvalOptions}} |
| 1921 |
% |
| 1922 |
% \begin{macro}{\ProcessKeyvalOptions} |
| 1923 |
% If the optional star is given, we get the family |
| 1924 |
% name and expand it for safety. |
| 1925 |
% \begin{macrocode} |
| 1926 |
\newcommand*{\ProcessKeyvalOptions}{% |
| 1927 |
\@ifstar{% |
| 1928 |
\begingroup |
| 1929 |
\edef\x{\endgroup |
| 1930 |
\noexpand\KVO@ProcessKeyvalOptions{\KVO@family}% |
| 1931 |
}% |
| 1932 |
\x |
| 1933 |
}% |
| 1934 |
\KVO@ProcessKeyvalOptions |
| 1935 |
} |
| 1936 |
% \end{macrocode} |
| 1937 |
% \end{macro} |
| 1938 |
% |
| 1939 |
% \begin{macrocode} |
| 1940 |
\def\KVO@ProcessKeyvalOptions#1{% |
| 1941 |
\let\@tempc\relax |
| 1942 |
\let\KVO@temp\@empty |
| 1943 |
% \end{macrocode} |
| 1944 |
% Add any global options that are known to KV to the start of |
| 1945 |
% the list being built in |\KVO@temp| and mark them used (by |
| 1946 |
% removing them from the unused option list). |
| 1947 |
% \begin{macrocode} |
| 1948 |
\ifx\@currext\@clsextension |
| 1949 |
\else |
| 1950 |
\KVO@GetClassOptionsList |
| 1951 |
\ifx\KVO@classoptionslist\relax |
| 1952 |
\else |
| 1953 |
\@for\KVO@CurrentOption:=\KVO@classoptionslist\do{% |
| 1954 |
\@ifundefined{KV@#1@\expandafter\KVO@getkey |
| 1955 |
\KVO@CurrentOption=\@nil}{% |
| 1956 |
}{% |
| 1957 |
\@ifundefined{KVO@local@#1@\expandafter\KVO@getkey |
| 1958 |
\KVO@CurrentOption=\@nil}{% |
| 1959 |
\ifx\KVO@Patch Y% |
| 1960 |
\edef\KVO@temp{% |
| 1961 |
\etex@unexpanded\expandafter{% |
| 1962 |
\KVO@temp |
| 1963 |
}% |
| 1964 |
,% |
| 1965 |
\etex@unexpanded\expandafter{% |
| 1966 |
\KVO@CurrentOption |
| 1967 |
}% |
| 1968 |
,% |
| 1969 |
}% |
| 1970 |
\ltx@onelevel@sanitize\KVO@CurrentOption |
| 1971 |
\else |
| 1972 |
\edef\KVO@temp{% |
| 1973 |
\KVO@temp |
| 1974 |
,% |
| 1975 |
\KVO@CurrentOption |
| 1976 |
,% |
| 1977 |
}% |
| 1978 |
\fi |
| 1979 |
\@expandtwoargs\@removeelement{\expandafter\@remove@eq@value\KVO@CurrentOption=\@nil}% |
| 1980 |
\@unusedoptionlist\@unusedoptionlist |
| 1981 |
}{}% |
| 1982 |
}% |
| 1983 |
}% |
| 1984 |
\fi |
| 1985 |
\fi |
| 1986 |
% \end{macrocode} |
| 1987 |
% Now stick the package options at the end of the list and wrap |
| 1988 |
% in a call to \cs{setkeys}. A class ignores unknown global |
| 1989 |
% options, we must remove them to prevent error messages |
| 1990 |
% from \cs{setkeys}. |
| 1991 |
% \begin{macrocode} |
| 1992 |
\begingroup |
| 1993 |
\toks\tw@{}% |
| 1994 |
\@ifundefined{opt@\@currname.\@currext}{% |
| 1995 |
\toks@\expandafter{\KVO@temp}% |
| 1996 |
}{% |
| 1997 |
\toks@\expandafter\expandafter\expandafter{% |
| 1998 |
\csname opt@\@currname.\@currext\endcsname |
| 1999 |
}% |
| 2000 |
\ifx\@currext\@clsextension |
| 2001 |
\edef\CurrentOption{\the\toks@}% |
| 2002 |
\toks@\expandafter{\KVO@temp}% |
| 2003 |
\@for\CurrentOption:=\CurrentOption\do{% |
| 2004 |
\@ifundefined{% |
| 2005 |
KV@#1@\expandafter\KVO@getkey\CurrentOption=\@nil |
| 2006 |
}{% |
| 2007 |
% \end{macrocode} |
| 2008 |
% A class puts not used options in the unused option list |
| 2009 |
% unless there is a default handler. |
| 2010 |
% \begin{macrocode} |
| 2011 |
\@ifundefined{KVO@default@\@currname.\@currext}{% |
| 2012 |
\ifx\KVO@Patch Y% |
| 2013 |
\ltx@onelevel@sanitize\CurrentOption |
| 2014 |
\fi |
| 2015 |
\ifx\@unusedoptionlist\@empty |
| 2016 |
\global\let\@unusedoptionlist\CurrentOption |
| 2017 |
\else |
| 2018 |
\expandafter\expandafter\expandafter\gdef |
| 2019 |
\expandafter\expandafter\expandafter\@unusedoptionlist |
| 2020 |
\expandafter\expandafter\expandafter{% |
| 2021 |
\expandafter\@unusedoptionlist |
| 2022 |
\expandafter,\CurrentOption |
| 2023 |
}% |
| 2024 |
\fi |
| 2025 |
}{% |
| 2026 |
\toks\tw@\expandafter{% |
| 2027 |
\the\toks\expandafter\tw@\expandafter,\CurrentOption |
| 2028 |
}% |
| 2029 |
}% |
| 2030 |
}{% |
| 2031 |
\toks@\expandafter{% |
| 2032 |
\the\expandafter\toks@\expandafter,\CurrentOption |
| 2033 |
}% |
| 2034 |
}% |
| 2035 |
}% |
| 2036 |
\else |
| 2037 |
% \end{macrocode} |
| 2038 |
% Without default action we pass all options to \cs{setkeys}. |
| 2039 |
% Otherwise we have to check which options are known. |
| 2040 |
% These are passed to \cs{setkeys}. For the others the default |
| 2041 |
% action is performed. |
| 2042 |
% \begin{macrocode} |
| 2043 |
\@ifundefined{KVO@default@\@currname.\@currext}{% |
| 2044 |
\toks@\expandafter\expandafter\expandafter{% |
| 2045 |
\expandafter\KVO@temp\the\toks@ |
| 2046 |
}% |
| 2047 |
}{% |
| 2048 |
\edef\CurrentOption{\the\toks@}% |
| 2049 |
\toks@\expandafter{\KVO@temp}% |
| 2050 |
\@for\CurrentOption:=\CurrentOption\do{% |
| 2051 |
\@ifundefined{% |
| 2052 |
KV@#1@\expandafter\KVO@getkey\CurrentOption=\@nil |
| 2053 |
}{% |
| 2054 |
\toks\tw@\expandafter{% |
| 2055 |
\the\toks\expandafter\tw@\expandafter,\CurrentOption |
| 2056 |
}% |
| 2057 |
}{% |
| 2058 |
\toks@\expandafter{% |
| 2059 |
\the\expandafter\toks@\expandafter,\CurrentOption |
| 2060 |
}% |
| 2061 |
}% |
| 2062 |
}% |
| 2063 |
}% |
| 2064 |
\fi |
| 2065 |
}% |
| 2066 |
\edef\KVO@temp{\endgroup |
| 2067 |
\noexpand\KVO@calldefault{\the\toks\tw@}% |
| 2068 |
\noexpand\KVO@setkeys{#1}{\the\toks@}% |
| 2069 |
}% |
| 2070 |
\KVO@temp |
| 2071 |
% \end{macrocode} |
| 2072 |
% Some cleanup of \cs{ProcessOptions}. |
| 2073 |
% \begin{macrocode} |
| 2074 |
\let\CurrentOption\@empty |
| 2075 |
\AtEndOfPackage{\let\@unprocessedoptions\relax}% |
| 2076 |
} |
| 2077 |
% \end{macrocode} |
| 2078 |
% |
| 2079 |
% \subsubsection{\cs{ProcessLocalKeyvalOptions}} |
| 2080 |
% |
| 2081 |
% \begin{macro}{\ProcessLocalKeyvalOptions} |
| 2082 |
% If the optional star is given, we get the family |
| 2083 |
% name and expand it for safety. |
| 2084 |
% \begin{macrocode} |
| 2085 |
\newcommand*{\ProcessLocalKeyvalOptions}{% |
| 2086 |
\@ifstar{% |
| 2087 |
\begingroup |
| 2088 |
\edef\x{\endgroup |
| 2089 |
\noexpand\KVO@ProcessLocalKeyvalOptions{\KVO@family}% |
| 2090 |
}% |
| 2091 |
\x |
| 2092 |
}% |
| 2093 |
\KVO@ProcessLocalKeyvalOptions |
| 2094 |
} |
| 2095 |
% \end{macrocode} |
| 2096 |
% \end{macro} |
| 2097 |
% |
| 2098 |
% \begin{macrocode} |
| 2099 |
\def\KVO@ProcessLocalKeyvalOptions#1{% |
| 2100 |
\let\@tempc\relax |
| 2101 |
\let\KVO@temp\@empty |
| 2102 |
% \end{macrocode} |
| 2103 |
% Check if \cs{ProcessLocalKeyvalOptions} is called inside |
| 2104 |
% a package. |
| 2105 |
% \begin{macrocode} |
| 2106 |
\ifx\@currext\@pkgextension |
| 2107 |
\else |
| 2108 |
\PackageError{kvoptions}{% |
| 2109 |
\string\ProcessLocalKeyvalOptions\space is intended for packages only% |
| 2110 |
}\@ehc |
| 2111 |
\fi |
| 2112 |
% \end{macrocode} |
| 2113 |
% The package options are put into toks register \cs{toks@}. |
| 2114 |
% \begin{macrocode} |
| 2115 |
\begingroup |
| 2116 |
\toks\tw@{}% |
| 2117 |
\@ifundefined{opt@\@currname.\@currext}{% |
| 2118 |
\toks@\expandafter{\KVO@temp}% |
| 2119 |
}{% |
| 2120 |
\toks@\expandafter\expandafter\expandafter{% |
| 2121 |
\csname opt@\@currname.\@currext\endcsname |
| 2122 |
}% |
| 2123 |
% \end{macrocode} |
| 2124 |
% Without default action we pass all options to \cs{setkeys}. |
| 2125 |
% Otherwise we have to check which options are known. |
| 2126 |
% These are passed to \cs{setkeys}. For the others the default |
| 2127 |
% action is performed. |
| 2128 |
% \begin{macrocode} |
| 2129 |
\@ifundefined{KVO@default@\@currname.\@currext}{% |
| 2130 |
\toks@\expandafter\expandafter\expandafter{% |
| 2131 |
\expandafter\KVO@temp\the\toks@ |
| 2132 |
}% |
| 2133 |
}{% |
| 2134 |
\edef\CurrentOption{\the\toks@}% |
| 2135 |
\toks@\expandafter{\KVO@temp}% |
| 2136 |
\@for\CurrentOption:=\CurrentOption\do{% |
| 2137 |
\@ifundefined{% |
| 2138 |
KV@#1@\expandafter\KVO@getkey\CurrentOption=\@nil |
| 2139 |
}{% |
| 2140 |
\toks\tw@\expandafter{% |
| 2141 |
\the\toks\expandafter\tw@\expandafter,\CurrentOption |
| 2142 |
}% |
| 2143 |
}{% |
| 2144 |
\toks@\expandafter{% |
| 2145 |
\the\expandafter\toks@\expandafter,\CurrentOption |
| 2146 |
}% |
| 2147 |
}% |
| 2148 |
}% |
| 2149 |
}% |
| 2150 |
}% |
| 2151 |
\edef\KVO@temp{\endgroup |
| 2152 |
\noexpand\KVO@calldefault{\the\toks\tw@}% |
| 2153 |
\noexpand\KVO@setkeys{#1}{\the\toks@}% |
| 2154 |
}% |
| 2155 |
\KVO@temp |
| 2156 |
% \end{macrocode} |
| 2157 |
% Some cleanup of \cs{ProcessOptions}. |
| 2158 |
% \begin{macrocode} |
| 2159 |
\let\CurrentOption\@empty |
| 2160 |
\AtEndOfPackage{\let\@unprocessedoptions\relax}% |
| 2161 |
} |
| 2162 |
% \end{macrocode} |
| 2163 |
% |
| 2164 |
% \subsubsection{Helper macros} |
| 2165 |
% |
| 2166 |
% \begin{macro}{\KVO@getkey} |
| 2167 |
% Extract the key part of a key=value pair. |
| 2168 |
% \begin{macrocode} |
| 2169 |
\def\KVO@getkey#1=#2\@nil{#1} |
| 2170 |
% \end{macrocode} |
| 2171 |
% \end{macro} |
| 2172 |
% |
| 2173 |
% \begin{macro}{\KVO@calldefault} |
| 2174 |
% \begin{macrocode} |
| 2175 |
\def\KVO@calldefault#1{% |
| 2176 |
\begingroup |
| 2177 |
\def\x{#1}% |
| 2178 |
\expandafter\endgroup |
| 2179 |
\ifx\x\@empty |
| 2180 |
\else |
| 2181 |
\@for\CurrentOption:=#1\do{% |
| 2182 |
\ifx\CurrentOption\@empty |
| 2183 |
\else |
| 2184 |
\expandafter\KVO@setcurrents\CurrentOption=\@nil |
| 2185 |
\@nameuse{KVO@default@\@currname.\@currext}% |
| 2186 |
\fi |
| 2187 |
}% |
| 2188 |
\fi |
| 2189 |
} |
| 2190 |
% \end{macrocode} |
| 2191 |
% \end{macro} |
| 2192 |
% \begin{macro}{\KVO@setcurrents} |
| 2193 |
% Extract the key part of a key=value pair. |
| 2194 |
% \begin{macrocode} |
| 2195 |
\def\KVO@setcurrents#1=#2\@nil{% |
| 2196 |
\def\CurrentOptionValue{#2}% |
| 2197 |
\ifx\CurrentOptionValue\@empty |
| 2198 |
\let\CurrentOptionKey\CurrentOption |
| 2199 |
\let\CurrentOptionValue\relax |
| 2200 |
\else |
| 2201 |
\edef\CurrentOptionKey{\zap@space#1 \@empty}% |
| 2202 |
\expandafter\KVO@setcurrentvalue\CurrentOption\@nil |
| 2203 |
\fi |
| 2204 |
} |
| 2205 |
% \end{macrocode} |
| 2206 |
% \end{macro} |
| 2207 |
% \begin{macro}{\KV@setcurrentvalue} |
| 2208 |
% Here the value part is parsed. Package \xpackage{keyval}'s |
| 2209 |
% \cs{KV@@sp@def} helps in removing spaces at the begin and |
| 2210 |
% end of the value. |
| 2211 |
% \begin{macrocode} |
| 2212 |
\def\KVO@setcurrentvalue#1=#2\@nil{% |
| 2213 |
\KV@@sp@def\CurrentOptionValue{#2}% |
| 2214 |
} |
| 2215 |
% \end{macrocode} |
| 2216 |
% \end{macro} |
| 2217 |
% |
| 2218 |
% \subsection{\plainTeX} |
| 2219 |
% |
| 2220 |
% Disable \LaTeX\ stuff. |
| 2221 |
% \begin{macrocode} |
| 2222 |
\begingroup\expandafter\expandafter\expandafter\endgroup |
| 2223 |
\expandafter\ifx\csname documentclass\endcsname\relax |
| 2224 |
\def\ProcessKeyvalOptions{% |
| 2225 |
\@ifstar{}\@gobble |
| 2226 |
}% |
| 2227 |
\fi |
| 2228 |
% \end{macrocode} |
| 2229 |
% |
| 2230 |
% \begin{macrocode} |
| 2231 |
\KVO@AtEnd% |
| 2232 |
%</package> |
| 2233 |
% \end{macrocode} |
| 2234 |
% |
| 2235 |
% \subsection{Package \xpackage{kvoptions-patch}} |
| 2236 |
% |
| 2237 |
% \begin{macrocode} |
| 2238 |
%<*patch> |
| 2239 |
\NeedsTeXFormat{LaTeX2e} |
| 2240 |
\begingroup\catcode61\catcode48\catcode32=10\relax% |
| 2241 |
\catcode13=5 % ^^M |
| 2242 |
\endlinechar=13 % |
| 2243 |
\catcode123=1 % { |
| 2244 |
\catcode125=2 % } |
| 2245 |
\catcode64=11 % @ |
| 2246 |
\def\x{\endgroup |
| 2247 |
\expandafter\edef\csname KVO@AtEnd\endcsname{% |
| 2248 |
\endlinechar=\the\endlinechar\relax |
| 2249 |
\catcode13=\the\catcode13\relax |
| 2250 |
\catcode32=\the\catcode32\relax |
| 2251 |
\catcode35=\the\catcode35\relax |
| 2252 |
\catcode61=\the\catcode61\relax |
| 2253 |
\catcode64=\the\catcode64\relax |
| 2254 |
\catcode123=\the\catcode123\relax |
| 2255 |
\catcode125=\the\catcode125\relax |
| 2256 |
}% |
| 2257 |
}% |
| 2258 |
\x\catcode61\catcode48\catcode32=10\relax% |
| 2259 |
\catcode13=5 % ^^M |
| 2260 |
\endlinechar=13 % |
| 2261 |
\catcode35=6 % # |
| 2262 |
\catcode64=11 % @ |
| 2263 |
\catcode123=1 % { |
| 2264 |
\catcode125=2 % } |
| 2265 |
\def\TMP@EnsureCode#1#2{% |
| 2266 |
\edef\KVO@AtEnd{% |
| 2267 |
\KVO@AtEnd |
| 2268 |
\catcode#1=\the\catcode#1\relax |
| 2269 |
}% |
| 2270 |
\catcode#1=#2\relax |
| 2271 |
} |
| 2272 |
\TMP@EnsureCode{39}{12}% ' |
| 2273 |
\TMP@EnsureCode{40}{12}% ( |
| 2274 |
\TMP@EnsureCode{41}{12}% ) |
| 2275 |
\TMP@EnsureCode{43}{12}% + |
| 2276 |
\TMP@EnsureCode{44}{12}% , |
| 2277 |
\TMP@EnsureCode{45}{12}% - |
| 2278 |
\TMP@EnsureCode{46}{12}% . |
| 2279 |
\TMP@EnsureCode{47}{12}% / |
| 2280 |
\TMP@EnsureCode{58}{12}% : |
| 2281 |
\TMP@EnsureCode{60}{12}% < |
| 2282 |
\TMP@EnsureCode{62}{12}% > |
| 2283 |
\TMP@EnsureCode{91}{12}% [ |
| 2284 |
\TMP@EnsureCode{93}{12}% ] |
| 2285 |
\TMP@EnsureCode{96}{12}% ` |
| 2286 |
\TMP@EnsureCode{124}{12}% | |
| 2287 |
\edef\KVO@AtEnd{\KVO@AtEnd\noexpand\endinput} |
| 2288 |
\ProvidesPackage{kvoptions-patch}% |
| 2289 |
[2022-06-15 v3.15 LaTeX patch for keyval options (HO)]% |
| 2290 |
% \end{macrocode} |
| 2291 |
% |
| 2292 |
% Check for \eTeX. |
| 2293 |
% \begin{macrocode} |
| 2294 |
\begingroup\expandafter\expandafter\expandafter\endgroup |
| 2295 |
\expandafter\ifx\csname eTeXversion\endcsname\relax |
| 2296 |
\PackageWarningNoLine{kvoptions-patch}{% |
| 2297 |
Package loading is aborted, because e-TeX is missing% |
| 2298 |
}% |
| 2299 |
\expandafter\KVO@AtEnd |
| 2300 |
\fi% |
| 2301 |
% \end{macrocode} |
| 2302 |
% |
| 2303 |
% Package \xpackage{etexcmds} for \cs{etex@unexpanded}. |
| 2304 |
% \begin{macrocode} |
| 2305 |
\RequirePackage{etexcmds}[2007/09/09] |
| 2306 |
\ifetex@unexpanded |
| 2307 |
\else |
| 2308 |
\PackageError{kvoptions-patch}{% |
| 2309 |
Could not find eTeX's \string\unexpanded.\MessageBreak |
| 2310 |
Try adding \string\RequirePackage\string{etexcmds\string} % |
| 2311 |
before \string\documentclass% |
| 2312 |
}\@ehd |
| 2313 |
\expandafter\KVO@AtEnd |
| 2314 |
\fi% |
| 2315 |
% \end{macrocode} |
| 2316 |
% |
| 2317 |
% Check for package \xpackage{xkvltxp}. |
| 2318 |
% \begin{macrocode} |
| 2319 |
\@ifpackageloaded{xkvltxp}{% |
| 2320 |
\PackageWarningNoLine{kvoptions}{% |
| 2321 |
Option `patch' cannot be used together with\MessageBreak |
| 2322 |
package `xkvltxp' that is already loaded.\MessageBreak |
| 2323 |
Therefore package loading is aborted% |
| 2324 |
}% |
| 2325 |
\KVO@AtEnd |
| 2326 |
}{}% |
| 2327 |
% \end{macrocode} |
| 2328 |
% |
| 2329 |
% \begin{macrocode} |
| 2330 |
\def\@if@ptions#1#2#3{% |
| 2331 |
\begingroup |
| 2332 |
\KVO@normalize\KVO@temp{#3}% |
| 2333 |
\edef\x{\endgroup |
| 2334 |
\noexpand\@if@pti@ns{% |
| 2335 |
\detokenize\expandafter\expandafter\expandafter{% |
| 2336 |
\csname opt@#2.#1\endcsname |
| 2337 |
}% |
| 2338 |
}{% |
| 2339 |
\detokenize\expandafter{\KVO@temp}% |
| 2340 |
}% |
| 2341 |
}% |
| 2342 |
\x |
| 2343 |
} |
| 2344 |
% \end{macrocode} |
| 2345 |
% |
| 2346 |
% \begin{macrocode} |
| 2347 |
\def\@pass@ptions#1#2#3{% |
| 2348 |
\KVO@normalize\KVO@temp{#2}% |
| 2349 |
\@ifundefined{opt@#3.#1}{% |
| 2350 |
\expandafter\gdef\csname opt@#3.#1% |
| 2351 |
\expandafter\endcsname\expandafter{% |
| 2352 |
\KVO@temp |
| 2353 |
}% |
| 2354 |
}{% |
| 2355 |
\expandafter\gdef\csname opt@#3.#1% |
| 2356 |
\expandafter\expandafter\expandafter\endcsname |
| 2357 |
\expandafter\expandafter\expandafter{% |
| 2358 |
\csname opt@#3.#1\expandafter\endcsname\expandafter,\KVO@temp |
| 2359 |
}% |
| 2360 |
}% |
| 2361 |
} |
| 2362 |
% \end{macrocode} |
| 2363 |
% |
| 2364 |
% \begin{macrocode} |
| 2365 |
\def\ProcessOptions{% |
| 2366 |
\let\ds@\@empty |
| 2367 |
\@ifundefined{opt@\@currname.\@currext}{% |
| 2368 |
\let\@curroptions\@empty |
| 2369 |
}{% |
| 2370 |
\expandafter\expandafter\expandafter\def |
| 2371 |
\expandafter\expandafter\expandafter\@curroptions |
| 2372 |
\expandafter\expandafter\expandafter{% |
| 2373 |
\csname opt@\@currname.\@currext\endcsname |
| 2374 |
}% |
| 2375 |
}% |
| 2376 |
\@ifstar\KVO@xprocess@ptions\KVO@process@ptions |
| 2377 |
} |
| 2378 |
% \end{macrocode} |
| 2379 |
% |
| 2380 |
% \begin{macrocode} |
| 2381 |
\def\KVO@process@ptions{% |
| 2382 |
\@for\CurrentOption:=\@declaredoptions\do{% |
| 2383 |
\ifx\CurrentOption\@empty |
| 2384 |
\else |
| 2385 |
\begingroup |
| 2386 |
\ifx\@currext\@clsextension |
| 2387 |
\toks@{}% |
| 2388 |
\else |
| 2389 |
\KVO@GetClassOptionsList |
| 2390 |
\toks@\expandafter{\KVO@classoptionslist,}% |
| 2391 |
\fi |
| 2392 |
\toks\tw@\expandafter{\@curroptions}% |
| 2393 |
\edef\x{\endgroup |
| 2394 |
\noexpand\in@{,\CurrentOption,}{,\the\toks@\the\toks\tw@,}% |
| 2395 |
}% |
| 2396 |
\x |
| 2397 |
\ifin@ |
| 2398 |
\KVO@use@ption |
| 2399 |
\expandafter\let\csname ds@\CurrentOption\endcsname\@empty |
| 2400 |
\fi |
| 2401 |
\fi |
| 2402 |
}% |
| 2403 |
\KVO@process@pti@ns |
| 2404 |
} |
| 2405 |
% \end{macrocode} |
| 2406 |
% |
| 2407 |
% \begin{macrocode} |
| 2408 |
\def\KVO@xprocess@ptions{% |
| 2409 |
\ifx\@currext\@clsextension |
| 2410 |
\else |
| 2411 |
\KVO@GetClassOptionsList |
| 2412 |
\@for\CurrentOption:=\KVO@classoptionslist\do{% |
| 2413 |
\ifx\CurrentOption\@empty |
| 2414 |
\else |
| 2415 |
\KVO@in@\CurrentOption\@declaredoptions |
| 2416 |
\ifin@ |
| 2417 |
\KVO@use@ption |
| 2418 |
\expandafter\let\csname ds@\CurrentOption\endcsname\@empty |
| 2419 |
\fi |
| 2420 |
\fi |
| 2421 |
}% |
| 2422 |
\fi |
| 2423 |
\KVO@process@pti@ns |
| 2424 |
} |
| 2425 |
% \end{macrocode} |
| 2426 |
% |
| 2427 |
% \begin{macrocode} |
| 2428 |
\def\KVO@in@#1#2{% |
| 2429 |
\in@false |
| 2430 |
\begingroup |
| 2431 |
\@for\x:=#2\do{% |
| 2432 |
\ifx\x#1\relax |
| 2433 |
\in@true |
| 2434 |
\fi |
| 2435 |
}% |
| 2436 |
\edef\x{\endgroup |
| 2437 |
\ifin@ |
| 2438 |
\noexpand\in@true |
| 2439 |
\fi |
| 2440 |
}% |
| 2441 |
\x |
| 2442 |
} |
| 2443 |
% \end{macrocode} |
| 2444 |
% |
| 2445 |
% \begin{macrocode} |
| 2446 |
\def\KVO@process@pti@ns{% |
| 2447 |
\@for\CurrentOption:=\@curroptions\do{% |
| 2448 |
\@ifundefined{ds@\KVO@SanitizedCurrentOption}{% |
| 2449 |
\KVO@use@ption |
| 2450 |
\default@ds |
| 2451 |
}% |
| 2452 |
\KVO@use@ption |
| 2453 |
}% |
| 2454 |
\@for\CurrentOption:=\@declaredoptions\do{% |
| 2455 |
\expandafter\let\csname ds@\CurrentOption\endcsname\relax |
| 2456 |
}% |
| 2457 |
\let\CurrentOption\@empty |
| 2458 |
\let\@fileswith@pti@ns\@@fileswith@pti@ns |
| 2459 |
\AtEndOfPackage{\let\@unprocessedoptions\relax}% |
| 2460 |
} |
| 2461 |
% \end{macrocode} |
| 2462 |
% |
| 2463 |
% \begin{macrocode} |
| 2464 |
\def\KVO@use@ption{% |
| 2465 |
\begingroup |
| 2466 |
\edef\x{\endgroup |
| 2467 |
\noexpand\@removeelement{% |
| 2468 |
\detokenize\expandafter{\CurrentOption}% |
| 2469 |
}{% |
| 2470 |
\detokenize\expandafter{\@unusedoptionlist}% |
| 2471 |
}% |
| 2472 |
}% |
| 2473 |
\x\@unusedoptionlist |
| 2474 |
\csname ds@\KVO@SanitizedCurrentOption\endcsname |
| 2475 |
} |
| 2476 |
% \end{macrocode} |
| 2477 |
% |
| 2478 |
% \begin{macrocode} |
| 2479 |
\def\OptionNotUsed{% |
| 2480 |
\ifx\@currext\@clsextension |
| 2481 |
\xdef\@unusedoptionlist{% |
| 2482 |
\ifx\@unusedoptionlist\@empty |
| 2483 |
\else |
| 2484 |
\detokenize\expandafter{\@unusedoptionlist,}% |
| 2485 |
\fi |
| 2486 |
\detokenize\expandafter{\CurrentOption}% |
| 2487 |
}% |
| 2488 |
\fi |
| 2489 |
} |
| 2490 |
% \end{macrocode} |
| 2491 |
% |
| 2492 |
% Variant of \cs{ExecuteOptions} that better protects \cs{CurrentOption}. |
| 2493 |
% \begin{macrocode} |
| 2494 |
\def\CurrentOption@SaveLevel{0} |
| 2495 |
\def\ExecuteOptions{% |
| 2496 |
\expandafter\KVO@ExecuteOptions |
| 2497 |
\csname CurrentOption@\CurrentOption@SaveLevel\endcsname |
| 2498 |
} |
| 2499 |
\def\KVO@ExecuteOptions#1#2{% |
| 2500 |
\let#1\CurrentOption |
| 2501 |
\edef\CurrentOption@SaveLevel{% |
| 2502 |
\the\numexpr\CurrentOption@SaveLevel+1% |
| 2503 |
}% |
| 2504 |
\@for\CurrentOption:=#2\do{% |
| 2505 |
\csname ds@\CurrentOption\endcsname |
| 2506 |
}% |
| 2507 |
\edef\CurrentOption@SaveLevel{% |
| 2508 |
\the\numexpr\CurrentOption@SaveLevel-1% |
| 2509 |
}% |
| 2510 |
\let\CurrentOption#1% |
| 2511 |
} |
| 2512 |
% \end{macrocode} |
| 2513 |
% |
| 2514 |
% \begin{macrocode} |
| 2515 |
\def\KVO@fileswith@pti@ns#1[#2]#3[#4]{% |
| 2516 |
\ifx#1\@clsextension |
| 2517 |
\ifx\@classoptionslist\relax |
| 2518 |
\KVO@normalize\KVO@temp{#2}% |
| 2519 |
\expandafter\gdef\expandafter\@classoptionslist\expandafter{% |
| 2520 |
\KVO@temp |
| 2521 |
}% |
| 2522 |
\def\reserved@a{% |
| 2523 |
\KVO@onefilewithoptions{#3}[{#2}][{#4}]#1% |
| 2524 |
\@documentclasshook |
| 2525 |
}% |
| 2526 |
\else |
| 2527 |
\def\reserved@a{% |
| 2528 |
\KVO@onefilewithoptions{#3}[{#2}][{#4}]#1% |
| 2529 |
}% |
| 2530 |
\fi |
| 2531 |
\else |
| 2532 |
\begingroup |
| 2533 |
\let\KVO@temp\relax |
| 2534 |
\let\KVO@onefilewithoptions\relax |
| 2535 |
\let\@pkgextension\relax |
| 2536 |
\def\reserved@b##1,{% |
| 2537 |
\ifx\@nil##1\relax |
| 2538 |
\else |
| 2539 |
\ifx\relax##1\relax |
| 2540 |
\else |
| 2541 |
\KVO@onefilewithoptions{##1}[{\KVO@temp}][{#4}]% |
| 2542 |
\@pkgextension |
| 2543 |
\fi |
| 2544 |
\expandafter\reserved@b |
| 2545 |
\fi |
| 2546 |
}% |
| 2547 |
\edef\reserved@a{\zap@space#3 \@empty}% |
| 2548 |
\edef\reserved@a{\expandafter\reserved@b\reserved@a,\@nil,}% |
| 2549 |
\toks@{#2}% |
| 2550 |
\def\KVO@temp{\the\toks@}% |
| 2551 |
\edef\reserved@a{\endgroup \reserved@a}% |
| 2552 |
\fi |
| 2553 |
\reserved@a |
| 2554 |
} |
| 2555 |
% \end{macrocode} |
| 2556 |
% |
| 2557 |
% \begin{macrocode} |
| 2558 |
\def\KVO@onefilewithoptions#1[#2][#3]#4{% |
| 2559 |
\@pushfilename |
| 2560 |
\xdef\@currname{#1}% |
| 2561 |
\global\let\@currext#4% |
| 2562 |
\expandafter\let\csname\@currname.\@currext-h@@k\endcsname\@empty |
| 2563 |
\let\CurrentOption\@empty |
| 2564 |
\@reset@ptions |
| 2565 |
\makeatletter |
| 2566 |
\def\reserved@a{% |
| 2567 |
\@ifl@aded\@currext{#1}{% |
| 2568 |
\@if@ptions\@currext{#1}{#2}{% |
| 2569 |
}{% |
| 2570 |
\begingroup |
| 2571 |
\@ifundefined{opt@#1.\@currext}{% |
| 2572 |
\def\x{}% |
| 2573 |
}{% |
| 2574 |
\edef\x{% |
| 2575 |
\expandafter\expandafter\expandafter\strip@prefix |
| 2576 |
\expandafter\meaning\csname opt@#1.\@currext\endcsname |
| 2577 |
}% |
| 2578 |
}% |
| 2579 |
\def\y{#2}% |
| 2580 |
\edef\y{\expandafter\strip@prefix\meaning\y}% |
| 2581 |
\@latex@error{Option clash for \@cls@pkg\space #1}{% |
| 2582 |
The package #1 has already been loaded % |
| 2583 |
with options:\MessageBreak |
| 2584 |
\space\space[\x]\MessageBreak |
| 2585 |
There has now been an attempt to load it % |
| 2586 |
with options\MessageBreak |
| 2587 |
\space\space[\y]\MessageBreak |
| 2588 |
Adding the global options:\MessageBreak |
| 2589 |
\space\space |
| 2590 |
\x,\y\MessageBreak |
| 2591 |
to your \noexpand\documentclass declaration may fix this.% |
| 2592 |
\MessageBreak |
| 2593 |
Try typing \space <return> \space to proceed.% |
| 2594 |
}% |
| 2595 |
\endgroup |
| 2596 |
}% |
| 2597 |
}{% |
| 2598 |
\@pass@ptions\@currext{#2}{#1}% |
| 2599 |
\global\expandafter |
| 2600 |
\let\csname ver@\@currname.\@currext\endcsname\@empty |
| 2601 |
\InputIfFileExists |
| 2602 |
{\@currname.\@currext}% |
| 2603 |
{}% |
| 2604 |
{\@missingfileerror\@currname\@currext}% |
| 2605 |
\let\@unprocessedoptions\@@unprocessedoptions |
| 2606 |
\csname\@currname.\@currext-h@@k\endcsname |
| 2607 |
\expandafter\let\csname\@currname.\@currext-h@@k\endcsname |
| 2608 |
\@undefined |
| 2609 |
\@unprocessedoptions |
| 2610 |
}% |
| 2611 |
\@ifl@ter\@currext{#1}{#3}{% |
| 2612 |
}{% |
| 2613 |
\@latex@warning@no@line{% |
| 2614 |
You have requested,\on@line, % |
| 2615 |
version\MessageBreak |
| 2616 |
#3' of \@cls@pkg\space #1,\MessageBreak |
| 2617 |
but only version\MessageBreak |
| 2618 |
`\csname ver@#1.\@currext\endcsname'\MessageBreak |
| 2619 |
is available% |
| 2620 |
}% |
| 2621 |
}% |
| 2622 |
\ifx\@currext\@clsextension\let\LoadClass\@twoloadclasserror\fi |
| 2623 |
\@popfilename |
| 2624 |
\@reset@ptions |
| 2625 |
}% |
| 2626 |
\reserved@a |
| 2627 |
} |
| 2628 |
% \end{macrocode} |
| 2629 |
% |
| 2630 |
% \begin{macrocode} |
| 2631 |
\def\@unknownoptionerror{% |
| 2632 |
\@latex@error{% |
| 2633 |
Unknown option `\KVO@SanitizedCurrentOption' % |
| 2634 |
for \@cls@pkg\space`\@currname'% |
| 2635 |
}{% |
| 2636 |
The option `\KVO@SanitizedCurrentOption' was not declared in % |
| 2637 |
\@cls@pkg\space`\@currname', perhaps you\MessageBreak |
| 2638 |
misspelled its name. % |
| 2639 |
Try typing \space <return> % |
| 2640 |
\space to proceed.% |
| 2641 |
}% |
| 2642 |
} |
| 2643 |
% \end{macrocode} |
| 2644 |
% |
| 2645 |
% \begin{macrocode} |
| 2646 |
\def\@@unprocessedoptions{% |
| 2647 |
\ifx\@currext\@pkgextension |
| 2648 |
\@ifundefined{opt@\@currname.\@currext}{% |
| 2649 |
\let\@curroptions\@empty |
| 2650 |
}{% |
| 2651 |
\expandafter\let\expandafter\@curroptions |
| 2652 |
\csname opt@\@currname.\@currext\endcsname |
| 2653 |
}% |
| 2654 |
\@for\CurrentOption:=\@curroptions\do{% |
| 2655 |
\ifx\CurrentOption\@empty\else\@unknownoptionerror\fi |
| 2656 |
}% |
| 2657 |
\fi |
| 2658 |
} |
| 2659 |
% \end{macrocode} |
| 2660 |
% |
| 2661 |
% \begin{macrocode} |
| 2662 |
\def\KVO@SanitizedCurrentOption{% |
| 2663 |
\expandafter\strip@prefix\meaning\CurrentOption |
| 2664 |
} |
| 2665 |
% \end{macrocode} |
| 2666 |
% |
| 2667 |
% Normalize option list. |
| 2668 |
% \begin{macrocode} |
| 2669 |
\def\KVO@normalize#1#2{% |
| 2670 |
\let\KVO@result\@empty |
| 2671 |
\KVO@splitcomma#2,\@nil |
| 2672 |
\let#1\KVO@result |
| 2673 |
} |
| 2674 |
\def\KVO@splitcomma#1,#2\@nil{% |
| 2675 |
\KVO@ifempty{#1}{}{% |
| 2676 |
\KVO@checkkv#1=\@nil |
| 2677 |
}% |
| 2678 |
\KVO@ifempty{#2}{}{\KVO@splitcomma#2\@nil}% |
| 2679 |
} |
| 2680 |
\def\KVO@ifempty#1{% |
| 2681 |
\expandafter\ifx\expandafter\\\detokenize{#1}\\% |
| 2682 |
\expandafter\@firstoftwo |
| 2683 |
\else |
| 2684 |
\expandafter\@secondoftwo |
| 2685 |
\fi |
| 2686 |
} |
| 2687 |
\def\KVO@checkkv#1=#2\@nil{% |
| 2688 |
\KVO@ifempty{#2}{% |
| 2689 |
% option without value |
| 2690 |
\edef\KVO@x{\zap@space#1 \@empty}% |
| 2691 |
\ifx\KVO@x\@empty |
| 2692 |
% ignore empty option |
| 2693 |
\else |
| 2694 |
% append to list |
| 2695 |
\edef\KVO@result{% |
| 2696 |
\etex@unexpanded\expandafter{\KVO@result},\KVO@x |
| 2697 |
}% |
| 2698 |
\fi |
| 2699 |
}{% |
| 2700 |
% #1: "key", #2: "value=" |
| 2701 |
% add key part |
| 2702 |
\edef\KVO@result{% |
| 2703 |
\etex@unexpanded\expandafter{\KVO@result},% |
| 2704 |
\zap@space#1 \@empty |
| 2705 |
}% |
| 2706 |
\futurelet\@let@token\KVO@checkfirsttok#2 \@nil| = \@nil|\KVO@nil |
| 2707 |
}% |
| 2708 |
} |
| 2709 |
\def\KVO@checkfirsttok{% |
| 2710 |
\ifx\@let@token\bgroup |
| 2711 |
% no space at start |
| 2712 |
\expandafter\KVO@removelastspace\expandafter=% |
| 2713 |
% "<value><spaceopt>= \@nil" |
| 2714 |
\else |
| 2715 |
\expandafter\KVO@checkfirstA |
| 2716 |
\fi |
| 2717 |
} |
| 2718 |
\def\KVO@checkfirstA#1 #2\@nil{% |
| 2719 |
\KVO@ifempty{#2}{% |
| 2720 |
\KVO@removelastspace=#1 \@nil |
| 2721 |
}{% |
| 2722 |
\KVO@ifempty{#1}{% |
| 2723 |
\KVO@removelastspace=#2\@nil |
| 2724 |
}{% |
| 2725 |
\KVO@removelastspace=#1 #2\@nil |
| 2726 |
}% |
| 2727 |
}% |
| 2728 |
} |
| 2729 |
\def\KVO@removelastspace#1 = \@nil|#2\KVO@nil{% |
| 2730 |
\KVO@ifempty{#2}{% |
| 2731 |
\edef\KVO@result{% |
| 2732 |
\etex@unexpanded\expandafter{\KVO@result}% |
| 2733 |
\etex@unexpanded\expandafter{\KVO@removegarbage#1\KVO@nil}% |
| 2734 |
}% |
| 2735 |
}{% |
| 2736 |
\edef\KVO@result{% |
| 2737 |
\etex@unexpanded\expandafter{\KVO@result}% |
| 2738 |
\etex@unexpanded{#1}% |
| 2739 |
}% |
| 2740 |
}% |
| 2741 |
} |
| 2742 |
\def\KVO@removegarbage#1= \@nil#2\KVO@nil{#1}% |
| 2743 |
% \end{macrocode} |
| 2744 |
% |
| 2745 |
% Arguments |#1| and |#2| are macros. |
| 2746 |
% \begin{macrocode} |
| 2747 |
\def\KVO@removeelement#1#2{% |
| 2748 |
\begingroup |
| 2749 |
\toks@={}% |
| 2750 |
\@for\x:=#2\do{% |
| 2751 |
\ifx\x\@empty |
| 2752 |
\else |
| 2753 |
\ifx\x#1\relax |
| 2754 |
\else |
| 2755 |
\edef\t{\the\toks@}% |
| 2756 |
\ifx\t\@empty |
| 2757 |
\else |
| 2758 |
\toks@\expandafter{\the\toks@,}% |
| 2759 |
\fi |
| 2760 |
\toks@\expandafter{\the\expandafter\toks@\x}% |
| 2761 |
\fi |
| 2762 |
\fi |
| 2763 |
}% |
| 2764 |
\edef\x{\endgroup |
| 2765 |
\def\noexpand#2{\the\toks@}% |
| 2766 |
}% |
| 2767 |
\x |
| 2768 |
} |
| 2769 |
% \end{macrocode} |
| 2770 |
% |
| 2771 |
% |
| 2772 |
% \begin{macrocode} |
| 2773 |
\let\@@fileswith@pti@ns\KVO@fileswith@pti@ns |
| 2774 |
\ifx\@fileswith@pti@ns\@badrequireerror |
| 2775 |
\else |
| 2776 |
\let\@fileswith@pti@ns\KVO@fileswith@pti@ns |
| 2777 |
\fi |
| 2778 |
% \end{macrocode} |
| 2779 |
% |
| 2780 |
% \begin{macro}{\KVO@Patch} |
| 2781 |
% \begin{macrocode} |
| 2782 |
\let\KVO@Patch=Y |
| 2783 |
% \end{macrocode} |
| 2784 |
% \end{macro} |
| 2785 |
% |
| 2786 |
% \begin{macrocode} |
| 2787 |
\KVO@AtEnd% |
| 2788 |
%</patch> |
| 2789 |
% \end{macrocode} |
| 2790 |
% \section{Installation} |
| 2791 |
% |
| 2792 |
% \subsection{Download} |
| 2793 |
% |
| 2794 |
% \paragraph{Package.} This package is available on |
| 2795 |
% CTAN\footnote{\CTANpkg{kvoptions}}: |
| 2796 |
% \begin{description} |
| 2797 |
% \item[\CTAN{macros/latex/contrib/kvoptions/kvoptions.dtx}] The source file. |
| 2798 |
% \item[\CTAN{macros/latex/contrib/kvoptions/kvoptions.pdf}] Documentation. |
| 2799 |
% \end{description} |
| 2800 |
% |
| 2801 |
% |
| 2802 |
% |
| 2803 |
% \subsection{Package installation} |
| 2804 |
% |
| 2805 |
% \paragraph{Unpacking.} The \xfile{.dtx} file is a self-extracting |
| 2806 |
% \docstrip\ archive. The files are extracted by running the |
| 2807 |
% \xfile{.dtx} through \plainTeX: |
| 2808 |
% \begin{quote} |
| 2809 |
% \verb|tex kvoptions.dtx| |
| 2810 |
% \end{quote} |
| 2811 |
% |
| 2812 |
% \paragraph{TDS.} Now the different files must be moved into |
| 2813 |
% the different directories in your installation TDS tree |
| 2814 |
% (also known as \xfile{texmf} tree): |
| 2815 |
% \begin{quote} |
| 2816 |
% \def\t{^^A |
| 2817 |
% \begin{tabular}{@{}>{\ttfamily}l@{ $\rightarrow$ }>{\ttfamily}l@{}} |
| 2818 |
% kvoptions.sty & tex/latex/kvoptions/kvoptions.sty\\ |
| 2819 |
% kvoptions-patch.sty & tex/latex/kvoptions/kvoptions-patch.sty\\ |
| 2820 |
% kvoptions.pdf & doc/latex/kvoptions/kvoptions.pdf\\ |
| 2821 |
% example-mycolorsetup.sty & doc/latex/kvoptions/example-mycolorsetup.sty\\ |
| 2822 |
% kvoptions.dtx & source/latex/kvoptions/kvoptions.dtx\\ |
| 2823 |
% \end{tabular}^^A |
| 2824 |
% }^^A |
| 2825 |
% \sbox0{\t}^^A |
| 2826 |
% \ifdim\wd0>\linewidth |
| 2827 |
% \begingroup |
| 2828 |
% \advance\linewidth by\leftmargin |
| 2829 |
% \advance\linewidth by\rightmargin |
| 2830 |
% \edef\x{\endgroup |
| 2831 |
% \def\noexpand\lw{\the\linewidth}^^A |
| 2832 |
% }\x |
| 2833 |
% \def\lwbox{^^A |
| 2834 |
% \leavevmode |
| 2835 |
% \hbox to \linewidth{^^A |
| 2836 |
% \kern-\leftmargin\relax |
| 2837 |
% \hss |
| 2838 |
% \usebox0 |
| 2839 |
% \hss |
| 2840 |
% \kern-\rightmargin\relax |
| 2841 |
% }^^A |
| 2842 |
% }^^A |
| 2843 |
% \ifdim\wd0>\lw |
| 2844 |
% \sbox0{\small\t}^^A |
| 2845 |
% \ifdim\wd0>\linewidth |
| 2846 |
% \ifdim\wd0>\lw |
| 2847 |
% \sbox0{\footnotesize\t}^^A |
| 2848 |
% \ifdim\wd0>\linewidth |
| 2849 |
% \ifdim\wd0>\lw |
| 2850 |
% \sbox0{\scriptsize\t}^^A |
| 2851 |
% \ifdim\wd0>\linewidth |
| 2852 |
% \ifdim\wd0>\lw |
| 2853 |
% \sbox0{\tiny\t}^^A |
| 2854 |
% \ifdim\wd0>\linewidth |
| 2855 |
% \lwbox |
| 2856 |
% \else |
| 2857 |
% \usebox0 |
| 2858 |
% \fi |
| 2859 |
% \else |
| 2860 |
% \lwbox |
| 2861 |
% \fi |
| 2862 |
% \else |
| 2863 |
% \usebox0 |
| 2864 |
% \fi |
| 2865 |
% \else |
| 2866 |
% \lwbox |
| 2867 |
% \fi |
| 2868 |
% \else |
| 2869 |
% \usebox0 |
| 2870 |
% \fi |
| 2871 |
% \else |
| 2872 |
% \lwbox |
| 2873 |
% \fi |
| 2874 |
% \else |
| 2875 |
% \usebox0 |
| 2876 |
% \fi |
| 2877 |
% \else |
| 2878 |
% \lwbox |
| 2879 |
% \fi |
| 2880 |
% \else |
| 2881 |
% \usebox0 |
| 2882 |
% \fi |
| 2883 |
% \end{quote} |
| 2884 |
% If you have a \xfile{docstrip.cfg} that configures and enables \docstrip's |
| 2885 |
% TDS installing feature, then some files can already be in the right |
| 2886 |
% place, see the documentation of \docstrip. |
| 2887 |
% |
| 2888 |
% \subsection{Refresh file name databases} |
| 2889 |
% |
| 2890 |
% If your \TeX~distribution |
| 2891 |
% (\TeX\,Live, \mikTeX, \dots) relies on file name databases, you must refresh |
| 2892 |
% these. For example, \TeX\,Live\ users run \verb|texhash| or |
| 2893 |
% \verb|mktexlsr|. |
| 2894 |
% |
| 2895 |
% \subsection{Some details for the interested} |
| 2896 |
% |
| 2897 |
% \paragraph{Unpacking with \LaTeX.} |
| 2898 |
% The \xfile{.dtx} chooses its action depending on the format: |
| 2899 |
% \begin{description} |
| 2900 |
% \item[\plainTeX:] Run \docstrip\ and extract the files. |
| 2901 |
% \item[\LaTeX:] Generate the documentation. |
| 2902 |
% \end{description} |
| 2903 |
% If you insist on using \LaTeX\ for \docstrip\ (really, |
| 2904 |
% \docstrip\ does not need \LaTeX), then inform the autodetect routine |
| 2905 |
% about your intention: |
| 2906 |
% \begin{quote} |
| 2907 |
% \verb|latex \let\install=y\input{kvoptions.dtx}| |
| 2908 |
% \end{quote} |
| 2909 |
% Do not forget to quote the argument according to the demands |
| 2910 |
% of your shell. |
| 2911 |
% |
| 2912 |
% \paragraph{Generating the documentation.} |
| 2913 |
% You can use both the \xfile{.dtx} or the \xfile{.drv} to generate |
| 2914 |
% the documentation. The process can be configured by the |
| 2915 |
% configuration file \xfile{ltxdoc.cfg}. For instance, put this |
| 2916 |
% line into this file, if you want to have A4 as paper format: |
| 2917 |
% \begin{quote} |
| 2918 |
% \verb|\PassOptionsToClass{a4paper}{article}| |
| 2919 |
% \end{quote} |
| 2920 |
% An example follows how to generate the |
| 2921 |
% documentation with pdf\LaTeX: |
| 2922 |
% \begin{quote} |
| 2923 |
%\begin{verbatim} |
| 2924 |
%pdflatex kvoptions.dtx |
| 2925 |
%makeindex -s gind.ist kvoptions.idx |
| 2926 |
%pdflatex kvoptions.dtx |
| 2927 |
%makeindex -s gind.ist kvoptions.idx |
| 2928 |
%pdflatex kvoptions.dtx |
| 2929 |
%\end{verbatim} |
| 2930 |
% \end{quote} |
| 2931 |
% |
| 2932 |
% \begin{thebibliography}{99} |
| 2933 |
% \bibitem{tb94wright} |
| 2934 |
% A guide to key-value methods, Joseph Wright, second draft for |
| 2935 |
% \href{https://www.tug.org/tugboat}{TUGBoat}, 2009-03-17. |
| 2936 |
% \url{https://www.texdev.net/uploads/2009/03/keyval.pdf} |
| 2937 |
% \bibpackage{ifthen}{David Carlisle}{2001/05/26} |
| 2938 |
% {\CTANpkg{ifthen}} |
| 2939 |
% \bibpackage{helvet}{Sebastian Rahtz, Walter Schmidt}{2004/01/26} |
| 2940 |
% {\CTANpkg{psfonts}} |
| 2941 |
% \bibpackage{hyperref}{Sebastian Rahtz, Heiko Oberdiek}{2006/02/12} |
| 2942 |
% {\CTANpkg{hyperref}} |
| 2943 |
% \bibpackage{keyval}{David Carlisle}{1999/03/16} |
| 2944 |
% {\CTANpkg{keyval}} |
| 2945 |
% \bibpackage{multicol}{Frank Mittelbach}{2004/02/14} |
| 2946 |
% {\CTANpkg{multicol}} |
| 2947 |
% \bibpackage{tabularx}{David Carlisle}{1999/01/07} |
| 2948 |
% {\CTANpkg{tabularx}} |
| 2949 |
% \bibpackage{tracefnt}{Frank Mittelbach, Rainer Sch\"opf}{1997/05/29} |
| 2950 |
% {\CTANpkg{latex-base}} |
| 2951 |
% \bibpackage{xkeyval}{Hendri Adriaens}{2005/05/07} |
| 2952 |
% {\CTANpkg{xkeyval}} |
| 2953 |
% \bibitem{clsguide} |
| 2954 |
% The \LaTeX3 Project, \textit{\LaTeXe\ for class and package writers}, |
| 2955 |
% 2003/12/09. |
| 2956 |
% \CTANpkg{clsguide} |
| 2957 |
% |
| 2958 |
% \end{thebibliography} |
| 2959 |
% |
| 2960 |
% \begin{History} |
| 2961 |
% \begin{Version}{0000/00/00 v0.0} |
| 2962 |
% \item |
| 2963 |
% Probably David Carlisle's code in \xpackage{hyperref} |
| 2964 |
% was the start. |
| 2965 |
% \end{Version} |
| 2966 |
% \begin{Version}{2004/02/22 v1.0} |
| 2967 |
% \item |
| 2968 |
% The first version was never published. It also |
| 2969 |
% has offered a patch to get rid of \LaTeX's option |
| 2970 |
% expansion. |
| 2971 |
% \end{Version} |
| 2972 |
% \begin{Version}{2006/02/16 v2.0} |
| 2973 |
% \item |
| 2974 |
% Now the package is redesigned with an easier |
| 2975 |
% user interface. |
| 2976 |
% \item |
| 2977 |
% \cs{ProcessKeyvalOptions} remains the central service, inherited |
| 2978 |
% from \xpackage{hyperref}'s \cs{ProcessOptionsWithKV}. |
| 2979 |
% Now the use inside classes is also supported. |
| 2980 |
% \item |
| 2981 |
% Provides help macros for boolean and simple string options. |
| 2982 |
% \item |
| 2983 |
% Fixes for the patch of \LaTeX{}. The patch is only enabled, |
| 2984 |
% if the user requests it. |
| 2985 |
% \end{Version} |
| 2986 |
% \begin{Version}{2006/02/20 v2.1} |
| 2987 |
% \item |
| 2988 |
% Unused option list is sanitized to prevent problems |
| 2989 |
% with other packages that uses own processing methods |
| 2990 |
% for key value options. Disadvantage: the unused global |
| 2991 |
% option detection is weakened. |
| 2992 |
% \item |
| 2993 |
% New option type by \cs{DeclareVoidOption} for options without |
| 2994 |
% value. |
| 2995 |
% \item |
| 2996 |
% Default rule by \cs{DeclareDefaultOption}. |
| 2997 |
% \item |
| 2998 |
% Dynamic options: \cs{DisableKeyvalOption}. |
| 2999 |
% \end{Version} |
| 3000 |
% \begin{Version}{2006/06/01 v2.2} |
| 3001 |
% \item |
| 3002 |
% Fixes for option \xoption{patch}. |
| 3003 |
% \end{Version} |
| 3004 |
% \begin{Version}{2006/08/17 v2.3} |
| 3005 |
% \item |
| 3006 |
% \cs{DeclareBooleanOption} renamed to \cs{DeclareBoolOption} |
| 3007 |
% to avoid a name clash with package \cs{ifoption}. |
| 3008 |
% \end{Version} |
| 3009 |
% \begin{Version}{2006/08/22 v2.4} |
| 3010 |
% \item |
| 3011 |
% Option \xoption{patch}: \cs{ExecuteOptions} does not |
| 3012 |
% change the meaning of macro \cs{CurrentOption} at all. |
| 3013 |
% \end{Version} |
| 3014 |
% \begin{Version}{2007/04/11 v2.5} |
| 3015 |
% \item |
| 3016 |
% Line ends sanitized. |
| 3017 |
% \end{Version} |
| 3018 |
% \begin{Version}{2007/05/06 v2.6} |
| 3019 |
% \item |
| 3020 |
% Uses package \xpackage{etexcmds}. |
| 3021 |
% \end{Version} |
| 3022 |
% \begin{Version}{2007/06/11 v2.7} |
| 3023 |
% \item |
| 3024 |
% The patch part fixes LaTeX bug latex/3965. |
| 3025 |
% \end{Version} |
| 3026 |
% \begin{Version}{2007/10/02 v2.8} |
| 3027 |
% \item |
| 3028 |
% Compatibility for \plainTeX\ added. |
| 3029 |
% \item |
| 3030 |
% Typos in documentation fixed (Axel Sommerfeldt). |
| 3031 |
% \end{Version} |
| 3032 |
% \begin{Version}{2007/10/11 v2.9} |
| 3033 |
% \item |
| 3034 |
% Bug fix for option \xoption{patch}. |
| 3035 |
% \end{Version} |
| 3036 |
% \begin{Version}{2007/10/18 v3.0} |
| 3037 |
% \item |
| 3038 |
% New package \xpackage{kvoptions-patch}. |
| 3039 |
% \end{Version} |
| 3040 |
% \begin{Version}{2009/04/10 v3.1} |
| 3041 |
% \item |
| 3042 |
% Space by line end removed in definition of internal macro. |
| 3043 |
% \end{Version} |
| 3044 |
% \begin{Version}{2009/07/17 v3.2} |
| 3045 |
% \item |
| 3046 |
% \cs{ProcessLocalKeyvalOptions} added. |
| 3047 |
% \item |
| 3048 |
% \cs{DisableKeyvalOption} with the \texttt{action=ignore} option |
| 3049 |
% fixed (Joseph Wright). |
| 3050 |
% \end{Version} |
| 3051 |
% \begin{Version}{2009/07/21 v3.3} |
| 3052 |
% \item |
| 3053 |
% \cs{DeclareLocalOption}, \cs{DeclareLocalOptions} added. |
| 3054 |
% \end{Version} |
| 3055 |
% \begin{Version}{2009/08/13 v3.4} |
| 3056 |
% \item |
| 3057 |
% Documentation addition: recommendation for Joseph Wright's |
| 3058 |
% review article. |
| 3059 |
% \item |
| 3060 |
% Documentation addition: local/global options. |
| 3061 |
% \end{Version} |
| 3062 |
% \begin{Version}{2009/12/04 v3.5} |
| 3063 |
% \item |
| 3064 |
% \cs{AddToKeyvalOption} added. |
| 3065 |
% \end{Version} |
| 3066 |
% \begin{Version}{2009/12/08 v3.6} |
| 3067 |
% \item |
| 3068 |
% Fix: If a default handler is configured, it is now also |
| 3069 |
% called for classes. |
| 3070 |
% \end{Version} |
| 3071 |
% \begin{Version}{2010/02/22 v3.7} |
| 3072 |
% \item |
| 3073 |
% Missing space in error message added. |
| 3074 |
% \end{Version} |
| 3075 |
% \begin{Version}{2010/07/23 v3.8} |
| 3076 |
% \item |
| 3077 |
% Documenation for package \xpackage{kvoptions-patch} improved. |
| 3078 |
% No code changes. |
| 3079 |
% \end{Version} |
| 3080 |
% \begin{Version}{2010/12/02 v3.9} |
| 3081 |
% \item |
| 3082 |
% Key \texttt{setkeys} added for \cs{SetupKeyvalOptions}. |
| 3083 |
% \end{Version} |
| 3084 |
% \begin{Version}{2010/12/23 v3.10} |
| 3085 |
% \item |
| 3086 |
% \cs{DeclareVoidOption} also parses the second parameter as |
| 3087 |
% \hologo{TeX} argument to improve compatibility with |
| 3088 |
% \cs{DeclareOption}. |
| 3089 |
% \end{Version} |
| 3090 |
% \begin{Version}{2011/06/30 v3.11} |
| 3091 |
% \item |
| 3092 |
% Fix because of design bug in package \xpackage{xkeyval} that |
| 3093 |
% removes global options with equal signs. |
| 3094 |
% \end{Version} |
| 3095 |
% \begin{Version}{2016/05/16 v3.12} |
| 3096 |
% \item |
| 3097 |
% Documentation updates. |
| 3098 |
% \end{Version} |
| 3099 |
% \begin{Version}{2019/11/29 v3.13} |
| 3100 |
% \item |
| 3101 |
% Documentation updates. |
| 3102 |
% \end{Version} |
| 3103 |
% \begin{Version}{2020-10-07 v3.14} |
| 3104 |
% \item \xpackage{kvoptions-patch} is not compatible with a |
| 3105 |
% \LaTeX\ 2020-10-01 or newer and so it will abort loading if it detects it. |
| 3106 |
% This fixes github issue \#5. |
| 3107 |
% \end{Version} |
| 3108 |
% \begin{Version}{2022-06-15 v3.15} |
| 3109 |
% \item Remove only the key from the \cs{@unusedoptionlist} |
| 3110 |
% \end{Version} |
| 3111 |
% \end{History} |
| 3112 |
% |
| 3113 |
% \PrintIndex |
| 3114 |
% |
| 3115 |
% \Finale |
| 3116 |
\endinput |