I want to prepare an index of symbols for a book I'm writing (using the memoir class). There is an obvious problem of how you order the symbols. Since many of them are non-alphabetic, I think that the order of appearance in the book is the best idea. I skimmed through the man page for makeindex, but didn't find any option for that (and I don't want to do things like \index{01@symbol}, \index{02@symbol} etc., for obvious reasons).

Bonus points for a solution where non-alphabetic symbols appear first (as a group), sorted in the order of appearance, and alphabetic ones after them, sorted lexicographically, like in



Banach space
  • Do something like \index{aaaaaaa\arabic{symbolcounter} @\somesymbol}\stepcounter{symbolcounter}?
    – Symbol 1
    Sep 18 '14 at 14:49
  • Thanks! I thought about it, too, but some time after posting the question. It might work, and if there's no package doing this, I'll probably end up writing one. ;)
    – mbork
    Sep 18 '14 at 15:53
  • Ha, I found out that my question is mostly duplicate of tex.stackexchange.com/q/41140/5626 .
    – mbork
    Sep 18 '14 at 15:55
  • Under that post egreg explained "hAB" without an implement. And Marc van Dongen gave an answer producing duplicated symbol-items.
    – Symbol 1
    Sep 18 '14 at 16:05
  • What do you mean by "duplicated"? (I didn't test the solutions there.)
    – mbork
    Sep 18 '14 at 16:15

Something like this?


  • \newsymbol{cos} gives this symbol ($\cos$) an unique id (= current value of symbolcounter). This number is stored in the macro symbolidofcos.
  • \symbolindex{cos} check whether this symbol appeared before. If not, it does \newsymbol{cos}. It then, no matter the symbol being new or old, writes informations into the index.
  • Symbols will be sorted according to their ids. Since ids are given in sequences, symbols will be shown in the order of their first appearances.

Here is the code

        \expandafter\edef\csname symbolidof#1\endcsname{\arabic{symbolcounter}}}
        \ifcsname symbolidof#1\endcsname\else\newsymbol{#1}\fi
        \index{~@(Symbols)!\csname symbolidof#1\endcsname @$\csname#1\endcsname$}}

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.