| 1 |
% \iffalse meta-comment |
| 2 |
% !TeX program = pdfLaTeX |
| 3 |
%<*internal> |
| 4 |
\iffalse |
| 5 |
%</internal> |
| 6 |
%<*readme> |
| 7 |
pgfopts - LaTeX package options with pgfkeys |
| 8 |
============================================ |
| 9 |
|
| 10 |
Using key-value options for packages and macros is a good way of |
| 11 |
handling large numbers of options with a clean interface. The |
| 12 |
`pgfkeys` package provides a very well designed system for |
| 13 |
defining and using keys, but does not make this available for |
| 14 |
handling LaTeX class and package options. The `pgfopts` package |
| 15 |
adds this ability to `pgfkeys`, in the same way that `kvoptions` |
| 16 |
extends the `keyval` package. |
| 17 |
|
| 18 |
Installation |
| 19 |
------------ |
| 20 |
|
| 21 |
The package is supplied in `.dtx` format and as a pre-extracted |
| 22 |
zip file, `pgfopts.tds.zip`. The later is most convenient for |
| 23 |
most users: simply unzip this in your local `texmf` directory. |
| 24 |
If you want to unpack the `.dtx` yourself, running `tex |
| 25 |
pgfopts.dtx` will extract the package whereas 'latex pgfopts.dtx |
| 26 |
will extract it and also typeset the documentation. |
| 27 |
|
| 28 |
Typesetting the documentation requires a number of packages in |
| 29 |
addition to those needed to use the package. This is mainly |
| 30 |
because of the number of demonstration items included in the |
| 31 |
text. To compile the documentation without error, you will |
| 32 |
need the packages: |
| 33 |
- `csquotes` |
| 34 |
- `helvet` |
| 35 |
- `hypdoc` |
| 36 |
- `listings` |
| 37 |
- `lmodern` |
| 38 |
- `mathpazo` |
| 39 |
- `microtype` |
| 40 |
%</readme> |
| 41 |
%<*internal> |
| 42 |
\fi |
| 43 |
\def\nameofplainTeX{plain} |
| 44 |
\ifx\fmtname\nameofplainTeX\else |
| 45 |
\expandafter\begingroup |
| 46 |
\fi |
| 47 |
%</internal> |
| 48 |
%<*install> |
| 49 |
\input docstrip.tex |
| 50 |
\keepsilent |
| 51 |
\askforoverwritefalse |
| 52 |
\preamble |
| 53 |
---------------------------------------------------------------- |
| 54 |
pgfopts --- LaTeX package options with pgfkeys |
| 55 |
E-mail: [email protected] |
| 56 |
Released under the LaTeX Project Public License v1.3c or later |
| 57 |
See http://www.latex-project.org/lppl.txt |
| 58 |
---------------------------------------------------------------- |
| 59 |
|
| 60 |
\endpreamble |
| 61 |
\postamble |
| 62 |
|
| 63 |
Copyright (C) 2008-2011,2013,2014 by |
| 64 |
Joseph Wright <[email protected]> |
| 65 |
|
| 66 |
It may be distributed and/or modified under the conditions of |
| 67 |
the LaTeX Project Public License (LPPL), either version 1.3c of |
| 68 |
this license or (at your option) any later version. The latest |
| 69 |
version of this license is in the file: |
| 70 |
|
| 71 |
http://www.latex-project.org/lppl.txt |
| 72 |
|
| 73 |
This work is "maintained" (as per LPPL maintenance status) by |
| 74 |
Joseph Wright. |
| 75 |
|
| 76 |
This work consists of the file pgfopts.dtx |
| 77 |
and the derived files pgfopts.ins and |
| 78 |
pgfopts.pdf. |
| 79 |
|
| 80 |
\endpostamble |
| 81 |
\usedir{tex/latex/pgfopts} |
| 82 |
\generate{ |
| 83 |
\file{\jobname.sty}{\from{\jobname.dtx}{package}} |
| 84 |
} |
| 85 |
%</install> |
| 86 |
%<install>\endbatchfile |
| 87 |
%<*internal> |
| 88 |
\usedir{source/latex/pgfopts} |
| 89 |
\generate{ |
| 90 |
\file{\jobname.ins}{\from{\jobname.dtx}{install}} |
| 91 |
} |
| 92 |
\nopreamble\nopostamble |
| 93 |
\usedir{doc/latex/pgfopts} |
| 94 |
\generate{ |
| 95 |
\file{README.txt}{\from{\jobname.dtx}{readme}} |
| 96 |
} |
| 97 |
\ifx\fmtname\nameofplainTeX |
| 98 |
\expandafter\endbatchfile |
| 99 |
\else |
| 100 |
\expandafter\endgroup |
| 101 |
\fi |
| 102 |
%</internal> |
| 103 |
%<*driver> |
| 104 |
\documentclass[a4paper]{ltxdoc} |
| 105 |
\usepackage{csquotes,lmodern,pgfopts} |
| 106 |
\usepackage[osf]{mathpazo} |
| 107 |
\usepackage[scaled=0.95]{helvet} |
| 108 |
\usepackage[T1]{fontenc} |
| 109 |
\usepackage[final]{listings,microtype} |
| 110 |
\usepackage[numbered]{hypdoc} |
| 111 |
\EnableCrossrefs |
| 112 |
\CodelineIndex |
| 113 |
\RecordChanges |
| 114 |
\begin{document} |
| 115 |
\DocInput{\jobname.dtx} |
| 116 |
\end{document} |
| 117 |
%</driver> |
| 118 |
% \fi |
| 119 |
% |
| 120 |
%\GetFileInfo{\jobname.sty} |
| 121 |
% |
| 122 |
%\makeatletter |
| 123 |
% |
| 124 |
%^^A For creating examples with nice highlighting of code, and so |
| 125 |
%^^A on; based on the system used in the listings source (lstsample). |
| 126 |
%\lst@RequireAspects{writefile} |
| 127 |
%\lstnewenvironment{LaTeXdemo}[1][code and example]^^A |
| 128 |
% {^^A |
| 129 |
% \global\let\lst@intname\@empty |
| 130 |
% \expandafter\let\expandafter\LaTeXdemo@end |
| 131 |
% \csname LaTeXdemo@#1@end\endcsname |
| 132 |
% \@nameuse{LaTeXdemo@#1}^^A |
| 133 |
% } |
| 134 |
% {\LaTeXdemo@end} |
| 135 |
%\newcommand*\LaTeXdemo@new[3]{^^A |
| 136 |
% \expandafter\newcommand\expandafter*\expandafter |
| 137 |
% {\csname LaTeXdemo@#1\endcsname}{#2}^^A |
| 138 |
% \expandafter\newcommand\expandafter*\expandafter |
| 139 |
% {\csname LaTeXdemo@#1@end\endcsname}{#3}^^A |
| 140 |
%} |
| 141 |
%\newcommand*\LaTeXdemo@common{^^A |
| 142 |
% \setkeys{lst} |
| 143 |
% { |
| 144 |
% basicstyle = \small\ttfamily, |
| 145 |
% basewidth = 0.51em, |
| 146 |
% gobble = 3, |
| 147 |
% keywordstyle = \color{blue}, |
| 148 |
% language = [LaTeX]{TeX}, |
| 149 |
% moretexcs = |
| 150 |
% { |
| 151 |
% pgfkeys , |
| 152 |
% ProcessPgfOptions , |
| 153 |
% ProcessPgfPackageOptions , |
| 154 |
% } |
| 155 |
% }^^A |
| 156 |
%} |
| 157 |
%\newcommand*\LaTeXdemo@input{^^A |
| 158 |
% \MakePercentComment |
| 159 |
% \catcode`\^^M=10\relax |
| 160 |
% \small |
| 161 |
% \begingroup |
| 162 |
% \setkeys{lst}^^A |
| 163 |
% {^^A |
| 164 |
% SelectCharTable=\lst@ReplaceInput{\^\^I}{\lst@ProcessTabulator} |
| 165 |
% }^^A |
| 166 |
% \leavevmode |
| 167 |
% \input{\jobname.tmp}^^A |
| 168 |
% \endgroup |
| 169 |
% \MakePercentIgnore |
| 170 |
%} |
| 171 |
%\LaTeXdemo@new{code only}{\LaTeXdemo@common}{} |
| 172 |
% |
| 173 |
%\MakeShortVerb\" |
| 174 |
%\DeleteShortVerb\| |
| 175 |
% |
| 176 |
%\providecommand*\file{\texttt} |
| 177 |
%\providecommand*\opt{\texttt} |
| 178 |
%\providecommand*\pkg{\textsf} |
| 179 |
% |
| 180 |
%\makeatother |
| 181 |
% |
| 182 |
%\title{^^A |
| 183 |
% \textsf{pgfopts} --- LaTeX package options with |
| 184 |
% \pkg{pgfkeys}\thanks{^^A |
| 185 |
% This file describes version \fileversion, last revised |
| 186 |
% \filedate.^^A |
| 187 |
% }^^A |
| 188 |
%} |
| 189 |
%\author{^^A |
| 190 |
% Joseph Wright\thanks{E-mail: [email protected]}^^A |
| 191 |
%} |
| 192 |
%\date{Released \filedate} |
| 193 |
% |
| 194 |
%\maketitle |
| 195 |
% |
| 196 |
%\changes{v1.0}{2008/06/26}{First public release} |
| 197 |
%\changes{v2.0}{2009/04/30}{Complete internal rewrite} |
| 198 |
%\changes{v2.1}{2011/06/02}{Allow for \texttt{.unknown} handler for |
| 199 |
% class options} |
| 200 |
%\changes{v2.1a}{2014/07/10}{Fix incorrect \cs{Provides\ldots} line} |
| 201 |
% |
| 202 |
%\begin{abstract} |
| 203 |
% Using key--value options for packages and macros is a good way of |
| 204 |
% handling large numbers of options with a clean interface. The |
| 205 |
% \pkg{pgfkeys} package provides a very well designed system for |
| 206 |
% defining and using keys, but does not make this available for |
| 207 |
% handling LaTeX class and package options. The \pkg{pgfopts} package |
| 208 |
% adds this ability to \pkg{pgfkeys}, in the same way that |
| 209 |
% \pkg{kvoptions} extends the \pkg{keyval} package. |
| 210 |
%\end{abstract} |
| 211 |
% |
| 212 |
%\tableofcontents |
| 213 |
% |
| 214 |
%\section{Introduction} |
| 215 |
% |
| 216 |
% The key--value method for optional arguments is very popular, as it |
| 217 |
% allows the class or package author to define a large number of |
| 218 |
% options with a simple interface. A number of packages can be used |
| 219 |
% to provide the key management system, most of which load or extent |
| 220 |
% the parent \pkg{keyval} package. On its own, \pkg{keyval} can only |
| 221 |
% be used for parsing the arguments of macros. However, a number of |
| 222 |
% packages have extended the method to processing LaTeX class and |
| 223 |
% package options. This processing is made available as part of two |
| 224 |
% general-purpose packages \pkg{xkeyval} and \pkg{kvoptions}; both |
| 225 |
% allow the author of a class or package to process key--value |
| 226 |
% options given at load-time. |
| 227 |
% |
| 228 |
% The \pkg{pgfkeys} package provides a somewhat different key--value |
| 229 |
% system to \pkg{keyval} and derivatives. This uses a completely |
| 230 |
% different model for defining and using keys, although for the |
| 231 |
% end-user the result appears very similar. The \pkg{pgfopts} package |
| 232 |
% allows keys defined with \pkg{pgfkeys} to be used as class or |
| 233 |
% package options, in the same way that \pkg{kvoptions} extends |
| 234 |
% \pkg{keyval}. |
| 235 |
% |
| 236 |
% Users of \pkg{pgfopts} should be familiar with the general methods |
| 237 |
% used by \pkg{pgfkeys}. These are outlined in the manual for the |
| 238 |
% Ti\emph{k}z and \pkg{pgf} bundle. |
| 239 |
% |
| 240 |
%\section{Installation} |
| 241 |
% |
| 242 |
% The package is supplied in \file{dtx} format and as a pre-extracted |
| 243 |
% zip file, \file{\jobname.tds.zip}. The later is most convenient for |
| 244 |
% most users: simply unzip this in your local texmf directory and |
| 245 |
% run \texttt{texhash} to update the database of file locations. If |
| 246 |
% you want to unpack the \file{dtx} yourself, running |
| 247 |
% \texttt{tex \jobname.dtx} will extract the package whereas |
| 248 |
% \texttt{latex \jobname.dtx} will extract it and also typeset the |
| 249 |
% documentation. |
| 250 |
% |
| 251 |
% Typesetting the documentation requires a number of packages in |
| 252 |
% addition to those needed to use the package. This is mainly |
| 253 |
% because of the number of demonstration items included in the text. To |
| 254 |
% compile the documentation without error, you will need the packages: |
| 255 |
% \begin{itemize} |
| 256 |
% \item \pkg{csquotes} |
| 257 |
% \item \pkg{helvet} |
| 258 |
% \item \pkg{hypdoc} |
| 259 |
% \item \pkg{listings} |
| 260 |
% \item \pkg{lmodern} |
| 261 |
% \item \pkg{mathpazo} |
| 262 |
% \item \pkg{microtype} |
| 263 |
%\end{itemize} |
| 264 |
% |
| 265 |
%\section{Using the package} |
| 266 |
% |
| 267 |
%\subsection{Creating options} |
| 268 |
% |
| 269 |
% To create package or class options for use with \pkg{pgfopts}, it is |
| 270 |
% only necessary to define the appropriate keys. Taking as an |
| 271 |
% example a package \enquote{\pkg{MyOwnPackage}}, which uses the prefix |
| 272 |
% \texttt{MOP} on internal macros, creating keys would take the form: |
| 273 |
%\begin{LaTeXdemo}[code only] |
| 274 |
% \pgfkeys{ |
| 275 |
% /MOP/.cd, |
| 276 |
% keyone/.code=\wlog{Value '#1' given}, |
| 277 |
% keytwo/.store in=\MOP@store |
| 278 |
% } |
| 279 |
%\end{LaTeXdemo} |
| 280 |
% Here, \opt{keyone} simply writes its argument to the log, while |
| 281 |
% \opt{keytwo} stores the value given in the \cs{MOP@store} macro. |
| 282 |
% |
| 283 |
% An important point to notice is that the key names \emph{do not} |
| 284 |
% contain a space. This is because the LaTeX kernel removes spaces |
| 285 |
% from options before they are passed to the class or package. Spaces |
| 286 |
% can occur in the path to the key, but not in the key name itself. |
| 287 |
% This restriction only applies to keys used as options. |
| 288 |
% |
| 289 |
%\subsection{Processing options} |
| 290 |
% |
| 291 |
%\DescribeMacro{\ProcessPgfOptions} |
| 292 |
% The \cs{ProcessPgfOptions} macro is used to process package or |
| 293 |
% class options using \pkg{pgfkeys}. When used in a package, it |
| 294 |
% will also examine the available class options, and use any which |
| 295 |
% match declared package options. \cs{ProcessPgfOptions} requires |
| 296 |
% the \pkg{pgfkeys} key \meta{path} to search for options. Thus |
| 297 |
% for the example of \pkg{MyOwnPackage} given in the previous |
| 298 |
% section, the appropriate call would be |
| 299 |
%\begin{LaTeXdemo}[code only] |
| 300 |
% \ProcessPgfOptions{/MOP} |
| 301 |
%\end{LaTeXdemo} |
| 302 |
% Alternatively, \cs{ProcessPgfOptions} can be given with a |
| 303 |
% star: |
| 304 |
%\begin{LaTeXdemo}[code only] |
| 305 |
% \ProcessPgfOptions* |
| 306 |
%\end{LaTeXdemo} |
| 307 |
% The macro will then use the current file name as the path. This will |
| 308 |
% be the name of the current class or package, as appropriate. |
| 309 |
% |
| 310 |
%\DescribeMacro{\ProcessPgfPackageOptions} |
| 311 |
%\changes{v2.0}{2010/05/01}{New \cs{ProcessPgfPackageOptions} |
| 312 |
% macro} |
| 313 |
% As a complement to \cs{ProcessPgfOptions}, the macro |
| 314 |
% \cs{ProcessPgfPackageOptions} is also provided. As the name indicates, |
| 315 |
% this is intended for use in packages. It does \emph{not} examine the |
| 316 |
% list of global class options, processing only the list of options |
| 317 |
% given for the class itself. If used in a class, the behaviour will |
| 318 |
% be identical to \cs{ProcessPgfOptions}. |
| 319 |
% |
| 320 |
%\StopEventually{^^A |
| 321 |
% \PrintChanges |
| 322 |
% \PrintIndex |
| 323 |
%} |
| 324 |
% |
| 325 |
%\section{Implementation} |
| 326 |
% |
| 327 |
% The code here is based heavily on \pkg{kvoptions}, which has a |
| 328 |
% similar aim to \pkg{pgfopts}, but works with \pkg{keyval} and derived |
| 329 |
% packages. |
| 330 |
% |
| 331 |
% \begin{macrocode} |
| 332 |
%<*package> |
| 333 |
\ProvidesPackage{pgfopts} |
| 334 |
[2014/07/10 v2.1a LaTeX package options with pgfkeys] |
| 335 |
% \end{macrocode} |
| 336 |
% |
| 337 |
% The only package requires is \pkg{pgfkeys} itself. |
| 338 |
% \begin{macrocode} |
| 339 |
\RequirePackage{pgfkeys} |
| 340 |
% \end{macrocode} |
| 341 |
% |
| 342 |
%\begin{macro}{\ifpgfopts@process@class} |
| 343 |
% The processing of options can apply to those which are given for |
| 344 |
% a class, or can be limited to those of the package only. |
| 345 |
% \begin{macrocode} |
| 346 |
\newif\ifpgfopts@process@class |
| 347 |
% \end{macrocode} |
| 348 |
%\end{macro} |
| 349 |
% |
| 350 |
%\begin{macro}{\pgfopts@options@clist} |
| 351 |
% A comma-separated list of options to process. |
| 352 |
% \begin{macrocode} |
| 353 |
\newcommand*\pgfopts@options@clist{} |
| 354 |
% \end{macrocode} |
| 355 |
%\end{macro} |
| 356 |
% |
| 357 |
%\begin{macro}{\pgfopts@options@execute} |
| 358 |
% A storage macro which specifies the final list of options to |
| 359 |
% actually execute. |
| 360 |
% \begin{macrocode} |
| 361 |
\newcommand*\pgfopts@options@execute{} |
| 362 |
% \end{macrocode} |
| 363 |
%\end{macro} |
| 364 |
% |
| 365 |
%\begin{macro}{\pgfopts@key@path} |
| 366 |
%\begin{macro}{\pgfopts@process@options} |
| 367 |
% The main processing macro first clears the list of options to deal |
| 368 |
% with, and stores the key path to use. Global and local options are |
| 369 |
% then added to the \enquote{to do} list before executing the options. |
| 370 |
% \begin{macrocode} |
| 371 |
\newcommand*\pgfopts@key@path{} |
| 372 |
\newcommand\pgfopts@process@options[1]{% |
| 373 |
\def\pgfopts@options@clist{}% |
| 374 |
\def\pgfopts@options@execute{}% |
| 375 |
\def\pgfopts@key@path{#1/}% |
| 376 |
\ifx\@currext\@clsextension\else |
| 377 |
\expandafter\pgfopts@check@class@options |
| 378 |
\fi |
| 379 |
\pgfopts@process@local@options |
| 380 |
\pgfopts@options@execute |
| 381 |
\let\CurrentOption\@empty |
| 382 |
\AtEndOfPackage{\let\@unprocessedoptions\relax}% |
| 383 |
} |
| 384 |
% \end{macrocode} |
| 385 |
%\end{macro} |
| 386 |
%\end{macro} |
| 387 |
% |
| 388 |
%\begin{macro}{\pgfopts@current@option} |
| 389 |
%\begin{macro}{\pgfopts@check@class@options} |
| 390 |
%\begin{macro}{\pgfopts@check@class@options@aux} |
| 391 |
% First, a check to see if class options should be processed, and if so |
| 392 |
% if there are any. If so, then each option needs to be examined. Any |
| 393 |
% \texttt{=\meta{value}} is removed, and a test is made to see if |
| 394 |
% the resulting \meta{key} was defined for the current \meta{path}. |
| 395 |
% If so, the option is added to the list for processing later, and |
| 396 |
% it is removed from the list of unused options. The syntax for the |
| 397 |
% later process is rather complex, but LaTeX2e's function to |
| 398 |
% achieve that is somewhat awkward. |
| 399 |
% \begin{macrocode} |
| 400 |
\newcommand*\pgfopts@current@option{} |
| 401 |
\newcommand*\pgfopts@check@class@options{% |
| 402 |
\ifpgfopts@process@class |
| 403 |
\ifx\@classoptionslist\relax\else |
| 404 |
\expandafter\expandafter\expandafter |
| 405 |
\pgfopts@check@class@options@aux |
| 406 |
\fi |
| 407 |
\fi |
| 408 |
} |
| 409 |
\newcommand*\pgfopts@check@class@options@aux{% |
| 410 |
\@for\pgfopts@current@option:=\@classoptionslist\do |
| 411 |
{% |
| 412 |
\pgfkeysifdefined |
| 413 |
{% |
| 414 |
\pgfopts@key@path |
| 415 |
\pgfopts@get@key@name\pgfopts@current@option |
| 416 |
/.@cmd% |
| 417 |
}% |
| 418 |
{% |
| 419 |
\pgfopts@list@add\pgfopts@options@clist\pgfopts@current@option |
| 420 |
\@expandtwoargs\@removeelement\pgfopts@current@option |
| 421 |
\@unusedoptionlist\@unusedoptionlist |
| 422 |
}% |
| 423 |
{}% |
| 424 |
}% |
| 425 |
} |
| 426 |
% \end{macrocode} |
| 427 |
%\end{macro} |
| 428 |
%\end{macro} |
| 429 |
%\end{macro} |
| 430 |
% |
| 431 |
%\begin{macro}{\pgfopts@local@options} |
| 432 |
%\begin{macro}{\pgfopts@process@local@options} |
| 433 |
%\begin{macro}{\pgfopts@process@local@options@aux@i} |
| 434 |
%\begin{macro}{\pgfopts@process@local@options@aux@ii} |
| 435 |
%\begin{macro}{\pgfopts@process@local@options@class} |
| 436 |
%\begin{macro}{\pgfopts@process@local@options@class@aux} |
| 437 |
%\begin{macro}{\pgfopts@process@local@options@package} |
| 438 |
% The first step in processing local options is to see if any exist. |
| 439 |
% This is done inside a group to avoid polluting the hash table. If |
| 440 |
% options are found, these are transferred into a storage macro and |
| 441 |
% the auxiliary function is called. There is then a fork depending on |
| 442 |
% whether a package or class is being processed. Once the list is |
| 443 |
% finalised, the execution macro is set up appropriately. |
| 444 |
% \begin{macrocode} |
| 445 |
\newcommand*\pgfopts@local@options{} |
| 446 |
\newcommand*\pgfopts@process@local@options{% |
| 447 |
\begingroup |
| 448 |
\@ifundefined{opt@\@currname.\@currext}% |
| 449 |
{\endgroup}% |
| 450 |
{% |
| 451 |
\toks@\expandafter\expandafter\expandafter |
| 452 |
{\csname opt@\@currname.\@currext\endcsname}% |
| 453 |
\expandafter\endgroup |
| 454 |
\expandafter\def\expandafter\pgfopts@local@options |
| 455 |
\expandafter{\the\toks@}% |
| 456 |
\pgfopts@process@local@options@aux@i |
| 457 |
}% |
| 458 |
} |
| 459 |
\newcommand*\pgfopts@process@local@options@aux@i{% |
| 460 |
\ifx\@currext\@clsextension |
| 461 |
\expandafter\pgfopts@process@local@options@class |
| 462 |
\else |
| 463 |
\expandafter\pgfopts@process@local@options@package |
| 464 |
\fi |
| 465 |
\ifx\pgfopts@options@clist\@empty\else |
| 466 |
\expandafter\pgfopts@process@local@options@aux@ii |
| 467 |
\fi |
| 468 |
} |
| 469 |
\newcommand*\pgfopts@process@local@options@aux@ii{% |
| 470 |
\begingroup |
| 471 |
\toks@\expandafter{\pgfopts@options@clist}% |
| 472 |
\edef\pgfopts@options@execute |
| 473 |
{% |
| 474 |
\noexpand\pgfkeys |
| 475 |
{% |
| 476 |
\pgfopts@key@path .cd,% |
| 477 |
\the\toks@ |
| 478 |
}% |
| 479 |
}% |
| 480 |
\expandafter\endgroup |
| 481 |
\expandafter\def\expandafter\pgfopts@options@execute |
| 482 |
\expandafter{\pgfopts@options@execute}% |
| 483 |
} |
| 484 |
% \end{macrocode} |
| 485 |
% Options given for a class may not be applicable to the class itself, |
| 486 |
% and so they have to be checked. First, there is a simple test for an |
| 487 |
% unknown key handler: if it exists then there is no need to look at |
| 488 |
% each option separately. |
| 489 |
% \begin{macrocode} |
| 490 |
\newcommand*\pgfopts@process@local@options@class |
| 491 |
{% |
| 492 |
\pgfkeysifdefined{\pgfopts@key@path .unknown/.@cmd}% |
| 493 |
{\pgfopts@list@add\pgfopts@options@clist\@classoptionslist} |
| 494 |
{\pgfopts@process@local@options@class@aux}% |
| 495 |
} |
| 496 |
\newcommand*\pgfopts@process@local@options@class@aux{% |
| 497 |
\@for\pgfopts@current@option:=\pgfopts@local@options\do{% |
| 498 |
\pgfkeysifdefined |
| 499 |
{% |
| 500 |
\pgfopts@key@path |
| 501 |
\pgfopts@get@key@name\pgfopts@current@option |
| 502 |
/.@cmd% |
| 503 |
}% |
| 504 |
{\pgfopts@list@add\pgfopts@options@clist\pgfopts@current@option}% |
| 505 |
{\pgfopts@list@add\@unusedoptionlist\pgfopts@current@option}% |
| 506 |
}% |
| 507 |
} |
| 508 |
% \end{macrocode} |
| 509 |
% For packages, the local options are simply added to the list already |
| 510 |
% set up from the global values. |
| 511 |
% \begin{macrocode} |
| 512 |
\newcommand*\pgfopts@process@local@options@package{% |
| 513 |
\pgfopts@list@add\pgfopts@options@clist\pgfopts@local@options |
| 514 |
} |
| 515 |
% \end{macrocode} |
| 516 |
%\end{macro} |
| 517 |
%\end{macro} |
| 518 |
%\end{macro} |
| 519 |
%\end{macro} |
| 520 |
%\end{macro} |
| 521 |
%\end{macro} |
| 522 |
%\end{macro} |
| 523 |
% |
| 524 |
%\begin{macro}{\pgfopts@get@key@name} |
| 525 |
%\begin{macro}{\pgfopts@get@key@name@aux} |
| 526 |
% A simple function to leave only the key \meta{name} in the input |
| 527 |
% stream, whether there is a \meta{value} or not. This needs to work |
| 528 |
% with options which do not contain an equals sign at all. It is |
| 529 |
% designed to work with a stored value. |
| 530 |
% \begin{macrocode} |
| 531 |
\newcommand\pgfopts@get@key@name[1]{% |
| 532 |
\expandafter\pgfopts@get@key@name@aux#1=\@nil |
| 533 |
} |
| 534 |
\def\pgfopts@get@key@name@aux#1=#2\@nil{#1} |
| 535 |
% \end{macrocode} |
| 536 |
%\end{macro} |
| 537 |
%\end{macro} |
| 538 |
% |
| 539 |
%\begin{macro}{\pgfopts@list@add@a@toks} |
| 540 |
%\begin{macro}{\pgfopts@list@add@b@toks} |
| 541 |
%\begin{macro}{\pgfopts@list@add@temp} |
| 542 |
%\begin{macro}{\pgfopts@list@add} |
| 543 |
% This function takes "#1" as the name of a comma-separated list and |
| 544 |
% "#2" as the name of a macro containing content to add to the list. |
| 545 |
% After the appropriate checks it adds the content of "#2" to the |
| 546 |
% right hand end of variable "#1". |
| 547 |
% \begin{macrocode} |
| 548 |
\newtoks\pgfopts@list@add@a@toks |
| 549 |
\newtoks\pgfopts@list@add@b@toks |
| 550 |
\newcommand*\pgfopts@list@add@temp{} |
| 551 |
\newcommand\pgfopts@list@add[2]{% |
| 552 |
\pgfopts@list@add@a@toks\expandafter{#2}% |
| 553 |
\def\pgfopts@list@add@temp{#2}% |
| 554 |
\pgfopts@list@add@b@toks\expandafter{#1}% |
| 555 |
\ifx\pgfopts@options@clist\@empty |
| 556 |
\edef#1{\the\pgfopts@list@add@a@toks}% |
| 557 |
\else |
| 558 |
\ifx\pgfopts@list@add@temp\@empty\else |
| 559 |
\edef#1% |
| 560 |
{\the\pgfopts@list@add@b@toks,\the\pgfopts@list@add@a@toks}% |
| 561 |
\fi |
| 562 |
\fi |
| 563 |
} |
| 564 |
% \end{macrocode} |
| 565 |
%\end{macro} |
| 566 |
%\end{macro} |
| 567 |
%\end{macro} |
| 568 |
%\end{macro} |
| 569 |
% |
| 570 |
%\begin{macro}{\ProcessPgfOptions} |
| 571 |
%\begin{macro}{\ProcessPgfPackageOptions} |
| 572 |
%\begin{macro}{\pgfopts@star@check} |
| 573 |
% The two user functions set the flag for class option processing. |
| 574 |
% A shared internal function then checks for a star, and either adds |
| 575 |
% the current name or looks to pick one up from the input stream. |
| 576 |
% \begin{macrocode} |
| 577 |
\newcommand*\ProcessPgfOptions{% |
| 578 |
\pgfopts@process@classtrue |
| 579 |
\pgfopts@star@check |
| 580 |
} |
| 581 |
\newcommand*\ProcessPgfPackageOptions{% |
| 582 |
\pgfopts@process@classfalse |
| 583 |
\pgfopts@star@check |
| 584 |
} |
| 585 |
\newcommand*\pgfopts@star@check{% |
| 586 |
\@ifstar |
| 587 |
{% |
| 588 |
\begingroup |
| 589 |
\edef\@tempa |
| 590 |
{% |
| 591 |
\endgroup |
| 592 |
\noexpand\pgfopts@process@options{/\@currname}% |
| 593 |
}% |
| 594 |
\@tempa |
| 595 |
}% |
| 596 |
{\pgfopts@process@options}% |
| 597 |
} |
| 598 |
\@onlypreamble\ProcessPgfOptions |
| 599 |
\@onlypreamble\ProcessPgfPackageOptions |
| 600 |
%</package> |
| 601 |
% \end{macrocode} |
| 602 |
%\end{macro} |
| 603 |
%\end{macro} |
| 604 |
%\end{macro} |
| 605 |
% |
| 606 |
%\Finale |