diff options
author | Karl Berry <karl@freefriends.org> | 2012-11-06 22:34:41 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2012-11-06 22:34:41 +0000 |
commit | 2f6000f28f9662342c1cfe6e59abfdf345bd3a23 (patch) | |
tree | 355599dfbcbd8d58bafc0f0b60dd720bed14d8f5 | |
parent | 342ef68b3bd1c09a3acb309fbd8d9c253cbcefc4 (diff) |
keyreader (6nov12)
git-svn-id: svn://tug.org/texlive/trunk@28195 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Master/texmf-dist/doc/latex/keyreader/README | 8 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/keyreader/keyreader-example1.tex | 58 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/keyreader/keyreader-guide.cfg | 61 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/keyreader/keyreader-guide.pdf | bin | 232171 -> 232150 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/keyreader/keyreader-guide.tex | 26 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/keyreader/keyreader.sty | 140 |
6 files changed, 169 insertions, 124 deletions
diff --git a/Master/texmf-dist/doc/latex/keyreader/README b/Master/texmf-dist/doc/latex/keyreader/README index 25603641d83..af74a37d0ea 100644 --- a/Master/texmf-dist/doc/latex/keyreader/README +++ b/Master/texmf-dist/doc/latex/keyreader/README @@ -6,7 +6,11 @@ Ahmed Musa VERSION -Version 0.5, October 2012 +Version 0.5b, 2012/11/06 + +LOCATION ON CTAN + +macros/latex/contrib/keyreader SUMMARY @@ -28,7 +32,7 @@ shortcomings not withstanding). RELATED PACKAGES -xkeyval, ltxkeys, skeyval +xkeyval, ltxkeys, skeyval LICENSE diff --git a/Master/texmf-dist/doc/latex/keyreader/keyreader-example1.tex b/Master/texmf-dist/doc/latex/keyreader/keyreader-example1.tex index bf8c56d5348..6ca57dc2ac2 100644 --- a/Master/texmf-dist/doc/latex/keyreader/keyreader-example1.tex +++ b/Master/texmf-dist/doc/latex/keyreader/keyreader-example1.tex @@ -1,24 +1,59 @@ \documentclass{article} -\usepackage{keyreader} +\usepackage{keyreader}[2012/11/01] \usepackage{xcolor} \usepackage{graphicx} \makeatletter + +% Choice keys with braced default: +\krddefinekeys[JKV]{jorg}{% + choice/key1/{A/X}/{ + A/X.do=\def\currcolor{blue}, + A/Y.do=\def\currcolor{green}, + B/X.do=\def\currcolor{red}, + B/Y.do=\def\currcolor{magenta} + } + /\def\val{Value of key1: #1} + ; + choice/align/justified/{ + center.do=\def\curralign##1{\hfil##1\hfil}, + right.do=\def\curralign##1{\hfill##1}, + left.do=\def\curralign##1{##1\hfill}, + justified.do=\let\curralign\@iden + } + ; +} +\krdpresetkeys[JKV]{jorg}{key1=A/X,align=justified} +\newcommand\jorgcommand[2][]{% + \krdsetkeys[JKV]{jorg}{#1}% + \endgraf\bigskip + \parbox{\hsize}{\centering\textbf{\textcolor{\currcolor}{\val}}}% + \endgraf + \parbox{\hsize}{\curralign{\textcolor{\currcolor}{#2}}}% +} + +% Shadow box: \newdimen\shadowsize \krddefinekeys*[KV]{ebox}[mp@]{% bool/frame/true; - bool/shadow/true; + bool+/shadow/true// + \mp@shadowtrue + \@@warning{Invalid value for 'shadow': 'true' assumed} + ; cmd/framecolor/black; cmd/shadecolor/white; cmd/shadowcolor/gray; cmd/framesize/.4pt; cmd/boxsize/.1\columnwidth; cmd/shadowsize/1pt; - choice/align/center/ + choice+/align/center/ center.do=\let\mp@alignright\hfil\let\mp@alignleft\hfil, right.do=\let\mp@alignright\hfill\let\mp@alignleft\relax, left.do=\let\mp@alignright\relax\let\mp@alignleft\hfill, justified.do=\let\mp@alignright\relax\let\mp@alignleft\relax - //\@@warning{Invalid value for 'align'}; + // + \let\mp@alignright\hfil\let\mp@alignleft\hfil + \@@warning{Invalid value for 'align'; 'center' used} + ; } \savevaluekeys[KV]{ebox}{frame,framecolor,framesize} \krdpresetkeys[KV]{ebox}{% @@ -58,6 +93,7 @@ \begin{document} \parindent-60pt +% Shadow boxes: \scalebox{2}{% \ebox[shadecolor=brown!70]{ebox1}% \ebox[framecolor=magenta,boxsize=2cm,align=right]{ebox2}% @@ -65,4 +101,18 @@ \ebox[framesize=1pt,framecolor=green,shadowcolor=blue]{ebox4}% \ebox[frame=false,shadow,shadowcolor=yellow,framesize=.5pt]{ebox5}% } + +% Choice keys: +\def\name#1{\texttt{\textcolor{black}{#1}}} +\def\atext{% + \name{choice} keys of the \name{keyreader} package. +} +\jorgcommand[key1=A/X,align=justified]{\atext} +\jorgcommand[key1=A/Y,align=center]{\atext} +\jorgcommand[key1=B/X,align=right]{\atext} +\jorgcommand[key1=B/Y,align=left]{\atext} +\jorgcommand{\atext} +% Invalid value for key1 ('x+y' not allowed): +% \jorgcommand[key1=x+y]{\atext} + \end{document} diff --git a/Master/texmf-dist/doc/latex/keyreader/keyreader-guide.cfg b/Master/texmf-dist/doc/latex/keyreader/keyreader-guide.cfg deleted file mode 100644 index af803ae50e3..00000000000 --- a/Master/texmf-dist/doc/latex/keyreader/keyreader-guide.cfg +++ /dev/null @@ -1,61 +0,0 @@ -\ProvidesFile{keyreader-guide.cfg}% - [2012/10/10 v0.5 Configuration file for keyreader-guide (AM)] - -\amltxoptions{% - geometryoptions = {left=3cm,right=3cm,top=2.5cm,% - bottom=2.5cm,includeheadfoot}, - reviewdocument = false, - parindent = false, - toc = false, - frontpagestyle = empty, - pretitleskip = 0ex, - posttitleskip = 1ex, - presuptitleskip = 0ex, - postsuptitleskip = 0ex, - presubtitleskip = 0ex, - postsubtitleskip = 0ex, - natbiboptions = {numbers,sort&compress}, - cmdcolor = xmagenta1, - stylecolor = xgreen1, - speccolor = teal, - sectionheadcolor = blue -} - -\fancypagenos[% - textalign = center, - show-on-page-one = false, - show-page-numbers = true, - show-headrule = true, - show-footrule = false, - y-position = -.44\paperheight, - x-position = 0, - scale = 1, - angle = 0, - style = \textsc{Page~\thepage~of~\pageref{xwmlastpage}}, - left-header = The \textcolor{macrocolor}{keyreader} package, - right-header = \ttcl{black}{\today} -] - -\newwatermark[page=1,fontfamily=phv,fontsize=11pt,fontseries=m,align=center, - coordunit=pc,width=.978\paperwidth,angle=0,scale=1,xpos=-.62,ypos=31.2]{% - \xwmcolorbox[framesep=5pt,framerule=2pt,fillcolor=white, - outerframecolor=Orange,innerframecolor=brown,textalign=justified, - width=.978\paperwidth]{% - \normalfont\small\color{black}\vspace*{-1ex}% - \parbox{.95\paperwidth}{% - \vspace*{2ex}% - \begin{center}% - \sffamily\bfseries - \scalebox{4}{The \textcolor{blue}{keyreader} Package\titleref{t1,t2}}% - \endgraf\vspace*{1ex}% - \scalebox{2}{A robust interface to \pkg'{xkeyval}}% - \endgraf\vspace*{1ex}% - {\normalsize\normalfont\sffamily - \copyright\ Ahmed Musa 2010-\number\year}% - \end{center}% - \vspace*{2ex}% - }% - }% -} - -\endinput diff --git a/Master/texmf-dist/doc/latex/keyreader/keyreader-guide.pdf b/Master/texmf-dist/doc/latex/keyreader/keyreader-guide.pdf Binary files differindex 2dd2392b7c4..ed0c6538c91 100644 --- a/Master/texmf-dist/doc/latex/keyreader/keyreader-guide.pdf +++ b/Master/texmf-dist/doc/latex/keyreader/keyreader-guide.pdf diff --git a/Master/texmf-dist/doc/latex/keyreader/keyreader-guide.tex b/Master/texmf-dist/doc/latex/keyreader/keyreader-guide.tex index 23eaf5618f5..2d0490d9c2b 100644 --- a/Master/texmf-dist/doc/latex/keyreader/keyreader-guide.tex +++ b/Master/texmf-dist/doc/latex/keyreader/keyreader-guide.tex @@ -40,7 +40,7 @@ \def\abstractname{\textsf{Summary}} \begin{abstract} \small - The \pkg{keyreader} bundle is platform independent and provides robustness and some extensions to the \pkg'{xkeyval}. However, it is completely independent of the \pkg'{xkeyval}. It preserves braces in key values throughout parsing and saves estate when defining keys. Also, the command \fx{\krdsetkeys} allows unbalanced conditionals to be parsed as values of keys. Furthermore, when the command \fx{\krddefinekeys} is used, keys are initialized as soon as they are defined, and, unlike in the \pkg'{xkeyval}, admissible alternate values of choice keys can have individual callbacks. The looping macros of the \pkg'{xkeyval} are redefined, to increase robustness. The command \fx{\define@key} of the \pkg'{xkeyval} has had two of its subordinate commands redefined, to offset a complaint about the grabbing of the key's callback when defining keys with \fx{\define@key}. This user manual assumes that the reader is familiar with some of the functions and user interfaces of the \pkg'{xkeyval}. The \fx{\krdkeys} command ... Unlike the \pkg'{xkeyval}, the \pkg'{keyreader} can be loaded before \hx{\documentclass} and this feature doesn't affect its ability to later filter class options-list for options that have values. + The \pkg{keyreader} bundle is platform independent \latex package that provides robustness and some extensions to the \pkg'{xkeyval}. However, it isn't completely independent of the \pkg'{xkeyval}. It preserves braces in key values throughout parsing and saves estate when defining keys. Also, the command \fx{\krdsetkeys} allows unbalanced conditionals to be parsed as values of keys. Furthermore, when the command \fx{\krddefinekeys} is used, keys are initialized as soon as they are defined, and, unlike in the \pkg'{xkeyval}, admissible alternate values of choice keys can have individual callbacks. The looping macros of the \pkg'{xkeyval} are redefined, to increase robustness. The command \fx{\define@key} of the \pkg'{xkeyval} has had two of its subordinate commands redefined, to offset a complaint about the grabbing of the key's callback when defining keys with \fx{\define@key}. This user manual assumes that the reader is familiar with some of the functions and user interfaces of the \pkg'{xkeyval}. The \fx{\krdkeys} command ... Unlike the \pkg'{xkeyval}, the \pkg'{keyreader} can be loaded before \hx{\documentclass} and this feature doesn't affect its ability to later filter class options-list for options that have values. \end{abstract} \let\licensename\relax @@ -69,8 +69,7 @@ The \pkg'{keyreader} predated the \pkg'{ltxkeys} and was developed to make key parsing by the \pkg'{xkeyval} robust (in the sense of preserving outer braces in key values throughout parsing and enabling the parsing of key values with unbalanced conditionals), as well as reduce the amount of typing that is required for defining several keys. To achieve robustness in key parsing, the \fx{\setkeys} command of the \pkg'{xkeyval} has been patched and renamed \fx{\krdsetkeys}. The \pkg'{xkeyval}'s \fx{\setkeys} remains unchanged, to avoid breaking existing codes that rely on it's current form. Some other low-level commands of \pkg'{xkeyval} have been patched and renamed. The \pkg'{keyreader} provides commands for compactly defining and setting all types of key (ordinary, command, boolean, and choice). Also, the \pkg'{keyreader} introduces the concept of callbacks for the alternate/admissible values of choice keys defined via the command \fx{\krddefinekeys}. Moreover, when \fx{\krddefinekeys} is used, keys are automatically set/initialized as soon as they are defined. This provides default definitions for the key macros and functions. Boolean keys are initialized with a value of \hx{false} irrespective of their default values. -The \pkg'{keyreader} has been used as a development platform for the \pkg'{ltxkeys} because the \pkg'{xkeyval}, on which the \pkg'{keyreader} is based, has been quite stable for some years, its inherent -shortcomings not withstanding. Has the user ever tried to pass to \pkg'{xkeyval}'s \fx{\setkeys} an unbalanced conditional as the value of a key? He/she will quickly be hit by the error message \quoted{! Incomplete \hx{\ifx}; all text was ignored after line \ldots}, or something similar. This limitation has been removed by the \pkg'{keyreader}. +The \pkg'{keyreader} has been used as a development platform for the \pkg'{ltxkeys} because the \pkg'{xkeyval}, on which the \pkg'{keyreader} is based, has been quite stable for some years, its inherent shortcomings not withstanding. Has the user ever tried to pass to \pkg'{xkeyval}'s \fx{\setkeys} an unbalanced conditional as the value of a key? He/she will quickly be hit by the error message \quoted{! Incomplete \hx{\ifx}; all text was ignored after line \ldots}, or something similar. This limitation has been removed by the \pkg'{keyreader}\footnote{But, in general, parsing unbalanced conditionals isn't advisable in \tex.}. The packages in the \pkg{keyreader} bundle are ... @@ -190,7 +189,8 @@ The commands \ffxi'{\krdDeclareOption, \krdExecuteOptions, \krdProcessOptions} a center.do=\def\vcp@align{center}\def\w##1{#1##1}, left.do=\def\vcp@align{flushleft}, right.do=\def\vcp@align{flushright}, - justified.do=\def\vcp@align{relax}/ + justified.do=\def\vcp@align{relax} + / \ifkrdindef\else \def\xa##1{#1##1} \fi; @@ -200,20 +200,22 @@ The commands \ffxi'{\krdDeclareOption, \krdExecuteOptions, \krdProcessOptions} a |com(Setting keys with values having unbalanced conditionals:) \krdsetkeys[KV]{fam}{keye={\iffalse keye-value}} -\let\warning\@latex@warning@no@line \krddefinekeys*[KV]{fam}[mp@]{% ord/keya/default-a/\def\x##1{#1*##1}; bool/keyb/true/; - bool+/keyc/true//\@latexerr{Invalid value for keyc}; + bool+/keyc/true//\@latexerr{Invalid value for keyc}\@ehd; cmd/keyd/black; choice+/keye/center/ center.do=\let\mp@alignright\hfil\let\mp@alignleft\hfil, right.do=\let\mp@alignright\hfill\let\mp@alignleft\relax, left.do=\let\mp@alignright\relax\let\mp@alignleft\hfill, - justified.do=\let\mp@alignright\relax\let\mp@alignleft\relax - //\warning{Invalid value for keye}; + // + \let\mp@alignright\hfil\let\mp@alignleft\hfil + \@@warning{Invalid value for 'align'; 'center' assumed} + ; + ord/keyf/.na/\def\y##1{#1*##1}; |com(No default.) + bool+/keyg/true; |com(Will raise error when user input is invalid.) } - \finish{example} The braces around \quoted{green}, the value of \fx{keya}, will be preserved throughout parsing. It should be remembered that keys are automatically set as soon as they are defined by \fx{\krddefinekeys}. The boolean \fx{\ifkrdindef} is true when \fx{\krddefinekeys} is defining keys, and false otherwise. The essence of it is that since keys are set as soon as they are defined by \fx{\krddefinekeys}, some actions should not be executed at this time, until the keys are being set by the user. @@ -315,8 +317,7 @@ The output of the following example is shown in \sref{fig:1}: \begin{figure}[h!] \caption{Output of \sref{example:1}\label{fig:1}} \centerline{% - \includegraphics[viewport=141 642 416 674,clip,scale=1] - {keyreader-example1}% + \includegraphics[viewport=141 642 416 674,clip,scale=1]{keyreader-example1}% } \end{figure} @@ -326,6 +327,9 @@ The output of the following example is shown in \sref{fig:1}: The following change history highlights significant changes that affect user utilities and interfaces; changes of technical nature are not documented in this section. \begin{versionhist} + \begin{version}{0.5b}{2012/11/06} + \item Choice keys can't have outer-braced default or user-supplied values. Outer-braced values may not have been given in the state pattern. Hence the outer braces are removed automatically internally before matching the value against the singleton. Also, key values are no longer converted into lowercase before matching against the state pattern. + \end{version} \begin{version}{0.5}{2012/10/10} \item The \pkg'{keyreader} can now be loaded before \fx{\documentclass}. \end{version} diff --git a/Master/texmf-dist/tex/latex/keyreader/keyreader.sty b/Master/texmf-dist/tex/latex/keyreader/keyreader.sty index e30f0dcaf02..3b6ad1d7cfb 100644 --- a/Master/texmf-dist/tex/latex/keyreader/keyreader.sty +++ b/Master/texmf-dist/tex/latex/keyreader/keyreader.sty @@ -1,5 +1,5 @@ %++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% -% This is file 'keyreader.sty', version 0.5, October 2012. % +% This is file 'keyreader.sty', version 0.5b, 2012/11/06. % % % % This package and accompanying files may be distributed and/or % % modified under the conditions of the LaTeX Project Public License, % @@ -19,7 +19,7 @@ %++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% \ProvidesPackage{keyreader} - [2012/10/10 v0.5 Robust interfaces to xkeyval package (AM)] + [2012/11/06 v0.5b Robust interfaces to xkeyval package (AM)] \newdimen\krdz@ \ifcase \ifx\eTeXversion\@undefined\krdz@\else @@ -211,6 +211,9 @@ \csname @\ifnum\krd@pdfstrcmp{\detokenize{#1}}% {\detokenize{#2}}=0first\else second\fi oftwo\endcsname } +\def\krdifcond#1\fi{% + \csname @#1first\else second\fi oftwo\endcsname +} % If we were to use \krdtrimspace for \krdifbraced, then the need % for double \romannumeral will cause problems of premature expansion. % We need the \romannumeral below to make \krdifbraced expandable: @@ -230,6 +233,21 @@ \def\krd@ifbraced@d#1\krd@nil#2{% \krdifstrcmp{#1}{#2}\@secondoftwo\@firstoftwo } +% \krdstripouterbraces{<nr>}<cmd> +\protected\def\krdstripouterbraces#1#2{% + \begingroup + \@tempcnta\krdz@ + \expandafter\krd@stripouterbraces#2\krd@stripbrace{#2}{#1}% +} +\protected\def\krd@stripouterbraces#1\krd@stripbrace#2#3{% + \advance\@tempcnta\@ne + \krdifcond\ifnum\@tempcnta=#3\fi{% + \edef#2{\unexpanded{#1}}% + \edef\x{\endgroup\krdaftergr#2}\x + }{% + \krd@stripouterbraces#1\krd@stripbrace{#2}{#3}% + }% +} \def\krdoxdetok#1{\detokenize\expandafter{#1}} \def\krdusearg#1#2{% @@ -237,6 +255,7 @@ } \def\krdexpandonce#1{\unexpanded\expandafter{#1}} \def\krdnoexpandcs#1{\krdexpandonce{\csname#1\endcsname}} +\def\krdncsname{\expandafter\noexpand\csname} \protected\def\krdexpanded#1{% \begingroup \protected@edef\reserved@a{\endgroup#1}\reserved@a @@ -249,6 +268,9 @@ \protected\def\krdexpandsecondonce#1#2{% \krdexpanded{\unexpanded{#1}\krdexpandonce{#2}}% } +\def\krdaftergr#1{% + \edef\noexpand#1{\noexpand\unexpanded{\krdexpandonce{#1}}}% +} \protected\def\krdifescaped#1{% \begingroup \escapechar92\relax @@ -256,9 +278,6 @@ \expandafter\endgroup \csname @\ifx\x\@backslashchar first\else second\fi oftwo\endcsname } -\def\krdifcond#1\fi{% - \csname @#1first\else second\fi oftwo\endcsname -} % Eg, % \newcount\nr\nr=\tw@ % \def\do#1{% @@ -324,7 +343,6 @@ \edef#1{\unexpanded{#2}}% \krdcsvnormalize#1% } - \protected\def\krd@pushmacros#1#2#3{% \begingroup \global\advance#2\@ne @@ -622,7 +640,7 @@ {\@testopt\XKV@define@choicekey{choice\XKV@header}}}% } \def\XKV@define@choicekey[#1]#2{% - \def\XKV@macropf{#1#2}% + \edef\XKV@macropf{\krdtrimspace{#1}\krdtrimspace{#2}}% \@testopt{\XKV@d@fine@choicekey{#2}}{}% } \def\XKV@d@fine@choicekey#1[#2]#3{% @@ -632,7 +650,12 @@ \@ifnextchar[{\XKV@d@fine@ch@icekey{#1}}{\XKV@d@fine@ch@ic@key{#1}}% } \def\XKV@d@fine@ch@icekey#1[#2]{% - \XKV@define@default{#1}{#2}% + \edef\krd@default{\krdtrimspace{#2}}% + % Choice keys shouldn't have braced values: + \krdstripouterbraces{2}\krd@default + \krdexpanded{% + \noexpand\XKV@define@default{#1}{\krdexpandonce\krd@default}% + }% \XKV@d@fine@ch@ic@key{#1}% } \def\XKV@d@fine@ch@ic@key#1{% @@ -892,9 +915,10 @@ \edef\krd@macpref{\krdtrimspace{#3}}% \toks@{}% \def\krd@rej{^?^}% + \def\krd@defna{.na}% \def\krd@vals{}% - \def\krd@altlist@a{}% - \def\krd@altlist@b{}% + \let\krduserinput\relax + \let\krdorder\relax \def\krd@splita##1/##2/{\krd@splitb##1/##2/.}% \def\krd@splitb##1/##2/##3/##4/##5/##6/##7/##8/##9\krd@nil{% \edef\krd@type{\krdzapspace{##1}}% @@ -919,67 +943,81 @@ \ifin@\else \krd@err{Unknown key type '\krd@type'}\krd@ehd \fi - \@expandtwoargs\in@ - {,\krdoxdetok\krd@default,}{,\detokenize{true,false},}% - \edef\krd@vals{% - \ifx\krd@vals\@empty\else\krdexpandonce\krd@vals,\fi - \ifx\krd@default\krd@rej\else - \krd@name=\ifin@ false\else\krdexpandonce\krd@default\fi - \fi - }% % ord{0}cmd{1}bool{2}bool+{3}choice{4}choice+{5} \krdusearg\krd@gettypenr{\krd@type}% \ifnum\krd@typenr>\thr@@ - \def\reserved@a{% + \krdstripouterbraces{2}\krd@default + \ifcase0% + \ifx\krd@itemfour\@empty\else + \ifx\krd@itemfour\krd@rej\else + \ifx\krd@itemfour\krd@defna\else 1\fi\fi\fi\relax \krd@err{Empty nominations for choice key \krd@name}\krd@ehd - }% - \ifx\krd@itemfour\@empty - \reserved@a \else - \ifx\krd@itemfour\krd@rej - \reserved@a - \else - \krd@getaltlist{##4}% - \fi + \krd@getaltlist{##4}% \fi \fi + \@expandtwoargs\in@ + {,\krdoxdetok\krd@default,}{,\detokenize{true,false},}% + \edef\krd@vals{% + \ifx\krd@vals\@empty\else\krdexpandonce\krd@vals,\fi + \ifx\krd@default\krd@rej\else + \ifx\krd@default\krd@defna\else + \krd@name=\ifin@ false\else\krdexpandonce\krd@default\fi + \fi + \fi + }% \krdexpanded{% \toks@{\the\toks@ - \krdnoexpandcs{define@\krd@typefordef key}% - \ifnum\krd@typenr>\thr@@*\fi + \krdncsname define@\krd@typefordef key\endcsname \if\krd@plustype+\fi [\krd@prefix]{\krd@family}% \ifnum\krd@typenr>\krdz@[\krd@macpref]\fi {\krd@name}% \ifnum\krd@typenr>\thr@@ - [\unexpanded{\krduserinput\krdorder}]% - {\krdexpandonce\krd@altlist@a}% + [\krduserinput\krdorder]{\krdexpandonce\krd@altlist@a}% \fi - \ifx\krd@default\krd@rej\else\XKV@afterfi - [{\expandafter\krdifbraced\expandafter{\krd@default}% - {{{\krdexpandonce\krd@default}}}{\krdexpandonce\krd@default}}]% + \ifx\krd@default\krd@rej\else + \ifx\krd@default\krd@defna\else + [{\krdexpandonce\krd@default}]% + \fi \fi - {% callback1 + {% callback-1 \ifnum\krd@typenr>\thr@@ - \ifx\krd@itemfive\krd@rej\else\krdexpandonce\krd@itemfive\fi + \ifx\krd@itemfive\krd@rej\else + \ifx\krd@itemfive\krd@defna\else + \krdexpandonce\krd@itemfive + \fi + \fi \krd@executealt{########1}{\krdexpandonce\krd@altlist@b}% \else - \ifx\krd@itemfour\krd@rej\else\krdexpandonce\krd@itemfour\fi + \ifx\krd@itemfour\krd@rej\else + \ifx\krd@itemfour\krd@defna\else + \krdexpandonce\krd@itemfour + \fi + \fi \fi }% \if\krd@plustype - {% + {% callback-2 \ifnum\krd@typenr>\thr@@ \ifx\krd@itemsix\krd@rej \noexpand\krd@keyvalerr \else - \krdexpandonce\krd@itemsix + \ifx\krd@itemsix\krd@defna + \noexpand\krd@keyvalerr + \else + \krdexpandonce\krd@itemsix + \fi \fi \else \ifx\krd@itemfive\krd@rej \noexpand\krd@keyvalerr \else - \krdexpandonce\krd@itemfive + \ifx\krd@itemfive\krd@defna + \noexpand\krd@keyvalerr + \else + \krdexpandonce\krd@itemfive + \fi \fi \fi }% @@ -1027,8 +1065,11 @@ } \protected\def\krd@getaltlist#1{% \begingroup + \def\krd@altlist@a{}% + \def\krd@altlist@b{}% \def\krd@g@taltlist##1.do=##2.do=##3\krd@nil{% \edef\XKV@tempa{\krdtrimspace{##1}}% + \krdstripouterbraces{2}\XKV@tempa \edef\XKV@tempb{\krdoxdetok\XKV@tempa{\krdtrimspace{##2}}}% \def\@do####1####2{% \edef####1{% @@ -1043,14 +1084,21 @@ \krd@g@taltlist##1.do=.do=\krd@nil }% \krdfor{#1}% - \global\let\krd@altlist@a\krd@altlist@a - \global\let\krd@altlist@b\krd@altlist@b - \endgroup + \ifx\krd@altlist@a\@empty + \krd@err{No nominations for choice key}\@ehd + \def\krd@altlist@b{}% + \fi + \krdexpanded{\endgroup + \krdaftergr\krd@altlist@a\krdaftergr\krd@altlist@b + }% } \protected\def\krd@executealt#1#2{% \edef\reserved@a{\krdtrimspace{#1}}% + \krdstripouterbraces{2}\reserved@a \edef\reserved@a{\krdoxdetok\reserved@a}% - \def\reserved@b##1{% + % There may be parameters characters in #2. So hide #2 in a macro: + \edef\reserved@b{\unexpanded{#2}}% + \def\reserved@c##1{% \def\reserved@a####1##1####2####3\krd@nil{% \edef\reserved@a{\unexpanded{####2}}% \krdifx\reserved@a\krd@nnil{% @@ -1059,9 +1107,9 @@ ####2% }% }% - \reserved@a#2#1{\krd@nil}\krd@nil + \expandafter\reserved@a\reserved@b#1{\krd@nil}\krd@nil }% - \krdusearg\reserved@b{\reserved@a}% + \krdusearg\reserved@c\reserved@a } \def\krd@lengthofival{20} \protected\def\krd@getinnoval{% |