TOC created from field codes

S

Sol Apache

Hello

Someone on this list or another has mentioned offside that TOCs can be
generated using field codes, or something other than the automatic TOC.

Can anyone point me in the direction of some information on this? I am
having problems with automatically created TOCs and would like to create one
with non-standard style but with persistent data.

Thanks


Sol
 
D

Daiya Mitchell

You can build it from TC fields. Each TC field has to be entered manually,
but you can easily set your own text. Probably the most relevant Help topic
is " Field codes: TC (Table of Contents Entry) field"
 
S

Sol Apache

Hi Dalya

Thanks for this, but I am somewhat confused, and I have read the Help topic.
Do I have to mark each heading which has to go into the TOC? The TOC will be
part of a report template to be used by several people for different reports
and the TOC will be updated as the report-making progresses. How do I enter
this manually?

What I want to do is create a macro which replaces the auto TOC and
consistently creates the following:

Level 1 style using TOC1 but with no page numbers
Level 2 style using TOC2 but with no page numbers
(both of these entries are really headers within the TOC)
Level 3 style using TOC3 (a bulleted style) with page numbers at the right
margin.

I cannot see how I can do this with the auto TOC (and I have tried to!). Can
I do it using the TC fields? If so, how do I generate the TOC I want using
TC fields?

None of the styles I have marked to go into the TOC are named Heading 1,
Heading 2, Heading 3 but I can change that if it makes TOC creation easier.
I have instead set them at Level 1, 2 & 3. With the auto TOC I can select
the styles I want, but the selection does not stay. I have to select the
styles every time I want to create a TOC and that¹s not practical for
template users who don¹t know much about Word.

I have already reformatted the TOC1, TOC2 and TOC3 styles for my purposes,
though I cannot get the TOC3 style to put the page number at the right
(maybe the bullet is affecting this)


Many thanks


Sol
 
J

John McGhie [MVP - Word and Word Macintosh]

Hi Sol:

No. This is a little confusing, the Help could be better worded.

1) There are two ways to build the TOC, one with Style names, the other
with TC Codes.

2) The two methods are not mutually-exclusive. You can have both in the
one document. If you do, you better really know what you're doing because
the range of permutations and variations rapidly gets to be extreme.

For almost every known case imaginable, use Style Names to rebuild your TOC.

3) Where at all possible, customise the formatting of the existing built-in
Word styles Heading 1 through Heading 9 for your headings, and use those
styles for the document headings. If you do that, you do not need to do
anything else: the TOC will build automatically when you insert it.

4) When creating highly-complex structured documentation, there "may" be
times when you need to use TC fields. These should basically be used only
IN ADDITION to the style names, and only for things such as Appendixes with
Numbered headings. Even in those cases, it's usually far better to continue
using style names to build the TOC.

It has been about five or ten years since I was last forced to use TC fields
in a TOC. I occasionally encounter them in documents built by people who
did not really understand the mechanism, but I have never seen an actual
condition where they were actually needed.

This is important, because using TC fields is a lot of work and a lot of
maintenance in a long document :)

