diff options
author | Karl Berry <karl@freefriends.org> | 2012-11-22 23:36:05 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2012-11-22 23:36:05 +0000 |
commit | 6348770c313c5104acd5b60d68377af2621c9a2d (patch) | |
tree | 2ea0217daba84f82e5c145bcd667f47be6e9e466 /Master/texmf-dist | |
parent | fc2a68380059c28818ca479985c96b7d4af1dca4 (diff) |
ltxkeys (22nov12)
git-svn-id: svn://tug.org/texlive/trunk@28332 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
6 files changed, 861 insertions, 676 deletions
diff --git a/Master/texmf-dist/doc/latex/ltxkeys/README b/Master/texmf-dist/doc/latex/ltxkeys/README index d3609376c67..bea50783284 100644 --- a/Master/texmf-dist/doc/latex/ltxkeys/README +++ b/Master/texmf-dist/doc/latex/ltxkeys/README @@ -2,7 +2,7 @@ This is the README file for the ltxkeys package. VERSION -Version 0.0.3b, October 14, 2012 +Version 0.0.3c, 2012/11/17 LOCATION ON CTAN @@ -21,8 +21,7 @@ package is faster than the xkeyval package because, among other features, it avoids character-wise parsing of key values (which is called selective sanitization by the xkeyval package). -It also provides many new functions for defining and -managing keys, including the separate pathkeys package. +It also provides many new functions for defining and managing keys. LICENSE diff --git a/Master/texmf-dist/doc/latex/ltxkeys/ltxkeys-guide-table1.tex b/Master/texmf-dist/doc/latex/ltxkeys/ltxkeys-guide-table1.tex index 7a5a614c4cf..0e5797602ee 100644 --- a/Master/texmf-dist/doc/latex/ltxkeys/ltxkeys-guide-table1.tex +++ b/Master/texmf-dist/doc/latex/ltxkeys/ltxkeys-guide-table1.tex @@ -30,8 +30,12 @@ \colthree=\dimexpr\textwidth-(\colone+\coltwo+1.5cm)\relax \coltotal=\dimexpr\colone+\coltwo+\colthree\relax + +%\starttracingall +%\trace \begingroup\small \begin{tabularx}{\linewidth}{|m{3cm}|m{2cm}|X|} +%\begin{longtable}[c]{|>{\hspace{0pt}\raggedright}m{\colone}|m{\coltwo}|m{\colthree}|} \caption{Package options\xwmlabel{tab:pkgoptions}}\\\hline \rowcolor{pink} \bfseries Option&\bfseries Default&\bfseries Meaning\\\hline @@ -49,7 +53,10 @@ \fx{keydepthlimit} & \hx{4} & This is used to guard against erroneous infinite re-entrance of the package's key-setting commands. The default value of~4 means that neither of these commands can ordinarily be nested beyond level~4.\useltablenote[tab:pkgoptions:note3]{ltxkeys-3}\\\hline \fx{reservenopath} & \hx{false} & The \quoted{path} (or roots or bases) of a key is the combination of key prefix, key family and macro prefix, but when dealing with \quoted{path keys} (see \sref{sec:pathkeys}) the term excludes the macro prefix. These can be reserved and unreserved by any user by the tools of \sref{sec:reservedpath}. Subsequent users can, at their own risk, override all previously reserved paths by enabling the package's boolean option \fx{reservenopath}.\\\hline \fx{allowemptypath} & \hx{false} & Allow the use of empty key prefix and family. This isn't advisable but some pre-existing packages might have used empty key prefixes and families. \useltablenote[tab:pkgoptions:note4]{4} +%\end{longtable} \end{tabularx} \endgroup +%\endtrace + \end{document}
\ No newline at end of file diff --git a/Master/texmf-dist/doc/latex/ltxkeys/ltxkeys-guide.cfg b/Master/texmf-dist/doc/latex/ltxkeys/ltxkeys-guide.cfg index bde62498dc1..73fc463bfec 100644 --- a/Master/texmf-dist/doc/latex/ltxkeys/ltxkeys-guide.cfg +++ b/Master/texmf-dist/doc/latex/ltxkeys/ltxkeys-guide.cfg @@ -1,5 +1,5 @@ \ProvidesFile{ltxkeys-guide.cfg}% - [2012/10/14 v0.0.3b Configuration file for ltxkeys-guide.tex (AM)] + [2012/11/17 v0.0.3c Configuration file for ltxkeys-guide.tex (AM)] \hfuzz1pt\vfuzz2pt \makeindex diff --git a/Master/texmf-dist/doc/latex/ltxkeys/ltxkeys-guide.tex b/Master/texmf-dist/doc/latex/ltxkeys/ltxkeys-guide.tex index 6e8b021c26c..dbc9151418a 100644 --- a/Master/texmf-dist/doc/latex/ltxkeys/ltxkeys-guide.tex +++ b/Master/texmf-dist/doc/latex/ltxkeys/ltxkeys-guide.tex @@ -14,32 +14,21 @@ \makeatletter -\ltsbegincomment +\ltscomment % Include the use of the following commands in this manual: -% \ltxkeysifoneincsvlistTF -% \ltxkeysifincsvlistTF -% \ltxkeysifoneintokenlistTF -% \ltxkeysifintsvlistTF -% \ifltxkeysnovalue - -% \ltxkeysgetrmkeys -% \ltxkeysggetrmkeys - -% \ltxkeyspresetkeys -% \ltxkeysgpresetkeys -% \ltxkeyspostsetkeys -% \ltxkeysgpostsetkeys - -% \ltxkeysinitializermkeys -% \ltxkeysginitializermkeys +% \ifltxkeys@novalue +% \ltxkeys@presetkeys +% \ltxkeys@gpresetkeys +% \ltxkeys@postsetkeys +% \ltxkeys@gpostsetkeys +% \ltxkeys@preposetkeys +% \ltxkeys@gpreposetkeys \ltxkeysifinlistTF, \ltxkeysnormalizeset, \ltxkeysnormalizecsset -\ltxkeysuseandrelaxcsn -\ltxkeysifeltcountTF, \ltxkeyssetinitialkeyvalues, \ltxkeysinitializeafterdeclare \carmustykeys -\ltsendcomment +\ltscommentend \begin{document} @@ -47,7 +36,7 @@ \title{The \texttt{\color{blue}ltxkeys} Package\titleref{t1,t2}} \titlenotes[t1,t2]{% The package is available at \url{\titleurltext}.\sep - This user manual corresponds to version~0.0.3b of the package. + This user manual corresponds to version~0.0.3 of the package. } \subtitle{A robust key parser for \latex} \titleurl{http://mirror.ctan.org/macros/latex/contrib/ltxkeys/} @@ -67,7 +56,7 @@ \hrule \ltsnewfootnote{1}{% - Because of the multitude of functions provided by the \pkg'{ltxkeys}, it may actually slow down when executing some tasks, depending on the task at hand. The package option \fx{tracingkeys}, for example, does slow down processing. And automatically initiating keys after definition, as done by the command \ffx'{\ltxkeysdeclarekeys}, also affects processing speed; so does \quoted{launching keys}, which first presets absent keys with their default values before setting the current keys (\ie, keys whose values are provided by the user at the moment of setting keys that belong to a family). Then, as in the \pkg'{xkeyval}, there are the commands for presetting and post-setting keys. + Because of the multitude of functions provided by the \pkg'{ltxkeys}, it may actually slow down when executing some tasks, depending on the task at hand. The package option \fx{tracingkeys}, for example, does slow down processing. And automatically initiating keys after definition, as done by the commands \ffx'{\ltxkeysdefinekeys, \ltxkeysdeclarekeys}, also affects processing speed; so does \quoted{launching keys}, which first presets absent keys with their default values before setting the current keys (\ie, keys whose values are provided by the user at the moment of setting keys that belong to a family). Then, as in the \pkg'{xkeyval}, there are the commands for presetting and post-setting keys. } \ltsnewfootnote{2}{% Options are also keys, but (from the user's viewpoint) there might be a need to treat options separately when dealing with unknown keys. @@ -76,10 +65,7 @@ \docsection(sec:intro){Introduction} -%\lletter{T}{he \pkg'{ltxkeys}} - -\yinipar{\color{red}T}he \pkg'{ltxkeys} -provides facilities for creating and managing keys in the manner of the \pkg'{keyval, xkeyval}, but it is intended to be more robust, faster, and provide more functionality than these earlier packages. Its robustness emanates from, inter alia, its ability to preserve braces in key values throughout parsing. The need to preserve braces in key values without expecting the user to double braces emerges often in parsing keys. This is the case in, \eg, the \pkg'{xwatermark}, but consider also the possibility of passing all the following options to a package at once, where \quotedtt{layout} is a package or class option or key\footnote{It should be noted that if a value of the demonstrative option \fx{layout} is expandable, then the option can't be passed by \hx{\documentclass} without preloading a robust options parser like \pkg{kvoptions-patch, xkvltxp, ltxtools}, or \pkg{ltxkeys} package. In fact, \latex's native options processor can't handle options with values. The \pkg'{ltxkeys}, unlike the \pkg'{xkeyval}, can be loaded before \hx{\documentclass}.}: +\lletter{T}{he \pkg'{ltxkeys}} provides facilities for creating and managing keys in the manner of the \pkg'{keyval, xkeyval}, but it is intended to be more robust, faster, and provide more functionality than these earlier packages. Its robustness emanates from, inter alia, its ability to preserve braces in key values throughout parsing. The need to preserve braces in key values without expecting the user to double braces emerges often in parsing keys. This is the case in, \eg, the \pkg'{xwatermark}, but consider also the possibility of passing all the following options to a package at once, where \quotedtt{layout} is a package or class option or key\footnote{It should be noted that if a value of the demonstrative option \fx{layout} is expandable, then the option can't be passed by \hx{\documentclass} without preloading a robust options parser like \pkg{kvoptions-patch, xkvltxp, ltxtools}, or \pkg{ltxkeys} package. In fact, \latex's native options processor can't handle options with values. The \pkg'{ltxkeys}, unlike the \pkg'{xkeyval}, can be loaded before \hx{\documentclass}.}: %[Braced option values] \start'{example} @@ -137,15 +123,15 @@ The package options are listed in \sref{tab:pkgoptions}. The package options can \usepackage[tracingkeys,keyparser={|nv}]{ltxkeys} \finish{example} -They can also be passed locally via the command \fx{\ltxkeysoptions}: +They can also be passed locally via the command \fx{\setltxkeysoptions}: -\start{newmacro}[\ltxkeysoptions] -\ltxkeysoptions{tracingkeys=false,keyparser={;}} +\start{newmacro}[\setltxkeysoptions] +\setltxkeysoptions{tracingkeys=false,keyparser={;}} \finish{newmacro} -\fxim*{\ltxkeysoptions} +\fxim*{\setltxkeysoptions} \newltablenote{ltxkeys-1}{% - The speed of compilation may be affected by this option, but it is recommended at the pre-production stages of developing keys. The option provide some trace functionality and enables the user to, among other things, follow the progress of the \latex run and to see if a key has been defined and/or set/executed more than once in the current run. The \stform+ of the command \ffx'{\ltxkeysdeclarekeys} will always flag an error if a key is being defined twice, irrespective of the state of the package option \fx{tracingkeys}. The \textkey variants (unlike the \textnewkey variants) of key-defining commands don't have this facility, and it may be desirable to know if and when an existing key is being redefined. + The speed of compilation may be affected by this option, but it is recommended at the pre-production stages of developing keys. The option provide some trace functionality and enables the user to, among other things, follow the progress of the \latex run and to see if a key has been defined and/or set/executed more than once in the current run. The \stform+ of the commands \ffx'{\ltxkeysdefinekeys, \ltxkeysdeclarekeys} will always flag an error if a key is being defined twice, irrespective of the state of the package option \fx{tracingkeys}. The \textltxkey variants (unlike the \textnewkey variants) of key-defining commands don't have this facility, and it may be desirable to know if and when an existing key is being redefined. } \newltablenote{ltxkeys-2}{% Wherever the \qsemicolon is indicated as a list parser in this guide, it can be replaced by any user-specified one character parser via the package option \fx{keyparser}. To avoid confusing the user-supplied parser with internal parsers, it is advisable to enclose the chosen character in curly braces when submitting it as a package option. The braces will be stripped off internally. Please note that some of the characters that may be passed as a list parser may indeed be active; be careful to make them innocent before using them as a list/key parser. My advice is that the user sticks with the \qsemicolon as the key parser: the chances of it being made active by any package is minimal. If you have the chosen parser as literals in the callbacks of your keys, they have to be enclosed in curly braces. @@ -161,7 +147,7 @@ They can also be passed locally via the command \fx{\ltxkeysoptions}: \small %\trace* \begin{tabularx}{\linewidth}{|p{3cm}|p{2cm}|X|} -\caption{Package options. All the package options can also be changed globally via \headhx{\documentclass} and locally through the control sequence \headfx{\ltxkeysoptions}.} \xwmlabel{tab:pkgoptions} +\caption{Package options. All the package options can also be changed globally via \headhx{\documentclass} and locally through the control sequence \headfx{\setltxkeysoptions}.} \xwmlabel{tab:pkgoptions} \\\hline \rowcolor{pink} \bfseries Option&\bfseries Default&\bfseries Meaning\\\hline @@ -175,7 +161,7 @@ They can also be passed locally via the command \fx{\ltxkeysoptions}: \hline \endlastfoot \fx{tracingkeys} & \hx{false} & The global boolean switch that determines if information should be logged in the transcript file for some tasks in the package. \useltablenote[tab:pkgoptions:note1]{ltxkeys-1}\\\hline -\fx{keyparser} & \texttt{;} & The most user-relevant of the list parsers (\ie, item separators) used by internal loops in defining keys---mainly in the macro \ffx'{\ltxkeysdeclarekeys}. \useltablenote[tab:pkgoptions:note2]{ltxkeys-2}\\\hline +\fx{keyparser} & \texttt{;} & The most user-relevant of the list parsers (\ie, item separators) used by internal loops in defining keys---mainly in the macros \ffx'{\ltxkeysdefinekeys, \ltxkeysdeclarekeys}. \useltablenote[tab:pkgoptions:note2]{ltxkeys-2}\\\hline \fx{keydepthlimit} & \hx{4} & This is used to guard against erroneous infinite re-entrance of the package's key-setting commands. The default value of~4 means that neither of these commands can ordinarily be nested beyond level~4.\useltablenote[tab:pkgoptions:note3]{ltxkeys-3}\\\hline \fx{reservenopath} & \hx{false} & The \quoted{path} (or roots or bases) of a key is the combination of key prefix, key family and macro prefix. These can be reserved and unreserved by any user by the tools of \sref{sec:reservedpath}. Subsequent users can, at their own risk, override all previously reserved paths by enabling the package's boolean option \fx{reservenopath}.\\\hline \fx{allowemptypath} & \hx{false} & Allow the use of empty key prefix and family. This isn't advisable but some pre-existing packages might have used empty key prefixes and families. \useltablenote[tab:pkgoptions:note4]{ltxkeys-4}\\\hline @@ -189,7 +175,7 @@ They can also be passed locally via the command \fx{\ltxkeysoptions}: \docsubsection(sec:definablekeys){Defining only definable keys} -If the package option \fx{tracingkeys} is enabled (\ie, turned true), the user can see in the transcript file the existing keys that he has redefined with the \textkey variants of the key-defining commands, which redefine existing keys without any default warning or error. The log file messages being referred to here will be highlighted with the warning sign (\makered{!!}). This is always desirable in the preproduction stages of your project. However, instead of looking for these warning messages in the log file, the user can use the \textnewkey variants of the key-defining commands to bar himself from redefining existing keys. +If the package option \fx{tracingkeys} is enabled (\ie, turned true), the user can see in the transcript file the existing keys that he has redefined with the \textltxkey variants of the key-defining commands, which redefine existing keys without any default warning or error. The log file messages being referred to here will be highlighted with the warning sign (\makered{!!}). This is always desirable in the preproduction stages of your project. However, instead of looking for these warning messages in the log file, the user can use the \textnewkey variants of the key-defining commands to bar himself from redefining existing keys. Subsequently we will mention the \textnewkey variants of key-defining commands without necessarily explaining what they mean, since their meaning is henceforth clear. @@ -205,7 +191,7 @@ In the following, syntactic quantities in square brackets (\eg, \fx{[yyy]}) and \finish{newmacro} \fxim*{\ltxkeysordkey,\ltxkeysnewordkey} -These define a macro of the form \preffamkey of one parameter that holds the key function/callback \ang{cbk}. The default value for the \quoted{key prefix} \ang{pref} is always \fx{KV}, as in the \pkg'{xkeyval}. When \ang{key} is used in a \fx{\ltxkeysetkeys} command (see \sref{sec:settingkeys}) containing \keyval, the macro \preffamkey takes the value as its argument and is then executed. The given argument or key value can be accessed in the key's callback \ang{cbk} by using \fx{#1} inside the function. The optional default value \ang{dft}, if available, will be used by \preffamkey when the user hasn't provided a value for the key at \fx{\ltxkeyssetkeys}. If \ang{dft} was absent at key definition and the key user hasn't provided a value for the key, an error message is flagged\footnote{The commands \ffx'{\ltxkeyskey, \ltxkeysnewkey} aren't user commands.}. +These define a macro of the form \preffamkey of one parameter that holds the key function/callback \ang{cbk}. The default value for the \quoted{key prefix} \ang{pref} is always \fx{KV}, as in the \pkg'{xkeyval}. When \ang{key} is used in a \fx{\ltxkeyssetkeys} command (see \sref{sec:settingkeys}) containing \keyval, the macro \preffamkey takes the value as its argument and is then executed. The given argument or key value can be accessed in the key's callback \ang{cbk} by using \fx{#1} inside the function. The optional default value \ang{dft}, if available, will be used by \preffamkey when the user hasn't provided a value for the key at \fx{\ltxkeyssetkeys}. If \ang{dft} was absent at key definition and the key user hasn't provided a value for the key, an error message is flagged\footnote{The commands \ffx'{\ltxkeys@key, \ltxkeys@newkey} aren't user commands.}. Run the following example and do \fx{\show\cmdb} and \fx{\show\cmdd}: @@ -227,7 +213,7 @@ The commands \ffx'{\ltxkeysordkey,\ltxkeysnewordkey} can be used to introduce or \fxim*{\ltxkeysordkeys,\ltxkeysnewordkeys} -\docsubsection(sec:lispkeys)<lispkeys>{List keys (lispkeys)} +\docsubsection(sec:lispkeys)<lispkeys>{List processor keys (lispkeys)} \start+{newmacro}[\ltxkeyslispkey,\ltxkeysnewlispkey, etc.] \ltxkeyslispkey[|A(pref)]{|A(fam)}{|A(key)}[|A(dft)]{|A(cbk)} @@ -239,30 +225,71 @@ The commands \ffx'{\ltxkeysordkey,\ltxkeysnewordkey} can be used to introduce or List processor keys (or lisp keys) are ordinary keys that accept a parser-separated list as a user input and process each element of the list. The key's callback \ang{cbk} is then a list processor, but the key author doesn't have to design and suggest his own looping system. All he has to do is to pass the parameter \fx{#1}, representing the individual items of the list, to the key's callback. The key will internally do the loop and process the list (\ie, the user input). -Each item will be processed by the key's callback. A lisp key does accept any arbitrary list separator. When the list separator differs from \qcomma, it has to be provided in the key's callback as the argument of the undefined command \fx{\listsep}. And at key-setting time, user inputs that are comma-separated should be enclosed in curly braces, otherwise they won't be parsed properly and errors will arise. An example follows. When setting the key, the user must then use the same list separator. \fx{\ltxkeyslispnr} gives the numerical order of each item in the list. The default value and user input of a lisp key should take cognizance of the list separator. Both the default value and the user input of a lisp key can be just one item, rather than a list; in which case the current input is assumed to have just one item. Spurious leading and trailing spaces (\ie, unprotected spaces) in the list are trimmed before the list is parsed by the key's callback. Reminder: \fx{#1} in the key's callback refers to the individual item of the list, and not the entire list itself. +\Note In the lisp key's callback, the parameter character \fx{#1} represents not the entire user input (which is assumed to be a list) but the individual items of the list. Each item of the list will be processed by the key's callback. + +A lisp key does accept any arbitrary list separator. When the list separator differs from \qcomma, it has to be provided in the key's callback as the argument of the undefined command \fx{\listsep}. And at key-setting time, user inputs that are comma-separated should be enclosed in curly braces, otherwise they won't be parsed properly and errors will arise. An example follows. When setting the key, the user must then use the same list separator. \fx{\ltxkeyslispcount} gives the numerical order of each item in the list. The default value and user input of a lisp key should take cognizance of the list separator. Both the default value and the user input of a lisp key can be just one item, rather than a list; in which case the current input is assumed to have just one item. Spurious leading and trailing spaces (\ie, unprotected spaces) in the list are trimmed before the list is parsed by the key's callback. Reminder: \fx{#1} in the key's callback refers to the individual item of the list, and not the entire list itself. It is possible to call the command \fx{\ltxkeysbreakloop} in the key's callback \ang{cbk} to break out of the list processing prematurely. The unprocessed items will be handled by the command \fx{\ltxkeysdoremainder}, which can be redefined by the user. By default, it has the same meaning as the \latex kernel's \hx{\@gobble}, meaning that it simply throws away the list remainder. \start+{example}[\ltxkeyslispkey] \ltxkeyslispkey[KV]{fam}{keya}[aaa, bbb]{% |com(`#1' here refers to the current item of the list:) - \csndef{ww@\romannumeral\ltxkeyslispnr}{#1}% + \ltscsdef{ww@\romannumeral\ltxkeyslispcount}{#1}% } |com(User inputs that are comma-separated should be wrapped in braces:) \ltxkeyssetkeys[KV]{fam}{keya={val1, val2, val3}} \ltxkeyslispkey[KV]{fam}{keyb}[aaa; bbb]{% |R(\listsep){;}% - \ifnum\ltxkeyslispnr>2\relax + \ifnum\ltxkeyslispcount>2\relax \ltxkeysbreakloop \else - \csn@def{ww@\romannumeral\ltxkeyslispnr}{#1}% + \ltscsdef{ww@\romannumeral\ltxkeyslispcount}{#1}% \fi } \ltxkeyssetkeys[KV]{fam}{keyb=val1; val2; val3; val4} \ltxkeyssetkeys[KV]{fam}{keyb=val5} \finish{example} +\start+{example}[\ltxkeyslispkey] +\ltxkeyslispkey[KV]{fam}{keya,keyb}[default1,default2]{% + \begingroup + \color{blue} + \ifltxkeysnoval + \ifnum\ltxkeyslispcount=\@ne + \endgraf + Using default value of `\ltxkeystkey': + \fi + \else + \ifnum\ltxkeyslispcount=\@ne + \endgraf + Using user value of `\ltxkeystkey': + \fi + \fi + \endgroup + \endgraf + Doing item no. \ltxkeyslispcount: #1% +} +%\show\KV@fam@keya +%\endtrace +\let\ltxsetkeys\ltxkeyssetkeys +\makeatother + +\begin{document} +\parindent0pt +%\trace* +\ltxsetkeys[KV]{fam}{keya,keyb} +%\endtrace + +\par\bigskip +\ltxsetkeys[KV]{fam}{% + keya={item1A,item1B,item1C,item1D}, + keyb={item2A,item2B,item2C,item2D} +} +%\endtrace +\end{document} +\finish{example} + \docsubsection(sec:cmdkeys)<command keys (cmd)>{Command keys} @@ -290,7 +317,7 @@ The commands \ffx'{\ltxkeyscmdkey,\ltxkeysnewcmdkey} can be used to introduce co \docsubsection(sec:stylekeys){Style keys} \aidx*{style keys (sty)} -Style keys are keys with dependants (\ie, keys that are processed when the master is set). They have the following syntaxes: +Style keys are keys with observers (\ie, keys that are processed when the subject/master key is set). They have the following syntaxes: \start+{newmacro}[\ltxkeysstylekey,\ltxkeysnewstylekey] \ltxkeysstylekey[|A(pref)]{|A(fam)}[|A(mp)]{|A(key)}[|A(dft)]|(|A(deps)|){|A(cbk)} @@ -300,47 +327,39 @@ Style keys are keys with dependants (\ie, keys that are processed when the maste \finish{newmacro} \fxim*{\ltxkeysstylekey,\ltxkeysnewstylekey} -The dependants \ang{deps} have the syntax: +The observers \ang{deps} have the syntax: -\start'{macro}[Dependant keys syntax] +\start'{macro}[Observer keys syntax] |( - |A(keytype)/|A(keyname)/|A(dft)/|A(cbk); - another set of dependant; etc. + |A(key1)=|A(value1),...,|A(key1)=|A(value1) |) \finish{macro} -\aidxs*{dependant keys}{style keys} +\aidxs*{observer keys}{style keys} The default value \ang{dft} and the callback \ang{cbk} can be absent in the syntax of style keys. \ang{keytype} can be \quoted{ord} (ordinary key), \quoted{cmd} (command key), \quoted{bool} (boolean key), or \quoted{choice} (choice key). -Dependant keys always share the same key prefix \ang{pref}, family \ang{fam}, and macro prefix \ang{mp} with the parent key. +Observer keys always share the same key prefix \ang{pref}, family \ang{fam}, and macro prefix \ang{mp} with the parent key. If \ang{mp} is given, the command \mpkey will hold the current user input for the parent key; otherwise the user input will be available in \ipreffamkey{style}. The macro \preffamkey will always hold the callback \ang{cbk}. -If the \stform is used, all undefined dependants will be defined and set on the fly as the parent is being set. If the \stform isn't used and undefined dependants occur, then an error message will be flagged at the time the parent is being set. +If the \stform is used, all undefined observers will be defined and set on the fly as the parent is being set. If the \stform isn't used and undefined observers occur, then an error message will be flagged at the time the parent is being set. -Most of the time it is possible to access the parent key's current value with \fx{\parentval}. Within \ang{dft} and \ang{cbk} of \ang{deps}, it is possible to refer to the parent key's callback with its full macro name (\ie, \preffamkey). \fx{\parentval} is always available for use as the default value of dependant keys, but it may be lost in the callbacks of dependant keys, because a dependant key, once defined, may be set independent of, and long after, the parent key has been executed. It is, therefore, more reliable to refer to the macro \jpreffamkey{value}, which is recorded for only the parent key of style keys and which holds the current user input for the parent key. The macro \jpreffamkey{value} is recorded only if it appears at least once in the attributes or callbacks of dependant keys. The macro \jpreffamkey{value} has a more unique name than \mpkey but they always contain the same value of a style key. As mentioned above, if \ang{mp} is not given, the user input for a style key will be available in the macro \ipreffamkey{style}, instead of \mpkey. +Most of the time it is possible to access the parent key's current value with \fx{\parentval}. Within \ang{dft} and \ang{cbk} of \ang{deps}, it is possible to refer to the parent key's callback with its full macro name (\ie, \preffamkey). \fx{\parentval} is always available for use as the default value of observer keys, but it may be lost in the callbacks of observer keys, because a observer key, once defined, may be set independent of, and long after, the parent key has been executed. It is, therefore, more reliable to refer to the macro \jpreffamkey{value}, which is recorded for only the parent key of style keys and which holds the current user input for the parent key. The macro \jpreffamkey{value} is recorded only if it appears at least once in the attributes or callbacks of observer keys. The macro \jpreffamkey{value} has a more unique name than \mpkey but they always contain the same value of a style key. As mentioned above, if \ang{mp} is not given, the user input for a style key will be available in the macro \ipreffamkey{style}, instead of \mpkey. \ltsnote -The parameter \quotedfx{#1} in the callback of parent key refers to the current value of the parent key, while \quotedfx{#1} in the callback of any dependant key refers to the current value of that dependant key. Here is an example that defines and sets all undefined dependants on the fly: +The parameter \quotedfx{#1} in the callback of parent key refers to the current value of the parent key, while \quotedfx{#1} in the callback of any observer key refers to the current value of that observer key. Here is an example that defines and sets all undefined observers on the fly: \start+{example}[\ltxkeysstylekey] \ltxkeysstylekey|*[KV]{fam}[mp@]{keya}[{left}]|(% - |com(`#1' here refers to the value of the DEPENDANT key) - |com(at the time it is being set. Use \parentkey and \parentval) - |com(here to access the parent key name and its current value:) - ord/keyb/{right}/\def\y##1{#1##1}; - |com( The default of `keyc' is the current value of parent `keya':) - cmd/keyc/\parentval; - |com(Because \KV@fam@keya@value appears below, it will be saved) - |com(when the parent key `keya' is being set, otherwise it would be) - |com(unavailable:) - bool/keyd/true/\ifmp@keyd\edef\x##1{##1\KV@fam@keya@value}\fi + |com(`#1' here refers to the value of the PARENT key at the time) + |com(it is being set:) + keyb=valueb,keyc=#1,keyd=2*#1 |){% |com(`#1' here refers to the value of the PARENT key at the time) |com(it is being set:) \def\x##1{##1xx#1xx}% |com(Check the value of parent key:) - \ltxkeyscheckchoice[,]|(\userinput\order|){#1}{left,right,center}{}{% + \ltxkeyscheckchoice+[,]|(\userinput\order|){#1}{left,right,center}{}{% \@latex@error{Invalid input `#1'}\@ehd }% } @@ -558,7 +577,7 @@ If the parser is \qsemicolon, then we would have This means that if you have \quotedfx{/.do} or \quotedfx{/} in any of the callbacks, it has to be enclosed in curly braces! Please recall that the default value of \ang{keyparser} is \qsemicolon. \fx{keyparser} is a package option. This syntax also implies that if you have the \ang{keyparser} in \ang{defn}, it has to be wrapped in curly braces. \ltsnote -The \ang{keyparser} in these syntaxes of \quoted{nominations} for choice keys could also be \qcomma, without the need to declare the package option \fx{keyparser} as \qcomma. Here is the rule for parsing the \ang{alt} list. First the package checks if the declared key parser (\ie, \ang{keyparser}) is in the \ang{alt} list. If the parser exists in \ang{alt}, then the list is parsed using this parser. Otherwise the list is parsed using \qcomma as the parser. Moreover, the package checks if \quotedfx{/.do} separates \ang{choice} from the callback \ang{cbk}. If no \quotedfx{/.do} is found, then \quotedfx{/} is assumed to be the separator. But note that when there is no \ang{cbk} for a nomination, then neither \quotedfx{/.do} nor \quotedfx{/} is necessary. +The \ang{keyparser} in these syntaxes of \quoted{nominations} for choice keys could also be \qcomma, without the need to declare the package option \fx{keyparser} as \qcomma. Here is the rule for parsing the \ang{alt} list. First the package checks if the declared key parser (\ie, \ang{keyparser}) is in the \ang{alt} list. If the parser exists in \ang{alt}, then the list is parsed using this parser. Otherwise the list is parsed using \qcomma as the parser. Moreover, the package checks if \quotedfx{.do} separates \ang{choice} from the callback \ang{cbk}. If no \quotedfx{.do} is found, then \quotedfx{/} is assumed to be the separator. But note that when there is no \ang{cbk} for a nomination, then neither \quotedfx{.do} nor \quotedfx{/} is necessary. It is possible to refer to the current value of \ang{key} as \fx{#1} in \ang{alt}. @@ -617,7 +636,7 @@ The \stform of \fx{\ltxkeyschoicekey} will convert the user input to lowercase b \ltxkeyssetkeys[KV]{fam}{keyb=center,keyd} \finish{example} -The representations \ffx'{\savevalue,\usevalue,\needvalue} are pointers (see \sref{sec:keypointers}). +The representations \ffx{\savevalue,\usevalue,\needvalue}, \etc are pointers (see \sref{sec:keypointers}). \docsubsubsection(sec:choicekeys-sameattributes) @@ -643,10 +662,9 @@ The commands \ffx'{\ltxkeyschoicekey,\ltxkeysnewchoicekey} can be used to introd \docsection{Default values of keys} +The code after \fx{.do=} will be executed whenever the default value of the key is used. -The code after \fx{/.do=} will be executed whenever the default value of the key is used. - -% \ltxkeysordkey[KV]{fam}{keya}[\def\y#1{#1}/.do=\def\x#1{#1}]{% +% \ltxkeysordkey[KV]{fam}{keya}[\def\y#1{#1}.do=\def\x#1{#1}]{% % \def\cmda##1{##1*#1*##1} % } @@ -673,68 +691,6 @@ The following example defines key-default handler for two key prefixes and two f \docsubsection(sec:declarekeys){Defining all types of key with one command} \aidx*{defining multiple keys} -%% Read this section again. - -\begin{noteenv}* -\label{nte:definekeys-1} -Keys defined by \fx{\ltxkeysdeclarekeys} are automatically set/initialized instantly, to provide default values for immediate use. Boolean keys are preset with value \quoted{false}, so that they aren't turned \quoted{true} prematurely. There is a potential problem with this manner of presetting keys. Consider the following example, in which \ttx{keya} builds a list: - -\start{example}[\ltxkeysdeclarekeys] -\def\alist{} -\ltxkeysdeclarekeys[pref]{fam}[mp]{% - cmd/keya/defaulta/\edef\alist{\ifx\alist\@empty\else\alist,\fi#1}; - cmd/keyb/defaultb/\def\callback##1{##1*#1}% -} -\finish{example} - -If, as is done by the command \fx{\ltxkeysdeclarekeys}, \ttx{keya} is automatically preset at definition, the building of the list \fx{\alist} would then have started soon after the definition of the key, which is most likely not what the user of the key requires. The \pkg'{ltxkeys} therefore provides an internal boolean \fx{\ifltxkeysdec} that is set true within the commands \ffx'{\ltxkeysdeclarekeys, \ltxkeysdeclarekeys} and toggled false outside these commands. The boolean has other uses within these commands. It can be used as follows: - -\start{example}[\ltxkeysdeclarekeys] -\def\alist{} -\ltxkeysdeclarekeys[pref]{fam}[mp]{% - keya/defaulta/ - \ifltxkeysdec\else - |com(Don't execute this when defining the key:) - \edef\alist{\ifx\alist\@empty\else\alist,\fi#1}% - \fi; - keyb/defaultb/\def\callback##1{##1*#1}% -} -\finish{example} - -So here the building of the list by \ttx{keya} wouldn't start until the key has been defined (\ie, outside \fx{\ltxkeysdeclarekeys}). -\end{noteenv} - -\ltsnote -In \ffx'{\ltxkeysdeclarekeys}, if \fx{endcallbackline} is true, every line is assumed to end with a comment sign. This is to be specially noted if a space is desired at the end of line. You can insert such a space with a comment sign, or, if appropriate, use \hx{\space}. - -\start+{example}[\ltxkeysdeclarekeys] -|com(The |stform defines new keys:) -\ltxkeysdeclarekeys|*[KV]{fam}[mp@]{% - |com(Command key with callback:) - cmd/keya/{keepbraced}/\def\x##1{##1*#1*##1}; - |com(Boolean key:) - bool/keyb/true/\def\y##1{##1yyy#1}; - |com(Command key with no callback:) - cmd/keyc/xxx; - |com(Choice-like command key:) - cmd/keyd/center/\ltxkeyscheckuserinput{#1}{left,right,center} - \ifltxkeysinputvalid |label(mac:ifltxkeysinputvalid) - \edef\myval{\expandcsonce\userinput} - \edef\numberinlist{\number\order} - \edef\mychoices{\expandcsonce\nominations} - \else - \@latex@error{Input `#1' not valid}\@ehd - \fi; - |com(Boolean key with no callback:) - bool/keye/false; -} -\finish{example} -\fxim*{\ifltxkeysinputvalid,\ltxkeyscheckuserinput,\nominations,\userinput} -\aiidxm*[\bs,choice keys]{nominations,ifltxkeysinputvalid} - -In this example, \fx{\userinput} corresponds to \fx{#1}; \fx{\order} is the numerical order of the user input in \fx{\nominations}; the list of valid values suggested at key definition time (\fnz*{left,right,center} in this example). The boolean \fx{ltxkeysinputvalid} is associated with the command \fx{\ltxkeyscheckuserinput} and is available to the user. It is set \hx{true} when the user input is valid, and \hx{false} otherwise. The command \fx{\ltxkeyscheckuserinput} expects two arguments: the user input and the list of nominations. It doesn't expect two branches (see \sref{sec:checkchoice}). - - \start{newmacro}[\ltxkeysdeclarekeys] \ltxkeysdeclarekeys[|A(pref)]{|A(fam)}[|A(mp)]{%|label(mac:declarekeys) |A(keytype)/|A(keyname)/|A(dft)/|A(cbk); @@ -750,7 +706,7 @@ In this example, \fx{\userinput} corresponds to \fx{#1}; \fx{\order} is the nume \fxim*{\ltxkeysdeclarekeys} \aidx*{style keys (sty*)} -Here, the default value \ang{dft} and the callback \ang{cbk} can be absent in all cases. \ang{keytype} must be any one of \fnz{ord,cmd,sty,sty*,bool,choice,switch}. The star (\redstar) in \quoted{sty\Redstar} has the same meaning as in \fx{\ltxkeysstylekey} above, namely, undefined dependants will be defined on the fly when the parent key is set. The optional quantity \ang{mp} is the macro prefix, as in, \eg, \sref{sec:cmdkeys,sec:definekeys}. +Here, the default value \ang{dft} and the callback \ang{cbk} can be absent in all cases. \ang{keytype} must be any one of \fnz{ord,cmd,sty,sty*,bool,choice,switch}. The star (\redstar) in \quoted{sty\Redstar} has the same meaning as in \fx{\ltxkeysstylekey} above, namely, undefined observers will be defined on the fly when the parent key is set. The optional quantity \ang{mp} is the macro prefix, as in, \eg, \sref{sec:cmdkeys,sec:definekeys}. Choice keys must have their names associated with their admissible \ang{alt} values in the format \keydotchoice{keyname}{alt} (see example below). @@ -763,18 +719,19 @@ Keys defined by \fx{\ltxkeysdeclarekeys} are automatically set instantly with th \ltxkeysdeclarekeys|*[KV]{fam}[mp@]{% |com(Ordinary key with callback:) ord/keya/.1\paperwidth/\leftmargin=#1\relax; - |com(Command key with callback:) - cmd/keyb/10mm/\rightmargin=#1\def\x##1{##1*#1*##1}; + |com(Command key with callback. `.do=' is allowed before callback:) + cmd/keyb/10mm/.do=\rightmargin=#1\def\x##1{##1*#1*##1}; |com(Boolean key without callback:) bool/keyc/true; |com(Boolean key with callback:) bool/keyd/true/\ifmp@keyd\@tempswatrue\else\@tempswafalse\fi; - |com(Style key with callback but no dependants:) - sty/keye/aaa/\def\y##1{##1yyy#1}; - |com(Style key with callback and dependants `keyg' and `keyh':) - sty|*/keyf/blue/\def\y##1{##1#1}/ - cmd|R(>)keyg|R(>)\parentval|R(>)\def\z####1{####1+##1+####1}|R(,) - ord|R(>)keyh|R(>)\KV@fam@keyf@value; + |com(Style key with callback but no observers:) + style/keye/aaa/\def\y##1{##1yyy#1}; + |com(Style key with callback and observers `keyg' and `keyh':) + style/keyf|R(.){ + keyg=valueg,keyh=valueh + } + /blue/\def\y##1{##1#1}; |com(Choice key with simple nominations and callback. The function) |com(\order is generated internally:) choice/keyi|R(.){left,right,center}/center/ @@ -783,19 +740,23 @@ Keys defined by \fx{\ltxkeysdeclarekeys} are automatically set instantly with th choice/keyj|R(.){ center/.do=\def\mp@textalign{center}, left/.do=\def\mp@textalign{flushleft}, - |com(`.do=' can be omitted:) - right/\def\mp@textalign{flushright}, - justified/\let\mp@textalign\relax + right/.do=\def\mp@textalign{flushright}, + justified/.do=\let\mp@textalign\relax } /center/\def\yy##1{##1yy#1}; ord/keyk/\letcstocsn\func{as-defined-by-user}; switch/keyl/true/\if\mp@keyl\def\y##1{##1+#1+##1}\fi; + |com(#1 here means the value of the subject key:) + style/key1|R(.){ + key1a=value1a,key1b=#1 + } + /dft1/\def\y##1{##1*#1}; } \finish{example} -\aidx*{style keys (sty*)} +\aidx*{style keys} \aidx*{/.do} -Notice the notation \fx{>...>} used for the attributes of the dependant keys \ttx{keyg,keyh} of style key \quoted{keyf}. Dependent keys are the last attributes of a style key, and they (dependant keys) are separated by \qcomma. The default value of the dependant key \quoted{keyg} will in this example be whatever is submitted for \quoted{keyf}. As indicated in \sref{sec:stylekeys}, the function \fx{\KV@fam@keyf@value} has a longer lifespan than \fx{\parentval}. Notice also the syntax \keydotchoice{keyi}{left,right,center} for the choice keys \ttx{keyi,keyj}. It says that the alternate admissible values for \quoted{keyi} are \quotedlist'{left,right,center,justified}; similarly for key \quoted{keyj}. +Notice the syntax \keydotchoice{keyi}{left,right,center} for the choice keys \ttx{keyi,keyj}. It says that the alternate admissible values for \quoted{keyi} are \quotedlist'{left,right, center, justified}; similarly for key \quoted{keyj}. For style keys, \keydotchoice{keyf}{keyg=valueg, keyh=valueh} means that \ttx{keyg,keyh} are observer keys of the subject \ttx{keyf}. \docsubsubsection(sec:sametypekeys)[Defining keys of common type] @@ -823,12 +784,109 @@ If you have to define keys of the same type with the command \fx{\ltxkeysdeclare } \ltxkeysdeclarekeys|*|(sty|*|)[KV]{fam}[mp@]{% keyd/xxx/\def\y##1{##1yyy#1}; - |com(keyf is a dependant of keye:) + |com(keyf is a observer of keye:) keye/blue/\def\y##1{##1#1}/cmd>keyf>\parentval>\def\z####1{####1+##1+####1} } \finish{example} +\docsubsection(sec:definekeys){Defining keys with one command} +\aidx*{defining multiple keys} + +In my personal experience, boolean and command keys have been the most widely used types of key in the context of \pkg'{xkeyval}. More than one boolean and command keys can be defined simultaneously by the following command: + +\start{newmacro}[\ltxkeysdefinekeys] +\ltxkeysdefinekeys[|A(pref)]{|A(fam)}[|A(mp)]{% + |A(key)|R(=)|A(dft)/|A(cbk); + another set of key attributes; etc. +} +\ltxkeysdefinekeys|*[|A(pref)]{|A(fam)}[|A(mp)]{% + |A(key)|R(=)|A(dft)/|A(cbk); + another set of key attributes; etc. +} +\finish{newmacro} +\fxim*{\ltxkeysdefinekeys} + +The default value \ang{dft} can be absent in the case of command keys, and the callback \ang{cbk} can be absent for the two types of key. Boolean keys must, however, have default values \fnz*{true,false}, to be distinguishable from command keys. The \eqsign that separates the key name from the default value can be replaced with forward slash (/). That is, the following syntax is also permitted: + +\start{newmacro}[\ltxkeysdefinekeys] +\ltxkeysdefinekeys[|A(pref)]{|A(fam)}[|A(mp)]{% + |A(key)|R(/)|A(dft)/|A(cbk); + another set of key attributes; etc. +} +\ltxkeysdefinekeys|*[|A(pref)]{|A(fam)}[|A(mp)]{% + |A(key)|R(/)|A(dft)/|A(cbk); + another set of key attributes; etc. +} +\finish{newmacro} +\fxim*{\ltxkeysdefinekeys} + +You can use the command \fx{\ltxkeyscheckuserinput} in \ang{cbk} to indirectly introduce choice keys as command keys (see example below). + +Ordinary keys and conventional choice keys can't be introduced directly by this command (use the command \fx{\ltxkeysdeclarekeys} instead). + +The \stform of \fx{\ltxkeysdefinekeys} can be used to define non-existing boolean and command keys in the sense of \hx{\newcommand}. + +\begin{noteenv}* +\label{nte:definekeys-1} +Keys defined by \fx{\ltxkeysdefinekeys} are automatically set/initialized instantly, to provide default values for immediate use. Boolean keys are preset with value \quoted{false}, so that they aren't turned \quoted{true} prematurely. There is a potential problem with this manner of presetting keys. Consider the following example, in which \ttx{keya} builds a list: + +\start{example}[\ltxkeysdefinekeys] +\def\alist{} +\ltxkeysdefinekeys[pref]{fam}[mp]{% + keya/defaulta/\edef\alist{\ifx\alist\@empty\else\alist,\fi#1}; + keyb/defaultb/\def\callback##1{##1*#1}% +} +\finish{example} + +If, as is done by the command \fx{\ltxkeysdefinekeys}, \ttx{keya} is automatically preset at definition, the building of the list \fx{\alist} would then have started, which is most likely not what the user of the key requires. The \pkg'{ltxkeys} therefore provides an internal boolean \fx{\ifltxkeysdec} that is set true within the commands \ffx'{\ltxkeysdefinekeys, \ltxkeysdeclarekeys} and toggled false outside these commands. The boolean has other uses within these commands. It can be used as follows: + +\start{example}[\ltxkeysdefinekeys] +\def\alist{} +\ltxkeysdefinekeys[pref]{fam}[mp]{% + keya/defaulta/ + \ifltxkeysdec\else + |com(Don't execute this when defining the key:) + \edef\alist{\ifx\alist\@empty\else\alist,\fi#1}% + \fi; + keyb/defaultb/\def\callback##1{##1*#1}% +} +\finish{example} + +So here the building of the list by \ttx{keya} wouldn't start until the key has been defined (\ie, outside \fx{\ltxkeysdefinekeys}). +\end{noteenv} + +\ltsnote +In \ffx'{\ltxkeysdefinekeys, \ltxkeysdeclarekeys}, if \fx{endcallbackline} is true, every line is assumed to end with a comment sign. This is to be specially noted if a space is desired at the end of line. You can insert such a space with a comment sign, or, if appropriate, use \hx{\space}. + +\start+{example}[\ltxkeysdefinekeys] +|com(The |stform defines new keys:) +\ltxkeysdefinekeys|*[KV]{fam}[mp@]{% + |com(Command key with callback:) + keya={keepbraced}/\def\x##1{##1*#1*##1}; + |com(Boolean key:) + keyb=true/\def\y##1{##1yyy#1}; + |com(Command key with no callback:) + keyc=xxx; + |com(Choice-like command key:) + keyd=center/\ltxkeyscheckuserinput{#1}{left,right,center} + \ifltxkeysinputvalid |label(mac:ifltxkeysinputvalid) + \edef\myval{\expandcsonce\userinput} + \edef\numberinlist{\number\order} + \edef\mychoices{\expandcsonce\nominations} + \else + \@latex@error{Input `#1' not valid}\@ehd + \fi; + |com(Boolean key with no callback:) + keye=false; +} +\finish{example} +\fxim*{\ifltxkeysinputvalid,\ltxkeyscheckuserinput,\nominations,\userinput} +\aiidxm*[\bs,choice keys]{nominations,ifltxkeysinputvalid} + +In this example, \fx{\userinput} corresponds to \fx{#1}; \fx{\order} is the numerical order of the user input in \fx{\nominations}; the list of valid values suggested at key definition time (\fnz*{left,right,center} in this example). The boolean \fx{ltxkeysinputvalid} is associated with the command \fx{\ltxkeyscheckuserinput} and is available to the user. It is set \hx{true} when the user input is valid, and \hx{false} otherwise. The command \fx{\ltxkeyscheckuserinput} expects two arguments: the user input and the list of nominations. It doesn't expect two branches (see \sref{sec:checkchoice}). + + \docsubsection(sec:needvalue)<need-value keys>{Need-value keys} Sometimes you may want to create keys for which the user must always supply his/her own values, even if the keys originally have default values. The default values of keys may not always be suitable. Take, for example, the height and width of a graphics image. For functions that are meant to handle generic images, it would certainly be inappropriate to relieve the user of the need to call picture height and width without corresponding values. @@ -851,7 +909,7 @@ See more about key pointers in \sref{sec:keypointers}. There are times when it is required to use the same, or nearly the same, set of keys for different functions and purposes, and thus for different key families and prefixes. We call such keys \quoted{cross-family keys} or \quoted{xfamily keys}. Such keys bear the same names across key families and key prefixes. For example, the \pkg'{xwatermark} defines three functions (\ffx'{\xwmminipage,\xwmboxedminipage,\xwmcolorbox}) using nearly the same set of keys. In each of the three families, the keys bear the same or similar names and they have similar callbacks. The management of cross-family keys can be simplified by using the tools of this section. Even if not all the cross-family keys are needed in all the families to which they may belong, there are still advantages in using this type of keys when some of the keys cut across families. -Cross-family keys are automatically initialized after being defined---as we saw in the case of the commands \ffx'{\ltxkeysdeclarekeys,\ltxkeysdeclarekeys}. +Cross-family keys are automatically initialized after being defined---as we saw in the case of the commands \ffx'{\ltxkeysdefinekeys,\ltxkeysdeclarekeys}. \start+{newmacro}[\ltxkeyssavexfamilykeys,\ltxkeysdefinexfamilykeys] \ltxkeyssavexfamilykeys<|A(id)>{|A(keylist)} @@ -865,9 +923,9 @@ Cross-family keys are automatically initialized after being defined---as we saw \finish{newmacro} \fxim*{\ltxkeyssavexfamilykeys,\ltxkeysdefinexfamilykeys} -Here, \ang{id} is the mandatory identifier of the key list \ang{keylist}, \ang{pref} is the key prefix, \ang{fam} the key family, \ang{mp} is the macro prefix, and \ang{na} is the list of keys belonging to \ang{keylist} that shouldn't be presently defined and initialized. The \ang{na} can be empty, but it must always be there as a mandatory argument. \emph{So, where you put the key list in the commands \emfx{\ltxkeysdeclarekeys} and \emfx{\ltxkeysdeclarekeys} is where you now have to locate \ang{na}}. For any use of the command \fx{\ltxkeysdefinexfamilykeys} we expect the \ang{na} to be far less than the remaining keys. The \stform of \fx{\ltxkeyssavexfamilykeys} will expand \ang{keylistcmd} once before saving the xfamily keys. The \stform of \fx{\ltxkeysdefinexfamilykeys} will define only definable keys, in the sense of \hx{\newcommand}. +Here, \ang{id} is the mandatory identifier of the key list \ang{keylist}, \ang{pref} is the key prefix, \ang{fam} the key family, \ang{mp} is the macro prefix, and \ang{na} is the list of keys belonging to \ang{keylist} that shouldn't be presently defined and initialized. The \ang{na} can be empty, but it must always be there as a mandatory argument. \emph{So, where you put the key list in the commands \emfx{\ltxkeysdefinekeys} and \emfx{\ltxkeysdeclarekeys} is where you now have to locate \ang{na}}. For any use of the command \fx{\ltxkeysdefinexfamilykeys} we expect the \ang{na} to be far less than the remaining keys. The \stform of \fx{\ltxkeyssavexfamilykeys} will expand \ang{keylistcmd} once before saving the xfamily keys. The \stform of \fx{\ltxkeysdefinexfamilykeys} will define only definable keys, in the sense of \hx{\newcommand}. -\ang{keylist} and \ang{keylistcmd} have the same syntax as the last arguments of \ffx'{\ltxkeysdeclarekeys,\ltxkeysdeclarekeys}: +\ang{keylist} and \ang{keylistcmd} have the same syntax as the last arguments of \ffx'{\ltxkeysdefinekeys,\ltxkeysdeclarekeys}: \start'{newmacro}[Syntax of keylist] |A(keytype)/|A(keyname)/|A(dft)/|A(cbk); @@ -875,7 +933,7 @@ another set of key attributes; etc. \finish{newmacro} -Here too \ang{keytype} must be a member of the set \fnz{ord,cmd,sty,sty*,bool,choice}, \ang{keyname} is obviously the name of the key, \ang{dft} is the default value of the key, and \ang{cbk} is the callback of the key. If the key is a style key, you can add the attributes of the dependants after \ang{cbk} (see the syntaxes of the commands \ffx'{\ltxkeysdeclarekeys, \ltxkeysdeclarekeys}). +Here too \ang{keytype} must be a member of the set \fnz{ord,cmd,sty,sty*,bool,choice}, \ang{keyname} is obviously the name of the key, \ang{dft} is the default value of the key, and \ang{cbk} is the callback of the key. If the key is a style key, you can add the attributes of the observers after \ang{cbk} (see the syntaxes of the commands \ffx'{\ltxkeysdefinekeys, \ltxkeysdeclarekeys}). The mandatory identifier \ang{id} for each list must be unique, not withstanding the fact that the identifiers have their separate namespace. @@ -914,15 +972,15 @@ If the xfamily keys are all of the same type (\ie, only one of the types \fnz{or \fxi*{\ltxkeyssavexfamilykeys,\ltxkeysdefinexfamilykeys} \start+{example}[xfamily keys] -|com(`keya' and `keyd' are starred style keys but `keyd' has no dependants:) +|com(`keya' and `keyd' are starred style keys but `keyd' has no observers:) \ltxkeyssavexfamilykeys<a1>|(sty|*|){% - keya/center/\def\xx##1{##1xx#1}/ + keya/center/.do=\def\xx##1{##1xx#1}/ ord>\needvalue{keyb}>\parentval>\edef\yy##1{##1yy\unexpanded{#1}}, |com(The braces around `center' |(the default value of `keyc'|)) |com(will be preserved in parsing:) cmd>keyc>{center}; |com(The braces around the callback of `keyd' will be preserved:) - keyd/red/\def\x{\color{#1}print aaa}; + keyd/red/.do={\def\x{\color{#1}print aaa}}; } |com(Ignore `keyd' in defining keys saved in `a1':) \ltxkeysdefinexfamilykeys*<a1>[KV]{fam}[mp@]{keyd} @@ -1063,13 +1121,13 @@ Aliased keys differ from style keys of \sref{sec:stylekeys}. Two keys may be ali Here, \ang{value} is optional; if it is not given, \ang{key} will be set with the current value of its alias. \start+{example}[\ltxkeyssetaliaskey] -\ltxkeysdeclarekeys|*[KV]{fam}[mp@]{% +\ltxkeysdefinekeys|*[KV]{fam}[mp@]{% printsign=true; printmark=true/\ltxkeyssetaliaskey{printsign}[false]; keya=$+++$; keyb=star/\ltxkeyssetaliaskey{keya}[$***$] } -\ltxkeysdeclarekeys|*[KV]{fam}[mp@]{% +\ltxkeysdefinekeys|*[KV]{fam}[mp@]{% keya=sun/\ltxkeyscheckuserinput{#1}{star,sun,moon} \ifltxkeysinputvalid \edef\givenval{\userinput} @@ -1111,7 +1169,7 @@ Here is an interesting example and proof of concept of pointers: \ltxkeysstylekeys|*[KV]{fam}{% \needvalue{keya},\savevalue\needvalue{keyb},\gneedvalue\gsavevalue{keyc} }[{left}]|(% - |com(`#1' here refers to the value of the dependant key at the) + |com(`#1' here refers to the value of the observer key at the) |com(time it is being set.) ord/\savevalue{keyb}/\parentval/\edef\y##1{##1xx\unexpanded{#1}}; cmd/keyc/{center} @@ -1131,70 +1189,69 @@ Here is an interesting example and proof of concept of pointers: If you have to save the values of many keys, then the above scheme of placing \fx{\savevalue} or \fx{\gsavevalue} on keys at key setting time can be avoided by using the following commands: -\start+{newmacro}[\ltxkeyssavevaluekeys,\ltxkeysaddsavevaluekeys, etc.] -\ltxkeyssavevaluekeys[|A(pref)]{|A(fam)}{|A(list)} -\ltxkeysaddsavevaluekeys[|A(pref)]{|A(fam)}{|A(list)} -\ltxkeysremovesavevaluekeys[|A(pref)]{|A(fam)}{|A(list)} -\ltxkeysundefsavevaluekeys[|A(pref)]{|A(fam)} -\ltxkeysundefsavevaluekeys|![|A(pref)]{|A(fam)} -\ltxkeysemptifysavevaluekeys[|A(pref)]{|A(fam)} -\ltxkeysemptifysavevaluekeys|![|A(pref)]{|A(fam)} +\start+{newmacro}[\ltxkeys@savevaluekeys,\ltxkeys@addsavevaluekeys, etc.] +\ltxkeys@savevaluekeys[|A(pref)]{|A(fam)}{|A(list)} +\ltxkeysgsavevaluekeys[|A(pref)]{|A(fam)}{|A(list)} +\ltxkeys@addsavevaluekeys[|A(pref)]{|A(fam)}{|A(list)} +\ltxkeysgaddsavevaluekeys[|A(pref)]{|A(fam)}{|A(list)} +\ltxkeys@removesavevaluekeys[|A(pref)]{|A(fam)}{|A(list)} +\ltxkeysgremovesavevaluekeys[|A(pref)]{|A(fam)}{|A(list)} +\ltxkeys@undefsavevaluekeys[|A(pref)]{|A(fam)} +\ltxkeysgundefsavevaluekeys|![|A(pref)]{|A(fam)} \finish{newmacro} -\fxim*{\ltxkeyssavevaluekeys,\ltxkeysaddsavevaluekeys, - \ltxkeysremovesavevaluekeys,\ltxkeysundefsavevaluekeys, - \ltxkeysemptifysavevaluekeys} +\fxim*{\ltxkeys@savevaluekeys,\ltxkeys@addsavevaluekeys, + \ltxkeys@removesavevaluekeys,\ltxkeys@undefsavevaluekeys} -The command \fx{\ltxkeyssavevaluekeys} will create, for the given key family and prefix, a list of keys whose values should be saved at key-setting time, if those keys don't already exist in the list. The command \fx{\ltxkeysaddsavevaluekeys} will add to the list those keys that don't already exist in the list; \fx{\ltxkeysremovesavevaluekeys} remove those save-keys that it can find in the list; while the command \fx{\ltxkeysundefsavevaluekeys} will undefine the entire list of save-keys of the given key family and prefix. The command \fx{\ltxkeysemptifysavevaluekeys} will simplify emptify the content of the save-key list. The \clform of the commands +The command \fx{\ltxkeys@savevaluekeys} will create, for the given key family and prefix, a list of keys whose values should be saved at key-setting time, if those keys don't already exist in the list. The command \fx{\ltxkeys@addsavevaluekeys} will add to the list those keys that don't already exist in the list; \fx{\ltxkeys@removesavevaluekeys} remove those save-keys that it can find in the list; while the command \fx{\ltxkeys@undefsavevaluekeys} will undefine the entire list of save-keys of the given key family and prefix. -\start+{macro} -\ltxkeysundefsavevaluekeys -\ltxkeysemptifysavevaluekeys -\finish{macro} - -will undefine or emptify the existing save-key list globally. - -\start+{example}[\ltxkeyssavevaluekeys] -\ltxkeysdeclarekeys[KV]{fam}[mp@]{% +\start+{example}[\ltxkeys@savevaluekeys] +\ltxkeysdefinekeys[KV]{fam}[mp@]{% ord/keya/2cm/\def\x##1{#1xx##1}; cmd/keyb/John; bool/keyc/true/\ifmp@keyc\def\y##1{##1yy#1}\fi; choice/keyd.{left,right,center}/ - \ifcase\order\def\shoot{0}\or\def\shoot{1}\or\def\shoot{2}\fi + \ifcase\order + \def\shoot{0}% + \or + \def\shoot{1}% + \or + \def\shoot{2}% + \fi } -\ltxkeyssavevaluekeys[KV]{fam}{keya,keyb,keyc} -\ltxkeysaddsavevaluekeys[KV]{fam}{keyd} -\ltxkeysremovesavevaluekeys[KV]{fam}{keya,keyb} -\ltxkeysundefsavevaluekeys[KV]{fam} +\ltxkeys@savevaluekeys[KV]{fam}{keya,keyb,keyc} +\ltxkeys@addsavevaluekeys[KV]{fam}{keyd} +\ltxkeys@removesavevaluekeys[KV]{fam}{keya,keyb} +\ltxkeys@undefsavevaluekeys[KV]{fam} \ltxkeyssetkeys[KV]{fam}{keya=\usevalue{keyc},keyb=\usevalue{keya}} \finish{example} The following commands are also available: -\start+{newmacro}[\ltxkeysneedvaluekeys,\ltxkeysaddneedvaluekeys, etc.] -\ltxkeysneedvaluekeys[|A(pref)]{|A(fam)}{|A(list)} -\ltxkeysaddneedvaluekeys[|A(pref)]{|A(fam)}{|A(list)} -\ltxkeysremoveneedvaluekeys[|A(pref)]{|A(fam)}{|A(list)} -\ltxkeysundefneedvaluekeys[|A(pref)]{|A(fam)} -\ltxkeysundefneedvaluekeys|![|A(pref)]{|A(fam)} -\ltxkeysemptifyneedvaluekeys[|A(pref)]{|A(fam)} -\ltxkeysemptifyneedvaluekeys|![|A(pref)]{|A(fam)} +\start+{newmacro}[\ltxkeys@needvaluekeys,\ltxkeys@addneedvaluekeys, etc.] +\ltxkeys@needvaluekeys[|A(pref)]{|A(fam)}{|A(list)} +\ltxkeysgneedvaluekeys[|A(pref)]{|A(fam)}{|A(list)} +\ltxkeys@addneedvaluekeys[|A(pref)]{|A(fam)}{|A(list)} +\ltxkeysgaddneedvaluekeys[|A(pref)]{|A(fam)}{|A(list)} +\ltxkeys@removeneedvaluekeys[|A(pref)]{|A(fam)}{|A(list)} +\ltxkeysgremoveneedvaluekeys[|A(pref)]{|A(fam)}{|A(list)} +\ltxkeys@undefneedvaluekeys[|A(pref)]{|A(fam)} +\ltxkeysgundefneedvaluekeys|![|A(pref)]{|A(fam)} -\ltxkeysforbidvaluekeys[|A(pref)]{|A(fam)}{|A(list)} -\ltxkeysaddforbidvaluekeys[|A(pref)]{|A(fam)}{|A(list)} -\ltxkeysremoveforbidvaluekeys[|A(pref)]{|A(fam)}{|A(list)} -\ltxkeysundefforbidvaluekeys[|A(pref)]{|A(fam)} -\ltxkeysundefforbidvaluekeys|![|A(pref)]{|A(fam)} -\ltxkeysemptifyforbidvaluekeys[|A(pref)]{|A(fam)} -\ltxkeysemptifyforbidvaluekeys|![|A(pref)]{|A(fam)} +\ltxkeys@forbidvaluekeys[|A(pref)]{|A(fam)}{|A(list)} +\ltxkeysgforbidvaluekeys[|A(pref)]{|A(fam)}{|A(list)} +\ltxkeys@addforbidvaluekeys[|A(pref)]{|A(fam)}{|A(list)} +\ltxkeysgaddforbidvaluekeys[|A(pref)]{|A(fam)}{|A(list)} +\ltxkeys@removeforbidvaluekeys[|A(pref)]{|A(fam)}{|A(list)} +\ltxkeysgremoveforbidvaluekeys[|A(pref)]{|A(fam)}{|A(list)} +\ltxkeys@undefforbidvaluekeys[|A(pref)]{|A(fam)} +\ltxkeysgundefforbidvaluekeys|![|A(pref)]{|A(fam)} \finish{newmacro} -\fxim*{\ltxkeysneedvaluekeys,\ltxkeysaddneedvaluekeys, - \ltxkeysremoveneedvaluekeys,\ltxkeysundefneedvaluekeys, - \ltxkeysemptifyneedvaluekeys, - \ltxkeysforbidvaluekeys,\ltxkeysaddforbidvaluekeys, - \ltxkeysremoveforbidvaluekeys,\ltxkeysundefforbidvaluekeys, - \ltxkeysemptifyforbidvaluekeys +\fxim*{\ltxkeys@needvaluekeys,\ltxkeys@addneedvaluekeys, + \ltxkeys@removeneedvaluekeys,\ltxkeys@undefneedvaluekeys, + \ltxkeys@forbidvaluekeys,\ltxkeys@addforbidvaluekeys, + \ltxkeys@removeforbidvaluekeys,\ltxkeys@undefforbidvaluekeys, } @@ -1244,30 +1301,14 @@ Here, \ang{cs} is the macro (defined or undefined) that will receive the saved v \ltxkeysremovepostsetkeys|![|A(pref)]{|A(fam)}{|A(keyvals)} \ltxkeysundefpostsetkeys[|A(pref)]{|A(fam)} \ltxkeysundefpostsetkeys|![|A(pref)]{|A(fam)} - -\ltxkeyspreposetkeys[|A(pref)]{|A(fam)}{|A(head-keyvals)}{|A(tail-keyvals)} -\ltxkeyspreposetkeys|![|A(pref)]{|A(fam)}{|A(head-keyvals)}{|A(tail-keyvals)} -\ltxkeysaddpreposetkeys[|A(pref)]{|A(fam)}{|A(head-keyvals)}{|A(tail-keyvals)} -\ltxkeysaddpreposetkeys|![|A(pref)]{|A(fam)}{|A(head-keyvals)}{|A(tail-keyvals)} -\ltxkeysremovepreposetkeys[|A(pref)]{|A(fam)}{|A(head-keyvals)}{|A(tail-keyvals)} -\ltxkeysremovepreposetkeys|![|A(pref)]{|A(fam)}{|A(head-keyvals)}{|A(tail-keyvals)} -\ltxkeysundefpreposetkeys[|A(pref)]{|A(fam)} -\ltxkeysundefpreposetkeys|![|A(pref)]{|A(fam)} \finish{newmacro} \fxim*{\ltxkeyspresetkeys,\ltxkeysaddpresetkeys,\ltxkeysremovepresetkeys, \ltxkeysundefpresetkeys,\ltxkeyspostsetkeys,\ltxkeysaddpostsetkeys, - \ltxkeysremovepostsetkeys,\ltxkeysundefpostsetkeys, - \ltxkeyspreposetkeys,\ltxkeysaddpreposetkeys,\ltxkeysremovepreposetkeys, - \ltxkeysundefpreposetkeys -} + \ltxkeysremovepostsetkeys,\ltxkeysundefpostsetkeys} -Here, \ang{keyvals} is a comma-separated list of \keyval pairs to be preset or postset in the given families. The optional exclamation mark \redclam here, as in many (but not all) instances in the \pkg'{ltxkeys}, means that the assignments would be done and the lists built globally rather than locally. \quoted{Presetting keys} means \quoted{these keys should be set before setting other keys in the user input in every run of the command \fx{\ltxkeyssetkeys} for the given key prefix and family}. Keys contained in the current user input to \fx{\ltxkeyssetkeys} will not be preset or postset, \ie, the current user key-value pairs will always take priority over preset and postset values. The command \fx{\ltxkeysaddpresetkeys} is an alias for \fx{\ltxkeyspresetkeys}, and this helps explain that \fx{\ltxkeyspresetkeys} is indeed a list merger. Neither the command \fx{\ltxkeyspresetkeys} nor \fx{\ltxkeyspostsetkeys} set keys itself, contrary to what the names might suggest. +Here, \ang{keyvals} is a comma-separated list of \keyval pairs to be preset or postset in the given families. The optional exclamation mark \redclam here, as in many (but not all) instances in the \pkg'{ltxkeys}, means that the assignments would be done and the lists built globally rather than locally. \quoted{Presetting keys} means \quoted{these keys should be set before setting other keys in every run of the command \fx{\ltxkeyssetkeys} for the given key prefix and family}\footnote{Keys contained in the current user input to \fx{\ltxkeyssetkeys} will not be preset or postset, \ie, the current user values of keys will always take priority over preset and postset values.}. The command \fx{\ltxkeysaddpresetkeys} is an alias for \fx{\ltxkeyspresetkeys}, and this helps explain that \fx{\ltxkeyspresetkeys} is indeed a list merger. Neither the command \fx{\ltxkeyspresetkeys} nor \fx{\ltxkeyspostsetkeys} set keys itself, contrary to what the names might suggest. -\quoted{Post-setting keys} means \quoted{these keys are to be set after setting other keys in the user input in every run of the command \fx{\ltxkeyssetkeys} for the given key prefix and family}. \fx{\ltxkeysaddpostsetkeys} is an alias for \fx{\ltxkeyspostsetkeys}. Keys contained in the current user input to \fx{\ltxkeyssetkeys} will not be postset. - -\quoted{Prepo-setting keys} means \quoted{these leading (head) keys are to be set before, and the trailing (tail) keys are to be set after, setting other keys in the user input in every run of the command \fx{\ltxkeyssetkeys} for the given key prefix and family}. Keys contained in the current user input to \fx{\ltxkeyssetkeys} will not be preposet. \fx{\ltxkeysaddpreposetkeys} is an alias for \fx{\ltxkeyspreposetkeys}. - -The commands +\quoted{Post-setting keys} means \quoted{these keys are to be set after setting other keys in every run of the command \fx{\ltxkeyssetkeys} for the given key prefix and family}. \fx{\ltxkeysaddpostsetkeys} is an alias for \fx{\ltxkeyspostsetkeys}. The commands \start+{macro} \ltxkeysremovepresetkeys|![|A(pref)]{|A(fam)}{|A(keys)} @@ -1286,7 +1327,7 @@ respectively, undefine all preset and post-set keys in the given family. Logically, you can't enter the same key twice in either preset or post-set list in the same family and prefix. \start+{example}[\ltxkeyspresetkeys, \ltxkeyspostsetkeys, etc.] -\ltxkeysdeclarekeys|*[KV1]{fam1}[mp@]{% +\ltxkeysdefinekeys|*[KV1]{fam1}[mp@]{% keya/left/\def\x##1{#1x##1}; \needvalue{keyb}/right; keyc/center; @@ -1305,16 +1346,17 @@ Logically, you can't enter the same key twice in either preset or post-set list \finish{example} -\docsubsection(sec:initializekeys)<initializing keys>{Initializing keys} +\docsubsection(sec:initializekeys) + <initializing keys>{Initializing keys} \start{newmacro}[\ltxkeysinitializekeys] \ltxkeysinitializekeys[|A(prefs)]{|A(fams)}[|A(na)] \finish{newmacro} \fxim*{\ltxkeysinitializekeys} -This presets all the keys previously defined in families \ang{fams} with their default values; it ignores keys listed in \ang{na}. If \ang{na} is a list of \keyval pairs, the key names are extracted from the list before the family keys are initialized. Any \keyval pairs in \ang{na} are not set at all. All keys defined by \ffx'{\ltxkeysdeclarekeys, \ltxkeysdeclarekeys} are automatically instantly initialized, except slave/alias and dependant keys. Alias and dependant keys aren't initialized in this case in order to avoid cyclic re-entrance of \fx{\ltxkeyssetkeys}. +This presets all the keys previously defined in families \ang{fams} with their default values; it ignores keys listed in \ang{na}. If \ang{na} is a list of \keyval pairs, the key names are extracted from the list before the family keys are initialized. Any \keyval pairs in \ang{na} are not set at all. All keys defined by \ffx'{\ltxkeysdefinekeys, \ltxkeysdeclarekeys} are automatically instantly initialized, except slave/alias and observer keys. Alias and observer keys aren't initialized in this case in order to avoid cyclic re-entrance of \fx{\ltxkeyssetkeys}. -The command \fx{\ltxkeysinitializekeys} can be used in place of \fx{\ltxkeysexecuteoptions}, since \fx{\ltxkeysexecuteoptions} (similar to \latex kernel's \hx{\ExecuteOptions}) fulfils the sole purpose of setting up default values of options. Keys defined via \ffx'{\ltxkeysdeclarekeys, \ltxkeysdeclarekeys} don't have to be initialized, since they're automatically initialized at definition time. But if you have used the scheme of \sref{nte:definekeys-1}, then it might still be necessary to initialize keys outside \ffx'{\ltxkeysdeclarekeys, \ltxkeysdeclarekeys}. +The command \fx{\ltxkeysinitializekeys} can be used in place of \fx{\ltxkeysexecuteoptions}, since \fx{\ltxkeysexecuteoptions} (similar to \latex kernel's \hx{\ExecuteOptions}) fulfils the sole purpose of setting up default values of options. Keys defined via \ffx'{\ltxkeysdefinekeys, \ltxkeysdeclarekeys} don't have to be initialized, since they're automatically initialized at definition time. But if you have used the scheme of \sref{nte:definekeys-1}, then it might still be necessary to initialize keys outside \ffx'{\ltxkeysdefinekeys, \ltxkeysdeclarekeys}. \begin{noteenv} \label{nte:initializekeys} @@ -1377,7 +1419,7 @@ The following example provides unknown option and key handlers. The unknown key \ltxkeysunknownkeyhandler[KVA,KVB]{fam1,fam2}{% \@expandtwoargs\in@{,#3,}{,\myspecialkeys,}% - \ifdefboolTF{in@}{% + \ltsifboolTF{in@}{% |com(The reader may want to investigate what the parameter texts) |com(##1 and ####1 below stand for |(see |sref(nte:unknownkey) below|):) \ltxkeysordkey[#1]{#2}{#3}[#4]{\def\x####1{####1xx##1}}% @@ -1402,7 +1444,7 @@ To see what the parameter texts \fx{##1} and \fx{####1} above stand for, run the \ifin@ \ltxkeysordkey[#1]{#2}{#3}[#4]{\def\x####1{####1xx##1}}% \else - \@warning{Unknown key `#3' with value `\ltxkeysinnocentvalue' + \ltxmsg@warn{Unknown key `#3' with value `\ltxkeysinnocentvalue' in family `#2' ignored}\@ehd \fi } @@ -1441,19 +1483,25 @@ Here, \ang{prefs} and \ang{fams} are comma-separated lists of prefixes and famil The plain forms of \ffx'{\ltxkeysdisablefamilies,\ltxkeysgdisablefamilies} disable the given families instantly, while the \stform+ disable the families at \hx{\AtBeginDocument}. Authors can use these commands to bar users of their keys from calling those families after a certain point. Individual keys in a family can be disabled using the commands \ffx'{\ltxkeysdisablekeys, \ltxkeysgdisablekeys}. \start{example}[\ltxkeysdisablefamilies] -\ltxkeysdeclarekeys*[KV1]{fam1}[mp@]{% - bool/key1/true/\def\xx##1{##1\\#1\\##1}; - bool/key2/true/\def\yy##1{##1*#1*##1}; - cmd/key3/aaa/; - cmd/key4/bbb/ -} -\ltxkeysdeclarekeys*[KV2]{fam2}[mp@]{% - bool/key1/true; - bool/key2/true; - cmd/key3/yyy/; - cmd/key4/zzz/ -} -\ltxkeysdisablefamilies[KV1,KV2]{fam1,fam2}[key3,key4] +\ltxkeys{% + |com(The commands \declare@keys, \set@keys and \set@rmkeys are available) + |com(only within \ltxkeys.) + \declare@keys*[KV1]{fam1}[mp@]{% + bool/key1/true/\def\xx##1{##1\\#1\\##1}; + bool/key2/true/\def\yy##1{##1*#1*##1}; + cmd/key3/aaa/; + cmd/key4/bbb/ + }% + \\ + \declare@keys*[KV2]{fam2}[mp@]{% + bool/key1/true; + bool/key2/true; + cmd/key3/yyy/; + cmd/key4/zzz/ + }% + \\ + \ltxkeysdisablefamilies[KV1,KV2]{fam1,fam2}[key3,key4] +} \showcsn{KV1@fam2@disabledkeys} \finish{example} @@ -1507,7 +1555,7 @@ The command \fx{\ltxkeysmakeoptionkeys} makes all the keys with prefix \ang{pref \docsection(sec:handledkeys)<handled keys>{Handled keys} -As mentioned in \sref{sec:unknownkeyhandler}, handled keys are keys defined in a macro that is key-prefix and key-family dependent. They are defined as a list in a macro so that they can be used for future applications, such as deciding if a dependant key of a style key should be defined or redefined on the fly. Handled keys should be defined, or added to, using key prefix, family and key names. You can define or add to handled keys by the following command: +As mentioned in \sref{sec:unknownkeyhandler}, handled keys are keys defined in a macro that is key-prefix and key-family dependent. They are defined as a list in a macro so that they can be used for future applications, such as deciding if a observer key of a style key should be defined or redefined on the fly. Handled keys should be defined, or added to, using key prefix, family and key names. You can define or add to handled keys by the following command: \start{newmacro}[\ltxkeyshandledkeys] \ltxkeyshandledkeys[|A(pref)]{|A(fam)}{|A(list)} @@ -1553,7 +1601,7 @@ Rather than remove individual handled keys from a list, you might prefer or need \docsection(sec:reservedpath){Reserving and unreserving key path or bases} \aidxm*{reserving key prefix, reserving key family} -By \quoted{key path} we mean the key prefix (default is \fx{KV}), key family (generally no default), and macro prefix (default is dependent on the type of key). You can reserve key path or bases (\ie, bar future users from using the same path or bases) by the following commands. Once a key family or prefix name has been used, it might be useful barring further use of those names. For example, the \pkg'{ltxkeys} has barred users from defining keys with key family \fx{ltxkeys} and macro prefix \fx{ltxkeys@}. +By \quoted{key path} we mean the key prefix (default is \fx{KV}), key family (generally no default), and macro prefix (default is dependent on the type of key). You can reserve key path or bases (\ie, bar future users from using the same path or bases) by the following commands. Once a key family or prefix name has been used, it might be useful barring further use of those names. For example, the \pkg'{ltxkeys} has barred users from defining keys with key family \fx{ltxkeys} and macro prefix \fx{ltxkeys}. \start+{newmacro}[\ltxkeysreservekeyprefix,\ltxkeysreservekeyfamily, etc.] \ltxkeysreservekeyprefix{|A(list)} @@ -1563,11 +1611,12 @@ By \quoted{key path} we mean the key prefix (default is \fx{KV}), key family (ge \ltxkeysreservemacroprefix{|A(list)} \ltxkeysreservemacroprefix|*{|A(list)} \finish{newmacro} -\fxim*{\ltxkeysreservekeyprefix,\ltxkeysreservekeyfamily,\ltxkeysreservemacroprefix} +\fxim*{\ltxkeysreservekeyprefix,\ltxkeysreservekeyfamily, + \ltxkeysreservemacroprefix} Here, \ang{list} is a comma-separated list of bases. The \stform+ of these commands will defer reservation to the end of the current package or class, while the \unstform+ will effect the reservation immediately. As the package or class author you may want to defer the reservation to the end of your package or class. -Users can, at their own risk, override reserved key bases simply by issuing the package boolean option \fx{reservenopath}. This can be issued in \hhx{\documentclass,\usepackage} or \fx{\ltxkeysoptions}. This might be too drastic for many users and uses. Therefore, the \pkg'{ltxkeys} also provides the following commands that can be used for selectively unreserving currently reserved key bases: +Users can, at their own risk, override reserved key bases simply by issuing the package boolean option \fx{reservenopath}. This can be issued in \hhx{\documentclass,\usepackage} or \fx{\setltxkeysoptions}. This might be too drastic for many users and uses. Therefore, the \pkg'{ltxkeys} also provides the following commands that can be used for selectively unreserving currently reserved key bases: \start+{newmacro}[\ltxkeysunreservekeyprefix,\ltxkeysunreservekeyfamily, etc.] \ltxkeysunreservekeyprefix{|A(list)} @@ -1577,7 +1626,8 @@ Users can, at their own risk, override reserved key bases simply by issuing the \ltxkeysunreservemacroprefix{|A(list)} \ltxkeysunreservemacroprefix|*{|A(list)} \finish{newmacro} -\fxim*{\ltxkeysunreservekeyprefix,\ltxkeysunreservekeyfamily,\ltxkeysunreservemacroprefix} +\fxim*{\ltxkeysunreservekeyprefix,\ltxkeysunreservekeyfamily, + \ltxkeysunreservemacroprefix} The \stform+ of these commands will defer action to the end of the current package or class, while the \unstform+ will undo the reservation immediately. @@ -1728,13 +1778,12 @@ can each be used to introduce several options that share the same path or bases \finish{newmacro} \fxim*{\ltxkeysdeclaremultitypeoptions} -Here, the key default value \ang{dft} and callback \ang{cbk} can be absent in all cases. \ang{keytype} may be any one of \fnz{ord,cmd,sty,sty*,bool,choice}. The star (\redstar) in \quoted{sty\Redstar} has the same meaning as in \fx{\ltxkeysstylekey} above, namely, undefined dependants will be defined on the fly when the parent key is set. The optional quantity \ang{mp} is the macro prefix, as in, for example, \sref{sec:cmdkeys}. The syntax for the command \fx{\ltxkeysdeclaremultitypeoptions} is identical to that of \fx{\ltxkeysdeclarekeys} except for the following differences: For \fx{\ltxkeysdeclarekeys} the family is mandatory and must be given in curly braces, while for \fx{\ltxkeysdeclaremultitypeoptions} the family is optional, with the default value of \quotedhx{\@currname.\@currext}, \ie, the name of the class file or package and its file extension. For \fx{\ltxkeysdeclaremultitypeoptions}, the optional family is expected to be given in angled brackets. The \stform of the command \fx{\ltxkeysdeclaremultitypeoptions} defines only undefined options. +Here, the key default value \ang{dft} and callback \ang{cbk} can be absent in all cases. \ang{keytype} may be any one of \fnz{ord,cmd,sty,sty*,bool,choice}. The star (\redstar) in \quoted{sty\Redstar} has the same meaning as in \fx{\ltxkeysstylekey} above, namely, undefined observers will be defined on the fly when the parent key is set. The optional quantity \ang{mp} is the macro prefix, as in, for example, \sref{sec:cmdkeys}. The syntax for the command \fx{\ltxkeysdeclaremultitypeoptions} is identical to that of \fx{\ltxkeysdeclarekeys} except for the following differences: For \fx{\ltxkeysdeclarekeys} the family is mandatory and must be given in curly braces, while for \fx{\ltxkeysdeclaremultitypeoptions} the family is optional, with the default value of \quotedhx{\@currname.\@currext}, \ie, the name of the class file or package and its file extension. For \fx{\ltxkeysdeclaremultitypeoptions}, the optional family is expected to be given in angled brackets. The \stform of the command \fx{\ltxkeysdeclaremultitypeoptions} defines only undefined options. An alias for the long command \fx{\ltxkeysdeclaremultitypeoptions} is \fx{\declaremultitypeoptions}. \start{example}[\ltxkeysdeclaremultitypeoptions] -\ltxkeysdeclaremultitypeoptions*[KV]<fam>[mp@]{% +\declaremultitypeoptions*[KV]<fam>[mp@]{% cmd/option1/xx/\def\x##1{##1xx#1}; bool/option2/true; - sty* } \finish{example} @@ -1803,11 +1852,11 @@ The specification of the mandatory arguments and any optional first argument for \start+{newmacro}[\ltxkeyscommand,\ltxkeysenvironment, etc] |A(pref)\ltxkeyscommand|A(cs)[|A(narg)][|A(dft)]<|A(delim)>|(|A(keys)|){|A(defn)} -|A(pref)\renewltxkeyscommand|A(cs)[|A(narg)][|A(dft)]<|A(delim)>|(|A(keys)|){|A(defn)} +|A(pref)\reltxkeyscommand|A(cs)[|A(narg)][|A(dft)]<|A(delim)>|(|A(keys)|){|A(defn)} |A(pref)\ltxkeysenvironment{|A(name)}[|A(narg)][|A(dft)]<|A(delim)>|(|A(keys)|){|A(begdefn)}{|A(enddefn)} -|A(pref)\renewltxkeysenvironment{|A(name)}[|A(narg)][|A(dft)]<|A(delim)>|(|A(keys)|){|A(begdefn)}{|A(enddefn)} +|A(pref)\reltxkeysenvironment{|A(name)}[|A(narg)][|A(dft)]<|A(delim)>|(|A(keys)|){|A(begdefn)}{|A(enddefn)} \finish{newmacro} -\fxim*{\ltxkeyscommand,\renewltxkeyscommand,\ltxkeysenvironment,\renewltxkeysenvironment,\ltxkeysglobal, +\fxim*{\ltxkeyscommand,\reltxkeyscommand,\ltxkeysenvironment,\reltxkeysenvironment,\ltxkeysglobal, \ltxkeysprotected,\ltxkeysrobust} Here, \ang{pref} is the optional command prefix, which may be either \fx{\ltxkeysglobal} (for global commands) or \fx{\ltxkeysprotected} (for \etex protected commands); \ang{cs} is the command; \ang{name} is the environment name; \ang{narg} is the number of parameters; \ang{dft} is the default value of the first argument; \ang{delim} are the parameter delimiters; \ang{keys} are the keys to be defined for the command or environment; \ang{defn} is the replacement text of the command; \ang{begdefn} is the environment entry text; and \ang{enddefn} is the code to execute while exiting the environment. @@ -1828,7 +1877,7 @@ In the \latex \hhx'{\newenvironment,\renewenvironment} commands, with the syntax \finish{macro} \hxim*{\newenvironment,\renewenvironment} -the environment's parameters and/or arguments aren't accessible in \ang{enddefn}. If the environment user wants to access the parameters in \ang{enddefn}, he has to save them while still in \ang{begdefn}. This isn't the case with the commands \ffx'{\ltxkeysenvironment,\renewltxkeysenvironment}, for which the user can access the environment parameters while in \ang{enddefn}. To do this, he should call the command \fxim{\envarg}, which expects as argument the corresponding numeral of the parameter text. For example, \ffx'{\envarg{1},\envarg{3}} refer to the first and third arguments of the environment, respectively. Examples are provided later. The current values of environment's keys can always be accessed in \ang{enddefn}. +the environment's parameters and/or arguments aren't accessible in \ang{enddefn}. If the environment user wants to access the parameters in \ang{enddefn}, he has to save them while still in \ang{begdefn}. This isn't the case with the commands \ffx'{\ltxkeysenvironment,\reltxkeysenvironment}, for which the user can access the environment parameters while in \ang{enddefn}. To do this, he should call the command \fxim{\envarg}, which expects as argument the corresponding numeral of the parameter text. For example, \ffx'{\envarg{1},\envarg{3}} refer to the first and third arguments of the environment, respectively. Examples are provided later. The current values of environment's keys can always be accessed in \ang{enddefn}. But how do we access the current values or states of keys while in \ang{begdefn} and \ang{enddefn}? To this end the commands \ffx'{\val,\ifval,\ifvalTF,\keyval,\ifkeyval,\ifkeyvalTF} are provided. They have the following syntaxes: @@ -2024,7 +2073,7 @@ Here, \ang{code} will be executed at the right instance when \ang{keycmd} is bei \start+{example}[Nested key environments] \def\testenv{} -\renewltxkeysenvironment{testenv}|(% +\reltxkeysenvironment{testenv}|(% |com(The \y below is just a test:) cmd/fraclen/0.1cm/\def\y##1{#1yyy##1}; cmd/framerule/.4pt; @@ -2125,14 +2174,14 @@ The following example shows that in place of the functions \ffx'{\val,\ifval,\if Sometimes keys are used simply to save values for later use. This can be achieved easily by using the command \fx{\ltxkeysdeclarevariables}. -\start{newmacro}[\ltxkeysdeclarevariables,\ltxkeyssetvariablevalues,\ltxkeysgetvariablevalue] +\start{newmacro}[\ltxkeysdeclarevariables,\ltxkeyssetvarvalues,\ltxkeysgetvarvalue] \ltxkeysdeclarevariables[|A(namespace)]{% |A(key-1) = |A(dft-1) = |A(cbk-1), ..., |A(key-n) = |A(dft-n) = |A(cbk-n) } -\ltxkeyssetvariablevalues[|A(namespace)]{|keyval pairs} -\ltxkeysgetvariablevalue[|A(namespace)]{|A(key)} +\ltxkeyssetvarvalues[|A(namespace)]{|keyval pairs} +\ltxkeysgetvarvalue[|A(namespace)]{|A(key)} \finish{newmacro} -\fxim*{\ltxkeysdeclarevariables,\ltxkeyssetvariablevalues,\ltxkeysgetvariablevalue} +\fxim*{\ltxkeysdeclarevariables,\ltxkeyssetvarvalues,\ltxkeysgetvarvalue} Here, \ang{key-i}, \ang{dft-i} and \ang{cbk-i} are key name, key default value, and key callback, respectively, for key \quotedfx{i}. The optional \ang{namespace} is the private namespace for the declared variables and is used to avoid clashes of control sequences. @@ -2146,11 +2195,11 @@ The key default value \ang{dft} and callback \ang{cbk} are optional and may be m |com(No default value and no callback:) var3 } -\ltxkeyssetvariablevalues[mynamespace]{var1=new value1, var2=new value2} -\edef\x{\ltxkeysgetvariablevalue[mynamespace]{var1}} +\ltxkeyssetvarvalues[mynamespace]{var1=new value1, var2=new value2} +\edef\x{\ltxkeysgetvarvalue[mynamespace]{var1}} \begin{document} -\ltxkeysgetvariablevalue[mynamespace]{var1} +\ltxkeysgetvarvalue[mynamespace]{var1} \end{document} \finish{example} @@ -2164,15 +2213,88 @@ The private namespace is optional but clashes of control sequences might occur: |com(No default value and no callback:) var3 } -\ltxkeyssetvariablevalues{var1=new value1, var2=new value2} -\edef\x{\ltxkeysgetvariablevalue{var1}} +\ltxkeyssetvarvalues{var1=new value1, var2=new value2} +\edef\x{\ltxkeysgetvarvalue{var1}} \begin{document} -\ltxkeysgetvariablevalue{var1} +\ltxkeysgetvarvalue{var1} \end{document} \finish{example} +\docsection(sec:ltxkeys-command){The \headfx{\ltxkeys} command} + +\start{newmacro}[\ltxkeys] +\ltxkeys|*|'{|A(code-1) \\ |A(code-2) ... \\ ... |A(code-n)} +\finish{newmacro} +\fxim*{\ltxkeys} + +The command \fx{\ltxkeys} simply provides an ungrouped\footnote{Meaning no local groups are created.} environment for using the short forms of the commands shown in \sref{tab:ltxkeys-cmdabbrv}. The abbreviated commands are pushed on entry into \fx{\ltxkeys}, they are then assigned the meaning of their longer counterparts, and then popped (to whatever their original meaning was before entry into \fx{\ltxkeys}) on exist of \fx{\ltxkeys}. The list parser within \fx{\ltxkeys} is invariably \quotedfx{\\}. The list is normalized\footnote{Normalization implies replacing double \quotedfx{\\} by single \quotedfx{\\} and removing spurious spaces around each \quotedfx{\\}.} and the given codes \ang{code-i}, $i=1,...,n$, executed on the consecutive loops. The commands \ffx{\ordkeys,\cmdkeys}, \etcc, can be used to define just one key or multiple keys in the same family and of the same callback. \sref{tab:ltxkeys-cmdabbrv} lists the other abbreviations available within \fx{\ltxkeys}. + +The \stform of \fx{\ltxkeys} will expand its argument once before commencing the loop and executing the codes \ang{code-i}, $i=1,...,n$. The \pmform is equivalent to invoking the package option \fx{endcallbackline} before calling \fx{\ltxkeys}. Using both \redstar and \redprime makes \hx{\endlinechar} $-1$ but the effect is not enforced, since in the \stform of \fx{\ltxkeys} the argument has already been read. + +\begingroup +\small +\begin{tabularx}{\linewidth}{|p{4.5cm}|p{5.5cm}|} +\caption{Command abbreviations available within \headfx{\ltxkeys} + \xwmlabel{tab:ltxkeys-cmdabbrv}}\\\hline +\rowcolor{pink} +\bf Command & \bf Abbreviation \\\hline +\endfirsthead +\hline +\multicolumn{2}{|l|}{\emph{Continued from last page}}\\\hline +\bf Command & \bf Abbreviation \\\hline +\endhead +\multicolumn{2}{|r|}{\emph{Continued on next page}}\\\hline +\endfoot +\hline +\endlastfoot +\fx{\ordkey} & \fx{\ltxkeysordkey} \\\hline +\fx{\ordkeys} & \fx{\ltxkeysordkeys} \\\hline +\fx{\listkey} & \fx{\ltxkeyslistkey} \\\hline +\fx{\listkeys} & \fx{\ltxkeyslistkeys} \\\hline +\fx{\cmdkey} & \fx{\ltxkeyscmdkey} \\\hline +\fx{\cmdkeys} & \fx{\ltxkeyscmdkeys} \\\hline +\fx{\boolkey} & \fx{\ltxkeysboolkey} \\\hline +\fx{\boolkeys} & \fx{\ltxkeysboolkeys} \\\hline +\fx{\switchkey} & \fx{\ltxkeysswitchkey} \\\hline +\fx{\switchkeys} & \fx{\ltxkeysswitchkeys} \\\hline +\fx{\choicekey} & \fx{\ltxkeyschoicekey} \\\hline +\fx{\choicekeys} & \fx{\ltxkeyschoicekeys} \\\hline +\fx{\stylekey} & \fx{\ltxkeysstylekey} \\\hline +\fx{\stylekeys} & \fx{\ltxkeysstylekeys} \\\hline +\fx{\definekeys} & \fx{\ltxkeysdefinekeys} \\\hline +\fx{\declarekeys} & \fx{\ltxkeysdeclarekeys} \\\hline +\fx{\declareoptions} & \fx{\ltxkeysdeclaremultitypeoptions} \\\hline +\fx{\ifdeclaringkeys}\fx{\then} & \fx{\ifltxkeysdec} \\\hline +\fx{\setkeys} & \fx{\ltxkeyssetkeys}\\\hline +\fx{\setrmkeys} & \fx{\ltxkeyssetrmkeys}\\\hline +\end{tabularx} +\endgroup + +\start{example}[\ltxkeys] +\ltxkeys|'{ + \switchkeys|+[KV]{fam}[mp@]{keya,keyb}[true]{ + \if\@nameuse{mp@\ltxkeyscurrentkey} + \def\xx##1{##1*#1*##1} + \fi + }{% + \keyvalueerror + } + \declarekeys*[KV]{fam}[mp@]{ + bool/keyc/true/\def\x##1{##1\\#1\\##1}; + cmd/keyd/keyd-default/\def\currval{#1}; + }% + \\ + |com(Arbitrary code to be executed on its own:) + \def\x##1{x ##1 x} + \\ + \setkeys*[KV]{fam}[keyb,keyc]{keya=false,keyb,keyc=false,keyd=yy} + \setrmkeys|*[KV]{fam}[keyc] +} +\finish{example} + + \docsection(sec:weirdargs){Keys with argument patterns} @@ -2185,13 +2307,13 @@ The private namespace is optional but clashes of control sequences might occur: \ltxkeyscmdkeys \ltxkeysnewcmdkeys \ltxkeysstylekey \ltxkeysnewstylekey \ltxkeysstylekeys \ltxkeysnewstylekeys -\ltxkeysdeclarekeys (only when defining cmd keys) +\ltxkeysdefinekeys (only when defining cmd keys) \ltxkeysdeclarekeys (only when defining ord, cmd, sty keys) \finish{macro} \fxi*{\ltxkeysordkey,\ltxkeysnewordkey,\ltxkeysordkeys,\ltxkeysnewordkeys, \ltxkeyscmdkey,\ltxkeysnewcmdkey,\ltxkeyscmdkeys,\ltxkeysnewcmdkeys, \ltxkeysstylekey,\ltxkeysnewstylekey,\ltxkeysstylekeys,\ltxkeysnewstylekeys, -\ltxkeysdeclarekeys,\ltxkeysdeclarekeys} +\ltxkeysdefinekeys,\ltxkeysdeclarekeys} When using the \pkg'{xkeyval} it is indirectly possible to submit multiple arguments to a key's macro. Suppose we wish to set the text size, then we can define an ordinary key called \texttt{textsize} as follows: @@ -2226,7 +2348,7 @@ With the \pkg'{ltxkeys} this can be achieved directly as follows: The argument pattern for the key's macro should be specified within the key's callback as the argument of the undefined command \fx{\argpattern}. The token \argpat can be positioned anywhere within the key's callback, provided it isn't enclosed in curly braces. There is no need to delimit the last argument: an internal delimiter is used. -The same principles apply when using the macro \ffx'{\ltxkeysdeclarekeys}: simply put \argpat anywhere within the key's callback, but note that it doesn't apply in the case of boolean and choice keys. +The same principles apply when using the macros \ffx'{\ltxkeysdefinekeys, \ltxkeysdeclarekeys}: simply put \argpat anywhere within the key's callback, but note that it doesn't apply in the case of boolean and choice keys. \start+{example}[Key callback with multiple arguments] \ltxkeyscmdkey[KV]{fam}[mp@]{keya}[{default1 and default2}]{% @@ -2237,19 +2359,12 @@ The same principles apply when using the macro \ffx'{\ltxkeysdeclarekeys}: simpl \ltxkeysdeclarekeys[KV]{fam}[mp@]{% cmd/keya/{left/right}/|R(\argpattern){#1/#2}\def\xa##1{#1/##1/#2}; bool/keyb/true/\ifmp@keyb\def\xb##1{#1xx##1}\fi; - sty*/keyc/blue+green+black/|R(\argpattern){#1+#2+#3}\def\xc##1{#1==#2==#3}/ - |com(Dependant `keyd'. Choice key can't have weird arguments:) - choice>keyd.{% - left/.do=\def\y##1{#1 xx ##1}, - right/.do=\def\y##1{##1 yy #1}, - center/.do=\def\y##1{##1 zz #1} - }>left>\def\xd##1{##1xx#1}; ord/keye/{x y z w}/|R(\argpattern){#1 #2 #3 #4}\def\xe{#1 #2 #3 #4}; } \ltxkeyssetkeys[KV]{fam}{keya={value1/value2}, keyc={value1+value2+value3}} \finish{example} -Caution should be exercised when using \argpat for the dependant key of a style key in the case in which the value of the parent key is used as the default for the dependant key. The following gives an error because, although \ttx{keya} has two arguments, the macros \ffx'{\parentval, \KV@fam@keya@value} will not be expanded before the callbacks of \ttx{keyb,keyc} are called. Errors will be flagged when initializing (or setting without values) \ttx{keyb,keyc}. Remember that the \stform of \fx{\ltxkeysstylekeys} will define and initialize dependant keys on the fly. +Caution should be exercised when using \argpat for the observer key of a style key in the case in which the value of the parent key is used as the default for the observer key. The following gives an error because, although \ttx{keya} has two arguments, the macros \ffx'{\parentval, \KV@fam@keya@value} will not be expanded before the callbacks of \ttx{keyb,keyc} are called. Errors will be flagged when initializing (or setting without values) \ttx{keyb,keyc}. Remember that the \stform of \fx{\ltxkeysstylekeys} will define and initialize observer keys on the fly. \start+{example}[Style key callback with multiple arguments] \ltxkeysstylekeys|*[KV]{fam}[mp@]{keya}[{left right center}]|(% @@ -2309,31 +2424,31 @@ The commands \ffx'{\ltxkeyscheckinput,\ltxkeyscheckuserinput} apply to comma-sep \docsubsection(sec:ifinset){Does a test string exist in a string?} -\start+{newmacro}[\ltxkeys@in,\ltxkeysiffound] -\ltxkeys@in{|A(teststr)}{|A(str)} -\ltxkeys@in|*{|A(teststr)}{|A(str)}{|A(true)}{|A(false)} +\start+{newmacro}[\ltxkeysin,\ltxkeysiffound] +\ltxkeysin{|A(teststr)}{|A(str)} +\ltxkeysin|*{|A(teststr)}{|A(str)}{|A(true)}{|A(false)} \ltxkeysiffound|A(teststr)|R(\in)|A(str)|R(\then) |A(true) \else |A(false) \fi \finish{newmacro} -\fxim*{\ltxkeys@in,\ltxkeysiffound} +\fxim*{\ltxkeysin,\ltxkeysiffound} -The \unstform of the command \fx{\ltxkeys@in} is identical with \usecsn{latex2e} kernel's (2011/06/27) \hx{\in@}. The command \hx{\in@} tests for the presence of \ang{teststr} in \ang{str} and returns the boolean \hx{\ifin@} as \hx{\iftrue} or \hx{\iffalse}. The \stform of \fx{\ltxkeys@in} returns two \latex branches \ang{true} and \ang{false}. On the other hand, the command \fx{\ltxkeysiffound} requires the first argument to be delimited by \fx{\in} and the second argument by \fx{\then}. +The \unstform of the command \fx{\ltxkeysin} is identical with \usecsn{latex2e} kernel's (2011/06/27) \hx{\in@}. The command \hx{\in@} tests for the presence of \ang{teststr} in \ang{str} and returns the boolean \hx{\ifin@} as \hx{\iftrue} or \hx{\iffalse}. The \stform of \fx{\ltxkeysin} returns two \latex branches \ang{true} and \ang{false}. On the other hand, the command \fx{\ltxkeysiffound} requires the first argument to be delimited by \fx{\in} and the second argument by \fx{\then}. \start{example}[\ltxkeysiffound] \ltxkeysiffound xx\in aax\then \def\x{T}\else \def\x{F}\fi \finish{example} \ltsnote -The command \fx{\ltxkeysiffound} trims leading and trailing spaces around the tokens \ang{teststr} and \ang{str} before the test! The commands \ffx'{\ltxkeys@in,\ltxkeysiffound} aren't expandable. +The command \fx{\ltxkeysiffound} trims leading and trailing spaces around the tokens \ang{teststr} and \ang{str} before the test! The commands \ffx'{\ltxkeysin,\ltxkeysiffound} aren't expandable. \docsubsection(sec:ifpattern){Does a given pattern exist in the meaning of a macro?} -\start{newmacro}[\ltxkeysifpatternTF] -\ltxkeysifpatternTF{|A(teststr)}|A(cmd){|A(true)}{|A(false)} +\start{newmacro}[\ltxkeysifpattern] +\ltxkeysifpattern{|A(teststr)}|A(cmd){|A(true)}{|A(false)} \finish{newmacro} -\fxim*{\ltxkeysifpatternTF} +\fxim*{\ltxkeysifpattern} -The command \fx{\ltxkeysifpatternTF} simply determines if the meaning of \ang{cmd} contains \ang{teststr}. It returns \ang{true} if \ang{teststr} is found in the meaning of \ang{cmd}, and \ang{false} otherwise. +The command \fx{\ltxkeysifpattern} simply determines if the meaning of \ang{cmd} contains \ang{teststr}. It returns \ang{true} if \ang{teststr} is found in the meaning of \ang{cmd}, and \ang{false} otherwise. \docsubsection(sec:ltxkeysifcase) @@ -2476,52 +2591,38 @@ These commands will normalize the comma-separated \ang{list} (or \ang{list-i}) a \docsubsection(sec:listparse){Parsing arbitrary csv or kv list} -% Edit ++++++++++++++++++++++++++++++ - -\start{newmacro}[\ltxkeysdolist] -\ltxkeysdolist|A(flag)[|A(parser)]{|A(list)} -\ltxkeysdolist|*|A(flag)[|A(parser)]{|A(listcmd)} +\start{newmacro}[\ltxkeysdocsvlist,\ltxkeysdokvlist, etc.] +\ltxkeysdocsvlist[|A(parser)]{|A(list)} +\ltxkeysdocsvlist|*[|A(parser)]{|A(listcmd)} +\ltxkeysparsecsvlist[|A(parser)]{|A(list)} +\ltxkeysparsecsvlist|*[|A(parser)]{|A(listcmd)} +\ltxkeysdokvlist[|A(parser)]{|A(list)} +\ltxkeysdokvlist|*[|A(parser)]{|A(listcmd)} +\ltxkeysparsekvlist[|A(parser)]{|A(list)} +\ltxkeysparsekvlist|*[|A(parser)]{|A(listcmd)} \finish{newmacro} -\fxim*{\ltxkeysdolist} +\fxim*{\ltxkeysdocsvlist,\ltxkeysparsecsvlist,\ltxkeysdokvlist,\ltxkeysparsekvlist} -The unexpandable command \fx{\ltxkeysdolist} is the list processor for the \pkg'{ltxkeys}. It can process both arbitrary \ang{parser}-separated lists and \keyval pairs. It can also be nested to any level, and it keeps each nesting-level independent. The default value of the optional list-item separators \ang{parser} is \qcomma. The list normalizer for \fx{\ltxkeysdolist} is \pkg'{ltxtools}'s \fx{\csv@@normalize}, which can deal with arbitrary list parsers/separators. The \ang{flag}, which must lie in the range $(0,3)$, determines the type of processing that is required. The admissible values of \ang{flag} and their meaning are given in \sref{tab:parser-flags}. The macro \fx{\ltxkeysdolist} loops over the given \ang{parser}-separated \ang{list} and execute the user-defined, one-parameter command \fx{\ltxkeysdo} for every item in the list, passing the item as an argument and preserving outer braces. The default value of \ang{parser} is \qcomma. The \stform of \fx{\ltxkeysdolist} will expand \ang{listcmd} once before commencing the loop. - -\begingroup -\small -\begin{tabularx}{\linewidth}{|p{1cm}|X|} -\caption{Flags for command \ltsprotectedtokens{\fx{\ltxkeysdolist}} - \label{tab:parser-flags}}\\\hline -\rowcolor{pink} -\bfseries Flag &\bfseries Meaning\\\hline -\endfirsthead -\hline -\multicolumn{2}{|l|}{\emph{Continued from last page}}\\\hline -\bfseries Flag &\bfseries Meaning\\\hline -\endhead -\multicolumn{2}{|r|}{\emph{Continued on next page}}\\\hline -\endfoot -\hline -\endlastfoot -$0$ & \ang{list} is assumed to be an ordinary list (\ie, not a list of \keyval pairs); it isn't normalized by \fx{\ltxkeysdolist} prior to parsing. \\\hline -$1$ & \ang{list} is assumed to be an ordinary list (\ie, not a list of \keyval pairs); it is normalized by \fx{\ltxkeysdolist} prior to parsing. \\\hline -$2$ & \ang{list} is assumed to be a list of \keyval pairs; it isn't normalized by the command \fx{\ltxkeysdolist} prior to parsing. \\\hline -$3$ & \ang{list} is assumed to be a list of \keyval pairs; it is normalized by \fx{\ltxkeysdolist} prior to parsing. -\end{tabularx} -\endgroup +The unexpandable command \fx{\ltxkeysdocsvlist} is the list processor for the \pkg'{ltxkeys}. It can process both arbitrary \ang{parser}-separated lists and \keyval pairs. It can also be nested to any level, and it keeps each nesting-level independent. The default value of the optional list-item separators \ang{parser} is \qcomma. The list normalizer for \fx{\ltxkeysdocsvlist} is \pkg'{ltxtools}'s \fx{\csv@@normalize}, which can deal with arbitrary list parsers/separators. The \ang{flag}, which must lie in the range $(0,3)$, determines the type of processing that is required. The admissible values of \ang{flag} and their meaning are given in \sref{tab:parser-flags}. The macro \fx{\ltxkeysdocsvlist} loops over the given \ang{parser}-separated \ang{list} and execute the user-defined, one-parameter command \fx{\ltxkeysdo} for every item in the list, passing the item as an argument and preserving outer braces. The default value of \ang{parser} is \qcomma. The \stform of \fx{\ltxkeysdocsvlist} will expand \ang{listcmd} once before commencing the loop. -Here are some points to note about the list processor \fx{\ltxkeysdolist}: +Here are some points to note about the list processor \fx{\ltxkeysdocsvlist}: \begin{enum} -\item If an item contains \ang{parser}, it must be wrapped in curly braces when calling the command \fx{\ltxkeysdolist}, otherwise the elements may be mixed up during parsing. The braces will persist thereafter, but will of course be removed during printing (if the items are printed). -\item White spaces before and after the list separator are always ignored by the normalizer called by \fx{\ltxkeysdolist}. If an item contains \ang{parser} or starts with a space, it must, therefore, be wrapped in curly braces before calling \fx{\ltxkeysdolist}. -\item Since when \ang{flag} is $0$ or $2$ the command \fx{\ltxkeysdolist} doesn't call the normalizer, in this case it does preserve outer/surrounding spaces in the entries. Empty entries in \ang{list} or \ang{listcmd} will be processed by \fx{\ltxkeysdolist} if the boolean \fx{\ifltxkeys@useempty} is true. You may thus issue \fx{\ltxkeys@useemptytrue} before calling \fx{\ltxkeysdolist}. The ability to parse empty entries is required by packages that use empty key prefixes, and/or families\footnote{The use of empty key prefixes, families and paths is, in general, not advisable.}. \fx{\ifltxkeys@useempty} is false by default, and its state is nesting-level dependant. -\item The command \fx{\ltxkeysdolist} can be nested to any level and can be mixed with other looping macros. -\item In the command \fx{\ltxkeysdolist}, it is always possible to break out of the loop prematurely at any level of nesting, simply by issuing the command \fx{\ltxkeysbreakloop}, which toggles the boolean \fx{\ifltxkeys@breakloop}\footnote{The command \fx{\ltxkeysbreakloop} may be called within the loop to terminate the loop prematurely. The unprocessed items of the list will be handled by the command \fx{\ltxkeysdoremainder}, which can be redefined by the user. By default, it is defined as the \latex kernel's \hx{\@gobble}, meaning that it simply throws away the list remainder. The command \fx{\ltxkeysbreaklist} may also be inserted as a list item to break out of the loop prematurely. The commands \ffx'{\ltxkeysbreakloop, \ltxkeysbreaklist} have different syntax and semantics.}. Breaking an inner loop doesn't affect the continuation of the outer loop, and vice versa: loop break is nesting-level dependant. +\item If an item contains \ang{parser}, it must be wrapped in curly braces when calling the command \fx{\ltxkeysdocsvlist}, otherwise the elements may be mixed up during parsing. The braces will persist thereafter, but will of course be removed during printing (if the items are printed). +\item White spaces before and after the list separator are always ignored by the normalizer called by \fx{\ltxkeysdocsvlist}. If an item contains \ang{parser} or starts with a space, it must, therefore, be wrapped in curly braces before calling \fx{\ltxkeysdocsvlist}. +\item Since when \ang{flag} is $0$ or $2$ the command \fx{\ltxkeysdocsvlist} doesn't call the normalizer, in this case it does preserve outer/surrounding spaces in the entries. Empty entries in \ang{list} or \ang{listcmd} will be processed by \fx{\ltxkeysdocsvlist} if the boolean \fx{\ifltxkeysuseempty} is true. You may thus issue \fx{\ltxkeysuseemptytrue} before calling \fx{\ltxkeysdocsvlist}. The ability to parse empty entries is required by packages that use empty key prefixes, and/or families\footnote{The use of empty key prefixes, families and paths is, in general, not advisable.}. \fx{\ifltxkeysuseempty} is false by default, and its state is nesting-level observer. +\item The command \fx{\ltxkeysdocsvlist} can be nested to any level and can be mixed with other looping macros. +\item In the command \fx{\ltxkeysdocsvlist}, it is always possible to break out of the loop prematurely at any level of nesting, simply by issuing the command \fx{\ltxkeysbreakloop}\footnote{The command \fx{\ltxkeysbreakloop} may be called within the loop to terminate the loop prematurely. The unprocessed items of the list will be handled by the command \fx{\ltxkeysdoremainder}, which can be redefined by the user. By default, it is defined as the \latex kernel's \hx{\@gobble}, meaning that it simply throws away the list remainder. The command \fx{\ltxkeyslistbreak} may also be inserted as a list item to break out of the loop prematurely. The commands \ffx'{\ltxkeysbreakloop, \ltxkeyslistbreak} have different syntax and semantics.}. Breaking an inner loop doesn't affect the continuation of the outer loop, and vice versa: loop break is nesting-level observer. \item The argument of the one-parameter command \fx{\ltxkeysdo} can be passed to a multi-parameter command, or to a command that expects delimited arguments. \end{enum} -\docsubsection(sec:dosisolist){Parsing arbitrary tsv or nsv lists} +\docsubsection(sec:sisolist){Parsing nsv/tsv list} +\start{newmacro}[\ltxkeysdosisolist] +\ltxkeysdosisolist[|A(parser)]{|A(list)} +\ltxkeysdosisolist|*[|A(parser)]{|A(listcmd)} +\finish{newmacro} +\fxim*{\ltxkeysdosisolist} @@ -2574,83 +2675,35 @@ where \ang{old-i} is the element to be replaced and \ang{new-i} is its replaceme The list and key parsers of the \pkg'{ltxkeys} preserve outer braces, but sometimes it is needed to rid a token of one or more of its outer braces. This can be achieved by the following commands: -\start+{newmacro}[\ltxkeysstripouterbraces, \ltxkeysstripallouterbraces, etc.] -\ltxkeysstripouterbraces|A(nr){|A(token)} +\start+{newmacro}[\ltxkeysstripNouterbraces, \ltxkeysstripallouterbraces, etc.] +\ltxkeysstripNouterbraces|A(nr){|A(token)} \ltxkeysstripallouterbraces{|A(token)} \ltxkeysstripallouterbracesincs{|A(cmd)} \finish{newmacro} -\fxim*{\ltxkeysstripouterbraces, +\fxim*{\ltxkeysstripNouterbraces, \ltxkeysstripallouterbraces,\ltxkeysstripallouterbracesincs} -The command \fx{\ltxkeysstripouterbraces} strips \ang{nr} number of outer braces from \ang{token}. The command \fx{\ltxkeysstripallouterbraces} strips all outer braces from \ang{token}. The command \fx{\ltxkeysstripallouterbracesincs} strips all the outer braces in the top content of the command \ang{cmd}. All these commands are expandable. Normally, \ang{token} wouldn't be expanded by these commands in the process of stripping off outer braces. +The command \fx{\ltxkeysstripNouterbraces} strips \ang{nr} number of outer braces from \ang{token}. The command \fx{\ltxkeysstripallouterbraces} strips all outer braces from \ang{token}. The command \fx{\ltxkeysstripallouterbracesincs} strips all the outer braces in the top content of the command \ang{cmd}. All these commands are expandable. Normally, \ang{token} wouldn't be expanded by these commands in the process of stripping off outer braces. -\start+{example}[\ltxkeysstripouterbraces,\ltxkeysstripallouterbraces, etc.] +\start+{example}[\ltxkeysstripNouterbraces,\ltxkeysstripallouterbraces, etc.] \toks@\expandafter\expandafter\expandafter - {\ltxkeysstripouterbraces{2}{{{\y}}}} + {\ltxkeysstripNouterbraces{2}{{{\y}}}} \edef\x{\unexpanded\expandafter\expandafter\expandafter - {\ltxkeysstripouterbraces\@m{{{\y}}}}} + {\ltxkeysstripNouterbraces\@m{{{\y}}}}} \edef\x{\ltxkeysstripallouterbraces{{{{\y}}}}} \finish{example} -\docsection(sec:add-patch-callback){Adding to and patching key macros} - -\subdocsection(sec:adtocallback){Adding to key macros} -% \ltxkeysadtocallback, \ltxkeysappendtocallback, \ltxkeysprependtocallback - - -\subdocsection(sec:patchcallback){Patching key macros} -% \ltxkeyspatchcallback, \ltxkeysgpatchcallback - -Sometimes you may want to modify the macro of an existing key. For some reasons, redefining the key may not be the best option, besides being uneconomical. - -The following \fx{\ltxkeyspatchcallback} command and use syntax can be utilized to patch/modify existing key macros. In rare circumstances one may wish to modify an subsisting key macro, especially one defined in an existing package, without redefining the key afresh. Key macros are intrinsically parameterized functions and \latex kernel's \fx{\g@addto@macro} can't be used to patch parameterized functions. - -\start{newmacro}[\ltxkeyspatchcallback] -\ltxkeyspatchcallback|*|![|nang(keyprefixes)]{|nang(families)}{ - |nang(key-1) {|nang(search-1)} {|nang(replace-1)} ; - |nang(key-2) {|nang(search-2)} {|nang(replace-2)} ; - ... - |nang(key-n) {|nang(search-n)} {|nang(replace-n)} -}{% - |nang(fallback-s) -}{% - |nang(fallback-f) -} -\finish{newmacro} -\fxim*{\ltxkeyspatchcallback} - -Here, \ang{keyprefixes} and \ang{families} are comma-separated lists of key prefixes and families; \ang{key-1} to \ang{key-n} are key names; \ang{search-1} to \ang{search-n} are the search patterns, and the quantities \ang{replace-1} to \ang{replace-n} the corresponding replacement texts. \ang{fallback-s} and \ang{fallback-f} are the actions that should be taken if the patching succeeds or fails for any of the existing keys. \fx{\ltxkeyspatchcallback} loops over the given key prefixes and families to find the listed keys. If a key can't be located (in terms of being previously defined), it is ignored and a warning message is logged (if the package option \fx{verbose} is enabled). Within the \ang{fallback-s} and \ang{fallback-f} blocks, you can use \fx{\ltxkeyscurrentkey}, \fx{\ltxkeyscurrentfamily}, and \fx{\ltxkeyscurrentprefix} to refer to the current key name, family and prefix (see example below). The \clsign instructs \fx{\ltxkeyspatchcallback} to globalize the outcome; the \stsign is explained below. +\docsection(sec:addkeycode){Adding to key macros} -Also, within the search-and-replace block you can use \fx{#1} to refer to the parameter of the key macro, which ordinarily corresponds to the value of the current key. There is no need to double the parameter character. But if you're introducing a new parameterized command within this block, you would need to double the parameter character. -White spaces between the key name and the search pattern are ignored within the block of key names and search and replacement patterns. You can insert \fx{\ltxkeysbreaklist} within this block to prematurely break out of the loop. The remaining elements of the list will be saved in \fx{\ListRemainder} (see \cref{sec:list-process}). - -The default list parser in \fx{\ltxkeyspatchcallback} is the semicolon (\fx{;}). This can be changed by using \fx{\ltxkeysdeclarekeypatchparser}, which takes only one argument (the list parser). - -\start{example}[\ltxkeyspatchcallback] -\ltxkeysordkey[KV]{fam}{keya}[value]{\def\x##1{x##1x}} -\ltxkeysboolkey[KX]{fax}[mp@]{keyb}[true]{\def\y{#1}} - -\ltxkeyspatchcallback|*|![KV,KX]{fam,fax}{% - keya {\def\x##1{x##1x}} {\def\X##1{XX##1XX}}, - keyb {\def\y{y#1y}} {\def\Y{YY#1YY}} -}{% - \wlog{Patching of `\ltxkeyscurrentkeymacro' succeeded}% -}{% - \wlog{Patching of `\ltxkeyscurrentkeymacro' failed}% -} -\show\KV@fam@keya -\finish{example} - -% \ltxkeyspatchcmd \docsection(sec:todo){To-do list} This section details additional package features that may become available in the foreseeable future. User views are being solicited in regard of the following proposals. -\docsubsection(sec:changedependantkeys) - {Modifying the dependant keys of an existing style key} + +\docsubsection(sec:changeobserverkeys){Modifying the observer keys of an existing style key} \start+{newmacro}[\ltxkeysadddepkeys,etc] \ltxkeysadddepkeys[|A(pref)]{|A(fam)}{|A(paren)}{|A(deps)} @@ -2659,7 +2712,7 @@ This section details additional package features that may become available in th \finish{newmacro} \fxim*{\ltxkeysadddepkeys,\ltxkeysremovedepkeys,\ltxkeysreplacedepkeys} -Here, \ang{paren} is the parent key of dependants keys; \ang{deps} is the full specification of new or existing dependant keys (as in \sref{sec:stylekeys}), with their default values and callbacks; \ang{olddeps} are the old dependants to replace with \ang{newdeps}. This would require patching macros of the form \jpreffamkey{dependants}, which might have nested parametered-commands. +Here, \ang{paren} is the parent key of observers keys; \ang{deps} is the full specification of new or existing observer keys (as in \sref{sec:stylekeys}), with their default values and callbacks; \ang{olddeps} are the old observers to replace with \ang{newdeps}. This would require patching macros of the form \jpreffamkey{observers}, which might have nested parametered-commands. @@ -2673,18 +2726,21 @@ Introduce toggle keys. The package already contains switch keys (\sref{sec:switc The following change history highlights significant changes that affect user utilities and interfaces; changes of technical nature are not documented in this section. The \stsign on the right-hand side of the following lists means the subject features in the package but is not reflected anywhere in this user guide. \begin{versionhist} + \begin{version}{0.0.3c}{2012/11/17} + \item \fx{\ltxkeys@liskeys} changed to \fx{\ltxkeys@listkeys}\vsecref{sec:listkeys} + \end{version} \begin{version}{0.0.3a-b}{2012/10/14} - \item Command name changes from \pkg'{catoptions} package. + \item Miscellaneous bug fixes\vsecref* \end{version} - \begin{version}{0.0.2}{2011/08/22} - \item Automatically call \fx{\ltxkeyscheckbool} when setting boolean keys \vsecref{sec:utilities} - \item Raise error for keys that have no user input and no default value \vsecref{sec:examples} + \begin{version}{0.0.3}{2011/12/17} + \item More flags (\ffx{preset, postset, setrm}, \eetc) have been introduced for pathkeys \vsecref{sec:pathkeys} \end{version} - \begin{version}{0.0.1a}{2011/08/14} - \item Completed the user guide\vsecref* + \begin{version}{0.0.2}{2011/09/01} + \item Pathkeys introduced\vsecref{sec:pathkeys} + \item User guide completed.\vsecref* \end{version} - \begin{version}{0.0.1}{2011/08/13} - \item First public release\vsecref* + \begin{version}{0.0.1}{2011/07/30} + \item First public release.\vsecref* \end{version} \end{versionhist} @@ -2695,7 +2751,3 @@ The following change history highlights significant changes that affect user uti \printindex \end{document} - - - -Normally, the command \fx{\patchcmd} of \cref{sec:cmd-patch} (and hence \fx{\ltxkeyspatchcallback}) doesn't allow nested commands, and hence no doubling of the parameter character in the replacement text. If you want to nest commands or double the parameter character in the replacement text, you need to use the \stform of \fx{\patchcmd} or \fx{\ltxkeyspatchcallback} (see example below).
\ No newline at end of file diff --git a/Master/texmf-dist/doc/latex/ltxkeys/ltxkeys-test-20121122.tex b/Master/texmf-dist/doc/latex/ltxkeys/ltxkeys-test-20121122.tex new file mode 100644 index 00000000000..725126ab120 --- /dev/null +++ b/Master/texmf-dist/doc/latex/ltxkeys/ltxkeys-test-20121122.tex @@ -0,0 +1,61 @@ +\documentclass{article} +\usepackage{xcolor} +\usepackage{ltxkeys} +\makeatletter +\def\somemethod#1#2{% + \begingroup + \color{#1}% + \ifltxkeys@novalue + \ifnum\ltxkeys@listcount=\@ne + \endgraf + Using default value of `\ltxkeys@tkey': + \fi + \else + \ifnum\ltxkeys@listcount=\@ne + \endgraf + Using user value of `\ltxkeys@tkey': + \fi + \fi + \endgroup + \endgraf + Processing item no. \ltxkeys@listcount: #2% +} +% Use comma (,), the default list separator, as the list separator +% for keya and keyb: +\ltxkeys@listkey[KV]{fam}{keya,keyb}[default1,default2]{% + \somemethod{blue}{#1}% + % Process only four (4) items of the list/value for keya and keyb: + \ifnum\ltxkeys@listcount=4\relax + \stopprocessinglistkey + \fi +} + +% Use semicolon (;) as the list separator for keyc and keyd: +\ltxkeys@listkey[KV]{fam}{keyc,keyd}[default1;default2]{% + \listsep{;}\somemethod{red}{#1}% +} + +\makeatother + +\begin{document} +\parindent0pt +% No values for keya and keyb; use their default values: +\ltxkeysusekeys[KV]{fam}{keya,keyb} + +\par\bigskip +\ltxkeysusekeys[KV]{fam}{% + keya={item1A,item1B,item1C,item1D,item1E,item1F}, + keyb={item2A,item2B,item2C,item2D,item2E,item2F} +} + +\par\bigskip +% Set keyc and keyd with their default values: +\ltxkeysusekeys[KV]{fam}{keyc,keyd} + +\par\bigskip +\ltxkeysusekeys[KV]{fam}{% + keyc={item1A;item1B;item1C;item1D}, + keyd={item2A;item2B;item2C;item2D} +} +\end{document} + diff --git a/Master/texmf-dist/tex/latex/ltxkeys/ltxkeys.sty b/Master/texmf-dist/tex/latex/ltxkeys/ltxkeys.sty index 4a1efbd718e..8109dd19a35 100644 --- a/Master/texmf-dist/tex/latex/ltxkeys/ltxkeys.sty +++ b/Master/texmf-dist/tex/latex/ltxkeys/ltxkeys.sty @@ -1,5 +1,5 @@ %++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% -% This is file 'ltxkeys.sty', version 0.0.3b, October 14, 2012. % +% This is file 'ltxkeys.sty', version 0.0.3c, 2012/11/17. % % % % This package and accompanying files may be distributed and/or % % modified under the conditions of the LaTeX Project Public License, % @@ -21,7 +21,7 @@ \@ifpackageloaded{catoptions}{% \@ifpackagelater{catoptions}{2012/10/14}{}{% \@latex@error{Loaded version of catoptions package is - not current}\@ehc + not current}\@ehd }% }{% \RequirePackage{catoptions}[2012/10/14]% @@ -29,24 +29,24 @@ \UseNormalCatcodes \StyleFilePurpose{A robust key-value parser (AM)} \StyleFileRCSInfo -$Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ +$Id: ltxkeys.sty,v 0.0.3c 2012/11/17 09:00:00 Ahmed Musa Exp $ \ProvidesPackage{ltxkeys}[\StyleFileInfo] \NeedsTeXFormat{LaTeX2e}[2011/06/27] \SetStyleFileMessages[ltxkeys@]{info}{warn}{err} \cpt@setupsafeactivesedef -\catcode`\&=3 -\new@def\ltxkeys@afterfi#1\ltxkeys@fi{\fi#1} -\new@def\ltxkeys@after@i#1\ltxkeys@else#2\ltxkeys@fi{\fi#1} -\new@def\ltxkeys@after@ii#1\ltxkeys@else#2\ltxkeys@fi{\fi#2} -\newletcs\ltxkeys@else\else -\newletcs\ltxkeys@fi\fi -\new@def*\ltxkeys@ehc{% +\catcode`\&=3\relax +\new@def\ltxkeys@afterfi#1\fi{\fi#1} +\new@def\ltxkeys@afterelsei#1\else#2\fi{\fi#1} +\new@def\ltxkeys@afterelseii#1\else#2\fi{\fi#2} +\new@def*\ltxkeys@ehd{% \ifx\protect\string\ltxkeys@afterfi A serious error has occurred.\MsgBrk Try typing <return>\space to proceed.\MsgBrk If that fails, type X and then <return>\space to quit. - \ltxkeys@fi + \fi } +\new@def*\ltxkeys@truetoks{true} +\new@def*\ltxkeys@falsetoks{false} \robust@def*\ltxkeys@specialhandler{% \cpt@testopt\ltxkeys@sp@cialhandler{}% } @@ -61,7 +61,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \new@def*\ltxkeys@quark{\@gobble\ltxkeys@quark} \new@def*\ltxkeys@antiquark{\@gobble\ltxkeys@antiquark} \new@def*\ltxkeys@cdr#1#2\ltxkeys@nil{#2} -\new@def*\ltxkeys@spcdr#1#2\ltxkeys@nil{\detokenize{#2}} +\new@def*\ltxkeys@spcdr#1#2#3\ltxkeys@nil{\detokenize{#2}} \new@def\ltxkeys@ifxFT#1#2{\ltxkeys@ifxTF{#1}{#2}\cptiiofii\cptiofii} \new@def\ltxkeys@ifxTF#1#2{% \expandafter\cptswap\cpt@car#1\ltxkeys@quark\car@nil @@ -87,7 +87,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \robust@def*\ltxkeys@d@bug#1#2{% \wlog{\ifcpt@st^^J\fi ltxkeys debug [#1] #2.}% } -\cptnewvariables{if}[ltxkeys@]{break,st,pl,cl,sw,sv,nv,noval,pxop,exop, +\cptnewvariables{if}[ltxkeys@]{break,st,pl,cl,sw,sv,nv,novalue,pxop,exop, preset,disable,ini,kf,rm,ssk,dec,dep,twk,tracingkeys,useempty,chdef, swa,reservenopath,global,protected,inkeycmd}[false] \cptnewvariables{if}{inputvalid}[false] @@ -153,6 +153,14 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ }% }% } +\robust@def*\ltxkeys@striplaststar#1*\@empty#2\ltxkeys@nil#3{\edef#3{#1}} +\robust@def*\ltxkeys@ifrejname#1{% + \ifcase0\ifx\key@type\ltxkeys@rej1\else + \ifx\key@name\ltxkeys@rej1\fi\fi\relax + \else + #1% + \fi +} \robust@def*\ltxkeys@testst#1{% \cpt@ifstar{\ltxkeys@sttrue#1}{\ltxkeys@stfalse#1}% } @@ -175,27 +183,28 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ } \robust@def\ltxkeys@trimspaces#1#2{% \begingroup - \ifcase\if.\ltxkeys@spcdr#2.0\ltxkeys@nil\else1\fi - \if\expandafter\cpt@car\string#2\car@nil - \@backslashchar0\else1\fi\relax\else - \ltxkeys@err{'\detokenize{#2}' has illegal form}\ltxkeys@ehc + \ifcase0% + % 1. When #2 of \ltxkeys@trimspaces is empty token, #1, #2, #3 of + % \ltxkeys@spcdr will be '.', 'x', <empty>. + % 2. No one will give #2 of \ltxkeys@trimspaces as a dot (.). So + % the test is fairly robust. + \if.\ltxkeys@spcdr#2.x\ltxkeys@nil\else1\fi + \if\expandafter\cpt@car\string#2\car@nil\@backslashchar\else1\fi\relax + \else + \ltxkeys@err{'\detokenize{#2}' has illegal form}\ltxkeys@ehd \fi \ltxkeys@tr@mspaces{#1}{#2}% } -\long\def\ltxkeys@tr@mspaces#1#2{% - \edef\trimmed{% - \expandcsonce{\romannumeral-`\q\ltxkeys@trimspace.#1& &}% - }% - \ltxkeys@ifxTF#2\trimmed{% +\robust@def\ltxkeys@tr@mspaces#1#2{% + \edef\ltxkeys@trimmed{\cpttrimspace{#1}}% + \ltxkeys@ifxTF#2\ltxkeys@trimmed{% \expandafter\endgroup\expandafter\edef\expandafter #2\expandafter{\expandafter\unexpanded\expandafter{#2}}% }{% - \let#2=\trimmed + \let#2=\ltxkeys@trimmed \expandafter\ltxkeys@tr@mspaces\expandafter{#2}#2% }% } -\long\def\ltxkeys@trimspace#1 &{\ltxkeys@tr@mspace#1&} -\long\def\ltxkeys@tr@mspace#1{\expandafter\noexpand\@gobble#1} \robust@def*\ltxkeys@trimspacesset#1{% \def\@do##1##2,{% \ifnot@nil{##1}{\ltxkeys@trimspaces{##1}##2\@do}% @@ -225,7 +234,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \def\ltxkeys@splita##1/##2/{% \ltxkeys@trimspacesset{{##1}\key@type,{##2}\key@name}% \ltxkeys@ifrejname{% - \ltxkeys@err{Wrong syntax for attributes of a key}\ltxkeys@ehc + \ltxkeys@err{Wrong syntax for attributes of a key}\ltxkeys@ehd }% \ltxkeys@splitb.% }% @@ -234,8 +243,8 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \ltxkeys@splitc.% }% \def\ltxkeys@splitc##1/{% - \edef\key@macro{\unexpanded\expandafter{\@gobble##1}}% - \ltxkeys@stripdotcode\key@macro + \edef\key@callback{\unexpanded\expandafter{\@gobble##1}}% + \ltxkeys@stripdotcode\key@callback \ltxkeys@splitd.% }% \def\ltxkeys@splitd##1/##2\ltxkeys@nil{% @@ -244,7 +253,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \ltxkeys@splita#1/^?^/^?^/^?^/^?^/^?^/\ltxkeys@nil \let\do\cpt@csexit \cptexpanded{\endgroup - \do\key@type\do\key@name\do\key@default\do\key@macro + \do\key@type\do\key@name\do\key@default\do\key@callback \do\key@dependants }% } @@ -303,7 +312,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \ifdefboolTF{cpt@choicefd} {\noexpand\@secondoftwo}{\noexpand\@firstoftwo}% \else - \ltxkeys@err{Invalid number '#1'}\ltxkeys@ehc + \ltxkeys@err{Invalid number '#1'}\ltxkeys@ehd \fi }% } @@ -375,7 +384,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ }% \advance\@tempcnta\@ne }% - \ltxkeys@parse*1[;]\ltxkeys@tempa + \ltxkeys@listparse*1[;]\ltxkeys@tempa \endtoksgroup } \robust@def*\ltxkeys@ifeltcountTF{\cpt@teststopt\ltxkeys@ifeltcount,} @@ -389,7 +398,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \def\ltxkeys@do##1{% \cptpushnumber\eltnum }% - \expandafter\ltxkeys@parse\reserved@a1[#1]{#4}% + \expandafter\ltxkeys@listparse\reserved@a1[#1]{#4}% \aftercsname\endgroup{@\ifnum\eltnum#2\numexpr#3% first\else second\fi oftwo}% } @@ -430,25 +439,25 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ }% }% } -\provide@def\all@to@endif#1\endif{#1} -\provide@def\first@to@endif#1#2\endif{#1} +\new@def\ltxkeys@alltoendif#1\endif{#1} +\new@def\ltxkeys@firsttoendif#1#2\endif{#1} \new@def*\ltxkeys@ifcassenumcmpTF#1#2#3{% \ifdim#1pt#2pt % \expandafter\cptiofii\else\expandafter\cptiiofii\fi } \new@def\ltxkeys@ifcasse#1{% \ifstrcmpTF{#1}\elseif{% - \all@to@endif + \ltxkeys@alltoendif }{% \ifstrcmpTF{#1}\endif{}{\ltxkeys@ifcasse@a{#1}}% }% } \new@def\ltxkeys@ifcasse@a#1#2{% \ifstrcmpTF{#2}\elseif{% - \all@to@endif + \ltxkeys@alltoendif }{% \ifstrcmpTF{#2}\endif{}{% - \ltxkeystestcmd{#1}{#2}\first@to@endif{\ltxkeys@ifcasse@b{#1}}% + \ltxkeystestcmd{#1}{#2}\ltxkeys@firsttoendif{\ltxkeys@ifcasse@b{#1}}% }% }% } @@ -493,7 +502,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ }% \s@expandarg\ltxkeys@remove@b#3% }% - \ltxkeys@parse1[##1]{#4}% + \ltxkeys@listparse1[##1]{#4}% \csv@@normalize*[##1]#3% }% \s@expandarg\ltxkeys@remove@a{\detk{#1}}% @@ -643,7 +652,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \cptpushnumber#2% }% }% - \cptexpandsecond{\ltxkeys@parse0}{[\ltxkeys@ccparser]}{#4}% + \cptexpandsecond{\ltxkeys@listparse0}{[\ltxkeys@ccparser]}{#4}% \cptpassexpanded{% \endgroup \cpt@csexit\ltxkeys@userinput @@ -665,7 +674,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ } \robust@def*\ltxkeys@nomatcherr{% \ltxkeys@error{User input '\ltxkeys@userinput' not in list - of nominations ||\ltxkeys@nominations||}\ltxkeys@ehc + of nominations ||\ltxkeys@nominations||}\ltxkeys@ehd } \robust@def*\ltxkeys@ifoneincsvlist{\cpt@teststopt\ltxkeys@ifoneincsvl@st,} \robust@def*\ltxkeys@ifoneincsvl@st[#1]#2#3{% @@ -709,7 +718,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ }% \ifnum\cpt@cnta>\numexpr#2-1\relax\loopbreak\fi }% - \ltxkeys@parse*1[#1]\ltxkeys@tempa + \ltxkeys@listparse*1[#1]\ltxkeys@tempa \ifnum\cpt@cnta>\numexpr#2-1\relax \edef\ltxkeys@nritems{\the\cpt@cnta}% \else @@ -795,7 +804,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ }{}% \ifnum\cpt@cnta>\numexpr#1-1\relax\loopbreak\fi }% - \ltxkeys@parse*1\ltxkeys@tempa + \ltxkeys@listparse*1\ltxkeys@tempa \ifnum\cpt@cnta>\numexpr#1-1\relax \edef\ltxkeys@nritems{\the\cpt@cnta}% \else @@ -816,9 +825,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ only in style files.}% }% } -\robust@def*\ltxkeys@commanormalize#1#2{% - \edef#2{\cptcommanormalize{#1}}% -} +\robust@def*\ltxkeys@commanormalize#1#2{\edef#2{\cptcommanormalize{#1}}} \robust@def*\ltxkeys@commanormalizeset{% \let\normelt\ltxkeys@commanormalize \ltxkeys@normalizeset @@ -839,9 +846,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \expandafter\@do\reserved@a,\@nil,% \undefcs\normelt } -\robust@def*\ltxkeys@normalizecsset{% - \cpt@testopt\ltxkeys@n@rmalizecsset,% -} +\robust@def*\ltxkeys@normalizecsset{\cpt@testopt\ltxkeys@n@rmalizecsset,} \robust@def*\ltxkeys@n@rmalizecsset[#1]#2{% \cptfor#2\dofor{\csv@@normalize[#1]##1}% } @@ -857,12 +862,9 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \def\elta##1{\noexpandcsn{\cptgobblescape#1@list@##1}}% \def\eltb##1{\cptexpandnext{\elta{b}##1}{########1}% #2\ltxkeys@parser@nil#2?{}}% - \def\eltc{\ltxkeys@ifxTF!\unexpanded{{####1}{####4}% - {\unexpanded{####4}}}}% + \def\eltc{\ltxkeys@ifxTF!\unexpanded{{####1}{####4}{\unexpanded{####4}}}}% \cptexpanded{\endgroup - \def#1####1{% - \ifstrcmpTF!{####1}{\elta{a}}{\eltb+}% - }% + \def#1####1{\ifstrcmpTF!{####1}{\elta{a}}{\eltb+}}% \def\elta{a}####1{\eltb!}% \def\elta{b}####1####2#2####3?####4####5{% \ltxkeys@ifxTF\ltxkeys@parser@nil{####2}{\eltc}{% @@ -875,8 +877,9 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ } \endgroup -\robust@def*\ltxkeys@parse{\cpt@testst\ltxkeys@parse@a} -\robust@def*\ltxkeys@parse@a#1{% +% Break out of the loop using \loopbreak. +\robust@def*\ltxkeys@listparse{\cpt@testst\ltxkeys@listparse@a} +\robust@def*\ltxkeys@listparse@a#1{% \begingroup \def\reserved@a##1##2{\endgroup \def\ltxkeys@nlz{##1}\def\ltxkeys@inkv{##2}% @@ -884,38 +887,40 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \cptexpandsecond\reserved@a{% \ifcase#1{01}{01}\or{00}{01}\or{01}{00}\or{00}{00}\else{01}{01}\fi }% - \cpt@testopt\ltxkeys@parse@b,% + \cpt@testopt\ltxkeys@listparse@b,% } -\robust@def*\ltxkeys@parse@b[#1]#2{% - \cpt@stchoose{cpt@st}{#2}\ltxkeys@arg\ltxkeys@parse - \cptpushfunctions\ltxkeys@parse{% +\robust@def*\ltxkeys@listparse@b[#1]#2{% + \cpt@stchoose{cpt@st}{#2}\ltxkeys@listitem\ltxkeys@listparse + \cptpushfunctions\ltxkeys@listparse{% \\\ifloopbreak\\\ifltxkeys@useempty\\\ltxkeys@doo - \\\ltxkeys@parse@c\\\ltxkeys@parse@d\\\ltxkeys@loopcbk + \\\ltxkeys@listparse@c\\\ltxkeys@listparse@d\\\ltxkeys@loopcbk + \\\stopprocessinglistkey }\cpt@csvdepth + \let\stopprocessinglistkey\loopbreak \ifdefTF\ltxkeys@do {\let\ltxkeys@doo\ltxkeys@do}{\cpt@notdeferr\ltxkeys@do}% - \def\ltxkeys@parse@c{% + \def\ltxkeys@listparse@c{% \ifboolTF{loopbreak} - {\gobble@to@sentinel\ltxkeys@nil#1}{\ltxkeys@parse@d.}% + {\gobble@to@sentinel\ltxkeys@nil#1}{\ltxkeys@listparse@d.}% }% - \def\ltxkeys@parse@d##1#1{% - \edef\ltxkeys@arg{\expandcsonce{\@gobble##1}}% - \ltxkeys@ifxTF\ltxkeys@arg\ltxkeys@nnil{}{% - \ltxkeys@ifcsemptyTF\ltxkeys@arg{% + \def\ltxkeys@listparse@d##1#1{% + \edef\ltxkeys@listitem{\expandcsonce{\@gobble##1}}% + \ltxkeys@ifxTF\ltxkeys@listitem\ltxkeys@nnil{}{% + \ltxkeys@ifcsemptyTF\ltxkeys@listitem{% \ifboolFT{ltxkeys@useempty}{}{\ltxkeys@doo{}}% }{% - \s@expandarg\ltxkeys@doo\ltxkeys@arg + \s@expandarg\ltxkeys@doo\ltxkeys@listitem }% - \relax\ltxkeys@parse@c + \relax\ltxkeys@listparse@c }% }% \ifswitchTF{ltxkeys@nlz}{% - \usename{\if\ltxkeys@inkv kv\else - csv\fi @@normalize}*[#1]\ltxkeys@arg + \usename{\if\ltxkeys@inkv kv\else csv\fi @@normalize}*[#1]% + \ltxkeys@listitem }{}% \loopbreakfalse - \expandafter\ltxkeys@parse@c\ltxkeys@arg#1\ltxkeys@nil#1% - \cptpopfunctions\ltxkeys@parse\cpt@csvdepth + \expandafter\ltxkeys@listparse@c\ltxkeys@listitem#1\ltxkeys@nil#1% + \cptpopfunctions\ltxkeys@listparse\cpt@csvdepth \ifnum\cpt@csvdepth=\z@pt\undefcs\ltxkeys@do\fi } \def\ltxkeys@keyprefixhook{} @@ -1023,7 +1028,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \def\temp@err##1{% \ltxkeys@err{Multiple ##1 in \noexpandcsn {ltxkeys@set\ifltxkeys@rm rm\fi keys}% - without '+' suffix}\ltxkeys@ehc + without '+' suffix}\ltxkeys@ehd }% \ltxkeys@ifeltcountTF[,](>)\@ne{#2}{% \temp@err{prefixes}% @@ -1058,7 +1063,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \toks@{#1}% \defpass\ltxkeys@tempa##1]{% \toks1\expandafter{\@gobble##1}% - \cptexpandsecond{\endgroup}{\the\toks@[{\the\toks1}]}% + \cptexpandsecond\endgroup{\the\toks@[{\the\toks1}]}% }.% } \robust@def*\ltxkeys@testopt@@a#1{\ltxkeys@testst{\ltxkeys@testopt@@b#1}} @@ -1126,8 +1131,9 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \letcstocsn\reserved@e{\ltxkeys@hdr#1keys}% \ifdefTF\reserved@e{% \xifinsetTF{,\cptoxdetok{#2},}{,\cptoxdetok\reserved@e,}{}{% - \csn@xdef{\ltxkeys@hdr#1keys}% - {\csliststack,\reserved@e\expandcsonce{#2}}% + \csn@xdef{\ltxkeys@hdr#1keys}{% + \csliststack,\reserved@e\expandcsonce{#2}% + }% }% }{% \csn@xdef{\ltxkeys@hdr#1keys}{\expandcsonce{#2}}% @@ -1138,12 +1144,14 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \letcstocsn\reserved@e{\ltxkeys@hdr @savedvaluelist}% \ifdefTF\reserved@e{% \oifinset@sp@TF,\ltxkeys@tempa\reserved@e{}{% - \csn@xdef{\ltxkeys@hdr @savedvaluelist}% - {\csliststack,\reserved@e\expandcsonce\ltxkeys@tempa}% + \csn@xdef{\ltxkeys@hdr @savedvaluelist}{% + \csliststack,\reserved@e\expandcsonce\ltxkeys@tempa + }% }% }{% - \csn@xdef{\ltxkeys@hdr @savedvaluelist}% - {\expandcsonce\ltxkeys@tempa}% + \csn@xdef{\ltxkeys@hdr @savedvaluelist}{% + \expandcsonce\ltxkeys@tempa + }% }% } \new@def*\ltxkeys@currtriple{% @@ -1192,7 +1200,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \begingroup \edef\ltxkeys@tempa{\cpttrimspaces{#1}}% \oifinset@sp@TF,\ltxkeys@tempa\ltxkeys@badkeynamelist{% - \ltxkeys@err{Bad key name '\ltxkeys@tempb'}\ltxkeys@ehc + \ltxkeys@err{Bad key name '\ltxkeys@tempb'}\ltxkeys@ehd }{}% \endgroup } @@ -1280,7 +1288,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \def\ltxkeys@do##1{% \expandafter\ltxkeys@ordkey@c\ltxkeys@loopcbk{##1}% }% - \ltxkeys@parse1{#1}% + \ltxkeys@listparse1{#1}% }{% \ltxkeys@ordkey@c{#1}{#2}{#3}% }% @@ -1294,6 +1302,81 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \ltxkeys@saveinitialkeyvals{}\ltxkeys@tkey{#2}% \@namedef{\ltxkeys@hdr\ltxkeys@tkey}##1{#3}% } + +\robust@def*\ltxkeys@denyusevaluepointer#1{% + \xifinsetTF{\detokenize{\usevalue}}{\detokenize{#1}}{% + \ltxkeys@err{Pointer '\string\usevalue' not allowed when + defining keys}\@ehd + }{}% +} +% List processor keys: +\robust@def*\ltxkeys@getlistseparator#1{% + \xifinsetTF{\detokenize{\listsep}}{\detokenize{#1}}{% + \def\reserved@a##1\listsep##2##3\ltxkeys@nil{% + \ifblankTF{##2}{% + \def\ltxkeys@listsep{,}% + }{% + \edef\ltxkeys@listsep{\cpttrimspace{##2}}% + }% + \edef\ltxkeys@tempb{\cpttrimspace{##1}\cpttrimspace{##3}}% + }% + \reserved@a#1\ltxkeys@nil + }{% + \def\ltxkeys@listsep{,}% + \edef\ltxkeys@tempb{\cpttrimspace{#1}}% + }% +} +% \ltxkeyslistkey[<pref>]{<fam>}{<key>}[<dft>]{<fn>} +\robust@def*\ltxkeys@listkey{% + \ltxkeys@swfalse + \def\ltxkeys@macpref{}% + \ltxkeys@testopt@a\ltxkeys@listkey@a +} +\newletcs\ltxkeys@listkeys\ltxkeys@listkey +\robust@def*\ltxkeys@newlistkey{\ltxkeys@chdeftrue\ltxkeys@listkey} +\newletcs\ltxkeys@newlistkeys\ltxkeys@newlistkey +\robust@def*\ltxkeys@listkey@a#1{% + \ltxkeys@debug{==}{Lisp key '\ltxkeys@tkey' is being defined}% + \cpt@ifbrack{% + \ltxkeys@bracedefault{\ltxkeys@sttrue\ltxkeys@listkey@b{#1}}% + }{% + \ltxkeys@stfalse\ltxkeys@listkey@b{#1}[]% + }% +} +\robust@def*\ltxkeys@listkey@b#1[#2]#3{% + \let\ifltxkeys@keyst\ifltxkeys@st + \edef\ltxkeys@loopcbk##1{{##1}\unexpanded{{#2}{#3}}}% + \ifinsetTF,{#1}{% + \def\ltxkeys@do##1{% + \expandafter\ltxkeys@listkey@c\ltxkeys@loopcbk{##1}% + }% + \ltxkeys@listparse1{#1}% + }{% + \ltxkeys@listkey@c{#1}{#2}{#3}% + }% +} +\robust@def*\ltxkeys@listkey@c#1#2#3{% + \ltxkeys@denyusevaluepointer{#1}% + \ltxkeys@findpointers{#1}% + \ltxkeys@checkdefkey + \ifdefboolTF{ltxkeys@keyst}{% + \ltxkeys@definedefault\ltxkeys@tkey{#2}% + }{}% + \ltxkeys@saveinitialkeyvals{}\ltxkeys@tkey{#2}% + \ltxkeys@getlistseparator{#3}% + \def\reserved@a{\csn@def{\ltxkeys@hdr\ltxkeys@tkey @auxcbk}####1}% + \expandafter\reserved@a\expandafter{\ltxkeys@tempb}% + \csn@edef{\ltxkeys@hdr\ltxkeys@tkey}##1{% + \def\noexpand\ltxkeys@listcount{0}% + \edef\noexpand\ltxkeys@tempa{\noexpand\ltxkeys@stripallouterbraces{##1}}% + \def\noexpand\ltxkeys@do####1{% + \noexpand\cptpushnumber\noexpand\ltxkeys@listcount + \noexpandcsn{\ltxkeys@hdr\ltxkeys@tkey @auxcbk}{####1}% + }% + \ltxkeys@listparse*1[\ltxkeys@listsep]\noexpand\ltxkeys@tempa + }% +} + \robust@def*\ltxkeys@cmdkey{% \ltxkeys@swfalse \ltxkeys@testopt@e\ltxkeys@cmdkey@a{cmd}% @@ -1308,7 +1391,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ }% \ifinsetTF,{#2}{% \def\ltxkeys@do##1{\ltxkeys@loopcbk{##1}}% - \ltxkeys@parse1{#2}% + \ltxkeys@listparse1{#2}% }{% \ltxkeys@cmdkey@b{#1}{#2}{#3}{#4}% }% @@ -1339,7 +1422,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \ifblankTF{#3}{}{% \xifstrcmpTF{#3}{true}{}{% \xifstrcmpTF{#3}{false}{}{% - \ltxkeys@err{Bad boolean value '#3'}\ltxkeys@ehc + \ltxkeys@err{Bad boolean value '#3'}\ltxkeys@ehd }% }% }% @@ -1369,7 +1452,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ }% \ifinsetTF,{#2}{% \def\ltxkeys@do##1{\ltxkeys@loopcbk{##1}}% - \ltxkeys@parse1{#2}% + \ltxkeys@listparse1{#2}% }{% \ltxkeys@loopcbk{#2}% }% @@ -1382,7 +1465,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ }% \ifinsetTF,{#2}{% \def\ltxkeys@do##1{\ltxkeys@loopcbk{##1}}% - \ltxkeys@parse1{#2}% + \ltxkeys@listparse1{#2}% }{% \ltxkeys@loopcbk{#2}% }% @@ -1447,7 +1530,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ % #3: default value \robust@def*\ltxkeys@biboolkeys@d#1#2#3{% \ltxkeys@ifeltcountTF[,](=)\tw@{#2}{}{% - \ltxkeys@error{Biboolean keys '#2' not equal to 2}\ltxkeys@ehc + \ltxkeys@error{Biboolean keys '#2' not equal to 2}\ltxkeys@ehd }% \ltxkeys@commanormalize{#2}\ltxkeys@keys \def\ltxkeys@tempa##1,##2\ltxkeys@nil##3##4{% @@ -1565,7 +1648,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ }% \ifinsetTF,{#2}{% \def\ltxkeys@do##1{\ltxkeys@loopcbk{##1}}% - \ltxkeys@parse1{#2}% + \ltxkeys@listparse1{#2}% }{% \ltxkeys@stylekey@c{#1}{#2}{#3}{#4}{#5}% }% @@ -1597,7 +1680,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ }% } -% #1: style type, '1' (*-form) or '0' (plain, non-*-form). +% #1: style type: '1' (*-form) or '0' (plain, non-*-form). % #2: <macro prefix> \robust@def*\ltxkeys@setdependants#1#2{% \letcstocsn\ltxkeys@tempa{\ltxkeys@hdr\ltxkeys@tkey @dependants}% @@ -1620,7 +1703,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \ltxkeys@s@td@pendants{##1}% \ltxkeys@s@td@p@ndants{#1}% }% - \cptexpandsecond{\ltxkeys@parse0}{[\ltxkeys@keyparser]}{#3}% + \cptexpandsecond{\ltxkeys@listparse0}{[\ltxkeys@keyparser]}{#3}% % We're in a group: so \ifblankTF can be temporarily redefined: \let\ifblankTF\relax \cptpassexpanded{% @@ -1644,16 +1727,9 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ }% \ltxkeys@depfalse } -\robust@def*\ltxkeys@striplaststar#1*\@empty#2\ltxkeys@nil#3{% - \edef#3{#1}% -} -\robust@def*\ltxkeys@ifrejname#1{% - \ifcase0\ifx\key@type\ltxkeys@rej1\else - \ifx\key@name\ltxkeys@rej1\fi\fi\relax\else#1\fi -} \robust@def*\ltxkeys@s@td@pendants#1{% \begingroup - \def\key@name{}\def\key@default{}\def\key@macro{}% + \def\key@name{}\def\key@default{}\def\key@callback{}% % '#1' may come with nested parameters that will make it % impossible to include '#1' directly in \temp@err. % So we put '#1' in a token register: @@ -1661,7 +1737,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \def\ltxkeys@splita##1/##2/{% \ifblankTF{##1##2}{% % No keys to read (remove forward slashes): - \ltxkeys@err{Something is wrong with dependant keys}\ltxkeys@ehc + \ltxkeys@err{Something is wrong with dependant keys}\ltxkeys@ehd \expandafter\gobble@to@sentinel\expandafter \ltxkeys@nil\ltxkeys@keyparser }{% @@ -1672,21 +1748,21 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \key@type\@empty*\@empty\ltxkeys@nil\key@type \xifstrcmpFT\key@type{sty}{}{% \ltxkeys@err{A dependant key can't have dependants: - ||\the\@temptokena||}\ltxkeys@ehc + ||\the\@temptokena||}\ltxkeys@ehd }% \xifinsetTF\key@type{,ord,cmd,bool,choice,}{}{% \ltxkeys@err{Invalid key type '\key@type' in dependant key(s) - ||\the\@temptokena||}\ltxkeys@ehc + ||\the\@temptokena||}\ltxkeys@ehd }% \ifblankTF{##2}{% \ltxkeys@err{Empty key name in dependant key(s) - ||\the\@temptokena||}\ltxkeys@ehc + ||\the\@temptokena||}\ltxkeys@ehd }{% \ltxkeys@findpointers{##2}% \let\key@name\ltxkeys@tkey }% \ltxkeys@ifrejname{% - \ltxkeys@err{Wrong syntax for dependant keys}\ltxkeys@ehc + \ltxkeys@err{Wrong syntax for dependant keys}\ltxkeys@ehd }% \ltxkeys@splitb.% }% @@ -1697,14 +1773,14 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \xifstrcmpTF{\cptoxdetok\key@default}{\detokenize{\parentval}}{% \edef\key@default{\expandcstwice\key@default}% }{}% - \edef\key@macro{\unexpanded{##2}}% - \ltxkeys@stripdotcode\key@macro + \edef\key@callback{\unexpanded{##2}}% + \ltxkeys@stripdotcode\key@callback }% \ltxkeys@splita#1/^?^/^?^/^?^/\ltxkeys@nil \let\do\cpt@csexit \cptpassexpanded{% \endgroup - \do\key@type\do\key@name\do\key@default\do\key@macro + \do\key@type\do\key@name\do\key@default\do\key@callback }% } \robust@def*\ltxkeys@s@td@p@ndants#1{% @@ -1722,7 +1798,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \the\toks1\oifblankTF{\the\toks1}{}{\ltxkeys@keyparser}% \key@type/\expandcsonce\key@name \ifx\key@default\ltxkeys@rej\else/\expandcsonce\key@default\fi - \ifx\key@macro\ltxkeys@rej\else/\expandcsonce\key@macro\fi + \ifx\key@callback\ltxkeys@rej\else/\expandcsonce\key@callback\fi }% \else \toks2{\the\toks2\oifblankTF{\the\toks2}{}{,}% @@ -1767,7 +1843,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ % #4 alt values \robust@def*\ltxkeys@choicekey@b#1#2[#3]#4{% \ifblankTF{#4}{% - \ltxkeys@err{Choice key can't have empty nominations}\ltxkeys@ehc + \ltxkeys@err{Choice key can't have empty nominations}\ltxkeys@ehd }{}% % Make \ltxkeys@chclist for the choice key: \ltxkeys@makechclist{#4}{0}% @@ -1810,7 +1886,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \def\ltxkeys@do##1{% \ltxkeys@loopcbk{##1}% }% - \ltxkeys@parse1{#2}% + \ltxkeys@listparse1{#2}% }{% \ltxkeys@loopcbk{#2}% }% @@ -1825,7 +1901,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \def\ltxkeys@do##1{% \ltxkeys@loopcbk{##1}% }% - \ltxkeys@parse1{#2}% + \ltxkeys@listparse1{#2}% }{% \ltxkeys@loopcbk{#2}% }% @@ -1889,7 +1965,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ }{}% \else \ltxkeys@err{Invalid number '#2' while - in \string\ltxkeys@makechclist}\ltxkeys@ehc + in \string\ltxkeys@makechclist}\ltxkeys@ehd \fi }% \def\ltxkeys@do##1{% @@ -1900,12 +1976,12 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ }% }% \expandafter\ifinsetTF\expandafter{\ltxkeys@keyparser}{#1}{% - \cptexpandsecond{\ltxkeys@parse1}{[\ltxkeys@keyparser]}{#1}% + \cptexpandsecond{\ltxkeys@listparse1}{[\ltxkeys@keyparser]}{#1}% }{% \ifinsetTF{,}{#1}{% - \ltxkeys@parse1[,]{#1}% + \ltxkeys@listparse1[,]{#1}% }{% - \ltxkeys@parse1[,]{#1,}% + \ltxkeys@listparse1[,]{#1,}% }% }% \postgroupdef\ltxkeys@chclist\endgroup @@ -1942,12 +2018,12 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \csliststack,\ltxkeys@keynames\expandcsonce\ltxkeys@tempa }% }% - \ifblankTF{#1}{}{\ltxkeys@parse3{#1}}% + \ifblankTF{#1}{}{\ltxkeys@listparse3{#1}}% \postgroupdef\ltxkeys@keynames\endgroup } \robust@def*\ltxkeys@getkeyvalue#1=#2\ltxkeys@nil#3{% \ifinsetTF{=\ltxkeys@nil}{#2\ltxkeys@nil}{% - \ltxkeys@novalfalse + \ltxkeys@novaluefalse \begingroup \def\ltxkeys@tempa##1=##2\ltxkeys@nil{\endgroup % \s@expandarg\ltxkeys@trimspaces{\@gobble##1}#3% @@ -1956,7 +2032,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ }% \ltxkeys@tempa.#2\ltxkeys@nil }{% - \ltxkeys@novaltrue\def#3{}% + \ltxkeys@novaluetrue\def#3{}% }% } \robust@def*\ltxkeys@splitkeyval#1\ltxkeys@nil#2#3{% @@ -2009,7 +2085,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ {Only defined keys can be made '#1option' keys.}% }% }% - \ltxkeys@parse1{#2}% + \ltxkeys@listparse1{#2}% } % Make defined keys option-keys from their <pref> and <fam>. % The starred (*) variant makes non-option keys. @@ -2021,7 +2097,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \ifcsndefTF{#1@#2@initialkeyvals}{% \letcstocsn\ltxkeys@tempa{#1@#2@initialkeyvals}% }{% - \ltxkeys@err{No initial key-values for family '#2'}\ltxkeys@ehc + \ltxkeys@err{No initial key-values for family '#2'}\ltxkeys@ehd }% \s@expandarg\ltxkeys@getkeynames\ltxkeys@tempa \ltxkeys@ifcsemptyTF\ltxkeys@keynames{}{% @@ -2080,7 +2156,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ {Only defined keys can be made #1-keys.}% }% }% - \ltxkeys@parse1{#2}% + \ltxkeys@listparse1{#2}% \letcsntocs{\ltxkeys@hdr#1keys}\ltxkeys@rsvda } \robust@def*\ltxkeys@rem@vehandledkeys#1#2{% @@ -2103,7 +2179,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ {I couldn't delete #1-keys.}% }% }% - \ltxkeys@parse1{#2}% + \ltxkeys@listparse1{#2}% }{% \ltxkeys@err{No #1 keys for family '\ltxkeys@tfam'}% {No #1 keys exist for prefix '\ltxkeys@ttpref' and @@ -2202,15 +2278,8 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \ifblankTF{#1}{% \ltxkeys@twkfalse }{% - \ltxkeys@ifinlistTF(1){% - \ltxkeys@setaliaskey,\setaliaskey - }{% - #2% - }{% - \ltxkeys@twktrue - }{% - \ltxkeys@twkfalse - }% + \ltxkeys@ifinlistTF(1){\ltxkeys@setaliaskey,\setaliaskey}{#2}% + {\ltxkeys@twktrue}{\ltxkeys@twkfalse}% }% \begingroup \edef\elt{\ifblankTF{#1}{}{\unexpanded{#1}}}% @@ -2276,7 +2345,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \def\ltxkeys@splitc##1/##2/##3/##4\ltxkeys@nil{% \ifblankTF{##1}{% \ltxkeys@err{Empty key name while in - \string\ltxkeys@definekeys}\ltxkeys@ehc + \string\ltxkeys@definekeys}\ltxkeys@ehd }{% \ltxkeys@findpointers{##1}% \let\key@name\ltxkeys@tkey @@ -2286,7 +2355,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ }{}{% \ltxkeys@err{Key '\key@name' already defined in family \MsgBrk '\iflacus#2\dolacus???\else#2\fi' with prefix - '\iflacus#1\dolacus???\else#1\fi'}\ltxkeys@ehc + '\iflacus#1\dolacus???\else#1\fi'}\ltxkeys@ehd }% \fi \oifblankTF{\@gobble##2}{% @@ -2294,11 +2363,11 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ }{% \ltxkeys@remdottrimspaces{##2}\key@default }% - \edef\key@macro{\unexpanded{##3}}% - \ltxkeys@stripdotcode\key@macro + \edef\key@callback{\unexpanded{##3}}% + \ltxkeys@stripdotcode\key@callback \cptexpandsecond\ltxkeys@accumkeyvals{% {\ifx\key@default\ltxkeys@rej\else\expandcsonce\key@default\fi}% - {\ifx\key@macro\ltxkeys@rej\else\expandcsonce\key@macro\fi}% + {\ifx\key@callback\ltxkeys@rej\else\expandcsonce\key@callback\fi}% }% \def\defwith{\ltxkeys@boolkey}% \oifstrcmpTF\key@default{true}{}{% @@ -2313,7 +2382,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \ifx\macro@pref\@empty\else[\macro@pref]\fi {\expandcsonce\key@name}% \ifx\key@default\ltxkeys@rej\else[\expandcsonce\key@default]\fi - \ifx\key@macro\ltxkeys@rej{}\else{\expandcsonce\key@macro}\fi + \ifx\key@callback\ltxkeys@rej{}\else{\expandcsonce\key@callback}\fi }% }% }% @@ -2327,7 +2396,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \expandafter\ltxkeys@splitb\ltxkeys@tempa/^?^/^?^/\ltxkeys@nil }% }% - \cptexpandsecond{\ltxkeys@parse1}{[\ltxkeys@keyparser]}{#4}% + \cptexpandsecond{\ltxkeys@listparse1}{[\ltxkeys@keyparser]}{#4}% % Define and initialize the keys here directly: \cptexpandsecond\endgroup{% \the\toks@ @@ -2376,15 +2445,12 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \ltxkeys@makehdr{#3}% \ltxkeys@dectrue \begingroup - \ltxkeys@trimspacesset{% - {#2}\key@pref,{#3}\key@fam,{#4}\macro@pref - }% - \def\key@vals{}% - \toks@{}% + \ltxkeys@trimspacesset{{#2}\key@pref,{#3}\key@fam,{#4}\macro@pref}% + \def\key@vals{}\toks@{}% \def\ltxkeys@splita##1/##2/{% \ifescapedTF{##1}{% \ltxkeys@err{Key type can't be a macro: '\detokenize{##1}'}% - \ltxkeys@ehc + \ltxkeys@ehd }{}% \ltxkeys@trimspacesset{{##1}\key@type,{##2}\key@name}% \xifstrcmpTF\key@type{choice}{% @@ -2394,19 +2460,19 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \ltxkeys@err{The syntax of \noexpand\ltxkeys@definekeys may \MsgBrk have been used for \string\ltxkeys@declarekeys. \MsgBrk This may have come from \noexpand\ltxkeyscmd or - \MsgBrk \string\ltxkeysenv}\ltxkeys@ehc + \MsgBrk \string\ltxkeysenv}\ltxkeys@ehd }{}% \ifx\key@type\@empty \ltxkeys@err{Empty key type in \string\ltxkeys@declarekeys} - \ltxkeys@ehc + \ltxkeys@ehd \fi \ifx\key@name\@empty \ltxkeys@err{Empty key name in \string\ltxkeys@declarekeys}% - \ltxkeys@ehc + \ltxkeys@ehd \fi \ltxkeys@ifrejname{% \ltxkeys@err{Wrong use syntax for \string\ltxkeys@declarekeys}% - \ltxkeys@ehc + \ltxkeys@ehd }% \ifltxkeys@inkeycmd \xifstrcmpFT\key@type{ord}{}{\def\key@type{cmd}}% @@ -2422,7 +2488,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \ifcsndefFT{\ltxkeys@hdr\key@name}{}{% \ltxkeys@err{Key '\key@name' already defined in family \MsgBrk '\iflacus#3\dolacus???\else#3\fi' with prefix - '\iflacus#2\dolacus???\else#2\fi'}\ltxkeys@ehc + '\iflacus#2\dolacus???\else#2\fi'}\ltxkeys@ehd }% \fi \ltxkeys@splitb.% @@ -2440,36 +2506,42 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \ltxkeys@debug{!!}{Boolean key '\key@name' has no default; 'true' used}% \else - \begingroup - \def\ltxkeys@true{true}\def\ltxkeys@false{false}% - \ifcase0\ifx\key@default\ltxkeys@true\else\ifx\key@default - \ltxkeys@false\else1\fi\fi\relax\else + \ifcase0% + \ifx\key@default\ltxkeys@truetoks\else + \ifx\key@default\ltxkeys@falsetoks\else1\fi\fi\relax + \else \ltxkeys@err{Invalid default value for boolean key - '\key@name'}\ltxkeys@ehc + '\key@name'}\ltxkeys@ehd \fi - \endgroup \fi }{}% - \edef\key@macro{\unexpanded{##2}}% - \ltxkeys@stripdotcode\key@macro - \expandafter\ltxkeys@striplaststar\key@type - \@empty*\@empty\ltxkeys@nil\key@@type - \xifinsetFT{,sty,}{,\key@@type,}{}{% + \edef\key@callback{\unexpanded{##2}}% + \ltxkeys@stripdotcode\key@callback + \expandafter\ltxkeys@striplaststar\key@type\@empty*\@empty + \ltxkeys@nil\key@type@aux + \xifinsetTF{,\key@type@aux,}{,sty,}{% \ltxkeys@trimspaces{##3}\key@dependants \ltxkeys@ifxTF\key@dependants\ltxkeys@rej{% \def\key@dependants{}% }{% \expandafter\ltxkeys@declarekeys@e\expandafter{\key@dependants}% }% + }{% + \xifinsetTF{,\key@type@aux,}{,bool,choice,}{% + \ltxkeys@trimspaces{##3}\key@bicallback + \ltxkeys@ifxTF\key@bicallback\ltxkeys@rej{% + \let\key@bicallback\ltxkeys@keyvalerr + }{}% + }{}% }% \cptexpandsecond\ltxkeys@accumkeyvals{% {\ifx\key@default\ltxkeys@rej\else\expandcsonce\key@default\fi}% - {\ifx\key@macro\ltxkeys@rej\else\expandcsonce\key@macro\fi}% + {\ifx\key@callback\ltxkeys@rej\else\expandcsonce\key@callback\fi}% }% - \def\dkey@macro{% - \ifx\key@macro\ltxkeys@rej{}\else{\expandcsonce\key@macro}\fi + \def\key@callback@aux{% + \ifx\key@callback\ltxkeys@rej{}\else{\expandcsonce\key@callback}\fi }% - \def\dkey@default{% + \def\key@default@aux{% \ifx\key@default\ltxkeys@rej\else[\expandcsonce\key@default]\fi }% \s@expandarg\ltxkeys@declarekeys@d\key@type @@ -2483,22 +2555,22 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \toks@{\the\toks@ \cptmakecs{ltxkeys@twk\ifltxkeys@twk true\else false\fi}% \ifcase\currmatch\relax - \ltxkeys@cmdkey\ltxkeys@tempa\dkey@default\dkey@macro + \ltxkeys@cmdkey\ltxkeys@tempa\key@default@aux\key@callback@aux \or - \ltxkeys@boolkey+\ltxkeys@tempa\dkey@default - \dkey@macro{\ltxkeys@keyvalerr}% + \ltxkeys@boolkey+\ltxkeys@tempa\key@default@aux + \key@callback@aux{\expandcsonce\key@bicallback}% \or - \ltxkeys@ordkey\ltxkeys@tempa\dkey@default\dkey@macro + \ltxkeys@ordkey\ltxkeys@tempa\key@default@aux\key@callback@aux \or \ltxkeys@choicekey*+\ltxkeys@tempa [\unexpanded{\userinput\order}]{\expandcsonce\ltxkeys@alt}% - \dkey@default\dkey@macro{\ltxkeys@keyvalerr}% + \key@default@aux\key@callback@aux{\expandcsonce\key@bicallback}% \or - \ltxkeys@stylekey\ltxkeys@tempa\dkey@default - (\expandcsonce\key@dependants)\dkey@macro + \ltxkeys@stylekey\ltxkeys@tempa\key@default@aux + (\expandcsonce\key@dependants)\key@callback@aux \or - \ltxkeys@stylekey*\ltxkeys@tempa\dkey@default - (\expandcsonce\key@dependants)\dkey@macro + \ltxkeys@stylekey*\ltxkeys@tempa\key@default@aux + (\expandcsonce\key@dependants)\key@callback@aux \else \cptgaddtolist\noexpand\ltxkeys@badkeytypes{\key@type}% \fi @@ -2521,14 +2593,14 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \ltxkeys@tempa#1/\unexpanded{##1}% }% }% - \cptexpandsecond{\ltxkeys@parse0}{[\ltxkeys@keyparser]}{#5}% + \cptexpandsecond{\ltxkeys@listparse0}{[\ltxkeys@keyparser]}{#5}% }% \def\ltxkeys@do##1{% \ifblankTF{##1}{}{% \ltxkeys@splita##1/^?^/^?^/^?^/^?^/\ltxkeys@nil }% }% - \cptexpandsecond{\ltxkeys@parse0} + \cptexpandsecond{\ltxkeys@listparse0} {[\ltxkeys@keyparser]{\expandcsonce\ltxkeys@tempa}}% \cptexpandsecond\endgroup{% \the\toks@ @@ -2536,7 +2608,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \edef\noexpand\key@vals{\ox@unexpanded\key@vals}% }% \ifx\ltxkeys@badkeytypes\@empty\else - \cpt@err{Invalid key types '\ltxkeys@badkeytypes'}\ltxkeys@ehc + \cpt@err{Invalid key types '\ltxkeys@badkeytypes'}\ltxkeys@ehd \fi % Initialize keys: \ltxkeys@ifcsemptyTF\key@vals{}{% @@ -2544,19 +2616,14 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ }% \ltxkeys@decfalse } -\robust@def\ltxkeys@declarekeys@d#1{% +\robust@def*\ltxkeys@declarekeys@d#1{% \ltxkeys@findmatch - {#1}{cmd:0,bool:1,ord:2,choice:3,sty:4,syt*:5}% - {\def\currmatch{-1}}% + {#1}{cmd:0,bool:1,ord:2,choice:3,sty:4,syt*:5}{\def\currmatch{-1}}% } -\robust@def\ltxkeys@declarekeys@e#1{% - \ifblankTF{#1}{% - \def\key@dependants{}\cptgobbletorelax - }{}% +% \ltxkeys@declarekeys@e{<dependant key specs>} +\robust@def*\ltxkeys@declarekeys@e#1{% + \ifblankTF{#1}{\def\key@dependants{}\cptgobbletorelax}{}% \begingroup - \ifinsetTF{>}{#1}{}{% - \ltxkeys@warn{Missing '>' in dependants of key '\ltxkeys@tkey'}% - }% \def\ltxkeys@splita##1>##2>{% \def\key@type{##1}% \edef\key@name{\unexpanded{##2}}% @@ -2564,24 +2631,24 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ }% \def\ltxkeys@splitb##1>##2>##3\ltxkeys@nil{% \edef\key@default{\expandcsonce{\@gobble##1}}% - \edef\key@macro{\unexpanded{##2}}% - \ltxkeys@stripdotcode\key@macro + \edef\key@callback{\unexpanded{##2}}% + \ltxkeys@stripdotcode\key@callback \ltxkeys@ifrejname{% \ltxkeys@err{Wrong syntax for dependants keys in - \MsgBrk\string\ltxkeys@declarekeys}\ltxkeys@ehc + \MsgBrk\string\ltxkeys@declarekeys}\ltxkeys@ehd }% \edef\key@dependants{% \expandafter\csliststack\ltxkeys@keyparser\key@dependants \key@type/\expandcsonce\key@name \ifx\key@default\ltxkeys@rej\else/\expandcsonce\key@default\fi - \ifx\key@macro\ltxkeys@rej\else/\expandcsonce\key@macro\fi + \ifx\key@callback\ltxkeys@rej\else/\expandcsonce\key@callback\fi }% }% \def\key@dependants{}% \def\ltxkeys@do##1{% \ltxkeys@splita##1>^?^>^?^>^?^>\ltxkeys@nil }% - \ltxkeys@parse1[,]{#1}% + \ltxkeys@listparse1[,]{#1}% \postgroupdef\key@dependants\endgroup \cpt@relax } @@ -2596,12 +2663,12 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \robust@def*\ltxkeys@savexf@milyk@ys#1(#2)#3{% \ifblankTF{#1}{% \ltxkeys@err{Empty set-identifier for \string\xfamilykeys: - ||\detokenize{#3}||}\ltxkeys@ehc + ||\detokenize{#3}||}\ltxkeys@ehd }{}% \ltxkeys@trimspaces{#1}\ltxkeys@tempb \ifcsndefTF{xfamilykeys@id@\ltxkeys@tempb}{% \ltxkeys@err{xfamilykeys identifier '\ltxkeys@tempb' - already in use}\ltxkeys@ehc + already in use}\ltxkeys@ehd }{}% \cpt@stchoose{cpt@st}{#3}\ltxkeys@tempa\ltxkeys@savexfamilykeys \ifblankTF{#2}{}{% @@ -2611,7 +2678,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \ltxkeys@tempa#2/\unexpanded{##1}% }% }% - \cptexpandsecond{\def\ltxkeys@tempa{}\ltxkeys@parse1}% + \cptexpandsecond{\def\ltxkeys@tempa{}\ltxkeys@listparse1}% {[\ltxkeys@keyparser]{\expandcsonce\ltxkeys@tempa}}% }% \cptexpandsecond{\endgroup\csn@edef} @@ -2626,7 +2693,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \edef\defwith{\ltxkeys@declarekeys\ifcpt@st*\fi}% \ifblankTF{#1}{% \ltxkeys@err{Invalid empty xfamilykeys identifier - \MsgBrk in \string\ltxkeys@definexfamilykeys}\ltxkeys@ehc + \MsgBrk in \string\ltxkeys@definexfamilykeys}\ltxkeys@ehd }{}% \ltxkeys@trimspaces{#1}\ltxkeys@tempa \ifcsndefTF{xfamilykeys@id@\ltxkeys@tempa}{% @@ -2634,7 +2701,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \ltxkeys@d@fin@xfamilykeys\expandafter{\ltxkeys@tempa}}{KV}% }{% \ltxkeys@err{Unknown xfamilykeys identifier '\ltxkeys@tempa' - \MsgBrk in \string\ltxkeys@definexfamilykeys}\ltxkeys@ehc + \MsgBrk in \string\ltxkeys@definexfamilykeys}\ltxkeys@ehd }% } \robust@def*\ltxkeys@d@fin@xfamilykeys#1[#2]#3{% @@ -2643,25 +2710,25 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \robust@def*\ltxkeys@d@fin@xf@milykeys#1#2#3[#4]#5{% \def\ltxkeys@na{#5}% \def\ltxkeys@splita##1/##2/{% - \ltxkeys@trimspacesset{{##1}\key@type,{##2}\key@n@me}% + \ltxkeys@trimspacesset{{##1}\key@type,{##2}\key@name@aux}% \xifstrcmpTF\key@type{choice}{% - \expandafter\ltxkeys@splitchoice\expandafter{\key@n@me}% + \expandafter\ltxkeys@splitchoice\expandafter{\key@name@aux}% }{% - \let\key@name\key@n@me + \let\key@name\key@name@aux }% \ltxkeys@splitb.% }% \def\ltxkeys@splitb##1/##2/##3/##4\ltxkeys@nil{% \edef\key@default{\expandcsonce{\@gobble##1}}% - \edef\key@macro{\unexpanded{##2}}% + \edef\key@callback{\unexpanded{##2}}% \edef\key@dependants{\unexpanded{##3}}% \oifinset@sp@TF,\key@name\ltxkeys@na{}{% \let\do\expandcsonce \edef\ltxkeys@tempa{% \expandafter\csliststack\ltxkeys@keyparser - \ltxkeys@tempa\key@type/\do\key@n@me + \ltxkeys@tempa\key@type/\do\key@name@aux \ifx\key@default\ltxkeys@rej\else/\do\key@default\fi - \ifx\key@macro\ltxkeys@rej\else/\do\key@macro\fi + \ifx\key@callback\ltxkeys@rej\else/\do\key@callback\fi \ifx\key@dependants\ltxkeys@rej\else/\do\key@dependants\fi }% }% @@ -2670,7 +2737,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \def\ltxkeys@do##1{% \ltxkeys@splita##1/^?^/^?^/^?^/^?^/\ltxkeys@nil }% - \cptexpandsecond{\ltxkeys@parse1} + \cptexpandsecond{\ltxkeys@listparse1} {[\ltxkeys@keyparser]{\expandcsnonce{xfamilykeys@id@#1}}}% \cptexpandsecond\endgroup {\defwith[#2]{#3}[#4]{\expandcsonce\ltxkeys@tempa}}% @@ -2703,7 +2770,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \ltxkeys@splitkeyval##1\ltxkeys@nil\ltxkeys@tkey\ltxkeys@tval \ifcsndefFT{\ltxkeys@hdr\ltxkeys@tkey}{% \ltxkeys@err{Key '\ltxkeys@currtriple' is undefined.}% - \ltxkeys@ehc + \ltxkeys@ehd }{% \ifcsndefTF{\ltxkeys@hdr#1setkeys@alreadysaved}{}{% \csn@def{\ltxkeys@hdr#1setkeys@alreadysaved}{}% @@ -2713,7 +2780,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \xifinsetTF{,\cptoxdetok\ltxkeys@tkey,}% {,\cptsxdetok{\usename{\ltxkeys@hdr#1setkeys@alreadysaved},}}{% \ltxkeys@err{Double entry for key '\ltxkeys@currtriple' in\MsgBrk - #1set key list}\ltxkeys@ehc + #1set key list}\ltxkeys@ehd }{% \edef\ltxkeys@rsvda{\csliststack,\ltxkeys@rsvda \ltxkeys@tkey\ltxkeys@ifcsemptyTF\ltxkeys@tval{}% @@ -2723,7 +2790,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ }% }% }% - \ltxkeys@parse3{#2}% + \ltxkeys@listparse3{#2}% % '...@alreadysaved' saves key names irrespective % of value, for testing if a preset key is being saved twice: \ltxkeys@ifcsemptyTF\ltxkeys@rsvda{}{% @@ -2748,14 +2815,14 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \robust@def*\ltxkeys@removeppsetkeys#1#2{% \ifcsndefFT{\ltxkeys@hdr#1setkeys}{% \ltxkeys@err{No #1set keys defined for prefix '\ltxkeys@ttpref' - and family '\ltxkeys@tfam'}\ltxkeys@ehc + and family '\ltxkeys@tfam'}\ltxkeys@ehd }{% \def\ltxkeys@rsvda{}\def\ltxkeys@rsvdb{}% \def\ltxkeys@do##1{% \ltxkeys@splitkeyval##1=\ltxkeys@nil\ltxkeys@tkey\ltxkeys@tval \ifcsndefFT{\ltxkeys@hdr\ltxkeys@tkey}{% \ltxkeys@err{Key '\ltxkeys@currtriple' is undefined}% - \ltxkeys@ehc + \ltxkeys@ehd }{% \xifinsetTF{,\cptoxdetok\ltxkeys@tkey=\cptoxdetok\ltxkeys@tval,}% {,\cptsxdetok{\usename{\ltxkeys@hdr#1setkeys}},}{% @@ -2766,11 +2833,11 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \expandcsonce\ltxkeys@tkey}% }{% \ltxkeys@err{Key '\ltxkeys@currtriple' not a #1set key}% - \ltxkeys@ehc + \ltxkeys@ehd }% }% }% - \ltxkeys@parse3{#2}% + \ltxkeys@listparse3{#2}% \ltxkeys@ifcsemptyTF\ltxkeys@rsvda{}{% \cptpassexpanded{% \cptfilterremovekv\noexpandcsn{\ltxkeys@hdr#1setkeys}% @@ -2788,7 +2855,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \robust@def*\ltxkeys@undefppsetkeys#1{% \ifcsndefFT{\ltxkeys@hdr#1setkeys}{% \ltxkeys@err{No #1set keys defined for prefix '\ltxkeys@ttpref' - and family '\ltxkeys@tfam'}\ltxkeys@ehc + and family '\ltxkeys@tfam'}\ltxkeys@ehd }{% \usename{\ifltxkeys@cl g\fi undefcsn}{\ltxkeys@hdr#1setkeys}% \usename{\ifltxkeys@cl g\fi undefcsn}% @@ -2801,7 +2868,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \ltxkeys@commanormalize{#1}\ltxkeys@tempa \xifinsetTF{,}{\cptoxdetok\ltxkeys@tempa}{% \ltxkeys@err{\noexpand\ltxkeys@setaliaskey doesn't - accept key list}\ltxkeys@ehc + accept key list}\ltxkeys@ehd }{% \cptexpandarg\cpt@testopt{\ltxkeys@s@taliaskey\ltxkeys@tempa}{}% }% @@ -2816,7 +2883,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ {\expandcsonce\y}% }{% \ltxkeys@err{\noexpand\ltxkeys@setaliaskey - or \noexpand\setaliaskey nested}\ltxkeys@ehc + or \noexpand\setaliaskey nested}\ltxkeys@ehd }{}% \cptexpandsecond\ltxkeys@setkeys{% [\ltxkeys@ttpref]{\ltxkeys@tfam}{% @@ -2830,7 +2897,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \ltxkeys@trimspaces{##1}\key@name \ifstrcmpTF{##2}{.}{% \ltxkeys@err{Invalid alternate value list for key '#1'} - \ltxkeys@ehc + \ltxkeys@ehd }{% \ifmacroTF{##2}{% \edef\ltxkeys@alt{\expandcsonce{##2}}% @@ -2886,9 +2953,9 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \ltxkeys@tempc\nofilter }{}% }% - \ltxkeys@parse1{#2}% + \ltxkeys@listparse1{#2}% }% - \ltxkeys@parse1{#1}% + \ltxkeys@listparse1{#1}% \ltxkeys@getkeynames{#3}% \cptexpandsecond{\endgroup\ltxkeys@setkeys*+[#1]{#2}}% {[\ltxkeys@keynames]{\expandcsonce\ltxkeys@resa}}% @@ -2912,7 +2979,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \edef#1{\csliststack,#1\unexpanded{##1}}% }% }% - \cptexpandargonce{\def#1{}\ltxkeys@parse3}{#1}% + \cptexpandargonce{\def#1{}\ltxkeys@listparse3}{#1}% \cpt@relax \postgroupdef#1\endgroup } @@ -2929,7 +2996,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \xifinsetTF{,}\ltxkeys@fams{% \ifltxkeys@pl\else \ltxkeys@err{Multiple key families: you need + prefix - \MsgBrk for command \string\ltxkeys@launchkeys}\ltxkeys@ehc + \MsgBrk for command \string\ltxkeys@launchkeys}\ltxkeys@ehd \fi }{}% \cptexpandsecond\ltxkeys@in@ti@lizekeys @@ -2946,9 +3013,9 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \cptexpandargonce{\cptfiltermergecsv[,]\ltxkeys@resa} \ltxkeys@tempc\nofilter }% - \ltxkeys@parse*0\ltxkeys@fams + \ltxkeys@listparse*0\ltxkeys@fams }% - \ltxkeys@parse*0\ltxkeys@prefs + \ltxkeys@listparse*0\ltxkeys@prefs \cptexpandargonce{\endgroup\expandafter\undefcs\expandafter \ltxkeys@cmdpf\expandafter\ltxkeys@setkeys \ltxkeys@cmdpf[#1]{#2}}\ltxkeys@resa @@ -2974,9 +3041,9 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \ltxkeys@makehdr{####1}% \ltxkeys@nonl@un@hk@ys }% - \ltxkeys@parse*0\ltxkeys@fams + \ltxkeys@listparse*0\ltxkeys@fams }% - \ltxkeys@parse*0\ltxkeys@prefs + \ltxkeys@listparse*0\ltxkeys@prefs } \robust@def*\ltxkeys@nonl@un@hk@ys{% \ifcsndefTF{\ltxkeys@hdr poxkeys}{}{% @@ -2992,13 +3059,16 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ }% }{}% }% - \ltxkeys@parse*0\ltxkeys@keys + \ltxkeys@listparse*0\ltxkeys@keys \letcsntocs{\ltxkeys@hdr poxkeys}\ltxkeys@tempc } \robust@def*\ltxkeys@setkeys{% \ltxkeys@rmfalse \ltxkeys@teststpl{\ltxkeys@testopt@c\ltxkeys@setkeys@a}% } +% Don't call \ltxkeysusekeys \ltxkeyssetkeys, since +% \ltxkeyssetkeys is used in mkii. +\newletcs\ltxkeysusekeys\ltxkeys@setkeys \newletcs\ltxkeys@setkey\ltxkeys@setkeys \robust@def*\ltxkeys@setrmkeys{% \ltxkeys@rmtrue @@ -3015,7 +3085,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \xifinsetTF{\x\detokenize{#2}\x} {\x.\x,\x;\x:\x+\x-\x=\x*\x^\x_\x/\x|\x[\x(\x)\x]\x}{% \ltxkeys@err{Invalid key list '#2': Something is wrong} - \ltxkeys@ehc + \ltxkeys@ehd }{}% \endgroup \ifcsndefTF{\ltxkeys@hdr executedkeys}{}{% @@ -3069,9 +3139,9 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ {\expandcsnonce{\ltxkeys@hdr#1setkeys}}}}% }% }% - \ltxkeys@parse*0\ltxkeys@fams + \ltxkeys@listparse*0\ltxkeys@fams }% - \ltxkeys@parse*0\ltxkeys@prefs + \ltxkeys@listparse*0\ltxkeys@prefs \oifblankTF{\the\toks@}{% \endgroup \ltxkeys@debug{==}{No #1-set keys found}% @@ -3093,12 +3163,12 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \ltxkeys@getkeyvalue##1=\ltxkeys@nil\ltxkeys@tval \ltxkeys@setkeys@c##1=\ltxkeys@nil }% - \ltxkeys@parse3{#2}% + \ltxkeys@listparse3{#2}% } \robust@def*\ltxkeys@setkeys@c#1=#2\ltxkeys@nil{% \ifinsetTF{\needvalue}{#1}{% \ltxkeys@err{\noexpand\needvalue pointer not allowed - \MsgBrk when setting keys}\ltxkeys@ehc + \MsgBrk when setting keys}\ltxkeys@ehd }{}% \ltxkeys@findp@inters\savevalue{#1}\ltxkeys@tkey{% \ltxkeys@svtrue @@ -3107,10 +3177,10 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ }% \let\CurrentKey\ltxkeys@tkey \ltxkeys@ifcsemptyTF\ltxkeys@tkey{% - \ifltxkeys@noval\else + \ifltxkeys@novalue\else \ltxkeys@err{No key specified for value '\expandcsonce\ltxkeys@tval' - \MsgBrk in families '\ltxkeys@fams'}\ltxkeys@ehc + \MsgBrk in families '\ltxkeys@fams'}\ltxkeys@ehd \fi }{% \oifinset@sp@TF,\ltxkeys@tkey\ltxkeys@nakeys{}{% @@ -3133,9 +3203,9 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \ltxkeys@makehdr\ltxkeys@tfam \ltxkeys@setkeys@e }% - \ltxkeys@parse*0\ltxkeys@fams + \ltxkeys@listparse*0\ltxkeys@fams }% - \ltxkeys@parse*0\ltxkeys@prefs + \ltxkeys@listparse*0\ltxkeys@prefs }{% \def\ltxkeys@do##1{% \def\CurrentPref{##1}% @@ -3147,10 +3217,10 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \ltxkeys@setkeys@e \ifltxkeys@kf\loopbreak\fi }% - \ltxkeys@parse*0\ltxkeys@fams + \ltxkeys@listparse*0\ltxkeys@fams \ifltxkeys@kf\loopbreak\fi }% - \ltxkeys@parse*0\ltxkeys@prefs + \ltxkeys@listparse*0\ltxkeys@prefs }% }% \ifboolTF{ltxkeys@kf}{% @@ -3179,9 +3249,9 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ }{% \ifboolTF{ltxkeys@st}{% \ifltxkeys@tracingkeys - \ltxkeys@getinnoval + \ltxkeys@getinnovalue \ltxkeys@debug{==}{Undefined key \ltxkeys@currtriple, - \InnocentVal, saved in \cptmakes{\ltxkeys@hdr rmkeys}}% + \InnocentVal, saved in \cptmakecs{\ltxkeys@hdr rmkeys}}% \fi \cptexpandargonce{\aftercsname{\cptfiltermergekv[,]}% {\ltxkeys@hdr rmkeys}}\CurrentKeyval\nofilter @@ -3197,7 +3267,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ }% }{% \ltxkeys@debug{==}{Key \ltxkeys@currtriple, saved as undefined}% - \ltxkeys@getinnoval + \ltxkeys@getinnovalue \cptexpandarg{\cptfiltermergecsv[;]\ltxkeys@undefinedkeys}{% \ltxkeys@ttpref,\ltxkeys@tfam,\ltxkeys@tkey,\InnocentVal }\nofilter @@ -3208,7 +3278,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ } \robust@def*\ltxkeys@setkeys@e{% \ifboolTF{ltxkeys@tracingkeys}{% - \ltxkeys@getinnovalnopad + \ltxkeys@getinnovaluenopad \ltxkeys@debug{==}{Setting\@space\ifltxkeys@preset preset\@space\fi key: \ltxkeys@currtriple,\InnocentVal}% }{}% @@ -3248,7 +3318,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \ifboolTF{ltxkeys@sv}{% \ltxkeys@addtosavedvalue\ltxkeys@tkey\ltxkeys@tval }{}% - \ifboolTF{ltxkeys@noval}{% + \ifboolTF{ltxkeys@novalue}{% \ifcsndefTF{\ltxkeys@hdr needvaluekeys}{\ltxkeys@testneedvaluekey}{}% \ifcsndefTF{\ltxkeys@hdr\ltxkeys@tkey @default}{% \ltxkeys@debug{==}{\ifltxkeys@preset Preset key\else Key\fi\@space @@ -3257,7 +3327,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \usename{\ltxkeys@hdr\ltxkeys@tkey @default}\ltxkeys@nil }{% \ltxkeys@err{No value specified for key '\ltxkeys@tkey'} - \ltxkeys@ehc + \ltxkeys@ehd }% }{% \s@expandarg\ltxkeys@replacepointers\ltxkeys@tval @@ -3299,7 +3369,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ }% \xaftercsname\reserved@a{\ltxkeys@hdr\ltxkeys@tkey @default}\ltxkeys@nil \ifboolTF{ltxkeys@tracingkeys}{% - \ltxkeys@getinnovalnopad + \ltxkeys@getinnovaluenopad \ltxkeys@debug{==}{% \ifltxkeys@preset Preset key\else Key\fi\@space '\ltxkeys@tkey', macro being executed now% @@ -3309,7 +3379,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \ifmacroTF{#1}{% \expandafter#1\expandafter{\ltxkeys@tval}\relax }{% - \ltxkeys@err{Faulty key macro '\detokenize{#1}'}\ltxkeys@ehc + \ltxkeys@err{Faulty key macro '\detokenize{#1}'}\ltxkeys@ehd }% \cpt@popstate\ltxkeys@setkeys\ltxkeys@keydepth \ltxkeys@debug{++}{% @@ -3342,7 +3412,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \edef\ltxkeys@tval{\unexpanded{#1}}% \ifltxkeys@swa \ifltxkeys@tracingkeys - \ltxkeys@getinnovalnopad + \ltxkeys@getinnovaluenopad \ltxkeys@debug{++}{Key '\ltxkeys@tkey', value inherited from '\ltxkeys@tempb'}% \fi @@ -3366,7 +3436,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ }% }% }{% - \ltxkeys@err{No value recorded for key '#2'}\ltxkeys@ehc + \ltxkeys@err{No value recorded for key '#2'}\ltxkeys@ehd \ltxkeys@r@placepointers }% }% @@ -3377,7 +3447,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \robust@def*\ltxkeys@st@revalue#1#2{% \ifinsetFT{,}{#1}{}{% \ltxkeys@err{Illegal multiple keys for - \string\ltxkeys@storevalue}\ltxkeys@ehc + \string\ltxkeys@storevalue}\ltxkeys@ehd }% \ifescapedTF{#2}{}{\cpt@notescapederr{#2}}% \ltxkeys@getsavedvalue{#1}{% @@ -3400,9 +3470,9 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \let#2=\reserved@a }% } -\robust@def*\ltxkeys@getinnoval{\ltxkeys@swatrue\ltxkeys@g@tinnoval} -\robust@def*\ltxkeys@getinnovalnopad{\ltxkeys@swafalse\ltxkeys@g@tinnoval} -\robust@def*\ltxkeys@g@tinnoval{% +\robust@def*\ltxkeys@getinnovalue{\ltxkeys@swatrue\ltxkeys@g@tinnovalue} +\robust@def*\ltxkeys@getinnovaluenopad{\ltxkeys@swafalse\ltxkeys@g@tinnovalue} +\robust@def*\ltxkeys@g@tinnovalue{% \begingroup \ltxkeys@ifcsemptyTF\ltxkeys@tval{% \def\InnocentVal{???}% @@ -3435,7 +3505,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \postgroupdef\InnocentVal\endgroup } \robust@def*\ltxkeys@keyvalerr{% - \ltxkeys@getinnovalnopad + \ltxkeys@getinnovaluenopad \ltxkeys@err{Erroneous value '\InnocentVal' for key or option \MsgBrk'\ltxkeys@tkey'}{Invalid key value encountered.}% } @@ -3445,7 +3515,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ } \robust@def*\ltxkeys@unkn@wnkeyhandler[#1]#2#3{% \begintoksgroup - \toks1{##1##2##3##4{\ltxkeys@getinnovalnopad#3}}% + \toks1{##1##2##3##4{\ltxkeys@getinnovaluenopad#3}}% \def\ltxkeys@do##1{% \ltxkeys@makepf{##1}% \def\ltxkeys@do####1{% @@ -3456,9 +3526,9 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ }% }% }% - \ltxkeys@parse1{#2}% + \ltxkeys@listparse1{#2}% }% - \ltxkeys@parse1{#1}% + \ltxkeys@listparse1{#1}% \endtoksgroup } \robust@def*\ltxkeys@logunknownkeys{% @@ -3498,13 +3568,13 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \expandafter\align@do\ltxkeys@tempc\\\\\\\\\\\\\\\\\\\@@ \edef\ltxkeys@msg{\expandcsonce\ltxkeys@msg####1\ltxkeys@skipb}% }% - \ltxkeys@parse1{##1,##2,##3,##4}% + \ltxkeys@listparse1{##1,##2,##3,##4}% \typeout{\ltxkeys@msg}% }% \def\ltxkeys@do##1{% \ltxkeys@splita##1\ltxkeys@nil }% - \ltxkeys@parse*0[;]\ltxkeys@tempa + \ltxkeys@listparse*0[;]\ltxkeys@tempa \typeout{\ltxkeys@skipa*******************}% \endgroup } @@ -3530,9 +3600,9 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \ltxkeys@makehdr{####1}% \ltxkeys@dis@bl@k@ys }% - \ltxkeys@parse*0\ltxkeys@fams + \ltxkeys@listparse*0\ltxkeys@fams }% - \ltxkeys@parse*0\ltxkeys@prefs + \ltxkeys@listparse*0\ltxkeys@prefs } \robust@def*\ltxkeys@dis@bl@k@ys{% \begingroup @@ -3568,7 +3638,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ family '\ltxkeys@tfam'}% }% }% - \ltxkeys@parse*0\ltxkeys@keys + \ltxkeys@listparse*0\ltxkeys@keys \cptpassexpanded{\endgroup \csn@def{\ltxkeys@hdr disabledkeys}{\ltxkeys@dkeys}% \noexpand\ltxkeys@disabletrue @@ -3578,7 +3648,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ } \robust@def*\ltxkeys@nostarform#1#2{% \if\detokenize{#1*.}% - \ltxkeys@err{No star (*) form of command \string#2}\ltxkeys@ehc + \ltxkeys@err{No star (*) form of command \string#2}\ltxkeys@ehd \fi } \robust@def*\ltxkeys@declareoption{% @@ -3699,7 +3769,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \robust@def*\ltxkeys@processoptions{% \ifcsndefTF{\@currname @\@currext @ltxkeys@beginprocessopt}{% \ltxkeys@err{\noexpand\ltxkeys@processoptions issued twice - in same \@cls@pkg '\@currname'}\ltxkeys@ehc + in same \@cls@pkg '\@currname'}\ltxkeys@ehd }{% \csn@def{\@currname @\@currext @ltxkeys@beginprocessopt}{}% }% @@ -3736,7 +3806,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ }% }% \ltxkeys@ifcsemptyTF\ltxkeys@classoptionslist{} - {\ltxkeys@parse*0\ltxkeys@classoptionslist}% + {\ltxkeys@listparse*0\ltxkeys@classoptionslist}% }% }% \edef\ltxkeys@tempa{\cpt@optionlist{\@currname.\@currext}}% @@ -3758,7 +3828,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ }% }% }% - \ltxkeys@parse*0\ltxkeys@keynames + \ltxkeys@listparse*0\ltxkeys@keynames \ifcsndefFT{\ltxkeys@hdr optionkeys}{}{% \letcstocsn\ltxkeys@tempb{\ltxkeys@hdr poxkeys}% \ifdefTF\ltxkeys@tempb{}{\def\ltxkeys@tempb{}}% @@ -3769,13 +3839,13 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ }% }% }% - \aftercsname{\ltxkeys@parse*0}{\ltxkeys@hdr optionkeys}% + \aftercsname{\ltxkeys@listparse*0}{\ltxkeys@hdr optionkeys}% \gletcsntocs{\ltxkeys@hdr poxkeys}\ltxkeys@tempb }% }% - \ltxkeys@parse*0\ltxkeys@fams + \ltxkeys@listparse*0\ltxkeys@fams }% - \ltxkeys@parse*0\ltxkeys@prefs + \ltxkeys@listparse*0\ltxkeys@prefs \undefcs\ltxkeys@poxlist \csn@def{\ltxkeys@hdr rmkeys}{}% \ltxkeys@pxopfalse @@ -3802,7 +3872,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \ltxkeys@ifk@yd@f }% }% - \ltxkeys@parse*0\ltxkeys@prefs + \ltxkeys@listparse*0\ltxkeys@prefs \ltxkeys@ifchcfd#1\endgroup } \robust@def*\ltxkeys@ifk@yd@f{% @@ -3812,7 +3882,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \cpt@choicefdtrue\loopbreak }{}% }% - \ltxkeys@parse*0\ltxkeys@fams + \ltxkeys@listparse*0\ltxkeys@fams } \robust@def*\ltxkeysglobal{\ltxkeys@globaltrue} \robust@def*\ltxkeysprotected{\ltxkeys@protectedtrue} @@ -3916,13 +3986,13 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \advance\@tempcnta\@ne \ifnum\@tempcnta>#1\relax \ltxkeys@err{Number of delimiters exceeds - number of parameters}\ltxkeys@ehc + number of parameters}\ltxkeys@ehd \fi \xifinsetTF{,\expandcsonce\ltxkeys@tempa,}% {,1,2,3,4,5,6,7,8,9,}{}{% \ltxkeys@err{Invalid delimiter syntax: \MsgBrk no digit [1-9] found before - delimiter}\ltxkeys@ehc + delimiter}\ltxkeys@ehd }% \csn@edef{d\ltxkeys@tempa}{\cpttrimspace{##2}}% \@do @@ -3934,7 +4004,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \ifx\ltxkeys@tempb\@gobble\else \expandafter\ifx\csname d1\endcsname\@empty\else \ltxkeys@err{First argument of command \string#2 is - \MsgBrk already delimited by '[]'}\ltxkeys@ehc + \MsgBrk already delimited by '[]'}\ltxkeys@ehd \fi \fi \fi @@ -3968,7 +4038,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \usename{#1@\cpttrimspace{##1}}% }{% \ltxkeys@err{Key '\cpttrimspace{##1}' not defined by - command '\@backslashchar#1'}\ltxkeys@ehc + command '\@backslashchar#1'}\ltxkeys@ehd }% }% \def\ifkeyval##1\then{% @@ -3976,7 +4046,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ \usename{if#1@\cpttrimspace{##1}}% }{% \ltxkeys@err{Key '\cpttrimspace{##1}' not defined by - command '\@backslashchar#1'}\ltxkeys@ehc + command '\@backslashchar#1'}\ltxkeys@ehd }% }% \def\ifkeyvalTF##1{% @@ -4216,7 +4286,7 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ }{% \ifblankTF{#1}{% \ltxkeys@err{Invalid empty value for 'keydepthlimit'} - \ltxkeys@ehc + \ltxkeys@ehd }{% \xdef\cpt@optionstacklimit{\number0#1}% }% @@ -4226,23 +4296,19 @@ $Id: ltxkeys.sty,v 0.0.3b 2012/10/14 09:00:00 Ahmed Musa Exp $ }{% \ltxkeys@setaliaskey{keydepthlimit}% } -\ltxkeys@declarebooloption[KV]<ltxkeys>[ltxkeys@]{pathkeys}[true]{% - \ifltxkeys@pathkeys - \ltxkeys@afterprocessoptions{\RequirePackage{pathkeys}}% - \fi +\ltxkeys@declarebooloptions[KV]<ltxkeys>[ltxkeys@]{% + tracingkeys,reservenopath +}[true]{} +\ltxkeys@declarebooloption[KV]<ltxkeys>[ltxkeys@]{allowemptypath}[true]{% + \ifltxkeys@allowemptypath\ltxkeys@useemptytrue\fi } -\ltxkeys@declarebooloptions[KV]<ltxkeys>[ltxkeys@] - {tracingkeys,reservenopath}[true]{} -\ltxkeys@declarebooloption[KV]<ltxkeys>[ltxkeys@]{allowemptypath} - [true]{\ifltxkeys@allowemptypath\ltxkeys@useemptytrue\fi} -\ltxkeys@executeoptions[KV]<ltxkeys> - {keyparser,keydepthlimit=4}\relax +\ltxkeys@executeoptions[KV]<ltxkeys>{keyparser,keydepthlimit=4}\relax \ltxkeys@processoptions*[KV]<ltxkeys>\relax \cpt@optioncleanup\ltxkeys@processedoptions -\robust@def*\ltxkeys@options#1{% +\robust@def*\setltxkeysoptions#1{% \ifblankTF{#1}{}{\ltxkeys@setkeys[KV]{ltxkeys}{#1}}% } |