diff options
author | Karl Berry <karl@freefriends.org> | 2012-01-19 22:47:43 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2012-01-19 22:47:43 +0000 |
commit | 0588a0a5e407004b82011594c3bf7fde2a003f71 (patch) | |
tree | 899a4a22629f6ee60f9c15f34220487cc2f5fedb /Master/texmf-dist/tex/latex/keyreader | |
parent | bf9553f10ccf89db30bcaff668b6c6df9c7fbe12 (diff) |
keyreader 0.4b (19jan12)
git-svn-id: svn://tug.org/texlive/trunk@25155 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/keyreader')
-rw-r--r-- | Master/texmf-dist/tex/latex/keyreader/keyreader-guide.cfg | 61 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/keyreader/keyreader.sty | 260 |
2 files changed, 270 insertions, 51 deletions
diff --git a/Master/texmf-dist/tex/latex/keyreader/keyreader-guide.cfg b/Master/texmf-dist/tex/latex/keyreader/keyreader-guide.cfg new file mode 100644 index 00000000000..22fe64bc33e --- /dev/null +++ b/Master/texmf-dist/tex/latex/keyreader/keyreader-guide.cfg @@ -0,0 +1,61 @@ +\ProvidesFile{keyreader-guide.cfg}% + [2012/01/14 v0.0.3 Configuration file for keyreader-guide (AM)] + +\amltxoptions{% + geometryoptions = {left=3cm,right=3cm,top=2.5cm,% + bottom=2.5cm,includeheadfoot}, + reviewdocument = false, + parindent = false, + toc = false, + frontpagestyle = empty, + pretitleskip = 0ex, + posttitleskip = 1ex, + presuptitleskip = 0ex, + postsuptitleskip = 0ex, + presubtitleskip = 0ex, + postsubtitleskip = 0ex, + natbiboptions = {numbers,sort&compress}, + cmdcolor = xmagenta1, + stylecolor = xgreen1, + speccolor = teal, + sectionheadcolor = blue +} +\fancypagenos[% + textalign = center, + show-on-page-one = false, + show-page-numbers = true, + show-headrule = true, + show-footrule = false, + y-position = -.44\paperheight, + x-position = 0, + scale = 1, + angle = 0, + style = \textsc{Page~\thepage~of~\pageref{xwmlastpage}}, + left-header = The \textcolor{macrocolor}{keyreader} package, + right-header = \ttcl{black}{\today} +] + +\newwatermark +[page=1,fontfamily=phv,fontsize=11pt,fontseries=m,align=center, + coordunit=pc,width=.978\paperwidth,angle=0,scale=1,xpos=-.62,ypos=31.2]{% + \xwmcolorbox[framesep=5pt,framerule=2pt,fillcolor=white, + outerframecolor=Orange,innerframecolor=brown,textalign=justified, + width=.978\paperwidth]{% + \normalfont\small\color{black}\vspace*{-1ex}% + \parbox{.95\paperwidth}{% + \vspace*{2ex}% + \begin{center}% + \sffamily\bfseries + \scalebox{4}{The \textcolor{blue}{keyreader} Package\titleref{t1,t2}}% + \endgraf\vspace*{1ex}% + \scalebox{2}{A robust interface to \pkg'{xkeyval}}% + \endgraf\vspace*{1ex}% + {\normalsize\normalfont\sffamily + \copyright\ Ahmed Musa 2010-\number\year}% + \end{center}% + \vspace*{2ex}% + }% + }% +} + +\endinput diff --git a/Master/texmf-dist/tex/latex/keyreader/keyreader.sty b/Master/texmf-dist/tex/latex/keyreader/keyreader.sty index a64ec1e7908..7db99a9a5d2 100644 --- a/Master/texmf-dist/tex/latex/keyreader/keyreader.sty +++ b/Master/texmf-dist/tex/latex/keyreader/keyreader.sty @@ -1,6 +1,6 @@ %++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% % % -% This is file 'keyreader.sty', version 0.4a, December 2011. % +% This is file 'keyreader.sty', version 0.4b, January 2012. % % % % This package and accompanying files may be distributed and/or % % modified under the conditions of the LaTeX Project Public License, % @@ -16,12 +16,12 @@ % implied warranties of merchantability and fitness for a particular % % purpose. % % % -% Copyright (c) 2011 Ahmed Musa (amusa22@gmail.com). % +% Copyright (c) 2010-2012 Ahmed Musa (amusa22@gmail.com). % % % %++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% \ProvidesPackage{keyreader} - [2011/12/23 v0.4a Robust xkeyval package interface (AM)] + [2012/01/14 v0.4b Robust interfaces to xkeyval package (AM)] \ifcase \ifx\eTeXversion\@undefined\z@\else \ifnum\eTeXversion<\tw@\z@\else\@ne\fi\fi @@ -39,7 +39,9 @@ \def\reserved@a{\endgroup \def\do##1,{% \ifx##1\end\else - \catcode##1\string=\the\catcode##1\expandafter\do\fi + \catcode##1\string=\the\catcode##1 % + \expandafter\do + \fi }% \edef\krd@restorecodes{\do035,064,123,125,061,059,\end,}% } @@ -54,7 +56,7 @@ \ifx#1\end\else \edef\krd@restorecodes{% \krd@restorecodes - \catcode#1=\the\catcode#1\relax + \catcode#1=\the\catcode#1 % }% \catcode#1=#2\relax \expandafter\do @@ -73,6 +75,21 @@ \protected\def\krdnewlet#1{\@ifdefinable#1\relax\let#1} \krdnewlet\krd@nil\relax \def\krd@nnil{\krd@nil} +\def\krdswap#1#2{#2#1} +\def\krd@quark{\@gobble\krd@quark} +\newcount\krd@csvdepth +\newif\ifkrdloopbreak +\newif\ifkrd@st +\newif\ifkrddef +\krdnewlet\krdloopbreak\krdloopbreaktrue +\begingroup +\catcode`\&=7 +\gdef\krdtrimspace#1{\krd@trimspace@a.#1& &} +\gdef\krd@trimspace@a#1 &{\krd@trimspace@b#1&} +\gdef\krd@trimspace@b#1{% + \krdexpandonce{\romannumeral-`\q\expandafter\noexpand\@gobble#1}% +} +\endgroup \protected\def\krdAfterEndPackage{% \krdifcsndef{\@currname.\@currext-krd@endpkghook}{}{% \@namedef{\@currname.\@currext-krd@endpkghook}{}% @@ -89,7 +106,6 @@ }% \unexpanded\expandafter{\@popfilename}% } -\newcommand*\krd@quark{\@gobble\krd@quark} \newcommand*\krdifdef[1]{% \krdifblank{#1}\@secondoftwo{% \ifx#1\@undefined @@ -117,8 +133,9 @@ \expandafter\krdifdef\csname#1\endcsname }% } +\def\krd@ifx@quark{\@gobble\krd@ifx@quark} \newcommand\krdifx[2]{% - \ifx#1#2\krd@quark + \ifx#1#2\krd@ifx@quark \expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi } \long\def\krdifblank#1{% @@ -137,14 +154,14 @@ }% }% } -\def\krdifswitch@aux#1#2\krd@nil{% +\def\krd@ifswitch@aux#1#2\krd@nil{% \krdifblank{#2}\@secondoftwo\@firstoftwo } \def\krdifswitch#1{% \krdifblank{#1}{% \@secondoftwo }{% - \expandafter\krdifswitch@aux\romannumeral-`\q#1\krd@nil{% + \expandafter\krd@ifswitch@aux\romannumeral-`\q#1\krd@nil{% \if#1\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi }{% \@latex@error{Invalid switch '#1'}\@ehc @@ -154,7 +171,7 @@ \krdifx\pdfstrcmp\@undefined{% \RequirePackage{pdftexcmds}% \krdifx\pdf@strcmp\@undefined{% - \cpt@err{Neither \string\pdfstrcmp nor \string\pdf@strcmp exists}\@ehc + \cpt@err{Neither '\string\pdfstrcmp' nor '\string\pdf@strcmp' exists}\@ehc }{% \let\krd@pdfstrcmp\pdf@strcmp }% @@ -165,8 +182,20 @@ \csname @\ifnum\krd@pdfstrcmp{\detokenize{#1}}% {\detokenize{#2}}=0first\else second\fi oftwo\endcsname } -\def\krdifbraced#1{\krd@ifbraced#1\krd@nil{#1}} -\def\krd@ifbraced#1\krd@nil#2{% +\def\krdifbraced#1{% + \expandafter\krdswap\expandafter{% + \expandafter{\romannumeral-`\q\krd@ifbraced@a{#1}}% + }{% + \expandafter\krd@ifbraced@d\romannumeral-`\q\krd@ifbraced@a{#1}\krd@nil + }% +} +\begingroup +\catcode`\&=7 +\gdef\krd@ifbraced@a#1{\krd@ifbraced@b.#1& &} +\gdef\krd@ifbraced@b#1 &{\krd@ifbraced@c#1&} +\gdef\krd@ifbraced@c#1{\expandafter\noexpand\@gobble#1} +\endgroup +\def\krd@ifbraced@d#1\krd@nil#2{% \krdifstrcmp{#1}{#2}\@secondoftwo\@firstoftwo } \def\krdexpandonce#1{\unexpanded\expandafter{#1}} @@ -183,20 +212,6 @@ \protected\def\krdexpandsecondonce#1#2{% \krdexpanded{\unexpanded{#1}\krdexpandonce{#2}}% } -\newcount\krd@csvdepth -\newif\ifkrd@lb -\newif\ifkrd@st -\krdnewlet\krdloopbreak\krd@lbtrue -\begingroup -\catcode`\&=7 -\gdef\krdtrimspace#1{\krd@trimspace@a.#1& &} -\gdef\krd@trimspace@a#1 &{\krd@trimspace@b#1&} -\gdef\krd@trimspace@b#1{% - \krdexpandonce{\romannumeral-`\q - \expandafter\noexpand\@gobble#1}% -} -\endgroup - % Eg, % \newcount\nr\nr=\tw@ % \def\do#1{% @@ -215,35 +230,92 @@ {}{\do{#1}\krd@for@a#2\krd@nil}% }% } -\def\krd@loopdostack{} +% We redefine xkeyval's loops to increase robustness. +% We can't replace \@nil by \krd@nil here because xkeyval +% uses \@nil in calling these macros: +\protected\long\def\XKV@for@n#1#2#3{% + \edef#2{\unexpanded{#1}}% + \krdifx#2\@empty{}{% + \XKV@f@r#2{#3}#1,\@nil,% + }% +} +\protected\long\def\XKV@f@r#1#2#3,{% + \edef#1{\unexpanded{#3}}% + \krdifx#1\@nnil{}{#2\XKV@f@r#1{#2}}% +} +\protected\long\def\XKV@for@eo#1#2#3{% + \edef#2{\unexpanded{\XKV@f@r#2{#3}}}% + \expandafter#2#1,\@nil,% +} +\protected\long\def\XKV@whilist#1#2#3\fi#4{% + #3\relax + \expandafter\@firstofone + \else + \expandafter\@gobble + \fi + {\expandafter\XKV@wh@list#1,\@nil,\@nnil#2#3\fi{#4}{}}% +} +\long\def\XKV@wh@list#1,#2\@nnil#3#4\fi#5#6{% + \edef#3{\unexpanded{#1}}% + \krdifx#3\@nnil{% + \def#3{#6}\@gobble + }{% + #4\relax + \expandafter\@firstofone + \else + \def#3{#6}% + \expandafter\@gobble + \fi + }% + {#5\XKV@wh@list#2\@nnil#3#4\fi{#5}{#1}}% +} +\protected\def\KV@@sp@def#1#2{\edef#1{\krdtrimspace{#2}}} +\protected\def\XKV@sp@deflist#1#2{% + \edef#1{\unexpanded{#2}}% + \krdcsvnormalize#1% +} +\def\krd@loopdo@stack{} \protected\def\krd@pushloopdo{% \global\advance\krd@csvdepth\@ne \def\reserved@a##1{\expandafter\@gobble\string##1@% \romannumeral\krd@csvdepth}% \def\do##1{\let\noexpand##1\krdnoexpandcsn{\reserved@a{##1}}}% - \xdef\krd@loopdostack{% - \krdfor{\krd@loopdo,\ifkrd@lb,\krd@loopact@a,\krd@loopact@b}% - {\krdexpandonce\krd@loopdostack}% + \xdef\krd@loopdo@stack{% + \krdfor{\krd@loopdo,\ifkrdloopbreak,\krd@final@loopact,% + \krd@regular@loopact}% + {\krdexpandonce\krd@loopdo@stack}% }% \def\do##1{\let\krdnoexpandcsn{\reserved@a{##1}}\noexpand##1}% \krdexpanded{% - \krdfor{\krd@loopdo,\ifkrd@lb,\krd@loopact@a,\krd@loopact@b}% + \krdfor{\krd@loopdo,\ifkrdloopbreak,\krd@final@loopact,% + \krd@regular@loopact}% }% } \protected\def\krd@poploopdo{% \begingroup - \def\reserved@a##1##{\endgroup##1\gdef\krd@loopdostack}% - \expandafter\reserved@a\krd@loopdostack + \def\reserved@a##1##{\endgroup##1\gdef\krd@loopdo@stack}% + \expandafter\reserved@a\krd@loopdo@stack \global\advance\krd@csvdepth\m@ne } \protected\def\krd@testst#1{\@ifstar{\krd@sttrue#1}{\krd@stfalse#1}} + +% \krdlistloop[<parser>]{<list>}<\if...>\fi<ini-code><final-code><reg-code> +% When the conditional <\if...> isn't true, the regular code <reg-code> +% will be executed for every member of the list. +% <final-code> will be executed when the conditional <\if...> is true. +% <ini-code> may be used to first turn <\if...> off before commencing +% the loop. \ifkrdloopbreak may be used as the conditional in <\if...>. +% Both <ini-code> and <final-code> can be empty (ie, {}). +% Use '#1' in <final-code> and <reg-code> to access the current element +% of the list. \protected\def\krdlistloop{\krd@testst{\@testopt\krd@listloop,}} \protected\def\krd@listloop[#1]#2#3\fi#4#5#6{% \krd@pushloopdo \edef\krd@csvarg{\krdifbool{krd@st}\krdexpandonce\unexpanded{#2}}% \krdcsvnormalize[#1]\krd@csvarg - \def\krd@loopact@a##1{#5}% - \def\krd@loopact@b##1{#6}% + \def\krd@final@loopact##1{#5}% + \def\krd@regular@loopact##1{#6}% + % Initial code: #4\relax \def\krd@loopdo##1#1##2\krd@nnil{% \edef\krd@csvarg{\krdexpandonce{\@gobble##1}}% @@ -251,9 +323,9 @@ #3\relax \expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi {% - \expandafter\krd@loopact@a\expandafter{\krd@csvarg}\relax + \expandafter\krd@final@loopact\expandafter{\krd@csvarg}\relax }{% - \expandafter\krd@loopact@b\expandafter{\krd@csvarg}\relax + \expandafter\krd@regular@loopact\expandafter{\krd@csvarg}\relax \krd@loopdo.##2\krd@nnil }% }% @@ -392,6 +464,8 @@ } \endgroup \krd@setupnormalize{,} + +% Redefine \XKV@define@key to heed a complaint about argument grabbing: \protected\def\XKV@define@key#1{% \@ifnextchar[{\XKV@d@fine@k@y{#1}}{% \begingroup @@ -413,6 +487,9 @@ \XKV@ch@cksanitize{#1}#2,% \krdifbool{in@}{\krdcsvnormalize[,]#2}{}% } +% Don't apply the new schemes to \setkeys, because old calls to +% \setkeys will now discover that braces are preserved. This may +% break their codes: \protected\def\krdsetkeys{\XKV@testopta{\XKV@testoptc\krd@setkeys}} \protected\def\krd@setkeys[#1]#2{% \edef\krd@na{\unexpanded{#1}}% @@ -440,16 +517,16 @@ \def\reserved@a####1=####2\@nil{% \edef\reserved@a{\expandafter\krdtrimspace\expandafter{\@gobble####1}}% \krdifx\reserved@a\@empty{% - \expandafter\XKV@s@tk@ys##1==\@nil + \expandafter\krd@s@tk@ys##1==\@nil }{% \expandafter\krdifbraced\expandafter{\reserved@a}{% \edef\CurrentOption{% - \unexpanded{##1}={{{\krdexpandonce\reserved@a}}}% + \unexpanded{##1}={{\krdexpandonce\reserved@a}}% }% }{% \edef\CurrentOption{\unexpanded{##1}=\krdexpandonce\reserved@a}% }% - \expandafter\XKV@s@tk@ys\CurrentOption==\@nil + \expandafter\krd@s@tk@ys\CurrentOption==\@nil }% }% \reserved@a.% @@ -458,10 +535,74 @@ \expandafter\krd@s@tkeys@a\CurrentOption==\@nil }% } +% \XKV@s@tk@ys is responsible for the inability of +% xkeyval's \setkeys to handle unbalanced conditionals. So +% we redefine it here, but only for \krdsetkeys: +\protected\def\krd@s@tk@ys#1=#2=#3\@nil{% + \XKV@g@tkeyname#1=\@nil\XKV@tkey + \krdexpandargonce{\KV@@sp@def\XKV@tkey}\XKV@tkey + \krdifx\XKV@tkey\@empty{% + \krdifblank{#2}{}{% + \XKV@err{No key specified for value '\the\XKV@toks'}% + }% + }{% + \@expandtwoargs\in@{,\XKV@tkey,}{,\XKV@na,}% + \krdifbool{in@}{}{% + \XKV@knftrue + \KV@@sp@def\XKV@tempa{#2}% + \krdifbool{XKV@preset}{% + \XKV@s@tk@ys@{#3}% + }{% + \krdifbool{XKV@pl}{% + \XKV@for@eo\XKV@fams\XKV@tfam{% + \XKV@makehd\XKV@tfam + \XKV@s@tk@ys@{#3}% + }% + }{% + \XKV@whilist\XKV@fams\XKV@tfam\ifXKV@knf\fi{% + \XKV@makehd\XKV@tfam + \XKV@s@tk@ys@{#3}% + }% + }% + }% + \krdifbool{XKV@knf}{% + \krdifbool{XKV@inpox}{% + \krdifx\XKV@doxs\relax{% + \ifx\@currext\@clsextension\else + \let\CurrentOption\XKV@tkey\@unknownoptionerror + \fi + }{% + \XKV@doxs + }% + }{% + \krdifbool{XKV@st}{% + \XKV@addtolist@o\XKV@rm\CurrentOption + }{% + \XKV@err{Key '\XKV@tkey' undefined in families '\XKV@fams'}% + }% + }% + }{% + \krdifbool{XKV@inpox}{% + \krdifx\XKV@testclass\XKV@documentclass{% + \expandafter\XKV@useoption\expandafter{\CurrentOption}% + }{}% + }{}% + }% + }% + }% +} \protected\def\krdsetrmkeys{\XKV@testopta{\XKV@testoptc\krd@setrmkeys}} \protected\def\krd@setrmkeys[#1]{% \krdexpandargonce{\krd@setkeys[#1]}\XKV@rm } +% We alias xkeyval's \savekeys to \savevaluekeys: +\krdnewlet\savevaluekeys\savekeys +% We split xkeyval's \presetkeys (head and tail) into +% \krdpresetkeys (head only) and \krdpostsetkeys (tail only): +\protected\def\krdpresetkeys{\@testopt\krd@presetkeys{KV}} +\protected\def\krd@presetkeys[#1]#2#3{\presetkeys[#1]{#2}{#3}{}} +\protected\def\krdpostsetkeys{\@testopt\krd@postsetkeys{KV}} +\protected\def\krd@postsetkeys[#1]#2#3{\presetkeys[#1]{#2}{}{#3}} \protected\def\krd@disabledkey@err#1{% \@latex@error{Key '#1' has been disabled} {You can't set or reset key '#1' at this\MessageBreak @@ -487,11 +628,23 @@ }% } \edef\krd@hashchar{\string#} -\protected\def\krddefinekeys{\krd@testst{\@testopt\krd@d@finekeys{KRD}}} -\protected\def\krd@d@finekeys[#1]#2{\@testopt{\krd@d@f@nekeys{#1}{#2}}{krdmp@}} +\protected\def\krddefinekeys{% + \begingroup + \endlinechar\m@ne + \krd@testst{\@testopt\krd@d@finekeys{KRD}}% +} +\protected\def\krd@d@finekeys[#1]#2{% + \@testopt{\krd@d@f@nekeys{#1}{#2}}{krdmp@}% +} \protected\def\krd@d@f@nekeys#1#2[#3]#4{% + \expandafter\endgroup + \ifkrd@st + \def\krd@keyst{00}% + \else + \def\krd@keyst{01}% + \fi + \krddeftrue \begingroup - \let\ifkrd@keyst\ifkrd@st \edef\key@prefix{\krdtrimspace{#1}}% \edef\key@family{\krdtrimspace{#2}}% \edef\macro@prefix{\krdtrimspace{#3}}% @@ -508,7 +661,7 @@ \ifin@ \@latex@error{Bad key name '\detokenize{##2}'}\@ehc \fi - \ifkrd@keyst + \if\krd@keyst \krdifcsndef{\key@prefix @\key@family @##2}{% \@latex@error{Key '##2' already exists in family '\key@family'}\@ehc @@ -563,7 +716,8 @@ \fi {\key@name}% \ifnum\key@typenr=\thr@@ - [\unexpanded{\userinput\order}]{\krdexpandonce\krd@altlista}% + [\unexpanded{\krduserinput\krdorder}]% + {\krdexpandonce\krd@altlista}% \fi \krdifx\key@default\krd@rej{}{% [\expandafter\krdifbraced\expandafter{\key@default}% @@ -576,6 +730,7 @@ \krdifx\krd@resa\krd@rej{}{\unexpanded{##4}}% \fi }% + % Second branch of callback for '+' variants: \ifnum\key@typenr>\@ne{\noexpand\krd@keyvalerr}\fi }% }% @@ -589,6 +744,7 @@ \noexpand\krdsetkeys[\key@prefix]% {\key@family}{\krdexpandonce\key@vals}% }% + \krddeffalse } \protected\def\krd@keyvalerr{% \krd@getinnoval @@ -596,26 +752,28 @@ \MessageBreak'\XKV@tkey'}{Invalid key value encountered.}% } \protected\def\krd@getaltlist#1{% - \def\krd@g@taltlist##1.code=##2\krd@nil{% + \def\krd@g@taltlist##1.do=##2\krd@nil{% \edef\krd@tempa{\krdtrimspace{##1}}% - \edef\krd@tempb{\krdexpandonce\krd@tempa{\krdtrimspace{##2}}}% + \edef\krd@tempb{\detokenize\expandafter{\krd@tempa}{\krdtrimspace{##2}}}% \krdaddtolist*\krd@altlista\krd@tempa \krdaddtolist*\krd@altlistb\krd@tempb }% \krdlistloop[,]{#1}\ifx\end\@undefined\fi{}{}{% - \@expandtwoargs\in@{\detokenize{.code=}}{\detokenize{##1}}% + \@expandtwoargs\in@{\detokenize{.do=}}{\detokenize{##1}}% \krdifbool{in@}{% \krd@g@taltlist##1\krd@nil }{% - \krd@g@taltlist##1.code=\krd@nil + \krd@g@taltlist##1.do=\krd@nil }% }% } \protected\def\krd@executealt#1#2{% - \krdexpandsecond{\def\reserved@a##1}{\krdtrimspace{#1}}##2##3\krd@nil{% + \edef\reserved@a{\krdtrimspace{#1}}% + \edef\reserved@a{\detokenize\expandafter{\reserved@a}}% + \krdexpandsecond{\def\reserved@a##1}\reserved@a##2##3\krd@nil{% \edef\reserved@a{\unexpanded{##2}}% \krdifx\reserved@a\krd@nnil{% - \@latex@error{No alternate list for key '\XKV@tkey'}\@ehc + \@latex@error{No alternate list match for key '\XKV@tkey'}\@ehc }{% ##2% }% |