Image: Prostock-Studio, Getty Images/iStockphoto

Microsoft Word’s indexing feature is easy to implement. When creating a simple index, you mark terms, and that’s about it. Usually marking entries and generating an index of main entries, or one level, is adequate. Occasionally, you’ll need main and subentries. Trying to determine whether a term is a main or subentry can be a bit tricky. 

In this article, I’ll show you how to switch between the two levels when the original marking doesn’t work as expected. If you don’t know how to create an index in Word, you can read the tutorial How to add an index to a Word document using index fields.

SEE: How to add hyperlinks to a Word document (TechRepublic)

I’m using Microsoft 365 on a Windows 10 64-bit system, but you can use older versions. You can work with your own data or download the demonstration .docx file. The browser edition will display an existing index, but you can’t mark entries or generate an index in the browser.

This article was prompted by a question from Tom Sampson.

The difference between main entries and subentries

Main entries are the first-tier terms. A subentry is a word or phrase that’s related to the main entry. They can also exist as main entries but it’s also important to acknowledge their relationship to another main entry. For instance, you might consider your grandmother the matriarch of your family. Your parents, aunts and uncles, and cousins all fall within your grandmother’s main entry. The relationship between an entry and subentry is similar. 

SEE: How to add a drop down list to an Excel cell (TechRepublic)

For most of us, this relationship works fine; however, occasionally, it seems contrary to what we’re trying to do. Let’s look at a fun example: Yachts and their names. Let’s assume that the word yacht exists within your text along with the names of several yachts. In the index, you want the word yacht to be the main entry and yacht names to be the subentries. It’s sounds simple enough until you try to implement that expectation. Before you can generate an index, you have to mark the entries.

How to mark index entries

We’re going to use an extremely simple example so we can concentrate on what we’re doing. This simple document repeats the same sentence at the top of three pages (so you can see the page numbers change in the index), but the names of the yachts change:

  • Page 1: This is a test of index main and subentries for yacht names like The SS Minnow and Daddy’s Mistress.
  • Page 2: This is a test of index main and subentries for yacht names like Moby’s Fear and My Ship Came In.
  • Page 3: This is a test of index main and subentries for yacht names like Mommy’s Paycheck and My Kids’ Inheritance.

Now, let’s mark the entries for the first sentence on the first page as follows:

  1. Select yacht because it’s the main entry.
  2. Click the References tab.
  3. Click Mark Entry (Figure A) in the Index group.
  4. The default settings are correct, so click Mark and then Close.
  5. Repeat steps 1 through 3 to mark The SS Minnow and Daddy’s Mistress.

Figure A

When you return to the document, Word will display the index fields, as shown in Figure B. Complete the easy steps above to index all of the instance of “yacht” and each yacht name on pages 2 and 3.

Figure B

After marking all of the entries (there are nine), you’re ready to generate the index.

How to generate the index

Generating an index is just as easy as marking the entries, usually. It takes only a few steps; let’s create an index for the example document:

  1. Position the cursor where you want the index; usually an index is at the end of a document and begins at the beginning of a new page.
  2. Click the References tab.
  3. In the Index group, click Insert Index.
  4. In the resulting dialog on the Index tab, change the number of columns to 1 (this isn’t strictly necessary, but I think two columns adds a bit of confusion to the discussion).
  5. Click OK to see the index shown in Figure C.

Figure C

As you can see, it’s not what we wanted. The yacht names are main entries, along with the word yacht. What we want is a list of yachts as subentries under yacht as a main entry. In addition, Word generates the index in a section of its own—it’s worth noting but won’t impact anything we do. One more thing: We don’t want to display the page numbers for every instance of the word yacht in the document; the names are what’s important, but we do want them noted as yachts in the index.

How to switch positions

The problem isn’t serious; in fact, the solution is quite simple. We marked everything as a main entry and that’s what the index gave us. A list of main entry terms with page numbers. First, let’s mark the yacht names as subentries as follows:

  1. If you’re using the demonstration file, remove all of the index fields—simply close the file without saving. If you’ve already saved the file, remove the fields, or recreate one of the sentences (you don’t need the entire list).
  2. Skip the word yacht in the first sentence and select The SS Minnow.
  3. Click the References tab, and then click Mark Entry in the Index group.
  4. Word assumes the selected word or phrase is a main entry; we know that it isn’t. Cut the entry from the Main entry control and copy it to the Subentry control.
  5. Enter yacht as the main entry (Figure D).
  6. Click Mark Entry and the Close.

Figure D

Repeat the steps for all of the yacht names, without ever marking the word yacht in any sentence. When you’re done, generate an index as before. This time, as shown in Figure E, yacht is the main entry and all of the yacht names are subentries of yacht. Also notice that yacht doesn’t display page numbers. If you want the page numbers for yacht, simply mark it each time it occurs or use the Mark All option at the bottom of the Index dialog.

Figure E

Return to any of the marked entries and notice that the code is different. As you can see in Figure F, the field now contains the word yacht—that’s the field’s main entry. You could manually make that change instead of starting over if you only had a few changes to make.

Figure F

The example is a bit contrived, and to tell the truth, you might know how to avoid this problem from the get-go; however, the purpose is to show you how to evaluate terms as main entries or subentries, and how to quickly correct those entries when the index doesn’t generate the results you need.

It’s worth noting that consistency matters a lot when marking index terms. For instance, if you accidentally enter Yacht (uppercase Y) for one yacht name, you will end up with two main entries for yacht and two incomplete lists. In addition, if you select the space of punctuation before the term, the term won’t sort correctly.

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

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