Welcome to the UK List of
TeX Frequently Asked Questions
on the Web

Searching

The index of Frequently Asked Questions about TeX is searchable.

Please enter your keyword here:   then press here: ,    or:
Google

Multiple indexes

LaTeX’s standard indexing capabilities (those provided by the makeidx package) only provide for one index in your document; even quite modest documents can be improved by indexes for separate topics.

The multind package provides simple and straightforward multiple indexing. You tag each \makeindex, \index and \printindex command with a file name, and indexing commands are written to (or read from) the name with the appropriate (.idx or .ind) extension appended. The \printindex command is modified from an old version of the LaTeX 2.09 standard so that it doesn’t create its own chapter or section heading; you therefore decide what names (or sectioning level, even) to use for the indexes, and \indexname is completely ignored.

To create a “general” and an “authors” index, one might write:

\usepackage{multind}
\makeindex{general}
\makeindex{authors}
...
\index{authors}{Eccentric Professor}
...
\index{general}{FAQs}
...
\printindex{general}{General index}
\printindex{authors}{Author index}

To complete the job, run LaTeX on your file enough times that labels, etc., are stable, and then execute the commands

makeindex general
makeindex authors

before running LaTeX again. Note that the names of the index files to process are not necessarily related to the name of the LaTeX file you’re processing, at all. (There’s no documentation that comes with the package: what you see above is as good as you will get…)

The multind package doesn’t work with the amslatex classes, but the AMS provide a substitute, the amsmidx package. You use the amsmidx package pretty much the same as you would multind, but if things aren’t clear, there is documentation (unlike multind).

The index package provides a comprehensive set of indexing facilities, including a \newindex command that allows the definition of new styles of index. \newindex takes a ‘tag’ (for use in indexing commands), replacements for the .idx and .ind file extensions, and a title for the index when it’s finally printed; it can also change the item that’s being indexed against (for example, one might have an index of artists referenced by the figure number where their work is shown).

Using index, to create an author index together with a “normal” index, one would start with preamble commands:

\usepackage{index}
\makeindex
\newindex{aut}{adx}{and}{Name Index}

which load the package, define a “main” (original-style) index, and then define an author index. Then, in the body of the document, we might find commands like:

\index[aut]{Another Idiot}
...
\index{FAQs}

Which place an entry in the author index, and then one in the main index. At the end of the document, we have two commands:

\printindex
\printindex[aut]

Which will print the main index and then the author index. Supposing this lot to be in myfile.tex, after enough runs through LaTeX that labels are stable, execute the following commands (Unix-style shell commands shown here, but the principle is the same whatever system you’re using):

makeindex myfile
makeindex myfile.adx -o myfile.and

and rerun LaTeX. The makeindex commands process myfile.idx to myfile.ind (the default action), and then myfile.adx to myfile.and, the two files needed as input by the two \printindex commands in myfile.tex.

The splitidx package can operate in the same way as the others: load the package with the split option, and declare each index with a \newindex command:

\newindex[<index name>]{<shortcut>}

and splitidx will generate a file \jobname.<shortcut> to receive index entries generated by commands like \sindex[<shortcut>]{<item>}. As with the other packages, this method is limited by TeX’s total number of output files. However, splitindex also comes with a small executable splitindex (available for a variety of operating systems); if you use this auxiliary program (and don’t use split), there’s no limit to the number of indexes. Apart from this trick, splitidx supports the same sorts of things as does index. An example of use appears in the documentation.

The imakeidx package can do a wide range of things (in particular, it can run an index-builder — via \write18 commands — so as to simplify business of making the final copy of a document). The package can also make multiple indexes; it can do the job in the conventional (multind) way, or by using the external splitindex script provided with the splitindex package. (This arrangement allows efficient operation with small numbers of indexes, while retaining the flexibility of permitting large numbers of indexes without hitting the restriction of numbers of active output streams.)

The memoir class has its own multiple-index functionality (as well as its own index layout options, which other packages delegate to the index style used by makeindex).

amsmidx.sty
Part of the AMS class distribution macros/latex/required/amslatex/amscls (or browse the directory); catalogue entry
imakeidx.sty
macros/latex/contrib/imakeidx (or browse the directory); catalogue entry
index.sty
macros/latex/contrib/index (or browse the directory); catalogue entry
makeidx.sty
Part of the LaTeX distribution
memoir.cls
macros/latex/contrib/memoir (or browse the directory); catalogue entry
multind.sty
macros/latex209/contrib/misc/multind.sty; catalogue entry
splitidx.sty and splitindex
macros/latex/contrib/splitindex (or browse the directory); catalogue entry


Go to previous question, or next question

Go to FAQ home.

URL for this question: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=multind

Comments, suggestions, or error reports? - see “how to improve the FAQ”.

This is FAQ version 3.28, released on 2014-06-10.