[tex-eplain] optional arguments

Oleg Katsitadze olegkat at gmail.com
Sun Mar 29 05:21:27 CEST 2009


On Thu, Mar 26, 2009 at 04:56:54PM +0000, Adam Fenn wrote:
> It is wrong (I think) because of this part of the macro
>
> \edef\temp{\the\arch at name, {\noexpand\it architect, \the\arch at loc}}%
> \expandafter\sidx\expandafter{\temp}%
>
> which makeindex orders entries under {\it architect. If you remove the command to
> put the word architects in italics the index is typeset correctly.

Removing "{\it" doesn't change anything for me.  I see what you mean,
but makeindex actually works correctly.  Consider this:

    architects
      Smith, John, London, 1
      Smith, London, 1

Now, without the markup, you should see that the sorting is correct --
J sorts before L.  What you want is a two-key sorting (author name as
the first key, location as the second), and makeindex doesn't support
that.  You could use only author name as the sort key, but then the
entries might end up sorted wrong (or even merged?) when there are two
authors with the same name from different locations.  Or you could
make location into a third-level key, but that would look ugly.

Maybe you can take a look at xindy, it might have something for this.

> Normally I would use something along the lines of
> 
> \sidx{architect@{\it architect}}
> 
> but I do not know how to insert this into the \architect macro so
> that it will work.

I include the revised \finisharchitect below, even though it doesn't
help with your problem.

Best,
Oleg


\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, \the\arch at loc
      @\the\arch at name, {\noexpand\it \the\arch at loc}}%
    \expandafter\sidx\expandafter{\temp}%
    \edef\temp{\the\arch at name, architect, \the\arch at loc
      @\the\arch at name, {\noexpand\it architect, \the\arch at loc}}%
    \expandafter\sidx\expandafter{\temp}%
  \fi
}


More information about the tex-eplain mailing list