[tex-eplain] [solved] Re: Position of optional argument

Rodolfo Medina rodolfo.medina at gmail.com
Tue Apr 28 19:41:13 CEST 2009


Rodolfo Medina <rodolfo.medina at gmail.com> writes:

>>>>> I've been using the eplain \@getoptionalarg and \@optionalarg commands in
>>>>> a certain macro.  It turns out to me that the optional argument must be
>>>>> put *before* the non optional argument.
>>>>>
>>>>> How can I set things - if possible - so to put it after it?

>> All right, now it seems to work:
>>
>> \catcode`@=\letter
>> \def\myhallo#1{%
>>   \def\temp <at> arg{#1}%
>>   \@getoptionalarg\@myhallo}
>>
>>     \def\@myhallo{%
>>       \message{^^JArg: \temp <at> arg}%
>>       \message{^^JOptional arg: \@optionalarg}%
>>   \ifx\@optionalarg\empty Hallo, \temp <at> arg!
>>   \else Hallo, \temp <at> arg and \@optionalarg!
>>   \fi
>>     }
>>
>>
>> \myhallo{John}[Mary]
>>
>> bla bla
>>
>> \myhallo{Paul}
>>
>>
>> \bye
>
>
>
> ...But still, something strange: I can't put the \@optionalarg in
> \definexref, and I need to:
>
> \input /home/rodolfo/macros/eplain-3.2
>
> \catcode`@=\letter
> \def\mymacro#1{%
>   \def\temp <at> arg{#1}%
>   \@getoptionalarg\@mymacro}
>
> \def\@mymacro{%
>   \ifx\@optionalarg\empty
>   \else
>     \definexref{\@optionalarg}{label}{}
>   \fi
>   \temp <at> arg
> }
>
> \mymacro{John}[Mary]
>
> \bye
>
>
> There are problems, as one can see processing the above example with tex or
> pdftex.


It seems that the problem disappears when closing \definexref in braces:

 {\definexref{\@optionalarg}{label}{}}

Rodolfo



More information about the tex-eplain mailing list