Remove right alignment of page numbers in TOC

jmt356
SilverLounger
Posts: 2389
Joined: 28 Mar 2010, 01:49

Remove right alignment of page numbers in TOC

Post by jmt356 »

I have a TOC that currently displays the chapter name, followed by a dotted tab (leader), followed by the right-aligned page number. I want to remove the dotted tab (leader) and the right-alignment of the page numbers. I'd like the page numbers separated from the text of the chapter name with either 5 spaces, an undotted tab (leader), a decimal symbol (this: •), a comma, or, if none of these are possible, two spaces. Is there anything I can add to this table of contents code in order to achieve this effect?

My TOC code is:
{ TOC \h \z \t "Heading 1,1, Level 1,1"}

If this is too complicated, simply adding something to the code to remove the right alignment of page numbers would be an adequate solution.

Thanks so much!
Regards,

JMT

User avatar
HansV
Administrator
Posts: 78488
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Remove right alignment of page numbers in TOC

Post by HansV »

Use the \p switch:

Code: Select all

{ TOC \h \z \p "     " \t "Heading 1,1, Level 1,1"}
or

Code: Select all

{ TOC \h \z \p "•" \t "Heading 1,1, Level 1,1"}
From the Word help for the TOC field:
\p "Separators"
Specifies the characters that separate an entry and its page number. For example, the field { TOC \p "—" }, with an em dash, displays a result such as "Selecting Text—53." The default is a tab with leader dots. You can use up to five characters, which must be enclosed in quotation marks.
Best wishes,
Hans

jmt356
SilverLounger
Posts: 2389
Joined: 28 Mar 2010, 01:49

Re: Remove right alignment of page numbers in TOC

Post by jmt356 »

Thank you. But why can't I get the spaces to show up? When I put 5 spaces, the number is still pushed up right against the chapter title. When I put space, decimal, space, nothing shows up. When I put decimal, space, I get only decimal. When I try comma, space, I get only a comma.

I'd also like to try to keep a tab between the chapter name and the page number, but leave the tab undotted and not have the page number right aligned; to put the page number at the .5" tab mark to the right of hte end of hte chapter. I tried using this:
{TOC \h \z \p " " \t "Heading 1,1, Level 1,1"} (there's a tab between the quoates after the p).

However, the page numbers remained right aligned. I was able to do this by clearing the right aligned tab by deletign all tabs in the TOC 1 style, but the right aligned tabs came back when I updated the TOC. How do I make it stick?
Regards,

JMT

User avatar
HansV
Administrator
Posts: 78488
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Remove right alignment of page numbers in TOC

Post by HansV »

Although the help file for Word 2003 claims that you can use up to five characters as custom separator, it appears that only the first character is used and the rest is ignored.
If you still want a tab, you don't need the \p switch. You can set a tab at the desired position, without tab leader, in the style definition. I'd clear the check box "Automatically update" to prevent unexpected changes to the style.
This works for me, but I have to admit that TOC updates have a will of their own, it can be difficult to control them.
Best wishes,
Hans

jmt356
SilverLounger
Posts: 2389
Joined: 28 Mar 2010, 01:49

Re: Remove right alignment of page numbers in TOC

Post by jmt356 »

Is that also the case in MS Word 2007?

I find a single space or character isn't enough to separate the text from the page number. I found the em dash (—) to however be adequate.

In order to add a non-right aligned tab between the text and the page number, I deleted the p switch and modified the Tab dialogue in the Modify style dialogue for TOC 1. Rather than simply clear the right tab and leave it at that (this gave me the effect I wanted until I updated the TOC), I cleared the right tab, added a new .5" left tab and a .5" default tab, and exited out. The non right-aligned tab now works even after I update the TOC. This is true whether or not I had Automatically update selected in the Modify style dialogue.
Last edited by jmt356 on 14 Mar 2011, 12:19, edited 1 time in total.
Regards,

JMT

User avatar
StuartR
Administrator
Posts: 12605
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: Remove right alignment of page numbers in TOC

Post by StuartR »

jmt356 wrote:Is that also the case in MS Word 2007?

I find a single space or character isn't enough to separate the text from the page number. I found the em dash (—) to however be adequate.
The character that you specify will be repeated as many times as needed to push the page number across to the tab stop
StuartR


User avatar
HansV
Administrator
Posts: 78488
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Remove right alignment of page numbers in TOC

Post by HansV »

jmt356 wrote:Is that also the case in MS Word 2007?
Yes, it is. Word 2007 also uses the first character only and ignores the rest.
Best wishes,
Hans