[tex-eplain] optional arguments
Dan Luecking
luecking at uark.edu
Mon Mar 23 17:18:31 CET 2009
At 07:10 AM 3/23/2009, Adam Fenn wrote:
> > \makeatletter
> >
> > \newtoks\arch at name
> > \newtoks\arch at loc
> >
> > \def\architect#1{%
> > \arch at name={#1}%
> > \@getoptionalarg\finisharchitect
> > }
> >
> > \def\finisharchitect{%
> > \arch at loc=\expandafter{\@optionalarg}%
> > \ifx\@optionalarg\empty
> > % No optional argument present.
> > \expandafter\sidx\expandafter{\the\arch at name}
> > \else
> > % One was present.
> > \edef\temp{architects!\the\arch at name, {\noexpand\it \the\arch at loc}}%
> > \expandafter\sidx\expandafter{\temp}%
> > \edef\temp{\the\arch at name, {\noexpand\it architect, \the\arch at loc}}%
> > \expandafter\sidx\expandafter{\temp}%
> > \fi
> > }
> >
> > \resetatcatcode
>
>I've just noticed that there is something not quite right here.
>
>If you run TeX on
>
>\architect{Smith, John}
>
>\architect{Smith}
>
>the index is correctly typeset as
>
>Smith, 1
>Smith, John, 1
>
>However, if you include the optional argument
>
>\architect{Smith, John}[London]
>
>\architect{Smith}[London]
>
>then the index is incorrectly typeset
>
>Smith, John, architect, of London, 1
>Smith, architect, of London
>
>Any ideas how I can sort this out?
What do the \indexentry commands look like in your idx file?
It seems to work for me.
Dan
Daniel H. Luecking
Department of Mathematical Sciences
University of Arkansas
"Dubito ergo cogito, cogito ergo sum" --Descartes
More information about the tex-eplain
mailing list