MAKEINDEX(1) | TeX Live | MAKEINDEX(1) |
makeindex - a general purpose, formatter-independent index processor
makeindex [-c] [-g] [-i] [-l] [-o ind] [-p num] [-q] [-r] [-s sfile] [-t log] [-L] [-T] [idx0 idx1 idx2...]
The program makeindex is a general purpose hierarchical index generator; it accepts one or more input files (often produced by a text formatter such as TeX (tex(1L)) or troff(1), sorts the entries, and produces an output file which can be formatted. The index can have up to three levels (0, 1, and 2) of subitem nesting. The way in which words are flagged for indexing within the main document is specific to the formatter used; makeindex does not automate the process of selecting these words. As the output index is hierarchical, makeindex can be considered complementary to the awk(1)-based make.index(1L) system of Bentley and Kernighan, which is specific to troff(1), generates non-hierarchical indices, and employs a much simpler syntax for indicating index entries. For illustration of use with troff and TeX, see the section EXAMPLES below.
The formats of the input and output files are specified in a style file; by default, input is assumed to be a .idx file, as generated by LaTeX.
Unless specified explicitly, the base name of the first input file (idx0) is used to determine the names of other files. For each input file name specified, a file of that name is sought. If this file is not found and the file name has no extension, the extension .idx is appended. If no file with this name is found, makeindex aborts.
If exactly one input file was given and no explicit style file was specified using -s, makeindex uses a file with the extension .mst as default style file (when present).
For important notes on how to select index keywords, see the document by Lamport cited below. As an issue separate from selecting index keywords, a systematic mechanism for placing index terms in a document is suggested in Index Preparation and Processing, a paper cited below.
The style file informs makeindex about the format of the .idx input files and the intended format of the final output file; examples appear below. This file can reside anywhere in the path defined by the environment variable INDEXSTYLE. The style file contains a list of <specifier, attribute> pairs. There are two types of specifiers: input and output. Pairs do not have to appear in any particular order. A line begun by `%' is a comment. In the following list of specifiers and arguments, <string> is an arbitrary string delimited by double quotes ("..."), <char> is a single letter embraced by single quotes ('...'), and <number> is a nonnegative integer. The maximum length of a <string> is 2048. A literal backslash or quote must be escaped (by a backslash). Anything not specified in the style file will be assigned a default value, which is shown at the head of the rightmost column.
The following example shows a style file called book.ist, which defines an index for a book which can be formatted independently of the main source:
preamble "\\documentstyle[12pt]{book} \\begin{document} \\begin{theindex} {\\small\n" postamble "\n\n} \\end{theindex} \\end{document}\n"
Assuming that a particular book style requires the index (as well as any chapters) to start from an odd page number, and that the input file is named foo.idx, the following command line produces output in file footmp.ind:
Here a non-default output file name is used to avoid clobbering the output for the book itself (presumably foo.dvi, which would have been the default name for the index output file!).
A sample control file for creating an index, which we will assume resides in the file sample.ist:
keyword "IX:" preamble ".\\\" start of index output \".\\\" enter two column mode .2C .SH .ce INDEX .XS INDEX .XE .R .ps 9p .vs 11p .sp .de I1 .ti 0.25i .. .de I2 .ti 0.5i .." postamble "\n.\\\" end of index output" setpage_prefix "\n.nr % " setpage_suffix "" group_skip "\n.sp 1.0" headings_flag 1 heading_prefix "\n.IS\n" heading_suffix "\n.IE" item_0 "\n.br\n" item_1 "\n.I1\n" item_2 "\n.I2\n" item_01 "\n.I1\n" item_x1 "\n.I1\n" item_12 "\n.I2\n" item_x2 "\n.I2\n" delim_0 ", " delim_1 ", " delim_2 ", " delim_r "-" delim_t "." encap_prefix "\\fB" encap_infix "" encap_suffix "\\fP" indent_space "" indent_length 0
The local macro package may require modification, as in this example of an extension to the -ms macros (note that at some sites, this macro should replace a pre-existing macro of the same name):
. .de IX .ie '\\n(.z'' .tm IX: \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 {\\n(PN} .el \\!.IX \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 {\\n(PN} ..
(note that the string {\\n(PN} is separated from the rest of the line by a tab. If your local macro package does not contain this extension, just include those lines at the beginning of your file. Here is a simple troff(1) input file, which we will assume is named sample.txt:
This is a sample file to test the \fImakeindex\fP(1L) program, and see .IX {indexing!programs!C language} .IX {makeindex@\fImakeindex\fP(1L)} .bp .rs .IX {Knuth} .IX {typesetting!computer-aided} how well it functions in the \fItroff\fP(1) environment.
Note that index entries are indicated by the .IX macro, which causes the following text to be written to stdout along with the current page number.
To create an input file for makeindex, in the Bourne shell environment, do the equivalent at your site of the command:
psroff -ms -Tpsc -t sample.txt > /dev/null 2> sample.tmp
Some sites will require ditroff instead of psroff. To filter out any genuine error messages, invoke grep(1):
With UCSF Enhanced troff/TRANSCRIPT, the -I option of psroff(1L) can produce both formatter output and an index file:
If it is wished to suppress the formatter output:
psroff -ms -I sample.inp -Tpsc -t sample.txt > /dev/null
Any of the above procedures leaves the input for makeindex in sample.inp. The next step is to invoke makeindex:
This leaves troff(1)-ready output in the file sample.ind.
By default, makeindex assumes word ordering; if the -l option is in effect, letter ordering is used. In word ordering, a blank precedes any letter in the alphabet, whereas in letter ordering, it does not count at all. This is illustrated by the following example:
Numbers are always sorted in numeric order. For instance,
Letters are first sorted without regard to case; when words are identical, the uppercase version precedes its lowercase counterpart.
A special symbol is defined here to be any character not appearing in the union of digits and the English alphabetic characters. Patterns starting with special symbols precede numbers, which precede patterns starting with letters. As a special case, a string starting with a digit but mixed with non-digits is considered to be a pattern starting with a special character.
Entries such as
\indexentry{alpha}{1} \indexentry{alpha!beta}{3} \indexentry{alpha!beta!gamma}{10}
in the input file will be converted to
\item alpha, 1 \subitem beta, 3 \subsubitem gamma, 10
in the output index file. Notice that the level symbol (`!') is used above to delimit hierarchical levels.
It is possible to make an item appear in a designated form by using the actual (`@') operator. For instance,
will become
after processing. The pattern preceding `@' is used as sort key, whereas the one following it is written to the output file. Note that two appearances of the same key, one with and one without the actual operator, are regarded as distinct entries.
The item, subitem, and subsubitem fields may have individual sort keys:
\indexentry{aa@{\it aa\/}!bb@{\it bb\/}!cc@{\it cc\/}}{1}
This will be converted to
\item {\it aa}, 1 \subitem {\it bb}, 3 \subsubitem {\it cc}, 10
It is possible to encapsulate a page number with a designated command using the encap (`|') operator:
will be converted to
where, with a suitable definition for TeX, \bold{n} will expand to {\bf n}. In this example, the three output attributes associated with page encapsulation encap_prefix, encap_infix, and encap_suffix, correspond to backslash, left brace, and right brace, respectively. This mechanism allows page numbers to be set in different fonts. For example, the page where the definition of a keyword appears can be in one font, the location of a primary example can be in another font, and other appearances in yet a third font.
The encap operator can also be used to create cross references in the index:
will become
in the output file, where
will expand to
Note that in a cross reference like this the page number disappears.
A pair of encap concatenated with range_open (`|(') and range_close (`|)') creates an explicit page range:
\indexentry{alpha|(}{1} \indexentry{alpha|)}{5}
will become
Intermediate pages indexed by the same key will be merged into the range implicitly. This is especially useful when an entire section about a particular subject is to be indexed, in which case only the range opening and closing operators need to be inserted at the beginning and end of the section. Explicit page range formation can also include an extra command to set the page range in a designated font:
\indexentry{alpha|(bold}{1} \indexentry{alpha|)}{5}
will become
Several potential problems are worth mentioning. First, entries like
\indexentry{alpha|(}{1} \indexentry{alpha|bold}{3} \indexentry{alpha|)}{5}
will be interpreted as
but with a warning message in the transcript about encountering an inconsistent page encapsulator. An explicit range beginning in a Roman page number and ending in Arabic is also considered an error. In this instance, (if possible) the range is broken into two subranges, one in Roman and the other in Arabic. For instance,
\indexentry{alpha|(}{i} \indexentry{alpha}{iv} \indexentry{alpha}{3} \indexentry{alpha|)}{7}
will be turned into
with a warning message in the transcript file complaining about an illegal range formation.
Every special symbol mentioned in this section may be escaped by the quote operator (`"'). Thus
will actually become
as a result of executing makeindex. The quoting power of quote is eliminated if it is immediately preceded by escape (`\'). For example,
becomes
which represents an umlaut-accented `u' to the TeX family of processors.
A page number can be a composite of one or more fields separated by the delimiter bound to page_compositor (`-'), e.g., II-12 for page 12 of Chapter II. Page numbers may contain up to ten fields.
Since version 2.11 of makeindex, the quote operator may quote any character in the range 1 ... 255. Character 0 is excluded because it is used internally in the makeindex source code as a string terminator. With this change, sort keys can be created for all eight-bit characters except 0. The sorting order is
punctuation characters (in ASCII order), digits, control characters (1 ... 31), space (32), letters (ignoring case), characters 127 ... 255.
\indexentry{" @" (space)}{32} \indexentry{"!@"! (exclamation point)}{33} \indexentry{""@"" (quotation mark)}{34} \indexentry{"#@"\# (sharp sign)}{35} \indexentry{"$@"\$ (dollar sign)}{36} \indexentry{"%@"\% (percent sign)}{37} \indexentry{"&@"\& (ampersand)}{38} \indexentry{"<@"$<$ (left angle bracket)}{60} \indexentry{"=@"= (equals)}{61} \indexentry{">@"$>$ (right angle bracket)}{62} \indexentry{"?@"? (query)}{63} \indexentry{"@@"@ (at sign)}{64} \indexentry{"[@"[ (left square bracket)}{91} \indexentry{"\@"\verb=\= (backslash)}{92} \indexentry{"]@"] (right square bracket)}{93} \indexentry{"^@"\verb=^= (caret)}{94} \indexentry{"_@"\verb=_= (underscore)}{95} \indexentry{"`@"\verb=~= (grave accent)}{96} \indexentry{"{@"\"{ (left brace)}{123} \indexentry{"|@"\verb="|= (vertical bar)}{124} \indexentry{"}@"\"} (right brace)}{125} \indexentry{"~@"\verb=~= (tilde)}{126}
\begin{theindex}
\item ! (exclamation point), 33
\item " (quotation mark), 34
\item \# (sharp sign), 35
\item \$ (dollar sign), 36
\item \% (percent sign), 37
\item \& (ampersand), 38
\item $<$ (left angle bracket), 60
\item = (equals), 61
\item $>$ (right angle bracket), 62
\item ? (query), 63
\item @ (at sign), 64
\item [ (left square bracket), 91
\item \verb=\= (backslash), 92
\item ] (right square bracket), 93
\item \verb=^= (caret), 94
\item \verb=_= (underscore), 95
\item \verb=~= (grave accent), 96
\item \{ (left brace), 123
\item \verb=|= (vertical bar), 124
\item \} (right brace), 125
\item \verb=~= (tilde), 126
\indexspace
\item (space), 32 \end{theindex}
ditroff(1L), latex(1L), make.index (1L), qsort(3), tex(1L), troff(1L)
UCSF Enhanced troff/TRANSCRIPT — An Overview, R. P. C. Rodgers and Conrad Huang, LSMB Technical Report 90-2, UCSF School of Pharmacy, San Francisco, 1990.
Index Preparation and Processing, Pehong Chen and Michael A. Harrison, Software: Practice and Experience, 19(9), 897–915, September 1988.
Automating Index Preparation, Pehong Chen and Michael A. Harrison. Technical Report 87/347, Computer Science Division, University of California, Berkeley, 1987 (a LaTeX document supplied with makeindex).
MakeIndex: An Index Processor for LaTeX, Leslie Lamport, February 1987 (a LaTeX document supplied with makeindex).
Tools for Printing Indices, Jon L. Bentley and Brian W. Kernighan, Electronic Publishing — Origination, Dissemination, and Design, 1(1), 3–18, June 1988 (also available as: Computing Science Technical Report No. 128, AT&T Bell Laboratories, Murray Hill, NJ 07974, 1986).
Pehong Chen, Chen & Harrison International Systems, Inc. Palo
Alto, California, USA.
Manual page extensively revised and corrected, and troff(1) examples
created by Rick P. C. Rodgers, UCSF School of Pharmacy.
Leslie Lamport contributed significantly to the design of MakeIndex. Michael Harrison provided valuable comments and suggestions. Nelson Beebe improved on the portable version, and maintained the source distribution for the TeX Users Group for many years. Andreas Brosig contributed to the German word ordering. The modification to the -ms macros was derived from a method proposed by Ravi Sethi of AT&T Bell Laboratories. The LOG and CONTRIB files in the makeindex source distribution record other contributions.
makeindex is currently maintained as part of the TeX Live distribution (http://tug.org/texlive); please send bug reports to tex-k@tug.org.
12 November 2014 | TeX Live |