Previous: , Up: Indices   [Contents][Index]

13.5 Defining New Indices

In addition to the predefined indices (see Predefined Indices), you may use the @defindex and @defcodeindex commands to define new indices. These commands create new indexing @-commands with which you mark index entries. The @defindex command is used like this:

@defindex name

New index names are usually two-letter words, such as ‘au’. For example:

@defindex au

This defines a new index, called the ‘au’ index. At the same time, it creates a new indexing command, @auindex, that you can use to make index entries. Use this new indexing command just as you would use a predefined indexing command.

For example, here is a section heading followed by a concept index entry and two ‘au’ index entries.

@section Cognitive Semantics
@cindex kinesthetic image schemas
@auindex Johnson, Mark
@auindex Lakoff, George

(Evidently, ‘au’ serves here as an abbreviation for “author”.)

Texinfo constructs the new indexing command by concatenating the name of the index with ‘index’; thus, defining an ‘xy’ index leads to the automatic creation of an @xyindex command.

Use the @printindex command to print the index, as you do with the predefined indices. For example:

@node Author Index
@unnumbered Author Index

@printindex au

The @defcodeindex is like the @defindex command, except that, in the printed output, it prints entries in an @code font by default instead of a roman font.

You should define new indices before the end-of-header line of a Texinfo file, and (of course) before any @synindex or @syncodeindex commands (see Texinfo File Header).

As mentioned earlier (see Predefined Indices), we recommend having a single index in the final document whenever possible, however many source indices you use, since then readers have only one place to look.

When creating an index, TeX creates a file whose extension is the name of the index (see Names of index files). Therefore you should avoid using index names that collide with extensions used for other purposes, such as ‘.aux’ or ‘.xml’. makeinfo already reports an error if a new index conflicts well-known extension name.

Previous: , Up: Indices   [Contents][Index]