Making an index in LaTeX

December 19th, 2006

Making an index in LaTeX is far easier than I thought. MakeIndex does most of the work.

What one basically has to do is to add \usepackage{makeidx} and \makeindex to the preamble, then put \printindex wherever one wants the index to go. Then one has to mark the words that one wants included in the index with \index{word}. Below is an example:

\documentclass[a4paper,11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf-8]{inputenc}
\usepackage{makeidx}

\title{My first index}
\makeindex

\begin{document}
\maketitle
Hello world.
\index{world}
\printindex

\end{document}

The following commands are then used to generate the index if the TeX is inside a file named "foo.tex":

$ latex foo.tex
$ makeindex foo.idx
$ latex foo.tex

The end result will be document containing "Hello world." and an index in the end containing "world".

Sorry, comments are closed for this article.