Skip to main content
Participant
February 18, 2010
Question

allign paragraph and numbers on same line [CS3]

  • February 18, 2010
  • 1 reply
  • 1637 views

I have a little problem with paragraph and numbering.

i'm creating a a little TOC with ownly my Chapters.

What i want to accomplis:

                                        Page nr.               Chapter nr.

Chapter                                       2                             1

Chapter                                       6                             2

the Chapter names, is text that is retrieve from my document.

behind the names i want the page number following with a chapter number.

in the example below i have split the paragraph in 2.

outherwise my page number will stand on the next line.

the Chapter nr is not implement in the example, but you got the idea

for (var j= 0; j<foundInstances.length; j++)
{       
   page = foundInstances.parentTextFrames[0].parent;                   
   myTextFrame.parentStory.insertionPoints.item (-1).contents = page.allPageItems[2].paragraphs[0].contents.substr(0,page.allPageItems[2].paragraphs[0].contents.length-1);       
   myTextFrame.parentStory.paragraphs.applyParagraphStyle (myParagraphStyle, true);
   myTextFrame.parentStory.insertionPoints.item (-1).contents = page.name;
   myTextFrame.parentStory.insertionPoints.item (-1).contents = page.allPageItems[2].paragraphs[0].contents.substr(page.allPageItems[2].paragraphs[0].contents.length-1,page.allPageItems[2].paragraphs[0].contents.length);
   myTextFrame.parentStory.paragraphs.applyParagraphStyle (myParagraphStyle, true);

}

1. is there a way, so i can align the numbers?

2. or is it only possible to allign ownly 1 of the 2 numbers?

3. is it posssible to give the numbers a different paragraphStyle?

This topic has been closed for replies.

1 reply

Peter Kahrel
Community Expert
Community Expert
February 18, 2010

> 1. is there a way, so i can align the numbers?

Insert tabs between the chapter name and page number, and between the page number and the chapter number. Then set tab stops in the paragraph style.

> 2. or is it only possible to allign ownly 1 of the 2 numbers?

Yes, you can align many items. Again, insert tabs and set tab stops in the paragraph style.

> 3. is it posssible to give the numbers a different paragraphStyle?

No, it is not. use character styles.

Peter

vlansusAuthor
Participant
February 21, 2010

thanks for you replay.

sorry for my late respons.

1. is there a way, so i can align the numbers?

sow what you meen is, when i place tabs in my script and i assign a paragraph style to it that hold 2 stops in the tab section.

than it will allign the numbers on that position?

greetz,

kim

Inspiring
February 22, 2010

Hi Kim,

You can assign right tab in your paragraph style. See attachment.

Or if you want through script then select your text and run below code

app.selection[0].paragraphs.everyItem().tabStops.everyItem().remove();

app.selection[0].paragraphs.everyItem().tabStops.add ({position:50, alignment: TabStopAlignment.rightAlign})

app.selection[0].paragraphs.everyItem().tabStops.add ({position:100, alignment: TabStopAlignment.rightAlign})

Change tab position as you want in you document.
Shonky