home > indexing
Index Syntax in Microsoft Word
.
.
By Seth A. Maislin

[ Jump to:
XE field syntax: sorting || \b and \i || \f || \r || \t
INDEX field syntax: \b || \c || \d || \e || \f || \g || \h || \l || \p || \r || \z ]

  Indexing in Microsoft Word requires XE and INDEX field codes, and these can take a number of options. Although these are documented in MS Word manuals, that documentation is rather poor. This document lists and better explains those options. Understanding how to use these options gives you greater editorial and formatting control when indexing your documentation.

The XE Field

 The basic XE field in Microsoft word looks like this. To see them, make hidden text visible.
     {XE "main heading:subheading:sub-subheading"}
In theory, you can have as many sublevels as you want, separating them all with colons. For formatting purposes, remember that each sublevel is given its own style; just make sure that the styles are properly designed. (It is accepted that most text indexes should have only three levels anyway, and exceptions are very few.)
     main heading
       subheading
         sub-subheading, 000  [where "000" is the generated page number]
  Sort Override
There is an undocumented feature that allows you to apply manual sorting overrides for the entries. Follow the entry level that you want differently sorted with a semicolon and the sort text itself. In the example below, the main heading will appear re-alphabetized as if the text of the main heading were actually "resortedmain." The subheading is also re-alphabetized as if it were spelled "resortedsub."
     {XE "main;resortedmain:sub;resortedsub:sub-sub;resortedsub-sub")
Note that if you're familiar with the syntax for embedded indexing with Adobe FrameMaker, this is significantly different. With FrameMaker, you would write the complete entry, followed by the semicolon, followed by the complete resorted entry. With Word, however, you apply the resorted text to each level individually. In general, you will want to override the sort for only one level; my exaggerated example above overrides all three levels.

  Note About the Flags That Follow
The next several sections discuss options available for the XE field. The syntax for the flags are as follows: backslash, flag character, space, argument (if needed) in quotation marks. The location of the flags and arguments within the tag is irrelevant to functionality; put the flags in the XE field wherever you find them easiest to read, access, and edit. XE fields can contain multiple flags provided they are all different. Using the same flag twice within one XE field will create errors of omission (that is, only one flag will be considered).

  Formatting the Page Numbers
Microsoft Word allows for the use of boldface and italics page numbers. The flags needed to do this are quite simple: \b for boldface and \i for italics.
     {XE \b "main heading:subheading:sub-subheading one"}
     {XE \i "main heading:subheading:sub-subheading two"}

     main heading
       subheading
         sub-subheading one, 000
         sub-subheading two, 000
  Using Something Other Than Page Numbers
