Recently, someone in one of my groups complained that they were having trouble understanding how to create a Table of Contents (TOC) in Word. Bingo! Looks like we need an article on that one. So here it is. This is a fairly basic article on how it works, although I will touch on how to handle the TC field for customizing your TOC entries. In a later article, I'll touch on some tricky techniques to handle more unusual TOC needs.
Time to Learn Styles
If you've been avoiding using styles to this point and you're planning to create a TOC, guess what? It's time to learn to understand styles. Why? Because Word uses the styles hierarchy to establish the outline structure for your table of contents. If you've typed your entire document in Normal style and applied direct formatting to your subtitles, you're in for some extra work because Word won't recognize your headings. You'll need to go through your document and either apply styles (the best way to handle it), or go through and insert TC fields to add the custom content you want in your TOC.
We'll discuss TC fields later in this article. And since this article is not a lesson in understanding styles, I'd suggest you check out this article to get rolling: Getting Started Using Styles.
There's a bit of a misconception when applying heading styles to Word document content when it comes to TOCs. You do not have to use Word's built-in styles, i.e., Heading 1, Heading 2, and so on. You can create your own, custom heading styles with your own, custom naming conventions and set up the TOC formatting dialog box to recognize your styles. In fact, the only time you must use built-in Word styles (only, as far as I know) is when you plan to setup a cross-reference to a Heading (Insert > Reference > Cross-reference > Heading). In that case, content using your custom heading styles won't display in the dialog box as possible choices for the cross-reference link. Only headings with Word's built-in heading styles will be displayed. Depending on your needs, you may be able to get around that one by using Word's Style Reference field. But why make things more difficult for yourself? If you know you'll also need to reference headings in your document (which requires built-in styles), you might as well use the built-in headings throughout (versus creating custom heading styles) and just plug them in for your TOC as well.
But if you won't be needing heading cross-references, then you can create your own styles and call them for your TOC. However, if you're new to Word or new to creating TOCs, you might want to stick with Word's heading styles for now, just to make your life easier and TOC creation simpler. Although, in this article, we'll review both methods.
Creating a Basic Table of Contents
Okay, so you've applied heading styles to your headings. Below is a little sample that I'll use to create a TOC.
As you can see above, I've inserted two main headings, each of which have Heading 1 applied. Then I've added a sub heading under the first main heading and I've applied Heading 2 to that title. Now I need to add a table of contents to this document.
If you want your TOC to appear at the top of this document, you'll need to add a blank page above, if you haven't planned on that page already.
Note that you can create a TOC in a separate document pulling heading information from several other separate documents. To do that, you'll need to use the RD (Reference Document) field. If you're trying to tackle that task, check out the article I wrote on that little trick: Compiling Sub Docs.
For this article, we'll assume you have one document and just need to now stuff a TOC at the top.
If you haven't inserted a page for your TOC at the top of your document, you can do that by hitting Ctrl + Home to move to the top of the file, then hit Ctrl + Enter to insert a hard page break.
One caveat here is if you have special header/footer content that you want to appear on your TOC page. In that case, inserting a blank page at the top of the document might cause header/footer problems for you. Ideally, space for a TOC should have been considered before you started the doc. And most likely, you'd want to click Insert > Break and insert a Next Page Section break, so you can set different page numbering styles and numbers for the TOC versus the start page of the actual content.
But these are things not everyone thinks about (but should) before they jump in and start typing a document. If you get tangled up with special page numbering for your TOC and also need to make adjustments to your header/footer...I'd suggest you click the TechTrax Archive button above on the main menu. Then run a couple of searches. Using keywords of "header" and another using "manual" will get you additional articles and training videos to help understand more complex issues. You can also jump into my free Word Advanced Document Design group, where hundreds of others doing what you're doing are there to help each other get over complex doc hurdles.
Assuming your TOC page is setup as you need, move to that page. Click Insert > Reference > Index and Tables. In Word 2007, click on the References tab of the ribbon. The first group is the Table of Contents group. Click the Table of Contents button to display the same dialog box as shown below from Word 2003.
Word 2007 will jump you right to the Table of Contents tab. In previous versions, make sure you click that tab so you see the same dialog box as shown above.
Now if you don't need to adjust the default formatting and you've also been careful to use Word's heading styles properly, you may be able to simply click the OK button and your TOC will appear on the page. However, it's rarely that easy. Most people want to fiddle with the formatting and such. In this first sample, I accepted all the defaults and just clicked OK, using Word's TOC defaults.
And there you have it, instant table of contents for each level of heading in my document.
Now realize, what you see in my sample above may not be the same as what you get as defaults. I mess with my default headings a lot when testing things for users, so who knows what my default settings are at this point...which is why I always create my own, custom heading styles for files. This way I can be sure that I'm starting with what I want in a style and I also always customize my TOC styles for each file template. In other words, I would rarely create a doc from Word's Normal default template and be restricted to the default settings. When I need to type a document, at least one important enough to require a TOC, I'd most likely start by calling up one of my custom templates to match the type of document I need, i.e., proposal, user manual, etc.
Customizing Your TOC
Let's assume that you didn't have the foresight to create a custom template before hand or maybe you're doing that now and you need to modify the default styles for the various levels in your TOC. You can click the Modify button from the TOC dialog box, which will display all the TOC level styles you can use. Choose the level style you want to modify (in my case, I'll change TOC 2) and click the Modify button in this second dialog box.
In the above image, notice the Preview area at the bottom of the dialog box. That displays info about all the attributes contained in the selected style. Now, again, you'll need to understand styles at this point so you can make the changes you need.
When I click Modify in the above dialog, I move into the style modification dialog box with the TOC 2 style set as the style I'll be changing. From there, I click the font color button to change it from dark red to black. I also uncheck the bold button and choose the italic button. A preview is showing me what my choices will do to my text. I also click the Format button in the style dialog box and choose Tabs to move into the Tab dialog box where I can change the tab stop, as well as add a dot leader.
I then click OK a bunch of times to back out of all these dialog boxes. My modified TOC is inserted. As you can see, the sub heading (TOC 2) style is now black, italic and the page number is pulled in from the right because I set a tab at five inches.
Using Your Own Styles for Headings
If you're like me, you prefer to create your own styles for everything in a new template. As you can see in the image below, I've modified the heading styles a bit by changing the font and color. What you can't see here, but will see shortly, is that I've also renamed the styles to my own, custom names versus using Word's Heading 1, Heading 2 naming convention. If I'm creating a custom template for a company, I generally like to add their company name or acronym to the style so I know who it's for (in my mess of styles I easily accumulate), as well as to help bring attention to the custom styles in the template to the user.
You see, you can't delete the built-in styles and not everyone knows how to display only the user defined styles. So if a new user is using a new company template, it'll be easier for them to know which styles to use if they are called something like OurCompany_Heading1, OurCompany_Bullet1 versus seeing Heading1, Bullet. If nothing else, maybe the custom name will cause them to at least question the difference if they don't understand styles, thereby using the right one. Well, let's hope so, anyway!
Now when I go into the Table of Contents Options dialog box, I need to go find my two heading styles and set their level numbers in so that Word will understand that these are actual heading styles that I want represented in my TOC and also to explain to Word which one should be set at which level...since it won't understand my names and won't know that 1 means first level, etc. I need to enter that info by entering the level numbers.
Now in the image below, however, the default headings are also still selected. This won't make any difference assuming I'm not actually using Word's headings. Since those styles aren't used in my document, they won't show up in the TOC. However, just to make sure that I didn't accidentally apply one of those styles, I could remove those numbers. But then again, if I did mess up my styles, leaving them will ensure that they aren't missed in the TOC! Although if I used those headings for text that shouldn't be in the TOC (not a good move!)...then that text will show up in the TOC...probably not what I want! If you're new to styles and think you may have tangled them up a bit, you might want to leave the default headings checked. Then again...you'll also want to spend some time proofing your TOC to make sure you don't have information you don't want in there or missed something you wanted.
To save yourself the extra proofing...learn to apply styles properly and apply them with care!
Since I've changed the settings of my TOC, Word now asks me if I want to replace the current TOC.
Granted, this version of my TOC (below) doesn't look any different than the last one, but it is. It now uses my custom styles and not the default headings. And notice that the text is black and not blue like my headings. This is because I didn't modify the TOC styles to change the font color. If I wanted the TOC to appear in the same colors, I'd need to make those style changes directly to the TOC styles.
Using the TC Field
If you click Insert > Field and scroll down the list, you'll see a TC field. This is a table of contents entry field. Now it's not the same as the TOC field, which you'll also see in this list. The TC field allows you to enter custom text that will be displayed in the TOC. And although you can use Styles as well as TC fields when compiling a TOC, you'll want to be careful to ensure you understand what you're doing or you'll end up with incorrect information in your TOC.
You'll notice in the image above that I've inserted some custom text Dian's Main Heading for Chapter 1. I've inserted this field marker just before my first heading. I've also set it to show in the level 1 position of my TOC outline format.
Furthermore, if I move to that location and hit Ctrl + Shift + 8 to display my hidden markers, I can see the field in its raw format. (The dotted underline represents the fact that this field is Hidden Text. By turning on my hidden code, I can now see the field details and even modify the field code, directly, if needed...and if I knew what I was doing! Yes, I know how to modify codes directly, but if you don't, you can delete the entered code and try again from the dialog box where the options are easier to understand.)
To use the TC field in your TOC, you need to check an additional option when defining your TOC. Go into the TOC Options dialog box and check the Table Entry Field checkbox at the bottom, as shown below.
Notice that the Styles option is also still checked at the top of the dialog box. That is the default and will be checked when you create a TOC, since Word assumes you'll probably want to use heading styles to call up your TOC content. You can use Styles or TC fields, or even both. But if you use both, pay attention to what you are doing! If you want to use TC fields exclusively in your TOC, uncheck the Styles option.
In this sample step, I only added a TC field for the first heading because I wanted the information that appears in the TOC to be a bit more elaborate than the text that actually appears in the first subheading. However, look below to see what happened!
Notice that I now have a custom heading Dian's Main Heading for Chapter 1, but I also still have the heading that says My First Main Heading...which is what the text in the document actually says. In other words, I have two listings for the same heading, but the TOC displays different text and is pointing to the same information twice. I doubt that's what you'd want. Granted, it may be if you wanted to list both the real heading and some other term for the same thing.
Assuming you might want to have one heading in the text and a modified, maybe more elaborate or simpler heading displayed in the TOC, you would have to remove the heading style being used for this same referenced heading and use some special heading style that isn't called within the TOC, so you don't get a duplicate. Confusing? Yes...which is why incorporating the TC field in this way isn't really the best use of it. (Although I must admit that I have used it to make TOC listings shorter than some particularly long headings...which the boss insisted on and then didn't like the way they looked in the TOC!<sigh> Do the terms Cake and eating it come to mind here? I think so!)
A better use of the TC field would be for adding something into the TOC that you don't plan on styling, such as an illustration or a table.
In the image below, I've inserted a picture. Just to the left of the picture I've inserted a TC field explaining that this is a Polar Bear Photo.
Now when I generate my TOC, a notation for my photo is inserted into the TOC to help the reader easily find it.
You probably will rarely need to use the TC field, but if you come across a boss who is fairly picky, it might come in handy. At least you now know it's there and you have the option of making a custom TOC entry if need be.
Field Toggle and Field Updating
An article discussing fields wouldn't be complete without a mention of the keystrokes for accessing the fields.
The TOC is actually just a field code that expands out to display the information you have requested. So don't try modifying the format of any individual TOC entry from within the TOC; because, when you need to update the TOC, your direct formatting will be lost. If you need to change the way the entry looks, you need to go into the Table of Contents modification dialog, select the TOC style you need to change and click Modify to change that style, as I did further up in this article.
To see the TOC field itself, you need to select the entire TOC and toggle the field to its raw code by hitting Shift + F9. You'll then see the small code that actually generates your TOC, as shown below.
Those additional letters are switches...the options I set when defining my TOC.
And be sure to select the entire TOC before you toggle it. If you only click within the TOC, you'll just toggle that entry. That'll give you a cryptic code, as shown below.
Also, know that your TOC will not update itself. In other words, if you create a TOC and then make changes to the wording in some headings, add more headings or change a heading to a new level, i.e., heading 2 to heading 1, the TOC will not reflect that change until you update it manually. Well, that's not exactly true, because Word will update the file the next time you open it or when you print it, if you've selected those options in Word's Option settings (see Word's options for the update field options for opening and printing, which are found under Office Button > Word Options in 2007 and Tools > Options in other versions).
But most people like to check out the TOC to make sure things are moving along as expected and want to see the TOC in its present state, with all updates displayed. So you can move within the TOC and hit F9 to update the field. When you do that, Word will check to see if you just want the pages updated or if you need to completely regenerate the TOC, as shown below.
Just to be safe, I personally always choose Update entire table.
This article should provide you with enough knowledge to now be dangerous.<smile> Experiment with the TOC and remember that we do have articles in the TechTrax archives that have related details for more complex documents, should you have trouble with other aspects such as headers or page numbering. But don't forget that you can also find help in my free support groups. You'll find a listing of them and others I recommend, here: http://www.mousetrax.com/resources.html.