[texhax] Implementing control sequences with key values
Paul Isambert
zappathustra at free.fr
Sun Nov 14 17:28:25 CET 2010
Selon "Philip Taylor (Webmaster, Ret'd)" <P.Taylor at rhul.ac.uk>:
>
>
> Wolfgang Schuster wrote:
> > \def\direction#1=#2#3
> > {\def\currentdirection{#2#3}}
> >
> > \tracingmacros1
> >
> > \direction=LTR Direction: \currentdirection\par
> > \direction=RTL Direction: \currentdirection\par
> >
> > \vskip\baselineskip
> >
> > \direction =LTR Direction: \currentdirection\par
> > \direction =RTL Direction: \currentdirection\par
> >
> > \vskip\baselineskip
> >
> > \direction = LTR Direction: \currentdirection\par
> > \direction = RTL Direction: \currentdirection\par
> >
> > \bye
>
> 11/10 for effort, Wolfgang, but there are some common cases
> for which it does not work :
>
> \direction = LTR\relax Direction: \currentdirection\par
> \direction = RTL\relax Direction: \currentdirection\par
>
> \vskip\baselineskip
>
> \direction = LTR%
> Direction: \currentdirection\par
> \direction = RTL%
> Direction: \currentdirection\par
If the direction is always made of three letters, as I think it is, then
\def\direction=#1#2#3{...}
might work well. Of course it forbids
\direction={RTL}
Anyway, Vafa, are you trying to mimick TeX assignments or key-value's? In the
former case (which is investigated here), nothing will be perfect. In the
latter, though, the "key = value" pair is normally well delimited (e.g. by a
comma or the end of the list), so the value can be easily retrieved.
Best,
Paul
More information about the texhax
mailing list