You can suppress the appearance of page numbers and replace them with some other hardcoded text of your choosing using the \t flag. Most writers know this as the flag used for cross references, but I recommend not being so limited. Here are some examples of its use:
     {XE "main heading:subheading one" \t "See cross reference"}
     {XE "main heading:subheading two" \t "See inside back cover"}
     {XE "main heading:subheading zero" \t "Consult technical service for 
              information relating to your personal configuration."}

     main heading
       subheading one. See cross reference
       subheading two. See inside back cover
       subheading zero. Consult technical service for information 
          relating to your personal configuration.
Note that the \t flag uses a period to separate the contents from the rest of the entry, whereas otherwise a comma is used. There is no way to override the choice of period. (The use of the comma is set using the \e flag for the INDEX field code.) Also note that styles within the \t argument are conserved.

  Identifying Groups of Index Fields
When you are building more than one index and want particular index entries to appear only within particular indexes, use the \f flag to label those entries. For example, if you are building a name index, a command index, and a general index (in which names and commands are included), you'll need two different arguments for the \f flag: one for the names, and one for the commands. The general index is the standard default index produced without the \f flags. (For more information, see the instructions on how to create separate indexes using the INDEX \f flag.)
     {XE "main heading:name one" \f "names"}
     {XE "main heading:command one" \f "commands"}
     {XE "main heading:general stuff one"}
     {XE "main heading:name two" \f "names"}
     {XE "main heading:command two" \f "commands"}
     {XE "main heading:general stuff two"}

   Name Index
     main heading
       name one, 000
       name two, 000

   Command Index
     main heading
       command one, 000
       command two, 000

   Subject Index (all-inclusive)
     main heading
       command one, 000
       command two, 000
       general stuff one, 000
       general stuff two, 000
       name one, 000
       name two, 000
Note that only one \f flag can be used within a single XE field. If you want an entry to appear in two specialized indexes (regardless of its appearance in an all-inclusive index), you need to create two XE fields, each with a different \f argument. For the all-inclusive index, duplicate entries on the same page do resolve into a single entry.
     {XE "main heading:subheading" \f "small-index-one"}
     {XE "main heading:subheading" \f "small-index-two"}
     {XE "main heading:subheading" \f "small-index-three"}

   Small Index 1
     main heading
       subheading, 000

   Small Index 2
     main heading
       subheading, 000

   Small Index 3
     main heading
       subheading, 000

   Subject Index (all-inclusive, duplicates removed)
     main heading
       subheading, 000
  Page Ranges
To create page ranges, use the \r flag. The argument of the flag must be a well-defined MS Word bookmark.
     {XE "main heading:subheading:sub-subheading" \r "bookmark"}

     main heading
       subheading
         sub-subheading, 000-001   [where the endpoints are defined by bookmark]

The INDEX Field

 The basic INDEX field is almost absurd in its simplicity:
     {INDEX}
All but one of the flags available for the INDEX field code are related to formatting. The order of the flags within the INDEX field is irrelevant, as long as they all appear after the word "INDEX" itself, with spaces between each flag and argument.

  Note About the Flags That Follow
The next several sections discuss options available for the INDEX field. The syntax for the flags are as follows: backslash, flag character, space, argument (if needed) in quotation marks. The location of the flags and arguments within the tag is irrelevant to functionality; put the flags in the INDEX field wherever you find them easiest to read, access, and edit. INDEX fields can contain multiple flags provided they are all different. Using the same flag twice within one INDEX field will create errors of omission (that is, only one flag will be considered).

  Number of Columns
The \c flag is used to count the number of columns. The default number of columns is one, so the flag can be omitted for one-column indexes.
     {INDEX \c "2"}   [two-column layout]
     {INDEX \c "4"}   [four-column layout]
  Indexes for Partial Documents
If you are interested in indexing only part of a document, use the \b flag. The argument of this flag is a well-defined MS Word bookmark that defines the region to be indexed. For example, if you wanted to generate an index for only page 4 of a 10-page document, create a bookmark for page 4 and use the name of that bookmark as the argument to the \b flag.
     {INDEX \b "bookmark"}
  Separation Character: Between Text and Numbers
The character that appears between the text of the entry and the page numbers is defined by the \e flag. The default value is a comma. (NOTE: It is not necessary to escape colons and semicolons in this field.)
     {INDEX \e ":"}

     main heading
       subheading one: 000, 001
       subheading two: 000-001, 002-003

     {INDEX \e "-->"}

     main heading
       subheading one--> 000, 001
       subheading two--> 000-001, 002-003
  Separation Character: Between Multiple Page References
The character that appears between multiple page references is defined by the \l (ell) flag. The default value is a comma. (NOTE: It is not necessary to escape colons and semicolons in this field.) It is worth noting that a space is always added after the character itself, but not before; when adding text, be sure to insert a leading space.
     {INDEX \l ";"}

     main heading
       subheading one, 000; 001
       subheading two, 000-001; 002-003

     {INDEX \l " and"}

     main heading
       subheading one, 000 and 001
       subheading two, 000-001 and 002-003
  Separation Character: Between Range Elements
The character that appears between endpoints of a range is defined by the \g flag. The default value is a hyphen. (NOTE: It is not necessary to escape colons and semicolons in this field.) It is worth noting that no spaces are added around the character.
     {INDEX \g "--"}

     main heading
       subheading one, 000, 001
       subheading two, 000--001, 002--003

     {INDEX \g " to "}

     main heading
       subheading one, 000, 001
       subheading two, 000 to 001, 002 to 003
  Separation Character: Within Complex Page Numbers
The character that appears between elements of a complex page number is defined by the \d flag. The default value is a hyphen. (NOTE: It is not necessary to escape colons and semicolons in this field.) It is worth noting that no spaces are added around the character.
[In this example, page numbers are normally of the form 0-000, 
where the first number represents the section number and the last 
three digits represent the page number. For example, 3-109 is the 
109th page of section 3.]

     {INDEX} 

     main heading
       subheading one, 0-000, 0-001
       subheading two, 0-000-0-001, 0-002-0-003

     {INDEX \d ":"}

     main heading
       subheading one, 0:000, 0:001
       subheading two, 0:000-0:001, 0:002-0:003

     {INDEX \d "/"}

     main heading
       subheading one, 0/000, 0/001
       subheading two, 0/000-0/001, 0/002-0/003
In general, when using multipart page numbers, the separator within range elements is of greater importance. The ranges must be clearly identifiable as something different from the multiple page locators. Below are two standards for representing multipart numbers.
     {INDEX \g " to "}

     main heading
       subheading one, 0-000, 0-001
       subheading two, 0-000 to 0-001, 0-002 to 0-003

     {INDEX \g "--"}   [this would be an em or en dash]

     main heading
       subheading one, 0-000, 0-001
       subheading two, 0-000--0-001, 0-002--0-003

  Heading Indicators
The characters that appear above various letter groups are somewhat customizable using the \h flag. The default setting is "A" (for one letter). Any character that appears in the argument for this flag is converted into the same character as defined by the entries in the letter group, and that character is always uppercase. Thus for the most part, this flag is useful only for the insertion of nonalphanumeric characters into the letter heads. See the examples below for clarity.
     {INDEX \h "A"}

     M
     main heading
       subheading one, 000, 001
       subheading two, 000-001, 002-003

     {INDEX \h "a"}

     M
     main heading
       subheading one, 000, 001
       subheading two, 000-001, 002-003

     {INDEX \h "AAAA"}

     MMMM
     main heading
       subheading one, 000, 001
       subheading two, 000-001, 002-003

     {INDEX \h "Letter Head: A"}

     MMMMMM MMMM: M
     main heading
       subheading one, 000, 001
       subheading two, 000-001, 002-003

     {INDEX \h "- A -"}

     - M -
     main heading
       subheading one, 000, 001
       subheading two, 000-001, 002-003

     {INDEX \h "*** A ***"}

     *** M ***
     main heading
       subheading one, 000, 001
       subheading two, 000-001, 002-003
  Multiple Indexes
To create multiple indexes in Word, use the \f flag. This will generate an index in which the only included entries are those labeled with \f flags that share the same argument. For example, if a command index is defined with \f "commands", then only XE fields with \f "commands" within are collated to create that index. (See above for more on the XE \f flag.)
     {XE "main heading:name one" \f "names"}
     {XE "main heading:command one" \f "commands"}
     {XE "main heading:general stuff one"}
     {XE "main heading:name two" \f "names"}
     {XE "main heading:command two" \f "commands"}
     {XE "main heading:general stuff two"}


     {INDEX \f "names"}  [name index]

     main heading
       name one, 000
       name two, 000


     {INDEX \f "commands"}   [command index]

     main heading
       command one, 000
       command two, 000


     {INDEX}   [subject index (all-inclusive)]

     main heading
       command one, 000
       command two, 000
       general stuff one, 000
       general stuff two, 000
       name one, 000
       name two, 000
  Limiting the Index to Only Certain Letter Groups
If you want to generate an index that includes only entries that begin with certain letters, use the \p flag. For example, if you wanted to create an index for entries that start with the letters A through J, use \p "A-J". If you want an index that includes only entries that start with vowels, use \p "AEIOU". (For numeric entries, use the argument "0-9".) I'm not certain if there is a best way to include entries that start with nonalphanumerics; perhaps just list all the symbols with which your entries begin in the same way the alphabetic vowels were listed in the above example.
     {INDEX \p "0-9"}
       no entries in our example start with numbers

     {INDEX \p "A-J"}
       no entries in our example start with these letters

     {INDEX \p "K-R"}
     main heading
       subheading one, 000, 001
       subheading two, 000-001, 002-003

     {INDEX \p "S-Z"}
       no entries in our example start with these letters

  Run-In Style
To generate an index that runs subheadings together instead of indenting them, use the \r flag. Semicolons are placed between consecutive subheadings, and this cannot be overridden. Notice that run-in style works only if the index is limited to two levels (main heading and subheading). This tag requires no argument. (The indentations are defined by styles, and most of the separation characters are assumed to be nonbreaking.) Run-in style is used in certain industries to save space; I recommend not using it unless absolutely necessary because it's hard to read.
     {INDEX}

     main heading, 000
       subheading one, 000, 001
       subheading two. See cross reference
       subheading three, 000-001, 002-003


     {INDEX \r}

     main heading, 000; subheading one, 000, 
           001; subheading two. See cross
           reference; subheading three, 000-001,
           002-003
  unknown
In a discussion I first had in 2008, I learned that there exists a \z tag, but we never quite figured out what it's for. There is an identical switch when generating tables of contents (TOCs), and according to Microsoft's documentation this flag (with TOCs) "hides tab leader and page numbers in Web layout view." However, the first time this was discovered was in someone's index, where they saw {Index \c "2" \h "A" \z "1033"}; that the parameter 1033 is in there means that this \z is not the same as the \z you'd find in a TOC. So there's that answer...

If I had to guess, I would say that the \z switch with INDEX has to do with localization or character sets. Adding this field seems to disrupt the alphabetization scheme you'd expect with American English.

If you know what this means, I need to know. :-) Thanks.

Request for Comments and Other Feedback

  Keeping up with software that is frequently re-released can be difficult, although to date Microsoft has awarded very little attention to indexing tools and functionality. (They seem to think indexes aren't important enough in the grand scheme of things, can you imagine? :-) To maintain this document, then, I'd appreciate your help. Email me with corrections, clarifications, anecdotes, and your special tips and tricks. I'll append them to this document. My email address is seth@maislin.com. Thank you.

 

Copyright 2010 Seth A. Maislin
Most recent update made in May 2010.

Top


HOME  |   ABOUT  |   INDEXING  |   WEBSMARTS  |   FUN & WACKY  |   EMAIL
Site design by little graphics studio.
© 2002   All rights reserved.