Debian Codegraph @

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

raw
1 % \iffalse meta-comment
2 %
3 % xkeyval package by Hendri Adriaens.
4 %
5 % Extract package files and examples and create documentation:
6 % latex xkeyval.dtx
7 % latex xkeyval.dtx
8 % bibtex xkeyval
9 % makeindex -s gglo.ist -o xkeyval.gls xkeyval.glo
10 % makeindex -s gind.ist -o xkeyval.ind xkeyval.idx
11 % latex xkeyval.dtx
12 % latex xkeyval.dtx
13 %
14 % To finish the installation you have to move the following
15 % files into a directory searched by TeX:
16 % xkeyval.tex
17 % keyval.tex
18 % xkvtxhdr.tex
19 % pst-xkey.tex
20 % xkvutils.tex
21 % Additional to these files, LaTeX should be able to locate
22 % the following files:
23 % xkeyval.sty
24 % xkvview.sty
25 % xkvltxp.sty
26 % pst-xkey.sty
27 %
28 %% ---------------------------------------
29 %% Copyright (C) 2004-2022 Hendri Adriaens
30 %% 2025 David Carlisle for latex-package-repositories
31 %% ---------------------------------------
32 %%
33 %% This work may be distributed and/or modified under the
34 %% conditions of the LaTeX Project Public License, either version 1.3
35 %% of this license or (at your option) any later version.
36 %% The latest version of this license is in
37 %% http://www.latex-project.org/lppl.txt
38 %% and version 1.3 or later is part of all distributions of LaTeX
39 %% version 2003/12/01 or later.
40 %%
41 %% This work has the LPPL maintenance status "maintained".
42 %%
43 %% This Current Maintainer of this work is Hendri Adriaens.
44 %%
45 %% This work consists of the file xkeyval.dtx and derived files
46 %% keyval.tex, xkvtxhdr.tex, xkeyval.sty, xkeyval.tex, xkvview.sty,
47 %% xkvltxp.sty, xkvutils.tex, pst-xkey.tex, pst-xkey.sty, xkveca.cls,
48 %% xkvecb.cls, xkvesa.sty, xkvesb.sty, xkvesc.sty, xkvex1.tex,
49 %% xkvex2.tex, xkvex3.tex and xkvex4.tex.
50 %%
51 %% The following files constitute the xkeyval bundle and must be
52 %% distributed as a whole: readme, xkeyval.pdf, keyval.tex,
53 %% pst-xkey.sty, pst-xkey.tex, xkeyval.sty, xkeyval.tex, xkvview.sty,
54 %% xkvltxp.sty, xkvtxhdr.tex, xkvutils.tex, pst-xkey.dtx and xkeyval.dtx.
55 %%
56 % \fi
57 %
58 % \iffalse
59 %<*batchfile>
60 \begingroup
61 \input docstrip
62 \keepsilent
63 \preamble
64 \endpreamble
65 \askforoverwritefalse
66 \generate{
67 \file{xkeyval.tex}{\from{xkeyval.dtx}{xkvtex}}
68 \file{xkeyval.sty}{\from{xkeyval.dtx}{xkvlatex}}
69 \file{xkvview.sty}{\from{xkeyval.dtx}{xkvview}}
70 \file{xkvltxp.sty}{\from{xkeyval.dtx}{xkvltxpatch}}
71 \file{keyval.tex}{\from{xkeyval.dtx}{xkvkeyval}}
72 \file{xkvtxhdr.tex}{\from{xkeyval.dtx}{xkvheader}}
73 \file{xkvutils.tex}{\from{xkeyval.dtx}{xkvutils}}
74 \file{pst-xkey.tex}{\from{xkeyval.dtx}{pxktex}}
75 \file{pst-xkey.sty}{\from{xkeyval.dtx}{pxklatex}}
76 \file{xkvex1.tex}{\from{xkeyval.dtx}{xkvex1}}
77 \file{xkvex2.tex}{\from{xkeyval.dtx}{xkvex2}}
78 \file{xkvex3.tex}{\from{xkeyval.dtx}{xkvex3}}
79 \file{xkvex4.tex}{\from{xkeyval.dtx}{xkvex4}}
80 \file{xkveca.cls}{\from{xkeyval.dtx}{xkveca}}
81 \file{xkvecb.cls}{\from{xkeyval.dtx}{xkvecb}}
82 \file{xkvesa.sty}{\from{xkeyval.dtx}{xkvesa}}
83 \file{xkvesb.sty}{\from{xkeyval.dtx}{xkvesb}}
84 \file{xkvesc.sty}{\from{xkeyval.dtx}{xkvesc}}
85 \file{xkvpream.ble}{\from{xkeyval.dtx}{preamble}}
86 \file{xkeyval.bib}{\from{xkeyval.dtx}{bib}}
87 }
88 \endgroup
89 %</batchfile>
90 %<*driver>
91 \documentclass[a4paper]{ltxdoc}
92 \input{xkvpream.ble}
93 \begin{document}
94 \DocInput{xkeyval.dtx}
95 \let\Section\section\def\section*#1{\Section*{#1}\addcontentsline{toc}{section}{#1}}
96 \bibliographystyle{plain}
97 \bibliography{xkeyval}
98 \section*{Acknowledgements}
99 The author is grateful to Carsten Heinz, Morten H\o gholm,
100 Josselin Noirel, Heiko Oberdiek, Will Robertson, Till Tantau,
101 Herbert Vo\ss and Joseph Wright for help and suggestions.
102 Thanks go to Donald Arseneau for contributing the robust
103 |\@ifnextcharacter| macro, to Morten H\o gholm for
104 contributing a fast for-loop macro and to David Carlisle for
105 modifications to support |\par|. Special thanks go to Uwe
106 Kern for his ideas for improving the functionality of this
107 package, a lot of useful comments on the package and the
108 documentation and for contributing the |\@selective@sanitize|
109 macro. \PrintChangesX\PrintIndexX
110 \end{document}
111 %</driver>
112 % \fi
113 %
114 % \changes{v1.0}{2004/04/29}{Initial release}
115 % \changes{v1.2}{2004/05/08}{Change to \cs{DeclareOptionXf}; macro is
116 % now replaced}
117 % \changes{v1.3}{2004/05/09}{Revision of documentation}
118 % \changes{v1.4}{2004/08/24}{Made package \TeX\ compatible}
119 % \changes{v1.4}{2004/08/24}{Renamed macros to \pf{keyval} names}
120 % \changes{v1.4}{2004/08/24}{Changed package options}
121 % \changes{v1.5}{2004/09/27}{Corrected some minor bugs}
122 % \changes{v1.5}{2004/09/27}{Added \pf{pst-xkey}}
123 % \changes{v1.5}{2004/09/27}{Revised documentation}
124 % \changes{v1.5}{2004/09/27}{Added \cs{XKV@for}}
125 % \changes{v1.6}{2004/10/05}{Changed loading preventions}
126 % \changes{v1.6}{2004/10/05}{Corrected typos}
127 % \changes{v1.7}{2004/11/25}{Improved coding}
128 % \changes{v1.7}{2004/11/25}{Package uses \eTeX\ if available}
129 % \changes{v1.7}{2004/11/25}{Changed \LaTeX\ patch from \texttt{.tex}
130 % to \texttt{.sty}}
131 % \changes{v1.7}{2004/11/25}{Updated license information}
132 % \changes{v1.7}{2004/11/25}{Added system to control the scope of
133 % definitions to various macros}
134 % \changes{v1.8 }{2004/12/13}{Made package robust for catcode changes
135 % of equality character}
136 % \changes{v1.8 }{2004/12/13}{Fixed inconsistency of treatment of
137 % spaces in key and family names, all left untouched now}
138 % \changes{v1.8c}{2005/01/01}{Simplified and improved some code}
139 % \changes{v1.8d}{2005/01/02}{Restructured package to indicate general
140 % tools and their implementation}
141 % \changes{v1.8d}{2005/01/02}{Renamed \texttt{xkeyval.def} to
142 % \texttt{xkvtxhdr.tex}}
143 % \changes{v1.9}{2005/01/16}{Added \cs{delpresetkeys}}
144 % \changes{v1.9}{2005/01/16}{Added \cs{delsavekeys}}
145 % \changes{v1.9}{2005/01/16}{Updated license information}
146 % \changes{v2.0}{2005/01/30}{Made \cs{setkeys} nestable}
147 % \changes{v2.1}{2005/02/08}{Added `immediate' versions of several
148 % macros}
149 % \changes{v2.2}{2005/02/14}{Improved nesting mechanism}
150 % \changes{v2.2}{2005/02/14}{Added viewer utility}
151 % \changes{v2.3}{2005/02/22}{Updated viewer utility}
152 % \changes{v2.3}{2005/02/22}{Added choice keys}
153 % \changes{v2.3}{2005/02/22}{Increased efficiency of loops}
154 % \changes{v2.4}{2005/03/31}{Added nesting protection for conditionals}
155 % \changes{v2.4}{2005/03/31}{Changed \cs{define@boolkey} to have a key
156 % function}
157 % \changes{v2.4}{2005/03/31}{Extended boolean keys}
158 % \changes{v2.4}{2005/03/31}{Extended choice keys}
159 % \changes{v2.4}{2005/03/31}{Updated \pf{xkvview}}
160 % \changes{v2.4}{2005/03/31}{Added `default value' column to
161 % \pf{xkvview} tables}
162 % \changes{v2.4}{2005/03/31}{Revised documentation and examples}
163 % \changes{v2.4}{2005/03/31}{Removed command keys}
164 % \changes{v2.4}{2005/03/31}{Simplified some code}
165 % \changes{v2.4}{2005/03/31}{Inserted \pf{pst-xkey} in \pf{xkeyval}
166 % source}
167 % \changes{v2.5 }{2005/05/07}{Added \cs{define@boolkeys},
168 % \cs{define@cmdkey} and \cs{define@cmdkeys}}
169 % \changes{v2.5 }{2005/05/07}{Restructured documentation}
170 % \changes{v2.5 }{2005/05/07}{Updated \pf{xkvview}}
171 % \changes{v2.5 }{2005/05/07}{Solved small bug in \cs{setkeys} which
172 % allowed other families to take over save key or preset key settings
173 % if the key was defined in multiple families}
174 % \changes{v2.5 }{2005/05/07}{Simplified \cs{setkeys} internals}
175 % \changes{v2.5 }{2005/05/21}{Reimplemented \pf{xkvview} and added
176 % several options}
177 % \changes{v2.5 }{2005/05/21}{Added default value examples to docs}
178 % \changes{v2.5b}{2005/06/20}{Made retrieving document class more robust}
179 % \changes{v2.5d}{2005/08/12}{Added missing \cs{filename@area} in
180 % document class retrieval in \texttt{xkeyval.sty}}
181 % \changes{v2.5e}{2005/11/25}{Updated docs}
182 % \changes{v2.5g}{2006/12/19}{Altered policy for handling \cs{XKV@rm}
183 % in nested \cs{setkeys*} commands: all unknown keys will be recorded,
184 % not only the once from the outermost \cs{setkeys*}}
185 % \changes{v2.6c}{2014/04/27}{Added support for \cs{par} to support similar
186 % changes in \pf{keyval}}
187 % \changes{v2.6d}{2014/05/09}{Implemented fix conform fix in \pf{keyval}}
188 % \changes{v2.7}{2014/05/25}{Moved several utility macros to \pf{xkvutils}}
189 %
190 % \GetFileInfo{xkeyval.sty}
191 %
192 %
193 %\DoNotIndex{\:,\@,\@@,\@backslashchar,\@ehc,\@empty,\@expandtwoargs,
194 %\@for,\@forloop,\@fornoop,\@fortmp,\@gobble,\@gobbletwo,\@if,\@ifnch,
195 %\@ifnextchar,\@iforloop,\@ifundefined,\@let@token,
196 %\@namedef,\@nil,\@nnil,\@sptoken,\@temptokena,\@testopt,\@undefined,
197 %\@xifnch,\\,\afterassignment,\AtEndOfPackage,\begingroup,\bgroup,
198 %\catcode,\count@,\csname,\def,\do,\edef,\else,\endcsname,\endgroup,
199 %\endinput,\errmessage,\escapechar,\eTeXversion,\expandafter,\fi,
200 %\futurelet,\gdef,\global,\if,\ifcsname,\iffalse,\ifin@,\iftrue,\ifx,
201 %\in@,\in@@,\in@false,\in@true,\input,\kernel@ifnextchar,\let,\long,
202 %\lowercase,\m@ne,\meaning,\message,\NeedsTeXFormat,\newif,\newtoks,
203 %\noexpand,\protect,\ProvidesFile,\ProvidesPackage,\relax,\reserved@a,
204 %\reserved@b,\reserved@c,\reserved@d,\space,\string,\strip@prefix,\the,
205 %\toks@,\xdef,\XKV@header,\XKV@inpoxfalse,\XKV@inpoxtrue,\XKV@knffalse,
206 %\XKV@knftrue,\XKV@plfalse,\XKV@pltrue,\XKV@resa,\XKV@rkvfalse,
207 %\XKV@rkvtrue,\XKV@stfalse,\XKV@sttrue,\XKV@tempa,\XKV@tempb,\XKV@tempc,
208 %\XKV@tempd,\XKV@tfam,\XKV@tkey,\XKV@toks,\XKVcatcodes,\XKV@sgtrue,
209 %\zap@space,\@@cmd,\@@tok,\@i,\@ii,\@iii,\@iv,\=,\XKV@rgtrue,\XKV@rgfalse,
210 %\z@,\@ne,\m@ne,\count@,\advance,\ifnum,\,,\@M,\XKV@resb,\XKV@sgfalse,
211 %\newcount,\ttfamily,\textst,\texttt,\ifcase,\begin,\bfseries,\end,
212 %\hline,\multicolumn,\normalfont,\romannumeral,\emph,\endfirsthead,
213 %\endfoot,\endhead,\endlastfoot,\textsf,\addto@hook,\RequirePackage,
214 %\ifcat,\PSTXKeyCatcodes,\@addtofilelist,\XKV@presettrue,\XKV@presetfalse,
215 %\protected@edef,\closeout,\openout,\label,\newwrite,\protected@write,
216 %\XKVV@coliitrue,\XKVV@coliiitrue,\XKVV@colivtrue,\XKVV@colvtrue,
217 %\XKVV@coliifalse,\XKVV@coliiifalse,\XKVV@colivfalse,\XKVV@colvfalse,
218 %\XKVV@vwkeyfalse,\XKVV@vwkeytrue}
219 %
220 % \CharacterTable
221 % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
222 % Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
223 % Digits \0\1\2\3\4\5\6\7\8\9
224 % Exclamation \! Double quote \" Hash (number) \#
225 % Dollar \$ Percent \% Ampersand \&
226 % Acute accent \' Left paren \( Right paren \)
227 % Asterisk \* Plus \+ Comma \,
228 % Minus \- Point \. Solidus \/
229 % Colon \: Semicolon \; Less than \<
230 % Equals \= Greater than \> Question mark \?
231 % Commercial at \@ Left bracket \[ Backslash \\
232 % Right bracket \] Circumflex \^ Underscore \_
233 % Grave accent \` Left brace \{ Vertical bar \|
234 % Right brace \} Tilde \~}
235 %
236 %\title{\vspace*{-1cm}The \pf{xkeyval} package
237 %\thanks{This package can be downloaded from the CTAN mirrors:
238 %\texttt{/macros/latex/contrib/xkeyval}. See \texttt{xkeyval.dtx} for
239 %information on installing \pf{xkeyval} into your \TeX\ or \LaTeX\
240 %distribution and for the license of this package.\\
241 %\url{https://github.com/LaTeX-Package-Repositories/xkeyval/issues}}}
242 %\author{\mktitledecor Hendri Adriaens}
243 %\date{\fileversion\ (\filedate)}
244 %\maketitle
245 %
246 %\begin{abstract}\noindent
247 %This package is an extension of the \pf{keyval} package and offers
248 %more flexible macros for defining and setting keys. The package
249 %provides a pointer and a preset system. Furthermore, it supplies
250 %macros to allow class and package options to contain options of the
251 %|key=value| form. A \LaTeX\ kernel patch is provided to avoid
252 %premature expansions of macros in class or package options. A
253 %specialized system for setting \pf{PSTricks} keys is provided by
254 %the \pf{pst-xkey} package.
255 %\end{abstract}
256 %
257 %\begin{multicols}{2}
258 %[\section*{Contents}
259 %\setlength{\columnseprule}{.4pt}
260 %\setlength{\columnsep}{18pt}]
261 %\tableofcontents
262 %\end{multicols}
263 %
264 %\newpage
265 %\section{Introduction}\label{sec:intro}
266 %This package is an extension of the \pf{keyval} package by David Carlisle
267 %\cite{keyval} and offers more flexible and robust macros for defining and
268 %setting keys. Using keys in macro definition has the advantage that
269 %the 9 arguments maximum can easily be avoided and that it reduces
270 %confusion in the syntax of your macro when compared to using a lot
271 %of (optional) arguments. Compare for instance the following
272 %possible syntaxes of the macro |\mybox| which might for instance
273 %use its arguments to draw some box containing text.
274 %\begin{example}
275 % \mybox[5pt][20pt]{some text}[red][white][blue]
276 % \mybox[text=red,background=white,frame=blue,left=5pt,right=20pt]{some text}
277 %\end{example}
278 %Notice that, to be able to specify the frame color in the first
279 %example, the other colors need to be specified as well. This is not
280 %necessary in the second example and these colors can get preset
281 %values. The same thing holds for the margins.
282 %
283 %The idea is that one first defines a set of keys using the tools
284 %presented in section~\ref{sec:define} in the document preamble or in a
285 %package or class. These keys can perform a function with the user
286 %input. The way to submit user input to these key macros, is by using
287 %one of the user interfaces described in sections~\ref{sec:setkeys},
288 %\ref{sec:pointers} and~\ref{sec:preset}. The main user interface is
289 %provided by the |\setkeys| command. Using these interfaces, one can
290 %simplify macro syntax and for instance define the |\mybox| macro
291 %above as follows.
292 %\begin{example}
293 % \define@key{mybox}{left}{\setlength\myleft{#1}}
294 % \define@key{mybox}{background}{\def\background{#1}}
295 % % and some other keys
296 % \def\mybox{\@ifnextchar[\@mybox{\@mybox[]}}
297 % \def\@mybox[#1]#2{%
298 % \setkeys{mybox}{#1}%
299 % % some operations to typeset #2
300 % }
301 %\end{example}
302 %Notice that the combination of the two definitions |\mybox| and
303 %|\@mybox| can be replaced by |\newcommand\mybox[2][]{...}|
304 %when using \LaTeX.
305 %
306 %Both keys defined using the \pf{keyval} and \pf{xkeyval} can be set
307 %by this package. The \pf{xkeyval} macros allow for scanning multiple
308 %sets (called `families') of keys. This can, for instance, be used to
309 %create local families for macros and environments which may not
310 %access keys meant for other macros and environments, while at the
311 %same time, allowing the use of a single command to (pre)set all of
312 %the keys from the different families globally.
313 %
314 %The package is compatible to plain \TeX\ and redefines several
315 %\pf{keyval} macros to provide an easy way to switch between using
316 %\pf{keyval} and \pf{xkeyval}. This might be useful for package
317 %writers that cannot yet rely on the availability of \pf{xkeyval} in
318 %a certain distribution. After loading \pf{xkeyval}, loading
319 %\pf{keyval} is prevented to make sure that the extended macros of
320 %\pf{xkeyval} will not be redefined. Some internal \pf{keyval} macros
321 %are supplied in |keyval.tex| to guarantee compatibility to packages
322 %that use those macros. Section~\ref{sec:issues} provides more
323 %information about this issue.
324 %
325 %The organization of this documentation is as follows.
326 %Section~\ref{sec:loading} discusses how to load \pf{xkeyval} and
327 %what the package does when it is loaded. Section~\ref{sec:define}
328 %will discuss the macros available to define and manage keys.
329 %Section~\ref{sec:setkeys} will continue with describing the macros
330 %that can set the keys. Section~\ref{sec:pointers} explains special
331 %syntax which will allow saving and copying key values. In
332 %section~\ref{sec:preset}, the preset system will be introduced.
333 %Section~\ref{sec:catcodes} will explain how \pf{xkeyval} protects
334 %itself for catcode changes of the comma and the equality sign by
335 %other packages. The \pf{xkeyval} package also provides commands to
336 %declare and process class and package options that can take values.
337 %These will be discussed in section~\ref{sec:options}.
338 %Section~\ref{sec:macrostructs} provides an overview of structures
339 %used to create \pf{xkeyval} internal macros used for keys, values,
340 %presets, etcetera. Sections~\ref{sec:errors} and~\ref{sec:issues}
341 %discuss feedback that \pf{xkeyval} might give and known issues,
342 %respectively. Section~\ref{sec:additional} discusses several
343 %additional packages that come with the \pf{xkeyval} bundle.
344 %Section~\ref{sec:view} presents a viewer utility which produces
345 %overviews of defined keys. An extension of the \LaTeXe\ kernel with
346 %respect to the class and package options system is discussed in
347 %section~\ref{sec:macrooptions}. This extension provides a way to use
348 %expandable macros in package options. Section~\ref{sec:pst-xkey}
349 %presents the \pf{pst-xkey} package, which provides an options system
350 %based on \pf{xkeyval}, but which is specialized in setting
351 %\pf{PSTricks} keys.
352 %
353 %Throughout this documentation, you will find some examples with a
354 %short description. More examples can be found in the example files
355 %that come with this package. See section~\ref{sec:sande} for more
356 %information. This section also provides the information how to
357 %generate the full documentation from the source.
358 %
359 %\section{Loading \pf{xkeyval}}\label{sec:loading}
360 %To load the \pf{xkeyval} package,\footnote{The \pf{xkeyval} package
361 %consists of the files \texttt{xkeyval.tex}, \texttt{xkeyval.sty},
362 %\texttt{keyval.tex}, \texttt{xkvtxhdr.tex}.} plain \TeX\ users do
363 %|\input xkeyval|. \LaTeX\ users do one of the following:
364 %|\usepackage{xkeyval}| or |\RequirePackage{xkeyval}|. The package
365 %does not have options. It is mandatory for \LaTeX\ users to load
366 %\pf{xkeyval} at any point after the |\documentclass| command.
367 %Loading \pf{xkeyval} from the class which is the document class
368 %itself is possible. The package will use the \eTeX\ engine when
369 %available. In particular, |\ifcsname| is used whenever possible to
370 %avoid filling \TeX's hash tables with useless entries, for instance
371 %when searching for keys in families.
372 %
373 %If \pf{xkeyval} is loaded by |\RequirePackage| or |\usepackage|, the
374 %package performs two action immediately. These require
375 %\pf{xkeyval} to be loaded at any point after |\documentclass| or by
376 %the document class itself.
377 %
378 %First, it retrieves the document class of the document at hand and
379 %stores that (including the class extension) into the following macro.
380 %\begin{command}
381 % `\cs{XKV@documentclass}'
382 %\end{command}
383 %\DescribeMacro{\XKV@documentclass}
384 %This macro could, for instance, contain |article.cls| and can be useful
385 %when using |\ProcessOptionsX*| in a class. See
386 %page~\pageref{macro:poxstar}.
387 %
388 %Secondly, the global options submitted to the |\documentclass| command
389 %and stored by \LaTeX\ in |\@classoptionslist|
390 %are copied to the following macro.
391 %\begin{command}
392 % `\cs{XKV@classoptionslist}'
393 %\end{command}
394 %\DescribeMacro{\XKV@classoptionslist}
395 %This macro will be used by |\ProcessOptionsX|. Options containing
396 %an equality sign are deleted from the original list in
397 %|\@classoptionslist| to avoid packages, which do not use \pf{xkeyval}
398 %and which are loaded later, running into problems when trying to copy
399 %global options using \LaTeX's |\ProcessOptions|.
400 %
401 %\section{Defining and managing keys}\label{sec:define}
402 %\changes{v1.4}{2004/08/24}{Added prefix options to macros}
403 %\changes{v1.7}{2004/11/25}{Removed optional key checking from define macros}
404 %This section discusses macros to define keys and some tools to manage
405 %keys. A useful extension to \pf{xkeyval} is the \pf{xkvview} package.
406 %This packages defines commands to generate overviews of defined keys.
407 %See section~\ref{sec:view} for more information.
408 %
409 %\subsection{Ordinary keys}\label{sec:odefine}
410 %This section describes how to define ordinary keys.
411 %\begin{command}
412 % `\cs{define@key}\oarg{prefix}\marg{family}\marg{key}\oarg{default}\marg{function}'
413 %\end{command}
414 %\DescribeMacro{\define@key}
415 %This defines a macro of the form
416 %|\|\meta{prefix}|@|\meta{family}|@|\meta{key} with one argument
417 %holding \meta{function}. The default value for \meta{prefix} is
418 %|KV|. This is the standard throughout the package to simplify mixing
419 %\pf{keyval} and \pf{xkeyval} keys. When \meta{key} is used in a
420 %|\setkeys| command (see section~\ref{sec:setkeys}) containing
421 %|key=value|, the macro |\|\meta{prefix}|@|\meta{family}|@|\meta{key}
422 %receives |value| as its argument and will be executed. The argument
423 %can be accessed by \meta{function} by using |#1| inside the
424 %function.
425 %\begin{example}
426 % \define@key{family}{key}{The input is: #1}
427 %\end{example}
428 %\pf{xkeyval} will generate an error when the user omits |=value| for
429 %a key in the options list of |\setkeys| (see
430 %section~\ref{sec:setkeys}). To avoid this, the optional argument can
431 %be used to specify a default value.
432 %\begin{example}
433 % \define@key{family}{key}[none]{The input is: #1}
434 %\end{example}
435 %This will additionally define a macro
436 %|\|\meta{prefix}|@|\meta{family}|@|\meta{key}|@default| as a macro
437 %with no arguments and definition
438 %|\|\meta{prefix}|@|\meta{family}|@|\meta{key}|{none}| which will be
439 %used when |=value| is missing for |key| in the options list. So, the
440 %last example comes down to doing
441 %\begin{example}
442 % \def\KV@family@key#1{The input is: #1}
443 % \def\KV@family@key@default{\KV@family@key{none}}
444 %\end{example}
445 %
446 %When \meta{prefix} is specified and empty, the macros created by
447 %|\define@key| will have the form |\|\meta{family}|@|\meta{key}. When
448 %\meta{family} is empty, the resulting form will be
449 %|\|\meta{prefix}|@|\meta{key}. When both \meta{prefix} and
450 %\meta{family} are empty, the form is |\|\meta{key}. This combination
451 %of prefix and family will be called the header. The rules to create
452 %the header will be applied to all commands taking (optional) prefix
453 %and family arguments.
454 %
455 %The intended use for \meta{family} is to create distinct sets of
456 %keys. This can be used to avoid a macro setting keys meant for
457 %another macro only. The optional \meta{prefix} can be used to
458 %identify keys specifically for your package. Using a package
459 %specific prefix reduces the probability of multiple packages
460 %defining the same key macros. This optional argument can also be
461 %used to set keys of some existing packages which use a system based
462 %on \pf{keyval}.\footnote{Like \pf{PSTricks}, which uses a system
463 %originating from \pf{keyval}, but which has been modified to use no
464 %families and |psset| as prefix.}\label{page:pstricks}
465 %
466 %We now define some keys to be used in examples throughout this
467 %documentation.
468 %\begin{example}
469 % \define@key[my]{familya}{keya}[default]{#1}
470 % \define@key[my]{familya}{keyb}{#1}
471 % \define@key[my]{familyb}{keyb}{#1}
472 % \define@key[my]{familya}{keyc}{#1}
473 %\end{example}
474 %
475 %\subsection{Command keys}\label{sec:cdefine}
476 %Command keys are specialized keys that, before executing any code,
477 %save the user input to a macro.
478 %\begin{command}
479 % `\cs{define@cmdkey}\oarg{prefix}\marg{family}\oarg{mp}\marg{key}\oarg{default}\marg{function}'
480 %\end{command}
481 %\DescribeMacro{\define@cmdkey}
482 %This has the effect of defining a key macro of the form
483 %|\|\meta{prefix}|@|\meta{family}|@|\meta{key} that, when used, first
484 %saves the user input to a macro of the form |\|\meta{mp}\meta{key}
485 %and then executes \meta{function}. \meta{mp} is the macro prefix. If
486 %\meta{mp} is not specified, the usual combination of \meta{prefix}
487 %and \meta{family}, together with the extra prefix |cmd|, will be
488 %used to create the macro prefix, namely
489 %|\cmd|\meta{prefix}|@|\meta{family}|@|.\footnote{\label{foot:1}Remember
490 %that some rules are applied when creating the header, the
491 %combination of \meta{prefix} and \meta{header}. See
492 %section~\ref{sec:odefine}.} The two keys in the following example
493 %hence do exactly the same thing.\footnote{Notice however, that the
494 %first key will be listed as a `command key' by \pf{xkvview} and the
495 %second as an `ordinary key'. See section~\ref{sec:view}.}
496 %\begin{example}
497 % \define@cmdkey{fam}{key}[none]{value: \cmdKV@fam@key}
498 % \define@key{fam}{key}[none]{\def\cmdKV@fam@key{#1}value: \cmdKV@fam@key}
499 %\end{example}
500 %The value |none| is again the default value that will be submitted
501 %to the key macro when the user didn't supply a value. (See also
502 %section~\ref{sec:odefine} for more information.)
503 %
504 %The following two lines also implement a key with the same key macro.
505 %\begin{example}
506 % \define@cmdkey{fam}[my@]{key}[none]{value: \my@key}
507 % \define@key{fam}{key}[none]{\def\my@key{#1}value: \my@key}
508 %\end{example}
509 %Note that the key macro itself in the examples above is still
510 %|\KV@fam@key|, just as in the previous example.
511 %
512 %A lot of packages define keys that only save their value to a macro
513 %so that it can be used later. Using the macro above, one can save
514 %some tokens in the package. Some more tokens can be saved by using
515 %the following macro.
516 %\begin{command}
517 % `\cs{define@cmdkeys}\oarg{prefix}\marg{family}\oarg{mp}\marg{keys}\oarg{default}'
518 %\end{command}
519 %\DescribeMacro{\define@cmdkeys}
520 %This repeatedly calls (an internal of) |\define@cmdkey| for all keys
521 %in the list of \meta{keys}. Note that it is not possible to specify
522 %a custom key function for the keys created by this command. The only
523 %function of those keys is to save user input in a macro. The first
524 %line and the last two lines of the following example create keys
525 %with the same internal key macro.
526 %\begin{example}
527 % \define@cmdkeys{fam}[my@]{keya,keyb}[none]
528 % \define@key{fam}{keya}[none]{\def\my@keya{#1}}
529 % \define@key{fam}{keyb}[none]{\def\my@keyb{#1}}
530 %\end{example}
531 %
532 %\subsection{Choice keys}\label{sec:chdefine}
533 %Choice keys allow only a limited number of different values for user
534 %input. These keys are defined as follows.
535 %\begin{command}
536 % `\cs{define@choicekey}\oarg{pre}\marg{fam}\marg{key}\oarg{bin}\marg{al}\oarg{dft}\marg{func}'
537 % `\cs{define@choicekey*}\oarg{pre}\marg{fam}\marg{key}\oarg{bin}\marg{al}\oarg{dft}\marg{func}'
538 %\end{command}
539 %\DescribeMacros{\define@choicekey,\define@choicekey*}
540 %The keys work the same as ordinary keys, except that, before
541 %executing anything, it is verified whether the user input |#1| is
542 %present in the comma separated list \meta{al}. The starred version
543 %first converts the input in |#1| and \meta{al} to lowercase before
544 %performing the check. If the input is not allowed, an error is
545 %produced and the key macro \meta{func} will not be executed. If the
546 %input is allowed, the key macro \meta{func} will be executed. \meta{dft}
547 %is submitted to the key macro when the user didn't supply a value
548 %for the key. (See also section~\ref{sec:odefine}.)
549 %
550 %The optional \meta{bin} should contain either one or two control
551 %sequences (macros). The first one will be used to store the user
552 %input used in the input check (hence, in lowercase when the starred
553 %version was used). The original user input will always be available
554 %in |#1|. The second (if present) will contain the number of the
555 %input in the \meta{al} list, starting from 0. The number will be set
556 %to |-1| if the input was not allowed. The number can, for instance,
557 %be used in a |\ifcase| statement in \meta{func}.
558 %\begin{example}
559 % \define@choicekey*{fam}{align}[\val\nr]{left,center,right}{%
560 % \ifcase\nr\relax
561 % \raggedright
562 % \or
563 % \centering
564 % \or
565 % \raggedleft
566 % \fi
567 % }
568 %\end{example}
569 %The example above only allows input values |left|, |center| and
570 %|right|. Notice that we don't need a |\else| case in the key macro
571 %above as the macro will not be executed when the input was not
572 %allowed.
573 %
574 %\begin{command}
575 % `\cs{define@choicekey+}\oarg{pre}\marg{fam}\marg{key}\oarg{bin}\marg{al}\oarg{dft}\marg{f1}\marg{f2}'
576 % `\cs{define@choicekey*+}\oarg{pre}\marg{fam}\marg{key}\oarg{bin}\marg{al}\oarg{dft}\marg{f1}\marg{f2}'
577 %\end{command}
578 %\DescribeMacros{\define@choicekey+,\define@choicekey*+}
579 %These macros operate as their counterparts without the |+|, but
580 %allow for specifying two key macros. \meta{f1} will be executed when
581 %the input was correct and \meta{f2} will be executed when the input
582 %was not allowed. Again, the starred version executes the check after
583 %converting user input and \meta{al} to lowercase.
584 %\begin{example}
585 % \define@choicekey*+{fam}{align}[\val\nr]{left,center,right}{%
586 % \ifcase\nr\relax
587 % \raggedright
588 % \or
589 % \centering
590 % \or
591 % \raggedleft
592 % \fi
593 % }{%
594 % \PackageWarning{mypack}{erroneous input ignored}%
595 % }
596 %\end{example}
597 %The example above defines a key that is similar as the one in the
598 %previous example, but when input is not allowed, it will not
599 %generate a standard \pf{xkeyval} warning, but will execute a custom
600 %function, which, in this case, generates a warning.
601 %
602 %\begin{command}
603 % `\cs{XKV@cc}\oarg{bin}\marg{input}\marg{al}\marg{func}'
604 % `\cs{XKV@cc*}\oarg{bin}\marg{input}\marg{al}\marg{func}'
605 % `\cs{XKV@cc+}\oarg{bin}\marg{input}\marg{al}\marg{func1}\marg{func2}'
606 % `\cs{XKV@cc*+}\oarg{bin}\marg{input}\marg{al}\marg{func1}\marg{func2}'
607 %\end{command}
608 %\DescribeMacros{\XKV@cc,\XKV@cc*,\XKV@cc+,\XKV@cc*+}
609 %Choice keys work by adding (an internal version\footnote{See
610 %section~\ref{sec:imple} for details of the implementation of choice
611 %keys.} of) the |\XKV@cc| macro to key macros. This macro has similar
612 %arguments as the |\define@choicekey| macro and the optional |*| and
613 %|+| have the same meaning. \meta{input} holds the input that should
614 %be checked, namely, whether it is (in lowercase if |*| was used) in
615 %the list \meta{al}. One can use this macro to create custom choice
616 %keys. See an example below.
617 %\begin{example}
618 % \define@key{fam}{key}{%
619 % I will first check your input, please wait.\\
620 % \XKV@cc*+[\val]{#1}{true,false}{%
621 % The input \val\ was correct, we proceed.\\
622 % }{%
623 % The input \val\ was incorrect and was ignored.\\
624 % }%
625 % I finished the input check.
626 % }
627 %\end{example}
628 %Try to find out why this key cannot be defined with |\define@boolkey|
629 %which is introduced in the next section.
630 %
631 %\subsection{Boolean keys}\label{sec:bdefine}
632 %\changes{v1.5}{2004/09/27}{Added boolean keys}
633 %This section describes boolean keys which can be either true or
634 %false. A boolean key is a special version of a choice key (see
635 %section~\ref{sec:chdefine}), where \meta{al} takes the value
636 %|true,false| and comparisons are always done in lowercase mode (so,
637 %|True| is allowed input).
638 %\begin{command}
639 % `\cs{define@boolkey}\oarg{pre}\marg{fam}\oarg{mp}\marg{key}\oarg{default}\marg{func}'
640 % `\cs{define@boolkey+}\oarg{pre}\marg{fam}\oarg{mp}\marg{key}\oarg{default}\marg{func1}\marg{func2}'
641 %\end{command}
642 %\DescribeMacros{\define@boolkey,\define@boolkey+}
643 %This creates a boolean of the form
644 %|\if|\meta{pre}|@|\meta{family}|@|\meta{key}\footref{foot:1}\footnote{
645 %When you want to use this macro directly, either make sure that
646 %neither of the input parameters contain characters with a catcode
647 %different from 11 (hence no \texttt{-} for instance), reset the
648 %catcode of the offending characters internally to 11 or use
649 %\texttt{\cs{csname}\dots\cs{endcsname}} to construct macro names,
650 %(for instance, \texttt{\cs{csname}
651 %ifpre@some-fam@key\cs{endcsname}}). See for more information
652 %section~\ref{sec:macrostructs}.} if \meta{mp} is not specified,
653 %using |\newif|\footnote{The \LaTeX\ of implementation \cs{newif} is
654 %used because it can be used in the replacement text of a macro,
655 %whereas the plain \TeX\ \cs{newif} is defined \cs{outer}.} (which
656 %initiates the conditional to |\iffalse|) and a key macro of the form
657 %|\|\meta{pre}|@|\meta{family}|@|\meta{key} which first checks the
658 %validity of the user input. If the input was valid, it uses it to
659 %set the boolean and afterwards, it executes \meta{func}. If the
660 %input was invalid, it will not set the boolean and \pf{xkeyval} will
661 %generate an error. If \meta{mp} is specified, it will create boolean
662 %of the form |\if|\meta{mp}\meta{key} (compare to command keys in
663 %section~\ref{sec:cdefine}). The value \meta{default} will be used by
664 %the key macro when the user didn't submit a value to the key.
665 %(See also section~\ref{sec:odefine}.)
666 %
667 %If the |+| version of the macro is used, one can specify two key
668 %macros. If user input is valid, the macro will set the boolean and
669 %executes \meta{func1}. Otherwise, it will not set the boolean and
670 %execute \meta{func2}.
671 %\begin{example}
672 % \define@boolkey{fam}[my@]{frame}{}
673 % \define@boolkey+{fam}{shadow}{%
674 % \ifKV@fam@shadow
675 % \PackageInfo{mypack}{turning shadows on}%
676 % \else
677 % \PackageInfo{mypack}{turning shadows off}%
678 % \fi
679 % }{%
680 % \PackageWarning{mypack}{erroneous input ignored}%
681 % }
682 %\end{example}
683 %The first example creates the boolean |\ifmy@frame| and defines
684 %the key macro |\KV@fam@frame| to only set the boolean (if input is
685 %correct). The second key informs the user about changed settings or
686 %produces a warning when input was incorrect.
687 %
688 %One can also define multiple boolean keys with a single command.
689 %\begin{command}
690 % `\cs{define@boolkeys}\oarg{pre}\marg{fam}\oarg{mp}\marg{keys}\oarg{default}'
691 %\end{command}
692 %\DescribeMacro{\define@boolkeys}
693 %This macro creates a boolean key for every entry in the list
694 %\meta{keys}. As with the command |\define@cmdkeys|, the individual keys cannot
695 %have a custom function. The boolean keys created with this command
696 %are only meant to set the state of the boolean using the user input.
697 %Concluding,
698 %\begin{example}
699 % \define@boolkeys{fam}[my@]{keya,keyb,keyc}
700 %\end{example}
701 %is an abbreviation for
702 %\begin{example}
703 % \define@boolkey{fam}[my@]{keya}{}
704 % \define@boolkey{fam}[my@]{keyb}{}
705 % \define@boolkey{fam}[my@]{keyc}{}
706 %\end{example}
707 %
708 %\subsection{Checking keys}\label{sec:check}
709 %\changes{v1.7}{2004/11/25}{Changed name of \cs{XKV@ifku}}
710 %\begin{command}
711 % `\cs{key@ifundefined}\oarg{prefix}\marg{families}\marg{key}\marg{undefined}\marg{defined}'
712 %\end{command}
713 %\DescribeMacro{\key@ifundefined}
714 %This macro executes \meta{undefined} when \meta{key} is not defined
715 %in a family listed in \meta{families} using \meta{prefix} (which is
716 %|KV| by default) and \meta{defined} when it is. If \meta{defined} is
717 %executed, |\XKV@tfam| holds the first family in the list \meta{families}
718 %that holds \meta{key}. If \meta{undefined} is executed, |\XKV@tfam|
719 %contains the last family of the list \meta{families}.
720 %\begin{example}
721 % \key@ifundefined[my]{familya,familyb}{keya}{`keya' not defined}{`keya' defined}
722 %\end{example}
723 %This example results in |`keya' defined| and |\XKV@tfam| holds |familya|.
724 %
725 %\subsection{Disabling keys}\label{sec:disable}
726 %\changes{v1.7}{2004/11/25}{Added \cs{disable@keys}}
727 %It is also possible to disable keys after use as to prevent the key
728 %from being used again.
729 %
730 %\begin{command}
731 % `\cs{disable@keys}\oarg{prefix}\marg{family}\marg{keys}'
732 %\end{command}
733 %\DescribeMacro{\disable@keys}
734 %When you disable a key, the use of this key will produce a warning
735 %in the log file. Disabling a key that hasn't been defined will result
736 %in an error message.
737 %\begin{example}
738 % \disable@keys[my]{familya}{keya,keyb}
739 %\end{example}
740 %This would make |keya| and |keyb| produce a warning when one tries to
741 %set these keys.
742 %
743 %\section{Setting keys}\label{sec:setkeys}
744 %\subsection{The user interface}
745 %\changes{v1.4}{2004/08/24}{Added prefix options to macros}
746 %This section describes the available macros for setting keys. All of
747 %the macros in this section have an optional argument \meta{prefix}
748 %which determines part of the form of the keys that the macros will
749 %be looking for. See section~\ref{sec:define}. This optional argument
750 %takes the value |KV| by default.
751 %
752 %\begin{command}
753 % `\cs{setkeys}\oarg{prefix}\marg{families}\oarg{na}\marg{keys}'
754 %\end{command}
755 %\DescribeMacro{\setkeys}
756 %This macro sets keys of the form
757 %|\|\meta{prefix}|@|\meta{family}|@|\meta{key}\footref{foot:1} where \meta{family} is
758 %an element of the list \meta{families} and |key| is an element of
759 %the options list \meta{keys} and not of \meta{na}. The latter list
760 %can be used to specify keys that should be ignored by the macro. If
761 %a key is defined by more families in the list \meta{families}, the
762 %first family from the list defining the key will set it. No errors
763 %are produced when \meta{keys} is empty. If \meta{family} is empty,
764 %the macro will set keys of the form |\|\meta{prefix}|@|\meta{key}.
765 %If \meta{prefix} is specified and empty, the macro will set keys of
766 %the form |\|\meta{family}|@|\meta{key}. If both \meta{prefix} and
767 %\meta{family} are empty, the macro will set keys of the form
768 %|\|\meta{key}.
769 %\begin{example}
770 % \setkeys[my]{familya,familyb}{keya=test}
771 % \setkeys[my]{familya,familyb}{keyb=test}
772 % \setkeys[my]{familyb,familya}{keyb=test}
773 %\end{example}
774 %In the example above, line 1 will set |keya| in family |familya|.
775 %This effectively means that the value |test| will be submitted to the
776 %key macro |\my@familya@keya|. The next line will set |keyb| in
777 %|familya|. The last one sets |keyb| in family |familyb|. As the keys
778 %used here, directly output their value, the above code results in
779 %typesetting the word |test| three times.
780 %
781 %When input is lacking for a key, |\setkeys| will check whether there
782 %is a default value for that key that can be used instead. If that is
783 %not the case, an error message will be generated. See also
784 %section~\ref{sec:define}.
785 %\begin{example}
786 % \setkeys[my]{familya}{keya}
787 % \setkeys[my]{familya}{keyb}
788 %\end{example}
789 %The first line of the example above does not generate an error as this
790 %key has been defined with a default value (see section~\ref{sec:odefine}).
791 %The second line does generate an error message. See also section~\ref{sec:errors}
792 %for all possible error messages generated by \pf{xkeyval}.
793 %
794 %When you want to use commas or equality signs in the value of a key,
795 %surround the value by braces, as shown in the example below.
796 %\begin{example}
797 % \setkeys[my]{familya}{keya={some=text,other=text}}
798 %\end{example}
799 %
800 %It is possible to nest |\setkeys| commands in other |\setkeys| commands
801 %or in key definitions. The following, for instance,
802 %\begin{example}
803 % \define@key[my]{familyb}{keyc}{#1}
804 % \setkeys[my]{familyb}{keyc=a\setkeys[my]{familya}{keya=~and b},keyb=~and c}
805 %\end{example}
806 %returns |a and b and c|.
807 %
808 %\begin{command}
809 % `\cs{setkeys*}\oarg{prefix}\marg{families}\oarg{na}\marg{keys}'
810 %\end{command}
811 %\DescribeMacro{\setkeys*}
812 %The starred version of |\setkeys| sets keys which it can locate in
813 %the given families and will not produce errors when it cannot find a
814 %key. Instead, these keys and their values will be appended to a list
815 %of remaining keys in the macro |\XKV@rm| after the use of
816 %|\setkeys*|. This list will also contain keys and values coming from
817 %nested |\setkeys*| commands in the order as they have been
818 %submitted. Keys listed in \meta{na} will be ignored fully and will
819 %not be appended to the |\XKV@rm| list.
820 %\begin{example}
821 % \setkeys*[my]{familyb}{keya=test}
822 %\end{example}
823 %Since |keya| is not defined in |familyb|, the value in the example
824 %above will be stored in |\XKV@rm| (so |\XKV@rm| expands to
825 %|keya=test|) for later use and no errors are raised.
826 %
827 %\begin{command}
828 % `\cs{setrmkeys}\oarg{prefix}\marg{families}\oarg{na}'
829 %\end{command}
830 %\DescribeMacro{\setrmkeys}
831 %The macro |\setrmkeys| sets the remaining keys given by the list
832 %|\XKV@rm| stored previously by a |\setkeys*| (or |\setrmkeys*|)
833 %command in \meta{families}. \meta{na} again lists keys that should
834 %be ignored. It will produce an error when a key cannot be located.
835 %\begin{example}
836 % \setrmkeys[my]{familya}
837 %\end{example}
838 %This submits |keya=test| from the previous
839 %|\setkeys*| command to |familya|. |keya| will be set.
840 %
841 %\begin{command}
842 % `\cs{setrmkeys*}\oarg{prefix}\marg{families}\oarg{na}'
843 %\end{command}
844 %\DescribeMacro{\setrmkeys*}
845 %The macro |\setrmkeys*| acts as the |\setrmkeys| macro but now,
846 %as with |\setkeys*|, it ignores keys that it cannot find and puts
847 %them again on the list stored in |\XKV@rm|. Keys listed in \meta{na}
848 %will be ignored fully and will not be appended to the list in
849 %|\XKV@rm|.
850 %\begin{example}
851 % \setkeys*[my]{familyb}{keya=test}
852 % \setrmkeys*[my]{familyb}
853 % \setrmkeys[my]{familya}
854 %\end{example}
855 %In the example above, the second line tries to set |keya| in
856 %|familyb| again and no errors are generated on failure. The last
857 %line finally sets |keya|.
858 %
859 %The combination of |\setkeys*| and |\setrmkeys| can be used to
860 %construct complex macros in which, for instance, a part of the keys
861 %should be set in multiple families and the rest in another family or
862 %set of families. Instead of splitting the keys or the inputs, the
863 %user can supply all inputs in a single argument and the two macros
864 %will perform the splitting and setting of keys for your macro, given
865 %that the families are well chosen.
866 %
867 %\begin{command}
868 % `\cs{setkeys+}\oarg{prefix}\marg{families}\oarg{na}\marg{keys}'
869 % `\cs{setkeys*+}\oarg{prefix}\marg{families}\oarg{na}\marg{keys}'
870 % `\cs{setrmkeys+}\oarg{prefix}\marg{families}\oarg{na}'
871 % `\cs{setrmkeys*+}\oarg{prefix}\marg{families}\oarg{na}'
872 %\end{command}
873 %\changes{v1.4}{2004/08/24}{Added \texttt{+} option to macros}
874 %\DescribeMacros{\setkeys+,\setkeys*+,\setkeys+,\setkeys*+}
875 %These macros act as their counterparts without the |+|. However,
876 %when a key in \meta{keys} is defined by multiple families, this key
877 %will be set in \emph{all} families in \meta{families}. This can, for
878 %instance, be used to set keys defined by your own package and by
879 %another package with the same name but in different families with a
880 %single command.
881 %\begin{example}
882 % \setkeys+[my]{familya,familyb}{keyb=test}
883 %\end{example}
884 %The example above sets |keyb| in both families.
885 %
886 %\subsection{A few details}
887 %Several remarks should be made with respect to processing the user
888 %input. Assuming that |keya| up to |keyd| are properly defined, one
889 %could do the following.
890 %\begin{example}
891 % \setkeys{family}{keya= test a, keyb={test b,c,d}, , keyc=end}
892 %\end{example}
893 %From values consisting entirely of a |{ }| group, the outer braces
894 %will be stripped off internally.\footnote{\pf{xkeyval} actually
895 %strips off 3 levels of braces: one by using \pf{keyval}'s
896 %\cs{KV@@sp@def} and two in internal parsings. \pf{keyval} strips off
897 %only 2 levels: one by using \cs{KV@@sp@def} and one in internal
898 %parsings. This difference has not yet been shown to cause problems
899 %for existing packages or new implementations. If this appears to be
900 %a problem in the future, effort will be done to solve it.} This
901 %allows the user to `hide' any commas or equality signs that appear
902 %in the value of a key. This means that when using braces around
903 %|value|, \pf{xkeyval} will not terminate the |value| when it
904 %encounters a comma in |value|. For instance, see the value of |keyb|
905 %in the example above. The same holds for the equality sign. Notice
906 %further that any spaces around the characters |=| and |,| (in the
907 %top level group) are removed and that empty entries will silently be
908 %ignored. This makes the example above equivalent to the example
909 %below.
910 %\begin{example}
911 % \setkeys{family}{keya=test a,keyb={test b,c,d},keyc=end}
912 %\end{example}
913 %
914 %Further, when executing a key macro, the following \pf{xkeyval}
915 %internals are available.
916 %\begin{description}
917 %\item[\cs{XKV@prefix}]\mbox{}\\
918 %The prefix, for instance |my|.
919 %\item[\cs{XKV@fams}]\mbox{}\\
920 %The list of families to search, for instance |familya,familyb|.
921 %\item[\cs{XKV@tfam}]\mbox{}\\
922 %The current family, for instance |familya|.
923 %\item[\cs{XKV@header}]\mbox{}\\
924 %The header which is a combination of the prefix and the current
925 %family, for instance |my@familya@|.
926 %\item[\cs{XKV@tkey}]\mbox{}\\
927 %The current key name, for instance |keya|.
928 %\item[\cs{XKV@na}]\mbox{}\\
929 %The keys that should not be set, for instance |keyc,keyd|.
930 %\end{description}
931 %You can use these internals and create, for example, dynamic options
932 %systems in which user input to |\setkeys| will be used to create new
933 %keys which can be used in the very same |\setkeys| command. The
934 %\pf{extract} package \cite{extract} provides an example for this.
935 %
936 %\section{Pointers}\label{sec:pointers}
937 %\changes{v1.4}{2004/08/24}{Added pointer syntax}
938 %\changes{v1.5}{2004/09/27}{Removed \cs{ifrecordkeyvals}}
939 %\changes{v1.7}{2004/11/25}{Changed value saving mechanism}
940 %\changes{v1.7}{2004/11/25}{Changed pointer mechanism}
941 %The \pf{xkeyval} package provides a pointer mechanism.
942 %Pointers can be used to copy values of keys. Hence, one can
943 %reuse the value that has been submitted to a particular key in the
944 %value of another key. This section will first describe how
945 %\pf{xkeyval} can be made to save key values. After that, it will
946 %explain how to use these saved values again. Notice already that the
947 %commands |\savevalue|, |\gsavevalue| and |\usevalue| can only be used
948 %in |\setkeys| commands.
949 %
950 %\subsection{Saving values}\label{sec:savevalue}
951 %\DescribeMacro{\savevalue}
952 %Saving a value for a particular key can be accomplished by using the
953 %|\savevalue| command with the key name as
954 %argument.
955 %\begin{example}
956 % \setkeys[my]{familya}{\savevalue{keya}=test}
957 %\end{example}
958 %This example will set |keya| as we have seen before, but will additionally define
959 %the macro |\XKV@my@familya@keya@value| to expand to |test|. This
960 %macro can be used later on by \pf{xkeyval} to replace pointers. In
961 %general, values of keys will be stored in macros of the form
962 %|\XKV@|\meta{prefix}|@|\meta{family}|@|\meta{key}|@value|. This implies
963 %that the pointer system can only be used within the same family (and
964 %prefix). We will come back to that in section~\ref{sec:usevalue}.
965 %
966 %\DescribeMacro{\gsavevalue}
967 %Using the global version of this command, namely |\gsavevalue|,
968 %will define the value macro |\XKV@my@family@key@value| globally.
969 %In other words, the value macro won't survive after a
970 %|\begingroup|\texttt\dots|\endgroup| construct (for instance, an
971 %environment), when it has been created in this group using
972 %|\savevalue| and it will survive afterwards if |\gsavevalue| is
973 %used.
974 %\begin{example}
975 % \setkeys[my]{familya}{\gsavevalue{keya}=test}
976 %\end{example}
977 %This example will globally define |\XKV@my@familya@keya@value| to
978 %expand to |test|.
979 %
980 %Actually, in most applications, package authors do not want to require
981 %users to use the |\savevalue| form when using the pointer system internally.
982 %To avoid this, the \pf{xkeyval} package also supplies the following commands.
983 %\begin{command}
984 % `\cs{savekeys}\oarg{prefix}\marg{family}\marg{keys}'
985 % `\cs{gsavekeys}\oarg{prefix}\marg{family}\marg{keys}'
986 %\end{command}
987 %\DescribeMacros{\savekeys,\gsavekeys}
988 %The |\savekeys| macro stores a list of keys for which the values
989 %should always be saved to a macro of the form
990 %|\XKV@|\meta{prefix}|@|\meta{family}|@save|. This will be used by
991 %|\setkeys| to check whether a value should be saved or not. The
992 %global version will define this internal macro globally so that the
993 %settings can escape groups (and environments). The |\savekeys| macro
994 %works incrementally. This means that new input will be added to an
995 %existing list for the family at hand if it is not in yet.
996 %\begin{example}
997 % \savekeys[my]{familya}{keya,keyc}
998 % \savekeys[my]{familya}{keyb,keyc}
999 %\end{example}
1000 %The first line stores |keya,keyc| to |\XKV@my@familya@save|. The
1001 %next line changes the content of this macro to |keya,keyc,keyb|.
1002 %
1003 %\begin{command}
1004 % `\cs{delsavekeys}\oarg{prefix}\marg{family}\marg{keys}'
1005 % `\cs{gdelsavekeys}\oarg{prefix}\marg{family}\marg{keys}'
1006 % `\cs{unsavekeys}\oarg{prefix}\marg{family}'
1007 % `\cs{gunsavekeys}\oarg{prefix}\marg{family}'
1008 %\end{command}
1009 %\DescribeMacros{\delsavekeys,\gdelsavekeys,\unsavekeys,\gunsavekeys}
1010 %The |\delsavekeys| macro can be used to remove some keys from an
1011 %already defined list of save keys. No errors will be raised when one
1012 %of the keys in the list \meta{keys} was not in the list. The global
1013 %version |\gdelsavekeys| does the same as |\delsavekeys|, but will
1014 %also make the resulting list global. The |\unsavekeys| macro can be
1015 %used to clear the entire list of key names for which the values
1016 %should be saved. The macro will make
1017 %|\XKV@|\meta{prefix}|@|\meta{family}|@save| undefined.
1018 %|\gunsavekeys| is similar to |\unsavekeys| but makes the internal
1019 %macro undefined globally.
1020 %\begin{example}
1021 % \savekeys[my]{familya}{keya,keyb,keyc}
1022 % \delsavekeys[my]{familya}{keyb}
1023 % \unsavekeys[my]{familya}
1024 %\end{example}
1025 %The first line of this example initializes the list to contain
1026 %|keya,keyb,keyc|. The second line removes |keyb| from this list and
1027 %hence |keya,keyc| remains. The last line makes the list undefined and
1028 %hence clears the settings for this family.
1029 %
1030 %\DescribeMacro{\global}
1031 %It is important to notice that the use of the global version
1032 %|\gsavekeys| will only have effect on the definition of the macro
1033 %|\XKV@|\meta{prefix}|@|\meta{family}|@save|. It will not have an
1034 %effect on how the key values will actually be saved by |\setkeys|.
1035 %To achieve that a particular key value will be saved globally (like
1036 %using |\gsavevalue|), use the |\global| specifier in the |\savekeys|
1037 %argument.
1038 %\begin{example}
1039 % \savekeys[my]{familya}{keya,\global{keyc}}
1040 %\end{example}
1041 %This example does the following. The argument |keya,\global{keyc}|
1042 %is saved (locally) to |\XKV@my@familya@save|. When |keyc| is used in
1043 %a |\setkeys| command, the associated value will be saved globally to
1044 %|\XKV@my@familya@keya@value|. When |keya| is used, its value will be
1045 %saved locally.
1046 %
1047 %All macros discussed in this section for altering the list of save keys
1048 %only look at the key name. If that is the same, old content will be
1049 %overwritten with new content, regardless whether |\global| has been
1050 %used in the content. See the example below.
1051 %\begin{example}
1052 % \savekeys[my]{familya}{\global{keyb},keyc}
1053 % \delsavekeys[my]{familya}{keyb}
1054 %\end{example}
1055 %The first line changes the list in |\XKV@my@familya@save| from
1056 %|keya,\global{keyc}| to |keya,keyc,\global{keyb}|. The second line
1057 %changes the list to |keya,keyc|.
1058 %
1059 %\subsection{Using saved values}\label{sec:usevalue}
1060 %\DescribeMacro{\usevalue}
1061 %The syntax of a pointer is |\usevalue{keyname}| and can only be used
1062 %inside |\setkeys| and friends. \pf{xkeyval} will
1063 %replace a pointer by the value that has been saved for the key that
1064 %the pointer is pointing to. If no value has been saved for this key,
1065 %an error will be raised. The following example will demonstrate how
1066 %to use pointers (using the keys defined in
1067 %section~\ref{sec:odefine}).
1068 %\begin{example}
1069 % \setkeys[my]{familya}{\savevalue{keya}=test}
1070 % \setkeys[my]{familya}{keyb=\usevalue{keya}}
1071 %\end{example}
1072 %The value submitted to |keyb| points to |keya|. This has the effect
1073 %that the value recorded for |keya| will replace |\usevalue{keya}| and this
1074 %value (here |test|) will be submitted to the key macro of |keyb|.
1075 %
1076 %Since the saving of values is prefix and family specific, pointers can
1077 %only locate values that have been saved for keys with the same
1078 %prefix and family as the key for which the pointer is used. Hence this
1079 %\begin{example}
1080 % \setkeys[my]{familya}{\savevalue{keya}=test}
1081 % \setkeys[my]{familyb}{keyb=\usevalue{keya}}
1082 %\end{example}
1083 %will never work. An error will be raised in case a key value points
1084 %to a key for which the value cannot be found or has not been stored.
1085 %
1086 %It is possible to nest pointers as the next example shows.
1087 %\begin{example}
1088 % \setkeys[my]{familya}{\savevalue{keya}=test}
1089 % \setkeys[my]{familya}{\savevalue{keyb}=\usevalue{keya}}
1090 % \setkeys[my]{familya}{keyc=\usevalue{keyb}}
1091 %\end{example}
1092 %This works as follows. First \pf{xkeyval} records the value |test|
1093 %in a macro. Then, |keyb| uses that value. Besides that, the value
1094 %submitted to |keyb|, namely |\usevalue{keya}| will be recorded in another
1095 %macro. Finally, |keyc| will use the value recorded previously for
1096 %|keyb|, namely |\usevalue{keya}|. That in turn points to the value saved for
1097 %|keya| and that value will be used.
1098 %
1099 %It is important to stress that the pointer replacement will be done
1100 %before \TeX\ or \LaTeX\ performs the expansion of the key macro and
1101 %its argument (which is the value that has been submitted to the
1102 %key). This allows pointers to be used in almost any application. (The
1103 %exception is grouped material, to which we will come back later.)
1104 %When programming keys (using |\define@key| and friends), you won't
1105 %have to worry about the expansion of the pointers which might be
1106 %submitted to your keys. The value that will be submitted to your key
1107 %macro in the end, will not contain pointers. These have
1108 %already been expanded and been replaced by the saved values.
1109 %
1110 %A word of caution is necessary. You might get into an infinite
1111 %loop if pointers are not applied with care, as the examples below
1112 %show. The first example shows a direct back link.
1113 %\begin{example}
1114 % \setkeys[my]{familya}{\savevalue{keya}=\usevalue{keya}}
1115 %\end{example}
1116 %The second example shows an indirect back link.
1117 %\begin{example}
1118 % \setkeys[my]{familya}{\savevalue{keya}=test}
1119 % \setkeys[my]{familya}{\savevalue{keyb}=\usevalue{keya}}
1120 % \setkeys[my]{familya}{\savevalue{keya}=\usevalue{keyb}}
1121 %\end{example}
1122 %In these cases, an error will be issued and further pointer replacement
1123 %is canceled.
1124 %
1125 %As mentioned already, pointer replacement does not work inside
1126 %grouped material, |{...}|, if this group is not around the entire
1127 %value (since that will be stripped off, see section~\ref{sec:intro}).
1128 %The following, for instance, will not work.
1129 %\begin{example}
1130 % \setkeys[my]{familya}{\savevalue{keya}=test}
1131 % \setkeys[my]{familya}{keyb=\parbox{2cm}{\usevalue{keya}}}
1132 %\end{example}
1133 %The following provides a working alternative for this situation.
1134 %\begin{example}
1135 % \setkeys[my]{familya}{\savevalue{keya}=test}
1136 % \setkeys[my]{familya}{keyb=\begin{minipage}{2cm}\usevalue{keya}\end{minipage}}
1137 %\end{example}
1138 %In case there is no appropriate alternative, we can work around this
1139 %restriction, for instance by using a value macro directly.
1140 %\begin{example}
1141 % \setkeys[my]{familya}{\savevalue{keya}=test}
1142 % \setkeys[my]{familya}{keyb=\parbox{2cm}{\XKV@my@familya@keya@value}}
1143 %\end{example}
1144 %When no value has been saved for |keya|, the macro
1145 %|\XKV@my@familya@keya@value| is undefined. Hence one might want to
1146 %do a preliminary check to be sure that the macro exists.
1147 %
1148 %Pointers can also be used in default values. We finish this section
1149 %with an example which demonstrates this.
1150 %\begin{example}
1151 % \define@key{fam}{keya}{keya: #1}
1152 % \define@key{fam}{keyb}[\usevalue{keya}]{keyb: #1}
1153 % \define@key{fam}{keyc}[\usevalue{keyb}]{keyc: #1}
1154 % \setkeys{fam}{\savevalue{keya}=test}
1155 % \setkeys{fam}{\savevalue{keyb}}
1156 % \setkeys{fam}{keyc}
1157 %\end{example}
1158 %Since user input is lacking in the final two commands, the default
1159 %value defined for those keys will be used. In the first case, the
1160 %default value points to |keya|, which results in the value |test|.
1161 %In the second case, the pointer points to |keyb|, which points to
1162 %|keya| (since its value has been saved now) and hence also in the
1163 %final command, the value |test| will be submitted to the key macro
1164 %of |keyc|.
1165 %
1166 %\section{Presetting keys}\label{sec:preset}
1167 %\changes{v1.5}{2004/09/27}{Added preset system}
1168 %In contrast to the default value system where users are required to
1169 %specify the key without a value to assign it its default value, the
1170 %presetting system does not require this. Keys which are preset will
1171 %be set automatically by |\setkeys| when the user didn't use those
1172 %keys in the |\setkeys| command. When users did use the keys which
1173 %are also preset, |\setkeys| will avoid setting them again. This
1174 %section again uses the key definitions of section~\ref{sec:odefine}
1175 %in examples.
1176 %
1177 %\begin{command}
1178 % `\cs{presetkeys}\oarg{prefix}\marg{family}\marg{head keys}\marg{tail keys}'
1179 % `\cs{gpresetkeys}\oarg{prefix}\marg{family}\marg{head keys}\marg{tail keys}'
1180 %\end{command}
1181 %\DescribeMacros{\presetkeys,\gpresetkeys}
1182 %This macro will save \meta{head keys} to
1183 %|\XKV@|\meta{prefix}|@|\meta{family}|@preseth| and \meta{tail keys}
1184 %to |\XKV@|\meta{prefix}|@|\meta{family}|@presett|. Savings are done
1185 %locally by |\presetkeys| and globally by |\gpresetkeys| (compare
1186 %|\savekeys| and |\gsavekeys|, section~\ref{sec:savevalue}). The
1187 %saved macros will be used by |\setkeys|, when they are defined,
1188 %whenever \meta{family} is used in the \meta{families} argument of
1189 %|\setkeys|. Head keys will be set before setting user keys, tail
1190 %keys will be set afterwards. However, if a key appears in the user
1191 %input, this particular key will not be set by any of the preset
1192 %keys.
1193 %
1194 %The macros work incrementally. This means that new input for a
1195 %particular key replaces already present settings for this key. If no
1196 %settings were present yet, the new input for this key will be
1197 %appended to the end of the existing list. The replacement ignores
1198 %the fact whether a |\savevalue| or an |=| has been specified in the key
1199 %input. We could do the following.
1200 %\begin{example}
1201 % \presetkeys{fam}{keya=red,\savevalue{keyb},keyc}{}
1202 % \presetkeys{fam}{\savevalue{keya},keyb=red,keyd}{}
1203 %\end{example}
1204 %After the first line of the example, the macro |\XKV@KV@fam@preseth|
1205 %will contain |keya=red,\savevalue{keyb},keyc|. After the second line of the
1206 %example, the macro will contain |\savevalue{keya},keyb=red,keyc,keyd|.
1207 %The \meta{tail keys} remain empty throughout the example.
1208 %
1209 %\begin{command}
1210 % `\cs{delpresetkeys}\oarg{prefix}\marg{family}\marg{head keys}\marg{tail keys}'
1211 % `\cs{gdelpresetkeys}\oarg{prefix}\marg{family}\marg{head keys}\marg{tail keys}'
1212 %\end{command}
1213 %\DescribeMacros{\delpresetkeys,\gdelpresetkeys}
1214 %These commands can be used to (globally) delete entries from the
1215 %presets by specifying the key names for which the presets should be
1216 %deleted. Continuing the previous example, we could do the following.
1217 %\begin{example}
1218 % \delpresetkeys{fam}{keya,keyb}{}
1219 %\end{example}
1220 %This redefines the list of head presets |\XKV@KV@fam@preseth| to
1221 %contain |keyc,keyd|. As can be seen from this example, the exact
1222 %use of a key name is irrelevant for successful deletion.
1223 %
1224 %\begin{command}
1225 % `\cs{unpresetkeys}\oarg{prefix}\marg{family}'
1226 % `\cs{gunpresetkeys}\oarg{prefix}\marg{family}'
1227 %\end{command}
1228 %\DescribeMacros{\unpresetkeys,\gunpresetkeys}
1229 %These commands clear the presets for \meta{family} and works just as
1230 %|\unsavekeys|. It makes
1231 %|\XKV@|\meta{prefix}|@|\meta{family}|@preseth| and
1232 %|\XKV@|\meta{prefix}|@|\meta{family}|@presett| undefined. The global
1233 %version will make the macros undefined globally.
1234 %
1235 %Two type of problems in relation to pointers could appear when
1236 %specifying head and tail keys incorrectly. This will be demonstrated
1237 %with two examples. In the first example, we would like to set |keya|
1238 %to |blue| and |keyb| to copy the value of |keya|, also when the user
1239 %has changed the preset value of |keya|. Say that we implement the
1240 %following.
1241 %\begin{example}
1242 % \savekeys[my]{familya}{keya}
1243 % \presetkeys[my]{familya}{keya=blue,keyb=\usevalue{keya}}{}
1244 % \setkeys[my]{familya}{keya=red}
1245 %\end{example}
1246 %This will come down to executing
1247 %\begin{example}
1248 % \savekeys[my]{familya}{keya}
1249 % \setkeys[my]{familya}{keyb=\usevalue{keya},keya=red}
1250 %\end{example}
1251 %since |keya| has been specified by the user. At best, |keyb| will
1252 %copy a probably wrong value of |keya|. In the case that no value for
1253 %|keya| has been saved before, we get an error. We observe that the
1254 %order of keys in the simplified |\setkeys| command is wrong. This
1255 %example shows that the |keyb=\usevalue{keya}| should have been in the
1256 %tail keys, so that it can copy the user input to |keya|.
1257 %
1258 %The following example shows what can go wrong when using presets
1259 %incorrectly and when |\setkeys| contains pointers.
1260 %\begin{example}
1261 % \savekeys[my]{familya}{keya}
1262 % \presetkeys[my]{familya}{}{keya=red}
1263 % \setkeys[my]{familya}{keyb=\usevalue{keya}}
1264 %\end{example}
1265 %This will come down to executing the following.
1266 %\begin{example}
1267 % \savekeys[my]{familya}{keya}
1268 % \setkeys[my]{familya}{keyb=\usevalue{keya},keya=red}
1269 %\end{example}
1270 %This results in exactly the same situation as we have seen in the
1271 %previous example and hence the same conclusion holds. In this case,
1272 %we conclude that the |keya=red| argument should have been specified
1273 %in the head keys of the |\presetkeys| command so that |keyb| can
1274 %copy the value of |keya|.
1275 %
1276 %For most applications, one could use the rule of thumb that preset
1277 %keys containing pointers should go in the tail keys. All other keys
1278 %should go in head keys. There might, however, be applications
1279 %thinkable in which one would like to implement the preset system as
1280 %shown in the two examples above, for instance to easily retrieve
1281 %values used in the last use of a macro or environment. However, make
1282 %sure that keys in that case receive an initialization in order to
1283 %avoid errors of missing values.
1284 %
1285 %For completeness, the working examples are below.
1286 %\begin{example}
1287 % \savekeys[my]{familya}{keya}
1288 % \presetkeys[my]{familya}{keya=blue}{keyb=\usevalue{keya}}
1289 % \setkeys[my]{familya}{keya=red}
1290 % \presetkeys[my]{familya}{keya=red}{}
1291 % \setkeys[my]{familya}{keyb=\usevalue{keya}}
1292 %\end{example}
1293 %Other examples can be found in the example files. See section~\ref{sec:sande}.
1294 %
1295 %\section{Package option processing}\label{sec:options}
1296 %\changes{v1.4}{2004/08/24}{Added prefix options to macros}
1297 %The macros in this section can be used to build \LaTeX\ class or
1298 %package options systems using \pf{xkeyval}. These are comparable to
1299 %the standard \LaTeX\ macros without the trailing |X|. See for more
1300 %information about these \LaTeX\ macros the documentation of the
1301 %source \cite{LaTeXbase} or a \LaTeX\ manual (for instance, the
1302 %\LaTeX\ Companion \cite{companion}). The macros in this section have
1303 %been built using |\define@key| and |\setkeys| and are not
1304 %available to \TeX\ users.
1305 %
1306 %The macros below allow for specifying the \meta{family} (or
1307 %\meta{families}) as an optional
1308 %argument. This could be useful if you want to define global options
1309 %which can be reused later (and set locally by the user) in a macro or
1310 %environment that you define. If no \meta{family} (or
1311 %\meta{families}) is specified, the macro will insert the default
1312 %family name which is the filename of the file that is calling the
1313 %macros. The macros in this section also allow for setting an
1314 %optional prefix. When using the filename as family, uniqueness of
1315 %key macros is already guaranteed. In that case, you can omit the
1316 %optional \meta{prefix}. However, when you use a custom prefix for
1317 %other keys in your package and you want to be able to set all of
1318 %the keys later with a single command, you can use the custom prefix
1319 %also for the class or package options system.
1320 %
1321 %Note that both \oarg{arg} and \larg{arg} denote optional arguments
1322 %to the macros in this section. This syntax is used to identify the
1323 %different optional arguments when they appear next to each other.
1324 %
1325 %\begin{command}
1326 % `\cs{DeclareOptionX}\oarg{prefix}\larg{family}\marg{key}\oarg{default}\marg{function}'
1327 %\end{command}
1328 %\DescribeMacro{\DeclareOptionX}
1329 %Declares an option (i.e., a key, which can also be used later on in
1330 %the package in |\setkeys| and friends). This macro is comparable to the
1331 %standard \LaTeX\ macro |\DeclareOption|, but with this command, the
1332 %user can pass a value to the option as well. Reading that value can
1333 %be done by using |#1| in \meta{function}. This will contain
1334 %\meta{default} when no value has been specified for the key. The
1335 %value of the optional argument \meta{default} is empty by default.
1336 %This implies that when the user does not assign a value to
1337 %\meta{key} and when no default value has been defined, no error will
1338 %be produced. The optional argument \meta{family} can be used to
1339 %specify a custom family for the key. When the argument is not used,
1340 %the macro will insert the default family name.
1341 %\begin{example}
1342 % \newif\iflandscape
1343 % \DeclareOptionX{landscape}{\landscapetrue}
1344 % \DeclareOptionX{parindent}[20pt]{\setlength\parindent{#1}}
1345 %\end{example}
1346 %Assuming that the file containing the example above
1347 %is called |myclass.cls|, the example is equivalent to
1348 %\begin{example}
1349 % \newif\iflandscape
1350 % \define@key{myclass.cls}{landscape}[]{\landscapetrue}
1351 % \define@key{myclass.cls}{parindent}[20pt]{\setlength\parindent{#1}}
1352 %\end{example}
1353 %Notice that an empty default value has been inserted by \pf{xkeyval}
1354 %for the |landscape| option. This allows for the usual \LaTeX\ options
1355 %use like
1356 %\begin{example}
1357 % \documentclass[landscape]{myclass}
1358 %\end{example}
1359 %without raising \texttt{No value specified for key `landscape'} errors.
1360 %
1361 %These examples also show that one can also use |\define@key| (or
1362 %friends, see section~\ref{sec:define}) to define class or package
1363 %options. The macros presented here are supplied for the ease of
1364 %package programmers wanting to convert the options section of their
1365 %package to use \pf{xkeyval}.
1366 %
1367 %\begin{command}
1368 % `\cs{DeclareOptionX*}\marg{function}'
1369 %\end{command}
1370 %\DescribeMacro{\DeclareOptionX*}
1371 %This macro can be used to process any unknown inputs. It is
1372 %comparable to the \LaTeX\ macro |\DeclareOption*|. Use
1373 %|\CurrentOption| within this macro to get the entire input from
1374 %which the key is unknown, for instance |unknownkey=value| or
1375 %|somevalue|. These values (possibly including a key) could for
1376 %example be passed on to another class or package or could be used as
1377 %an extra class or package option specifying for instance a style
1378 %that should be loaded.
1379 %\begin{example}
1380 % \DeclareOptionX*{\PackageWarning{mypackage}{`\CurrentOption' ignored}}
1381 %\end{example}
1382 %The example produces a warning when the user issues an option
1383 %that has not been declared.
1384 %
1385 %\begin{command}
1386 % `\cs{ExecuteOptionsX}\oarg{prefix}\larg{families}\oarg{na}\marg{keys}'
1387 %\end{command}
1388 %\DescribeMacro{\ExecuteOptionsX}
1389 %This macro sets keys created by |\DeclareOptionX| and is basically a
1390 %copy of |\setkeys|. The optional argument \meta{na} specifies keys
1391 %that should be ignored. The optional argument \meta{families} can be
1392 %used to specify a list of families which define \meta{keys}. When
1393 %the argument is not used, the macro will insert the default family
1394 %name. This macro will not use the declaration done by |\DeclareOptionX*|
1395 %when undeclared options appear in its argument. Instead, in this case
1396 %the macro will raise an error. This mimics \LaTeX's |\ExecuteOptions|'
1397 %behavior.
1398 %\begin{example}
1399 % \ExecuteOptionsX{parindent=0pt}
1400 %\end{example}
1401 %This initializes |\parindent| to |0pt|.
1402 %
1403 %\begin{command}
1404 % `\cs{ProcessOptionsX}\oarg{prefix}\larg{families}\oarg{na}'
1405 %\end{command}
1406 %\DescribeMacro{\ProcessOptionsX}
1407 %This macro processes the keys and values passed by the user to the
1408 %class or package. The optional argument \meta{na} can be used to
1409 %specify keys that should be ignored. The optional argument
1410 %\meta{families} can be used to specify the families that have been
1411 %used to define the keys. Note that this macro will not protect
1412 %macros in the user inputs (like |\thepage|) as will be explained in
1413 %section~\ref{sec:macrooptions}. When used in a class file, this macro
1414 %will ignore unknown keys or options. This allows
1415 %the user to use global options in the |\documentclass| command which
1416 %can be copied by packages loaded afterwards.
1417 %
1418 %\begin{command}
1419 % `\cs{ProcessOptionsX*}\oarg{prefix}\larg{families}\oarg{na}'
1420 %\end{command}
1421 %\label{macro:poxstar}
1422 %\DescribeMacro{\ProcessOptionsX*}
1423 %The starred version works like |\ProcessOptionsX| except that it also
1424 %copies user input from the |\documentclass| command. When the user
1425 %specifies an option in the document class which also exists in the
1426 %local family (or families) of the package issuing
1427 %|\ProcessOptionsX*|, the local key will be set as well. In this
1428 %case, |#1| in the |\DeclareOptionX| macro will contain the value
1429 %entered in the |\documentclass| command for this key. First the
1430 %global options from |\documentclass| will set local keys and
1431 %afterwards, the local options, specified with |\usepackage|,
1432 %|\RequirePackage| or |\LoadClass| (or friends), will set local keys,
1433 %which could overwrite the global options again, depending on the way
1434 %the options sections are constructed. This macro reduces to
1435 %|\ProcessOptionsX| only when issued from the class which forms the
1436 %document class for the file at hand to avoid setting the same
1437 %options twice, but not for classes loaded later using for instance
1438 %|\LoadClass|. Global options that do not have a counterpart in local
1439 %families of a package or class will be skipped.
1440 %
1441 %It should be noted that these implementations differ from the
1442 %\LaTeX\ implementations of |\ProcessOptions| and |\ProcessOptions*|.
1443 %The difference is in copying the global options. The \LaTeX\
1444 %commands always copy global options if possible. As a package author
1445 %doesn't know beforehand which document class will be used and with
1446 %which options, the options declared by the author might show some
1447 %unwanted interactions with the global options. When the class and
1448 %the package share the same option, specifying this option in the
1449 %|\documentclass| command will force the package to use that option
1450 %as well. With |\ProcessOptionsX|, \pf{xkeyval} offers a package
1451 %author to become fully independent of the global options and be sure
1452 %to avoid conflicts with any class. Have a look at the example class,
1453 %style and |.tex| file below and observe the effect of changing to
1454 %|\ProcessOptionsX*| in the style file.\footnote{See
1455 %section~\ref{sec:bdefine} for information about
1456 %\cs{define@boolkey}.}
1457 %\begin{minipage}[t]{.49\linewidth}
1458 %\begin{example}
1459 % % myclass.cls
1460 % \RequirePackage{xkeyval}
1461 % \define@boolkey{myclass.cls}%
1462 % [cls]{bool}{}
1463 % \ProcessOptionsX
1464 % \LoadClass{article
1465 %\end{example}
1466 %\end{minipage}
1467 %\hfill
1468 %\begin{minipage}[t]{.49\linewidth}
1469 %\begin{example}
1470 % % mypack.sty
1471 % \define@boolkey{mypack.sty}%
1472 % [pkg]{bool}{}
1473 % \ProcessOptionsX
1474 %\end{example}
1475 %\end{minipage}
1476 %\begin{example}
1477 % % test.tex
1478 % \documentclass[bool=true]{myclass}
1479 % \usepackage{mypack}
1480 % \begin{document}\parindent0pt
1481 % \ifclsbool class boolean true \else class boolean false\fi\\
1482 % \ifpkgbool package boolean true \else package boolean false\fi
1483 % \end{document}
1484 %\end{example}
1485 %See section~\ref{sec:sande} for more examples.
1486 %
1487 %The use of |\ProcessOptionsX*| in a class file might be tricky since
1488 %the class could also be used as a basis for another package or class
1489 %using |\LoadClass|. In that case, depending on the options system of
1490 %the document class, the behavior of the class loaded with
1491 %|\LoadClass| could change compared to the situation when it is
1492 %loaded by |\documentclass|. But since it is technically possible to
1493 %create two classes that cooperate, the \pf{xkeyval} package allows
1494 %for the usage of |\ProcessOptionsX*| in class files. Notice that
1495 %using \LaTeX's |\ProcessOptions| or |\ProcessOptions*|, a class file
1496 %cannot copy document class options.
1497 %
1498 %In case you want to verify whether your class is loaded with
1499 %|\documentclass| or |\LoadClass|, you can use the |\XKV@documentclass|
1500 %macro which contains the current document class.
1501 %
1502 %A final remark concerns the use of expandable macros in class or
1503 %package options values. Due to the construction of the \LaTeX\
1504 %option processing mechanism, this is not possible. However, the
1505 %\pf{xkeyval} bundle includes a patch for the \LaTeX\ kernel which
1506 %solves this problem. See section~\ref{sec:ltxpatch} for more
1507 %information.
1508 %
1509 %\section{List of macro structures}\label{sec:macrostructs}
1510 %This section provides a list of all reserved internal macro structures used
1511 %for key processing. Here |pre| denotes a prefix, |fam| denotes a
1512 %family and |key| denotes a key. These vary per application. The
1513 %other parts in internal macro names are constant. The macros with
1514 %additional |XKV| prefix are protected in the sense that all \pf{xkeyval}
1515 %macros disallow the use of the |XKV| prefix. Package authors
1516 %using \pf{xkeyval} are responsible for protecting the other types of
1517 %internal macros.
1518 %
1519 %\begin{description}
1520 %\item[\cs{pre@fam@key}]\mbox{}\\
1521 %Key macro. This macro takes one argument. This macro will execute
1522 %the \meta{function} of |\define@key| (and friends) on the value
1523 %submitted to the key macro through |\setkeys|.
1524 %\item[\cs{cmdpre@fam@key}]\indent\\
1525 %The macro which is used by |\define@cmdkey| to store user input in
1526 %when no custom macro prefix was specified.
1527 %\item[\cs{ifpre@fam@key}, \cs{pre@fam@keytrue}, \cs{pre@fam@keyfalse}]\indent\\
1528 %The conditional created by |\define@boolkey| with parameters |pre|,
1529 %|fam| and |key| if no custom macro prefix was specified. The
1530 %|true| and |false| macros are used to set the conditional to
1531 %|\iftrue| and |\iffalse| respectively.
1532 %\item[\cs{pre@fam@key@default}]\indent\\
1533 %Default value macro. This macro expands to |\pre@fam@key{default value}|.
1534 %This macro is defined through |\define@key| and friends.
1535 %\item[\cs{XKV@pre@fam@key@value}]\indent\\
1536 %This macro is used to store the value that has been submitted
1537 %through |\setkeys| to the key macro (without replacing pointers).
1538 %\item[\cs{XKV@pre@fam@save}]\indent\\
1539 %Contains the names of the keys that should always be saved when they
1540 %appear in a |\setkeys| command. This macro is defined by
1541 %|\savekeys|.
1542 %\item[\cs{XKV@pre@fam@preseth}]\indent\\
1543 %Contains the head presets. These will be submitted to |\setkeys|
1544 %before setting user input. Defined by |\presetkeys|.
1545 %\item[\cs{XKV@pre@fam@presett}]\indent\\
1546 %Contains the tail presets. These will be submitted to |\setkeys|
1547 %after setting user input. Defined by |\presetkeys|.
1548 %\end{description}
1549 %
1550 %An important remark should be made. Most of the macros listed above
1551 %will be constructed by \pf{xkeyval} internally using
1552 %|\csname...\endcsname|. Hence almost any input to the macros defined
1553 %by this package is possible. However, some internal macros might be
1554 %used outside \pf{xkeyval} macros as well, for instance the macros of
1555 %the form |\ifpre@fam@key| and |\cmdpre@fam@key|. To be able to use
1556 %these macros yourself, none of the input parameters should contain
1557 %non-letter characters. If you feel that this is somehow necessary
1558 %anyway, there are several strategies to make things work.
1559 %
1560 %Let us consider as example the following situation (notice the hyphen
1561 %|-| in the family name).
1562 %\begin{example}
1563 % \define@boolkey{some-fam}{myif}
1564 % \setkeys{some-fam}{myif=false}
1565 %\end{example}
1566 %Using these keys in a |\setkeys| command is not a problem at all.
1567 %However, if you want to use the |\ifKV@some-fam@myif| command itself,
1568 %you can do either
1569 %\begin{example}
1570 % \edef\savedhyphencatcode{\the\catcode`\-}%
1571 % \catcode`\-=11\relax
1572 % \def\mymacro{%
1573 % \ifKV@some-fam@myif
1574 % % true case
1575 % \else
1576 % % false case
1577 % \fi}
1578 % \catcode`\-=\savedhyphencatcode
1579 %\end{example}
1580 %or
1581 %\begin{example}
1582 % \def\mymacro{%
1583 % \csname ifKV@some-fam@myif\endcsname
1584 % % true case
1585 % \else
1586 % % false case
1587 % \fi}
1588 %\end{example}
1589 %
1590 %\section{Warnings and errors}\label{sec:errors}
1591 %There are several points where \pf{xkeyval} performs a check and
1592 %could produce a warning or an error. All possible warnings or and
1593 %error messages are listed below with an explanation. Here |pre|
1594 %denotes a prefix, |name| denotes the name of a key, |fam| denotes a
1595 %family, |fams| denotes a list of families and |val| denotes some
1596 %value. These vary per application. Note that messages 1 to 7 could
1597 %result from erroneous key setting through |\setkeys|, |\setrmkeys|,
1598 %|\ExecuteOptionsX| and |\ProcessOptionsX|.
1599 %
1600 %\begin{description}
1601 %\item[\normalfont 1)\, \texttt{value `val' is not allowed}]\hfill(error)\\
1602 %The value that has been submitted to a key macro is not allowed.
1603 %This error can be generated by either a choice or a boolean key.
1604 %\item[\normalfont 2)\, \texttt{`name' undefined in families `fams'}]\hfill(error)\\
1605 %The key |name| is not defined in the families in |fams|. Probably
1606 %you mistyped |name|.
1607 %\item[\normalfont 3)\, \texttt{no key specified for value `val'}]\hfill(error)\\
1608 %\pf{xkeyval} found a value without a key, for instance something
1609 %like |=value|, when setting keys.
1610 %\item[\normalfont 4)\, \texttt{no value recorded for key `name'}]\hfill(error)\\
1611 %You have used a pointer to a key for which no value has been saved
1612 %previously.
1613 %\item[\normalfont 5)\, \texttt{back linking pointers; pointer replacement canceled}]\hfill(error)\\
1614 %You were back linking pointers. Further pointer replacements are canceled
1615 %to avoid getting into an infinite loop. See section~\ref{sec:usevalue}.
1616 %\item[\normalfont 6)\, \texttt{no value specified for key `name'}]\hfill(error)\\
1617 %You have used the key `name' without specifying any value for it
1618 %(namely, |\setkeys{fam}{name}| and the key does not have a default
1619 %value. Notice that |\setkeys{fam}{name=}| submits the empty value to
1620 %the key macro and that this is considered a legal value.
1621 %\item[\normalfont 7)\, \label{mess:2}\texttt{key `name' has been disabled}]\hfill(warning)\\
1622 %The key that you try to set has been disabled and cannot be used anymore.
1623 %\item[\normalfont 8)\, \texttt{`XKV' prefix is not allowed}]\hfill(error)\\
1624 %You were trying to use the |XKV| prefix when defining or setting
1625 %keys. This error can be caused by any \pf{xkeyval} macro having an
1626 %optional prefix argument.
1627 %\item[\normalfont 9)\, \texttt{key `name' undefined}]\hfill(error)\\
1628 %This error message is caused by trying to disable a key that does not
1629 %exist. See section~\ref{sec:disable}.
1630 %\item[\normalfont 10)\, \texttt{no save keys defined for `pre@fam@'}]\hfill(error)\\
1631 %You are trying to delete or undefine save keys that have not been defined yet.
1632 %See section~\ref{sec:savevalue}.
1633 %\item[\normalfont 11)\, \texttt{no presets defined for `pre@fam@'}]\hfill(error)\\
1634 %You are trying to delete or undefine presets that have not been defined yet.
1635 %See section~\ref{sec:preset}.
1636 %\item[\normalfont 12)\, \texttt{xkeyval loaded before \cs{documentclass}}]\hfill(error)\\
1637 %Load \pf{xkeyval} after |\documentclass| (or in the class that is
1638 %the document class). See section~\ref{sec:options}.
1639 %\end{description}
1640 %
1641 %\section{Category codes}\label{sec:catcodes}
1642 %Some packages change the catcode of the equality sign and the comma.
1643 %This is a problem for \pf{keyval} as it then does not recognize
1644 %these characters anymore and cannot parse the input. This problem
1645 %can play up on the background. Consider for instance the following
1646 %example and note that the \pf{graphicx} package is using \pf{keyval}
1647 %and that Turkish \pf{babel} will activate the equality sign for
1648 %shorthand notation.
1649 %\begin{example}
1650 % \documentclass{article}
1651 % \usepackage{graphicx}
1652 % \usepackage[turkish]{babel}
1653 % \begin{document}
1654 % \includegraphics[scale=.5]{rose.eps}
1655 % \end{document}
1656 %\end{example}
1657 %The \pf{babel} package provides syntax to temporarily reset the
1658 %catcode of the equality sign and switch shorthand back on after
1659 %using \pf{keyval} (in the |\includegraphics| command), namely
1660 %|\shorthandoff{=}| and |\shorthandon{=}|. But having to do this
1661 %every time \pf{keyval} is invoked is quite cumbersome. Besides that,
1662 %it might not always be clear to the user what the problem is and
1663 %what the solution.
1664 %
1665 %For these reasons, \pf{xkeyval} performs several actions with user
1666 %input before trying to parse it.\footnote{Notice that temporarily
1667 %resetting catcodes before reading the input to \cs{setkeys} won't
1668 %suffice, as it will not help solving problems when input has been
1669 %read before and has been stored in a token register or a macro.}
1670 %First of all, it performs a check whether the characters |=| and |,|
1671 %appear in the input with unexpected catcodes. If so, the
1672 %|\@selective@sanitize| macro is used to sanitize these characters
1673 %only in the top level. This means that characters inside (a)
1674 %group(s), |{ }|, will not be sanitized. For instance, when using
1675 %Turkish \pf{babel}, it is possible to use |=| shorthand notation
1676 %even in the value of a key, as long as this value is inside a group.
1677 %\begin{example}
1678 % \documentclass{article}
1679 % \usepackage{graphicx}
1680 % \usepackage[turkish]{babel}
1681 % \usepackage{xkeyval}
1682 % \makeatletter
1683 % \define@key{fam}{key}{#1}
1684 % \begin{document}
1685 % \includegraphics[scale=.5]{rose.eps}
1686 % \setkeys{fam}{key={some =text}}
1687 % \end{document}
1688 %\end{example}
1689 %In the example above, the |\includegraphics| command does work.
1690 %Further, the first equality sign in the |\setkeys| command will be
1691 %sanitized, but the second one will be left untouched and will be
1692 %typeset as \pf{babel} shorthand notation.
1693 %
1694 %The commands |\savekeys| and |\disable@keys| are protected against
1695 %catcode changes of the comma. The commands |\setkeys| and
1696 %|\presetkeys| are protected against catcode changes of the comma and
1697 %the equality sign. Note that \LaTeX\ option macros (see
1698 %section~\ref{sec:options}) are not protected as \LaTeX\ does not
1699 %protect them either.
1700 %
1701 %\section{Known issues}\label{sec:issues}
1702 %This package redefines \pf{keyval}'s |\define@key| and |\setkeys|.
1703 %This is risky in general. However, since \pf{xkeyval} extends the
1704 %possibilities of these commands while still allowing for the
1705 %\pf{keyval} syntax and use, there should be no problems for packages
1706 %using these commands after loading \pf{xkeyval}. The package
1707 %prevents \pf{keyval} to be loaded afterwards to avoid these commands
1708 %from being redefined again into the simpler versions. For packages
1709 %using internals of \pf{keyval}, like |\KV@@sp@def|, |\KV@do| and
1710 %|\KV@errx|, these are provided separately in |keyval.tex|.
1711 %
1712 %The advantage of redefining these commands instead of making new
1713 %commands is that it is much easier for package authors to start
1714 %using \pf{xkeyval} instead of \pf{keyval}. Further, it eliminates
1715 %the confusion of having multiple commands doing similar things.
1716 %
1717 %A potential problem lies in other packages that redefine either
1718 %|\define@key| or |\setkeys| or both. Hence particular care has been
1719 %spend to check packages for this. Only one package has been found to
1720 %do this, namely \pf{pst-key}. This package implements a custom
1721 %version of |\setkeys| which is specialized to set \pf{PSTricks}
1722 %\cite{PSTricksWeb,PSTricks} keys of the form |\psset@somekey|.
1723 %\pf{xkeyval} also provides the means to set these kind of keys (see
1724 %page~\pageref{page:pstricks}) and work is going on to convert
1725 %\pf{PSTricks} packages to be using a specialization of \pf{xkeyval}
1726 %instead of \pf{pst-key}. This specialization is available in the
1727 %\pf{pst-xkey} package, which is distributed with the \pf{xkeyval}
1728 %bundle and is described in section~\ref{sec:pst-xkey}. However, since
1729 %a lot of authors are involved and since it requires a change of
1730 %policy, the conversion of \pf{PSTricks} packages might take some
1731 %time. Hence, at the moment of writing, \pf{xkeyval} will conflict
1732 %with \pf{pst-key} and the \pf{PSTricks} packages still using
1733 %\pf{pst-key}, which are \pf{pst-ob3d}, \pf{pst-stru} and \pf{pst-uml}.
1734 %
1735 %Have a look at the \pf{PSTricks} website \cite{PSTricksWeb} to find
1736 %out if the package that you want to use has been converted already.
1737 %If not, load an already converted package (like \pf{pstricks-add})
1738 %after loading the old package to make them work.
1739 %
1740 %\section{Additional packages}\label{sec:additional}
1741 %\subsection{\pf{xkvview}}\label{sec:view}
1742 %The \pf{xkeyval} bundle includes a viewer utility, called
1743 %\pf{xkvview},\footnote{The \pf{xkvview} package is contained in the
1744 %file \texttt{xkvview.sty}.} which keeps track of the keys that are
1745 %defined. This utility is intended for package programmers who want
1746 %to have an overview of the keys defined in their package(s). All
1747 %keys defined after loading the package will be recorded in a database.
1748 %It provides the following commands to display (part of) the database.
1749 %\begin{command}
1750 % `\cs{xkvview}\marg{options}'
1751 %\end{command}
1752 %\DescribeMacro{\xkvview}
1753 %When \meta{options} is empty, the entire database will be typeset in
1754 %a table created with the \pf{longtable} package. The columns will,
1755 %respectively, contain the key name, the prefix, the family, the type
1756 %(|ordinary|, |command|, |choice| or |boolean|) and the presence of a
1757 %default value for every key defined after loading \pf{xkvview}.
1758 %
1759 %\DescribeOptions{prefix,family,type,default}
1760 %There are several options to control the output of this command. This
1761 %set of options can be used to set up criteria for the keys that
1762 %should be displayed. If a key does not satisfy one or more of them,
1763 %it won't be included in the table. For instance, the following example
1764 %will display all keys with family |fama|, that do not have a
1765 %default value. Notice that \pf{xkvview} codes `no default value'
1766 %with |[none]|.
1767 %\begin{example}
1768 % \documentclass{article}
1769 % \usepackage{xkvview}
1770 % \makeatletter
1771 % \define@key{fama}{keya}[default]{}
1772 % \define@cmdkey{fama}{keyb}{}
1773 % \define@choicekey{famb}{keyc}{a,b}{}
1774 % \define@boolkey{famb}{keyd}{}
1775 % \makeatother
1776 % \begin{document}
1777 % \xkvview{family=fama,default=[none]}
1778 % \end{document}
1779 %\end{example}
1780 %In the following examples in this section, the same preamble will be
1781 %used, but will not be displayed explicitly in the examples.
1782 %
1783 %\DescribeOption{columns}
1784 %One can select the columns that should be included in the table using
1785 %the |columns| option. The following example includes the columns |prefix|
1786 %and |family| in the table (additional to the key name column).
1787 %\begin{example}
1788 % \xkvview{columns={prefix,family}}
1789 %\end{example}
1790 %The remaining columns are called |type| and |default|.
1791 %
1792 %\DescribeOption{vlabels}
1793 %If you want to refer to an option, |\xkvview| can automatically generate
1794 %labels using the scheme \meta{prefix}|-|\meta{family}|-|\meta{keyname}.
1795 %Here is an example.
1796 %\begin{example}
1797 % \xkvview{vlabels=true}
1798 % Find more information about the keya
1799 % option on page~\pageref{KV-fama-keya}.
1800 %\end{example}
1801 %
1802 %\DescribeOptions{file,wcolsep,weol}
1803 %The package can also write (part of) the database to a file. The
1804 %selection of the information happens in the same way as discussed
1805 %above. When specifying a filename with the option |file|, the body
1806 %of the table that is displayed, will also be written to this file.
1807 %Entries will be separated by |wcolsep| which is |&| by default and
1808 %every row will be concluded by |weol| which is |\\| by default. The
1809 %output in the file can then be used as basis for a custom table, for
1810 %instance in package documentation. The following displays a table in
1811 %the dvi and also writes the body to |out.tex|.
1812 %\begin{example}
1813 % \xkvview{file=out}
1814 %\end{example}
1815 %|out.tex| contains
1816 %\begin{example}
1817 % keya&KV&fama&ordinary&default\\
1818 % keyb&KV&fama&command&[none]\\
1819 % keyc&KV&famb&choice&[none]\\
1820 % keyd&KV&famb&boolean&[none]\\
1821 %\end{example}
1822 %
1823 %The following example generates a table with entries separated by a
1824 %space and no end-of-line content.
1825 %\begin{example}
1826 % \xkvview{file=out,wcolsep=\space,weol=}
1827 %\end{example}
1828 %Now |out.tex| contains
1829 %\begin{example}
1830 % keya KV fama ordinary default
1831 % keyb KV fama command [none]
1832 % keyc KV famb choice [none]
1833 % keyd KV famb boolean [none]
1834 %\end{example}
1835 %
1836 %\DescribeOption{wlabels}
1837 %When post-processing the table generated in this way, one might want
1838 %to refer to entries again as well. When setting |wlabels| to true,
1839 %the labels with names \meta{prefix}|-|\meta{family}|-|\meta{keyname}
1840 %will be in the output file. The following
1841 %\begin{example}
1842 % \xkvview{file=out,wlabels=true}
1843 %\end{example}
1844 %will result in the following content in |out.tex|
1845 %\begin{example}
1846 % keya&KV&fama&ordinary&default\label{KV-fama-keya}\\
1847 % keyb&KV&fama&command&[none]\label{KV-fama-keyb}\\
1848 % keyc&KV&famb&choice&[none]\label{KV-famb-keyc}\\
1849 % keyd&KV&famb&boolean&[none]\label{KV-famb-keyd}\\
1850 %\end{example}
1851 %
1852 %\DescribeOption{view}
1853 %Finally, when you only want to generate a file and no output to the
1854 %dvi, set the |view| option to false.
1855 %\begin{example}
1856 % \xkvview{file=out,view=false}
1857 %\end{example}
1858 %This example only generate |out.tex| and does not put a table in the
1859 %dvi.
1860 %
1861 %\subsection{\pf{xkvltxp}}\label{sec:macrooptions}
1862 %The package and class option system of \LaTeX\ contained in the
1863 %kernel performs some expansions while processing options. This
1864 %prevents doing for instance
1865 %\begin{example}
1866 % \documentclass[title=My title,author=\textsc{Me}]{myclass}
1867 %\end{example}
1868 %given that |myclass| uses \pf{xkeyval} and defines the options |title|
1869 %and |author|.
1870 %
1871 %This problem can be overcome by redefining certain kernel commands.
1872 %These redefinitions are contained in the \pf{xkvltxp}
1873 %package.\footnote{The \pf{xkvltxp} package consists of the file
1874 %\texttt{xkvltxp.sty}.} If you want to allow the user of your class
1875 %to be able to specify expandable macros in the package options, the
1876 %user will have to do |\RequirePackage{xkvltxp}| on the first line of
1877 %the \LaTeX\ file. If you want to offer this functionality in a
1878 %package, the user can use the package in the ordinary way with
1879 %|\usepackage{xkvltxp}|. This package then has to be loaded before
1880 %loading the package which will use this functionality. A description
1881 %of the patch can be found in the source code documentation.
1882 %
1883 %The examples below summarize this information. The first example
1884 %shows the case in which we want to allow for macros in the
1885 %|\documentclass| command.
1886 %\begin{example}
1887 % \RequirePackage{xkvltxp}
1888 % \documentclass[title=My title,author=\textsc{Me}]{myclass}
1889 % \begin{document}
1890 % \end{document}
1891 %\end{example}
1892 %
1893 %The second example shows the case in which we want to allow for
1894 %macros in a |\usepackage| command.
1895 %\begin{example}
1896 % \documentclass{article}
1897 % \usepackage{xkvltxp}
1898 % \usepackage[footer=page~\thepage.]{mypack}
1899 % \begin{document}
1900 % \end{document}
1901 %\end{example}
1902 %
1903 %Any package or class using \pf{xkeyval} and \pf{xkvltxp} to process
1904 %options can take options that contain macros in their value without
1905 %expanding them prematurely. However, you can of course not use
1906 %macros in options which are not of the |key=value| form since they
1907 %might in the end be passed on to or copied by a package which is not
1908 %using \pf{xkeyval} to process options, which will then produce
1909 %errors. Options of the |key=value| form will be deleted from
1910 %|\@classoptionslist| (see section~\ref{sec:options}) and form no
1911 %threat for packages loaded later on. Finally, make sure not to pass
1912 %options of the |key=value| form to packages not using \pf{xkeyval}
1913 %to process options since they cannot process them. For examples see
1914 %section~\ref{sec:sande}.
1915 %
1916 %\subsection{\pf{pst-xkey}}\label{sec:pst-xkey}
1917 %The \pf{pst-xkey} package\footnote{The \pf{pst-xkey} package
1918 %consists of the files \texttt{pst-xkey.tex} and
1919 %\texttt{pst-xkey.sty}. To load \pf{pst-xkey} \TeX\ users do
1920 %\cs{input pst-xkey}, \LaTeX\ users do
1921 %\cs{RequirePackage\{pst-xkey\}} or \cs{usepackage\{pst-xkey\}}.}
1922 %implements a specialized version of the options system of
1923 %\pf{xkeyval} designed for \pf{PSTricks} \cite{PSTricksWeb,PSTricks}.
1924 %This system gives additional freedom to \pf{PSTricks} package
1925 %authors since they won't have to worry anymore about potentially
1926 %redefining keys of one of the many other \pf{PSTricks} packages. The
1927 %command |\psset| is redefined to set keys in multiple families.
1928 %Reading the documentation of the \pf{xkeyval} package (especially
1929 %section~\ref{sec:issues}) first is recommended.
1930 %
1931 %Keys defined in the original distribution of \pf{PSTricks} have the
1932 %macro structure |\psset@somekey| (where |psset| is literal). These
1933 %can be (re)defined by
1934 %\begin{example}
1935 % \define@key[psset]{}{somekey}{function}
1936 %\end{example}
1937 %Notice especially that these keys are located in the so-called
1938 %`empty family'. For more information about |\define@key| and friends,
1939 %see section~\ref{sec:define}.
1940 %
1941 %When writing a \pf{PSTricks} package, let's say \pf{pst-new}, you
1942 %should locate keys in a family which contains the name of your
1943 %package. If you only need one family, you should define keys using
1944 %\begin{example}
1945 % \define@key[psset]{pst-new}{somekey}{function}
1946 %\end{example}
1947 %If you want to use multiple families in your package, you can do
1948 %\begin{example}
1949 % \define@key[psset]{pst-new-a}{somekey}{function}
1950 % \define@key[psset]{pst-new-b}{anotherkey}{function}
1951 %\end{example}
1952 %
1953 %\DescribeMacros{\pst@addfams,\pst@famlist}
1954 %It is important that you add all of the families that you use in
1955 %your package to the list in |\pst@famlist|.
1956 %This list of families will be used by |\psset| to scan for keys to
1957 %set user input. You can add your families to the list using
1958 %\begin{command}
1959 % `\cs{pst@addfams}\marg{families}'
1960 %\end{command}
1961 %For instance
1962 %\begin{example}
1963 % \pst@addfams{pst-new}
1964 %\end{example}
1965 %or
1966 %\begin{example}
1967 % \pst@addfams{pst-new-a,pst-new-b}
1968 %\end{example}
1969 %
1970 %Only one command is needed to set \pf{PSTricks} keys.
1971 %\begin{command}
1972 % `\cs{psset}\oarg{families}\marg{keys}'
1973 %\end{command}
1974 %\DescribeMacro{\psset}
1975 %This command will set \meta{keys} in \meta{families} using
1976 %|\setkeys+| (see section~\ref{sec:setkeys}). When \meta{families} is
1977 %not specified, it will set \meta{keys} in all families in
1978 %|\pst@famlist| (which includes the empty family for original
1979 %\pf{PSTricks} keys).
1980 %\begin{example}
1981 % \psset{somekey=red,anotherkey}
1982 % \psset[pst-new-b]{anotherkey=green}
1983 %\end{example}
1984 %
1985 %\section{Examples and documentation}\label{sec:sande}
1986 %To generate the package and example files from the source, find the
1987 %source of this package, the file |xkeyval.dtx|, in your local \TeX\
1988 %installation or on CTAN and run it with \LaTeX.
1989 %\begin{example}
1990 % latex xkeyval.dtx
1991 %\end{example}
1992 %This will generate the package files (|xkeyval.tex|, |xkeyval.sty|,
1993 %|xkvltxp.sty|, |keyval.tex|, |xkvtxhdr.tex| |xkvview.sty|,
1994 %|pst-xkey.tex| and |pst-xkey.sty|) and the example files.
1995 %
1996 %The file |xkvex1.tex| provides an example for \TeX\ users for the
1997 %macros described in sections~\ref{sec:define},
1998 %\ref{sec:setkeys}, \ref{sec:pointers} and \ref{sec:preset}. The file
1999 %|xkvex2.tex| provides an example for \LaTeX\ users for the same
2000 %macros. The files |xkvex3.tex|, |xkveca.cls|, |xkvecb.cls|,
2001 %|xkvesa.sty|, |xkvesb.sty| and |xkvesc.sty| together form an example
2002 %for the macros described in section~\ref{sec:options}. The set of
2003 %files |xkvex4.tex|, |xkveca.cls|, |xkvecb.cls|, |xkvesa.sty|,
2004 %|xkvesb.sty| and |xkvesc.sty| provides an example for
2005 %sections~\ref{sec:options} and~\ref{sec:macrooptions}. These files
2006 %also demonstrate the possibilities of interaction between packages
2007 %or classes not using \pf{xkeyval} and packages or classes that do
2008 %use \pf{xkeyval} to set options.
2009 %
2010 %To (re)generate this documentation, perform the following steps.
2011 %\begin{example}
2012 % latex xkeyval.dtx
2013 % latex xkeyval.dtx
2014 % bibtex xkeyval
2015 % makeindex -s gglo.ist -o xkeyval.gls xkeyval.glo
2016 % makeindex -s gind.ist -o xkeyval.ind xkeyval.idx
2017 % latex xkeyval.dtx
2018 % latex xkeyval.dtx
2019 %\end{example}
2020 %
2021 % \StopEventually{}
2022 %
2023 % \section{Implementation}\label{sec:imple}
2024 % \subsection{\texttt{xkeyval.tex}}
2025 % Avoid loading |xkeyval.tex| twice.
2026 % \begin{macrocode}
2027 %<*xkvtex>
2028 \csname XKeyValLoaded\endcsname
2029 \let\XKeyValLoaded\endinput
2030 % \end{macrocode}
2031 % Adjust some catcodes to define internal macros.
2032 % \begin{macrocode}
2033 \edef\XKVcatcodes{%
2034 \catcode`\noexpand\@\the\catcode`\@\relax
2035 \catcode`\noexpand\=\the\catcode`\=\relax
2036 \catcode`\noexpand\,\the\catcode`\,\relax
2037 \catcode`\noexpand\:\the\catcode`\:\relax
2038 \let\noexpand\XKVcatcodes\relax
2039 }
2040 \catcode`\@11\relax
2041 \catcode`\=12\relax
2042 \catcode`\,12\relax
2043 \catcode`\:12\relax
2044 % \end{macrocode}
2045 % Load some basic utilities.
2046 % \begin{macrocode}
2047 \input xkvutils
2048 % \end{macrocode}
2049 % Initializations.
2050 % \begin{macrocode}
2051 \newcount\XKV@depth
2052 \newif\ifXKV@st
2053 \newif\ifXKV@sg
2054 \newif\ifXKV@pl
2055 \newif\ifXKV@knf
2056 \newif\ifXKV@rkv
2057 \newif\ifXKV@inpox
2058 \newif\ifXKV@preset
2059 \let\XKV@rm\@empty
2060 % \end{macrocode}
2061 % Load \LaTeX\ primitives if necessary and provide information.
2062 % \begin{macrocode}
2063 \ifx\ProvidesFile\@undefined
2064 \message{2014/12/03 v2.7a key=value parser (HA)}
2065 \input xkvtxhdr
2066 \else
2067 \ProvidesFile{xkeyval.tex}[2014/12/03 v2.7a key=value parser (HA)]
2068 \@addtofilelist{xkeyval.tex}
2069 \fi
2070 % \end{macrocode}
2071 % \begin{macro}{\XKV@warn}
2072 % \begin{macro}{\XKV@err}
2073 % \begin{macro}{\KV@err}
2074 % \begin{macro}{\KV@errx}
2075 % Warning and error macros. We redefine the \pf{keyval} error macros
2076 % to use the \pf{xkeyval} ones. This avoids redefining them again when
2077 % we redefine the |\XKV@warn| and |\XKV@err| macros in |xkeyval.sty|.
2078 % \begin{macrocode}
2079 \def\XKV@warn#1{\message{xkeyval warning: #1}}
2080 \def\XKV@err#1{\errmessage{xkeyval error: #1}}
2081 \def\KV@errx{\XKV@err}
2082 \let\KV@err\KV@errx
2083 % \end{macrocode}
2084 % \end{macro}
2085 % \end{macro}
2086 % \end{macro}
2087 % \end{macro}
2088 % \begin{macro}{\XKV@ifstar}
2089 % \begin{macro}{\XKV@ifplus}
2090 % Checks whether the following token is a |*| or |+|. Use
2091 % |\XKV@ifnextchar| to perform the action safely and ignore catcodes.
2092 % \begin{macrocode}
2093 \def\XKV@ifstar#1{\@ifnextcharacter*{\@firstoftwo{#1}}}
2094 \def\XKV@ifplus#1{\@ifnextcharacter+{\@firstoftwo{#1}}}
2095 % \end{macrocode}
2096 % \end{macro}
2097 % \end{macro}
2098 % \begin{macro}{\XKV@makepf}
2099 % \changes{v1.7}{2004/11/25}{Made macro protect internal macros}
2100 % \marg{prefix}\\
2101 % This macro creates the prefix, like |prefix@| in |\prefix@family@key|.
2102 % First it deletes spaces from the input and checks whether it is empty.
2103 % If not empty, an |@|-sign is added. The use of the |XKV| prefix is
2104 % forbidden to protect internal macros and special macros like saved
2105 % key values.
2106 % \begin{macrocode}
2107 \def\XKV@makepf#1{%
2108 \KV@@sp@def\XKV@prefix{#1}%
2109 \def\XKV@resa{XKV}%
2110 \ifx\XKV@prefix\XKV@resa
2111 \XKV@err{`XKV' prefix is not allowed}%
2112 \let\XKV@prefix\@empty
2113 \else
2114 \edef\XKV@prefix{\ifx\XKV@prefix\@empty\else\XKV@prefix @\fi}%
2115 \fi
2116 }
2117 % \end{macrocode}
2118 % \end{macro}
2119 % \begin{macro}{\XKV@makehd}
2120 % \marg{family}\\
2121 % Creates the header, like |prefix@family@| in |\prefix@family@key|.
2122 % If \meta{family} is empty, the header reduces to |prefix@|.
2123 % \begin{macrocode}
2124 \def\XKV@makehd#1{%
2125 \expandafter\KV@@sp@def\expandafter\XKV@header\expandafter{#1}%
2126 \edef\XKV@header{%
2127 \XKV@prefix\ifx\XKV@header\@empty\else\XKV@header @\fi
2128 }%
2129 }
2130 % \end{macrocode}
2131 % \end{macro}
2132 % \begin{macro}{\XKV@srstate}
2133 % \changes{v2.5f}{2006/11/18}{Added \texttt{XKV@tkey} and \texttt{XKV@rm} to solve bugs}
2134 % \changes{v2.5g}{2006/12/19}{Removed \texttt{XKV@rm} again on user request}
2135 % \changes{v2.6b}{2012/10/14}{Added \texttt{CurrentOption} to fix class options not being
2136 % removed from \cs{@unusedoptionlist} when \cs{setkeys} is nested in \cs{ProcessOptionsX}}
2137 % \marg{postfix1}\marg{postfix2}\\
2138 % Macro to save and restore \pf{xkeyval} internals to allow for
2139 % nesting |\setkeys| commands. It executes a for loop over a set of
2140 % \pf{xkeyval} internals and does, for instance, |\let\XKV@na@i\XKV@na|
2141 % to prepare for stepping a level deeper. If \meta{prefix2} is empty,
2142 % we step a level deeper. If \meta{prefix1} is empty, we go a level up.
2143 % The non-empty argument is always |@\romannumeral\XKV@depth|. Notice
2144 % that this also helps to keep changes to boolean settings (for instance
2145 % by |\XKV@cc*+|) local to the execution of that key.
2146 % \begin{macrocode}
2147 \def\XKV@srstate#1#2{%
2148 \ifx\@empty#2\@empty\advance\XKV@depth\@ne\fi
2149 \XKV@for@n{XKV@prefix,XKV@fams,XKV@tkey,XKV@na,%
2150 ifXKV@st,ifXKV@pl,ifXKV@knf,CurrentOption}\XKV@resa{%
2151 \expandafter\let\csname\XKV@resa#1\expandafter
2152 \endcsname\csname\XKV@resa#2\endcsname
2153 }%
2154 \ifx\@empty#1\@empty\advance\XKV@depth\m@ne\fi
2155 }
2156 % \end{macrocode}
2157 % \end{macro}
2158 % \begin{macro}{\XKV@testopta}
2159 % \begin{macro}{\XKV@t@stopta}
2160 % \marg{function}\\
2161 % Tests for the presence of an optional star or plus and executes
2162 % \meta{function} afterwards.
2163 % \begin{macrocode}
2164 \def\XKV@testopta#1{%
2165 \XKV@ifstar{\XKV@sttrue\XKV@t@stopta{#1}}%
2166 {\XKV@stfalse\XKV@t@stopta{#1}}%
2167 }
2168 \def\XKV@t@stopta#1{\XKV@ifplus{\XKV@pltrue#1}{\XKV@plfalse#1}}
2169 % \end{macrocode}
2170 % \end{macro}
2171 % \end{macro}
2172 % \begin{macro}{\XKV@testoptb}
2173 % \begin{macro}{\XKV@t@stoptb}
2174 % \marg{function}\\
2175 % First check for an optional prefix. Afterwards, set the \meta{prefix}, set
2176 % the header, remove spaces from the \meta{family} and execute \meta{function}.
2177 % \begin{macrocode}
2178 \def\XKV@testoptb#1{\@testopt{\XKV@t@stoptb#1}{KV}}
2179 \def\XKV@t@stoptb#1[#2]#3{%
2180 % \end{macrocode}
2181 % Set prefix.
2182 % \begin{macrocode}
2183 \XKV@makepf{#2}%
2184 % \end{macrocode}
2185 % Set header.
2186 % \begin{macrocode}
2187 \XKV@makehd{#3}%
2188 % \end{macrocode}
2189 % Save family name for later use.
2190 % \begin{macrocode}
2191 \KV@@sp@def\XKV@tfam{#3}%
2192 #1%
2193 }
2194 % \end{macrocode}
2195 % \end{macro}
2196 % \end{macro}
2197 % \begin{macro}{\XKV@testoptc}
2198 % \begin{macro}{\XKV@t@stoptc}
2199 % \marg{function}\\
2200 % Test for an optional \meta{prefix}. Then, set the \meta{prefix},
2201 % sanitize comma's in the list of \meta{families} and remove redundant
2202 % spaces from this list. Finally, check for optional key names that
2203 % should not be set and execute \meta{function}.
2204 % \begin{macrocode}
2205 \def\XKV@testoptc#1{\@testopt{\XKV@t@stoptc#1}{KV}}
2206 \def\XKV@t@stoptc#1[#2]#3{%
2207 \XKV@makepf{#2}%
2208 \XKV@checksanitizeb{#3}\XKV@fams
2209 \expandafter\XKV@sp@deflist\expandafter
2210 \XKV@fams\expandafter{\XKV@fams}%
2211 \@testopt#1{}%
2212 }
2213 % \end{macrocode}
2214 % \end{macro}
2215 % \end{macro}
2216 % \begin{macro}{\XKV@testoptd}
2217 % \begin{macro}{\XKV@t@stoptd}
2218 % \marg{function}\\
2219 % Use |\XKV@testoptb| first to find \meta{prefix} and the
2220 % \meta{family}. Then check for optional \meta{mp} (`macro prefix').
2221 % Next eat the \meta{key} name and check for an optional
2222 % \meta{default} value.
2223 % \begin{macrocode}
2224 \def\XKV@testoptd#1#2{%
2225 \XKV@testoptb{%
2226 \edef\XKV@tempa{#2\XKV@header}%
2227 \def\XKV@tempb{\@testopt{\XKV@t@stoptd#1}}%
2228 \expandafter\XKV@tempb\expandafter{\XKV@tempa}%
2229 }%
2230 }
2231 \def\XKV@t@stoptd#1[#2]#3{%
2232 % \end{macrocode}
2233 % |\ifXKV@st| gives the presence of an optional default value.
2234 % \begin{macrocode}
2235 \@ifnextchar[{\XKV@sttrue#1{#2}{#3}}{\XKV@stfalse#1{#2}{#3}[]}%
2236 }
2237 % \end{macrocode}
2238 % \end{macro}
2239 % \end{macro}
2240 % \begin{macro}{\XKV@ifcmd}
2241 % \begin{macro}{\XKV@@ifcmd}
2242 % \marg{tokens}\marg{macro}\marg{cmd}\marg{yes}\marg{no}\\
2243 % This macro checks whether the \meta{tokens} contains the macro
2244 % specification \meta{macro}. If so, the argument to this macro
2245 % will be saved to \meta{cmd} and \meta{yes} will be executed.
2246 % Otherwise, the content of \meta{tokens} is saved to \meta{cmd}
2247 % and \meta{no} is executed. This macro will, for instance, be used
2248 % to distinguish |key| and |\global{key}| and retrieve |key| in the
2249 % latter case.
2250 % \begin{macrocode}
2251 \def\XKV@ifcmd#1#2#3{%
2252 \def\XKV@@ifcmd##1#2##2##3\@nil##4{%
2253 \def##4{##2}\ifx##4\@nnil
2254 \def##4{##1}\expandafter\@secondoftwo
2255 \else
2256 \expandafter\@firstoftwo
2257 \fi
2258 }%
2259 \XKV@@ifcmd#1#2{\@nil}\@nil#3%
2260 }
2261 % \end{macrocode}
2262 % \end{macro}
2263 % \end{macro}
2264 % \begin{macro}{\XKV@getkeyname}
2265 % \meta{keyvalue}\meta{bin}\\
2266 % Utility macro to retrieve the key name from \meta{keyvalue} which
2267 % is of the form |key=value|, |\savevalue{key}=value| or
2268 % |\gsavevalue{key}=value|, possibly without |value|. |\ifXKV@rkv|
2269 % will record whether this particular value should be saved.
2270 % |\ifXKV@sg| will record whether this value should be saved globally
2271 % or not. The key name will be stored in \meta{bin}.
2272 % \begin{macrocode}
2273 \def\XKV@getkeyname#1#2{\expandafter\XKV@g@tkeyname#1=\@nil#2}
2274 % \end{macrocode}
2275 % \end{macro}
2276 % \begin{macro}{\XKV@g@tkeyname}
2277 % \meta{key}|=|\meta{value}|\@nil|\meta{bin}\\
2278 % Use |\XKV@ifcmd| several times to check the syntax of \meta{value}.
2279 % Save \meta{key} to \meta{bin}.
2280 % \begin{macrocode}
2281 \long\def\XKV@g@tkeyname#1=#2\@nil#3{%
2282 \XKV@ifcmd{#1}\savevalue#3{\XKV@rkvtrue\XKV@sgfalse}{%
2283 \XKV@ifcmd{#1}\gsavevalue#3%
2284 {\XKV@rkvtrue\XKV@sgtrue}{\XKV@rkvfalse\XKV@sgfalse}%
2285 }%
2286 }
2287 % \end{macrocode}
2288 % \end{macro}
2289 % \begin{macro}{\XKV@getsg}
2290 % \meta{key}\meta{bin}\\
2291 % Utility macro to check whether |key| or |\global{key}| has been
2292 % specified in \meta{key}. The key name is saved to \meta{bin}
2293 % \begin{macrocode}
2294 \def\XKV@getsg#1#2{%
2295 \expandafter\XKV@ifcmd\expandafter{#1}\global#2\XKV@sgtrue\XKV@sgfalse
2296 }
2297 % \end{macrocode}
2298 % \end{macro}
2299 % \begin{macro}{\XKV@define@default}
2300 % \marg{key}\marg{default}\\
2301 % Defines the default value macro for \meta{key} and given |\XKV@header|.
2302 % \begin{macrocode}
2303 \def\XKV@define@default#1#2{%
2304 \expandafter\def\csname\XKV@header#1@default\expandafter
2305 \endcsname\expandafter{\csname\XKV@header#1\endcsname{#2}}%
2306 }
2307 % \end{macrocode}
2308 % \end{macro}
2309 % \begin{macro}{\define@key}
2310 % \changes{v1.4}{2004/08/24}{Added optional check}
2311 % \oarg{prefix}\marg{family}\\
2312 % Macro to define a key in a family. Notice the use of the |KV| prefix
2313 % as default prefix. This is done to allow setting both \pf{keyval} and
2314 % \pf{xkeyval} keys with a single command. This top level command first
2315 % checks for an optional \meta{prefix} and the mandatory \meta{family}.
2316 % \begin{macrocode}
2317 \def\define@key{\XKV@testoptb\XKV@define@key}
2318 % \end{macrocode}
2319 % \end{macro}
2320 % \begin{macro}{\XKV@define@key}
2321 % \marg{key}\\
2322 % Check for an optional default value. If none present, define the
2323 % key macro, else continue to eat the default value.
2324 % \begin{macrocode}
2325 \def\XKV@define@key#1{%
2326 \@ifnextchar[{\XKV@d@fine@k@y{#1}}{%
2327 \long\expandafter\def\csname\XKV@header#1\endcsname####1%
2328 }%
2329 }
2330 % \end{macrocode}
2331 % \end{macro}
2332 % \begin{macro}{\XKV@d@fine@key}
2333 % \marg{key}\oarg{default}\\
2334 % Defines the key macro and the default value macro.
2335 % \begin{macrocode}
2336 \def\XKV@d@fine@k@y#1[#2]{%
2337 \XKV@define@default{#1}{#2}%
2338 \expandafter\def\csname\XKV@header#1\endcsname##1%
2339 }
2340 % \end{macrocode}
2341 % \end{macro}
2342 % \begin{macro}{\define@cmdkey}
2343 % \oarg{prefix}\marg{family}\oarg{mp}\marg{key}\\
2344 % Define a command key.
2345 % Test for optional \meta{prefix}, mandatory \meta{family}, optional
2346 % \meta{mp} `macro prefix' and mandatory \meta{key} name.
2347 % \begin{macrocode}
2348 \def\define@cmdkey{\XKV@testoptd\XKV@define@cmdkey{cmd}}
2349 % \end{macrocode}
2350 % \end{macro}
2351 % \begin{macro}{\XKV@define@cmdkey}
2352 % \marg{mp}\marg{key}\oarg{default}\marg{function}\\
2353 % \changes{v2.5c}{2005/07/10}{Avoid initializing control sequence as \cs{relax}}
2354 % Define the default value macro and the key macro. The key macro first
2355 % defines the control sequence formed by the \meta{mp} and \meta{key}
2356 % to expand to the user input and then executes the \meta{function}.
2357 % \begin{macrocode}
2358 \def\XKV@define@cmdkey#1#2[#3]#4{%
2359 \ifXKV@st\XKV@define@default{#2}{#3}\fi
2360 \def\XKV@tempa{\expandafter\def\csname\XKV@header#2\endcsname####1}%
2361 \begingroup\expandafter\endgroup\expandafter\XKV@tempa\expandafter
2362 {\expandafter\def\csname#1#2\endcsname{##1}#4}%
2363 }
2364 % \end{macrocode}
2365 % \end{macro}
2366 % \begin{macro}{\define@cmdkeys}
2367 % \oarg{prefix}\marg{family}\oarg{mp}\marg{keys}\\
2368 % Define multiple command keys.
2369 % \begin{macrocode}
2370 \def\define@cmdkeys{\XKV@testoptd\XKV@define@cmdkeys{cmd}}
2371 % \end{macrocode}
2372 % \end{macro}
2373 % \begin{macro}{\XKV@define@cmdkeys}
2374 % \marg{mp}\marg{keys}\oarg{default}\\
2375 % Loop over \meta{keys} and define a command key for every entry.
2376 % \begin{macrocode}
2377 \def\XKV@define@cmdkeys#1#2[#3]{%
2378 \XKV@sp@deflist\XKV@tempa{#2}%
2379 \XKV@for@o\XKV@tempa\XKV@tempa{%
2380 \edef\XKV@tempa{\noexpand\XKV@define@cmdkey{#1}{\XKV@tempa}}%
2381 \XKV@tempa[#3]{}%
2382 }%
2383 }
2384 % \end{macrocode}
2385 % \end{macro}
2386 % \begin{macro}{\define@choicekey}
2387 % |*+|\oarg{prefix}\marg{family}\\
2388 % Choice keys. First check optional star, plus and prefix and store the
2389 % family.
2390 % \begin{macrocode}
2391 \def\define@choicekey{\XKV@testopta{\XKV@testoptb\XKV@define@choicekey}}
2392 % \end{macrocode}
2393 % \end{macro}
2394 % \begin{macro}{\XKV@define@choicekey}
2395 % \marg{key}\\
2396 % Check for optional storage bins for the input and the number of
2397 % the input in the list of allowed inputs.
2398 % \begin{macrocode}
2399 \def\XKV@define@choicekey#1{\@testopt{\XKV@d@fine@choicekey{#1}}{}}
2400 % \end{macrocode}
2401 % \end{macro}
2402 % \begin{macro}{\XKV@d@fine@choicekey}
2403 % \marg{key}\oarg{bin}\marg{allowed}\\
2404 % Store the storage bin and the list of allowed inputs for later use.
2405 % After that, check for an optional default value.
2406 % \begin{macrocode}
2407 \def\XKV@d@fine@choicekey#1[#2]#3{%
2408 \toks@{#2}%
2409 \XKV@sp@deflist\XKV@tempa{#3}\XKV@toks\expandafter{\XKV@tempa}%
2410 \@ifnextchar[{\XKV@d@fine@ch@icekey{#1}}{\XKV@d@fine@ch@ic@key{#1}}%
2411 }
2412 % \end{macrocode}
2413 % \end{macro}
2414 % \begin{macro}{\XKV@d@fine@ch@icekey}
2415 % \marg{key}\oarg{default}\\
2416 % Define the default value macro if a default value was specified.
2417 % \begin{macrocode}
2418 \def\XKV@d@fine@ch@icekey#1[#2]{%
2419 \XKV@define@default{#1}{#2}%
2420 \XKV@d@fine@ch@ic@key{#1}%
2421 }
2422 % \end{macrocode}
2423 % \end{macro}
2424 % \begin{macro}{\XKV@d@fine@ch@ic@key}
2425 % \marg{key}\\
2426 % Eat correct number of arguments.
2427 % \begin{macrocode}
2428 \def\XKV@d@fine@ch@ic@key#1{%
2429 \ifXKV@pl\XKV@afterelsefi
2430 \expandafter\XKV@d@f@ne@ch@ic@k@y
2431 \else\XKV@afterfi
2432 \expandafter\XKV@d@f@ne@ch@ic@key
2433 \fi
2434 \csname\XKV@header#1\endcsname
2435 }
2436 % \end{macrocode}
2437 % \end{macro}
2438 % \begin{macro}{\XKV@d@f@ne@ch@ic@key}
2439 % \meta{key macro}\marg{function}\\
2440 % Eat one argument and pass it on to the macro that will define the key macro.
2441 % \begin{macrocode}
2442 \def\XKV@d@f@ne@ch@ic@key#1#2{\XKV@d@f@n@@ch@ic@k@y#1{{#2}}}
2443 % \end{macrocode}
2444 % \end{macro}
2445 % \begin{macro}{\XKV@d@f@ne@ch@ic@k@y}
2446 % \meta{key macro}\marg{function1}\marg{function2}\\
2447 % Eat two arguments and pass these on to the macro that will define the key macro.
2448 % \meta{fucntion1} will be executed on correct input, \meta{function2}
2449 % on incorrect input.
2450 % \begin{macrocode}
2451 \def\XKV@d@f@ne@ch@ic@k@y#1#2#3{\XKV@d@f@n@@ch@ic@k@y#1{{#2}{#3}}}
2452 % \end{macrocode}
2453 % \end{macro}
2454 % \begin{macro}{\XKV@d@f@n@@ch@ic@k@y}
2455 % \meta{key macro}\marg{function}\\
2456 % Create the key macros. |\XKV@checkchoice| will be used to check the choice
2457 % and execute one of its mandatory arguments.
2458 % \begin{macrocode}
2459 \def\XKV@d@f@n@@ch@ic@k@y#1#2{%
2460 \edef#1##1{%
2461 \ifXKV@st\noexpand\XKV@sttrue\else\noexpand\XKV@stfalse\fi
2462 \ifXKV@pl\noexpand\XKV@pltrue\else\noexpand\XKV@plfalse\fi
2463 \noexpand\XKV@checkchoice[\the\toks@]{##1}{\the\XKV@toks}%
2464 }%
2465 \def\XKV@tempa{\def#1####1}%
2466 \expandafter\XKV@tempa\expandafter{#1{##1}#2}%
2467 }
2468 % \end{macrocode}
2469 % \end{macro}
2470 % \begin{macro}{\define@boolkey}
2471 % |+|\oarg{prefix}\marg{family}\oarg{mp}\marg{key}\\
2472 % Define a boolean key. This macro checks for an optional |+|, an
2473 % optional \meta{prefix}, the mandatory \meta{family}, an optional
2474 % \meta{mp} (`macro prefix') and the mandatory \meta{key} name.
2475 % \begin{macrocode}
2476 \def\define@boolkey{\XKV@t@stopta{\XKV@testoptd\XKV@define@boolkey{}}}
2477 % \end{macrocode}
2478 % \end{macro}
2479 % \begin{macro}{\XKV@define@boolkey}
2480 % \marg{mp}\marg{key}\oarg{default}\\
2481 % Decide to eat 1 or 2 mandatory arguments for the key macro. Further,
2482 % construct the control sequence for the key macro and the one for the
2483 % if.
2484 % \begin{macrocode}
2485 \def\XKV@define@boolkey#1#2[#3]{%
2486 \ifXKV@pl\XKV@afterelsefi
2487 \expandafter\XKV@d@f@ne@boolkey
2488 \else\XKV@afterfi
2489 \expandafter\XKV@d@fine@boolkey
2490 \fi
2491 \csname\XKV@header#2\endcsname{#2}{#1#2}{#3}%
2492 }
2493 % \end{macrocode}
2494 % \end{macro}
2495 % \begin{macro}{\XKV@d@fine@boolkey}
2496 % \changes{v2.5 }{2005/05/07}{Removed \cs{relax}}
2497 % \meta{key macro}\marg{key}\marg{if name}\marg{default}\marg{function}\\
2498 % Eat one mandatory key function and pass it. Insert `setting the if'.
2499 % \begin{macrocode}
2500 \def\XKV@d@fine@boolkey#1#2#3#4#5{%
2501 \XKV@d@f@ne@b@olkey#1{#2}{#3}{#4}%
2502 {{\csname#3\XKV@resa\endcsname#5}}%
2503 }
2504 % \end{macrocode}
2505 % \end{macro}
2506 % \begin{macro}{\XKV@d@f@ne@boolkey}
2507 % \changes{v2.5 }{2005/05/07}{Removed \cs{relax}}
2508 % \meta{key macro}\marg{key}\marg{if name}\marg{default}\marg{func1}\marg{func2}\\
2509 % Eat two mandatory key functions and pass them. Insert `setting the if'.
2510 % \begin{macrocode}
2511 \def\XKV@d@f@ne@boolkey#1#2#3#4#5#6{%
2512 \XKV@d@f@ne@b@olkey#1{#2}{#3}{#4}%
2513 {{\csname#3\XKV@resa\endcsname#5}{#6}}%
2514 }
2515 % \end{macrocode}
2516 % \end{macro}
2517 % \begin{macro}{\XKV@d@f@ne@b@olkey}
2518 % \meta{key macro}\marg{key}\marg{if name}\marg{default}\marg{function}\\
2519 % Create the if, the default value macro (if a default value was present)
2520 % and the key macro. We use |\XKV@checkchoice| internally to check the
2521 % input and |\XKV@resa| to store the user input and pass it to setting
2522 % the conditional.
2523 % \begin{macrocode}
2524 \def\XKV@d@f@ne@b@olkey#1#2#3#4#5{%
2525 \expandafter\newif\csname if#3\endcsname
2526 \ifXKV@st\XKV@define@default{#2}{#4}\fi
2527 \ifXKV@pl
2528 \def#1##1{\XKV@pltrue\XKV@sttrue
2529 \XKV@checkchoice[\XKV@resa]{##1}{true,false}#5%
2530 }%
2531 \else
2532 \def#1##1{\XKV@plfalse\XKV@sttrue
2533 \XKV@checkchoice[\XKV@resa]{##1}{true,false}#5%
2534 }%
2535 \fi
2536 }
2537 % \end{macrocode}
2538 % \end{macro}
2539 % \begin{macro}{\define@boolkeys}
2540 % \oarg{prefix}\marg{family}\oarg{mp}\marg{keys}\\
2541 % Define multiple boolean keys without user specified key function.
2542 % The key will, of course, still set the if with user input.
2543 % \begin{macrocode}
2544 \def\define@boolkeys{\XKV@plfalse\XKV@testoptd\XKV@define@boolkeys{}}
2545 % \end{macrocode}
2546 % \end{macro}
2547 % \begin{macro}{\XKV@define@boolkeys}
2548 % \marg{mp}\marg{keys}\oarg{default}\\
2549 % Loop over the list of \meta{keys} and create a boolean key for
2550 % every entry.
2551 % \begin{macrocode}
2552 \def\XKV@define@boolkeys#1#2[#3]{%
2553 \XKV@sp@deflist\XKV@tempa{#2}%
2554 \XKV@for@o\XKV@tempa\XKV@tempa{%
2555 \expandafter\XKV@d@fine@boolkeys\expandafter{\XKV@tempa}{#1}{#3}%
2556 }%
2557 }
2558 % \end{macrocode}
2559 % \end{macro}
2560 % \begin{macro}{\XKV@d@fine@boolkeys}
2561 % \marg{key}\marg{mp}\marg{default}\\
2562 % Use |\XKV@d@f@ne@b@olkey| internally to define the if, the default
2563 % value macro (if present) and the key macro.
2564 % \begin{macrocode}
2565 \def\XKV@d@fine@boolkeys#1#2#3{%
2566 \expandafter\XKV@d@f@ne@b@olkey\csname\XKV@header#1\endcsname
2567 {#1}{#2#1}{#3}{{\csname#2#1\XKV@resa\endcsname}}%
2568 }
2569 % \end{macrocode}
2570 % \end{macro}
2571 % \begin{macro}{\XKV@cc}
2572 % This macro is used inside key macros to perform input checks. This
2573 % is the user interface to |\XKV@checkchoice| and we only use the
2574 % latter internally to avoid slow parsings of optional |*| and |+|.
2575 % \begin{macrocode}
2576 \def\XKV@cc{\XKV@testopta{\@testopt\XKV@checkchoice{}}}
2577 % \end{macrocode}
2578 % \end{macro}
2579 % \begin{macro}{\XKV@checkchoice}
2580 % \oarg{bin}\marg{input}\marg{allowed}\\
2581 % Checks whether \meta{bin} contains at least one control sequence and
2582 % converts \meta{input} and \meta{allowed} to lowercase if requested.
2583 % If \meta{bin} is empty, perform the fast |\in@| check immediately.
2584 % Else, determine whether the bin contains one or two tokens. For the
2585 % first alternative, we can still use the fast |\in@| check. Notice
2586 % that this macro uses settings for |\ifXKV@st| and |\ifXKV@pl|.
2587 % \begin{macrocode}
2588 \def\XKV@checkchoice[#1]#2#3{%
2589 \def\XKV@tempa{#1}%
2590 \ifXKV@st\lowercase{\fi
2591 \ifx\XKV@tempa\@empty
2592 \def\XKV@tempa{\XKV@ch@ckch@ice\@nil{#2}{#3}}%
2593 \else
2594 \def\XKV@tempa{\XKV@ch@ckchoice#1\@nil{#2}{#3}}%
2595 \fi
2596 \ifXKV@st}\fi\XKV@tempa
2597 }
2598 % \end{macrocode}
2599 % \end{macro}
2600 % \begin{macro}{\XKV@ch@ckchoice}
2601 % \meta{bin1}\meta{bin2}|\@nil|\marg{input}\marg{allowed}\\
2602 % Check whether \meta{bin2} is empty. In that case, only the \meta{input} should
2603 % be saved and we can continue with the fast |\in@| check. If not, also
2604 % the number of the input in the \meta{allowed} list should be saved
2605 % and we need to do a slower while type of loop.
2606 % \begin{macrocode}
2607 \def\XKV@ch@ckchoice#1#2\@nil#3#4{%
2608 \def\XKV@tempa{#2}%
2609 \ifx\XKV@tempa\@empty\XKV@afterelsefi
2610 \XKV@ch@ckch@ice#1{#3}{#4}%
2611 \else\XKV@afterfi
2612 \XKV@@ch@ckchoice#1#2{#3}{#4}%
2613 \fi
2614 }
2615 % \end{macrocode}
2616 % \end{macro}
2617 % \begin{macro}{\XKV@ch@ckch@ice}
2618 % \meta{bin}\marg{input}\marg{allowed}\\
2619 % Checks whether \meta{input} is in the list \meta{allowed} and perform
2620 % actions accordingly.
2621 % \begin{macrocode}
2622 \def\XKV@ch@ckch@ice#1#2#3{%
2623 \def\XKV@tempa{#1}%
2624 % \end{macrocode}
2625 % If we have a \meta{bin}, store the input there.
2626 % \begin{macrocode}
2627 \ifx\XKV@tempa\@nnil\let\XKV@tempa\@empty\else
2628 \def\XKV@tempa{\def#1{#2}}%
2629 \fi
2630 \in@{,#2,}{,#3,}%
2631 \ifin@
2632 % \end{macrocode}
2633 % The \meta{input} is allowed.
2634 % \begin{macrocode}
2635 \ifXKV@pl
2636 % \end{macrocode}
2637 % If we have a |+|, there are two functions. Execute the first.
2638 % \begin{macrocode}
2639 \XKV@addtomacro@n\XKV@tempa\@firstoftwo
2640 \else
2641 % \end{macrocode}
2642 % Else, we have one function; execute it.
2643 % \begin{macrocode}
2644 \XKV@addtomacro@n\XKV@tempa\@firstofone
2645 \fi
2646 \else
2647 % \end{macrocode}
2648 % If we have a |+|, there are two functions. Execute the second.
2649 % \begin{macrocode}
2650 \ifXKV@pl
2651 \XKV@addtomacro@n\XKV@tempa\@secondoftwo
2652 \else
2653 % \end{macrocode}
2654 % Else, raise an error and gobble the one function.
2655 % \begin{macrocode}
2656 \XKV@toks{#2}%
2657 \XKV@err{value `\the\XKV@toks' is not allowed}%
2658 \XKV@addtomacro@n\XKV@tempa\@gobble
2659 \fi
2660 \fi
2661 \XKV@tempa
2662 }
2663 % \end{macrocode}
2664 % \end{macro}
2665 % \begin{macro}{\XKV@@ch@ckchoice}
2666 % \meta{bin1}\meta{bin2}\marg{input}\marg{allowed}\\
2667 % Walk over the \meta{allowed} list and compare each entry with the
2668 % \meta{input}. The input is saved in \meta{bin1}, the number of the
2669 % \meta{input} in the \meta{allowed} list (starting at zero) is saved
2670 % in \meta{bin2}. If the \meta{input} is not allowed, \meta{bin2} will
2671 % be defined to contain |-1|.
2672 % \begin{macrocode}
2673 \def\XKV@@ch@ckchoice#1#2#3#4{%
2674 % \end{macrocode}
2675 % Save the current value of the counter as to avoid disturbing it.
2676 % We don't use a group as that takes a lot of memory and requires some
2677 % more tokens (for global definitions).
2678 % \begin{macrocode}
2679 \edef\XKV@tempa{\the\count@}\count@\z@
2680 % \end{macrocode}
2681 % The input.
2682 % \begin{macrocode}
2683 \def\XKV@tempb{#3}%
2684 % \end{macrocode}
2685 % Define the while loop.
2686 % \begin{macrocode}
2687 \def\XKV@tempc##1,{%
2688 \def#1{##1}%
2689 \ifx#1\@nnil
2690 % \end{macrocode}
2691 % The \meta{input} was not in \meta{allowed}. Set the number to |-1|.
2692 % \begin{macrocode}
2693 \def#1{#3}\def#2{-1}\count@\XKV@tempa
2694 \ifXKV@pl
2695 % \end{macrocode}
2696 % Execute the macro for the case that input was not allowed.
2697 % \begin{macrocode}
2698 \let\XKV@tempd\@secondoftwo
2699 \else
2700 % \end{macrocode}
2701 % If that function does not exist, raise a generic error and gobble
2702 % the function to be executed on good input.
2703 % \begin{macrocode}
2704 \XKV@toks{#3}%
2705 \XKV@err{value `\the\XKV@toks' is not allowed}%
2706 \let\XKV@tempd\@gobble
2707 \fi
2708 \else
2709 \ifx#1\XKV@tempb
2710 % \end{macrocode}
2711 % We found \meta{input} in \meta{allowed}.
2712 % Save the number of the \meta{input} in the list \meta{allowed}.
2713 % \begin{macrocode}
2714 \edef#2{\the\count@}\count@\XKV@tempa
2715 \ifXKV@pl
2716 \let\XKV@tempd\XKV@@ch@ckch@ice
2717 \else
2718 \let\XKV@tempd\XKV@@ch@ckch@ic@
2719 \fi
2720 \else
2721 % \end{macrocode}
2722 % Increase counter and check next item in the list \meta{allowed}.
2723 % \begin{macrocode}
2724 \advance\count@\@ne
2725 \let\XKV@tempd\XKV@tempc
2726 \fi
2727 \fi
2728 \XKV@tempd
2729 }%
2730 % \end{macrocode}
2731 % Start the while loop.
2732 % \begin{macrocode}
2733 \XKV@tempc#4,\@nil,%
2734 }
2735 % \end{macrocode}
2736 % \end{macro}
2737 % \begin{macro}{\XKV@@ch@ckch@ice}
2738 % \begin{macro}{\XKV@@ch@ckch@ic@}
2739 % \meta{text}|\@nil,|\\
2740 % Gobble remaining \meta{text} and execute the proper key function.
2741 % \begin{macrocode}
2742 \def\XKV@@ch@ckch@ice#1\@nil,{\@firstoftwo}
2743 \def\XKV@@ch@ckch@ic@#1\@nil,{\@firstofone}
2744 % \end{macrocode}
2745 % \end{macro}
2746 % \end{macro}
2747 % \begin{macro}{\key@ifundefined}
2748 % This macro allows checking if a key is defined in a family from
2749 % a list of families. Check for an optional prefix.
2750 % \begin{macrocode}
2751 \def\key@ifundefined{\@testopt\XKV@key@ifundefined{KV}}
2752 % \end{macrocode}
2753 % \end{macro}
2754 % \begin{macro}{\XKV@key@ifundefined}
2755 % \oarg{prefix}\marg{fams}\\
2756 % This macro is split in two parts so that |\XKV@p@x| can use only
2757 % the main part of the macro. First we save the prefix and the list
2758 % of families.
2759 % \begin{macrocode}
2760 \def\XKV@key@ifundefined[#1]#2{%
2761 \XKV@makepf{#1}%
2762 \XKV@checksanitizeb{#2}\XKV@fams
2763 \expandafter\XKV@sp@deflist\expandafter
2764 \XKV@fams\expandafter{\XKV@fams}%
2765 \XKV@key@if@ndefined
2766 }
2767 % \end{macrocode}
2768 % \end{macro}
2769 % \begin{macro}{\XKV@key@if@ndefined}
2770 % \marg{key}\\
2771 % Loop over the list of families until we find the key in a family.
2772 % \begin{macrocode}
2773 \def\XKV@key@if@ndefined#1{%
2774 \XKV@knftrue
2775 \KV@@sp@def\XKV@tkey{#1}%
2776 % \end{macrocode}
2777 % Loop over possible families.
2778 % \begin{macrocode}
2779 \XKV@whilist\XKV@fams\XKV@tfam\ifXKV@knf\fi{%
2780 % \end{macrocode}
2781 % Set the header.
2782 % \begin{macrocode}
2783 \XKV@makehd\XKV@tfam
2784 % \end{macrocode}
2785 % Check whether the macro for the key is defined.
2786 % \begin{macrocode}
2787 \XKV@ifundefined{\XKV@header\XKV@tkey}{}{\XKV@knffalse}%
2788 }%
2789 % \end{macrocode}
2790 % Execute one of the final two arguments depending on state of |\XKV@knf|.
2791 % \begin{macrocode}
2792 \ifXKV@knf
2793 \expandafter\@firstoftwo
2794 \else
2795 \expandafter\@secondoftwo
2796 \fi
2797 }
2798 % \end{macrocode}
2799 % \end{macro}
2800 % \begin{macro}{\disable@keys}
2801 % \oarg{prefix}\marg{family}\\
2802 % Macro that make a key produce a warning on use.
2803 % \begin{macrocode}
2804 \def\disable@keys{\XKV@testoptb\XKV@disable@keys}
2805 % \end{macrocode}
2806 % \end{macro}
2807 % \begin{macro}{\XKV@disable@keys}
2808 % \marg{keys}\\
2809 % Workhorse for |\disable@keys| which redefines a list of key macro
2810 % to produce a warning.
2811 % \begin{macrocode}
2812 \def\XKV@disable@keys#1{%
2813 \XKV@checksanitizeb{#1}\XKV@tempa
2814 \XKV@for@o\XKV@tempa\XKV@tempa{%
2815 \XKV@ifundefined{\XKV@header\XKV@tempa}{%
2816 \XKV@err{key `\XKV@tempa' undefined}%
2817 }{%
2818 \edef\XKV@tempb{%
2819 \noexpand\XKV@warn{key `\XKV@tempa' has been disabled}%
2820 }%
2821 \XKV@ifundefined{\XKV@header\XKV@tempa @default}{%
2822 \edef\XKV@tempc{\noexpand\XKV@define@key{\XKV@tempa}}%
2823 }{%
2824 \edef\XKV@tempc{\noexpand\XKV@define@key{\XKV@tempa}[]}%
2825 }%
2826 \expandafter\XKV@tempc\expandafter{\XKV@tempb}%
2827 }%
2828 }%
2829 }
2830 % \end{macrocode}
2831 % \end{macro}
2832 % \begin{macro}{\presetkeys}
2833 % \begin{macro}{\gpresetkeys}
2834 % \changes{v1.7}{2004/11/25}{Made incremental}
2835 % \oarg{prefix}\marg{family}\\
2836 % This provides the presetting system. The macro works incrementally:
2837 % keys that have been preset before will overwrite the old preset
2838 % values, new ones will be added to the end of the preset list.
2839 % \begin{macrocode}
2840 \def\presetkeys{\XKV@stfalse\XKV@testoptb\XKV@presetkeys}
2841 \def\gpresetkeys{\XKV@sttrue\XKV@testoptb\XKV@presetkeys}
2842 % \end{macrocode}
2843 % \end{macro}
2844 % \end{macro}
2845 % \begin{macro}{\XKV@presetkeys}
2846 % \marg{head presets}\marg{tail presets}\\
2847 % Execute the merging macro |\XKV@pr@setkeys| for both head and tail
2848 % presets.
2849 % \begin{macrocode}
2850 \def\XKV@presetkeys#1#2{%
2851 \XKV@pr@setkeys{#1}{preseth}%
2852 \XKV@pr@setkeys{#2}{presett}%
2853 }
2854 % \end{macrocode}
2855 % \end{macro}
2856 % \begin{macro}{\XKV@pr@setkeys}
2857 % \marg{presets}\marg{postfix}\\
2858 % Check whether presets have already been defined. If not, define them
2859 % and do not start the merging macro. Otherwise, create the control
2860 % sequence that stores these presets and start merging.
2861 % \begin{macrocode}
2862 \def\XKV@pr@setkeys#1#2{%
2863 \XKV@ifundefined{XKV@\XKV@header#2}{%
2864 \XKV@checksanitizea{#1}\XKV@tempa
2865 \ifXKV@st\expandafter\global\fi\expandafter\def\csname
2866 XKV@\XKV@header#2\expandafter\endcsname\expandafter{\XKV@tempa}%
2867 }{%
2868 \expandafter\XKV@merge\csname XKV@\XKV@header
2869 #2\endcsname{#1}\XKV@getkeyname
2870 }%
2871 }
2872 % \end{macrocode}
2873 % \end{macro}
2874 % \begin{macro}{\delpresetkeys}
2875 % \begin{macro}{\gdelpresetkeys}
2876 % \oarg{prefix}\marg{family}\\
2877 % Macros to remove entries from presets.
2878 % \begin{macrocode}
2879 \def\delpresetkeys{\XKV@stfalse\XKV@testoptb\XKV@delpresetkeys}
2880 \def\gdelpresetkeys{\XKV@sttrue\XKV@testoptb\XKV@delpresetkeys}
2881 % \end{macrocode}
2882 % \end{macro}
2883 % \end{macro}
2884 % \begin{macro}{\XKV@delpresetkeys}
2885 % \marg{head key list}\marg{tail key list}\\
2886 % Run the main macro for both head and tail presets.
2887 % \begin{macrocode}
2888 \def\XKV@delpresetkeys#1#2{%
2889 \XKV@d@lpresetkeys{#1}{preseth}%
2890 \XKV@d@lpresetkeys{#2}{presett}%
2891 }
2892 % \end{macrocode}
2893 % \end{macro}
2894 % \begin{macro}{\XKV@d@lpresetkeys}
2895 % \marg{key list}\marg{postfix}\\
2896 % Check whether presets have been saved and if so, start deletion
2897 % algorithm. Supply the macro |\XKV@getkeyname| to retrieve key names
2898 % from entries.
2899 % \begin{macrocode}
2900 \def\XKV@d@lpresetkeys#1#2{%
2901 \XKV@ifundefined{XKV@\XKV@header#2}{%
2902 \XKV@err{no presets defined for `\XKV@header'}%
2903 }{%
2904 \expandafter\XKV@delete\csname XKV@\XKV@header
2905 #2\endcsname{#1}\XKV@getkeyname
2906 }%
2907 }
2908 % \end{macrocode}
2909 % \end{macro}
2910 % \begin{macro}{\unpresetkeys}
2911 % \begin{macro}{\gunpresetkeys}
2912 % \oarg{prefix}\marg{family}\\
2913 % Removes presets for a particular family.
2914 % \begin{macrocode}
2915 \def\unpresetkeys{\XKV@stfalse\XKV@testoptb\XKV@unpresetkeys}
2916 \def\gunpresetkeys{\XKV@sttrue\XKV@testoptb\XKV@unpresetkeys}
2917 % \end{macrocode}
2918 % \end{macro}
2919 % \end{macro}
2920 % \begin{macro}{\XKV@unpresetkeys}
2921 % Undefine the preset macros. We make them undefined since this will
2922 % make them appear undefined to both versions of the macro |\XKV@ifundefined|.
2923 % Making the macros |\relax| would work in the case that no \eTeX\ is
2924 % available (hence using |\ifx\csname|), but doesn't work when \eTeX\
2925 % is used (and using |\ifcsname|).
2926 % \begin{macrocode}
2927 \def\XKV@unpresetkeys{%
2928 \XKV@ifundefined{XKV@\XKV@header preseth}{%
2929 \XKV@err{no presets defined for `\XKV@header'}%
2930 }{%
2931 \ifXKV@st\expandafter\global\fi\expandafter\let
2932 \csname XKV@\XKV@header preseth\endcsname\@undefined
2933 \ifXKV@st\expandafter\global\fi\expandafter\let
2934 \csname XKV@\XKV@header presett\endcsname\@undefined
2935 }%
2936 }
2937 % \end{macrocode}
2938 % \end{macro}
2939 % \begin{macro}{\savekeys}
2940 % \begin{macro}{\gsavekeys}
2941 % \oarg{prefix}\marg{family}\\
2942 % Store a list of keys of a family that should always be saved. The
2943 % macro works incrementally and avoids duplicate entries in the list.
2944 % \begin{macrocode}
2945 \def\savekeys{\XKV@stfalse\XKV@testoptb\XKV@savekeys}
2946 \def\gsavekeys{\XKV@sttrue\XKV@testoptb\XKV@savekeys}
2947 % \end{macrocode}
2948 % \end{macro}
2949 % \end{macro}
2950 % \begin{macro}{\XKV@savekeys}
2951 % \marg{key list}\\
2952 % Check whether something has been saved before. If not, start merging.
2953 % \begin{macrocode}
2954 \def\XKV@savekeys#1{%
2955 \XKV@ifundefined{XKV@\XKV@header save}{%
2956 \XKV@checksanitizeb{#1}\XKV@tempa
2957 \ifXKV@st\expandafter\global\fi\expandafter\def\csname XKV@%
2958 \XKV@header save\expandafter\endcsname\expandafter{\XKV@tempa}%
2959 }{%
2960 \expandafter\XKV@merge\csname XKV@\XKV@header
2961 save\endcsname{#1}\XKV@getsg
2962 }%
2963 }
2964 % \end{macrocode}
2965 % \end{macro}
2966 % \begin{macro}{\delsavekeys}
2967 % \begin{macro}{\gdelsavekeys}
2968 % \oarg{prefix}\marg{family}\\
2969 % Remove entries from the list of save keys.
2970 % \begin{macrocode}
2971 \def\delsavekeys{\XKV@stfalse\XKV@testoptb\XKV@delsavekeys}
2972 \def\gdelsavekeys{\XKV@sttrue\XKV@testoptb\XKV@delsavekeys}
2973 % \end{macrocode}
2974 % \end{macro}
2975 % \end{macro}
2976 % \begin{macro}{\XKV@delsavekeys}
2977 % \marg{key list}\\
2978 % Check whether save keys are defined and if yes, start deletion
2979 % algorithm. Use the macro |\XKV@getsg| to retrieve key names from
2980 % entries.
2981 % \begin{macrocode}
2982 \def\XKV@delsavekeys#1{%
2983 \XKV@ifundefined{XKV@\XKV@header save}{%
2984 \XKV@err{no save keys defined for `\XKV@header'}%
2985 }{%
2986 \expandafter\XKV@delete\csname XKV@\XKV@header
2987 save\endcsname{#1}\XKV@getsg
2988 }%
2989 }
2990 % \end{macrocode}
2991 % \end{macro}
2992 % \begin{macro}{\unsavekeys}
2993 % \begin{macro}{\gunsavekeys}
2994 % \oarg{prefix}\marg{family}\\
2995 % Similar to |\unpresetkeys|, but removes the `save keys list' for a
2996 % particular family.
2997 % \begin{macrocode}
2998 \def\unsavekeys{\XKV@stfalse\XKV@testoptb\XKV@unsavekeys}
2999 \def\gunsavekeys{\XKV@sttrue\XKV@testoptb\XKV@unsavekeys}
3000 % \end{macrocode}
3001 % \end{macro}
3002 % \end{macro}
3003 % \begin{macro}{\XKV@unsavekeys}
3004 % Workhorse for |\unsavekeys|.
3005 % \begin{macrocode}
3006 \def\XKV@unsavekeys{%
3007 \XKV@ifundefined{XKV@\XKV@header save}{%
3008 \XKV@err{no save keys defined for `\XKV@header'}%
3009 }{%
3010 \ifXKV@st\expandafter\global\fi\expandafter\let
3011 \csname XKV@\XKV@header save\endcsname\@undefined
3012 }%
3013 }
3014 % \end{macrocode}
3015 % \end{macro}
3016 % \begin{macro}{\setkeys}
3017 % |*+|\oarg{prefix}\marg{families}\\
3018 % Set keys. The starred version does not produce errors, but appends
3019 % keys that cannot be located to the list in |\XKV@rm|. The plus
3020 % version sets keys in all families that are supplied.
3021 % \begin{macrocode}
3022 \def\setkeys{\XKV@testopta{\XKV@testoptc\XKV@setkeys}}
3023 % \end{macrocode}
3024 % \end{macro}
3025 % \begin{macro}{\XKV@setkeys}
3026 % \oarg{na}\marg{key=value list}\\
3027 % \changes{v1.8a}{2004/12/20}{Solved small bug}
3028 % \changes{v2.5f}{2006/11/18}{Added reset of \cs{CurrentOption}}
3029 % \changes{v2.5g}{2006/12/19}{Avoid reset of \cs{XKV@rm} in nested \cs{setkeys} commands}
3030 % Workhorse for |\setkeys|.
3031 % \begin{macrocode}
3032 \long\def\XKV@setkeys[#1]#2{%
3033 \XKV@checksanitizea{#2}\XKV@resb
3034 \let\XKV@naa\@empty
3035 % \end{macrocode}
3036 % Retrieve a list of key names from the user input.
3037 % \begin{macrocode}
3038 \XKV@for@o\XKV@resb\XKV@tempa{%
3039 \expandafter\XKV@g@tkeyname\XKV@tempa=\@nil\XKV@tempa
3040 \XKV@addtolist@x\XKV@naa\XKV@tempa
3041 }%
3042 % \end{macrocode}
3043 % Initialize the remaining keys, but only for the outermost level of
3044 % |\setkeys|.
3045 % \begin{macrocode}
3046 \ifnum\XKV@depth=\z@\let\XKV@rm\@empty\fi
3047 % \end{macrocode}
3048 % Now scan the list of families for preset keys and set user input keys.
3049 % \begin{macrocode}
3050 \XKV@usepresetkeys{#1}{preseth}%
3051 \expandafter\XKV@s@tkeys\expandafter{\XKV@resb}{#1}%
3052 \XKV@usepresetkeys{#1}{presett}%
3053 \let\CurrentOption\@empty
3054 }
3055 % \end{macrocode}
3056 % \end{macro}
3057 % \begin{macro}{\XKV@usepresetkeys}
3058 % \marg{na}\marg{postfix}\\
3059 % Loop over the list of families and check them for preset keys. If
3060 % present, set them right away, taking into account the keys which
3061 % are set by the user, available in the |\XKV@naa| list.
3062 % \begin{macrocode}
3063 \def\XKV@usepresetkeys#1#2{%
3064 \XKV@presettrue
3065 \XKV@for@eo\XKV@fams\XKV@tfam{%
3066 \XKV@makehd\XKV@tfam
3067 \XKV@ifundefined{XKV@\XKV@header#2}{}{%
3068 \XKV@toks\expandafter\expandafter\expandafter
3069 {\csname XKV@\XKV@header#2\endcsname}%
3070 \@expandtwoargs\XKV@s@tkeys{\the\XKV@toks}%
3071 {\XKV@naa\ifx\XKV@naa\@empty\else,\fi#1}%
3072 }%
3073 }%
3074 \XKV@presetfalse
3075 }
3076 % \end{macrocode}
3077 % \end{macro}
3078 % \begin{macro}{\XKV@s@tkeys}
3079 % \marg{key=value list}\marg{na}\\
3080 % This macro starts the loop over the |key=value| list. Do not set
3081 % keys in the list \meta{na}.
3082 % \begin{macrocode}
3083 \long\def\XKV@s@tkeys#1#2{%
3084 % \end{macrocode}
3085 % Define the list of key names which should be ignored.
3086 % \begin{macrocode}
3087 \XKV@sp@deflist\XKV@na{#2}%
3088 % \end{macrocode}
3089 % Loop over the key=value list.
3090 % \begin{macrocode}
3091 \XKV@for@n{#1}\CurrentOption{%
3092 % \end{macrocode}
3093 % Split key and value.
3094 % \begin{macrocode}
3095 \expandafter\XKV@s@tk@ys\CurrentOption==\@nil
3096 }%
3097 }
3098 % \end{macrocode}
3099 % \end{macro}
3100 % \begin{macro}{\XKV@s@tk@ys}
3101 % \changes{v1.4}{2004/08/24}{Made macro more efficient}
3102 % \changes{v2.4}{2005/03/31}{Added \cs{global} to make \cs{XKV@rm}
3103 % survive when \cs{setkeys} executed in a group.}
3104 % \changes{v2.5g}{2006/12/19}{Removed \cs{global} again for consistent
3105 % approach of \cs{XKV@rm} and to allow groups to keep \cs{XKV@rm} local}
3106 % \meta{key}|=|\meta{value}|=#3\@nil|\\
3107 % Split key name and value (if present). If |#3| non-empty, there was
3108 % no |=|\meta{value}.
3109 % \begin{macrocode}
3110 \long\def\XKV@s@tk@ys#1=#2=#3\@nil{%
3111 % \end{macrocode}
3112 % Check for |\savevalue| and |\gsavevalue| and remove spaces from around the key name.
3113 % \begin{macrocode}
3114 \XKV@g@tkeyname#1=\@nil\XKV@tkey
3115 \expandafter\KV@@sp@def\expandafter\XKV@tkey\expandafter{\XKV@tkey}%
3116 % \end{macrocode}
3117 % If the key is empty and a value has been specified, generate an error.
3118 % \begin{macrocode}
3119 \ifx\XKV@tkey\@empty
3120 \XKV@toks{#2}%
3121 \ifcat$\the\XKV@toks$\else
3122 \XKV@err{no key specified for value `\the\XKV@toks'}%
3123 \fi
3124 \else
3125 % \end{macrocode}
3126 % If in the |\XKV@na| list, ignore the key.
3127 % \begin{macrocode}
3128 \@expandtwoargs\in@{,\XKV@tkey,}{,\XKV@na,}%
3129 \ifin@\else
3130 \XKV@knftrue
3131 \KV@@sp@def\XKV@tempa{#2}%
3132 \ifXKV@preset\XKV@s@tk@ys@{#3}\else
3133 \ifXKV@pl
3134 % \end{macrocode}
3135 % If a command with a |+| is used, set keys in all families on the
3136 % list.
3137 % \begin{macrocode}
3138 \XKV@for@eo\XKV@fams\XKV@tfam{%
3139 \XKV@makehd\XKV@tfam
3140 \XKV@s@tk@ys@{#3}%
3141 }%
3142 \else
3143 % \end{macrocode}
3144 % Else, scan the families on the list but stop when the key is found
3145 % or when the list has run out.
3146 % \begin{macrocode}
3147 \XKV@whilist\XKV@fams\XKV@tfam\ifXKV@knf\fi{%
3148 \XKV@makehd\XKV@tfam
3149 \XKV@s@tk@ys@{#3}%
3150 }%
3151 \fi
3152 \fi
3153 \ifXKV@knf
3154 \ifXKV@inpox
3155 % \end{macrocode}
3156 % We are in the options section. Try to use the macro defined by
3157 % |\DeclareOptionX*|.
3158 % \begin{macrocode}
3159 \ifx\XKV@doxs\relax
3160 % \end{macrocode}
3161 % For classes, ignore unknown (possibly global) options. For packages,
3162 % raise the standard \LaTeX\ error.
3163 % \begin{macrocode}
3164 \ifx\@currext\@clsextension\else
3165 \let\CurrentOption\XKV@tkey\@unknownoptionerror
3166 \fi
3167 % \end{macrocode}
3168 % Pass the option through |\DeclareOptionX*|.
3169 % \begin{macrocode}
3170 \else\XKV@doxs\fi
3171 \else
3172 % \end{macrocode}
3173 % If not in the options section, raise an error or add the key to the
3174 % list in |\XKV@rm| when |\setkeys*| has been used.
3175 % \begin{macrocode}
3176 \ifXKV@st
3177 \XKV@addtolist@o\XKV@rm\CurrentOption
3178 \else
3179 \XKV@err{`\XKV@tkey' undefined in families `\XKV@fams'}%
3180 \fi
3181 \fi
3182 \else
3183 % \end{macrocode}
3184 % Remove global options set by the document class from |\@unusedoptionlist|.
3185 % Global options set by other packages or classes will be removed by
3186 % |\ProcessOptionsX*|.
3187 % \begin{macrocode}
3188 \ifXKV@inpox\ifx\XKV@testclass\XKV@documentclass
3189 \expandafter\XKV@useoption\expandafter{\CurrentOption}%
3190 \fi\fi
3191 \fi
3192 \fi
3193 \fi
3194 }
3195 % \end{macrocode}
3196 % \end{macro}
3197 % \begin{macro}{\XKV@s@tk@ys@}
3198 % \marg{ind}\\
3199 % This macro coordinates the work of setting a key. \meta{ind} is an
3200 % indicator for the presence of a user submitted value for the key. If
3201 % empty, no value was present.
3202 % \begin{macrocode}
3203 \def\XKV@s@tk@ys@#1{%
3204 % \end{macrocode}
3205 % Check whether the key macro exists.
3206 % \begin{macrocode}
3207 \XKV@ifundefined{\XKV@header\XKV@tkey}{}{%
3208 \XKV@knffalse
3209 % \end{macrocode}
3210 % Check global setting by |\savekeys| to know whether or not to save
3211 % the value of the key at hand.
3212 % \begin{macrocode}
3213 \XKV@ifundefined{XKV@\XKV@header save}{}{%
3214 \expandafter\XKV@testsavekey\csname XKV@\XKV@header
3215 save\endcsname\XKV@tkey
3216 }%
3217 % \end{macrocode}
3218 % Save the value of a key.
3219 % \begin{macrocode}
3220 \ifXKV@rkv
3221 \ifXKV@sg\expandafter\global\fi\expandafter\let
3222 \csname XKV@\XKV@header\XKV@tkey @value\endcsname\XKV@tempa
3223 \fi
3224 % \end{macrocode}
3225 % Replace pointers by saved values.
3226 % \begin{macrocode}
3227 \expandafter\XKV@replacepointers\expandafter{\XKV@tempa}%
3228 % \end{macrocode}
3229 % If no value was present, use the default value macro, if one exists.
3230 % Otherwise, issue an error.
3231 % \begin{macrocode}
3232 \ifx\@empty#1\@empty\XKV@afterelsefi
3233 \XKV@ifundefined{\XKV@header\XKV@tkey @default}{%
3234 \XKV@err{no value specified for key `\XKV@tkey'}%
3235 }{%
3236 \expandafter\expandafter\expandafter\XKV@default
3237 \csname\XKV@header\XKV@tkey @default\endcsname\@nil
3238 }%
3239 \else\XKV@afterfi
3240 % \end{macrocode}
3241 % Save state in case the key executes |\setkeys| or |\XKV@cc|.
3242 % \begin{macrocode}
3243 \XKV@srstate{@\romannumeral\XKV@depth}{}%
3244 % \end{macrocode}
3245 % Execute the key.
3246 % \begin{macrocode}
3247 \csname\XKV@header\XKV@tkey\expandafter
3248 \endcsname\expandafter{\XKV@tempa}\relax
3249 % \end{macrocode}
3250 % Restore the current state.
3251 % \begin{macrocode}
3252 \XKV@srstate{}{@\romannumeral\XKV@depth}%
3253 \fi
3254 }%
3255 }
3256 % \end{macrocode}
3257 % \end{macro}
3258 % \begin{macro}{\XKV@testsavekey}
3259 % \meta{save key list}\meta{key name}\\
3260 % This macro checks whether the key in macro \meta{key name} appears in the
3261 % save list in macro \meta{save key list}. Furthermore, it checks whether or not to
3262 % save the key globally. In other words, that |\global{key}| is in
3263 % the list.
3264 % \begin{macrocode}
3265 \def\XKV@testsavekey#1#2{%
3266 \ifXKV@rkv\else
3267 \XKV@for@o#1\XKV@resa{%
3268 \expandafter\XKV@ifcmd\expandafter{\XKV@resa}\global\XKV@resa{%
3269 \ifx#2\XKV@resa
3270 \XKV@rkvtrue\XKV@sgtrue
3271 \fi
3272 }{%
3273 \ifx#2\XKV@resa
3274 \XKV@rkvtrue\XKV@sgfalse
3275 \fi
3276 }%
3277 }%
3278 \fi
3279 }
3280 % \end{macrocode}
3281 % \end{macro}
3282 % \begin{macro}{\XKV@replacepointers}
3283 % \begin{macro}{\XKV@r@placepointers}
3284 % \changes{v1.8d}{2005/01/02}{Added \cs{XKV@afterfi} to avoid capacity
3285 % problems when too many pointers present}
3286 % \changes{v1.9}{2005/01/16}{Added back linking test}
3287 % \changes{v2.0}{2005/01/30}{Simplified}
3288 % \changes{v2.7a}{2014/12/03}{Removed erroneous \cs{@empty}}
3289 % \marg{key=value list}\\
3290 % Replaces all pointers by their saved values. The result is stored in
3291 % |\XKV@tempa|. We feed the replacement and the following tokens again to the
3292 % macro to replace nested pointers. It stops when no pointers are
3293 % found anymore. We keep a list of pointers replaced already for this
3294 % key in |\XKV@resa| so we can check whether we are running in circles.
3295 % \begin{macrocode}
3296 \long\def\XKV@replacepointers#1{%
3297 \let\XKV@tempa\@empty
3298 \let\XKV@resa\@empty
3299 \XKV@r@placepointers#1\usevalue\@nil
3300 }
3301 \long\def\XKV@r@placepointers#1\usevalue#2{%
3302 \XKV@addtomacro@n\XKV@tempa{#1}%
3303 \def\XKV@tempb{#2}%
3304 \ifx\XKV@tempb\@nnil\else\XKV@afterfi
3305 \XKV@ifundefined{XKV@\XKV@header#2@value}{%
3306 \XKV@err{no value recorded for key `#2'; ignored}%
3307 \XKV@r@placepointers
3308 }{%
3309 \@expandtwoargs\in@{,#2,}{,\XKV@resa,}%
3310 \ifin@\XKV@afterelsefi
3311 \XKV@err{back linking pointers; pointer replacement canceled}%
3312 \else\XKV@afterfi
3313 \XKV@addtolist@x\XKV@resa{#2}%
3314 \expandafter\expandafter\expandafter\XKV@r@placepointers
3315 \csname XKV@\XKV@header#2@value\endcsname
3316 \fi
3317 }%
3318 \fi
3319 }
3320 % \end{macrocode}
3321 % \end{macro}
3322 % \end{macro}
3323 % \begin{macro}{\XKV@default}
3324 % \changes{v2.0}{2005/01/30}{Repaired adding extra braces when executing default value}
3325 % \meta{token}\meta{tokens}\\
3326 % This macro checks the |\prefix@fam@key@default| macro. If the macro
3327 % has the form as defined by \pf{keyval} or \pf{xkeyval}, it is
3328 % possible to extract the default value and safe that (if requested)
3329 % and replace pointers. If the form is incorrect, just execute the
3330 % macro and forget about possible pointers. The reason for this check
3331 % is that certain packages (like \pf{fancyvrb}) abuse the `default
3332 % value system' to execute code instead of setting keys by redefining
3333 % default value macros. These macros do not actually contain a
3334 % default value and trying to extract that would not work.
3335 % \begin{macrocode}
3336 \def\XKV@default#1#2\@nil{%
3337 % \end{macrocode}
3338 % Retrieve the first token in the macro.
3339 % \begin{macrocode}
3340 \expandafter\edef\expandafter\XKV@tempa
3341 \expandafter{\expandafter\@gobble\string#1}%
3342 % \end{macrocode}
3343 % Construct the name that we expect on the basis of the \pf{keyval}
3344 % and \pf{xkeyval} syntax of default values.
3345 % \begin{macrocode}
3346 \edef\XKV@tempb{\XKV@header\XKV@tkey}%
3347 % \end{macrocode}
3348 % Sanitize |\XKV@tempb| to reset catcodes for comparison with |\XKV@tempa|.
3349 % \begin{macrocode}
3350 \@onelevel@sanitize\XKV@tempb
3351 \ifx\XKV@tempa\XKV@tempb
3352 % \end{macrocode}
3353 % If it is safe, extract the value. We temporarily redefine the key
3354 % macro to save the default value in a macro. Saving the default value
3355 % itself directly to a macro when defining keys would of course be easier,
3356 % but a lot of packages rely on this system created by \pf{keyval}, so
3357 % we have to support it here.
3358 % \begin{macrocode}
3359 \begingroup
3360 \expandafter\def\csname\XKV@header\XKV@tkey\endcsname##1{%
3361 \gdef\XKV@tempa{##1}%
3362 }%
3363 \csname\XKV@header\XKV@tkey @default\endcsname
3364 \endgroup
3365 % \end{macrocode}
3366 % Save the default value to a value macro if either the key name has
3367 % been entered in a |\savekeys| macro or the starred form has been used.
3368 % \begin{macrocode}
3369 \XKV@ifundefined{XKV@\XKV@header save}{}{%
3370 \expandafter\XKV@testsavekey\csname XKV@\XKV@header
3371 save\endcsname\XKV@tkey
3372 }%
3373 \ifXKV@rkv
3374 \ifXKV@sg\expandafter\global\fi\expandafter\let
3375 \csname XKV@\XKV@header\XKV@tkey @value\endcsname\XKV@tempa
3376 \fi
3377 % \end{macrocode}
3378 % Replace the pointers.
3379 % \begin{macrocode}
3380 \expandafter\XKV@replacepointers\expandafter
3381 {\XKV@tempa}\XKV@afterelsefi
3382 % \end{macrocode}
3383 % Save internal state.
3384 % \begin{macrocode}
3385 \XKV@srstate{@\romannumeral\XKV@depth}{}%
3386 % \end{macrocode}
3387 % Execute the key with the (possibly changed) default value.
3388 % \begin{macrocode}
3389 \expandafter#1\expandafter{\XKV@tempa}\relax
3390 % \end{macrocode}
3391 % Restore internal state.
3392 % \begin{macrocode}
3393 \XKV@srstate{}{@\romannumeral\XKV@depth}%
3394 \else\XKV@afterfi
3395 % \end{macrocode}
3396 % Save internal state.
3397 % \begin{macrocode}
3398 \XKV@srstate{@\romannumeral\XKV@depth}{}%
3399 % \end{macrocode}
3400 % Execute the key with the default value.
3401 % \begin{macrocode}
3402 \csname\XKV@header\XKV@tkey @default\endcsname\relax
3403 % \end{macrocode}
3404 % Restore the state.
3405 % \begin{macrocode}
3406 \XKV@srstate{}{@\romannumeral\XKV@depth}%
3407 \fi
3408 }
3409 % \end{macrocode}
3410 % \end{macro}
3411 % \begin{macro}{\setrmkeys}
3412 % |*+|\oarg{prefix}\marg{families}\\
3413 % Set remaining keys stored in |\XKV@rm|. The starred version creates
3414 % a new list in |\XKV@rm| in case there are still keys that cannot
3415 % be located in the families specified. Care is taken again not to
3416 % expand fragile macros. Use |\XKV@testopa| again to handle optional
3417 % arguments.
3418 % \begin{macrocode}
3419 \def\setrmkeys{\XKV@testopta{\XKV@testoptc\XKV@setrmkeys}}
3420 % \end{macrocode}
3421 % \end{macro}
3422 % \begin{macro}{\XKV@setrmkeys}
3423 % \oarg{na}\\
3424 % Submits the keys in |\XKV@rm| to |\XKV@setkeys|.
3425 % \begin{macrocode}
3426 \def\XKV@setrmkeys[#1]{%
3427 \def\XKV@tempa{\XKV@setkeys[#1]}%
3428 \expandafter\XKV@tempa\expandafter{\XKV@rm}%
3429 }
3430 % \end{macrocode}
3431 % \end{macro}
3432 % Reset catcodes.
3433 % \begin{macrocode}
3434 \XKVcatcodes
3435 %</xkvtex>
3436 % \end{macrocode}
3437 % \subsection{\texttt{xkeyval.sty}}
3438 % \changes{v1.5}{2004/09/27}{Made macros avoid expansions of options}
3439 % Initialize the package.
3440 % \begin{macrocode}
3441 %<*xkvlatex>
3442 \NeedsTeXFormat{LaTeX2e}[1995/12/01]
3443 \ProvidesPackage{xkeyval}
3444 [2025/11/04 v2.10 package option processing (HA)]
3445 % \end{macrocode}
3446 % Initializations. Load |xkeyval.tex|, adjust some catcodes to define
3447 % internal macros and initialize the |\DeclareOptionX*| working macro.
3448 % \begin{macrocode}
3449 \ifx\XKeyValLoaded\endinput\else\input xkeyval \fi
3450 \edef\XKVcatcodes{%
3451 \catcode`\noexpand\=\the\catcode`\=\relax
3452 \catcode`\noexpand\,\the\catcode`\,\relax
3453 \let\noexpand\XKVcatcodes\relax
3454 }
3455 \catcode`\=12\relax
3456 \catcode`\,12\relax
3457 \let\XKV@doxs\relax
3458 % \end{macrocode}
3459 % \begin{macro}{\XKV@warn}
3460 % \begin{macro}{\XKV@err}
3461 % \changes{v2.8}{2020/11/20}{Removed path from search for options of the documentclass}
3462 % Warning and error macros.
3463 % \begin{macrocode}
3464 \def\XKV@warn#1{\PackageWarning{xkeyval}{#1}}
3465 \def\XKV@err#1{\PackageError{xkeyval}{#1}\@ehc}
3466 % \end{macrocode}
3467 % \end{macro}
3468 % \end{macro}
3469 % Retrieve the document class from |\@filelist|. This is the first
3470 % filename in the list with a class extension. Use a while loop to
3471 % scan the list and stop when we found the first filename which is
3472 % a class. Also stop in case the list is scanned fully.
3473 % \begin{macrocode}
3474 \XKV@whilist\@filelist\XKV@tempa\ifx\XKV@documentclass\@undefined\fi{%
3475 \filename@parse\XKV@tempa
3476 \ifx\filename@ext\@clsextension
3477 \XKV@ifundefined{opt@\filename@base.\filename@ext
3478 }{}{\edef\XKV@documentclass{\filename@base.\filename@ext}}%
3479 \fi
3480 }
3481 % \end{macrocode}
3482 % If we didn't find the document class, raise an error, otherwise
3483 % filter global options.
3484 % \begin{macrocode}
3485 \ifx\XKV@documentclass\@undefined
3486 \XKV@err{xkeyval loaded before \protect\documentclass}%
3487 \let\XKV@documentclass\@empty
3488 \let\XKV@classoptionslist\@empty
3489 \else
3490 \let\XKV@classoptionslist\@classoptionslist
3491 % \end{macrocode}
3492 % \changes{v1.4}{2004/08/24}{Fixed small bug in class option filtering}
3493 % Code to filter |key=value| pairs from |\@classoptionslist| without
3494 % expanding options.
3495 % \begin{macrocode}
3496 \def\XKV@tempa#1{%
3497 \let\@classoptionslist\@empty
3498 \XKV@for@n{#1}\XKV@tempa{%
3499 \expandafter\in@\expandafter=\expandafter{\XKV@tempa}%
3500 \ifin@\else\XKV@addtolist@o\@classoptionslist\XKV@tempa\fi
3501 }%
3502 }
3503 \expandafter\XKV@tempa\expandafter{\@classoptionslist}
3504 \fi
3505 % \end{macrocode}
3506 % \begin{macro}{\XKV@testopte}
3507 % \begin{macro}{\XKV@t@stopte}
3508 % \begin{macro}{\XKV@t@st@pte}
3509 % \changes{v1.9}{2005/01/16}{Added extension to default family}
3510 % \begin{macro}{\XKV@@t@st@pte}
3511 % \marg{function}\\
3512 % Macros for |\ExecuteOptionsX| and |\ProcessOptionsX| for testing for
3513 % optional arguments and inserting default values. Execute \meta{function}
3514 % after preforming the checks.
3515 % \begin{macrocode}
3516 \def\XKV@testopte#1{%
3517 \XKV@ifstar{\XKV@sttrue\XKV@t@stopte#1}{\XKV@stfalse\XKV@t@stopte#1}%
3518 }
3519 \def\XKV@t@stopte#1{\@testopt{\XKV@t@st@pte#1}{KV}}
3520 \def\XKV@t@st@pte#1[#2]{%
3521 \XKV@makepf{#2}%
3522 \@ifnextchar<{\XKV@@t@st@pte#1}%
3523 {\XKV@@t@st@pte#1<\@currname.\@currext>}%
3524 }
3525 \def\XKV@@t@st@pte#1<#2>{%
3526 \XKV@sp@deflist\XKV@fams{#2}%
3527 \@testopt#1{}%
3528 }
3529 % \end{macrocode}
3530 % \end{macro}
3531 % \end{macro}
3532 % \end{macro}
3533 % \end{macro}
3534 % Macros for class and package writers. These are mainly shortcuts to
3535 % |\define@key| and |\setkeys|. The \LaTeX\ macro |\@fileswith@pti@ns|
3536 % is set to generate an error. This is the case when a class or package
3537 % is loaded in between |\DeclareOptionX| and |\ProcessOptionsX| commands.
3538 % \begin{macro}{\DeclareOptionX}
3539 % |*|\\
3540 % Declare a package or class option.
3541 % \begin{macrocode}
3542 \def\DeclareOptionX{%
3543 \let\@fileswith@pti@ns\@badrequireerror
3544 \XKV@ifstar\XKV@dox\XKV@d@x
3545 }
3546 % \end{macrocode}
3547 % \end{macro}
3548 % \begin{macro}{\XKV@dox}
3549 % This macro defines |\XKV@doxs| to be used for unknown options.
3550 % \begin{macrocode}
3551 \long\def\XKV@dox#1{\XKV@toks{#1}\edef\XKV@doxs{\the\XKV@toks}}
3552 % \end{macrocode}
3553 % \end{macro}
3554 % \begin{macro}{\XKV@d@x}
3555 % \begin{macro}{\XKV@@d@x}
3556 % \changes{v1.9}{2005/01/16}{Added extension to default family}
3557 % \begin{macro}{\XKV@@@d@x}
3558 % \changes{v1.1}{2004/04/30}{Redefined to insert an empty default value
3559 % if none is present}
3560 % Insert default prefix and family name (which is the filename of the
3561 % class or package) and add empty default value if none present. Execute
3562 % |\define@key|.
3563 % \begin{macrocode}
3564 \def\XKV@d@x{\@testopt\XKV@@d@x{KV}}
3565 \def\XKV@@d@x[#1]{%
3566 \@ifnextchar<{\XKV@@@d@x[#1]}{\XKV@@@d@x[#1]<\@currname.\@currext>}%
3567 }
3568 \def\XKV@@@d@x[#1]<#2>#3{\@testopt{\define@key[#1]{#2}{#3}}{}}
3569 % \end{macrocode}
3570 % \end{macro}
3571 % \end{macro}
3572 % \end{macro}
3573 % \begin{macro}{\ExecuteOptionsX}
3574 % \oarg{prefix}\marg{families}\oarg{na}\marg{key=value list}\\
3575 % This macro sets keys to specified values and uses |\XKV@setkeys| to do
3576 % the job. Insert default prefix and family name if none provided. Use
3577 % |\XKV@t@stopte| to handle optional arguments and reset |\ifXKV@st|
3578 % and |\ifXKV@pl| first to avoid unexpected behavior when |\setkeys*+|
3579 % (or a friend) has been used before |\ExecuteOptionsX|.
3580 % \begin{macrocode}
3581 \def\ExecuteOptionsX{\XKV@stfalse\XKV@plfalse\XKV@t@stopte\XKV@setkeys}
3582 % \end{macrocode}
3583 % \end{macro}
3584 % \begin{macro}{\ProcessOptionsX}
3585 % \changes{v1.4}{2004/08/24}{Fixed macro for \cs{LoadClass} case}
3586 % |*|\oarg{prefix}\marg{families}\\
3587 % Processes class or package using \pf{xkeyval}. The starred version
3588 % copies class options submitted by the user as well, given that they
3589 % are defined in the local families which are passed to the macro. Use
3590 % |\XKV@testopte| to handle optional arguments.
3591 % \begin{macrocode}
3592 \def\ProcessOptionsX{\XKV@plfalse\XKV@testopte\XKV@pox}
3593 % \end{macrocode}
3594 % \end{macro}
3595 % \begin{macro}{\XKV@pox}
3596 % \oarg{na}\\
3597 % Workhorse for |\ProcessOptionsX| and |\ProcessOptionsX*|.
3598 % \begin{macrocode}
3599 \def\XKV@pox[#1]{%
3600 \let\XKV@tempa\@empty
3601 % \end{macrocode}
3602 % Set |\XKV@inpox|: indicates that we are in |\ProcessOptionsX| to
3603 % invoke a special routine in |\XKV@s@tkeys|.
3604 % \begin{macrocode}
3605 \XKV@inpoxtrue
3606 % \end{macrocode}
3607 % Set |\@fileswith@pti@ns| again in case no |\DeclareOptionX| has been
3608 % used. This will be used to identify a call to |\setkeys| from
3609 % |\ProcessOptionsX|.
3610 % \begin{macrocode}
3611 \let\@fileswith@pti@ns\@badrequireerror
3612 \edef\XKV@testclass{\@currname.\@currext}%
3613 % \end{macrocode}
3614 % If \pf{xkeyval} is loaded by the document class, initialize
3615 % |\@unusedoptionlist|.
3616 % \begin{macrocode}
3617 \ifx\XKV@testclass\XKV@documentclass
3618 \let\@unusedoptionlist\XKV@classoptionslist
3619 \XKV@ifundefined{[email protected]}{}{%
3620 \@onelevel@sanitize\@unusedoptionlist
3621 }%
3622 \else
3623 % \end{macrocode}
3624 % Else, if the starred version is used, copy global options in case
3625 % they are defined in local families. Do not execute this in the
3626 % document class to avoid setting keys twice.
3627 % \begin{macrocode}
3628 \ifXKV@st
3629 \def\XKV@tempb##1,{%
3630 \def\CurrentOption{##1}%
3631 \ifx\CurrentOption\@nnil\else
3632 \XKV@g@tkeyname##1=\@nil\CurrentOption
3633 \XKV@key@if@ndefined{\CurrentOption}{}{%
3634 % \end{macrocode}
3635 % If the option also exists in local families, add it to the list for
3636 % later use and remove it from |\@unusedoptionlist|.
3637 % \begin{macrocode}
3638 \XKV@useoption{##1}%
3639 \XKV@addtolist@n\XKV@tempa{##1}%
3640 }%
3641 \expandafter\XKV@tempb
3642 \fi
3643 }%
3644 \expandafter\XKV@tempb\XKV@classoptionslist,\@nil,%
3645 \fi
3646 \fi
3647 % \end{macrocode}
3648 % Add current package options to the list.
3649 % \begin{macrocode}
3650 \expandafter\XKV@addtolist@o\expandafter
3651 \XKV@tempa\csname opt@\@currname.\@currext\endcsname
3652 % \end{macrocode}
3653 % Set options. We can be certain that global options can be set since
3654 % the definitions of local options have been checked above. Note that
3655 % |\DeclareOptionX*| will not consume global options when
3656 % |\ProcessOptionsX*| is used.
3657 % \begin{macrocode}
3658 \def\XKV@tempb{\XKV@setkeys[#1]}%
3659 \expandafter\XKV@tempb\expandafter{\XKV@tempa}%
3660 % \end{macrocode}
3661 % Reset the macro created by |\DeclareOptionX*| to avoid processing
3662 % future unknown keys using |\XKV@doxs|.
3663 % \begin{macrocode}
3664 \let\XKV@doxs\relax
3665 % \end{macrocode}
3666 % Reset the |\XKV@rm| macro to avoid processing remaining options
3667 % with |\setrmkeys|.
3668 % \begin{macrocode}
3669 \let\XKV@rm\@empty
3670 % \end{macrocode}
3671 % Reset |\ifXKV@inpox|: not in |\ProcessOptionsX| anymore.
3672 % \begin{macrocode}
3673 \XKV@inpoxfalse
3674 % \end{macrocode}
3675 % Reset |\@fileswith@pti@ns| to allow loading of classes or packages
3676 % again.
3677 % \begin{macrocode}
3678 \let\@fileswith@pti@ns\@@fileswith@pti@ns
3679 \AtEndOfPackage{\let\@unprocessedoptions\relax}%
3680 }
3681 % \end{macrocode}
3682 % \end{macro}
3683 % \begin{macro}{\XKV@useoption}
3684 % \marg{option}\\
3685 % Removes an option from |\@unusedoptionlist|.
3686 % \changes{v2.9}{2022/06/16}{Fix for package options with braces}
3687 % \begin{macrocode}
3688 \def\XKV@useoption#1{%
3689 \def\XKV@resa{#1}%
3690 \XKV@ifundefined{[email protected]}{}{%
3691 \@onelevel@sanitize\XKV@resa
3692 }%
3693 \@expandtwoargs\@removeelement{\expandafter\@remove@eq@value\XKV@resa=\@nil}%
3694 {\@unusedoptionlist}\@unusedoptionlist
3695 }
3696 % \end{macrocode}
3697 % \end{macro}
3698 % \changes{v1.3}{2004/05/09}{Moved the options section to the end of
3699 % the package to allow it to use \pf{xkeyval} option macros}
3700 % The options section. Postponed to the end to allow for using
3701 % \pf{xkeyval} options macros. All options are silently ignored.
3702 % \begin{macrocode}
3703 \DeclareOptionX*{%
3704 \PackageWarning{xkeyval}{Unknown option `\CurrentOption'}%
3705 }
3706 \ProcessOptionsX
3707 % \end{macrocode}
3708 % Reset catcodes.
3709 % \begin{macrocode}
3710 \XKVcatcodes
3711 %</xkvlatex>
3712 % \end{macrocode}
3713 % \subsection{\texttt{keyval.tex}}
3714 % \changes{v1.4}{2004/08/24}{Added \pf{keyval} primitives}
3715 % \changes{v2.6 }{2008/08/10}{Added \cs{KV@def} to \texttt{keyval.tex}
3716 % as it is used by some packages}
3717 % Since the \pf{xkeyval} macros handle input in a very different way
3718 % than \pf{keyval} macros, it is not wise to redefine \pf{keyval}
3719 % primitives (like |\KV@do| and |\KV@split|) used by other packages
3720 % as a back door into |\setkeys|. Instead, we load the original
3721 % primitives here for compatibility to existing packages using (parts
3722 % of) \pf{keyval}. Most of the code is original, but slightly
3723 % adapted to \pf{xkeyval}. See the \pf{keyval} documentation for
3724 % information about the macros below.
3725 % \begin{macrocode}
3726 %<*xkvkeyval>
3727 %%
3728 %% Based on keyval.sty.
3729 %%
3730 \def\XKV@tempa#1{%
3731 \long\def\KV@@sp@def##1##2{%
3732 \futurelet\XKV@resa\KV@@sp@d##2\@nil\@nil#1\@nil\relax##1}%
3733 \long\def\KV@@sp@d{%
3734 \ifx\XKV@resa\@sptoken
3735 \expandafter\KV@@sp@b
3736 \else
3737 \expandafter\KV@@sp@b\expandafter#1%
3738 \fi}%
3739 \long\def\KV@@sp@b#1##1 \@nil{\KV@@sp@c##1}%
3740 }
3741 \XKV@tempa{ }
3742 \long\def\KV@@sp@c#1\@nil#2\relax#3{\XKV@toks{#1}\edef#3{\the\XKV@toks}}
3743 \long\def\KV@do#1,{%
3744 \ifx\relax#1\@empty\else
3745 \KV@split#1==\relax
3746 \expandafter\KV@do\fi}
3747 \long\def\KV@split#1=#2=#3\relax{%
3748 \KV@@sp@def\XKV@tempa{#1}%
3749 \ifx\XKV@tempa\@empty\else
3750 \expandafter\let\expandafter\XKV@tempc
3751 \csname\KV@prefix\XKV@tempa\endcsname
3752 \ifx\XKV@tempc\relax
3753 \XKV@err{`\XKV@tempa' undefined}%
3754 \else
3755 \ifx\@empty#3\@empty
3756 \KV@default
3757 \else
3758 \KV@@sp@def\XKV@tempb{#2}%
3759 \expandafter\XKV@tempc\expandafter{\XKV@tempb}\relax
3760 \fi
3761 \fi
3762 \fi}
3763 \def\KV@default{%
3764 \expandafter\let\expandafter\XKV@tempb
3765 \csname\KV@prefix\XKV@tempa @default\endcsname
3766 \ifx\XKV@tempb\relax
3767 \XKV@err{No value specified for key `\XKV@tempa'}%
3768 \else
3769 \XKV@tempb\relax
3770 \fi}
3771 \def\KV@def#1#2[#3]{%
3772 \long\@namedef{KV@#1@#2@default\expandafter}\expandafter
3773 {\csname KV@#1@#2\endcsname{#3}}%
3774 \long\@namedef{KV@#1@#2}##1}
3775 %</xkvkeyval>
3776 % \end{macrocode}
3777 % \subsection{\texttt{xkvtxhdr.tex}}
3778 % This section generates |xkvtxhdr.tex| which contains some standard
3779 % \LaTeX\ macros taken from |latex.ltx|. This will only be loaded
3780 % when not using |xkeyval.sty|.
3781 % \begin{macrocode}
3782 %<*xkvheader>
3783 %%
3784 %% Taken from latex.ltx.
3785 %%
3786 \message{2005/02/22 v1.1 xkeyval TeX header (HA)}
3787 \def\@nnil{\@nil}
3788 \def\@empty{}
3789 \def\newif#1{%
3790 \count@\escapechar \escapechar\m@ne
3791 \let#1\iffalse
3792 \@if#1\iftrue
3793 \@if#1\iffalse
3794 \escapechar\count@}
3795 \def\@if#1#2{%
3796 \expandafter\def\csname\expandafter\@gobbletwo\string#1%
3797 \expandafter\@gobbletwo\string#2\endcsname
3798 {\let#1#2}}
3799 \long\def\@ifnextchar#1#2#3{%
3800 \let\reserved@d=#1%
3801 \def\reserved@a{#2}%
3802 \def\reserved@b{#3}%
3803 \futurelet\@let@token\@ifnch}
3804 \def\@ifnch{%
3805 \ifx\@let@token\@sptoken
3806 \let\reserved@c\@xifnch
3807 \else
3808 \ifx\@let@token\reserved@d
3809 \let\reserved@c\reserved@a
3810 \else
3811 \let\reserved@c\reserved@b
3812 \fi
3813 \fi
3814 \reserved@c}
3815 \def\:{\let\@sptoken= } \: % this makes \@sptoken a space token
3816 \def\:{\@xifnch} \expandafter\def\: {\futurelet\@let@token\@ifnch}
3817 \let\kernel@ifnextchar\@ifnextchar
3818 \long\def\@testopt#1#2{%
3819 \kernel@ifnextchar[{#1}{#1[{#2}]}}
3820 \long\def\@firstofone#1{#1}
3821 \long\def \@gobble #1{}
3822 \long\def \@gobbletwo #1#2{}
3823 \def\@expandtwoargs#1#2#3{%
3824 \edef\reserved@a{\noexpand#1{#2}{#3}}\reserved@a}
3825 \edef\@backslashchar{\expandafter\@gobble\string\\}
3826 \newif\ifin@
3827 \def\in@#1#2{%
3828 \def\in@@##1#1##2##3\in@@{%
3829 \ifx\in@##2\in@false\else\in@true\fi}%
3830 \in@@#2#1\in@\in@@}
3831 \def\strip@prefix#1>{}
3832 \def \@onelevel@sanitize #1{%
3833 \edef #1{\expandafter\strip@prefix
3834 \meaning #1}%
3835 }
3836 %</xkvheader>
3837 % \end{macrocode}
3838 % \subsection{\texttt{xkvutils.tex}}
3839 % Avoid loading |xkvutils.tex| twice.
3840 % \begin{macrocode}
3841 %<*xkvutils>
3842 \csname XKeyValUtilsLoaded\endcsname
3843 \let\XKeyValUtilsLoaded\endinput
3844 \edef\XKeyValUtilsCatcodes{%
3845 \catcode`\noexpand\@\the\catcode`\@\relax
3846 \let\noexpand\XKeyValUtilsCatcodes\relax
3847 }
3848 \catcode`\@=11\relax
3849 % \end{macrocode}
3850 % This package uses a private token to avoid
3851 % conflicts with other packages that use \LaTeX\ scratch token registers
3852 % in key macro definitions (for instance, \pf{graphicx}, keys angle
3853 % and scale).
3854 % \changes{v2.10}{2025/11/04}{declare toks register latex2e/1652}
3855 % \begin{macrocode}
3856 \newtoks\XKV@toks
3857 \newtoks\XKV@tempa@toks
3858 \newtoks\XKV@tempb@toks
3859 % \end{macrocode}
3860 % \begin{macro}{\@firstoftwo}
3861 % \begin{macro}{\@secondoftwo}
3862 % Two utility macros from the |latex.ltx| needed for executing
3863 % |\XKV@ifundefined| in the sequel.
3864 % \begin{macrocode}
3865 \long\def\@firstoftwo#1#2{#1}
3866 \long\def\@secondoftwo#1#2{#2}
3867 % \end{macrocode}
3868 % \end{macro}
3869 % \end{macro}
3870 % \begin{macro}{\XKV@afterfi}
3871 % \begin{macro}{\XKV@afterelsefi}
3872 % Two utility macros to move execution of content of a conditional
3873 % branch after the |\fi|. This avoids nesting conditional structures
3874 % too deep.
3875 % \begin{macrocode}
3876 \long\def\XKV@afterfi#1\fi{\fi#1}
3877 \long\def\XKV@afterelsefi#1\else#2\fi{\fi#1}
3878 % \end{macrocode}
3879 % \end{macro}
3880 % \end{macro}
3881 % \begin{macro}{\XKV@ifundefined}
3882 % \changes{v1.8d}{2005/01/02}{Simplified definition by using \cs{XKV@afterelsefi}}
3883 % \changes{v2.0}{2005/01/30}{Made none \eTeX\ version not leave \cs{relax}}
3884 % \marg{csname}\marg{undefined}\marg{defined}\\
3885 % Executes \meta{undefined} if the control sequence with name \meta{csname}
3886 % is undefined, else it executes \meta{defined}. This macro uses
3887 % \eTeX\ if possible to avoid filling \TeX's hash when checking
3888 % control sequences like key macros in the rest of the package.
3889 % The use of |\XKV@afterelsefi| is necessary here to avoid \TeX\ picking up the
3890 % second |\fi| as end of the main conditional when |\ifcsname| is
3891 % undefined. For |\XKV@afterelsefi| this |\fi| is hidden in the
3892 % group used to define |\XKV@ifundefined| in branch of the case that
3893 % |\ifcsname| is defined. Notice the following. Both versions of the
3894 % macro leave the tested control sequence undefined. However, the
3895 % first version will execute \meta{undefined} if the control sequence
3896 % is undefined or |\relax|, whereas the second version will only
3897 % execute \meta{undefined} if the control sequence is undefined. This
3898 % is no problem for the applications in this package.
3899 % \begin{macrocode}
3900 \ifx\ifcsname\@undefined\XKV@afterelsefi
3901 \def\XKV@ifundefined#1{%
3902 \begingroup\expandafter\expandafter\expandafter\endgroup
3903 \expandafter\ifx\csname#1\endcsname\relax
3904 \expandafter\@firstoftwo
3905 \else
3906 \expandafter\@secondoftwo
3907 \fi
3908 }
3909 \else
3910 \def\XKV@ifundefined#1{%
3911 \ifcsname#1\endcsname
3912 \expandafter\@secondoftwo
3913 \else
3914 \expandafter\@firstoftwo
3915 \fi
3916 }
3917 \fi
3918 % \end{macrocode}
3919 % \end{macro}
3920 % Check whether \pf{keyval} has been loaded and if not, load
3921 % \pf{keyval} primitives and prevent \pf{keyval} from being loaded
3922 % after \pf{xkeyval}.
3923 % \begin{macrocode}
3924 \XKV@ifundefined{[email protected]}{
3925 \input keyval
3926 \expandafter\def\csname [email protected]\endcsname{1999/03/16}
3927 }{}
3928 % \end{macrocode}
3929 % \begin{macro}{\@ifnextcharacter}
3930 % \changes{v1.4}{2004/08/24}{Added robust next character check}
3931 % \begin{macro}{\@ifncharacter}
3932 % Check the next character independently of its catcode. This will be
3933 % used to safely perform |\@ifnextcharacter+| and
3934 % |\@ifnextcharacter*|. This avoids errors in case any other package
3935 % changes the catcode of these characters.\\ Contributed by Donald
3936 % Arseneau.
3937 % \begin{macrocode}
3938 \long\def\@ifnextcharacter#1#2#3{%
3939 \@ifnextchar\bgroup
3940 {\@ifnextchar{#1}{#2}{#3}}%
3941 {\@ifncharacter{#1}{#2}{#3}}%
3942 }
3943 \long\def\@ifncharacter#1#2#3#4{%
3944 \if\string#1\string#4%
3945 \expandafter\@firstoftwo
3946 \else
3947 \expandafter\@secondoftwo
3948 \fi
3949 {#2}{#3}#4%
3950 }
3951 % \end{macrocode}
3952 % \end{macro}
3953 % \end{macro}
3954 % \begin{macro}{\XKV@for@n}
3955 % \changes{v2.6 }{2008/08/10}{protecting assignments from \#}
3956 % \changes{v2.6a}{2008/08/13}{Use private scratch register}
3957 % \marg{list}\meta{cmd}\marg{function}\\
3958 % Fast for-loop. \meta{list} is not expanded. Entries of \meta{list}
3959 % will be stored in \meta{cmd} and at every iteration \meta{function}
3960 % is executed.\\
3961 % Contributed by Morten H\o gholm.
3962 % \begin{macrocode}
3963 \long\def\XKV@for@n#1#2#3{%
3964 \XKV@tempa@toks{#1}\edef#2{\the\XKV@tempa@toks}%
3965 \ifx#2\@empty
3966 \XKV@for@break
3967 \else
3968 \expandafter\XKV@f@r
3969 \fi
3970 #2{#3}#1,\@nil,%
3971 }
3972 % \end{macrocode}
3973 % \end{macro}
3974 % \begin{macro}{\XKV@f@r}
3975 % \changes{v2.6 }{2008/08/10}{protecting assignments from \#}
3976 % \changes{v2.6a}{2008/08/13}{Use private scratch register}
3977 % \meta{cmd}\marg{function}\meta{entry}|,|\\
3978 % Looping macro.
3979 % \begin{macrocode}
3980 \long\def\XKV@f@r#1#2#3,{%
3981 \XKV@tempa@toks{#3}\edef#1{\the\XKV@tempa@toks}%
3982 \ifx#1\@nnil
3983 \expandafter\@gobbletwo
3984 \else
3985 #2\expandafter\XKV@f@r
3986 \fi
3987 #1{#2}%
3988 }
3989 % \end{macrocode}
3990 % \end{macro}
3991 % \begin{macro}{\XKV@for@break}
3992 % \meta{text}|\@nil,|\\
3993 % Macro to stop the for-loop.
3994 % \begin{macrocode}
3995 \long\def\XKV@for@break #1\@nil,{\fi}
3996 % \end{macrocode}
3997 % \end{macro}
3998 % \begin{macro}{\XKV@for@o}
3999 % \meta{listcmd}\meta{cmd}\marg{function}\\
4000 % \meta{listcmd} is expanded once before starting the loop.
4001 % \begin{macrocode}
4002 \long\def\XKV@for@o#1{\expandafter\XKV@for@n\expandafter{#1}}
4003 % \end{macrocode}
4004 % \end{macro}
4005 % \begin{macro}{\XKV@for@en}
4006 % \marg{list}\meta{cmd}\marg{function}\\
4007 % As |\XKV@for@n|, but this macro will execute \meta{function} also
4008 % when \meta{list} is empty. This is done to support packages that use the `empty
4009 % family', like \pf{PSTricks}.
4010 % \begin{macrocode}
4011 \long\def\XKV@for@en#1#2#3{\XKV@f@r#2{#3}#1,\@nil,}
4012 % \end{macrocode}
4013 % \end{macro}
4014 % \begin{macro}{\XKV@for@eo}
4015 % \meta{listcmd}\meta{cmd}\marg{function}\\
4016 % As |\XKV@for@o|, but this macro will execute \meta{function} also
4017 % when \meta{listcmd} is empty.
4018 % \begin{macrocode}
4019 \long\def\XKV@for@eo#1#2#3{%
4020 \def#2{\XKV@f@r#2{#3}}\expandafter#2#1,\@nil,%
4021 }
4022 % \end{macrocode}
4023 % \end{macro}
4024 % \begin{macro}{\XKV@whilist}
4025 % \meta{listcmd}\meta{cmd}\meta{if}|\fi|\marg{function}\\
4026 % \changes{v1.5}{2004/09/27}{Changed behavior}
4027 % \meta{listcmd} is expanded once. Execution of \meta{function} stops when either
4028 % the list has ran out of elements or \meta{if} is not true anymore.
4029 % When using |\iftrue| for \meta{if}, the execution of the macro is the
4030 % same as that of |\XKV@for@o|, but contains an additional check at every
4031 % iteration and is
4032 % hence less efficient than |\XKV@for@o| in that situation.
4033 % \begin{macrocode}
4034 \long\def\XKV@whilist#1#2#3\fi#4{%
4035 % \end{macrocode}
4036 % Check whether the condition is true and start iteration.
4037 % \begin{macrocode}
4038 #3\expandafter\XKV@wh@list#1,\@nil,\@nil\@@#2#3\fi{#4}{}\fi
4039 }
4040 % \end{macrocode}
4041 % \end{macro}
4042 % \begin{macro}{\XKV@wh@list}
4043 % \changes{v1.6}{2004/10/05}{Added missing \%}
4044 % \changes{v1.9}{2005/01/16}{Made running command contain last used list entry at exit}
4045 % \changes{v2.4}{2005/03/31}{Avoid using grouping}
4046 % \meta{entry}|,|\meta{text}|\@@|\meta{cmd}\meta{if}|\fi|\marg{function}\marg{previous}\\
4047 % Performs iteration and checks extra condition. This macro is not
4048 % optimized for the case that the list contains a single element. At
4049 % the end of every iteration, the current \meta{entry} will be stored
4050 % in \meta{previous} for the next iteration. The previous entry is
4051 % necessary when stepping out of the loop.
4052 % \begin{macrocode}
4053 \long\def\XKV@wh@list#1,#2\@@#3#4\fi#5#6{%
4054 % \end{macrocode}
4055 % Define the running \meta{cmd}.
4056 % \begin{macrocode}
4057 \def#3{#1}%
4058 % \end{macrocode}
4059 % If we find the end of the list, stop.
4060 % \begin{macrocode}
4061 \ifx#3\@nnil
4062 \def#3{#6}\expandafter\XKV@wh@l@st
4063 \else
4064 % \end{macrocode}
4065 % If the condition is met, execute \meta{function} and continue.
4066 % Otherwise, define the running command to be the previous entry
4067 % (which inflicted the condition becoming false) and stop.
4068 % \begin{macrocode}
4069 #4%
4070 #5\expandafter\expandafter\expandafter\XKV@wh@list
4071 \else
4072 \def#3{#6}\expandafter\expandafter\expandafter\XKV@wh@l@st
4073 \fi
4074 \fi
4075 #2\@@#3#4\fi{#5}{#1}%
4076 }
4077 % \end{macrocode}
4078 % \end{macro}
4079 % \begin{macro}{\XKV@wh@l@st}
4080 % \meta{text}|\@@|\meta{cmd}\meta{if}|\fi|\marg{function}\marg{previous}\\
4081 % Macro to gobble remaining input.
4082 % \begin{macrocode}
4083 \long\def\XKV@wh@l@st#1\@@#2#3\fi#4#5{}
4084 % \end{macrocode}
4085 % \end{macro}
4086 % \begin{macro}{\XKV@addtomacro@n}
4087 % \changes{v2.6 }{2008/08/10}{protecting assignments from \#}
4088 % \changes{v2.6a}{2008/08/13}{Use private scratch register}
4089 % \meta{macro}\marg{content}\\
4090 % Adds \meta{content} to \meta{macro} without expanding it.
4091 % \begin{macrocode}
4092 \long\def\XKV@addtomacro@n#1#2{%
4093 \XKV@tempa@toks\expandafter{#1#2}%
4094 \edef#1{\the\XKV@tempa@toks}%
4095 }
4096 % \end{macrocode}
4097 % \end{macro}
4098 % \begin{macro}{\XKV@addtomacro@o}
4099 % \changes{v2.6 }{2008/08/10}{protecting assignments from \#}
4100 % \changes{v2.6a}{2008/08/13}{Use private scratch register}
4101 % \meta{macro}\marg{content}\\
4102 % Adds \meta{content} to \meta{macro} after expanding the first token
4103 % of \meta{content} once. Often used to add the content of a macro
4104 % to another macro.
4105 % \begin{macrocode}
4106 \def\XKV@addtomacro@o#1#2{%
4107 \expandafter\XKV@addtomacro@n\expandafter#1\expandafter{#2}%
4108 }
4109 % \end{macrocode}
4110 % \end{macro}
4111 % \begin{macro}{\XKV@addtolist@n}
4112 % \meta{cmd}\marg{content}\\
4113 % \changes{v1.8 }{2004/12/13}{Changed to respect groups}
4114 % \changes{v2.0}{2005/01/30}{Simplified}
4115 % Adds \meta{content} to the list in \meta{cmd} without expanding \meta{content}.
4116 % Notice that it is assumed that \meta{cmd} is not undefined.
4117 % \begin{macrocode}
4118 \def\XKV@addtolist@n#1#2{%
4119 \ifx#1\@empty
4120 \XKV@addtomacro@n#1{#2}%
4121 \else
4122 \XKV@addtomacro@n#1{,#2}%
4123 \fi
4124 }
4125 % \end{macrocode}
4126 % \end{macro}
4127 % \begin{macro}{\XKV@addtolist@o}
4128 % \meta{cmd}\marg{content}\\
4129 % \changes{v2.0}{2005/01/30}{Simplified}
4130 % Adds \meta{content} to the list in \meta{cmd} after expanding the
4131 % first token in \meta{content} once.
4132 % \begin{macrocode}
4133 \def\XKV@addtolist@o#1#2{%
4134 \ifx#1\@empty
4135 \XKV@addtomacro@o#1#2%
4136 \else
4137 \XKV@addtomacro@o#1{\expandafter,#2}%
4138 \fi
4139 }
4140 % \end{macrocode}
4141 % \end{macro}
4142 % \begin{macro}{\XKV@addtolist@x}
4143 % \meta{cmd}\marg{content}\\
4144 % Adds \meta{content} to the list in \meta{cmd} after a full expansion
4145 % of both \meta{cmd} and \meta{content}.
4146 % \begin{macrocode}
4147 \def\XKV@addtolist@x#1#2{\edef#1{#1\ifx#1\@empty\else,\fi#2}}
4148 % \end{macrocode}
4149 % \end{macro}
4150 % \begin{macro}{\@selective@sanitize}
4151 % \begin{macro}{\@s@lective@sanitize}
4152 % \changes{v2.5a}{2005/05/31}{Added missing `\%'}
4153 % \changes{v2.6 }{2008/08/10}{protecting assignments from \#}
4154 % \changes{v2.6a}{2008/08/13}{Use private scratch register}
4155 % \oarg{level}\marg{character string}\marg{cmd}\\
4156 % Converts selected characters, given by \meta{character string},
4157 % within the first-level expansion of \meta{cmd} to category code~12,
4158 % leaving all other tokens (including grouping braces) untouched.
4159 % Thus, macros inside \meta{cmd} do not lose their function, as it is
4160 % the case with |\@onelevel@sanitize|.
4161 % The resulting token list is again saved in \meta{cmd}.\\
4162 % Example: |\def\cs{ ^{\fi}~}| and |\@selective@sanitize{!^}\cs| will
4163 % change the catcode of `|^|' to \emph{other}
4164 % within |\cs|, while |\fi| and `|~|' will remain unchanged.
4165 % As the example shows, unbalanced conditionals are allowed.\\
4166 % Remarks: \meta{cmd} should not contain the control sequence |\bgroup|;
4167 % however, |\csname| |bgroup\endcsname| and |\egroup| are possible.
4168 % The optional \meta{level} command controls up to which nesting
4169 % level sanitizing takes place inside groups; |0| will only sanitize
4170 % characters in the top level, |1| will also sanitize within the first
4171 % level of braces (but not in the second), etc.
4172 % The default value is |10000|.
4173 % \begin{macrocode}
4174 \def\@selective@sanitize{\@testopt\@s@lective@sanitize\@M}
4175 \def\@s@lective@sanitize[#1]#2#3{%
4176 \begingroup
4177 \count@#1\relax\advance\count@\@ne
4178 \XKV@toks\expandafter{#3}%
4179 \def#3{#2}\@onelevel@sanitize#3%
4180 \edef#3{{#3}{\the\XKV@toks}}%
4181 \expandafter\@s@l@ctive@sanitize\expandafter#3#3%
4182 \expandafter\XKV@tempa@toks\expandafter{#3}%
4183 \expandafter\endgroup\expandafter\XKV@tempb@toks\expandafter{\the\XKV@tempa@toks}%
4184 \edef#3{\the\XKV@tempb@toks}%
4185 }
4186 % \end{macrocode}
4187 % \end{macro}
4188 % \end{macro}
4189 % \begin{macro}{\@s@l@ctive@sanitize}
4190 % \changes{v1.8 }{2004/12/13}{Bug fixed, added level control}
4191 % \marg{cmd}\marg{sanitized character string}\marg{token list}\\
4192 % Performs the main work.
4193 % Here, the characters in \meta{sanitized character string} are already
4194 % converted to catcode~12, \meta{token list} is the first-level expansion
4195 % of the original contents of \meta{cmd}.
4196 % The macro basically steps through the \meta{token list}, inspecting
4197 % each single token to decide whether it has to be sanitized or passed
4198 % to the result list.
4199 % Special care has to be taken to detect spaces, grouping characters
4200 % and conditionals (the latter may disturb other expressions).
4201 % However, it is easier and more efficient to look for \TeX{}
4202 % primitives in general -- which are characterized by a |\meaning|
4203 % that starts with a backslash -- than to test whether a token equals
4204 % specifically |\if|, |\else|, |\fi|, etc.
4205 % Note that |\@s@l@ctive@sanitize| is being called recursively if
4206 % \meta{token list} contains grouping braces.
4207 % \begin{macrocode}
4208 \def\@s@l@ctive@sanitize#1#2#3{%
4209 \def\@i{\futurelet\@@tok\@ii}%
4210 \def\@ii{%
4211 \expandafter\@iii\meaning\@@tok\relax
4212 \ifx\@@tok\@s@l@ctive@sanitize
4213 \let\@@cmd\@gobble
4214 \else
4215 \ifx\@@tok\@sptoken
4216 \XKV@toks\expandafter{#1}\edef#1{\the\XKV@toks\space}%
4217 \def\@@cmd{\afterassignment\@i\let\@@tok= }%
4218 \else
4219 \let\@@cmd\@iv
4220 \fi
4221 \fi
4222 \@@cmd
4223 }%
4224 \def\@iii##1##2\relax{\if##1\@backslashchar\let\@@tok\relax\fi}%
4225 \def\@iv##1{%
4226 \toks@\expandafter{#1}\XKV@toks{##1}%
4227 \ifx\@@tok\bgroup
4228 \advance\count@\m@ne
4229 \ifnum\count@>\z@
4230 \begingroup
4231 \def#1{\expandafter\@s@l@ctive@sanitize
4232 \csname\string#1\endcsname{#2}}%
4233 \expandafter#1\expandafter{\the\XKV@toks}%
4234 \XKV@toks\expandafter\expandafter\expandafter
4235 {\csname\string#1\endcsname}%
4236 \edef#1{\noexpand\XKV@toks{\the\XKV@toks}}%
4237 \expandafter\endgroup#1%
4238 \fi
4239 \edef#1{\the\toks@{\the\XKV@toks}}%
4240 \advance\count@\@ne
4241 \let\@@cmd\@i
4242 \else
4243 \edef#1{\expandafter\string\the\XKV@toks}%
4244 \expandafter\in@\expandafter{#1}{#2}%
4245 \edef#1{\the\toks@\ifin@#1\else
4246 \ifx\@@tok\@sptoken\space\else\the\XKV@toks\fi\fi}%
4247 \edef\@@cmd{\noexpand\@i\ifx\@@tok\@sptoken\the\XKV@toks\fi}%
4248 \fi
4249 \@@cmd
4250 }%
4251 \let#1\@empty\@i#3\@s@l@ctive@sanitize
4252 }
4253 % \end{macrocode}
4254 % \end{macro}
4255 % \begin{macro}{\XKV@checksanitizea}
4256 % \marg{content}\meta{cmd}\\
4257 % Check whether \meta{content}, to be saved to macro \meta{cmd} unexpanded,
4258 % contains the characters |=| or |,| with wrong catcodes. If so, it sanitizes
4259 % them before saving \meta{content} to \meta{cmd}.
4260 % \begin{macrocode}
4261 \long\def\XKV@checksanitizea#1#2{%
4262 \XKV@ch@cksanitize{#1}#2=%
4263 \ifin@\else\XKV@ch@cksanitize{#1}#2,\fi
4264 \ifin@\@selective@sanitize[0]{,=}#2\fi
4265 }
4266 % \end{macrocode}
4267 % \end{macro}
4268 % \begin{macro}{\XKV@checksanitizeb}
4269 % \marg{content}\meta{cmd}\\
4270 % Similar to |\XKV@checksanitizea|, but only checks commas.
4271 % \begin{macrocode}
4272 \def\XKV@checksanitizeb#1#2{%
4273 \XKV@ch@cksanitize{#1}#2,%
4274 \ifin@\@selective@sanitize[0],#2\fi
4275 }
4276 % \end{macrocode}
4277 % \end{macro}
4278 % \begin{macro}{\XKV@ch@cksanitize}
4279 % \changes{v1.8b}{2004/12/22}{Fixed bug for key value \cs{@empty}}
4280 % \changes{v2.6 }{2008/08/10}{protecting assignments from \#}
4281 % \changes{v2.6a}{2008/08/13}{Use private scratch register}
4282 % \marg{character string}\meta{cmd}\meta{token}\\
4283 % This macro first checks whether at least one \meta{token} is in \meta{character string}.
4284 % If that is the case, it checks whether the character has catcode 12.
4285 % Note that the macro will conclude that the character does not have
4286 % catcode 12 when it is used inside a group |{}|, but that is not a
4287 % problem, as we don't expect \meta{token} (namely |,| or |=|) inside
4288 % a group, unless this group is in a key value. But we won't worry about
4289 % those characters anyway since the relevant user key macro will have to
4290 % process that. Further, it is assumed that all occurrences of \meta{token}
4291 % in \meta{character string} have the same catcode. \meta{cmd} is used
4292 % as a temporary macro and will contain \meta{character string} at the
4293 % end of the macro.
4294 % \begin{macrocode}
4295 \long\def\XKV@ch@cksanitize#1#2#3{%
4296 \XKV@tempa@toks{#1}\edef#2{\the\XKV@tempa@toks}%
4297 \@onelevel@sanitize#2%
4298 % \end{macrocode}
4299 % Check whether there is at least one |=| present.
4300 % \begin{macrocode}
4301 \@expandtwoargs\in@#3{#2}%
4302 \ifin@
4303 % \end{macrocode}
4304 % If so, try to find it. If we can't find it, the character(s) has (or
4305 % have) the wrong catcode. In that case sanitizing is necessary. This
4306 % actually occurs, because the input was read by \TeX\
4307 % before (and for instance stored in a macro or token register).
4308 % \begin{macrocode}
4309 \long\def#2##1#3##2\@nil{%
4310 \XKV@tempa@toks{##2}\edef#2{\the\XKV@tempa@toks}%
4311 \ifx#2\@empty\else\in@false\fi
4312 }%
4313 #2#1#3\@nil
4314 \fi
4315 \XKV@tempa@toks{#1}\edef#2{\the\XKV@tempa@toks}%
4316 }
4317 % \end{macrocode}
4318 % \end{macro}
4319 % \begin{macro}{\XKV@sp@deflist}
4320 % \changes{v1.8a}{2004/12/20}{Modified to respect the empty family}
4321 % \meta{cmd}\marg{token list}\\
4322 % Defines \meta{cmd} as \meta{token list} after removing spaces surrounding
4323 % elements of the list in \meta{token list}. So, |keya, key b| becomes
4324 % |keya,key b|. This is used to remove spaces from around elements in
4325 % a list. Using |\zap@space| for this job, would also remove the
4326 % spaces inside elements and hence changing key or family names with
4327 % spaces. This method is slower, but does allow for spaces in key and
4328 % family names, just as \pf{keyval} did. We need this algorithm at
4329 % several places to be able to perform |\in@{,key,}{,...,}|, without
4330 % having to worry about spaces in between commas and key names.
4331 % \begin{macrocode}
4332 \def\XKV@sp@deflist#1#2{%
4333 \let#1\@empty
4334 \XKV@for@n{#2}\XKV@resa{%
4335 \expandafter\KV@@sp@def\expandafter\XKV@resa\expandafter{\XKV@resa}%
4336 \XKV@addtomacro@o#1{\expandafter,\XKV@resa}%
4337 }%
4338 \ifx#1\@empty\else
4339 \def\XKV@resa,##1\@nil{\def#1{##1}}%
4340 \expandafter\XKV@resa#1\@nil
4341 \fi
4342 }
4343 % \end{macrocode}
4344 % \end{macro}
4345 % \begin{macro}{\XKV@merge}
4346 % \changes{v1.8 }{2004/12/13}{Simplified}
4347 % \meta{list}\marg{new items}\meta{filter}\\
4348 % This is a merging macro. For a given new item, the old
4349 % items are scanned. If an old item key name matches with a new
4350 % one, the new one will replace the old one. If not, the old one will
4351 % be appended (and might be overwritten in a following loop). If, at
4352 % the end of the old item loop the new item has not been used, it
4353 % will be appended to the end of the list. This macro works irrespective
4354 % of special syntax. The \meta{filter} is used to filter the key name
4355 % from the syntax, eg |\global{key}|. All occurrences of a particulary key
4356 % in the existing list will be overwritten by the new item. This macro
4357 % is used to make |\savekeys| and |\presetkeys| incremental. The
4358 % \meta{filter} is |\XKV@getsg| and |\XKV@getkeyname| respectively.
4359 % \begin{macrocode}
4360 \def\XKV@merge#1#2#3{%
4361 \XKV@checksanitizea{#2}\XKV@tempa
4362 % \end{macrocode}
4363 % Start the loop over the new presets. At every iteration, one new preset
4364 % will be compared with old presets.
4365 % \begin{macrocode}
4366 \XKV@for@o\XKV@tempa\XKV@tempa{%
4367 \XKV@pltrue
4368 % \end{macrocode}
4369 % Retrieve the key name of the new item at hand.
4370 % \begin{macrocode}
4371 #3\XKV@tempa\XKV@tempb
4372 % \end{macrocode}
4373 % Store the (partially updated) old list in a temp macro and empty
4374 % the original macro.
4375 % \begin{macrocode}
4376 \let\XKV@tempc#1%
4377 \let#1\@empty
4378 % \end{macrocode}
4379 % Start a loop over the old list.
4380 % \begin{macrocode}
4381 \XKV@for@o\XKV@tempc\XKV@tempc{%
4382 % \end{macrocode}
4383 % Retrieve the key name of the old key at hand.
4384 % \begin{macrocode}
4385 #3\XKV@tempc\XKV@tempd
4386 \ifx\XKV@tempb\XKV@tempd
4387 % \end{macrocode}
4388 % If the key names are equal, append the new item to the list
4389 % and record that this key should not be added to the end of the
4390 % presets list.
4391 % \begin{macrocode}
4392 \XKV@plfalse
4393 \XKV@addtolist@o#1\XKV@tempa
4394 \else
4395 % \end{macrocode}
4396 % If the key names are not equal, then just append the current item
4397 % to the list.
4398 % \begin{macrocode}
4399 \XKV@addtolist@o#1\XKV@tempc
4400 \fi
4401 }%
4402 % \end{macrocode}
4403 % If, after checking the old item, no old item has been overwritten
4404 % then append the new item to the end of the existing list.
4405 % \begin{macrocode}
4406 \ifXKV@pl\XKV@addtolist@o#1\XKV@tempa\fi
4407 }%
4408 % \end{macrocode}
4409 % If requested, save the new list globally.
4410 % \begin{macrocode}
4411 \ifXKV@st\global\let#1#1\fi
4412 }
4413 % \end{macrocode}
4414 % \end{macro}
4415 % \begin{macro}{\XKV@delete}
4416 % \meta{list}\marg{delete}\meta{filter}\\
4417 % Delete entries \meta{delete} by key name from a \meta{list} of presets
4418 % or save keys using \meta{filter}. For |\delpresetkeys|,
4419 % this is the macro |\XKV@getkeyname| and for |\delsavekeys|, it is
4420 % the macro |\XKV@getsg|.
4421 % \begin{macrocode}
4422 \def\XKV@delete#1#2#3{%
4423 % \end{macrocode}
4424 % Sanitize comma's.
4425 % \begin{macrocode}
4426 \XKV@checksanitizeb{#2}\XKV@tempa
4427 % \end{macrocode}
4428 % Copy the current list and make the original empty.
4429 % \begin{macrocode}
4430 \let\XKV@tempb#1%
4431 \let#1\@empty
4432 % \end{macrocode}
4433 % Run over the current list.
4434 % \begin{macrocode}
4435 \XKV@for@o\XKV@tempb\XKV@tempb{%
4436 % \end{macrocode}
4437 % Get the key name to identify the current entry.
4438 % \begin{macrocode}
4439 #3\XKV@tempb\XKV@tempc
4440 % \end{macrocode}
4441 % If the current key name is in the list, do not add it anymore.
4442 % \begin{macrocode}
4443 \@expandtwoargs\in@{,\XKV@tempc,}{,\XKV@tempa,}%
4444 \ifin@\else\XKV@addtolist@o#1\XKV@tempb\fi
4445 }%
4446 % \end{macrocode}
4447 % Save globally is necessary.
4448 % \begin{macrocode}
4449 \ifXKV@st\global\let#1#1\fi
4450 }
4451 % \end{macrocode}
4452 % \end{macro}
4453 % Finalize.
4454 % \begin{macrocode}
4455 \XKeyValUtilsCatcodes
4456 %</xkvutils>
4457 % \end{macrocode}
4458 % \subsection{\texttt{xkvview.sty}}
4459 % This section provides a small utility for package developers. It
4460 % provides several macros to generate overviews of the keys that are
4461 % defined in a package or a collection of packages. It is possible
4462 % to get an overview for a specific family, but also to get a complete
4463 % overview of all keys that have been defined after loading this
4464 % package.
4465 % \begin{macrocode}
4466 %<*xkvview>
4467 \NeedsTeXFormat{LaTeX2e}[1995/12/01]
4468 \ProvidesPackage{xkvview}%
4469 [2008/08/10 v1.5 viewer utility for xkeyval (HA)]
4470 \RequirePackage{xkeyval}
4471 \RequirePackage{longtable}
4472 \DeclareOptionX*{%
4473 \PackageWarning{xkvview}{Unknown option `\CurrentOption'}%
4474 }
4475 \ProcessOptionsX
4476 % \end{macrocode}
4477 % Initializations.
4478 % \begin{macrocode}
4479 \newif\ifXKVV@vwkey
4480 \newif\ifXKVV@colii
4481 \newif\ifXKVV@coliii
4482 \newif\ifXKVV@coliv
4483 \newif\ifXKVV@colv
4484 \newwrite\XKVV@out
4485 \let\XKVV@db\@empty
4486 % \end{macrocode}
4487 % Setup options and presets.
4488 % \begin{macrocode}
4489 \define@cmdkeys[XKVV]{xkvview}[XKVV@]{%
4490 prefix,family,type,default,file,columns,wcolsep,weol}[\@nil]
4491 \define@boolkeys[XKVV]{xkvview}[XKVV@]{view,vlabels,wlabels}[true]
4492 \presetkeys[XKVV]{xkvview}{prefix,family,type,default,file,%
4493 columns,wcolsep=&,weol=\\,view,vlabels=false,wlabels=false}{}
4494 % \end{macrocode}
4495 % \begin{macro}{\XKVV@tabulate}
4496 % \begin{macro}{\XKVV@t@bulate}
4497 % \changes{v2.6 }{2008/08/10}{Solved bug occurring with empty prefix}
4498 % \marg{key}\marg{type}\marg{default}\\
4499 % Adds the input information to the main database in |\XKVV@db|.
4500 % \begin{macrocode}
4501 \def\XKVV@tabulate#1#2#3{%
4502 \def\XKV@tempa{#3}%
4503 \@onelevel@sanitize\XKV@tempa
4504 \XKV@addtolist@x\XKVV@db{#1=\ifx\XKV@prefix\@empty\else\expandafter
4505 \XKVV@t@bulate\XKV@prefix\fi=\XKV@tfam=#2=\XKV@tempa}%
4506 }
4507 \def\XKVV@t@bulate#1@{#1}
4508 % \end{macrocode}
4509 % \end{macro}
4510 % \end{macro}
4511 % \begin{macro}{\XKV@define@key}
4512 % \begin{macro}{\XKV@d@fine@k@y}
4513 % \begin{macro}{\XKV@define@cmdkey}
4514 % \changes{v2.5c}{2005/07/10}{Avoid initializing control sequence as \cs{relax}}
4515 % \begin{macro}{\XKV@d@fine@ch@icekey}
4516 % \begin{macro}{\XKV@d@fine@ch@ic@key}
4517 % \begin{macro}{\XKV@d@f@ne@b@olkey}
4518 % Redefine the internals of key defining macros to record information
4519 % in the database.
4520 % \begin{macrocode}
4521 \def\XKV@define@key#1{%
4522 \@ifnextchar[{\XKV@d@fine@k@y{#1}}{%
4523 \XKVV@tabulate{#1}{ordinary}{[none]}%
4524 \expandafter\def\csname\XKV@header#1\endcsname####1%
4525 }%
4526 }
4527 \def\XKV@d@fine@k@y#1[#2]{%
4528 \XKVV@tabulate{#1}{ordinary}{#2}%
4529 \XKV@define@default{#1}{#2}%
4530 \expandafter\def\csname\XKV@header#1\endcsname##1%
4531 }
4532 \def\XKV@define@cmdkey#1#2[#3]#4{%
4533 \ifXKV@st
4534 \XKVV@tabulate{#2}{command}{#3}%
4535 \XKV@define@default{#2}{#3}%
4536 \else
4537 \XKVV@tabulate{#2}{command}{[none]}%
4538 \fi
4539 \def\XKV@tempa{\expandafter\def\csname\XKV@header#2\endcsname####1}%
4540 \begingroup\expandafter\endgroup\expandafter\XKV@tempa\expandafter
4541 {\expandafter\def\csname#1#2\endcsname{##1}#4}%
4542 }
4543 \def\XKV@d@fine@ch@icekey#1[#2]{%
4544 \XKVV@tabulate{#1}{choice}{#2}%
4545 \XKV@define@default{#1}{#2}%
4546 \XKV@d@fine@ch@ic@key{#1}%
4547 }
4548 \def\XKV@d@fine@ch@ic@key#1{%
4549 \XKVV@tabulate{#1}{choice}{[none]}%
4550 \ifXKV@pl\XKV@afterelsefi
4551 \expandafter\XKV@d@f@ne@ch@ic@k@y
4552 \else\XKV@afterfi
4553 \expandafter\XKV@d@f@ne@ch@ic@key
4554 \fi
4555 \csname\XKV@header#1\endcsname
4556 }
4557 \def\XKV@d@f@ne@b@olkey#1#2#3#4#5{%
4558 \expandafter\newif\csname if#3\endcsname
4559 \ifXKV@st
4560 \XKVV@tabulate{#2}{boolean}{#4}%
4561 \XKV@define@default{#2}{#4}%
4562 \else
4563 \XKVV@tabulate{#2}{boolean}{[none]}%
4564 \fi
4565 \ifXKV@pl
4566 \def#1##1{\XKV@pltrue\XKV@sttrue
4567 \XKV@checkchoice[\XKV@resa]{##1}{true,false}#5%
4568 }%
4569 \else
4570 \def#1##1{\XKV@plfalse\XKV@sttrue
4571 \XKV@checkchoice[\XKV@resa]{##1}{true,false}#5%
4572 }%
4573 \fi
4574 }
4575 % \end{macrocode}
4576 % \end{macro}
4577 % \end{macro}
4578 % \end{macro}
4579 % \end{macro}
4580 % \end{macro}
4581 % \end{macro}
4582 % \begin{macro}{\xkvview}
4583 % \marg{options}\\
4584 % The main macro. Produces a long table and/or writes to a target file.
4585 % \begin{macrocode}
4586 \def\xkvview#1{%
4587 % \end{macrocode}
4588 % Process all options.
4589 % \begin{macrocode}
4590 \setkeys[XKVV]{xkvview}{#1}%
4591 \ifx\XKVV@default\@nnil\else\@onelevel@sanitize\XKVV@default\fi
4592 % \end{macrocode}
4593 % If no column information, display all columns.
4594 % \begin{macrocode}
4595 \ifx\XKVV@columns\@nnil
4596 \count@5
4597 \XKVV@coliitrue\XKVV@coliiitrue\XKVV@colivtrue\XKVV@colvtrue
4598 \else
4599 % \end{macrocode}
4600 % Check how much and which columns should be displayed.
4601 % \begin{macrocode}
4602 \count@\@ne
4603 \@expandtwoargs\in@{,prefix,}{,\XKVV@columns,}%
4604 \ifin@\advance\count@\@ne\XKVV@coliitrue\else\XKVV@coliifalse\fi
4605 \@expandtwoargs\in@{,family,}{,\XKVV@columns,}%
4606 \ifin@\advance\count@\@ne\XKVV@coliiitrue\else\XKVV@coliiifalse\fi
4607 \@expandtwoargs\in@{,type,}{,\XKVV@columns,}%
4608 \ifin@\advance\count@\@ne\XKVV@colivtrue\else\XKVV@colivfalse\fi
4609 \@expandtwoargs\in@{,default,}{,\XKVV@columns,}%
4610 \ifin@\advance\count@\@ne\XKVV@colvtrue\else\XKVV@colvfalse\fi
4611 \fi
4612 \ifXKVV@view
4613 % \end{macrocode}
4614 % Construct long table header.
4615 % \begin{macrocode}
4616 \protected@edef\XKV@tempa{\noexpand\begin{longtable}[l]{%
4617 *\the\count@ l}\normalfont Key\ifXKVV@colii&\normalfont Prefix%
4618 \fi\ifXKVV@coliii&\normalfont Family\fi\ifXKVV@coliv&\normalfont
4619 Type\fi\ifXKVV@colv&\normalfont Default\fi\\\noexpand\hline
4620 \noexpand\endfirsthead\noexpand\multicolumn{\the\count@}{l}{%
4621 \normalfont\emph{Continued from previous page}}\\\noexpand\hline
4622 \normalfont Key\ifXKVV@colii&\normalfont Prefix\fi\ifXKVV@coliii
4623 &\normalfont Family\fi\ifXKVV@coliv&\normalfont Type\fi
4624 \ifXKVV@colv&\normalfont Default\fi\\\noexpand\hline\noexpand
4625 \endhead\noexpand\hline\noexpand\multicolumn{\the\count@}{r}{%
4626 \normalfont\emph{Continued on next page}}\\\noexpand\endfoot
4627 \noexpand\hline\noexpand\endlastfoot
4628 }%
4629 \XKV@toks\expandafter{\XKV@tempa}%
4630 \fi
4631 % \end{macrocode}
4632 % Open the target file for writing if a file name has been specified.
4633 % \begin{macrocode}
4634 \ifx\XKVV@file\@nnil\else\immediate\openout\XKVV@out\XKVV@file\fi
4635 % \end{macrocode}
4636 % Parse the entire database to find entries that match the criteria.
4637 % \begin{macrocode}
4638 \XKV@for@o\XKVV@db\XKV@tempa{%
4639 \XKVV@vwkeytrue\expandafter\XKVV@xkvview\XKV@tempa\@nil
4640 }%
4641 % \end{macrocode}
4642 % Finish the long table and typeset it.
4643 % \begin{macrocode}
4644 \ifXKVV@view
4645 \addto@hook\XKV@toks{\end{longtable}}%
4646 \begingroup\ttfamily\the\XKV@toks\endgroup
4647 \fi
4648 % \end{macrocode}
4649 % Close the target file.
4650 % \begin{macrocode}
4651 \ifx\XKVV@file\@nnil\else\immediate\closeout\XKVV@out\fi
4652 }
4653 % \end{macrocode}
4654 % \end{macro}
4655 % \begin{macro}{\XKVV@xkvview}
4656 % \meta{key}|=|\meta{prefix}|=|\meta{family}|=|\meta{type}|=|\meta{default}|\@nil|\\
4657 % Parse a row in the database to get individual column entries. Select
4658 % the requested columns and store the table row in the token or write
4659 % it to the target file.
4660 % \begin{macrocode}
4661 \def\XKVV@xkvview#1=#2=#3=#4=#5\@nil{%
4662 % \end{macrocode}
4663 % Check whether the current entry satisfies all criteria.
4664 % \begin{macrocode}
4665 \ifx\XKVV@prefix\@nnil\else
4666 \def\XKV@tempa{#2}%
4667 \ifx\XKV@tempa\XKVV@prefix\else\XKVV@vwkeyfalse\fi
4668 \fi
4669 \ifx\XKVV@family\@nnil\else
4670 \def\XKV@tempa{#3}%
4671 \ifx\XKV@tempa\XKVV@family\else\XKVV@vwkeyfalse\fi
4672 \fi
4673 \ifx\XKVV@type\@nnil\else
4674 \def\XKV@tempa{#4}%
4675 \ifx\XKV@tempa\XKVV@type\else\XKVV@vwkeyfalse\fi
4676 \fi
4677 \ifx\XKVV@default\@nnil\else
4678 \def\XKV@tempa{#5}%
4679 \ifx\XKV@tempa\XKVV@default\else\XKVV@vwkeyfalse\fi
4680 \fi
4681 \ifXKVV@vwkey
4682 % \end{macrocode}
4683 % If output should go to the dvi, construct the table row and add it
4684 % to the token.
4685 % \begin{macrocode}
4686 \ifXKVV@view
4687 \edef\XKV@tempa{%
4688 #1\ifXKVV@colii&#2\fi\ifXKVV@coliii&#3\fi
4689 \ifXKVV@coliv&#4\fi\ifXKVV@colv&#5\fi
4690 \ifXKVV@vlabels\noexpand\label{#2-#3-#1}\fi
4691 }%
4692 \expandafter\addto@hook\expandafter
4693 \XKV@toks\expandafter{\XKV@tempa\\}%
4694 \fi
4695 \ifx\XKVV@file\@nnil\else
4696 % \end{macrocode}
4697 % When writing, construct the line and write it to file. Notice that
4698 % \pf{xkeyval} removes braces and spaces, so |wcolsep={ }| won't make
4699 % a space between column entries, but |wcolsep=\space| will.
4700 % \begin{macrocode}
4701 \immediate\write\XKVV@out{%
4702 #1\ifXKVV@colii\XKVV@wcolsep#2\fi
4703 \ifXKVV@coliii\XKVV@wcolsep#3\fi
4704 \ifXKVV@coliv\XKVV@wcolsep#4\fi
4705 \ifXKVV@colv\XKVV@wcolsep#5\fi
4706 \ifXKVV@wlabels\string\label{#2-#3-#1}\fi
4707 \expandafter\noexpand\XKVV@weol
4708 }%
4709 \fi
4710 \fi
4711 }
4712 %</xkvview>
4713 % \end{macrocode}
4714 % \end{macro}
4715 % \subsection{\texttt{xkvltxp.sty}}\label{sec:ltxpatch}
4716 % \changes{v1.5}{2004/09/27}{Added \LaTeX\ kernel patch}
4717 % This section redefines some kernel macros as to avoid expansions of
4718 % options at several places to allow for macros in key values in class
4719 % and package options. It uses a temporary token register and some
4720 % careful expansions. Notice that |\@unusedoptionlist| is sanitized
4721 % after creation by \pf{xkeyval} to avoid |\@removeelement| causing
4722 % problems with macros and braces. See for more information about the
4723 % original versions of the macros below the kernel source documentation
4724 % \cite{LaTeXbase}.
4725 % \begin{macrocode}
4726 %<*xkvltxpatch>
4727 %%
4728 %% Based on latex.ltx.
4729 %%
4730 \NeedsTeXFormat{LaTeX2e}[1995/12/01]
4731 \ProvidesPackage{xkvltxp}[2014/05/25 v1.3 LaTeX2e kernel patch (HA)]
4732 % \end{macrocode}
4733 % Load utilities needed in this package.
4734 % \begin{macrocode}
4735 \input xkvutils
4736 % \end{macrocode}
4737 % Start redefining internal \LaTeX\ macros.
4738 % \begin{macrocode}
4739 \def\@pass@ptions#1#2#3{%
4740 \def\reserved@a{#2}%
4741 \def\reserved@b{\CurrentOption}%
4742 \ifx\reserved@a\reserved@b
4743 \@ifundefined{opt@#3.#1}{\@temptokena\expandafter{#2}}{%
4744 \@temptokena\expandafter\expandafter\expandafter
4745 {\csname opt@#3.#1\endcsname}%
4746 \@temptokena\expandafter\expandafter\expandafter{%
4747 \expandafter\the\expandafter\@temptokena\expandafter,#2}%
4748 }%
4749 \else
4750 \@ifundefined{opt@#3.#1}{\@temptokena{#2}}{%
4751 \@temptokena\expandafter\expandafter\expandafter
4752 {\csname opt@#3.#1\endcsname}%
4753 \@temptokena\expandafter{\the\@temptokena,#2}%
4754 }%
4755 \fi
4756 \expandafter\xdef\csname opt@#3.#1\endcsname{\the\@temptokena}%
4757 }
4758 \def\OptionNotUsed{%
4759 \ifx\@currext\@clsextension
4760 \let\reserved@a\CurrentOption
4761 \@onelevel@sanitize\reserved@a
4762 \xdef\@unusedoptionlist{%
4763 \ifx\@unusedoptionlist\@empty\else\@unusedoptionlist,\fi
4764 \reserved@a}%
4765 \fi
4766 }
4767 \def\@use@ption{%
4768 \let\reserved@a\CurrentOption
4769 \@onelevel@sanitize\reserved@a
4770 \@expandtwoargs\@removeelement\reserved@a
4771 \@unusedoptionlist\@unusedoptionlist
4772 \csname ds@\CurrentOption\endcsname
4773 }
4774 % \end{macrocode}
4775 % \begin{macro}{\@fileswith@pti@ns}
4776 % \changes{v1.3}{2014/05/25}{Added code to remove spaces around options}
4777 % \begin{macrocode}
4778 \def\@fileswith@pti@ns#1[#2]#3[#4]{%
4779 \XKV@sp@deflist\XKV@resb{#2}%
4780 \ifx#1\@clsextension
4781 \ifx\@classoptionslist\relax
4782 \let\@classoptionslist\XKV@resb
4783 \def\reserved@a{%
4784 \@onefilewithoptions#3[#2][#4]#1%
4785 \@documentclasshook}%
4786 \else
4787 \def\reserved@a{%
4788 \@onefilewithoptions#3[#2][#4]#1}%
4789 \fi
4790 \else
4791 \def\reserved@b##1,{%
4792 \ifx\@nil##1\relax\else
4793 \ifx\relax##1\relax\else
4794 \noexpand\@onefilewithoptions##1%
4795 [\XKV@resb][#4]\noexpand\@pkgextension
4796 \fi
4797 \expandafter\reserved@b
4798 \fi}%
4799 \edef\reserved@a{\zap@space#3 \@empty}%
4800 \edef\reserved@a{\expandafter\reserved@b\reserved@a,\@nil,}%
4801 \fi
4802 \reserved@a}
4803 % \end{macrocode}
4804 % \end{macro}
4805 % \begin{macrocode}
4806 \let\@@fileswith@pti@ns\@fileswith@pti@ns
4807 %</xkvltxpatch>
4808 % \end{macrocode}
4809 % \subsection{\texttt{pst-xkey.tex}}
4810 % Avoid loading |pst-xkey.tex| twice.
4811 % \begin{macrocode}
4812 %<*pxktex>
4813 \csname PSTXKeyLoaded\endcsname
4814 \let\PSTXKeyLoaded\endinput
4815 \edef\PSTXKeyCatcodes{%
4816 \catcode`\noexpand\@\the\catcode`\@\relax
4817 \let\noexpand\PSTXKeyCatcodes\relax
4818 }
4819 \catcode`\@=11\relax
4820 % \end{macrocode}
4821 % Load \pf{xkeyval} when not already done by |pst-xkey.sty| and
4822 % provide information.
4823 % \begin{macrocode}
4824 \ifx\ProvidesFile\@undefined
4825 \message{2005/11/25 v1.6 PSTricks specialization of xkeyval (HA)}
4826 \ifx\XKeyValLoaded\endinput\else\input xkeyval \fi
4827 \else
4828 \ProvidesFile{pst-xkey.tex}
4829 [2005/11/25 v1.6 PSTricks specialization of xkeyval (HA)]
4830 \@addtofilelist{pst-xkey.tex}
4831 \RequirePackage{xkeyval}
4832 \fi
4833 % \end{macrocode}
4834 % \begin{macro}{\pst@famlist}
4835 % Initialize the list of families.
4836 % \begin{macrocode}
4837 \def\pst@famlist{}
4838 % \end{macrocode}
4839 % \end{macro}
4840 % \begin{macro}{\pst@addfams}
4841 % Adds the family to |\pst@famlist| if it was not in yet.
4842 % \begin{macrocode}
4843 \def\pst@addfams#1{%
4844 \XKV@for@n{#1}\XKV@tempa{%
4845 \@expandtwoargs\in@{,\XKV@tempa,}{,\pst@famlist,}%
4846 \ifin@\else\edef\pst@famlist{\pst@famlist,\XKV@tempa}\fi
4847 }%
4848 }
4849 % \end{macrocode}
4850 % \end{macro}
4851 % \begin{macro}{\psset}
4852 % \changes{v1.8b}{2004/12/22}{Properly expand \cs{pst@famlist}}
4853 % \changes{v2.5e}{2005/11/25}{Added \cs{ignorespaces} as in \texttt{pstricks.tex}}
4854 % \begin{macro}{\pss@t}
4855 % Set keys. Uses \pf{xkeyval}'s |\setkeys+|.
4856 % \begin{macrocode}
4857 \def\psset{%
4858 \expandafter\@testopt\expandafter\pss@t\expandafter{\pst@famlist}%
4859 }
4860 \def\pss@t[#1]#2{\setkeys+[psset]{#1}{#2}\ignorespaces}
4861 % \end{macrocode}
4862 % \end{macro}
4863 % \end{macro}
4864 % \begin{macro}{\@psset}
4865 % This macro defined by |pstricks.tex| is internally used as a
4866 % shortcut. We have to redefine this as well to avoid problems.
4867 % \begin{macrocode}
4868 \def\@psset#1,\@nil{%
4869 \edef\XKV@tempa{\noexpand\setkeys+[psset]{\pst@famlist}}%
4870 \XKV@tempa{#1}%
4871 }
4872 % \end{macrocode}
4873 % \end{macro}
4874 % Finalize.
4875 % \begin{macrocode}
4876 \PSTXKeyCatcodes
4877 %</pxktex>
4878 % \end{macrocode}
4879 % \subsection{\texttt{pst-xkey.sty}}
4880 % Initialize the package.
4881 % \begin{macrocode}
4882 %<*pxklatex>
4883 \NeedsTeXFormat{LaTeX2e}[1995/12/01]
4884 \ProvidesPackage{pst-xkey}
4885 [2005/11/25 v1.6 package wrapper for pst-xkey.tex (HA)]
4886 % \end{macrocode}
4887 % Load required package.
4888 % \begin{macrocode}
4889 \ifx\PSTXKeyLoaded\endinput\else\input pst-xkey \fi
4890 % \end{macrocode}
4891 % Ignore options.
4892 % \begin{macrocode}
4893 \DeclareOptionX*{%
4894 \PackageWarning{pst-xkey}{Unknown option `\CurrentOption'}%
4895 }
4896 \ProcessOptionsX
4897 %</pxklatex>
4898 % \end{macrocode}
4899 %
4900 % \Finale
4901 % \endinput
4902 %
4903 %<*xkvex1>
4904 \input xkeyval
4905
4906 \catcode`\@=11
4907
4908 %% xkeyval package: TeX example
4909 %% Hendri Adriaens
4910
4911 \noindent Example 1. This example demonstrates the use of the new
4912 macros for setting keys of the `xkeyval' package. Have a look at the
4913 source for information about this example and to understand the output.
4914
4915 %% Define keys.
4916 \define@key{fami}{keyi}{key 1: #1 }
4917 \define@key{famii}{keyii}{key 2: #1 }
4918 \define@key{famiii}{keyiii}[test 2]{key 3: #1 }
4919 \define@key{famiv}{keyi}{key 4: #1 }
4920
4921 %% Set keys from multiple families.
4922 \setkeys{fami,famii,famiii}{keyi=test 1,keyiii}
4923
4924 %% Multiplely defined keys will be taken from the first family on the
4925 %% list that defines the key. When + is used, all families
4926 %% defining the key will set it.
4927 \setkeys{fami,famiv}{keyi=test 3}\par
4928 \setkeys{famiv,fami}{keyi=test 4}\par
4929 \setkeys+{fami,famiv}{keyi=test 5}\par
4930
4931 %% Starred form sets keys that it can find in the families specified.
4932 %% Keys that cannot be located will be put onto a list for later use
4933 %% by \setrmkeys.
4934 \setkeys*{famiv}{keyi=test 9,keyii=http://www.test10.com,
4935 keyiii=test 11}\par
4936
4937 %% Try to set the remaining keys from the previous step. The starred
4938 %% version defines a new list in case there are still keys that cannot
4939 %% be located in the given families. The command below does not do
4940 %% anything since the `keyi' key has already been taken from family
4941 %% `famiv' above.
4942 \setrmkeys*{fami}\par
4943
4944 %% The normal version will complain (as \setkeys) when it cannot locate
4945 %% a key which was previously submitted to \xsetkeys and hasn't been
4946 %% set yet by previous commands. `xkeyval' commands can also be used to
4947 %% set `keyval' options.
4948 \setrmkeys{famii,famiii}\par
4949
4950 %% Set keys, excluding some keys.
4951 \setkeys{fami,famii,famiii}[keyi,keyiii]{keyi=test 6,keyii=test
4952 7,keyiii=test 8}\par
4953
4954 %% Test whether a key is defined in a family from the list.
4955 \key@ifundefined{fami,famii}{keyiii}
4956 {keyiii is not defined in family `fami' or `famii'}
4957 {keyiii is defined in family `fami' or `famii'}
4958
4959 %% Define some keys and macros.
4960 \define@cmdkey[my]{fama}[my@]{keya}[none]{}
4961 \define@choicekey[my]{fama}{keyb}{a,b,c}[b]{correct input: #1}
4962 \define@boolkey[my]{famb}{keyc}[true]{}
4963 \def\testa{\setkeys[my]{fama}}
4964 \def\testb{\setkeys[my]{famb}}
4965 \def\testset{\setkeys[my]{fama,famb}}
4966
4967 %% Now \testa can only set keya, \testb can only
4968 %% set keyb and \testset can set both.
4969 \testa{keya}
4970 \my@keya\
4971 \testa{keyb}
4972 \testb{keyc}
4973 \ifmy@famb@keyc true \else false \fi
4974 \testset{keya=test 11,keyb=c,keyc=false}
4975 \my@keya\space
4976 \ifmy@famb@keyc true \else false \fi
4977
4978 %% Pointer system
4979
4980 %% First we (re)define some keys.
4981 \define@key{fam}{keyi}{key 1: #1 }
4982 \define@key{fam}{keyii}{key 2: #1 }
4983 \define@key{fam}{keyiii}[test 2]{key 3: #1 }
4984
4985 %% Pointers can be used to copy the value of other keys in the same
4986 %% family. This can be done in two ways. The first example shows `on
4987 %% the spot' value saving.
4988 \setkeys{fam}{\savevalue{keyi}=test 12,\savevalue{keyii}=\usevalue{keyi}}
4989 \setkeys{fam}{keyiii=\usevalue{keyii}}
4990
4991 %% However, you can also predefine the keys to be saved for the entire
4992 %% document with a single command.
4993 \savekeys{fam}{keyi,keyii}
4994 \setkeys{fam}{keyi=test 13,keyii=\usevalue{keyi}}
4995 \setkeys{fam}{keyiii=\usevalue{keyii}}
4996
4997 %% Pointers can be used in default values as well. Remember that the
4998 %% previous example used \savekeys for keyi and keyii.
4999 \define@key{fam}{keyi}{keyi: #1 }
5000 \define@key{fam}{keyii}[\usevalue{keyi}]{keyii: #1 }
5001 \define@key{fam}{keyiii}[\usevalue{keyii}]{keyiii: #1 }
5002 \setkeys{fam}{keyi=test 14}
5003 \setkeys{fam}{keyii}
5004 \setkeys{fam}{keyiii}
5005
5006 %% Presetting keys
5007
5008 %% Simple example of the preset system.
5009 \define@key{fam}{keyi}{keyi: #1 }
5010 \define@key{fam}{keyii}{keyii: #1 }
5011 \presetkeys{fam}{keyi=blue}{keyii=\usevalue{keyi}}
5012 \setkeys{fam}{}\par
5013 \setkeys{fam}{keyi=red}\par
5014 \setkeys{fam}{keyii=red}
5015 \presetkeys{fam}{keyi=red}{}\par
5016 \setkeys{fam}{keyii=\usevalue{keyi}}
5017
5018 \bye
5019 %</xkvex1>
5020 %
5021 %<*xkvex2>
5022 \documentclass{article}
5023 \usepackage{xkeyval}
5024 \usepackage{xcolor,calc}
5025
5026 %% Example of setting keyval options using xkeyval
5027 \usepackage{hyperref}
5028 \usepackage{helvet}
5029 \setkeys{Hyp,Hel}{colorlinks,urlcolor=green,scaled=.85}
5030
5031 \title{\textsf{xkeyval} package\\\normalsize\emph{Example 2}}
5032 \author{Hendri Adriaens}
5033 \setlength{\parindent}{0cm}
5034
5035 \makeatletter
5036
5037 \begin{document}
5038 \maketitle
5039
5040 This example demonstrates the use of the new macros for setting
5041 keys of the \textsf{xkeyval} package. Below each piece of verbatim
5042 code, you can find its output.
5043
5044 \section{Simple operations}
5045
5046 Define keys.
5047 \begin{verbatim}
5048 \define@key{fami}{keyi}{key 1: #1\space}
5049 \define@key{famii}{keyii}{key 2: #1\space}
5050 \define@key{famiii}{keyiii}[test 2]{key 3: #1\space}
5051 \define@key{famiv}{keyi}{key 4: #1\space}
5052 \end{verbatim}
5053 \define@key{fami}{keyi}{key 1: #1\space}
5054 \define@key{famii}{keyii}{key 2: #1\space}
5055 \define@key{famiii}{keyiii}[test 2]{key 3: #1\space}
5056 \define@key{famiv}{keyi}{key 4: #1\space}
5057
5058 Set keys from multiple families.
5059 \begin{verbatim}
5060 \setkeys{fami,famii,famiii}{keyi=test 1,keyiii}
5061 \end{verbatim}
5062 \begin{itemize}
5063 \item[$\Rightarrow$]
5064 \setkeys{fami,famii,famiii}{keyi=test 1,keyiii}
5065 \end{itemize}
5066
5067 Multiplely defined keys will be taken from the first family on the
5068 list that defines the key. When \verb|+| is used, all families
5069 defining the key will set it.
5070 \begin{verbatim}
5071 \setkeys{fami,famiv}{keyi=test 3}
5072 \setkeys{famiv,fami}{keyi=test 4}
5073 \setkeys+{fami,famiv}{keyi=test 5}
5074 \end{verbatim}
5075 \begin{itemize}
5076 \item[$\Rightarrow$]
5077 \setkeys{fami,famiv}{keyi=test 3}\par
5078 \setkeys{famiv,fami}{keyi=test 4}\par
5079 \setkeys+{fami,famiv}{keyi=test 5}
5080 \end{itemize}
5081
5082 Starred form sets keys that it can find in the families specified.
5083 Keys that cannot be located will be put onto a list for later use
5084 by \verb+\setrmkeys+.
5085 \begin{verbatim}
5086 \setkeys*{famiv}{keyi=test 9,keyii=\url{http://www.test10.com},
5087 keyiii=this key has been set on page \thepage}
5088 \end{verbatim}
5089 \begin{itemize}
5090 \item[$\Rightarrow$]
5091 \setkeys*{famiv}{keyi=test 9,keyii=\url{http://www.test10.com},
5092 keyiii=this key has been set on page \thepage}
5093 \end{itemize}
5094
5095 Try to set the remaining keys from the previous step. The starred
5096 version defines a new list in case there are still keys that
5097 cannot be located in the given families. The command below does
5098 not do anything since the \verb+keyi+ key has already been taken
5099 from family \verb+famiv+ above.
5100 \begin{verbatim}
5101 \setrmkeys*{fami}
5102 \end{verbatim}
5103 \setrmkeys*{fami}\par
5104
5105 The normal version will complain (as \verb+\setkeys+) when it
5106 cannot locate a key which was previously submitted to
5107 \verb+\setkeys+ and hasn't been set yet by previous commands.
5108 \textsf{xkeyval} commands can also be used to set \textsf{keyval}
5109 options as is done to the color of the url created with the
5110 \textsf{hyperref} package and the scaling of the font used for
5111 `\textsf{xkeyval}' with the \textsf{helvet} package. (See the
5112 preamble of the example for the code).
5113 \begin{verbatim}
5114 \setrmkeys{famii,famiii}
5115 \end{verbatim}
5116 \begin{itemize}
5117 \item[$\Rightarrow$]
5118 \setrmkeys{famii,famiii}
5119 \end{itemize}
5120
5121 Set keys, excluding some keys.
5122 \begin{verbatim}
5123 \setkeys{fami,famii,famiii}[keyi,keyiii]{keyi=test 6,keyii=test 7,keyiii=test 8}
5124 \end{verbatim}
5125 \begin{itemize}
5126 \item[$\Rightarrow$]
5127 \setkeys{fami,famii,famiii}[keyi,keyiii]{keyi=test 6,keyii=test 7,keyiii=test 8}
5128 \end{itemize}
5129
5130 Test whether a key is defined in a family from the list.
5131 \begin{verbatim}
5132 \key@ifundefined{fami,famii}{keyiii}
5133 {keyiii is not defined in family `fami' or `famii'}
5134 {keyiii is defined in family `fami' or `famii'}
5135 \end{verbatim}
5136 \begin{itemize}
5137 \item[$\Rightarrow$]
5138 \key@ifundefined{fami,famii}{keyiii}
5139 {keyiii is not defined in family `fami' or `famii'}
5140 {keyiii is defined in family `fami' or `famii'}
5141 \end{itemize}
5142
5143 Define some keys and macros.
5144 \begin{verbatim}
5145 \define@cmdkey[my]{fama}[my@]{keya}[none]{}
5146 \define@choicekey[my]{fama}{keyb}{a,b,c}[b]{correct input: #1}
5147 \define@boolkey[my]{famb}{keyc}[true]{}
5148 \def\testa{\setkeys[my]{fama}}
5149 \def\testb{\setkeys[my]{famb}}
5150 \def\testset{\setkeys[my]{fama,famb}}
5151 \end{verbatim}
5152 \define@cmdkey[my]{fama}[my@]{keya}[none]{}
5153 \define@choicekey[my]{fama}{keyb}{a,b,c}[b]{correct input: #1}
5154 \define@boolkey[my]{famb}{keyc}[true]{}
5155 \def\testa{\setkeys[my]{fama}}
5156 \def\testb{\setkeys[my]{famb}}
5157 \def\testset{\setkeys[my]{fama,famb}}
5158 Now \verb+\testa+ can only set \verb+keya+, \verb+\testb+ can only
5159 set \verb+keyb+ and \verb+\testset+ can set both.
5160 \begin{verbatim}
5161 \testa{keya}
5162 \my@keya\
5163 \testa{keyb}
5164 \testb{keyc}
5165 \ifmy@famb@keyc true \else false \fi
5166 \testset{keya=test 11,keyb=c,keyc=false}
5167 \my@keya\space
5168 \ifmy@famb@keyc true \else false \fi
5169 \end{verbatim}
5170 \begin{itemize}
5171 \item[$\Rightarrow$]
5172 \testa{keya}
5173 \my@keya\
5174 \testa{keyb}
5175 \testb{keyc}
5176 \ifmy@famb@keyc true \else false \fi
5177 \testset{keya=test 11,keyb=c,keyc=false}
5178 \my@keya\space
5179 \ifmy@famb@keyc true \else false \fi
5180 \end{itemize}
5181
5182 \section{Pointers and values}
5183
5184 First we (re)define some keys.
5185 \begin{verbatim}
5186 \define@key{fam}{keyi}{key 1: #1 }
5187 \define@key{fam}{keyii}{key 2: #1 }
5188 \define@key{fam}{keyiii}[test 2]{key 3: #1 }
5189 \end{verbatim}
5190 \define@key{fam}{keyi}{key 1: #1 }
5191 \define@key{fam}{keyii}{key 2: #1 }
5192 \define@key{fam}{keyiii}[test 2]{key 3: #1 }
5193
5194 Pointers can be used to copy the value of other keys in the same
5195 family. This can be done in two ways. The first example shows `on
5196 the spot' value saving.
5197 \begin{verbatim}
5198 \setkeys{fam}{\savevalue{keyi}=test 12,\savevalue{keyii}=\usevalue{keyi}}
5199 \setkeys{fam}{keyiii=\usevalue{keyii}}
5200 \end{verbatim}
5201 \begin{itemize}
5202 \item[$\Rightarrow$]
5203 \setkeys{fam}{\savevalue{keyi}=test 12,\savevalue{keyii}=\usevalue{keyi}}
5204 \setkeys{fam}{keyiii=\usevalue{keyii}}
5205 \end{itemize}
5206
5207 However, you can also predefine the keys to be saved for the entire
5208 document with a single command. Note that we force keys to be saved
5209 globally. This is necessary here since the commands in the source of
5210 this document appear in an environment.
5211 \begin{verbatim}
5212 \savekeys{fam}{\global{keyi},\global{keyii}}
5213 \setkeys{fam}{keyi=test 13,keyii=\usevalue{keyi}}
5214 \setkeys{fam}{keyiii=\usevalue{keyii}}
5215 \end{verbatim}
5216 \begin{itemize}
5217 \item[$\Rightarrow$]
5218 \savekeys{fam}{\global{keyi},\global{keyii}}
5219 \setkeys{fam}{keyi=test 13,keyii=\usevalue{keyi}}
5220 \setkeys{fam}{keyiii=\usevalue{keyii}}
5221 \end{itemize}
5222
5223 Pointers can be used in default values as well. Remember that the
5224 previous example used \verb+\savekeys+ for \verb+keyi+ and \verb+keyii+.
5225 \begin{verbatim}
5226 \define@key{fam}{keyi}{keyi: #1 }
5227 \define@key{fam}{keyii}[\usevalue{keyi}]{keyii: #1 }
5228 \define@key{fam}{keyiii}[\usevalue{keyii}]{keyiii: #1 }
5229 \setkeys{fam}{keyi=test 14}
5230 \setkeys{fam}{keyii}
5231 \setkeys{fam}{keyiii}
5232 \end{verbatim}
5233 \begin{itemize}
5234 \item[$\Rightarrow$]
5235 \define@key{fam}{keyi}{keyi: #1 }
5236 \define@key{fam}{keyii}[\usevalue{keyi}]{keyii: #1 }
5237 \define@key{fam}{keyiii}[\usevalue{keyii}]{keyiii: #1 }
5238 \setkeys{fam}{keyi=test 14}
5239 \setkeys{fam}{keyii}
5240 \setkeys{fam}{keyiii}
5241 \end{itemize}
5242
5243 \section{Presetting keys}
5244
5245 Simple example of the preset system.
5246 \begin{verbatim}
5247 \define@key{fam}{keyi}{keyi: #1 }
5248 \define@key{fam}{keyii}{keyii: #1 }
5249 \presetkeys{fam}{keyi=blue}{keyii=\usevalue{keyi}}
5250 \setkeys{fam}{}\par
5251 \setkeys{fam}{keyi=red}\par
5252 \setkeys{fam}{keyii=red}
5253 \presetkeys{fam}{keyi=red}{}
5254 \setkeys{fam}{keyii=\usevalue{keyi}}
5255 \end{verbatim}
5256 \begin{itemize}
5257 \item[$\Rightarrow$]
5258 \define@key{fam}{keyi}{keyi: #1 }
5259 \define@key{fam}{keyii}{keyii: #1 }
5260 \presetkeys{fam}{keyi=blue}{keyii=\usevalue{keyi}}
5261 \setkeys{fam}{}\par
5262 \setkeys{fam}{keyi=red}\par
5263 \setkeys{fam}{keyii=red}
5264 \presetkeys{fam}{keyi=red}{}\par
5265 \setkeys{fam}{keyii=\usevalue{keyi}}
5266 \end{itemize}
5267
5268 \section{Application of pointers, values and presets}
5269
5270 \setkeys{Hyp}{urlcolor=black}
5271 More complicated example of the preset
5272 system and pointer system. See for more information about this
5273 example the
5274 \textsf{xkeyval} article on\par
5275 \url{http://www.tug.org/TUGboat/tb25-2/tb81adriaens.pdf}.
5276 \begin{verbatim}
5277 \newdimen\shadowsize
5278 \define@boolkey{Fbox}{frame}[true]{}
5279 \define@boolkey{Fbox}{shadow}[true]{}
5280 \define@key{Fbox}{framecolor}{\def\Fboxframecolor{#1}}
5281 \define@key{Fbox}{shadowcolor}{\def\Fboxshadowcolor{#1}}
5282 \define@key{Fbox}{framesize}{\setlength\fboxrule{#1}}
5283 \define@key{Fbox}{shadowsize}{\setlength\shadowsize{#1}}
5284 \presetkeys{Fbox}{frame,framecolor=red,framesize=0.5pt}%
5285 {shadow=\usevalue{frame},shadowcolor=\usevalue{framecolor}!40,%
5286 shadowsize=\usevalue{framesize}*4}
5287 \savekeys{Fbox}{frame,framecolor,framesize}
5288 \newcommand*\Fbox[2][]{%
5289 \setkeys{Fbox}{#1}%
5290 {\ifKV@Fbox@frame\else\fboxrule0pt\fi
5291 \ifKV@Fbox@shadow\else\shadowsize0pt\fi
5292 \sbox0{\fcolorbox{\Fboxframecolor}{white}{#2}}%
5293 \hskip\shadowsize
5294 \color{\Fboxshadowcolor}%
5295 \rule[-\dp0]{\wd0}{\ht0+\dp0}%
5296 \llap{\raisebox{\shadowsize}%
5297 {\box0\hskip\shadowsize}}}%
5298 }
5299 \Fbox{demo1}
5300 \Fbox[framecolor=blue]{demo2}
5301 \Fbox[shadow=false]{demo3}
5302 \Fbox[framesize=1pt]{demo4}
5303 \Fbox[frame=false,shadow]{demo5}
5304 \end{verbatim}
5305 \newdimen\shadowsize
5306 \define@boolkey{Fbox}{frame}[true]{}
5307 \define@boolkey{Fbox}{shadow}[true]{}
5308 \define@key{Fbox}{framecolor}%
5309 {\def\Fboxframecolor{#1}}
5310 \define@key{Fbox}{shadowcolor}%
5311 {\def\Fboxshadowcolor{#1}}
5312 \define@key{Fbox}{framesize}%
5313 {\setlength\fboxrule{#1}}
5314 \define@key{Fbox}{shadowsize}%
5315 {\setlength\shadowsize{#1}}
5316 \presetkeys{Fbox}%
5317 {frame,framecolor=red,framesize=0.5pt}%
5318 {shadow=\usevalue{frame},
5319 shadowcolor=\usevalue{framecolor}!40,
5320 shadowsize=\usevalue{framesize}*4}
5321 \savekeys{Fbox}{frame,framecolor,framesize}
5322 \newcommand*\Fbox[2][]{%
5323 \setkeys{Fbox}{#1}%
5324 {\ifKV@Fbox@frame\else\fboxrule0pt\fi
5325 \ifKV@Fbox@shadow\else\shadowsize0pt\fi
5326 \sbox0{\fcolorbox{\Fboxframecolor}{white}{#2}}%
5327 \hskip\shadowsize
5328 \color{\Fboxshadowcolor}%
5329 \rule[-\dp0]{\wd0}{\ht0+\dp0}%
5330 \llap{\raisebox{\shadowsize}%
5331 {\box0\hskip\shadowsize}}}%
5332 }
5333 \Fbox{demo1}
5334 \Fbox[framecolor=blue]{demo2}
5335 \Fbox[shadow=false]{demo3}
5336 \Fbox[framesize=1pt]{demo4}
5337 \Fbox[frame=false,shadow]{demo5}
5338
5339 \end{document}
5340 %</xkvex2>
5341 %
5342 %<*xkvex3>
5343 %% keyi will set \keyi in xkveca.cls
5344 %% keyvi will set \keyvi in xkveca.cls and xkvesc.sty will pick
5345 %% it up from \documentclass and redefine it
5346 %% IgnoredGlobal and another=key will be considered as global
5347 %% options to be passed on to packages. Not used anymore.
5348 \documentclass[keyi=test1,keyvi,another=key,IgnoredGlobal,10pt]{xkveca}
5349
5350 %% keyii will set \keyii in xkvesa.sty
5351 %% keyiv will be passed to xkvesb.sty as unknown option
5352 %% the other input will be passed on to xkvesb as well.
5353 \usepackage[keyii=test2,keyiv=test4,test5]{xkvesa}
5354
5355 %% keyvii will set \keyvii in xkvesc.sty
5356 \usepackage[keyvii]{xkvesc}
5357
5358 \title{\textsf{xkeyval} package\\\normalsize\emph{Example 3}}
5359 \author{Hendri Adriaens}
5360 \setlength{\parindent}{0cm}
5361
5362 \makeatletter
5363 \let\@tempa\@classoptionslist
5364 \let\@tempb\@unusedoptionlist
5365
5366 \begin{document}
5367 \maketitle
5368
5369 This example demonstrates the use of the new macros for declaring
5370 class and package options of the \textsf{xkeyval} package. Please
5371 study the files \verb+xkvex2.tex+, \verb+xkveca.cls+,
5372 \verb+xkvecb.cls+, \verb+xkvesa.sty+, \verb+xkvesb.sty+ and
5373 \verb+xkvesc.sty+ carefully to understand the output below.\\
5374
5375 Set by \verb+xkveca.cls+: \keyi\par
5376 Set by \verb+xkvesa.sty+, copied from \verb+\documentclass+: \keyia\par
5377 Set by \verb+xkvesa.sty+: \keyii\par
5378 Set by \verb+xkvesb.sty+, passed on from \verb+xkvesa.sty+: \keyiii\par
5379 Set by \verb+xkvesb.sty+, passed on as unknown key from \verb+xkvesa.sty+: \keyiv\par
5380 Set by \verb+xkvesb.sty+, passed on as unknown from \verb+xkvesa.sty+: \keyv\par
5381 Set by the class, copied by \verb+xkvesc.sty+: \keyvi\par
5382 Set by \verb+xkvesc.sty+: \keyvii\par
5383 Set by \verb+xkvecb.cls+, passed on from \verb+xkveca.cls+: \keyviii\\
5384
5385 The document class is: \XKV@documentclass\par
5386 Unused global options: \@tempb\\
5387
5388 Notice the content of the following macros.\par
5389 \verb+\@classoptionslist+: \@tempa\par
5390 \verb+\XKV@classoptionslist+: \XKV@classoptionslist\\
5391
5392 This shows that \verb+key=value+ pairs have been deleted from the
5393 class options list so that subsequent packages which are not using
5394 \textsf{xkeyval} and are scanning this list will not run into
5395 problems.\\
5396
5397 \end{document}
5398 %</xkvex3>
5399 %
5400 %<*xkvex4>
5401 %% Load LaTeX kernel macros patch
5402 \RequirePackage{xkvltxp}
5403
5404 %% keyi will set \keyi in xkveca.cls
5405 %% keyvi will set \keyvi in xkveca.cls and xkvesc.sty will pick
5406 %% it up from \documentclass and redefine it
5407 %% IgnoredGlobal and another=key will be considered as global
5408 %% options to be passed on to packages. Not used anymore.
5409 \documentclass[keyi=test1 on page \thepage,keyvi,another=key,IgnoredGlobal,10pt]{xkveca}
5410
5411 %% keyii will set \keyii in xkvesa.sty
5412 %% keyiv will be passed to xkvesb.sty as unknown option
5413 %% the other input will be passed on to xkvesb as well.
5414 \usepackage[keyii=test2 on page \thepage,keyiv=test4 on page \thepage,test5]{xkvesa}
5415
5416 %% keyvii will set \keyvii in xkvesc.sty
5417 \usepackage[keyvii]{xkvesc}
5418
5419 \title{\textsf{xkeyval} package\\\normalsize\emph{Example 4}}
5420 \author{Hendri Adriaens}
5421 \setlength{\parindent}{0cm}
5422
5423 \makeatletter
5424 \let\@tempa\@classoptionslist
5425 \let\@tempb\@unusedoptionlist
5426 \let\@tempc\XKV@classoptionslist
5427 \@onelevel@sanitize\@tempc
5428
5429 \begin{document}
5430 \maketitle
5431
5432 This example demonstrates the use of the new macros for declaring
5433 class and package options of the \textsf{xkeyval} package. Please
5434 study the files \verb+xkvex2.tex+, \verb+xkveca.cls+,
5435 \verb+xkvecb.cls+, \verb+xkvesa.sty+, \verb+xkvesb.sty+ and
5436 \verb+xkvesc.sty+ carefully to understand the output below.\\
5437
5438 Set by \verb+xkveca.cls+: \keyi\par
5439 Set by \verb+xkvesa.sty+, copied from \verb+\documentclass+: \keyia\par
5440 Set by \verb+xkvesa.sty+: \keyii\par
5441 Set by \verb+xkvesb.sty+, passed on from \verb+xkvesa.sty+: \keyiii\par
5442 Set by \verb+xkvesb.sty+, passed on as unknown from \verb+xkvesa.sty+: \keyiv\par
5443 Set by \verb+xkvesb.sty+, passed on as unknown from \verb+xkvesa.sty+: \keyv\par
5444 Set by the class, copied by \verb+xkvesc.sty+: \keyvi\par
5445 Set by \verb+xkvesc.sty+: \keyvii\par
5446 Set by \verb+xkvecb.cls+, passed on from \verb+xkveca.cls+: \keyviii\\
5447
5448 The document class is: \XKV@documentclass\par
5449 Unused global options: \texttt{\@tempb}\\
5450
5451 Notice the content of the following macros.\par
5452 \verb+\@classoptionslist+: \texttt{\@tempa}\par
5453 \verb+\XKV@classoptionslist+:\par\texttt{\@tempc}\\
5454
5455 This shows that \verb+key=value+ pairs have been deleted from the
5456 class options list so that subsequent packages which are not using
5457 \textsf{xkeyval} and are scanning this list will not run into
5458 problems.\\
5459
5460 \newpage
5461 This page shows that key values are only expanded when they are
5462 actually used. They are not expanded during option processing.\\
5463
5464 \keyi\par
5465 \keyii\par
5466 \keyiv
5467
5468 \end{document}
5469 %</xkvex4>
5470 %
5471 %<*xkveca>
5472 \ProvidesClass{xkveca}
5473 \usepackage{xkeyval}
5474 \let\keyi\@empty
5475 \let\keyvi\@empty
5476 \DeclareOptionX{keyi}{\def\keyi{#1}}
5477 %% this key has a default value
5478 \DeclareOptionX{keyvi}[{test 6}]{\def\keyvi{#1}}
5479 %% pass option to class xkvesb.cls
5480 \PassOptionsToClass{notitlepage}{xkvecb}
5481 \PassOptionsToClass{keyviii={test 8}}{xkvecb}
5482 %% pass unknown options to article
5483 \DeclareOptionX*{\PassOptionsToClass{\CurrentOption}{article}}
5484 %% process options
5485 \ProcessOptionsX
5486 %% load another class
5487 \LoadClass{xkvecb}
5488 %</xkveca>
5489 %
5490 %<*xkvecb>
5491 \ProvidesClass{xkvecb}
5492 %% pass any unknown option to article
5493 \DeclareOptionX{keyviii}{\def\keyviii{#1}}
5494 \DeclareOptionX*{\PassOptionsToClass{\CurrentOption}{article}}
5495 \ProcessOptionsX*
5496 %% load article
5497 \LoadClass{article}
5498 %</xkvecb>
5499 %
5500 %<*xkvesa>
5501 \ProvidesPackage{xkvesa}
5502 \let\keyia\@empty
5503 \let\keyii\@empty
5504 %% keyi has been used in \documentclass
5505 %% this key uses that information to set another macro
5506 %% to do this, \ProcessOptionsX* is necessary.
5507 %% the value from the \documentclass is copied.
5508 \DeclareOptionX{keyi}{\def\keyia{#1}}
5509 \DeclareOptionX{keyii}{\def\keyii{#1}}
5510 %% pass any unknown keys to xkvesb.sty
5511 \DeclareOptionX*{\PassOptionsToPackage{\CurrentOption}{xkvesb}}
5512 %% pass a specific key=value to xkvesb.sty
5513 \PassOptionsToPackage{keyiii={test 3}}{xkvesb}
5514 %% process options. use the * to pick up options from \documentclass
5515 \ProcessOptionsX*
5516 \RequirePackage{xkvesb}
5517 %</xkvesa>
5518 %
5519 %<*xkvesb>
5520 \ProvidesPackage{xkvesb}
5521 \let\keyiii\@empty
5522 \let\keyiv\@empty
5523 \let\keyv\@empty
5524 %% use multiple families to define options
5525 \DeclareOptionX[xkvesb]<famiii>{keyiii}{\def\keyiii{#1}}
5526 \DeclareOptionX[xkvesb]<famiv>{keyiv}{\def\keyiv{#1}}
5527 %% define \keyv as \CurrentOption
5528 \DeclareOptionX*{\let\keyv\CurrentOption}
5529 %% execute options in multiple families
5530 \ExecuteOptionsX[xkvesb]<famiii>{keyiii={test 3}}
5531 %% process options in multiple families
5532 %% do not set keyiii
5533 \ProcessOptionsX[xkvesb]<famiii,famiv>[keyiii]
5534 %</xkvesb>
5535 %
5536 %<*xkvesc>
5537 \ProvidesPackage{xkvesc}
5538 %% redefine \keyvi when keyvi option is specified in \documentclass
5539 \DeclareOption{keyvi}{\def\keyvi{test 6a}}
5540 %% keyvii is a package specific key
5541 \DeclareOption{keyvii}{\def\keyvii{test 7}}
5542 %% note that this package uses original LaTeX macros for options.
5543 %% this is possible since xkeyval filters key=value pairs from
5544 %% the \documentclass options list.
5545 \ProcessOptions
5546 %</xkvesc>
5547 %
5548 %<*preamble>
5549 \usepackage{url}
5550 \usepackage{xkeyval}
5551 \usepackage{fourier}
5552 \usepackage{xcolor}
5553 \usepackage[multiple]{footmisc}
5554 \usepackage{pst-text}
5555 \usepackage{listings}
5556 \lstnewenvironment{command}{%
5557 \lstset{columns=flexible,frame=single,backgroundcolor=\color{blue!20},%
5558 xleftmargin=\fboxsep,xrightmargin=\fboxsep,escapeinside=`',gobble=1}}{}
5559 \lstnewenvironment{example}{%
5560 \lstset{basicstyle=\footnotesize\ttfamily,columns=flexible,frame=single,%
5561 backgroundcolor=\color{yellow!20},xleftmargin=\fboxsep,%
5562 xrightmargin=\fboxsep,gobble=1}}{}
5563 \def\mktitledecor{%
5564 \rput[tl]{90}(-6.5,-23.56){%
5565 \psline[linewidth=1pt](0,1.5)(\paperheight,1.5)%
5566 \rput[lB](.075\paperheight,.5){\pscharpath[linecolor=blue!50,%
5567 fillcolor=yellow!20,fillstyle=solid,linewidth=.5pt]%
5568 {\Huge\bfseries\sffamily xkeyval}%
5569 }%
5570 \rput[rB](.925\paperheight,.5){\pscharpath[linecolor=blue!50,%
5571 fillcolor=yellow!20,fillstyle=solid,linewidth=.5pt]%
5572 {\Huge\bfseries Documentation}%
5573 }%
5574 \psline[linewidth=1pt](0,0)(\paperheight,0)%
5575 }%
5576 }
5577 \makeatletter
5578 \def\tableofcontents{\@starttoc{toc}}
5579 \def\changes@#1#2#3{\ch@nges #1\@nil{#2}{#3}}
5580 \def\ch@nges v#1.#2#3\@nil#4#5{%
5581 \ifnum#1#2<20\else % Controls displaying changes; 0 displays all.
5582 \protected@edef\@tempa{%
5583 \noexpand\glossary{\textbf{v#1.#2#3}\hfill\emph{(#4)}%
5584 \levelchar
5585 \ifx\saved@macroname\@empty
5586 \space\actualchar\generalname
5587 \else
5588 \expandafter\@gobble\saved@macroname
5589 \actualchar\string\verb\quotechar*%
5590 \verbatimchar\saved@macroname\verbatimchar
5591 \fi
5592 :\levelchar #5}}%
5593 \@tempa
5594 \fi\endgroup\@esphack
5595 }
5596 \renewenvironment{theglossary}{%
5597 \section*{Version history}%
5598 This version history displays recent changes only.\par\bigskip
5599 \GlossaryParms \let\item\@idxitem \ignorespaces
5600 }{}%
5601 \def\eTeX{$\m@th\varepsilon$-\TeX}
5602 \def\DescribeMacros{\leavevmode\@bsphack
5603 \begingroup\MakePrivateLetters\Describe@Macros}
5604 \def\Describe@Macros#1{\endgroup\strut
5605 \marginpar{\raggedleft
5606 \def\@tempa{#1}\count@\z@
5607 \XKV@for@o\@tempa\@tempa{%
5608 \ifnum\count@>\z@\\\fi\advance\count@\@ne
5609 \MacroFont\expandafter\string\@tempa
5610 \expandafter\SpecialUsageIndex\expandafter{\@tempa}%
5611 }}%
5612 \@esphack\ignorespaces
5613 }
5614 \def\DescribeOption#1{\leavevmode\@bsphack
5615 \marginpar{\raggedleft\PrintDescribeOption{#1}}%
5616 \SpecialOptionIndex{#1}\@esphack\ignorespaces}
5617 \def\PrintDescribeOption#1{\strut\emph{option}\\\MacroFont #1\ }
5618 \def\SpecialOptionIndex#1{\@bsphack
5619 \index{#1\actualchar{\protect\ttfamily#1}
5620 (option)\encapchar usage}%
5621 \index{options:\levelchar#1\actualchar{\protect\ttfamily#1}\encapchar
5622 usage}\@esphack}
5623 \def\DescribeOptions#1{\leavevmode\@bsphack
5624 \marginpar{\raggedleft\strut\emph{options}%
5625 \@for\@tempa:=#1\do{%
5626 \\\strut\MacroFont\@tempa\SpecialOptionIndex\@tempa
5627 }}\@esphack\ignorespaces}
5628 \makeatother
5629 \def\PrintChangesX{%
5630 \begingroup
5631 \let\efill\relax
5632 \PrintChanges
5633 \endgroup
5634 }
5635 \def\PrintIndexX{%
5636 \begingroup
5637 \setcounter{IndexColumns}{2}
5638 \setlength{\columnsep}{18pt}%
5639 \setlength{\columnseprule}{.4pt}%
5640 \PrintIndex
5641 \endgroup
5642 }
5643 \def\larg#1{{\ttfamily\char`\<}\meta{#1}{\ttfamily\char`\>}}
5644 \def\pf#1{\textsf{#1}}
5645 \EnableCrossrefs
5646 \RecordChanges
5647 \CodelineIndex
5648 \AtBeginDocument{\hypersetup{linkcolor=black, citecolor=black, urlcolor=black}}
5649 %</preamble>
5650 %
5651 %<*bib>
5652 @MISC{LaTeXbase,
5653 author = {Johannes Braams and David Carlisle and Alan Jeffrey and Leslie Lamport
5654 and Frank Mittelbach and Chris Rowley and Rainer Sch\"opf},
5655 title = {The {\LaTeXe} Sources},
5656 howpublished = {\url{CTAN:/macros/latex/base}},
5657 year = 2003
5658 }
5659
5660 @book{companion,
5661 author = {Frank Mittelbach and Michel Goossens},
5662 title = {The {\LaTeX} Companion},
5663 edition = 2,
5664 note = {With Johannes Braams, David Carlisle, and Chris Rowley},
5665 series = {Tools and Techniques for Computer Typesetting},
5666 publisher = {Addison-Wesley},
5667 address = {Boston, Massachusetts},
5668 year = 2004,
5669 pagenums = {1120},
5670 bibliography = {yes},
5671 index = {yes},
5672 isbn = {0-201-36299-6}
5673 }
5674
5675 @MISC{keyval,
5676 author = {David Carlisle},
5677 title = {\pf{keyval} package, v1.13, 1999/03/16},
5678 howpublished = {\url{CTAN:/macros/latex/required/graphics}}
5679 }
5680
5681 @MISC{extract,
5682 author = {Hendri Adriaens},
5683 title = {\pf{extract} package},
5684 howpublished = {\url{CTAN:/macros/latex/contrib/extract}}
5685 }
5686
5687 @MISC{PSTricks,
5688 author = {{Timothy Van} {Zandt et al.}},
5689 title = {\pf{PSTricks} package, v1.04, 2004/06/22},
5690 howpublished = {\url{CTAN:/graphics/pstricks}}
5691 }
5692
5693 @MISC{PSTricksWeb,
5694 author = {Herbert Vo\ss},
5695 title = {\pf{PSTricks} website},
5696 howpublished = {\url{http://www.pstricks.de}}
5697 }
5698 %</bib>