[texhax] Uppercase index entries

Philip TAYLOR P.Taylor at Rhul.Ac.Uk
Thu Mar 3 18:40:25 CET 2005


Michael Barr wrote:

[snip]

 > Despite trying putting \expandafter in various places, the only index
 > entries I ever got were
 >
 >   \item \uppercase {B}arr, 1
 >   \item \uppercase {m}ichael, 1
 >
 > Does anyone know how to actually carry this out?
 >
 > michael Barr

\uppercase (and \lowercase) don't expand, so
\expandafter of itself isn't going to help.
If I understand the question correctly, your
authors have used \index {whatever}, and
you would like this to come out as

	\indexentry {Whatever} {<pagenumber>}

regardless of how <whatever> was originally
entered.  If I'm wrong, stop me there!

If I'm right, then I think the following
might work :
========
\documentclass [12pt]{book}

\makeindex
\let \Index = \index
\def \index #1{\parse #1\endparse}
\def \parse #1#2\endparse
     {%
         \uppercase {\def \HEAD {#1}}%
         \lowercase {\def \TAIL {#2}}%
         \edef \INDEXENTRY {\HEAD \TAIL}%
         \expandafter \expandafter \expandafter \Index
             \expandafter {\INDEXENTRY}%
     }

\begin {document}

aaa
\index{AAA}
\newpage
bbb
\index{Bbb}
\newpage
ccc
\index{ccc}
\newpage
ddd
\index{ddD}

\end {document}

========

Philip TAYLOR



More information about the texhax mailing list