diff options
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r-- | Master/texmf-dist/doc/latex/keyreader/README | 2 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/keyreader/keyreader-guide-0dot2.pdf | bin | 0 -> 116557 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/keyreader/keyreader-guide-0dot2.tex (renamed from Master/texmf-dist/doc/latex/keyreader/keyreader-guide.tex) | 87 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/keyreader/keyreader-guide.pdf | bin | 107029 -> 0 bytes | |||
-rw-r--r-- | Master/texmf-dist/tex/latex/keyreader/keyreader.sty | 102 |
5 files changed, 130 insertions, 61 deletions
diff --git a/Master/texmf-dist/doc/latex/keyreader/README b/Master/texmf-dist/doc/latex/keyreader/README index b5fdc5d981b..f8b3c25df38 100644 --- a/Master/texmf-dist/doc/latex/keyreader/README +++ b/Master/texmf-dist/doc/latex/keyreader/README @@ -18,7 +18,7 @@ % % %+++++++++++++++++++++++++++++++++++++ LICENSE ++++++++++++++++++++++++++++++++++++++% % % -% This is file 'keyreader.sty', version 0.1. % +% This is file 'keyreader.sty', version 0.2. % % % % This package reads multiple keys to be defined by xkeyval.sty. % % % diff --git a/Master/texmf-dist/doc/latex/keyreader/keyreader-guide-0dot2.pdf b/Master/texmf-dist/doc/latex/keyreader/keyreader-guide-0dot2.pdf Binary files differnew file mode 100644 index 00000000000..d85c1c17a05 --- /dev/null +++ b/Master/texmf-dist/doc/latex/keyreader/keyreader-guide-0dot2.pdf diff --git a/Master/texmf-dist/doc/latex/keyreader/keyreader-guide.tex b/Master/texmf-dist/doc/latex/keyreader/keyreader-guide-0dot2.tex index a11013decd3..2ac2ad0cc4f 100644 --- a/Master/texmf-dist/doc/latex/keyreader/keyreader-guide.tex +++ b/Master/texmf-dist/doc/latex/keyreader/keyreader-guide-0dot2.tex @@ -18,7 +18,6 @@ \date{\textcolor{purple}{\today}\vadjust{\kern0ex}} \newcommand*\krsty[1]{\textcolor{xgreen1}{\texttt{#1}}\xspace} \newcommand*\krcmd[1]{\textcolor{xteal1}{\texttt{\@backslashchar#1}}\xspace} -\newcommand*\krcs[1]{\textcolor{xteal1}{\texttt{\string#1}}\xspace} \hypersetup{colorlinks=true,linkcolor=red,pdfpagemode=UseThumbs, implicit=true,breaklinks=true,pagebackref=true,backref=true, bookmarks=true,bookmarksnumbered=true,hyperfootnotes=true,debug=true, @@ -31,7 +30,7 @@ \begin{document} \DefineShortVerb{\+} -\title{The \texttt{\color{blue}keyreader} Package\footnote{Version 0.1.}} +\title{The \texttt{\color{blue}keyreader} Package\footnote{Version 0.2.}} \author{Ahmed Musa\\\email{a.musa@rocketmail.com}} \maketitle \thispagestyle{empty} @@ -46,9 +45,8 @@ \section{Motivation} -The elaborate and powerful \krsty{xkeyval} package introduced \krcmd{define@cmdkeys} and -\krcmd{define@boolkeys}, which permit the setting of multiple command keys and -boolean keys, but in each category those keys must have the same default value +The elaborate and powerful \krsty{xkeyval} package provides +\krcmd{define@cmdkeys} and \krcmd{define@boolkeys} for defining and setting multiple command keys and boolean keys, but in each category those keys must have the same default value and no key macro/function. This package seeks to remove these restrictions, so that multiple keys of all categories (ordinary keys, command keys, boolean keys, and choice keys) can be set at one go and those keys can have different @@ -62,7 +60,7 @@ key macros to the complementary keys. \section{Usage} -The package can be loaded in style files by +The package can be loaded in style and class files by \begin{krverbatim} \RequirePackage[options]{keyreader} \end{krverbatim} @@ -72,12 +70,13 @@ and in document files via \end{krverbatim} where the options and their default values are \begin{krverbatim} -parser=;, macroprefix=mp@, keyprefix=KV, keyfamily=myfamily. +parser=;, macroprefix=mp@, keyprefix=KV, keyfamily=myfamily, +xchoicelist=false. \end{krverbatim} The \krsty{parser} is the separator between the keys in the key list to be defined in one go (see examples in section~\ref{sec:examples}). All these options can be set dynamically by using the \krcmd{krsetup} macro: \begin{krverbatim} -\krsetup{parser=;,macroprefix=mp@,keyprefix=KV, - keyfamily=myfamily}. +\krsetup{parser=;, macroprefix=mp@, keyprefix=KV, + keyfamily=myfamily, xchoicelist=false}. \end{krverbatim} The main user interface is the \krcmd{define@keylist} macro, whose syntax is @@ -94,34 +93,54 @@ If the key list is available in a macro, say, \def\keylist{<key type/id>, <key>, <key value>, <key macro/function>; <another set of key specifiers>; etc}, \end{krverbatim} -then the keys can be defined by +then the keys can be defined by the starred form of \krcmd{define@keylist}: \begin{krverbatim} -\cmddefine@keylist\keylist. +\define@keylist*\keylist. \end{krverbatim} -\krcmd{cmddefine@keylist} takes a macro as argument, while \krcmd{define@keylist} accepts a key list. +\krcmd{define@keylist*} takes a macro as argument, while \krcmd{define@keylist} accepts a key list. -The \krcmd{kr@altlist} macro is needed for choice keys; it lists the alternate +The \krcmd{ChoiceKeyValues} macro is needed for choice keys; it lists the alternate admissible values for a choice key and thus can't be empty when a choice key -is being defined or set. It has to be defined or redefined each time a choice -key is being defined, if its contents (ie, those of \krcmd{kr@altlist}) change from -one choice key to the next one being defined. This, unfortunately, implies the restriction that no two choice keys can appear in one \krcmd{define@keylist} statement. This restriction can be easily lifted but at the cost of some complication and extra requirement for the package user. So far this hasn't been a severe limitation (to me, anyway). +is being defined. Its syntax is +\begin{krverbatim} +\ChoiceKeyValues{<key>}{<admissible key values>}. +\end{krverbatim} +To save tokens, the abbreviation \krcmd{CKVS} is provided for \krcmd{ChoiceKeyValues} and may be used in place of \krcmd{ChoiceKeyValues}. + +It has to be defined each time a choice key is being defined. For example, if we want to define two choice keys \krsty{align} and \krsty{election}, then before the call to \krcmd{define@keylist}, we have to set +\begin{krverbatim} +\CKVS{align}{center,right,left,justified} +\CKVS{election}{state,federal,congress,senate}. +\end{krverbatim} +It doesn't matter which choice key first gets a \krcmd{CKVS}. The prevailing key family, obtainable from \krcmd{kr@keyfamily}, is used internally by \krcmd{ChoiceKeyValues} to build distinct alternate values lists for choice keys. Unless the key family changes, you can't set two \krcmd{ChoiceKeyValues} for the same choice key. This will be possible only if the package option \krsty{xchoicelist} (meaning ``allow overwriting of choice list'') has been set \krsty{true}, either through \krcmd{documentclass}, \krcmd{usepackage}, or \krcmd{krsetup}. + +As mentioned earlier, the key family (and other package options) can be changed via +\begin{krverbatim} +\krsetup{parser=;,macroprefix=mp@,keyprefix=KV, + keyfamily=myfamily,xchoicelist=false}. +\end{krverbatim} + +Thus any number of choice keys can appear in one \krcmd{define@keylist} statement if their lists of alternate/admissible values have been set by \krcmd{CKVS}. + +In line with the philosophy of the \krsty{xkeyval} package, all the choice keys to be defined using this package require \krcmd{ChoiceKeyValues}: choice keys by definition have pre-ordained or acceptable values. \section{Examples} \label{sec:examples} Suppose we wish to define a set of keys \krsty{\{color,angle,scale,align\}}. The keys \krsty{color}, \krsty{angle} and \krsty{scale} will de defined using command keys, while the key \krsty{align} will be defined by choice keys. Assume that the \krsty{align} key can only assume the values \krsty{\{center,right,left,justified\}}, where the first three values would further imply \krcmd{centering}, \krcmd{flushright}, and \krcmd{flushleft}, respectively. Moreover, we assume that the key \krsty{scale} will be associated with a macro called \krcmd{mydo}, where \krcmd{do} is assumed defined elsewhere. The keys \krsty{color} and \krsty{angle} aren't associated with macros. Then we can go: \begin{krverbatim} -\def\kr@altlist{center,right,left,justified} +\CKVS{align}{center,right,left,justified} \def\f@align{% - \ifcase\kr@nr\relax + \ifcase\nr\relax \def\kr@align{\centering}% \or \def\kr@align{\flushright}% \or \def\kr@align{\flushleft}% \or - \let\kr@align\relax\fi + \let\kr@align\relax + \fi } \define@keylist{2,color,gray!25,;2,angle,45,; @@ -138,7 +157,9 @@ Hundreds of keys can be defined efficiently in this way, using very few tokens. As another example, we consider the following page setup keys: \begin{krverbatim} -\def\kr@altlist{center,right,left,justified} % reused +\CKVS{align}{center,right,left,justified} +\CKVS{election}{state,federal,congress,senate} +% |color(gray)need to be defined only once|normalcolor \define@keylist{% 3,boolvar,true,;1,paperheight,\paperheight,; @@ -147,6 +168,7 @@ As another example, we consider the following page setup keys: 2,textwidth,\textwidth,\f@textwidth; 1,evensidemargin,\evensidemargin,; 4,align,center,\f@align; + 4,election,congress,; 2,testdim,2cm,\long\def\f@testdim##1{A test dimension ##1 \par\bigskip}% } @@ -167,7 +189,7 @@ which have the following trivial key macros: \def\f@paperwidth{\wlog{`paperwidth' was defined as % ordinary key.}} \newcommand\f@align{% - \ifcase\kr@nr\relax + \ifcase\nr\relax \def\mp@align{\centering}% \or \def\mp@align{\flushright}% @@ -180,6 +202,23 @@ which have the following trivial key macros: \end{krverbatim} Again, once the keys have been defined, these macros can be reused. +The same set of keys can be defined via the starred form of \krcmd{define@keylist}: +\begin{krverbatim} +\def\keylist{% + 3,boolvar,true,;1,paperheight,\paperheight,; + 1,paperwidth,\paperwidth,\f@paperwidth; + 2,textheight,\textheight,\f@textheight; + 2,textwidth,\textwidth,\f@textwidth; + 1,evensidemargin,\evensidemargin,; + 4,align,center,\f@align; + 4,election,congress,; + 2,testdim,2cm,\long\def\f@testdim####1% + {Do something with ####1}% + % |color(gray) Note the number of parameter characters here. +} +\define@keylist*\keylist. +\end{krverbatim} + Since the keys have been defined, they can now be set. In the following, we set only two of the keys: \begin{krverbatim} \setkeys[KV]{myfamily}{align=right,testdim=3cm} @@ -211,7 +250,9 @@ After defining and setting the keys above, the following tokens can be used in a \begin{krverbatim} \begin{center} \begin{minipage}{\mp@textwidth} - \lipsum[1] % from the lipsum package + \lipsum[1] + % |color(gray)From the |emph(lipsum) package. + % |color(gray)The |emph(blindtext) package can also be used. \end{minipage} \end{center} @@ -300,7 +341,7 @@ and then do \begin{krverbatim} \define@keylist{3,boolone,true,\f@boolone}, \end{krverbatim} -which will execute \krcmd{f@boolone} when the key \krsty{boolone} is set. Once the key \krsty{boolone} has been defined by the above statement, the function \krcmd{f@boolone} may be redefined and reused many times, any time, even before the setting of the key \krsty{boolone}. It isn't the function \krcmd{f@boolone} that is used in defining the key \krsty{boolone}, but the meaning of \krcmd{f@boolone}. +which will execute \krcmd{f@boolone} when the key \krsty{boolone} is set. Once the key \krsty{boolone} has been defined by the above statement, the function \krcmd{f@boolone} may be redefined and reused many times, any time, even before the setting of the key \krsty{boolone}. It isn't the function \krcmd{f@boolone} that is used in defining the key \krsty{boolone}, but the ``meaning'' of \krcmd{f@boolone}. As another example, we may do \begin{krverbatim} diff --git a/Master/texmf-dist/doc/latex/keyreader/keyreader-guide.pdf b/Master/texmf-dist/doc/latex/keyreader/keyreader-guide.pdf Binary files differdeleted file mode 100644 index 1056b606804..00000000000 --- a/Master/texmf-dist/doc/latex/keyreader/keyreader-guide.pdf +++ /dev/null diff --git a/Master/texmf-dist/tex/latex/keyreader/keyreader.sty b/Master/texmf-dist/tex/latex/keyreader/keyreader.sty index f240c803946..5b28021c5b2 100644 --- a/Master/texmf-dist/tex/latex/keyreader/keyreader.sty +++ b/Master/texmf-dist/tex/latex/keyreader/keyreader.sty @@ -1,14 +1,14 @@ %+++++++++++++++++++++++++++++++++++++ LICENSE ++++++++++++++++++++++++++++++++++++++% % % -% This is file 'keyreader.sty', version 0.1. % +% This is file 'keyreader.sty', version 0.2. % % % % This package reads multiple keys to be defined by xkeyval.sty. % % % -% This work may be distributed and/or modified under the conditions of the LaTeX % -% Project Public License, either version 1.3 of this license or any later version. % -% The latest version of this license is in http://www.latex-project.org/lppl.txt % -% and version 1.3 or later is part of all distributions of LaTeX version % -% 2005/12/01 or later. % +% This package and accompanying files may be distributed and/or modified under % +% the conditions of the LaTeX Project Public License, either version 1.3 of % +% this license or any later version. The latest version of this license is in % +% http://www.latex-project.org/lppl.txt and version 1.3 or later is part of all % +% distributions of LaTeX version 2005/12/01 or later. % % % % The LPPL maintenance status of this software is 'author-maintained'. % % % @@ -52,20 +52,16 @@ \kr@ensurecode{059}{12}% ; \kr@ensurecode{038}{03}% & \ProvidesPackage{keyreader}% - [2010/01/01 v0.1 Read multiple keys for the xkeyval parser (AM)] + [2010/01/13 v0.2 Read multiple keys for the xkeyval parser (AM)] \NeedsTeXFormat{LaTeX2e}[1996/12/01] \@ifpackageloaded{xkeyval}{}{\RequirePackage{xkeyval}[2008/08/13]} \protected\long\def\kr@warn#1{\PackageWarningNoLine{keyreader}{#1}} \protected\long\def\kr@err#1{\PackageError{keyreader}{#1}{\@ehc}} \protected\long\def\kr@afterfi#1\fi{\fi#1} \def\kr@CommandListParser#1{% - \long\def\define@keylist##1{% - \mathchardef\kr@cntb=\z@ - \kr@readlist##1#1& - }% - \long\def\cmddefine@keylist##1{% - \mathchardef\kr@cntb=\z@% - \expandafter\kr@readlist##1#1& + \long\def\kr@define@keylist##1##2{% + \mathchardef\kr@tempcntb=\z@ + ##1\kr@readlist##2#1& }% \long\def\kr@readlist##1#1##2&{% \kr@ifblank{##1}{}% @@ -73,13 +69,13 @@ \edef\@i{\detokenize{##1}}% \edef\@ii{\detokenize{\stopread}}% \ifx\@i\@ii - \mathchardef\kr@cntb=\@ne + \mathchardef\kr@tempcntb=\@ne \stopread##2& \else \kr@define@key##1& \fi }% - \ifnum\kr@cntb=\z@ + \ifnum\kr@tempcntb=\z@ \kr@ifblank{##2}{}{\kr@readlist##2&}% \fi }% @@ -91,20 +87,34 @@ \define@cmdkey[KV]{keyreader}[kr@]{keyprefix}[KV]{} \define@cmdkey[KV]{keyreader}[kr@]{keyfamily}[fam]{} \define@cmdkey[KV]{keyreader}[kr@]{macroprefix}[mp@]{} +\define@boolkey[KV]{keyreader}[kr@]{xchoicelist}[true]{} \DeclareOptionX*{\kr@warn{Unknown option '\CurrentOption' ignored}} \ExecuteOptionsX[KV]<keyreader>{parser,keyprefix,keyfamily,macroprefix} \ProcessOptionsX*[KV]<keyreader>\relax \newcommand\krsetup[1]{\setkeys[KV]{keyreader}{#1}} -\def\kr@namedef#1{% - \ifcsname#1\endcsname - \def\reserved@a{#1}% - \@notdefinable +\def\kr@defcommand#1#2{% + \ifcsname#2\endcsname + \expandafter\ifx\csname#2\endcsname\relax\else + \def\reserved@a{#2}% + \expandafter\expandafter\expandafter\@notdefinable + \fi \else - \expandafter\def\csname#1\expandafter\endcsname + \expandafter#1\csname#2\expandafter\endcsname \fi } -\def\kr@nameuse#1{% - \ifcsname#1\endcsname\csname#1\expandafter\endcsname\fi +\def\kr@namedef#1{\kr@defcommand\def{#1}} +\def\kr@nameedef#1{\kr@defcommand\edef{#1}} +\def\kr@nameuse#1{\ifcsname#1\endcsname\csname#1\expandafter\endcsname\fi} +\def\kr@ifnameundef#1{% + \ifcsname#1\endcsname + \expandafter\ifx\csname#1\endcsname\relax + \expandafter\expandafter\expandafter\@firstoftwo + \else + \expandafter\expandafter\expandafter\@secondoftwo + \fi + \else + \expandafter\@firstoftwo + \fi } \long\def\kr@ifnextchar#1#2#3{% \new@ifnextchar \let\tmp@d=#1\def\tmp@a{#2}\def\tmp@b{#3}% @@ -119,13 +129,30 @@ \long\def\kr@csexpandonce#1{\expandafter\kr@expandonce\csname#1\endcsname} \@ifdefinable\stopread{\long\def\stopread#1&{\long\def\kr@remainder{#1}}} \long\def\kr@inputerr#1#2{\kr@err{Erroneous value '#1' for key '#2'}} -\mathchardef\kr@cnta=\z@\mathchardef\kr@cntb=\z@\mathchardef\kr@cntc=\z@ -\let\kr@altlist\@empty +\mathchardef\kr@tempcnta=\z@\mathchardef\kr@tempcntb=\z@ +\mathchardef\kr@tempcntc=\z@ +\protected\long\def\define@keylist{% + \kr@ifstar{\kr@define@keylist\expandafter}{\kr@define@keylist\@firstofone}% +} +\def\ChoiceKeyValues#1#2{% + \ifkr@xchoicelist + \expandafter\edef\csname kr@altlist@\kr@keyfamily @#1\endcsname{#2}% + \else + \kr@ifnameundef{kr@altlist@\kr@keyfamily @#1}{% + \kr@nameedef{kr@altlist@\kr@keyfamily @#1}{#2}% + }{% + \kr@err{You have attempted to set two \MessageBreak + \string\ChoiceKeyValues\space for the same choice key,\MessageBreak + in the same family}% + }% + \fi +} +\@ifdefinable\CKVS{\global\let\CKVS\ChoiceKeyValues} \def\kr@define@key#1,#2,#3,#4&{% \begingroup \protected@edef\x{\endgroup \ifcase#1\relax - \mathchardef\kr@cntc=\@ne + \mathchardef\kr@tempcntc=\@ne \or \noexpand\define@key[\kr@keyprefix]{\kr@keyfamily}% {#2}[#3]{\kr@expandonce{#4}}% @@ -137,23 +164,24 @@ [\kr@macroprefix]{#2}[#3]{\kr@expandonce{#4}}% {\unexpanded{\kr@inputerr{##1}{#2}}}% \or - \ifx\kr@altlist\@empty - \mathchardef\kr@cnta=\@ne - \fi + \kr@ifnameundef{kr@altlist@\kr@keyfamily @#2}{\mathchardef\kr@tempcnta=\@ne}{} \noexpand\define@choicekey*+[\kr@keyprefix]{\kr@keyfamily}{#2}% - [\unexpanded{\kr@val\kr@nr}]{\kr@altlist}[#3]% + [\unexpanded{\val\nr}]{\kr@nameuse{kr@altlist@\kr@keyfamily @#2}}[#3]% {\kr@expandonce{#4}}{\unexpanded{\kr@inputerr{##1}{#2}}}% \else - \mathchardef\kr@cntc=\@ne\relax + \mathchardef\kr@tempcntc=\@ne \fi }\x - \ifnum\kr@cnta=\@ne\kr@afterfi - \kr@err{'\string\kr@altlist' is empty: choicekey can't be defined. - \MessageBreak You need to first define '\string\kr@altlist' - \MessageBreak as a nonempty set. It is the list of - \MessageBreak alternates values for your choicekey.}% + \ifnum\kr@tempcnta=\@ne\kr@afterfi + \kr@err{% + Alternate key values list for '#2' is empty: + \MessageBreak choicekey can't be defined. + \MessageBreak You need to first define admissible + \MessageBreak key values through '\string\ChoiceKeyValues' + \MessageBreak for choice key '#2' + }% \fi - \ifnum\kr@cntc=\@ne\kr@afterfi + \ifnum\kr@tempcntc=\@ne\kr@afterfi \kr@err{Unknown key type/identifier '#1'}% \fi } |