[tex-eplain] optional arguments

Adam Fenn acwfenn at hotmail.com
Mon Mar 23 13:10:27 CET 2009

> I don't understand -- how can the order be wrong if the names are all
> the same? :)  But if you mean, relative to other ("non-architect")
> entries, then the problem is again with non-expanding \name, because
> makeindex sorts the string "\name" instead of what this macro stands
> for.

> \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}


the index is correctly typeset as

Smith, 1
Smith, John, 1

However, if you include the optional argument

\architect{Smith, John}[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?


 25GB of FREE Online Storage – Find out more
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://tug.org/pipermail/tex-eplain/attachments/20090323/ccdbd44e/attachment.html 

More information about the tex-eplain mailing list