Link to home
Start Free TrialLog in
Avatar of ExpExchHelp
ExpExchHelpFlag for United States of America

asked on

MS-Word -- need help with modifying Table of Content (TOC)

Hello Experts:

Please see attached Word document which contains 3 TOCs.   I need assistance with modifying the "Table TOC" and "Figure TOC".

Essentially, right now all table and figure references (in the chapters) will -- and have to -- display the following:

Table 1.  Structure ABC
Figure 1.  Koala in Australia Zoo

[Note: above are just test examples).


However, given that the actual document will contain hundreds of tables, I was advised that the words "Table" -- and "Figure" should not be listed in the TOCs.

The attached document provides examples what they should look like (please see page 2 and page 3).  

My question:  How do I modify the Table TOC and Figure TOC in order to remove the words "Table" + leading space before table #?   Same applies for the Figure TOC.

Note:  I don't not want to manually remove these words from hundreds of table references and then choose "update page # only".    Instead, when updating the entire table/TOC, I automatically want to display their reference numbers only.

PLEASE HELP!!

Thanks,
EEH
Modifying-TOC.doc
Avatar of Dan Craciun
Dan Craciun
Flag of Romania image

Make the "Table " and "Figure " a differently named style than the "2. Western map".
Then you will be able to set the TOC style to the style of the text.

(Not related) If you want to do hundreds of pages with tables and images, please don't use Word. Try a desktop publishing software that is made specifically for this: Indesign, Quark, Scribus, Publisher if you don't have other choices.
You will save a lot of time and get a better looking output.

HTH,
Dan
Avatar of ExpExchHelp

ASKER

Dan:

Thank you for the prompt response.    Could you please provide me more details how to change the TOC style?   Alternatively, any chance you provide me the example document.

Note:  I'm not forced to use Word, so unfortunately I don't have the flexibility to use a desktop publishing document as you suggested.   Good point though.  ;)

EEH
I tried with the different styles, it does not work. The TOC does not use StyleRef fields, simply collects the entire line.

That being said, if you insert the table and image captions using References->Insert Caption, you can use the /a switch to remove the "Figure 1" or "Table 1" part.
See here for the TOC parameters: http://news.office-watch.com/t/n.aspx?articleid=165&paginate=false

I've attached the modified file. It does not have numbering on the tables/figures names, but I guess you can apply a style with numbering on them to get them to look like you want.

PS1: if you want to see the field code in a Word document, press ALT+F9
PS2: if you're not forced to use Word, then why do you?

HTH,
Dan
Modifying-TOC-v2.doc
Thanks, Dan.

I looked a the ToT and ToF.   Both of them missing the numbers though.  

What I needed is to remove the word, e.g., Table + leading space before the number.  

How can it be modified to include them again?

Thx,
EEH
You add them using Numbering (I mean select the ToT, press Numbering on the ribbon, between Bullets and Multilevel List)

You'll probably need to add tabs as the formatting will change.
I think that the 'Style Separator' option should be usable here. This is the possibility to change the paragraph style mid paragraph, so that, as I understand it, the embedded paragraph style can be used to create the TOC.

However, the usage is less that intuitive, so I am hoping that our man-of-style, Eric Fletcher will notice and give us the benefit of his experience.
ASKER CERTIFIED SOLUTION
Avatar of Paul Sauvé
Paul Sauvé
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
OK. I have now been able to get my head around Style Separators.

Style separators enable different paragraph styles to be applied to text within the same paragraph.They were introduced in Word 2002.  They are useful here because Tables of Contents and Tables of Figures can be created based on a style. The Insert Style Separator button does not appear in the menus by default, so a QAT or command bar button (depending on the Word release) must be added if you need to insert a style separator manually.

In use, the command changes the final paragraph mark of the selected paragraph into a Style Separator. This functionality makes it a bit difficult to selectively change the style of particular text  in a heading or a caption that has already been typed.

In the document you have supplied, the 'Figure' paragraph style that is used for the sample caption. Also in the document, you also have a 'Figure Caption' paragraph style that looks the same. The macro below applies the 'Figure Caption' style to the  text that you say that you want to appear in the table. After it has been run, the Table of Figures can then be created using the 'Figure Caption' style.
Sub ChangeParaStyle()
    Dim para As Paragraph
    Dim rng As Range
    Dim rng2 As Range
    Dim point As Long
    For Each para In ActiveDocument.Paragraphs
        If para.Style = "Figure" Then
            Set rng = para.Range
            If rng.start > point Then    'Code disturbs For Each current paragraph,
                                         'so make sure that we don't work on the same paragraph twice.
                Set rng2 = rng.Duplicate    'Inserting style separator
                rng2.Collapse wdCollapseEnd 'merges paragraphs,
                rng2.Text = vbCr & vbCr     'so add two more.
                rng.Select                     'Range has no InsertStyleSeparator method - 
                Selection.InsertStyleSeparator 'it only works on the Selection.
                rng.MoveStart wdCharacter, Len("Figure ") 'Trim the
                rng.MoveEnd wdCharacter, -1               'range
                rng.Cut                 'Move the text to
                rng.Move wdCharacter, 1 'the other side of
                rng.Paste               'the StyleSeparator
                rng.Style = "Figure Caption"
                rng.Select
                Selection.InsertStyleSeparator
                point = rng.End
            End If
         End If
    Next para
End Sub

Open in new window

You can't do this automatically with the TOC field code. As you probably discovered, the Insert Caption dialog assists in entering the SEQ field and provides an option to include or exclude the "Figure" or "Table" identifier. Unfortunately, it puts it in as text, so it will be included in the TOC.

I don't not want to manually remove these words from hundreds of table references and then choose "update page # only".
You wouldn't need to do that manually. Choose your Table of Figures after it has been updated and open the Find & Replace dialog. In the Find what box, type "Table " (no quotes, but include the trailing space), then use More > Format > Styles and choose the Table of Figures style. Leave the Replace with box empty and click Replace All. This will remove all of the "Table " instances at once from the generated ToC, but won't affect any instances within the document  because they are within "Table" styled ¶s in your example.

Do remember that you'll need to repeat this if you rebuild the ToC — although the "Table " parts won't reappear if you simply update the numbering.

And as an aside re Dan Craciun's comment... While I would agree about using a page layout product for getting very fine design control, Word is quite capable of producing a very large document with tables and figures. I have several examples with >600 pages and several hundred complex tables, figures and many images. Word will certainly choke if you not used properly, but that is also true for products like InDesign.
I've seen examples of huge documents made in Word too. And I still pity their authors...

As someone who did print layout for a living in the early 2000s, I was forced to use Word for dictionaries, cause nested styles in Indesign weren't available yet and I was better with VBA than with JS.
Learned a lot about Word, did the job, hated it. Layout in Word is clumsy, the output lacks fine control for print, the time required to position elements in a page is huge compared with Indesign/Quark. Don't get me started on proxy images :)

My point: Word is very good for business documents, where you simply need to present text and some tables/images. Don't try to make it do everything. And definitely don't use it for jobs that require offset printing.

My 2¢
Dan
There are always workarounds to get the results you want in Word. But they're always a pain in the thigh or thereabouts!
Everyone... thank you for your feedback.   I truly appreciate it.

In the end, I will have to award the points to Paul for a most excellent solution.  

Again, I thank everyone for their contributions as part of this question.
Thank you. Glad to be of assistance
Paul Sauve