10.2 Defining the Entries of an Index

The data to make an index come from many individual indexing commands scattered throughout the Texinfo source file. Each command says to add one entry to a particular index; after formatting, the index will give the current page number or node name as the reference.

An index entry consists of an indexing command at the beginning of a line followed, on the rest of the line, by the entry.

For example, this section begins with the following five entries for the concept index:

@cindex Defining indexing entries
@cindex Index entries, defining
@cindex Entries for an index
@cindex Specifying index entries
@cindex Creating index entries

Each predefined index has its own indexing command—@cindex for the concept index, @findex for the function index, and so on, as listed in the previous section.

Index entries should precede the visible material that is being indexed. For instance:

@cindex hello
Hello, there!

Among other reasons, that way following indexing links (in whatever context) ends up before the material, where readers want to be, instead of after.

In Info, an index is usually formatted as a menu. Try to avoid using a colon in index entries, as this may confuse some Info readers. See The Parts of a Menu for more information about the structure of a menu entry.

By default, entries for a concept index are printed in a roman font and entries for the other indices are printed in a typewriter font. You may change the way part of an entry is printed with the usual Texinfo commands, such as @file for file names (see Marking Text, Words and Phrases), and @r for the normal roman font (see Fonts for Printing).

You may specify an explicit sort key for an index entry using @sortas following either the index command or the text of the entry. For example: ‘@findex @sortas{\} \ @r{(literal \ in @code{@@math})’ sorts the index entry this produces under backslash.

You may choose to ignore certain characters in index entries for the purposes of sorting. The characters that you can currently choose to ignore are ‘\’, ‘-’, ‘<’ and ‘@’, which are ignored by giving as an argument to the @set command, respectively, txiindexbackslashignore, txiindexhyphenignore, txiindexlessthanignore and txiindexatsignignore. For example, specifying ‘@set txiindexbackslashignore’ causes the ‘\mathopsup’ entry in the index for this manual to be sorted as if it were ‘mathopsup’, so that it appears among the other entries beginning with ‘M’. This avoids the need to provide explicit sort keys for index entries containing these characters.

When using these options, it is possible to get an index entry with an empty sort key. To avoid this, specify a @sortas directive in the index entry. For example:

@set txiindexbackslashignore
@findex @sortas{\} \