Next: , Previous: Equation references, Up: User definitions


4.12 Indexing

Eplain provides support for generating raw material for an index, and for typesetting a sorted index. A separate program must do the actual collection and sorting of terms, because TeX itself has no support for sorting.

Eplain can create hypertext links pointing from the index to the index terms (see Index hyperlinks).

Eplain's indexing commands were designed to work with the program MakeIndex, available from CTAN hosts in tex-archive/indexing/makeindex; MakeIndex is also commonly included in prepackaged TeX distributions. It is beyond the scope of this manual to explain how to run MakeIndex, and all of its many options. See http://www.ctan.org/tex-archive/indexing/makeindex.

The basic strategy for indexing works like this:

  1. For a document foo.tex, Eplain's indexing commands (e.g., \idx; see the section `Indexing terms' below) write the raw index material to foo.idx.

  2. MakeIndex reads foo.idx, collects and sorts the index, and writes the result to foo.ind.
  3. Eplain reads and typesets foo.ind on a subsequent run of TeX. See the section `Typesetting an index' below.

The texi2dvi program can help you automate this process (see Invoking Eplain).

If your document needs more than one index, each must have its own file. Therefore, Eplain provides the command \defineindex, which takes an argument that is a single letter, which replaces `i' in the filenames and in the indexing command names described below. For example,

     \defineindex{m}

defines the command \mdx to write to the file foo.mdx. Eplain simply does \defineindex{i} to define the default commands.

For each index defined with \defineindex{n}, Eplain provides a switch \ifndx which controls whether indexing commands write index entries to the corresponding index file. However, even when index term writing is disabled, indexing commands still do all other processing of their arguments, including typesetting of proof index terms (see Proofing index terms.

For example, if you write \idxfalse near the beginning of a document foo.tex (before the first indexing command), Eplain will not open the default index file (foo.idx) and the corresponding indexing commands (\idx, \sidx, etc.) will not write index entries there. This may be useful for draft compilations of a manuscript, e.g., to avoid the overhead of index file input/output.