I would like to make an symbol index which is sorted by occurence of symbol.

For example: Something like

... $\omega$\index{$\omega$} ... $A^P_k$\index{$A^P_k$} ... $\{\}$\index{$\{\}$}

should produce an index which first mentions $\omega$ then $A^P_k$ and then $\{\}$.

I did not find any option for makeidx, so I tried to use a workaround and define a command which does that for me:


In fact this works to some extend but some symbols get rejected (I do not know which one) and some will not be printed appropriate for example \is{$\langle \rangle$} results in the entry "hAB".

  • You find a transcript of MakeIndex workings in the .ilg file.
    – egreg
    Jan 15, 2012 at 10:12

3 Answers 3


The problem is that \index expands its contents when it appears as the argument to another command, while it doesn't if it appears at the top level, so with \is{$\langle\rangle$} you get, in the .idx file,

\indexentry{0@{$\delimiter "426830A \delimiter "526930B $}}{1}

and, in the .ind file,

\item {$\delimiter 426830A \delimiter 526930B $}, 1

(notice that the double quotes get lost).

Now TeX finds \delimiter followed by the number 426830, which is hexadecimal "6834E and since it's in normal operations, it typesets the math code "0068: in position "68 of font family 0 there's an h. Similarly, 526930 is hexadecimal "80A52, but in position "80 there's no character! So you get a roman h, followed by italics A and B. Wow!

A way out is telling TeX not to interpret the characters:


You can control the order of the things in the index by providing some additional information to the argument of the \index command.

By writing \index{<sort information by>@<information>}, you tell \index to put <information> in the index but sort it by <sort information by>.

For example, using the following:

  • \index{.a omega@$\omega$}
  • \index{.a alpha@$\alpha$}
  • \index{.b APK@$A^P_k$}
  • \index{.c \{\}@$\{\}$}
  • \index{a}
  • \index{A}

The entries in the index should be as follows:

  • $\alpha$;
  • $\omega$;
  • $A^P_k$;
  • ${}$;
  • A;
  • a.

In this example, I use . as a prefix for index material with mathematical content (it effectively forces the mathematical stuff before the letters), and <letter> as a presorting criterion.

The following shows how to adjust the \index command to make it 'sort' the indexes by occurrence. This solution is equivalent to the solution that was posted by egreg.


    \advance \index@counter by 1\relax

Here's another possibility that uses glossaries. You need an up-to-date version of glossaries, but you don't need to use makeindex or any other external application. Just run LaTeX twice.









Of if you find \ensuremath abhorrent:









Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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