C.3.2. Coding Index Entries
This section describes the coding of index entries in the document
file. We use the .XX macro for placing index entries in a file. The
simplest case is:
.XX "entry"
If the entry consists of primary and secondary sort keys, then we can
code it as:
.XX "primary, secondary"
A comma delimits the two keys. We also have a .XN macro for
generating "See" references without a page number. It is specified
as:
.XN "entry (See anotherEntry)"
While these coding forms continue to work as they have,
masterindex provides greater flexibility by
allowing three levels of keys: primary, secondary, and tertiary. You'd
specify the entry like so:
.XX "primary: secondary; tertiary"
Note that the comma is not used as a delimiter. A colon delimits the
primary and secondary entry; the semicolon delimits the secondary and
tertiary entry. This means that commas can be a part of a key using
this syntax. Don't worry, though, you can continue to use a comma to
delimit the primary and secondary keys. (Be aware that the first
comma in a line is converted to a colon, if no colon delimiter is
found.) I'd recommend that new books be coded using the above syntax,
even if you are only specifying a primary and secondary key.
Another feature is automatic rotation of primary and secondary keys if
a tilde (~) is used as the delimiter. So the following entry:
.XX "cat~command"
is equivalent to the following two entries:
.XX "cat command"
.XX "command: cat"
You can think of the secondary key as a classification (command,
attribute, function, etc.) of the primary entry. Be careful not to
reverse the two, as "command cat" does not make much sense. To use a
tilde in an entry, enter "~~".
I added a new macro, .XB, that is the same as .XX except that the page
number for this index entry will be output in bold to indicate that it
is the most significant page number in a range. Here is an example:
.XB "cat command"
When troff processes the index entries, it outputs
the page number followed by an asterisk. This is how it appears when
output is seen in screen format. When coded for
troff formatting, the page number is surrounded by
the bold font change escape sequences. (By the way, in the
JofC index, I noticed that they allowed having the same page
number in roman and in bold.) Also, this page number will not be
combined in a range of consecutive numbers.
One other feature of the JofC index is that the very first
secondary key appears on the same line with the primary key. The old
index program placed any secondary key on the next line. The one
advantage of doing it the JofC way is that entries containing
only one secondary key will be output on the same line and look much
better. Thus, you'd have "line justification, definition of" rather
than having "definition of" indented on the next line. The next
secondary key would be indented. Note that if the primary key exists
as a separate entry (it has page numbers associated with it), the page
references for the primary key will be output on the same line and the
first secondary entry will be output on the next line.
To reiterate, while the syntax of the three-level entries is
different, this index entry is perfectly valid:
.XX "line justification, definition of"
It also produces the same result as:
.XX "line justification: definition of"
(The colon disappears in the output.) Similarly, you could write an
entry, such as
.XX "justification, lines, defined"
or
.XX "justification: lines, defined"
where the comma between "lines" and "defined" does not serve as a
delimiter but is part of the secondary key.
The previous example could be written as an entry with three levels:
.XX "justification: lines; defined"
where the semicolon delimits the tertiary key. The semicolon is
output with the key, and multiple tertiary keys may follow immediately
after the secondary key.
The main thing, though, is that page numbers are collected for
all primary, secondary, and tertiary keys. Thus, you could have
output such as:
justification 4-9
lines 4,6; defined, 5