A custom TOC

P

Paul Terrano

I posted the following question in August 2003 and received no
responses. I'm hoping for better luck now.

I am preparing documentation for a program that uses a large
number of functions to manipulate stock prices. This volume
contains one or at most two pages to describe each function and
they are arranged in alphabetical order. There are about 240 of
these functions and I wanted the TOC to look like this:



ABS Return the absolute value of a number
3

ACCDISTR Calculate the Accumulation/Distribution indicator
4

ASCII Return a string containing a character specified by a
value 22



BDAYS Returns the number of business days between two dates
23



and so forth.



This example was keyed in by hand to avoid a text conversion from
Word. The space between the end of the description and the page
number includes the usual dot leader.



The descriptive phrases shown do not appear in the underlying
documentation, so the techniques for using manual line breaks or
unusual formatting do not apply as far as I am able to determine.
TC fields appeared to have some hope and I created entries like
{TC "ABS>Return the absolute value of a number"}. {} was produced
by Ctrl+F9 and > represents the tab symbol. I was unable to
format the tab, so the comments did not line up. There are some
indications in the numerous articles and news entries that I read
that this may be a bug in Word 2000.



I then used a scheme described by McGhie and others where the TC
entry is entered as {TC "ABS@Return the absolute value of a
number"} while the first entry when the initial letter changes
is coded as {TC "@@BDAYS@Returns the number of business days
between two dates"}. After the toc is created, @@ is replaced by
a hard return and @ is replaced by a tab.



This scheme works tolerably well, but specifying a tab to be 1.0"
using Format|Tabs|Set doesn't stick. Usually the tab replacement
step results in a dotted leader appearing between the function
name and the description as well as between the description and
the page number, but resetting the tab with Format|Tabs|Set fixes
the toc spacing and the tab and leader between the description
and page number is unaffected. Each TC field is on the same page
as the function so that Word is able to create the correct page
number. The default TOC1 style is used to produce the table of
contents. I do not anticipate a great deal of maintenance, so I
am considering a completely hand-built toc.



Although I am pretty happy with the @ scheme, Pride Goeth Before
a Fall, so I would appreciate some analysis and suggestions from
the knowledgable contributors to this newsgroup. I have only
created a few entries so that not much work will be lost if a
superior alternative surfaces.
 
S

Shauna Kelly

Hi Paul

Your real problem appears to be with the tabs. Are you modifying the TOC 1
style, or are you modifying the TOC itself once its created? If you change
the formatting of the TOC directly, your changes won't survive the updating
of the TOC. You have to modify the TOC 1 style itself.

Try modifying the TOC 1 style to have a left-aligned tab at 3cm and a
right-aligned tab at 15cm and a hanging indent of 3cm. Change the 15cm tab
as required to position your page numbers against the right margin. If you
need to adjust the 3cm tab, make sure you change the hanging indent as well.
They must match for all to work perfectly.

You then won't need the @ and replace solution. Just do { TC
ABS>Return.... } where > is a Tab.

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
 
S

Suzanne S. Barnhill

By default, Word converts tabs in TOC entries to spaces unless you use the
\w switch. It may be that this does not apply when TC fields are used, but I
would suspect it would. Experimentation on another problem earlier today
also revealed that the \w switch appears not to work in Word 2003. Can you
confirm or deny any of the above wrt Word 2000 or 2003?
 
P

Paul Terrano

A reply to the comments by Shauna Kelly and Suzanne Barnhill.

Windows 2000 Pro, 5.0.2195, SP-4 & Word 2000 (9.0.6926, SP-3)

To minimize the effect of extraneous codes, styles and gremlins,
I created a nine-page document with the following characteristics
on each page except the first.

· A function name, formatted with Heading 1. The style
includes" page break before". There is no other text on the page.

· The header is empty

· The footer contains only a page number field, {PAGE}.

· A toc entry typically, { TC “VSTYPE<tab>Set the type for
a vector” } on each page.

· The style TOC 1 is defined as - TNR, 10pt, English(US),
Indent: Hanging 1.25", flush left, line spacing single,
widow/orphan control, Tabs: 1.25", 6" right flush …

· The field code on page 1 initially was{ TOC \o “1-1” \h
\z }. It was created from the Insert>Index and Tables dialog.

The toc that is produced is:

VSTYPE<tab with a dotted leader>2

VSUM<tab with a dotted leader >3

And so forth. The page numbers are aligned. The left and right
margins in Page Setup are each 1.25”. On a printed page, the left
margin is 1.25” but the right margin is 1.56” The additional text
from the TC field has not appeared.

The presence or absence of the \w switch does not appear to make
any difference.

Analysis by experimentation



I replaced the tab in the TC field with an @ and rebuilt the toc
and it was unchanged from that shown above. The tab persisted and
the text from the TC field did not appear.



I added a page similar to the others to get a page 10 displayed
in the toc. The page number is not right aligned.



The \o, \h and \z switches appear to be functioning, but deleting
\o “1-1” doesn’t change the appearance of the toc.



I renamed Normal.dot and created a single page document as above,
but using only the default Heading 1 style. The toc created had a
function name a dotted leader and a page number just as above.
 
S

Suzanne S. Barnhill

I think we're talking about different things. When you generate a TOC, Word
inserts one tab character automatically. This is the tab (with a dot leader)
that goes to the page number. Attempts to add another tab character to the
TOC entry (by adding a tab character to the heading or TC field) don't seem
to be terribly successful. Are you saying that the tab character you use in
your TC field *is* preserved?

Also, I'm curious about the way you're building your TOC. The \o switch
tells Word to include built-in heading styles with the outline level(s)
specified (1-3 by default). If you want to use TC fields only (which you'd
need to do if you don't want your entries duplicated), you would need to
clear the check boxes for "Styles" and "Outline levels" and check the box
for "Table entry fields"). This selection, with all other settings left at
their defaults, produces this TOC field:

{ TOC \f \h \z }

The reason you're not getting anything but the text formatted with Heading 1
(rather than the contents of your TC field) is thus that you have an \o
switch rather than an \f switch in the field.
 
P

Paul Terrano

Outstanding! 'Twas the \f switch. I thought I tried all the
switches individually, but obviously not. I now need to clean up
a few things to report authoritatively about the "preserved tabs"

Thank you. Happy New Year
 
P

Paul Terrano

Using Win 2000(SP4) & Word 2000(SP3), I experimented some with
the setting of tabs in the table of contents. The results are
reported below in the order they were performed The advice
previously given by both Shauna Kelly and Suzanne Barnhill in
this thread was both clear and accurate and had I been a little
more careful, would have worked the first time.

If you change the first tab (i.e. the one with the smallest
dimension), the offset for the hanging indent changes
automatically.

A dotted leader, if desired, must be associated with the longer
tab (i.e. the one just prior to the page number). If it
associated with the other tab(s) there will be multiple leaders.
This may be a useful construct in some situations.

If you happen to view the tab settings from the Format>Tabs menu
and there is a default tab setting shown, the hanging indent may
be changed without notice.

To test the persistence of tabs, I added a \w switch to the TOC
field which now reads { TOC \f \h \z \w }. The tabs set in the
TOC 1 style were 1.1 inches left and 6 inches right; both tabs
associated with a dotted leader. To this set, I added a 1.5 inch
left tab, no leader. In the first two of my TC definitions I
added a tab next to the one that was there. In the resulting
table of contents, the first two entries had three tabs while all
the rest showed 2 tabs. The first two entries had leaders
associated with the first and third tabs and none for the second.

Removing the \w switch and updating the table of contents causes
the second tab (of three) to be ignored and does not show the
leader associated with the first tab. Just adding the \w switch
back and updating the toc again restores both the second tab and
the initial leader.
 
S

Suzanne S. Barnhill

It would appear then, that the \w switch works (a) in Word 2000 (b) if the
tab character is added to a TC field. Without further experimentation, it's
difficult to determine whether (a) or (b) is the vital factor. It does *not*
work for me in Word 2003 if the tab character is added at the end of a
heading.
 

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