[tex-eplain] Position of optional argument
Rodolfo Medina
rodolfo.medina at gmail.com
Mon Apr 27 18:03:20 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:
>
> \input eplain
>
> \makeatletter
>
> \def\test#1{%
> \def\test at arg{#1}%
> \@getoptionalarg\@test
> }
>
> \def\@test{%
> \message{^^JArg: \test at arg}%
> \message{^^JOptional arg: \@optionalarg}%
> }
>
> \makeatother
>
> \test{text}
> \test{text}[optional text]
>
> \bye
Thanks, but when I process the file I get error message:
$ tex test
This is TeX, Version 3.141592 (Web2C 7.5.5)
(./test.tex (/home/rodolfo/macros/eplain-3.2.tex)
Arg: text
Optional arg:
! Use of \test doesn't match its definition.
l.18 \test{
text}[optional text]
? h
If you say, e.g., `\def\a1{...}', then you must always
put `1' after `\a', since control sequence names are
made up of letters only. The macro here has not been
followed by the required stuff, so I'm ignoring it.
?
Besides, it's not clear to me how I can use that to add an optional argument
to, say, such a macro:
\def\mymacro#1{%
Hallo, #1!
}
Thanks again
Rodolfo
More information about the tex-eplain
mailing list