Whether you're indexing an entire document or a partial list of terms, switches will enable you to customize the results.
After reading the article Generate multiple indexes in the same Word document, Tony tried to generate three partial indexes in a single document. He ran into two problems. First, he wanted each index to use the alpha-character header format. Second, even though he used three unique terms for each index--name, subject, and solar--Word was blending the subject- and solar-marked terms into one index. In this article, I'll show you how to solve both of Tony's indexing problems.
Before we start, let's back up a bit because this article assumes you know how to generate an index and even multiple indexes. If you're not familiar with Word's indexing feature, I recommend that you read How to add an index to a Word document using index tags and then read the article mentioned above.
I'm using Word 2016 on a Windows 10 64-bit system, but there's little to no discrepancy in the Ribbon versions. You can create your own index or download the demonstration .docx or .doc file.
Beyond the following, there are no Word 2003 instructions:
- To find indexing options, choose References from the Insert menu and then select Index And Tables.
- To insert a field, choose Field from the Insert menu.
To insert a single index, you'll probably use Word's Insert Index option in the Index group on the References tab. Doing so lets you set a number of formatting options. For instance, in Figure A, you can see that I've chosen the Modern format (or template) and the Print Preview pane displays alphabetical headers, which is the format Tony wants.
Index templates contain custom formats.
What you can't do using this interface option is insert a partial index. By partial, I mean an index that includes exclusive terms. For instance, you might want two indexes in a document on wildflowers: one for the entire document and a partial index that includes only botanical names. Marking is the key to partial indexing:
- Tag all terms using the Mark Entry option in the Index group on the References tab.
- Add an \f switch to a term you want included only in the partial index.
- If you want a term in both indexes, you'll need two index tags--one for each index.
When adding a partial index, you use Word's Quick Parts option on the Insert tab, and unfortunately, that interface doesn't let you specify custom formatting the way the Insert Index option does. That's why Tony was unsuccessful in generating a partial index with alphabetical headers. Fortunately, you can manually add a formatting switch for that format, and that's what we'll do next.
Figure B shows a simple document with and without the tags showing. As you can see, this document has tags for three partial indexes, identified by the three \f switches:
- \f "name"
- \f "subject"
- \f "solar"
To display the index tags, click Show/Hide in the Paragraph group on the Home tab. If you don't know how to mark index terms, read How to add an index to a Word document using index tags.
This document has entry tags for three partial indexes.
Now, let's generate the first index based on \f "name" switch as follows:
- Position your cursor where you want the index. (I added the label "Name Index" to identify the index, but you don't need to.)
- Click the Insert tab.
- From the Quick Parts dropdown (in the Text group), choose Field.
- In the resulting dialog, choose Index in the Field Names list.
- Click Field Codes (below the Field Names list) to display the Advanced field properties control. It will contain the INDEX identifier. In addition, the Field Codes button will change to the Hide Codes button.
- Add \f name (Figure C). In Figure B, the \f switches are enclosed in quotation marks (\f "name") but don't include those when adding the switch to the INDEX field.
- Click OK to see the default index shown in Figure D.
Add the partial index switch.
The default index has little formatting.
The index contains the three name items as expected, but Tony wants those alpha headers. Fortunately, we can modify the underlying field code to accommodate that format as follows:
- Select the index and press [Alt]+[F9] to see the underlying field code (Figure E).
- Add the \h "A" switch following the INDEX identifier (Figure F).
- Press [Alt]+[F9] to display the index.
- Right-click the index and choose Update Field to display the newly formatted index. (Figure G).
The index is generated by a field code.
Add the \h switch.
The new index includes alphabetic headers.
You might have noticed a few differences between the text and the way it looks in the indexes. First, the names in the index are in lastname, firstname format. That's because Tony manually made the change when marking the entries. Second, some of the index terms are proper case in the index but not in the text. Again, Tony made the case change when marking the entry. I purposely left these subtle differences so you could see firsthand how flexible this feature is.
A buggy switch
One problem down, one to go. If you remember, Tony said that Word included the subject and solar terms in the same index. Using the earlier instructions, insert a second index--but at step 6, enter \f subject. Figure H shows the resulting index, and Tony was right; it includes subject and solar items, not just subject. If you generate an index using \f solar, you'll see the same index.
Despite two different arguments, this \f switch index combines them.
The problem is the argument subject. Replace all of the instances of subject with topic, and Word will generate the topic (subject) and topic indexes, shown in Figure I, as expected.
Use the \f switch to generate partial indexes.
I suspect that the term subject is a reserved term, and using it as an argument with the \f switch confuses Word. That might not be the case, but I have no other explanation. I don't think it's a true bug. Please leave your thoughts about what caused this "bug" in the Comments section below; I'm interested in your take on it.
So to recap a bit: You can insert an index in two ways. Using the Insert Index option evaluates the entire document and offers several formatting templates. You can also manually enter the index field using the Quick Parts option. Either way, you can manually enter switches to customize the end results. For a complete list of field codes and switches, visit Field codes in Word.
Send me your question about Office
I answer readers' questions when I can, but there's no guarantee. When contacting me, be as specific as possible. For example, "Please troubleshoot my workbook and fix what's wrong" probably won't get a response, but "Can you tell me why this formula isn't returning the expected results?" might. Please mention the app and version that you're using. Don't send files unless requested; initial requests for help that arrive with attached files will be deleted unread. I'm not reimbursed by TechRepublic for my time or expertise when helping readers, nor do I ask for a fee from readers I help. You can contact me at firstname.lastname@example.org.
- Increase your productivity with Office and SharePoint add-ins
- Office 2016: A roundup of the best new capabilities
- Free online Office resources to raise your game
- Office Q&A: Two Excel list solutions