[tex-eplain] Position of optional argument

Rodolfo Medina rodolfo.medina at gmail.com
Mon Apr 27 23:13:08 CEST 2009


On Sun, Apr 26, 2009 at 07:16:55PM +0100, Rodolfo Medina wrote:

>>>> 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?



Oleg Katsitadze <olegkat at gmail.com> writes:

>>> Try this:
>>>
>>> [...]
>>>



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

> 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.

I still need help, thanks in advance.

Rodolfo



More information about the tex-eplain mailing list