diff options
Diffstat (limited to 'Master/texmf-dist/doc/latex/skeyval/skeyval-pokayoke1.tex')
-rw-r--r-- | Master/texmf-dist/doc/latex/skeyval/skeyval-pokayoke1.tex | 166 |
1 files changed, 123 insertions, 43 deletions
diff --git a/Master/texmf-dist/doc/latex/skeyval/skeyval-pokayoke1.tex b/Master/texmf-dist/doc/latex/skeyval/skeyval-pokayoke1.tex index 2be16f1aa95..ed79d37585d 100644 --- a/Master/texmf-dist/doc/latex/skeyval/skeyval-pokayoke1.tex +++ b/Master/texmf-dist/doc/latex/skeyval/skeyval-pokayoke1.tex @@ -12,12 +12,9 @@ watermarkcolor=brown!80!yellow ]{skeyval-testclass} -%\show\@unusedoptionlist - -\skvifpackageloaded{xcolor}{}{\usepackage[dvipsname]{xcolor}} +\skvifpackageloadedTF{xcolor}{}{\usepackage[dvipsname]{xcolor}} \usepackage{lipsum} - % The command \cmdalign is just for illustrating how key values % may be expanded at key setting time: \def\cmdalign{justified} @@ -29,14 +26,18 @@ unknown-option, ]{skeyval-testpkg} -% Keys whose names are zapped internally: -\skvzcmdkeys[KV]{fam}[mp@]{provide value,give value}[true]{} +%+++++++++++ Keys whose names are zapped internally ++++++++++++++% + +\skvzcmdkeys[KV]{fam}[mp@]{provide value,give value}[some value]{} \skvzboolkeys[KV]{fam}[mp@]{provide value,give value}[true]{} -% Parenthesized keys are keys with names that have parentheses. +%++++++++++++++++++++++ Parenthesized keys +++++++++++++++++++++++% + +% Parenthesized keys are keys with names that have parentheses % The following is a key of 3 arguments. The default values are -% \x, \y, and \numexpr\x*2. -\skvpntkey[KV]{fam}{evaluate (?) as (?) using (?)}[\x\y{\numexpr\x*2}]{% +% \x, \y, and \numexpr\x*2 - since there are 3 arguments. +% +\skvpntkey[KV]{fam}{evaluate (?) as (?) using (?)}[{\x}{\y}{\numexpr\x*2}]{% \def\argone{#1}\def\argtwo{#2}\def\argthree{#3}% % '\detokenize{\pgfmath}' won't work here! \skvxifinTF{\relax\string\pgfmath}{\relax\detokenize{#3}}{% @@ -47,6 +48,7 @@ } % The above parenthesized key can be set as follows: +% \def\cmda{2} \skvsetkeys[KV]{fam}{% evaluate (\cmda) as (\cmdb) using (\pgfmathsetmacro\cmdb{\cmda*10}) @@ -56,29 +58,40 @@ \newcommand*\vgap{\endgraf\medskip} \def\keycval{xx} -%% +++++++++++++++ Examples of using \directkeys command +++++++++ %% +%% +++++++++++++++ Examples of using \directkeys command ++++++++++% % Note: When the value of a handler contains equality sign (=) or % comma (,), it should be enclosed in braces. +\directkeys*{% + % Defining new handlers that can't be overloaded: + .new reserved handlers={ + {.x handler,.x handlers}={ + \dirkeys@defhandlers{00}{#1} + }, + } +} + \directkeys*{ .exec=\skvtestcnt\z@, .prefix = KV1, .family = fam1, .holder prefix = mp@, .add paths={KV2/fam2,KV3/fam3}, - .ignore roots={KV2/fam2,KV3/fam3}, - .restore roots={KV2/fam2,KV3/fam3}, + .ignore paths={KV2/fam2,KV3/fam3}, + .restore paths={KV2/fam2,KV3/fam3}, .save initial values of keys, .initialize keys after define=false, .new keys = { .ord/keya/{dfta,dftb}/ + %\def\skvhp{my@} \def\cmda##1{#1*##1*#2}\logsetting - , + , .arg/keya/{#1,#2}, + % See argument of keyb below: .cmd/keyb/{1cm,2cm}/ \edef\boxht{\the\dimexpr#1*2\relax} - \edef\boxwd{\the\dimexpr#1*10\relax}, + \edef\boxwd{\the\dimexpr#2*2\relax}, .choice/keyc/center/{right,left,center,justified}, .bool/keyd/true, .cmd/keye/dfte/\def\cmde##1{##1#1}, @@ -102,66 +115,77 @@ .restore keys = keye, .link={keye2/keye}, % Choices for keye can be declared directly: - .estate pattern={keye,keye2}/{ + .state pattern expanded={keye,keye2}/{ 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 }, - .exec code ={ + .exec code={ \def\leftval{left}\def\rightval{right} \def\rrightval{\rightval} }, % key1 and key2 are undefined. They will be defined internally % with the default values of keyc and keyd: - .prepend style={ + .prepend slots={ key1/{keyc=.expanded{\rightval}},key2/{keyd=false} }, - .append style={ + .append slots={ key1/{keye=right,keyf=valf} }, % When key3 and key4 are set, use their expanded values to set keye: .elink={ {key3,key4}/keye }, - .style expand twice={ + .slot expand twice={ key5/{keyf=#1,keyg=#1} }, .set keys={ key3=.expand once{\leftval}, key5=.expand twice{\rrightval} }, - .prepend link={ - {key6,key7}/{keye,keyf},{key8,key9}/{keye,keyg} + .prepend links={ + {key6,key7}/{keye,keyf}, + {key8,key9}/{keye,keyg} }, .exec code=\skvsetkeys[KV1]{fam1}{key6=center}, % Set keya and keyb on previously declared and the following paths. % Enter known keys in \mysuccesslist. Try 14 families; stop when % 12 families have been hit (ie, keys have been set in them % successfully): + .exec code=\def\flukepaths{}, .search also set keys={ - .add prefixes={KV3,KV4}, - .add families={fam3,fam4}, + .paths={KX/famx,KV1/fam1,KV3/fam3,KV3/fam4,KV4/fam3,KV4/fam4}, + .ignore keys={keyc}, .try=14, - .upper goal=12, + .min success=10, + .max success=12, .success list=\mysuccesslist, - .kv={keya={val1,val2},keyb={1cm,2cm}} + .if any path fails={% + \edef\flukepaths{\skvaddlist,\flukepaths\skvcurrentpath} + }, + .if hits less than goal={\skvsetkeys[KV1]{fam1}{keyc=center}}, + .kv={keya={val1,val2},keyb={1cm,2cm},keyc} }, % .exec code={\show\mysuccesslist}, \directkeys*{ .exec=\skvtestcnt\z@\def\mysuccesslist{}, - .paths={KUA/fam1,KUB/fam2}, - .define keys={ - .ord/{keya,keyb,keyc}/.na/ + .paths={KUA/fam1,KUA/fam2,KUB/fam1,KUB/fam2}, + .define ordinary keys={ + {keya,keyb,keyc}/.na/ \def\y##1{#1*##1} \typeout{***}\logsetting + \skvsetkeys[KV1]{fam1}{keyc=center} , } }, % '.try set keys' works independent of previously declared paths: .try set keys={ - .prefixes={KUA,KUB,KUC}, - .families={fam1,fam2,fam3,fam4}, + .paths={ + KUA/fam1,KUA/fam2,KUA/fam3,KUA/fam4, + KUB/fam1,KUB/fam2,KUB/fam3,KUB/fam4, + KUC/fam1,KUC/fam2,KUC/fam3,KUC/fam4 + }, .try=8, .upper goal=4, .lower goal=2, @@ -169,10 +193,10 @@ .success list=\mysuccesslist, .kv={keya=vala,keyb=valb,keyc=valc} }, -% .exec code={\show\mysuccesslist}, +%.exec code={\show\mysuccesslist}, } -\dirkeys*{ +\directkeys*{ .exec=\skvtestcnt\z@\def\mysuccesslist{}, .paths={KUA/fam1,KUB/fam2}, .hp=mp@, @@ -184,18 +208,17 @@ % keya has no default but has a complex callback: .ord/keya/.na/{ \skvtestcnt\z@\def\mysuccesslistb{} - \dirkeys{ + \directkeys{ .path={KVX/famx}, - .sa set keys={% - .prefixes={KUA,KUB}, - .families={fam1,fam2}, + .search also set keys={% + .paths={KUA/fam1,KUA/fam2,KUB/fam1,KUB/fam2}, .try=8, .upper goal=4, .lower goal=1, .success list=\mysuccesslistb, .kv={keyb=valb} }, -% .exec code=\show\mysuccesslistb, +% .exec code=\show\mysuccesslistb, } } , @@ -211,8 +234,10 @@ }/.na/\@@warning{Invalid value '\detokenize{#1}' for keye2}, }, .try set keys={% - .prefixes={KUA,KUB}, - .families={fam1,fam2,fam3,fam4}, + .paths={ + KUA/fam1,KUA/fam2,KUA/fam3,KUA/fam4, + KUB/fam1,KUB/fam2,KUB/fam3,KUB/fam4 + }, .try=1, .upper goal=1, .lower goal=1, @@ -226,7 +251,6 @@ \makeatother \begin{document} - \title{The \texttt{\textcolor{blue}{skeyval}} Package\\[1ex] Version 1.1a\\[1ex] \textsf{Test document 1}} @@ -251,7 +275,6 @@ return to their own country. \hfill{\small Hieronymus Hornschuch (1608)}\endgraf \end{\mpfalign} - \begingroup \par\bigskip \noindent @@ -356,10 +379,21 @@ on their deeds. \lipsum[1] \end{collectbody} - \end{document} +%%+++++++++++++++++++++ Assigning arguments to keys +++++++++++++++++%% + +\skvsetdefaultprefix{myprefix} +\skvordkey{fam}{key1}[deafult1]{} +\skvcmdkey{fam}[mp@]{key2}[deafultx,defaulty]{% + \def\cmd##1{#1+#2+##1}% +} +\skvassignargs{fam}[.expanded]{key2}{#1,#2} +\def\valuex{valuex} +\def\valuey{valuey} +\skvsetkeys[myprefix]{fam}{key1=value1,key2={\valuex,\valuey}} + %%+++++++++++++++++++++ Examples of \skvmakekeys +++++++++++++++++++%% \skvmakekeys[ @@ -481,6 +515,52 @@ on their deeds. } \makeatother -% End of file skeyval-pokayoke1.tex +%++++++++++++++++++++++++ \ifcases ++++++++++++++++++++++++++++++% +\skvifcases b\then + case{a}{\def\x{do a}} + case{b}{\def\x{do b}} + case{c}{\def\x{do c}} + % default{\def\x{no match}} +\fi +\skvifcasse{x} + case{a}{\def\x{do a}} + case{b}{\def\x{do b}} + case{c}{\def\x{do c}} +\elsedo + \def\x{no match} +\endif + +\skvifcasse{x} + case{a}{\def\x{do a}} + case{b}{\def\x{do b}} + case{c}{\def\x{do c}} +%\elsedo +% \def\x{no match} +\endif + +%++++++++++++ Processing a key's value as a comma list +++++++++++% + +\skvordkeys[KV]{fam}{key1,key2}[default]{% + .arg{#1/#2}% + \def\x##1{##1*#1*#2}% +} +\def\aval{val1a/val1b} +\def\bval{val2a/val2b,val2c/val2d} +\skvsetkeys[KV]{fam}{% + key1=\aval, + key2=.eprocess list{\bval} +} + +\skvordkeys[KV]{fam}{key1}[default]{\def\x##1{##1*#1}} +\def\aval{val1a,val1b,val1c,val1d} +\def\bval{\aval} +\def\cval{\bval} +\skvsetkeys[KV]{fam}{% + key1=.expand once process list{\aval}, + key1=.expand twice process list{\bval}, + key1=.expand process list{\cval} +} + +% End of file skeyval-pokayoke1.tex |