[texhax] FW: Re: Implementing control sequences with key values
Paul Isambert
zappathustra at free.fr
Mon Nov 15 12:34:36 CET 2010
Le 14/11/2010 22:47, Uwe Lueck a écrit :
> Correcting my 14.11.2010 19:02:33:
>>> Wolfgang Schuster wrote:
>>>> \def\direction#1=#2#3
>>>> {\def\currentdirection{#2#3}}
> I commented:
>> Wolfgang's code is redundant both in the definition and testing.
>> The core of his idea is:
>> \def\direction=#1 {\def\currentdirection{#1}}
> But
>
> \def\direction=#1#2 {\def\currentdirection{#1#2}}
>
> is superior in allowing ("optional"!) spaces after "="
> in using \direction.
And Wolfgang's original
\def\direction#1=#2#3 {...}
also allows optional space before "=", which might happen under some
circumstances. It actually allows any "filler".
>> Selon "Philip Taylor (Webmaster, Ret'd)" :
>>> 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
> I commented:
>> The problem (noted by Paul and Phil) is that it is somewhat difficult with TeX
>> to catch a "parameter word" with varying "word" delimiters. Wolfgang chose
>> delimiters "=" and " ", which of course fails when " " is replaced by anything else.
> But one might say that " " is the best choice for the right delimiter,
> and the documentation may say that a space as right delimiter
> is required, so its your fault if you try another one.
> (TeXbook somewhere: "If you are upset about this,
> you shouldn't be.")
>
> The semicolon would be another nice right delimiter,
> reminding of closing commands in other areas of computation.
Both solutions I have adopted in some places, instead of braces. You've
asked earlier why using the "=" syntax, and Phil mentioned plain TeX.
I'll elaborate and say: you can make do without braces in many cases,
something LaTeX seems to want its users to forget. I for one hate them,
for no good reason but anyway, and I always welcome alternatives
(starting with TeX's syntax for assignments).
Best,
Paul
More information about the texhax
mailing list