# How to order an index (a symbol table) based on first occurrence in text?

I'd like to add a symbol table to my math book. Since there is no meaningful/helpful way to order the index entries lexicographically, I'd like to order them chronologically, i.e. an index entry x will precede an index entry y if the first occurrence of x in the book precedes y's first occurrence. Is it possible to automate this kind of indexing using the MakeIndex program/makeidx package, or some other program/package?

P.S. To be more precise, I don't mean the absolute first occurrence of a symbol in the book; only those occurrences that I explicitly indicate should be considered.

• Package glossaries is able to achieve this, as far as I can remember
– user31729
May 11 '17 at 10:16

That is pretty much the default behaviour of the glossaries package. alpha_a and alpha_b got the same sort key so they are then sorted by first use. beta comes after them regardless of where it is used.

\documentclass{article}
\usepackage{glossaries}

\makenoidxglossaries

\newglossaryentry{alpha_a} {
name={\ensuremath{\alpha_a}},
sort={alpha},
}

\newglossaryentry{alpha_b} {
name={\ensuremath{\alpha_b}},
sort={alpha},
}

\newglossaryentry{beta} {
name={\ensuremath{\beta}},
sort={beta},