• Tables of Contents (Word 2003)

    Author
    Topic
    #435648

    Hello,

    I have a document with one master table of contents that is based on Styles. That table of contents has a section called “Statutory Compilation” which is a compilation of my state’s statutes. When the preson goes to the first page of the statutory compilation, I want there to be another table of contents with the names of each Title of the statutes and its page number.

    Every time I set up my second table of contents to be based on Styles, everything gets screwed up becasue the entries in the statutory compilation wind up in the master table of contents, and the entries from the master table of contents end up in my statutory compilation table of contents.

    I don’t want to manually mark table entry fields–I have neither the time nor the patience.

    What can I do?

    Viewing 0 reply threads
    Author
    Replies
    • #1030285

      Press Alt+F9 to display field codes. A table of contents will look like this:

      { TOC o “1-3” }

      if it is to include all text formatted with the Heading1, Heading2 and Heading3 styles (levels are assigned automatically), or like this:

      { TOC t “ThisStyle,1,ThatStyle,2” }

      if it is to include all text formatted with ThisStyle as level 1, and all text formatted as ThatStyle as level 2. The o and t switches can occur in the same TOC. There are also other switches, but these two are important for what you want to do.

      Look at the switches in your TOC fields. You may see why they don’t do what you want, and be able to modify them as needed. If not, you could copy the text between the brackets { } and paste it into a reply.

      • #1031021

        Hi Hans,

        Actually, that is not what my TOC field looks like. It looks like this: { TOC O “1-1″H Z }

        I still don’t understand how to create a second table of contents for a second set of entries by using styles, while preventing entries from my other TOC appearing in there.

        JMT
        How can I do it?

        • #1031028

          The H Z are just additional switches that specify how the TOC is displayed, they don’t control the contents of the TOC. H specifies that the TOC entries will act as clickable hyperlinks, and Z that the tab and page number after each entry will be suppressed in web layout view.
          Your TOC is *not* based on styles, but on outline levels: the content of the TOC is specified by o “1-1”. This tells Word to include all paragraphs that have been set to outline level 1 (only). Text formatted with the Heading 1 style is automatically assigned level 1, as is text formatted with the Title style. You can assign level 1 to other styles, and to individual paragraphs, in the Paragraph dialog. All paragraphs with outline level 1, whether it has been inherited from the style, or whether it has been set manually, will be included as TOC entries. You can, however, modify this by clicking Options in the Table of Contents tab of the Insert | Reference | Index and Tables dialog.

          If you want to create a TOC based on styles, you must click Options… in this dialog, and delete the outline levels for the styles you do *not* want to occur in your TOC, and enter outline levels for the styles you *do* want to appear in your TOC. In particular, you may want to delete the outline levels for styles such as Heading 1 that are included in the other TOC.

          • #1031059

            If you are uncomfortable with the switches, as am I –at least until I learn them better– you might try what I use to get figure and table lists, which appear after the main TOC. I’m usually working with docs nearing final, so Word’s autonumbering has been removed and we’ve used custom table and figure styles for the captions. As far as I can tell, you can generate any list of styled paragraphs using this method.

            I usually leave one return after the main TOC, but that may not be necessary. From the Index and Tables dialog box, choose the Table of figures tab. Choose none for the caption label. Then click the options tab. Click the Style box that appears after Build table of figures from” and then choose the style you want to collect in your special TOC.

            Word generates code like this:
            { TOC o “1-3” h z u }

            { TOC h z t “Caption – Figure,1” c }

            { TOC h z t “Caption – Table,1” c }

            where Caption – Figure and Caption – Table are my custom style names.

            Pam
            Freelance writer/editor

            • #1031116

              Hans:

              So if I understand correctly, you are suggesting that I create the second TOC as an outline-based TOC, and in order to avoid having all of the style-based entries that will be in my first TOC, that I go back and remove the outline levels from the styles of the items that I don’t want in my second TOC. Therefore, I will have one TOC based on styles and one based on outlines, and neither will have entries meant to go to the other.

              That sounds nice, but what if I am writing a book with five chapters, and each chapter has its own table of contents. Using your method, I will only be able to get at most two TOCs. If, on the third one, I base it on styles, then entries from my first, styles-based TOC will get in there. If I base my third one on outline levels, then stuff from my second, outline-based TOC will get in there.

              Can I get around this?

              Pam:

              That sounds like a good idea, but will a table of figures be clickable? I mean, will I be able to click on it and get right to the page I want?

              Thanks,

              JMT

            • #1031119

              You hadn’t mentioned that you had five chapters, each of which is to have a separate TOC.
              I would do it like this:
              – Create a bookmark for each chapter (i.e. a bookmark Chapter1 containing the entire text of chapter 1, a bookmark Chapter 2 containing the entire text of chapter 2, etc.)
              – Create a TOC based on outline levels or on styles, whichever you prefer, located in Chapter 1.
              – After creating it, press Alt+F9 to view field codes.
              – Insert a switch b Chapter1 after the word TOC in the field. The field code will now look something like

              { TOC b Chapter1 o “1-1” h z }

              or

              { TOC b t “Heading 1,1” h z }

              – This TOC will now only include entries within Chapter 1.
              – Copy and paste this field code (including the brackets) to the other chapters, and modify the bookmark name accordingly.
              – When done, press Alt+F9 to hide the field codes.
              – Select the entire document (Ctrl+A), then press F9 to update fields.-
              – You’ll be prompted whether to update only page numbers or the entire table for each TOC.
              – Select the option to update the entire table.

              See (for example) the section A partial table of contents in Customizing your table of contents with switches for more info.

            • #1033473

              Hi Hans,

              When I press cntrl + A to update the TOC, Word keeps sending me a dialogue box to ask if I want to update only the page numbers for every TOC in the document. Is there a way to select, “Yes to all,” rather than keep checking the boxes?

              Thank you,

              JMT

            • #1033490

              No, but you could create a macro

              Sub UpdateAllTOCs()
              Dim toc As TableOfContents
              For Each toc In ActiveDocument.TablesOfContents
              toc.Update
              Next toc
              End Sub

              and run that if you want to update all TOCs. You can assign the macro to a custom toolbar button and/or keyboard shortcut to make it easily available.

            • #1033735

              Is there code that can be added to this Update TOC macro to also update the List of Tables and List of Figures?

            • #1033736

              A list of tables and a list of figures are both special forms of a table of contents, so the macro I posted will update those too.

            • #1033753

              In my test file only the TOC updated with your macro. The LOT and LOF did not.

            • #1033757

              Sorry about that, I ddn’t actually test it. I didn’t know that Word treated them differently (they are all TOC fields). You can add the following code to the macro; it updates both the List of Figures and the List of Tables for me:

              Dim tof As TableOfFigures
              For Each tof In ActiveDocument.TablesOfFigures
              tof.Update
              Next tof

            • #1033776

              The added code works fine. Now the TOC, LOT, and LOF are all updated with one click. Great macro to keep. Thanks, Hans

            • #1031122

              Yes, the table of figures is clickable. The h in the code is the switch for hyperlinks. I was pondering the use of bookmarks when Hans’ latest message came through post 602,833 . His advice there is, I believe, the answer to your problem.

              Pam

    Viewing 0 reply threads
    Reply To: Tables of Contents (Word 2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: