Tools for Printing Indexes
Jon L. Bentley
Brian W. Kernighan
AT&T Bell Laboratories
Murray Hill, New Jersey 07974
This paper describes a set of programs for processing and printing the index for a
book or a manual. The input is a set of lines containing index terms and page numbers.
(Disclaimer: these programs do not help with the original creation of index terms!) The
programs collect multiple occurrences of the same terms, compress runs of page numbers,
create permutations (e.g., ``index, book'' from ``book index''), and sort them into proper
alphabetic order. The programs can cope with embedded formatting commands (size and
font changes, etc.) and with roman numerals.
The implementation uses an unusual software style: a long pipeline of short awk
programs. This structure makes the programs easy to adapt or augment to meet the spe-
cial requirements that arise in many indexes. The programs were intended to be used
with troff, but can be used with TEX or monk with minor changes.