h1

Word: Adding a TOC for a section

March 4, 2011

If you have a very large Word document, with lots of chapters/sections and several levels of headings and subheadings, you might want to help your document’s readers by adding a ‘mini’ Table of Contents (TOC) in front of each section, just like the publishers of US textbooks have done for years.  These mini TOCs are in addition to the main TOC near the beginning of your document.

The steps that follow are written for Word 2010, but they work equally well for Word 2007. The same sort of mini TOC can also be inserted in a Word 2003 document, but the steps to insert a bookmark and insert a field are different.

There are two main steps:

  1. Insert a bookmark for the section you want to include in the mini TOC
  2. Insert a TOC field that references that bookmark in front of the section.

We’ll create a mini TOC for this section (Section 2):

Step 1: Insert a bookmark

  1. Select all the text in the section (this selection could cover several pages).
  2. Go to the Insert tab and select Bookmark.
  3. Give this bookmark a unique but meaningful name (I’ve called this one Section2), then click Add. NOTE: Bookmarks cannot have spaces.
  4. If you have the Show Bookmarks option turned on (and I suggest that you do), then you’ll see light gray square brackets around the bookmark.

Step 2: Insert a TOC field

Once you’ve set up your bookmark, you need to insert a TOC field in front of the section. Unlike the normal TOC at the beginning of your document that builds the TOC based on just heading levels, your mini TOC is built on the bookmark you defined AND the heading levels within that bookmark (at least, I *think* that’s what’s going on!).

  1. Go to a blank area in front of the section. Press Enter a couple of times to add some space for the mini TOC.
  2. Go to the Insert tab, click Quick Parts, then select Field.
  3. Select TOC from the list of field names on the left, then click the Field Codes button.
  4. Click the Options button at the bottom left of the Field window to open the Field Options window.
  5. On the Field Options window, select \b, then click Add to Field. Hint: If you want to know what each switch does, click on it and read its Description.
  6. Add a space after \b, then type the name of the bookmark you created earlier, then click OK. NOTE: The space after the \b is critical — without it, your TOC won’t work; however, your bookmark name should NOT have a space.
  7. The complete field code, with bookmark switch and the bookmark name you typed, is shown in the Advanced field properties text box on the Field window. Click OK.
  8. The mini TOC is inserted in front of the section heading:
  9. Optional: You can make this section stand out by adding a title for it. In this example, I just typed Section 2 on an empty line in front of the mini TOC, then styled it using Word 2010’s text effects (Home tab, Font group)

More

  • Repeat the steps above for all other sections where you want a mini TOC.
  • To update the mini TOC, put your cursor anywhere in it, then press F9 (or right-click anywhere in the mini TOC and select Update field).
  • If you want to create a fancy title for the mini TOC that reflects the Heading 1 of the section and you don’t want to repeat the Heading 1 in the mini TOC, then don’t select the Heading 1 when selecting the area for the bookmark.
  • Update 27 June 2014: If you PDF your document using the Acrobat add-in, you’ll have clickable links for the main TOC, but not for this mini one, so place your cursor at the beginning of the first line of the mini TOC, right-click, then edit the field for the mini TOC so it looks like this: TOC \o “1-3” \h \z \u \b Section2 (“1-3” tells the mini TOC to display heading levels 1 to 3, and the bookmark name will vary according to which bookmark applies to this mini TOC). Now, when you PDF the doc, the mini TOC will have clickable links.

[Links last checked February 2011]

