TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've created a macro which highlights a word and sends it to the index


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





\indexthis{Aardvarks} keep out of the sun \\
\indexthis{Badgers} prefer the shade \\
But \indexthis{antelopes} adore sunshine \\
And \indexthis{lions} are sun addicts \\



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)

share|improve this question
to actually run, your example needs \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. – barbara beeton Aug 20 '13 at 16:27
It's working now, and I don't understand what you did except remove the \lowercase command. Is it just a case of running makeindex enough times? – Nick Riches Aug 20 '13 at 17:42
what i did was remove the \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. – barbara beeton Aug 20 '13 at 17:54
Brill. So it was just a case of curly brackets after all that? – Nick Riches Aug 21 '13 at 17:36
i haven't checked this, but i think it may be at least partly a case of the \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. – barbara beeton Aug 21 '13 at 18:49



(deleted xspace as it is not needed here as the macro call ends with } so does not drop spaces)

share|improve this answer

Are you also concerned about singular/plural use? For example, it would be more usual to have a single index entry for lion rather than separate index entries for lion and lions? Here's a possible way of adjusting for singular/plural/uppercase/lowercase:








\Glspl{lion} or \gls{lion}.
\Gls{lion} or \glspl{lion}.

\Glspl{aardvark} or \gls{aardvark}.
\Gls{aardvark} or \glspl{aardvark}.

\Glspl{badger} or \gls{badger}.
\Gls{badger} or \glspl{badger}.

\Glspl{antelope} or \gls{antelope}.
\Gls{antelope} or \glspl{antelope}.



The result looks like:

Image of resulting document

The makeindex call is now

makeindex -s "test.ist" -t "test.glg" -o "test.gls" "test.glo"

where the document is called test.tex. Alteratively, you can just do makeglossaries test.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.