[tex-eplain] optional arguments
Karl Berry
karl at freefriends.org
Fri Aug 28 02:08:47 CEST 2009
\catcode`@=\letter
\def\residx{\@getoptionalarg\finresidx}
\def\finresidx#1{\ifx\@optionalarg\empty{\sidx{#1}}
\else{\sidx{#1}[\@optionalarg]}\fi}
And a result later. \residx[sub]{result}
[...]
However, what is produced in the index is the entry "result" with the
subentry "optionalarg ". (Note it also has an extra space.)
Looking at the .idx file, I see:
\indexentry{result!\@optionalarg }{1}
So evidently the \@optionalarg macro is not expanded in the call to
\sidx. I don't see any particularly easy workaround. Might have to
construct the second call \sidx in a macro and \edef it :(. Oleg?
The spurious space is a side effect of the non-expansion.
Sorry,
Karl
More information about the tex-eplain
mailing list