34 comments

  1. You totally helped me!! and it was so simple, thank you xxxx


  2. Error! Bookmark not defined. – I have followed your steps precisely but still get this error.


  3. i followed your steps too, but got the messages,”Bookmark not defined”. I have done it like a hundred times. so frustrating cos I badly need to do this.


  4. Hi Harry and Sven

    When I followed the steps exactly, it worked. However, if I typed ‘Section 2’ (with a space) for the bookmark name at Step 6, I got the ‘bookmark not defined’ error too. Bookmark names can never have spaces, so typing a space in the bookmark name means that the bookmark named ‘Section’ is not found.

    I’ll modify the steps to make that clearer.

    –Rhonda


  5. Hi Rhonda,

    I followed your step to create a mini TOC but I also received the error “Bookmark not defined”. However, I am trying to create these TOC from section headers and I am not sure this is possible.


  6. Hi Marc

    Creating the mini TOC from section headers is what this post is all about. Other than not having any spaces in the bookmark name, each bookmark name should be unique — i.e. you cannot repeat a bookmark name somewhere else in the document.

    Also, make sure there’s a space after the “\b” and no spaces within “\b”.

    –Rhonda


  7. Hi Rhonda, thank you so much! I followed your steps and it totally worked! But i have a question, how do i update the page numbers on the table of contents in case i add more text in the previous section and the following section starts on a different page? I tried changing the page number directly on the table of contents but when i do that it no longer enable me to ‘hold control then click’ to follow link.


  8. Hi Pontsho

    You have to update the fields — see the second bullet point under ‘More’ at the end of the blog post.

    –Rhonda


  9. This is great – thanks! I have done this in Madcap Flare, but I never had the need to do it in Word — avoiding Word for very long documents anyhow. But it’s good to know… I love your blog!

    Melanie


  10. It’s terrific to be able to add TOC to sections of a document! Thank you.

    Is there a way to remove the gray shading on the table?

    Kathleen


  11. Hi Kathleen

    The gray shading you see in the images above is because I have ‘field shading’ turned on.

    You can turn this off, but I like to keep it on so I can see what’s a field and what’s just plain text so that I don’t inadvertently delete it. NOTE: This gray shading doesn’t print, doesn’t show in a PDF created from the document, and is only ever seen by you. Others working on the document will only see it if they have field shading turned on too.

    See this post for how: https://cybertext.wordpress.com/2010/04/19/word-show-those-fields/

    –Rhonda


  12. The bookmarking and field code \ b works really well for me except when it comes time to update the section’s TOC. 90% of the time Word replaces the bookmark-based TOC with a full document TOC which is precisely what I don’t want.

    When it does this the field code e.g. { TOC \b Chapter2 } is replaced by something like this: { HYPERLINK \l “_Toc366767252” } so it’s not so straight forward to resurrect what I had 5 seconds earlier.

    I’m working on a large document so there are quite a few chapters (~15) with the same number of TOCs to maintain (in addition to the full TOC at the top of the document). The document receives ongoing updates so a solution to this problem would be much appreciated.


  13. Actually, I think I figured it out. The issue I have been experiencing seems to relate to the TOC becoming mixed up with the Level 1 heading immediately above it (i.e. the chapter heading). Right-clicking at the end of the heading, in such cases, offers the “Toggle field codes” option and reveals the tell-tale curly braces of a hyperlink field tacked on.

    It appears some of the existing chapter TOCs were mixed up in that way and until recently I wasn’t deleting all of the existing “field” before attempting to create a new one. By deleting the curly braced field codes in the Level 1 heading I seem to have fixed the issue.


  14. I get the entire document’s TOC. I’m selecting sections 2.1 through 2.6 because I want to show the section title (2.0 Title) plus a paragraph, then the mini-TOC, then 2.1, etc. Per Kathryn’s comment, I turned on field codes and did indeed have a curly brace in my first Head1, making it part of the main TOC. Corrected that. But still get the entire TOC after bookmarking sections 2.1 thru 2.6, then adding the TOC field code. I’m using the /h option (I want the mini-TOC entries to be hyperlinks), followed by a space and my bookmark name. Any advice?


  15. Hi. Thank you so much for posting this. I am just wondering if it is possible to set the levels you want on this type of bookmark. I tried using \l 1-2 in combination with the bookmark info above but Word didn’t like it.


  16. I fixed my own problem – just in case anyone else is wondering… I forgot the quotes around the heading range. So something like this should work TOC \b YourName \o “1-3” … I am not sure the difference between o and l but this seemed to work…


  17. This is great advice. I have used this to create chapter TOCs in a living document. My issue is that when I go to update the overall TOC at the start of the document, it creates 2 listing’s for every entry one from the chapter TOC and then another for the actual entry, any tips?


  18. Hi David

    It sounds like your main TOC is picking up the bookmark references (the \b in the mini TOCs). By default, a main TOC has these field codes: { TOC \o “1-3” \h \z \u }.

    You can check what field codes your main TOC is using by putting your cursor immediately in front of the first main TOC entry, then right-click and select ‘Toggle field codes’ — check the field codes, and if there’s a \b in there, then remove it, and right-click the field code again and select ‘Toggle field codes’ again.

    Hopefully that will work.

    –Rhonda


  19. Rhonda-
    Thank you so much for the reply. I didn’t have the \b field code in there, but your response made me experiment with the other field codes. By removing the field code, it made the TOC work the way that I want it to. My final code for the field code is “TOC \h \z \t “Hidden,1, Heading 2,2″” Where Hidden and Heading 2 are the two styles that I want displayed. Thanks again.


  20. Oops sorry my reply was suppose to say
    …by removing the field code \o “2-2”, it made the TOC work…


  21. […] on from the instructions I wrote for adding a mini TOC to a section in Word, I found a way to also add a mini list of tables and figures for the tables and figures in a […]


  22. Currently trying to understand the switches. For the TOC, is it possible to omit page numbering for multiple non-consecutive TOC levels? For example, using { TOC \o “1-4” \n 1-1 } would omit numbering for level 1, but can it be written so page numbers for levels 1 and 3 are omitted and 2 and 4 are numbered? Thanks in advance!!


  23. Hi Rhonda,
    I exactly followed the steps and worked well. Thanks a lot for the post. You really saved me today. I will teach to my entire team. Once again thank you very much, You are my “HERO”


  24. Magnificent! And so easy, like clockwork!!! I will also inform my colleagues.

    THANK YOU


  25. […] This can in fact be done, but it’s a bit tricky. For this tip, we came across a great article from Cybertext that we recommend you check out: https://cybertext.wordpress.com/2011/03/04/word-adding-a-toc-for-a-section/. […]


  26. This is 2016 and I’m using Word 2010. Using TOC bookmarks is great but when I update it it always has a doublt line spacing and I want only a single line spacing. When I reformat the toc bookmark table it’s good until I update and then it reverts to double spacing. I want to change that spacing permanently. Can i do it.


  27. Hi Jerry

    It sounds as though the styles you have for TOC 1, TOC 2, and TOC 3 all have extra space above/below the paragraph, or are set to multiple lines instead of single lines. You’ll need to modify the paragraph settings of those styles — modifying it in place has no effect because as soon as you update the TOC, the style settings will reapply. NOTE: This will affect the spacing of ALL TOCs you have in your document, not just those for sections.

    –Rhonda


  28. Great! However, if I want to change the format of the section ToC, I can’t. If I choose “Edit Field” then “”ToC”, the section mini-ToC is replaced by the document ToC; if “Edit Field” then “Index”, I get the error “No Index entries found”. Any suggestion for this?


  29. This is really really helpful. Saved a lot of time and effort. Thanks Much !!


  30. Wow!!.. This really saved my life! Thanks a lot :)


  31. Followed your steps and it worked just fine.
    Thank you for sharing your knowledge !


  32. If the doc goes down to say Heading 4, but in the TOC you only want to capture Headings 1 and 2, how do you do this using this method? Thanks.


  33. Hi Peter

    I haven’t done this in a while, so I repeated the steps in this post and got Section 1 to 4 listed as a mini TOC. Then I added some of the info from the note about PDFs and got it to work. Here’s how:
    1. Once you have you mini TOC set up and displayed, right-click on that TOC and select Toggle Field Codes.
    2. The TOC info now looks like this: { TOC \b Section2 \* MERGEFORMAT }
    3. After ‘TOC’ in that code, type: o\ “1-2” (make sure you leave a space between the \ and the “, AND a space before the following \b)
    4. Right-click in the code again and select Toggle Field Codes again.
    5. With your cursor anywhere inside the TOC, press F9 to update the TOC.
    6. Select the option to update the entire table, then press OK.

    You should now have a mini TOC that has only two levels.

    –Rhonda



Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.