diff options
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/doc/latex/keyreader/README | 10 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/keyreader/keyreader-guide.pdf | bin | 241488 -> 250340 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/keyreader/keyreader-guide.tex | 205 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/keyreader/keyreader-guide.cfg | 61 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/keyreader/keyreader.sty | 260 |
5 files changed, 429 insertions, 107 deletions
diff --git a/Master/texmf-dist/doc/latex/keyreader/README b/Master/texmf-dist/doc/latex/keyreader/README index fc0c781397e..fa3a3b270fd 100644 --- a/Master/texmf-dist/doc/latex/keyreader/README +++ b/Master/texmf-dist/doc/latex/keyreader/README @@ -6,7 +6,7 @@ Ahmed Musa VERSION -Version 0.4a, December 2011 +Version 0.4b, January 2012 SUMMARY @@ -16,8 +16,10 @@ Keys are automatically set/initialized as soon as they are defined. It provides a compact and robust interface to the xkeyval package. The xkeyval package's commands for setting keys are made more robust, in the sense that outer braces in key values are preserved throughout -parsing. In the case of choice keys, each admissible value of the key -can be associated with a callback, unlike in the xkeyval package. +parsing and unbalanced conditionals can be parsed as part of a key's +value. In the case of choice keys defined by the command +\krddefinekeys, each admissible value of the key can be associated +with a callback, unlike in the xkeyval package. The keyreader package has been used as a development platform for the ltxkeys package because the xkeyval package, on which the keyreader @@ -26,7 +28,7 @@ shortcomings not withstanding). LICENSE -Copyright (c) 2011 Ahmed Musa. +Copyright (c) 2010-2012 Ahmed Musa This software is author-maintained. Permission is granted to copy, distribute and/or modify this software under the terms of the diff --git a/Master/texmf-dist/doc/latex/keyreader/keyreader-guide.pdf b/Master/texmf-dist/doc/latex/keyreader/keyreader-guide.pdf Binary files differindex 656583c7d3d..899cb1c32bc 100644 --- a/Master/texmf-dist/doc/latex/keyreader/keyreader-guide.pdf +++ b/Master/texmf-dist/doc/latex/keyreader/keyreader-guide.pdf diff --git a/Master/texmf-dist/doc/latex/keyreader/keyreader-guide.tex b/Master/texmf-dist/doc/latex/keyreader/keyreader-guide.tex index 41c1ca88398..6f8ce6b1319 100644 --- a/Master/texmf-dist/doc/latex/keyreader/keyreader-guide.tex +++ b/Master/texmf-dist/doc/latex/keyreader/keyreader-guide.tex @@ -26,12 +26,12 @@ \begin{document} \begin{frontmatter} -\title{The \texttt{\color{blue}keyreader} Package\titleref{t1,t2}} +\title{} \titlenotes[t1,t2]{% The package is available at \url{\titleurltext}.\sep - This user manual corresponds to version~0.4a of the package. + This user manual corresponds to version~0.4b of the package. } -\subtitle{A robust interface to \pkg'{xkeyval}} +\subtitle{} \titleurl{http://mirror.ctan.org/macros/latex/contrib/keyreader/} \author{Ahmed Musa\authorref{a1}} \authornotes[a1]{% @@ -39,8 +39,7 @@ } \def\abstractname{\textsf{Summary}} \begin{abstract} - \small - The \pkg'{keyreader} provides robustness and some extensions to the \pkg'{xkeyval}. It preserves braces in key values and saves estate when defining keys. Also, when the command \fx{\krddefinekeys} is used, keys are initialized as soon as they are defined, and, unlike in the \pkg'{xkeyval}, admissible alternate values of choice keys can have individual callbacks. This user manual assumes that the reader is familiar with some of the functions and user interfaces of the \pkg'{xkeyval}. + The \pkg'{keyreader} provides robustness and some extensions to the \pkg'{xkeyval}. It preserves braces in key values throughout parsing and saves estate when defining keys. Also, the command \fx{\krdsetkeys} allows unbalanced conditionals to be parsed as values of keys. Furthermore, when the command \fx{\krddefinekeys} is used, keys are initialized as soon as they are defined, and, unlike in the \pkg'{xkeyval}, admissible alternate values of choice keys can have individual callbacks. The looping macros of the \pkg'{xkeyval} are redefined, to increase robustness. The command \fx{\define@key} of the \pkg'{xkeyval} has had two of its subordinate commands redefined, to offset a complaint about the grabbing of the key's callback when defining keys with \fx{\define@key}. This user manual assumes that the reader is familiar with some of the functions and user interfaces of the \pkg'{xkeyval}. \end{abstract} \let\licensename\relax @@ -59,24 +58,25 @@ \normalcolor\normalfont \hrule \vskip 1ex plus 1pt minus 1pt -\def\contentsname{\centerline{\Large\sffamily\textcolor{blue}{Contents}}}% -\hypersetup{linkcolor=blue}\tableofcontents +\def\contentsname{\centerline{\Large\textcolor{blue}{Contents}}} +\hypersetup{linkcolor=blue} +\textsf{\tableofcontents} \hrule \endgroup -\vspace{3\baselineskip} -\newpage \docsection(sec:motivation){Motivation} -The \pkg'{keyreader} predated the \pkg'{ltxkeys} and was developed to make key parsing by the \pkg'{xkeyval} robust (in the sense of preserving outer braces in key values throughout parsing), as well as reduce the amount of typing that is required for defining several keys. To achieve robustness in key parsing, the \fx{\setkeys} command of the \pkg'{xkeyval} has been patched and renamed \fx{\krdsetkeys}. The \pkg'{keyreader} provides commands for compactly defining and setting all types of key (ordinary, command, boolean, and choice). Also, the \pkg'{keyreader} introduces the concept of callbacks for the alternate/admissible values of choice keys defined via the command \fx{\krddefinekeys}. Moreover, when \fx{\krddefinekeys} is used, keys are automatically set/initialized as soon as they are defined. This provides default definitions for the key macros and functions. Boolean keys are initialized with a value of \hx{false} irrespective of their default values. +The \pkg'{keyreader} predated the \pkg'{ltxkeys} and was developed to make key parsing by the \pkg'{xkeyval} robust (in the sense of preserving outer braces in key values throughout parsing and enabling the parsing of key values with unbalanced conditionals), as well as reduce the amount of typing that is required for defining several keys. To achieve robustness in key parsing, the \fx{\setkeys} command of the \pkg'{xkeyval} has been patched and renamed \fx{\krdsetkeys}. The \pkg'{xkeyval}'s \fx{\setkeys} remains unchanged, to avoid breaking existing codes that rely on it's current form. Some other low-level commands of \pkg'{xkeyval} have been patched and renamed. The \pkg'{keyreader} provides commands for compactly defining and setting all types of key (ordinary, command, boolean, and choice). Also, the \pkg'{keyreader} introduces the concept of callbacks for the alternate/admissible values of choice keys defined via the command \fx{\krddefinekeys}. Moreover, when \fx{\krddefinekeys} is used, keys are automatically set/initialized as soon as they are defined. This provides default definitions for the key macros and functions. Boolean keys are initialized with a value of \hx{false} irrespective of their default values. The \pkg'{keyreader} has been used as a development platform for the \pkg'{ltxkeys} because the \pkg'{xkeyval}, on which the \pkg'{keyreader} is based, has been quite stable for some years, its inherent -shortcomings not withstanding. Because the \pkg'{keyreader} is based on the \pkg'{xkeyval}, it inherits some of the limitations of the \pkg'{xkeyval}. Has the user ever tried to pass to \pkg'{xkeyval}'s \fx{\setkeys} an unbalanced conditional (invloving \hhx{\iftrue,\iffalse,\ifx}, or \hx{\fi}) as the value of a key? He/she will quickly be hit by the error message \quoted{! Incomplete \hx{\ifx}; all text was ignored after line \ldots}, or something similar. The same limitation applies to the \pkg'{keyreader}. In this respect, the \pkg'{ltxkeys} is more robust. +shortcomings not withstanding. Has the user ever tried to pass to \pkg'{xkeyval}'s \fx{\setkeys} an unbalanced conditional as the value of a key? He/she will quickly be hit by the error message \quoted{! Incomplete \hx{\ifx}; all text was ignored after line \ldots}, or something similar. This limitation has been removed by the \pkg'{keyreader}. \docsection(sec:user-commands)<user commands>{User commands} -The syntax for defining new keys is: +\docsubsection(sec:definingkeys){Defining keys} + +The syntax for defining keys is: \start{newmacro}[\krddefinekeys] \krddefinekeys|*[|A(kprefix)]{|A(kfamily)}[|A(mprefix)]{|A(keylist)} @@ -87,75 +87,89 @@ The optional \ang{kprefix} and mandatory \ang{kfamily} have unambiguous connotat In the case of ordinary, command and boolean keys, \ang{keylist} has the syntax -\start'{newmacro}[Syntax of key keylist] +\start'{macro}[Syntax of key keylist] { - |A(keytype1)/|A(keyname1)/|A(default1)/|A(callback1); - |A(keytype2)/|A(keyname2)/|A(default2)/|A(callback2); - etc. + |A(keytype-1)/|A(keyname-1)/|A(default-1)/|A(callback-1); + |A(keytype-2)/|A(keyname-2)/|A(default-2)/|A(callback-2); + ... + |A(keytype-n)/|A(keyname-n)/|A(default-n)/|A(callback-n); } -\finish{newmacro} +\finish{macro} The list parser for \ang{keylist} is invariably \qsemicolon. Hence, if the user has \qsemicolon in \ang{callback}, it has to be wrapped in curly braces, to hide it from \tex's scanner. \ang{keytype} can be any member of the list \leftbrace\fx{ord} (ordinary key), \fx{cmd} (command key), \fx{bool} (boolean key), \fx{choice} (choice key)\rightbrace. For choice keys, \ang{keylist} has the syntax -\start'{newmacro}[Syntax of key keylist] +\start'{macro}[Syntax of key keylist] { - |A(keytype1)/|A(keyname1)/|A(default1)/|A(alt)/|A(callback1); - |A(keytype2)/|A(keyname2)/|A(default2)/|A(alt)/|A(callback2); - etc. + |A(keytype-1)/|A(keyname-1)/|A(default-1)/|A(alt)/|A(callback-1); + |A(keytype-2)/|A(keyname-2)/|A(default-2)/|A(alt)/|A(callback-2); + ... + |A(keytype-n)/|A(keyname-n)/|A(default-n)/|A(alt)/|A(callback-n); } -\finish{newmacro} +\finish{macro} -The alternate (admissible list of) values \ang{alt} has the syntax +The \emph{alternate values} (also called \emph{nominations} or \emph{admissible list of user input}) \ang{alt} has the syntax -\start'{newmacro}[Syntax of alternate list for choice keys] -|A(value1).code=|A(callback1), -|A(value1).code=|A(callback1), -etc. -\finish{newmacro} +\start'{macro}[Syntax of alternate list for choice keys] +|A(value-1).do=|A(callback-1), +|A(value-2).do=|A(callback-2), +... +|A(value-n).do=|A(callback-n), +\finish{macro} The list parser in this case is invariably \qcomma. -The star (\redstar*) is an optional prefix. If it is present, then only definable (\ie, non-existent) keys will be defined. The existence of a key depends on \ang{kprefix} and \ang{kfamily}, since keys are name-spaced. +The star (\redstar*) sign on \fx{\krddefinekeys} is an optional suffix. If it is present, then only definable (\ie, non-existent) keys will be defined. The existence of a key depends on \ang{kprefix} and \ang{kfamily}, since keys are name-spaced. -The command \fx{\krdsetkeys} is a more robust counterpart of the \pkg'{xkeyval}'s \fx{\setkeys}, in the sense that it preserves all outer braces in the values of keys. The new command \fx{\krdsetkeys} has the same syntax as the original \fx{\setkeys} of the \pkg'{xkeyval}, namely +\ltsnote +Choice keys defined by \fx{\krddefinekeys} are of the \stform of choice keys (see the \pkg'{xkeyval} guide). Hence they will always convert the user input into lowercase before matching it against the alternate/admissible list of values specified at key definition time. The matching, as done by \fx{\krdsetkeys}, is catcode-agnostic. -\start{macro}[\setkeys] -\krdsetkeys|*|+[|A(kprefix)]{|A(families)}[|A(na)]{|A(|verbkeyval pairs)} -\finish{macro} -As usual, the star (\redstar) and plus sign (\redplus) are optional prefixes. The \stform will save all undeclared keys in the list \fx{\XKV@rm}, possibly for setting later with the command \fx{\setrmkeys}, and will not report any unknown key as undeclared. The \plform will set the given keys in all the given families, instead of in just one family. The combination \redstar\redplus* will set the listed keys in all the given families and append unknown keys to the container \fx{\XKV@rm}. \ang{na} is the list of keys that shouldn't be set in the current run. +\docsubsection(sec:settingkeys){Setting keys} + +The command \fx{\krdsetkeys} is a more robust counterpart of the \pkg'{xkeyval}'s \fx{\setkeys}, in the sense that it preserves all outer braces in the values of keys and allows the parsing of key values with unbalanced conditionals. The new command \fx{\krdsetkeys} has the same syntax as the original \fx{\setkeys} of the \pkg'{xkeyval}, namely + +\start{newmacro}[\krdsetkeys] +\krdsetkeys|*|+[|A(kprefix)]{|A(families)}[|A(na)]{|A(|verbkeyval)} +\finish{newmacro} +\fxim*{\krdsetkeys,\setkeys} + +As usual, the star (\redstar) and plus sign (\redplus) are optional suffixes. The \stform will save all undeclared keys in the list \fx{\XKV@rm}, possibly for setting later with the command \fx{\setrmkeys}, and will not report any unknown key as undeclared. The \plform will set the given keys in all the given families, instead of in just one family. The combination \redstar\redplus* will set the listed keys in all the given families and append unknown keys to the container \fx{\XKV@rm}. \ang{na} is the list of keys that shouldn't be set in the current run. -Since a package might redefine \fx{\setkeys}, we also saved the patched \fx{\setkeys} in \fx{\krdsetkeys}. Indeed, \fx{\krdsetkeys} isn't exactly \fx{\setkeys}, since the former avoids the selective sanitization of \keyval list that is done by \fx{\setkeys}. Instead \fx{\krdsetkeys} \quoted{normalizes} the \keyval or comma-separated list. Therefore, users of the \pkg'{keyreader} should always call the command \fx{\krdsetkeys} instead of \fx{\setkeys}. Both have the same user interface. +The command \fx{\krdsetkeys} isn't exactly \pkg'{xkeyval}'s \fx{\setkeys}, since the former is more robust and avoids the selective sanitization of \keyval list that is done by \fx{\setkeys}. The macro \fx{\krdsetkeys} \quoted{normalizes} the \keyval or comma-separated key list. Therefore, users of the \pkg'{keyreader} should always call the command \fx{\krdsetkeys} instead of \fx{\setkeys}. Both have the same user interface. The \fx{\setkeys} command of the \pkg'{xkeyval}'s remains unchanged. -The \pkg'{xkeyval}'s command \fxi{\setrmkeys}, which sets \quoted{remaining keys}, has been modified to \fxi{\krdsetrmkeys}, while keeping \fx{\setrmkeys} unchanged. Users of the \pkg'{keyreader} should use \fx{\krdsetrmkeys} in place of \fx{\setrmkeys}. +The \pkg'{xkeyval}'s command \fxi{\setrmkeys}, which sets \quoted{remaining keys}, has also been modified to \fxi{\krdsetrmkeys}, while keeping \fx{\setrmkeys} unchanged. Users of the \pkg'{keyreader} should use \fx{\krdsetrmkeys} in place of \fx{\setrmkeys}. -\docsection(sec:examples)<examples>{Examples} +\docsubsection(sec:examples)<examples>{Examples} -\start+{example}[\krddefinekeys, \krdsetkeys] +\start*+{example}[\krddefinekeys, \krdsetkeys] \krddefinekeys*[KV]{fam}[pnt@]{% - |com(`#1' here refers to the user input for the key.) + |com(`#1' throughout here refers to the user input for the key.) ord/keya/{black}/\def\xx##1{#1##1}; cmd/keyb/\@fisrtofone/\def\y##1{#1##1}; bool/keyc/true/\def\z##1{#1##1}; choice/keyd/center/ - center.code=\def\my@align{center}\def\w##1{#1##1}, - left.code=\def\my@align{flushleft}, - right.code=\def\my@align{flushright}, - justified.code=\def\my@align{relax}% - /\def\xa##1{#1##1}; + center.do=\def\vcp@align{center}\def\w##1{#1##1}, + left.do=\def\vcp@align{flushleft}, + right.do=\def\vcp@align{flushright}, + justified.do=\def\vcp@align{relax}/ + \ifkrddef\else + \def\xa##1{#1##1} + \fi; + ord/keye/{keye-default}/\def\y##1{#1##1} } \krdsetkeys[KV]{fam}[keyb]{keya={green},keyb=\@iden,keyc=false,keyd=left} +|com(Setting keys with values having unbalanced conditionals:) +\krdsetkeys[KV]{fam}{keye={\iffalse keye-value}} \finish{example} -\fxi*{\krddefinekeys,\setkeys,\krdsetkeys} -The braces around \quoted{green}, the value of \fx{keya}, will be preserved throughout parsing. It should be remembered that keys are automatically set as soon as they are defined by \fx{\krddefinekeys}. +The braces around \quoted{green}, the value of \fx{keya}, will be preserved throughout parsing. It should be remembered that keys are automatically set as soon as they are defined by \fx{\krddefinekeys}. The boolean \fx{\ifkrddef} is true when \fx{\krddefinekeys} is defining keys, and false otherwise. The essence of it is that since keys are set as soon as they are defined by \fx{\krddefinekeys}, some actions should not be executed at this time, until the keys are being set by the user. Using the keys defined in the above example, let us make \qcomma and \qequal active and see how the \pkg'{keyreader} will deal with them. -\start{example}[Active comma and equal sign] +\start*{example}[Active comma and equals sign] |com(Make comma (`,') and equal `=' active to test the list normalization) |com(scheme of `keyreader' pacakge:) \begingroup @@ -169,15 +183,99 @@ Using the keys defined in the above example, let us make \qcomma and \qequal act \expandafter\reserved@a\keylista \keylistb \finish{example} -\aidx*{active comma and equal sign} +\aidx*{active comma and equals sign} +The output of the following example is shown in \sref{fig:1}: -\docsection(sec:disable-keys)<disabling keys>{Disabling keys} +\start*{example}[\label{example:1}] +\documentclass{article} +\usepackage{keyreader} +\usepackage{xcolor} +\makeatletter +\newdimen\shadowsize +\krddefinekeys*[KV]{ebox}[mp@]{% + bool/frame/true; + bool/shadow/true; + cmd/framecolor/black; + cmd/shadecolor/white; + cmd/shadowcolor/gray; + cmd/framesize/.4pt; + cmd/boxsize/.1\columnwidth; + cmd/shadowsize/1pt; + choice/align/center/ + center.do=\let\mp@alignright\hfil\let\mp@alignleft\hfil, + right.do=\let\mp@alignright\hfill\let\mp@alignleft\relax, + left.do=\let\mp@alignright\relax\let\mp@alignleft\hfill, + justified.do=\let\mp@alignright\relax\let\mp@alignleft\relax + / + \def\userinput{#1}; +} +\savevaluekeys[KV]{ebox}{frame,framecolor,framesize} +|com(`Preset keys' have no `tail keys':) +\krdpresetkeys[KV]{ebox}{% + frame,framecolor=black,framesize=0.5pt,boxsize,align +} +|com(`Postset keys' have no `head keys':) +\krdpostsetkeys[KV]{ebox}{% + shadow=\usevalue{frame},shadowcolor=\usevalue{framecolor}!40, + shadowsize=\usevalue{framesize}*4 +} +\newcommand*\ebox[2][]{% + \setkeys[KV]{ebox}{#1}% + |com(What happens if we use the following, instead of the above \setkeys?) + |com(Preset and postset keys wouldn't be set when `#1' is empty:) + |com(\krdifblank{#1}{}{\setkeys[KV]{ebox}{#1}}) + \begingroup + \ifmp@frame + \fboxrule=\dimexpr\mp@framesize\relax + \else + \fboxrule=0pt + \fi + \ifmp@shadow + \shadowsize=\dimexpr\mp@shadowsize\relax + \else + \shadowsize=0pt + \fi + \setbox0=\hbox{% + \fcolorbox{\mp@framecolor}{\mp@shadecolor}{% + \hbox to\mp@boxsize{% + \mp@alignright #2\mp@alignleft + }% + }% + }% + \hskip\shadowsize + \color{\mp@shadowcolor}% + \rule[-\dp0]{\wd0}{\the\dimexpr\ht0+\dp0\relax}% + \llap{\raisebox{\shadowsize}{\box0\hskip\shadowsize}}% + \endgroup +} +\makeatother -The command \fxim{\krddisablekeys} has the same use syntax as \pkg'{xkeyval}'s command \fxi{\disable@keys} but will issue an error (instead of a warning) when an attempt is made to set a disabled key. +\begin{document} +\ebox{ebox1} +\ebox[framecolor=gray,boxsize=2cm,align=right]{ebox2} +\ebox[shadow=false,boxsize=1.5cm,align=left]{ebox3} +\ebox[framesize=1pt,framecolor=green,shadowcolor=blue]{ebox4} +\ebox[frame=false,shadow,shadowcolor=yellow,framesize=.5pt]{ebox5} +\end{document} +\finish{example} +\fxim*{\krdpresetkeys,\krdpostsetkeys} +\begin{figure}[h!] +\caption{Output of \sref{example:1}\label{fig:1}} +\centerline{% + \includegraphics[viewport=141 642 416 674,clip,scale=1] + {keyreader-example1}% +} +\end{figure} + + +\docsubsection(sec:disable-keys)<disabling keys>{Disabling keys} -\docsection(sec:options-processing)<options processing>{Options processing} +The command \fxim{\krddisablekeys} has the same use syntax as the \fxi{\disable@keys} command of the \pkg'{xkeyval}, but will issue an error (instead of a warning) when an attempt is made to set a disabled key. + + +\docsubsection(sec:options-processing)<options processing>{Options processing} The commands \ffxi'{\krdDeclareOption, \krdExecuteOptions, \krdProcessOptions} are aliases for \ffxi'{\DeclareOptionX, \ExecuteOptionsX, \ProcessOptionsX} of the \pkg'{xkeyval}. @@ -188,8 +286,11 @@ The commands \ffxi'{\krdDeclareOption, \krdExecuteOptions, \krdProcessOptions} a The following change history highlights significant changes that affect user utilities and interfaces; changes of technical nature are not documented in this section. \begin{versionhist} + \begin{version}{0.4b}{2012/01/14} + \item The command \fx{\krdsetkeys} can now parse key values with unbalanced conditionals. + \end{version} \begin{version}{0.4a}{2011/12/23} - \item Bug fix: the key list in \fx{\krddefinekeys} shouldn't have been normalized with respect to forward slash (/). + \item The key list in \fx{\krddefinekeys} shouldn't have been normalized with respect to forward slash (/). \end{version} \begin{version}{0.4}{2011/12/20} \item Several of the former functions of the package have been transferred to the \pkg'{ltxkeys} with even more robustness. The package now provides mainly a compact and robust interface to the features of the \pkg'{xkeyval}. diff --git a/Master/texmf-dist/tex/latex/keyreader/keyreader-guide.cfg b/Master/texmf-dist/tex/latex/keyreader/keyreader-guide.cfg new file mode 100644 index 00000000000..22fe64bc33e --- /dev/null +++ b/Master/texmf-dist/tex/latex/keyreader/keyreader-guide.cfg @@ -0,0 +1,61 @@ +\ProvidesFile{keyreader-guide.cfg}% + [2012/01/14 v0.0.3 Configuration file for keyreader-guide (AM)] + +\amltxoptions{% + geometryoptions = {left=3cm,right=3cm,top=2.5cm,% + bottom=2.5cm,includeheadfoot}, + reviewdocument = false, + parindent = false, + toc = false, + frontpagestyle = empty, + pretitleskip = 0ex, + posttitleskip = 1ex, + presuptitleskip = 0ex, + postsuptitleskip = 0ex, + presubtitleskip = 0ex, + postsubtitleskip = 0ex, + natbiboptions = {numbers,sort&compress}, + cmdcolor = xmagenta1, + stylecolor = xgreen1, + speccolor = teal, + sectionheadcolor = blue +} +\fancypagenos[% + textalign = center, + show-on-page-one = false, + show-page-numbers = true, + show-headrule = true, + show-footrule = false, + y-position = -.44\paperheight, + x-position = 0, + scale = 1, + angle = 0, + style = \textsc{Page~\thepage~of~\pageref{xwmlastpage}}, + left-header = The \textcolor{macrocolor}{keyreader} package, + right-header = \ttcl{black}{\today} +] + +\newwatermark +[page=1,fontfamily=phv,fontsize=11pt,fontseries=m,align=center, + coordunit=pc,width=.978\paperwidth,angle=0,scale=1,xpos=-.62,ypos=31.2]{% + \xwmcolorbox[framesep=5pt,framerule=2pt,fillcolor=white, + outerframecolor=Orange,innerframecolor=brown,textalign=justified, + width=.978\paperwidth]{% + \normalfont\small\color{black}\vspace*{-1ex}% + \parbox{.95\paperwidth}{% + \vspace*{2ex}% + \begin{center}% + \sffamily\bfseries + \scalebox{4}{The \textcolor{blue}{keyreader} Package\titleref{t1,t2}}% + \endgraf\vspace*{1ex}% + \scalebox{2}{A robust interface to \pkg'{xkeyval}}% + \endgraf\vspace*{1ex}% + {\normalsize\normalfont\sffamily + \copyright\ Ahmed Musa 2010-\number\year}% + \end{center}% + \vspace*{2ex}% + }% + }% +} + +\endinput diff --git a/Master/texmf-dist/tex/latex/keyreader/keyreader.sty b/Master/texmf-dist/tex/latex/keyreader/keyreader.sty index a64ec1e7908..7db99a9a5d2 100644 --- a/Master/texmf-dist/tex/latex/keyreader/keyreader.sty +++ b/Master/texmf-dist/tex/latex/keyreader/keyreader.sty @@ -1,6 +1,6 @@ %++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% % % -% This is file 'keyreader.sty', version 0.4a, December 2011. % +% This is file 'keyreader.sty', version 0.4b, January 2012. % % % % This package and accompanying files may be distributed and/or % % modified under the conditions of the LaTeX Project Public License, % @@ -16,12 +16,12 @@ % implied warranties of merchantability and fitness for a particular % % purpose. % % % -% Copyright (c) 2011 Ahmed Musa (amusa22@gmail.com). % +% Copyright (c) 2010-2012 Ahmed Musa (amusa22@gmail.com). % % % %++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% \ProvidesPackage{keyreader} - [2011/12/23 v0.4a Robust xkeyval package interface (AM)] + [2012/01/14 v0.4b Robust interfaces to xkeyval package (AM)] \ifcase \ifx\eTeXversion\@undefined\z@\else \ifnum\eTeXversion<\tw@\z@\else\@ne\fi\fi @@ -39,7 +39,9 @@ \def\reserved@a{\endgroup \def\do##1,{% \ifx##1\end\else - \catcode##1\string=\the\catcode##1\expandafter\do\fi + \catcode##1\string=\the\catcode##1 % + \expandafter\do + \fi }% \edef\krd@restorecodes{\do035,064,123,125,061,059,\end,}% } @@ -54,7 +56,7 @@ \ifx#1\end\else \edef\krd@restorecodes{% \krd@restorecodes - \catcode#1=\the\catcode#1\relax + \catcode#1=\the\catcode#1 % }% \catcode#1=#2\relax \expandafter\do @@ -73,6 +75,21 @@ \protected\def\krdnewlet#1{\@ifdefinable#1\relax\let#1} \krdnewlet\krd@nil\relax \def\krd@nnil{\krd@nil} +\def\krdswap#1#2{#2#1} +\def\krd@quark{\@gobble\krd@quark} +\newcount\krd@csvdepth +\newif\ifkrdloopbreak +\newif\ifkrd@st +\newif\ifkrddef +\krdnewlet\krdloopbreak\krdloopbreaktrue +\begingroup +\catcode`\&=7 +\gdef\krdtrimspace#1{\krd@trimspace@a.#1& &} +\gdef\krd@trimspace@a#1 &{\krd@trimspace@b#1&} +\gdef\krd@trimspace@b#1{% + \krdexpandonce{\romannumeral-`\q\expandafter\noexpand\@gobble#1}% +} +\endgroup \protected\def\krdAfterEndPackage{% \krdifcsndef{\@currname.\@currext-krd@endpkghook}{}{% \@namedef{\@currname.\@currext-krd@endpkghook}{}% @@ -89,7 +106,6 @@ }% \unexpanded\expandafter{\@popfilename}% } -\newcommand*\krd@quark{\@gobble\krd@quark} \newcommand*\krdifdef[1]{% \krdifblank{#1}\@secondoftwo{% \ifx#1\@undefined @@ -117,8 +133,9 @@ \expandafter\krdifdef\csname#1\endcsname }% } +\def\krd@ifx@quark{\@gobble\krd@ifx@quark} \newcommand\krdifx[2]{% - \ifx#1#2\krd@quark + \ifx#1#2\krd@ifx@quark \expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi } \long\def\krdifblank#1{% @@ -137,14 +154,14 @@ }% }% } -\def\krdifswitch@aux#1#2\krd@nil{% +\def\krd@ifswitch@aux#1#2\krd@nil{% \krdifblank{#2}\@secondoftwo\@firstoftwo } \def\krdifswitch#1{% \krdifblank{#1}{% \@secondoftwo }{% - \expandafter\krdifswitch@aux\romannumeral-`\q#1\krd@nil{% + \expandafter\krd@ifswitch@aux\romannumeral-`\q#1\krd@nil{% \if#1\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi }{% \@latex@error{Invalid switch '#1'}\@ehc @@ -154,7 +171,7 @@ \krdifx\pdfstrcmp\@undefined{% \RequirePackage{pdftexcmds}% \krdifx\pdf@strcmp\@undefined{% - \cpt@err{Neither \string\pdfstrcmp nor \string\pdf@strcmp exists}\@ehc + \cpt@err{Neither '\string\pdfstrcmp' nor '\string\pdf@strcmp' exists}\@ehc }{% \let\krd@pdfstrcmp\pdf@strcmp }% @@ -165,8 +182,20 @@ \csname @\ifnum\krd@pdfstrcmp{\detokenize{#1}}% {\detokenize{#2}}=0first\else second\fi oftwo\endcsname } -\def\krdifbraced#1{\krd@ifbraced#1\krd@nil{#1}} -\def\krd@ifbraced#1\krd@nil#2{% +\def\krdifbraced#1{% + \expandafter\krdswap\expandafter{% + \expandafter{\romannumeral-`\q\krd@ifbraced@a{#1}}% + }{% + \expandafter\krd@ifbraced@d\romannumeral-`\q\krd@ifbraced@a{#1}\krd@nil + }% +} +\begingroup +\catcode`\&=7 +\gdef\krd@ifbraced@a#1{\krd@ifbraced@b.#1& &} +\gdef\krd@ifbraced@b#1 &{\krd@ifbraced@c#1&} +\gdef\krd@ifbraced@c#1{\expandafter\noexpand\@gobble#1} +\endgroup +\def\krd@ifbraced@d#1\krd@nil#2{% \krdifstrcmp{#1}{#2}\@secondoftwo\@firstoftwo } \def\krdexpandonce#1{\unexpanded\expandafter{#1}} @@ -183,20 +212,6 @@ \protected\def\krdexpandsecondonce#1#2{% \krdexpanded{\unexpanded{#1}\krdexpandonce{#2}}% } -\newcount\krd@csvdepth -\newif\ifkrd@lb -\newif\ifkrd@st -\krdnewlet\krdloopbreak\krd@lbtrue -\begingroup -\catcode`\&=7 -\gdef\krdtrimspace#1{\krd@trimspace@a.#1& &} -\gdef\krd@trimspace@a#1 &{\krd@trimspace@b#1&} -\gdef\krd@trimspace@b#1{% - \krdexpandonce{\romannumeral-`\q - \expandafter\noexpand\@gobble#1}% -} -\endgroup - % Eg, % \newcount\nr\nr=\tw@ % \def\do#1{% @@ -215,35 +230,92 @@ {}{\do{#1}\krd@for@a#2\krd@nil}% }% } -\def\krd@loopdostack{} +% We redefine xkeyval's loops to increase robustness. +% We can't replace \@nil by \krd@nil here because xkeyval +% uses \@nil in calling these macros: +\protected\long\def\XKV@for@n#1#2#3{% + \edef#2{\unexpanded{#1}}% + \krdifx#2\@empty{}{% + \XKV@f@r#2{#3}#1,\@nil,% + }% +} +\protected\long\def\XKV@f@r#1#2#3,{% + \edef#1{\unexpanded{#3}}% + \krdifx#1\@nnil{}{#2\XKV@f@r#1{#2}}% +} +\protected\long\def\XKV@for@eo#1#2#3{% + \edef#2{\unexpanded{\XKV@f@r#2{#3}}}% + \expandafter#2#1,\@nil,% +} +\protected\long\def\XKV@whilist#1#2#3\fi#4{% + #3\relax + \expandafter\@firstofone + \else + \expandafter\@gobble + \fi + {\expandafter\XKV@wh@list#1,\@nil,\@nnil#2#3\fi{#4}{}}% +} +\long\def\XKV@wh@list#1,#2\@nnil#3#4\fi#5#6{% + \edef#3{\unexpanded{#1}}% + \krdifx#3\@nnil{% + \def#3{#6}\@gobble + }{% + #4\relax + \expandafter\@firstofone + \else + \def#3{#6}% + \expandafter\@gobble + \fi + }% + {#5\XKV@wh@list#2\@nnil#3#4\fi{#5}{#1}}% +} +\protected\def\KV@@sp@def#1#2{\edef#1{\krdtrimspace{#2}}} +\protected\def\XKV@sp@deflist#1#2{% + \edef#1{\unexpanded{#2}}% + \krdcsvnormalize#1% +} +\def\krd@loopdo@stack{} \protected\def\krd@pushloopdo{% \global\advance\krd@csvdepth\@ne \def\reserved@a##1{\expandafter\@gobble\string##1@% \romannumeral\krd@csvdepth}% \def\do##1{\let\noexpand##1\krdnoexpandcsn{\reserved@a{##1}}}% - \xdef\krd@loopdostack{% - \krdfor{\krd@loopdo,\ifkrd@lb,\krd@loopact@a,\krd@loopact@b}% - {\krdexpandonce\krd@loopdostack}% + \xdef\krd@loopdo@stack{% + \krdfor{\krd@loopdo,\ifkrdloopbreak,\krd@final@loopact,% + \krd@regular@loopact}% + {\krdexpandonce\krd@loopdo@stack}% }% \def\do##1{\let\krdnoexpandcsn{\reserved@a{##1}}\noexpand##1}% \krdexpanded{% - \krdfor{\krd@loopdo,\ifkrd@lb,\krd@loopact@a,\krd@loopact@b}% + \krdfor{\krd@loopdo,\ifkrdloopbreak,\krd@final@loopact,% + \krd@regular@loopact}% }% } \protected\def\krd@poploopdo{% \begingroup - \def\reserved@a##1##{\endgroup##1\gdef\krd@loopdostack}% - \expandafter\reserved@a\krd@loopdostack + \def\reserved@a##1##{\endgroup##1\gdef\krd@loopdo@stack}% + \expandafter\reserved@a\krd@loopdo@stack \global\advance\krd@csvdepth\m@ne } \protected\def\krd@testst#1{\@ifstar{\krd@sttrue#1}{\krd@stfalse#1}} + +% \krdlistloop[<parser>]{<list>}<\if...>\fi<ini-code><final-code><reg-code> +% When the conditional <\if...> isn't true, the regular code <reg-code> +% will be executed for every member of the list. +% <final-code> will be executed when the conditional <\if...> is true. +% <ini-code> may be used to first turn <\if...> off before commencing +% the loop. \ifkrdloopbreak may be used as the conditional in <\if...>. +% Both <ini-code> and <final-code> can be empty (ie, {}). +% Use '#1' in <final-code> and <reg-code> to access the current element +% of the list. \protected\def\krdlistloop{\krd@testst{\@testopt\krd@listloop,}} \protected\def\krd@listloop[#1]#2#3\fi#4#5#6{% \krd@pushloopdo \edef\krd@csvarg{\krdifbool{krd@st}\krdexpandonce\unexpanded{#2}}% \krdcsvnormalize[#1]\krd@csvarg - \def\krd@loopact@a##1{#5}% - \def\krd@loopact@b##1{#6}% + \def\krd@final@loopact##1{#5}% + \def\krd@regular@loopact##1{#6}% + % Initial code: #4\relax \def\krd@loopdo##1#1##2\krd@nnil{% \edef\krd@csvarg{\krdexpandonce{\@gobble##1}}% @@ -251,9 +323,9 @@ #3\relax \expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi {% - \expandafter\krd@loopact@a\expandafter{\krd@csvarg}\relax + \expandafter\krd@final@loopact\expandafter{\krd@csvarg}\relax }{% - \expandafter\krd@loopact@b\expandafter{\krd@csvarg}\relax + \expandafter\krd@regular@loopact\expandafter{\krd@csvarg}\relax \krd@loopdo.##2\krd@nnil }% }% @@ -392,6 +464,8 @@ } \endgroup \krd@setupnormalize{,} + +% Redefine \XKV@define@key to heed a complaint about argument grabbing: \protected\def\XKV@define@key#1{% \@ifnextchar[{\XKV@d@fine@k@y{#1}}{% \begingroup @@ -413,6 +487,9 @@ \XKV@ch@cksanitize{#1}#2,% \krdifbool{in@}{\krdcsvnormalize[,]#2}{}% } +% Don't apply the new schemes to \setkeys, because old calls to +% \setkeys will now discover that braces are preserved. This may +% break their codes: \protected\def\krdsetkeys{\XKV@testopta{\XKV@testoptc\krd@setkeys}} \protected\def\krd@setkeys[#1]#2{% \edef\krd@na{\unexpanded{#1}}% @@ -440,16 +517,16 @@ \def\reserved@a####1=####2\@nil{% \edef\reserved@a{\expandafter\krdtrimspace\expandafter{\@gobble####1}}% \krdifx\reserved@a\@empty{% - \expandafter\XKV@s@tk@ys##1==\@nil + \expandafter\krd@s@tk@ys##1==\@nil }{% \expandafter\krdifbraced\expandafter{\reserved@a}{% \edef\CurrentOption{% - \unexpanded{##1}={{{\krdexpandonce\reserved@a}}}% + \unexpanded{##1}={{\krdexpandonce\reserved@a}}% }% }{% \edef\CurrentOption{\unexpanded{##1}=\krdexpandonce\reserved@a}% }% - \expandafter\XKV@s@tk@ys\CurrentOption==\@nil + \expandafter\krd@s@tk@ys\CurrentOption==\@nil }% }% \reserved@a.% @@ -458,10 +535,74 @@ \expandafter\krd@s@tkeys@a\CurrentOption==\@nil }% } +% \XKV@s@tk@ys is responsible for the inability of +% xkeyval's \setkeys to handle unbalanced conditionals. So +% we redefine it here, but only for \krdsetkeys: +\protected\def\krd@s@tk@ys#1=#2=#3\@nil{% + \XKV@g@tkeyname#1=\@nil\XKV@tkey + \krdexpandargonce{\KV@@sp@def\XKV@tkey}\XKV@tkey + \krdifx\XKV@tkey\@empty{% + \krdifblank{#2}{}{% + \XKV@err{No key specified for value '\the\XKV@toks'}% + }% + }{% + \@expandtwoargs\in@{,\XKV@tkey,}{,\XKV@na,}% + \krdifbool{in@}{}{% + \XKV@knftrue + \KV@@sp@def\XKV@tempa{#2}% + \krdifbool{XKV@preset}{% + \XKV@s@tk@ys@{#3}% + }{% + \krdifbool{XKV@pl}{% + \XKV@for@eo\XKV@fams\XKV@tfam{% + \XKV@makehd\XKV@tfam + \XKV@s@tk@ys@{#3}% + }% + }{% + \XKV@whilist\XKV@fams\XKV@tfam\ifXKV@knf\fi{% + \XKV@makehd\XKV@tfam + \XKV@s@tk@ys@{#3}% + }% + }% + }% + \krdifbool{XKV@knf}{% + \krdifbool{XKV@inpox}{% + \krdifx\XKV@doxs\relax{% + \ifx\@currext\@clsextension\else + \let\CurrentOption\XKV@tkey\@unknownoptionerror + \fi + }{% + \XKV@doxs + }% + }{% + \krdifbool{XKV@st}{% + \XKV@addtolist@o\XKV@rm\CurrentOption + }{% + \XKV@err{Key '\XKV@tkey' undefined in families '\XKV@fams'}% + }% + }% + }{% + \krdifbool{XKV@inpox}{% + \krdifx\XKV@testclass\XKV@documentclass{% + \expandafter\XKV@useoption\expandafter{\CurrentOption}% + }{}% + }{}% + }% + }% + }% +} \protected\def\krdsetrmkeys{\XKV@testopta{\XKV@testoptc\krd@setrmkeys}} \protected\def\krd@setrmkeys[#1]{% \krdexpandargonce{\krd@setkeys[#1]}\XKV@rm } +% We alias xkeyval's \savekeys to \savevaluekeys: +\krdnewlet\savevaluekeys\savekeys +% We split xkeyval's \presetkeys (head and tail) into +% \krdpresetkeys (head only) and \krdpostsetkeys (tail only): +\protected\def\krdpresetkeys{\@testopt\krd@presetkeys{KV}} +\protected\def\krd@presetkeys[#1]#2#3{\presetkeys[#1]{#2}{#3}{}} +\protected\def\krdpostsetkeys{\@testopt\krd@postsetkeys{KV}} +\protected\def\krd@postsetkeys[#1]#2#3{\presetkeys[#1]{#2}{}{#3}} \protected\def\krd@disabledkey@err#1{% \@latex@error{Key '#1' has been disabled} {You can't set or reset key '#1' at this\MessageBreak @@ -487,11 +628,23 @@ }% } \edef\krd@hashchar{\string#} -\protected\def\krddefinekeys{\krd@testst{\@testopt\krd@d@finekeys{KRD}}} -\protected\def\krd@d@finekeys[#1]#2{\@testopt{\krd@d@f@nekeys{#1}{#2}}{krdmp@}} +\protected\def\krddefinekeys{% + \begingroup + \endlinechar\m@ne + \krd@testst{\@testopt\krd@d@finekeys{KRD}}% +} +\protected\def\krd@d@finekeys[#1]#2{% + \@testopt{\krd@d@f@nekeys{#1}{#2}}{krdmp@}% +} \protected\def\krd@d@f@nekeys#1#2[#3]#4{% + \expandafter\endgroup + \ifkrd@st + \def\krd@keyst{00}% + \else + \def\krd@keyst{01}% + \fi + \krddeftrue \begingroup - \let\ifkrd@keyst\ifkrd@st \edef\key@prefix{\krdtrimspace{#1}}% \edef\key@family{\krdtrimspace{#2}}% \edef\macro@prefix{\krdtrimspace{#3}}% @@ -508,7 +661,7 @@ \ifin@ \@latex@error{Bad key name '\detokenize{##2}'}\@ehc \fi - \ifkrd@keyst + \if\krd@keyst \krdifcsndef{\key@prefix @\key@family @##2}{% \@latex@error{Key '##2' already exists in family '\key@family'}\@ehc @@ -563,7 +716,8 @@ \fi {\key@name}% \ifnum\key@typenr=\thr@@ - [\unexpanded{\userinput\order}]{\krdexpandonce\krd@altlista}% + [\unexpanded{\krduserinput\krdorder}]% + {\krdexpandonce\krd@altlista}% \fi \krdifx\key@default\krd@rej{}{% [\expandafter\krdifbraced\expandafter{\key@default}% @@ -576,6 +730,7 @@ \krdifx\krd@resa\krd@rej{}{\unexpanded{##4}}% \fi }% + % Second branch of callback for '+' variants: \ifnum\key@typenr>\@ne{\noexpand\krd@keyvalerr}\fi }% }% @@ -589,6 +744,7 @@ \noexpand\krdsetkeys[\key@prefix]% {\key@family}{\krdexpandonce\key@vals}% }% + \krddeffalse } \protected\def\krd@keyvalerr{% \krd@getinnoval @@ -596,26 +752,28 @@ \MessageBreak'\XKV@tkey'}{Invalid key value encountered.}% } \protected\def\krd@getaltlist#1{% - \def\krd@g@taltlist##1.code=##2\krd@nil{% + \def\krd@g@taltlist##1.do=##2\krd@nil{% \edef\krd@tempa{\krdtrimspace{##1}}% - \edef\krd@tempb{\krdexpandonce\krd@tempa{\krdtrimspace{##2}}}% + \edef\krd@tempb{\detokenize\expandafter{\krd@tempa}{\krdtrimspace{##2}}}% \krdaddtolist*\krd@altlista\krd@tempa \krdaddtolist*\krd@altlistb\krd@tempb }% \krdlistloop[,]{#1}\ifx\end\@undefined\fi{}{}{% - \@expandtwoargs\in@{\detokenize{.code=}}{\detokenize{##1}}% + \@expandtwoargs\in@{\detokenize{.do=}}{\detokenize{##1}}% \krdifbool{in@}{% \krd@g@taltlist##1\krd@nil }{% - \krd@g@taltlist##1.code=\krd@nil + \krd@g@taltlist##1.do=\krd@nil }% }% } \protected\def\krd@executealt#1#2{% - \krdexpandsecond{\def\reserved@a##1}{\krdtrimspace{#1}}##2##3\krd@nil{% + \edef\reserved@a{\krdtrimspace{#1}}% + \edef\reserved@a{\detokenize\expandafter{\reserved@a}}% + \krdexpandsecond{\def\reserved@a##1}\reserved@a##2##3\krd@nil{% \edef\reserved@a{\unexpanded{##2}}% \krdifx\reserved@a\krd@nnil{% - \@latex@error{No alternate list for key '\XKV@tkey'}\@ehc + \@latex@error{No alternate list match for key '\XKV@tkey'}\@ehc }{% ##2% }% |