A correctly-structured and formatted document does not require TC fields. A
document in which "some" of the level 3 headings should be in the TOC and
"some" should not, DOES require TC fields. It usually also requires some
serious editing and design help :) (If the TOC should contain level 3
headings, then logically, it should contain all of them. If the book
contains some headings at level 3 that do not belong in the TOC, then the
book has structural problems. Using the TOC is one quick way to find them!

To omit page numbers from your top two styles, add \n "1-2" to your TOC
field (without the quotes). E.g. { TOC \o "1-5" \n "1-2" } Technically,
you do not require the quotes arount "1-2", but I put them in to make things
easier to read.

While you do not HAVE to use the built-in Heading styles for your headings,
I implore you to do so: you will save just so MUCH work and frustration down
the track. Yes, you "can" create your own heading styles. Yes, they "will"
work OK if you do it perfectly. And yes, you "could" even train your other
authors to use them.

But in any realistic group working environment, I can tell you from bitter
experience that misery, corruption, late nights and bitter thoughts will be
in your future. The built-in styles contain some hard-coded properties that
force them to be suitable for this usage. Because they're hard-coded, users
can't change them and thus stuff things up for you :)

Hope this helps



Hi Dalya

Thanks for this, but I am somewhat confused, and I have read the Help topic.
Do I have to mark each heading which has to go into the TOC? The TOC will be
part of a report template to be used by several people for different reports
and the TOC will be updated as the report-making progresses. How do I enter
this manually?

What I want to do is create a macro which replaces the auto TOC and
consistently creates the following:

Level 1 style using TOC1 but with no page numbers
Level 2 style using TOC2 but with no page numbers
(both of these entries are really headers within the TOC)
Level 3 style using TOC3 (a bulleted style) with page numbers at the right
margin.

I cannot see how I can do this with the auto TOC (and I have tried to!). Can
I do it using the TC fields? If so, how do I generate the TOC I want using
TC fields?

None of the styles I have marked to go into the TOC are named Heading 1,
Heading 2, Heading 3 but I can change that if it makes TOC creation easier.
I have instead set them at Level 1, 2 & 3. With the auto TOC I can select
the styles I want, but the selection does not stay. I have to select the
styles every time I want to create a TOC and that¹s not practical for
template users who don¹t know much about Word.

I have already reformatted the TOC1, TOC2 and TOC3 styles for my purposes,
though I cannot get the TOC3 style to put the page number at the right
(maybe the bullet is affecting this)


Many thanks


Sol

--

Please reply to the newsgroup to maintain the thread. Please do not email
me unless I ask you to.

John McGhie <[email protected]>
Microsoft MVP, Word and Word for Macintosh. Consultant Technical Writer
Sydney, Australia +61 4 1209 1410
 
D

Daiya Mitchell

To omit page numbers from your top two styles, add \n "1-2" to your TOC
field (without the quotes). E.g. { TOC \o "1-5" \n "1-2" } Technically,
you do not require the quotes arount "1-2", but I put them in to make things
easier to read.

Yes, this is the solution to what you want. "1-5" and "1-2" refer to
built-in Heading styles by that number. Once the field code is set up
correctly, F9 will update it by any user. If you need a macro for some
reason (though I don't see why you would), the macro can just type the field
code, rather than mess with the dialog at all.

For more information that breaks that field code down more thoroughly, see
here (though we don't have access to everything detailed in this article on
the Mac, notably the hyperlink switch. But it explains how it all works)
http://word.mvps.org/faqs/formatting/TOCSwitches.htm
(hit refresh a few times in Safari, or use a different browser)
While you do not HAVE to use the built-in Heading styles for your headings,
I implore you to do so:

Extended version of that here:
http://shaunakelly.com/word/numbering/UseBuiltInHeadingStyles.html

And one thing--I would not call your styles Level 1, etc, because outline
level is a property of a style and it seems likely to get confusing. But
presumably you will now be convinced to just use Headings 1-3 instead.

I'm not totally sure about the page number at the right for TOC3. Since you
are not using the dialog to set the format for the TOC styles, you may have
to include a right tab as part of the TOC3 style definition.

Daiya
[Desired result]:
Level 1 style using TOC1 but with no page numbers
Level 2 style using TOC2 but with no page numbers
(both of these entries are really headers within the TOC)
Level 3 style using TOC3 (a bulleted style) with page numbers at the right
margin.

I cannot see how I can do this with the auto TOC (and I have tried to!). Can
I do it using the TC fields? If so, how do I generate the TOC I want using
TC fields?

None of the styles I have marked to go into the TOC are named Heading 1,
Heading 2, Heading 3 but I can change that if it makes TOC creation easier.
I have instead set them at Level 1, 2 & 3. With the auto TOC I can select
the styles I want, but the selection does not stay. I have to select the
styles every time I want to create a TOC and that¹s not practical for
template users who don¹t know much about Word.

I have already reformatted the TOC1, TOC2 and TOC3 styles for my purposes,
though I cannot get the TOC3 style to put the page number at the right
(maybe the bullet is affecting this)
 
S

Sol Apache

HI Daiya

Thanks for replying and I now have a working TOC set out the way I need to
have it - following the instructions from you and John

You misunderstood me about the use of levels. I haven¹t named the styles
³Level 1, Level 2² etc, rather I set the styles at Level 1, Level 2 etc.
rather than at Body Text level for outline purposes.

At the moment the TOC works fine with the style names (Main page heading,
subhead 1, etc.) so I might risk letting them stay rather than changing them
to Heading 1, 2 and 3.

Sol


To omit page numbers from your top two styles, add \n "1-2" to your TOC
field (without the quotes). E.g. { TOC \o "1-5" \n "1-2" } Technically,
you do not require the quotes arount "1-2", but I put them in to make things
easier to read.

Yes, this is the solution to what you want. "1-5" and "1-2" refer to
built-in Heading styles by that number. Once the field code is set up
correctly, F9 will update it by any user. If you need a macro for some
reason (though I don't see why you would), the macro can just type the field
code, rather than mess with the dialog at all.

For more information that breaks that field code down more thoroughly, see
here (though we don't have access to everything detailed in this article on
the Mac, notably the hyperlink switch. But it explains how it all works)
http://word.mvps.org/faqs/formatting/TOCSwitches.htm
(hit refresh a few times in Safari, or use a different browser)
While you do not HAVE to use the built-in Heading styles for your headings,
I implore you to do so:

Extended version of that here:
http://shaunakelly.com/word/numbering/UseBuiltInHeadingStyles.html

And one thing--I would not call your styles Level 1, etc, because outline
level is a property of a style and it seems likely to get confusing. But
presumably you will now be convinced to just use Headings 1-3 instead.

I'm not totally sure about the page number at the right for TOC3. Since you
are not using the dialog to set the format for the TOC styles, you may have
to include a right tab as part of the TOC3 style definition.

Daiya
[Desired result]:
Level 1 style using TOC1 but with no page numbers
Level 2 style using TOC2 but with no page numbers
(both of these entries are really headers within the TOC)
Level 3 style using TOC3 (a bulleted style) with page numbers at the right
margin.

I cannot see how I can do this with the auto TOC (and I have tried to!). Can
I do it using the TC fields? If so, how do I generate the TOC I want using
TC fields?

None of the styles I have marked to go into the TOC are named Heading 1,
Heading 2, Heading 3 but I can change that if it makes TOC creation easier.
I have instead set them at Level 1, 2 & 3. With the auto TOC I can select
the styles I want, but the selection does not stay. I have to select the
styles every time I want to create a TOC and that¹s not practical for
template users who don¹t know much about Word.

I have already reformatted the TOC1, TOC2 and TOC3 styles for my purposes,
though I cannot get the TOC3 style to put the page number at the right
(maybe the bullet is affecting this)
 
J

John McGhie [MVP - Word and Word Macintosh]

Hi Sol:

If you are the only one editing the documents, then I would not bother to
change. You are doing two or three times as much work to set up your own
styles, but you have done the work now, and assuming you have done it
correctly the result will be stable.

If you have other users editing the documents, and particularly if they are
not fully trained in complex document production, then I would recommend
that you do switch the styles for the built-in ones. Simply because the
built-in Heading series have their level properties and some others
hard-coded, so unskilled uses *can't* break them, no matter what they do to
them.

Cheers


HI Daiya

Thanks for replying and I now have a working TOC set out the way I need to
have it - following the instructions from you and John

You misunderstood me about the use of levels. I haven¹t named the styles
³Level 1, Level 2² etc, rather I set the styles at Level 1, Level 2 etc.
rather than at Body Text level for outline purposes.

At the moment the TOC works fine with the style names (Main page heading,
subhead 1, etc.) so I might risk letting them stay rather than changing them
to Heading 1, 2 and 3.

Sol


To omit page numbers from your top two styles, add \n "1-2" to your TOC
field (without the quotes). E.g. { TOC \o "1-5" \n "1-2" } Technically,
you do not require the quotes arount "1-2", but I put them in to make things
easier to read.

Yes, this is the solution to what you want. "1-5" and "1-2" refer to
built-in Heading styles by that number. Once the field code is set up
correctly, F9 will update it by any user. If you need a macro for some
reason (though I don't see why you would), the macro can just type the field
code, rather than mess with the dialog at all.

For more information that breaks that field code down more thoroughly, see
here (though we don't have access to everything detailed in this article on
the Mac, notably the hyperlink switch. But it explains how it all works)
http://word.mvps.org/faqs/formatting/TOCSwitches.htm
(hit refresh a few times in Safari, or use a different browser)
While you do not HAVE to use the built-in Heading styles for your headings,
I implore you to do so:

Extended version of that here:
http://shaunakelly.com/word/numbering/UseBuiltInHeadingStyles.html

And one thing--I would not call your styles Level 1, etc, because outline
level is a property of a style and it seems likely to get confusing. But
presumably you will now be convinced to just use Headings 1-3 instead.

I'm not totally sure about the page number at the right for TOC3. Since you
are not using the dialog to set the format for the TOC styles, you may have
to include a right tab as part of the TOC3 style definition.

Daiya
[Desired result]:
Level 1 style using TOC1 but with no page numbers
Level 2 style using TOC2 but with no page numbers
(both of these entries are really headers within the TOC)
Level 3 style using TOC3 (a bulleted style) with page numbers at the right
margin.

I cannot see how I can do this with the auto TOC (and I have tried to!).
Can
I do it using the TC fields? If so, how do I generate the TOC I want using
TC fields?

None of the styles I have marked to go into the TOC are named Heading 1,
Heading 2, Heading 3 but I can change that if it makes TOC creation easier.
I have instead set them at Level 1, 2 & 3. With the auto TOC I can select
the styles I want, but the selection does not stay. I have to select the
styles every time I want to create a TOC and that¹s not practical for
template users who don¹t know much about Word.

I have already reformatted the TOC1, TOC2 and TOC3 styles for my purposes,
though I cannot get the TOC3 style to put the page number at the right
(maybe the bullet is affecting this)

--

Please reply to the newsgroup to maintain the thread. Please do not email
me unless I ask you to.

John McGhie <[email protected]>
Microsoft MVP, Word and Word for Macintosh. Consultant Technical Writer
Sydney, Australia +61 4 1209 1410
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top