Indexes (LaTeX2e unofficial reference manual (November 2018))

Next: Glossaries, Previous: Table of contents etc., Up: Front/back matter [Contents][Index]

### 25.2 Indexes

This document has an index.

    \documentclass{article}
    \usepackage{makeidx} \makeindex
      ...
    \begin{document}
      ...
    Recall Wilson's Theorem: \index{Wilson's Theorem}
    a number \( n>1 \) is prime if and only if the factorial of \( n-1 \)
    is congruent to \( -1 \) modulo~\( n \).
      ...
    \printindex
      ...

The `\usepackage{makeidx}` and `\makeindex` in the preamble bring in the relevant commands.

Producing an index is a three stage process. First, in the document body you declare index entries with the `\index` command (see \index). When you run LaTeX, the `\index` writes its information to an auxiliary file `root-name.idx`. Next, to alphabetize and to do other manipulations you run an external command, typically `makeindex` or `xindy` (see makeindex). These output a file `root-name.ind`. Finally, you bring the information back into your document and typeset it with the `\printindex` command (see \printindex).

There are many packages that apply to indexing commands. The `showidx` package causes each index entries to be shown in the margin on the page where the entry appears. This can help in preparing the index. The `multind` package supports multiple indexes. See also the TeX FAQ entry on this topic, http://www.tex.ac.uk/cgi-bin/texfaq2html?label=multind.

Unofficial LaTeX2e reference manual