Index commands
17.2 Index commands
There are a few major forms of \index commands. They are discussed in this section, illustrated by the commands shown in Section 17.1.
Simple \index commands The index entry
Foo, Soo-Key, 2 was created by command 9,
\index{Foo, Soo-Key} This entry is an example of the simplest form of an index command:
\index{entry } The entry
lattice, 2 was created as command 5,
\index{lattice|textbf} Ignore, for the time being, the |textbf part. This entry has a subentry,
lattice, 2 distributive, 2
which was created by command 6,
454 Chapter 17 MakeIndex
\index{lattice!distributive} There is also a subsubentry,
lattice, 2 distributive, 2 complete, 2
which was created by command 7, \index{lattice!distributive!complete} The form of the \index command for subentries is \index{entry !subentry } and for subsubentries it is \index{entry !subentry !subsubentry }
Modifiers Command 5 \index{lattice|textbf}
produces a bold page number in the entry lattice. The command whose name follows the symbol | (in this case, the command name is textbf) is applied to the page number. For instance, if you want a large bold page number, then define the command \LargeBold as
\newcommand{\LargeBoldB}[1]{\textbf{\Large #1}} and type the \index command as \index{entry |LargeBold}
You can also modify \index commands to indicate page ranges: Main Theorem, 1
exposition, 1–2 The latter index entry has a page range. It was created with commands 3 and 8:
\index{Main Theorem!exposition|(} \index{Main Theorem!exposition|)}
17.2 Index commands 455
Separate an entry from its modifier with |, open the page range with (, and close it with ).
Modifiers can also be combined. The index commands \index{Main Theorem!exposition|(textbf}
\index{Main Theorem!exposition|)textbf} produce a bold page range.
Sorting control Observe the \index command
\index{pistar@$\Pi^{*}$ construction} This produces the entry
Π ∗ construction, 1 To place this entry in the correct place in the index, use a sort key. The general form of
an \index command with a sort key is \index{sortkey @entry } In this example, the sortkey is pistar. When the entries are sorted, the sortkey is
used to sort the entry. A few typical examples follow: Example 1 An \index command for G.I. ˇ Zitomirski˘ı,
\index{Zitomirskii@\v{Z}itomirski\u{\i}, G.I.} sorts ˇ Zitomirski˘ı with the Z entries.
If you used the command \index{\v{Z}itomirski\u{\i}, G.I.} Zitomirski˘ı would be sorted with the v’s. ˇ
Example 2 An \index command for the ˝ Ormester lemma, \index{Ormester@\H{O}rmester lemma} would sort ˝ Ormester lemma with the O entries.
If you used the command \index{\H{O}rmester lemma} Ormester lemma would be sorted with the H’s. ˝
456 Chapter 17 MakeIndex
Example 3 An \index command for truncated lattice, \index{truncated lattice@\emph{truncated} lattice} sorts truncated lattice with the t entries.
If you use the command \index{\emph{truncated} lattice} this would sort truncated lattice with the e’s.
Example 4 We want to place the symbol Truncat f , typed as \Trunc f (see Sec- tion 7.6.2) in the index, sorted as Trunc.
\index{$\Trunc f$} would place Truncat f near the beginning of the index, sorted with the $ symbol.
If you use the command \index{Trunc@$\Trunc f$} this would sort Truncat f with the T’s.
Sorting control and subentries If you want to place a subentry under an entry with a sort key, you must include the
sort key part of the entry as well: \index{sortkey @entry !subentry } For instance, \index{Zitomirskii@\v{Z}itomirski\u{\i}, G.I.!education}
You can also use a sort key for subentries (and subsubentries), such as \index{lattice!weakly distributive@
\emph{weakly} distributive} or, a more complicated example, \index{Zitomirskii@\v{Z}itomirski\u{\i}, G.I.!elementary
education@\textbf{elementary} education}
17.2 Index commands 457
Special characters Since the !, @, and | characters have special meanings within an \index command,
you need to quote those characters if you want them to appear as themselves. MakeIn- dex uses the double quote character (") for this purpose: "!, "@, and "|.
Because this usage makes the double quote a special character itself, it also has to
be quoted if you need to use it in an \index command: "". Example 1 To produce the entry Start here!, type the \index command as
\index{Start here"!}
Example 2 To produce the entry @ symbol, type the \index command as \index{"@ symbol}
Example 3 To produce the entry |A|, type the \index command as \index{"|A"|@$"|A"|$}
Cross-references It is easy to make a cross-reference to another index entry. For instance, to list dis-
tributive lattice by cross-referencing it to lattice, distributive, the command is \index{distributive lattice|seeonly{lattice,
distributive}} which produces the entry
distributive lattice, see lattice, distributive For non-AMS document classes, seeonly should be see.
A command of this form can be placed anywhere in the document.
Tip Put all cross-referencing \index commands in one place in your document, so they are easy to keep track of.
458 Chapter 17 MakeIndex
Placement of \index commands The principle is simple.
Rule
Placement of \index commands An \index command should:
1. Reference the correct page
2. Not introduce unwanted space into the typeset document
For example, you should avoid placing \index commands as shown here: Let $L$ be a distributive lattice
\index{lattice} \index{distributive lattice} that is strongly complete.
This placement may result in unwanted extra space following the word lattice: Let L be a distributive lattice that is strongly complete.
Note the placement of the \index commands in Section 17.1. In each case I have placed them as close to the referenced item as I could. If you place an index entry on a separate line, use % to comment out unwanted spaces including the end-of-line character (see Section 5.5.1), as in
Let $L$ be a distributive lattice \index{lattice}% \index{distributive lattice}% that is strongly complete.
Read also Section 18.5 on page breaks and index entries. Listing the forms of the \index command
We have discussed the following forms: \index{entry }
\index{entry !subentry } \index{entry !subentry !subsubentry } \index{entry |modifier } \index{entry |open/close modifier } \index{sortkey @entry }
17.3 Processing the index entries 459
\index{sortkey @entry !subentry } \index{sortkey @entry !subsortkey @subentry }
Of course, more combinations are possible; the following may be the longest form: \index{sortkey @entry !subsortkey @subentry %
!subsubsortkey @subsubentry |open/close modifier }