I've created a macro which highlights a word and sends it to the index
\newcommand{\indexthis}[1]{\textcolor{Maroon}{\textbf{#1}}\index{\MakeLowercase{#1}@{#1}}\xspace).
However the \MakeLowercase
command does not appear to work as words which appear at the beginning of the sentence are sent to the .idx
file with the capital letter in place. This then affects the sort order of the index as the capitalised words come first. Here's a minimal worked example
\documentclass{minimal}
\usepackage{makeidx}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\newcommand{\indexthis}[1]{\textcolor{Maroon}{\textbf{#1}}\index{\MakeLowercase{#1}@{#1}}\xspace}
\makeindex
%================================================================================================
\begin{document}
\indexthis{Aardvarks} keep out of the sun \\
\indexthis{Badgers} prefer the shade \\
But \indexthis{antelopes} adore sunshine \\
And \indexthis{lions} are sun addicts \\
\printindex
\end{document}
And here is a screenshot
The problem is that we have two A-Z lists, one for words which begin with uppercase letters, and one for words which begin with lowercase letters. Can anyone make changes to the macro to force the argument #1
into lowercase before sending it to the .idx
file? Alternatively is there a way to get makeindex
to ignore capital letters during sorting? Ta.
(NB there's a thread Applying \lowercase
to index entries which deals partly with this issue. However, the solution is a macro containing two arguments. I'm trying to both highlight and add to the index using only one argument, and I haven't been able to adapt this code)
\usepackage{xspace}
. if you don't care whether some of your index entries start with uppercase letters, then\newcommand{\indexthis}[1]{\textcolor{Maroon}{\textbf{#1}}\index{#1}\xspace}
would have them sorted in the right alphabetical order -- ordinarily,makeindex
doesn't make a distinction.\MakeLowercase{#1}@
and extra braces. so an entry with an initial caps will be sorted separately from an all-lowercase entry, and if two entries are otherwise the same (say "Aardvark" and "aardvark"), you will get two entries in the index -- but sorted next to one another.\MakeLowercase
not being expanded at the right time. the argument of an\index
command is written out verbatim (one should check to see what actually gets into the .idx file), and the whole shebang is then sorted by a "dumb" ascii sort. the extra braces may play a part, but that needs checking. i will look into this; i'm writing a tome on how to abolish stealthy glitches, and this looks like something i hadn't yet considered.