The February 2015 article How to add an index to a Word document using index tags shows how to add an index to a Word document. Now I’d like to show you how to add to individual indices using special switches. You can bookmark sections and index the bookmarked section. Or, you can identify specific terms. In both cases, you selectively index the document to create multiple indices.
I’ll be working in Word 2013 on Windows 7; I’ll supply instructions for earlier versions as necessary. For your convenience, you can download the example .docx or .doc file, or use an existing document of your own. If you don’t know how to generate an index, I recommend that you work through the first article before trying to tackle this more advanced topic. This article assumes you know how to mark terms and generate an ordinary index.
Use the bookmark switch
Generating more than one index based on different sections of the document is the easiest way to add more than one index to the same document. Initially, the process is the same as generating a single index. You begin by marking each term you want included in the index. Then, before you generate the index, you bookmark the different sections. When generating each index, you indicate the bookmarked area you want indexed.
Before you can bookmark anything, you must determine the sections you want indexed. The example document shown in Figure A has two obvious sections: Galleries and Using Galleries. (The text is repeated to keep things simple.)
Use Show/Hide to display indexed terms.
The example document already contains marked terms. If you’re working with your own document, mark a few terms in two different sections or paragraphs. If you don’t see the index fields, click Show/Hide in the Paragraph group on the Home tab. This is a toggling option, so a click is all that’s required to display or hide formatting symbols. It’s on the Standard toolbar in 2003.
With the first step already completed for us, let’s move on to the second step — bookmarking the sections Galleries and Using Galleries. To bookmark the Galleries section, do the following:
- Select the three short paragraphs in the Galleries section (you don’t have to select the section title, but you can).
- Click the Insert tab, and then click Bookmark in the Links group. In 2003, choose Bookmark from the Insert menu.
- In the resulting dialog, give the bookmark a meaningful but short name. In this case, name the bookmark Galleries (Figure B) and click Add.
Name the bookmark Galleries.
Repeat this process to create a bookmark named UGalleries after selecting the Using Galleries section. Word displays brackets around bookmarked areas, as shown in Figure C.
Look for the brackets after adding a bookmark.
Now you’re ready to generate an index, but you won’t do so using the Insert Index on the References tab. You must insert the index field manually so you can add the bookmark switch as follows:
- Click where you want to position the index.
- Click the Insert tab.
- In the Text group, click the Quick Parts drop-down and choose Field (Figure D). In 2003, choose Field from the Insert menu.
- In the Field Names list, select Index.
- Below the Field Names list, click Field Codes and Word will display the Field Codes control. (The Field Codes button will then display Hide Codes.)
- In the Field Codes control, add \b Galleries \c 2 (Figure E).
- Click OK and Word will index only the previously indexed terms in the Galleries bookmark section.
If you’re comfortable using the keyboard, you can bypass the seven steps above and enter the index field as follows:
- Press [Ctrl]+[F9] to generate a blank field.
- Enter the appropriate field text: index \b Galleries \c.
- Press [F9] to generate the index.
Using either process, generate the index for the Using Galleries section, but in step 6, add \b UGalleries \c 3. Figure F shows the results of both indices.
Add two indexes to the same document using the bookmark switch, \b.
The \b switch tells Word to restrict the index to marked terms in the bookmarked sections. The \c switch formats the index in columns. In a working document you’d probably want the indexes to be consistently formatted, but I wanted you to see the flexibility that comes with using these switches by generating both a two- and a three-column index. There aren’t enough index terms to force a third column of text, but you can see that there’s room for it.
I promised you two methods, so next I’ll show you how to add specific terms to an index.
Use the entry type switch
You might want to separate terms in the same sections of the document into one or more indexes. In this case, bookmarks won’t help. Instead, use the \f entry type switch. In this example, we’ll use \f “abc” and \f “xyz”. Notice that we’re not referring to a bookmark this time; the strings are arbitrary, but you must match the references, respectively, when you generate each index later. You’ll want to use meaningful references and avoid including the term index in the reference. With a bit of testing, I found references that include index to be unreliable.
Don’t try to add the switch when marking the term using the Mark Index Entry dialog (Mark Index option). Word can’t transfer the switch correctly. Instead, manually add the switch and its argument to an indexed term. To demonstrate, we’ll modify only two terms (to keep things simple).
To mark the first term, do the following:
- Click inside the right end of the first indexed string, Insert tab, in the first line of the first paragraph following the Galleries heading.
- Type \f “abc”, as shown in Figure G.
Alter the existing index field by adding the bookmark switch and its argument.
Next, add the switch \f “xyz” to the Quick Styles field in the Formatting Text subsection in the Using Galleries section.
To generate the abc index, use the keyboard as I showed you earlier or use the interface as follows:
- Click where you want to insert the index (I added a header so you can visually distinguish between the two).
- Click the Insert tab and choose Field from the Quick Parts drop-down in the Text group.
- Choose Index in the Field Names list.
- Click Field Codes.
- In the control, add the following string, \f abc (Figure H). (Notice that I did not include the double quotation marks this time.)
- Click OK to generate the abc index.
Generate the xyz index, shown in Figure I, using the switch \f xyz (no quotation marks).
Generate entry type indexes.
We used multiple indexing as an excuse to explore two different ways to add index terms to an index that isn’t document-inclusive. In neither case must you generate more than one index. You can use the bookmark method to generate a unique index when you don’t want to index the entire document. In addition, the \f switch references can occur in the same section and even the same paragraph. If the resulting index doesn’t produce the results you expect, check your arguments for typos and missing quotation marks.
Multiple indexing isn’t something most ordinary users will need, but it’s a fun exercise. Learning what Word is capable of, even when you don’t think you’ll utilize the feature, is a great way to expand your Word expertise.
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. I’m not reimbursed by TechRepublic for my time or expertise, nor do I ask for a fee from readers. You can contact me at firstname.lastname@example.org.
Subscribe to the Developer Insider Newsletter
From the hottest programming languages to commentary on the Linux OS, get the developer and open source news and tips you need to know. Delivered Tuesdays and Thursdays