\usepackage{makeidx} in the preamble to define commands.
\makeindex in the preamble to create a .idx file.
\printindex in the end of the document to print the .ind file.
Syntax:
\documentclass[...]{...}
...
\usepackage{makeidx}
...
\makeindex
...
\begin{document}
...
\printindex
\end{document}
To create an index in your document,
If you are using AUCTEX in EMACS you can run MakeIndex using the command C-c C-c Index.
Normal entries:
Simple index entry: \index{alpha}
Subindex entry: \index{alpha!beta}
Subsubindex entry: \index{alpha!beta!gamma}
In the following, alpha may be replaced by alpha!beta or alpha!beta!gamma.
Page number effects:
Emphasized page number: \index{alpha|mainidx}
Boldfaced page number: \index{alpha|boldidx}
Page range: \index{alpha|(} Begin command
... Intermediate text
\index{alpha|)} End command
Emphasized page range: \index{alpha|(mainidx} Begin command
... Intermediate text
\index{alpha|)} End command
Bold page range: \index{alpha|(boldidx} Begin command
... Intermediate text
\index{alpha|)} End command
Special effects:
Cross ref in index: \index{alpha|see{delta}}
Alternative appearence: \index{alpha@delta} alpha is used for sorting,
but delta is printed.
\newcommand{\mainidx}[1]{{\it #1}}
\newcommand{\boldidx}[1]{{\bf #1}}
This defines the commands \mainidx and \boldidx that will appear in the .ind file after running MakeIndex.
Actually you can create more powerful commands if you want to. The effect see{delta}, which uses the predefined command \see, is a good example. After processing the .idx file to the .ind file, an \index{alpha|foo{delta}} command will result in the command \foo{delta}{n}, where n is the page number. Hence, if you have defined a command \foo taking two arguments (your own argument 'delta' and the page number) it will work.
Naturally you can have as many arguments as LATEX accepts if you wish. That normally is 10 arguments including the page number. Hence you can create as powerful commands as you wish. Your fantasy is the limit.
| Created: | Fri Mar 26 1999 by Mikael Olofsson |
| Last modified: | Wed Mar 17, 2010 by Mikael Olofsson |
| Comments to: | Mikael Olofsson ( mikael@isy.liu.se). |