6.3 Example

The following example shows a style file called book.isty which defines a stand-alone index for a book. By stand-alone, we mean it can be formatted independent of the main source.

preamble
"\\documentstyle[12pt]{book}
\\begin{document}
\\begin{theindex}
{\\small\n"

postamble
"\n\n}
\\end{theindex}
\\end{document}\n"

Suppose a particular book style requires the index (as well as any chapters) to start from an odd page number. Given foo.idx as the raw index file, the following command line produces an index in file foo-.ind.

makeindex  -s book.isty  -o foo-.ind  -p odd  foo

The reason to use a non-default output file name is to avoid clobbering the source output (presumably foo.dvi) because if the index is in file foo.ind, its output will also be in foo.dvi as a result of separate formatting using . In the example the index is in foo-.ind, its output will be in foo-.dvi and thus introduces no confusion.