[tex-eplain] sidx & optional arguments

Oleg Katsitadze olegkat at gmail.com
Tue Sep 14 04:47:45 CEST 2010


On Fri, 06 Aug 2010 13:33:13 +0100, Laszlo Hosszu <l.l.hosszu at shef.ac.uk> said:
> Enclosing with \makeatletter...\makeatother works, but the The macro does not seem to
> recognise the presence of the optional argument, and goes to the "else" statement
> regardless.
>
> %%%%%%%%%%%%%%%%%%%%%%%
>
> \makeatletter
> \def\finresidx#1{%
>   \ifx\@optionalarg\empty
>     \sidx{#1}%
>   \else
>     \toks0={#1}%
>     \toks2=\expandafter{\@optionalarg}%
>     \edef\temp{\noexpand\sidx{\the\toks0}[\the\toks2]}%
>     \temp
>   \fi
> }
> \makeatother
> \def\pagebreak{\vfil\eject}
>
> This is a test of \finresidx{Darwin}.
> \pagebreak
>
> This is a test of \finresidx{Darwin}[optional argument]. This is a test of
                    ^^^^^^^^^^
                    Try \residx here.

\finresidx is a helper for \residx and shouldn't be used directly.

HTH,
Oleg


More information about the tex-eplain mailing list