Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

allign paragraph and numbers on same line [CS3]

New Here ,
Feb 18, 2010 Feb 18, 2010

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?

TOPICS
Scripting
1.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 18, 2010 Feb 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 21, 2010 Feb 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Feb 21, 2010 Feb 21, 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 23, 2010 Feb 23, 2010

thanks,

but i have a other question.

now i can add tabs with scripting.

in my first example, i want to place the page number on  the first tab.

can i say before i add this page.number that the correct position is on the first tab?

myTextFrame.parentStory.insertionPoints.item (-1).contents = page.name;

myTextFrame.parentStory.paragraphs.applyParagraphStyle (myParagraphStyle.tabStops.firstItem(), true);  

i have done something like this.

but there is no tab?

what do i do wrong?

greetz,

kim

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Feb 23, 2010 Feb 23, 2010

I think there is no need tabstop within script. Set tab in your paragraph style and apply your style to text.

Shonky

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 23, 2010 Feb 23, 2010

i guese my way of thinking is now wrong.

when i place in my paragraph style a right tab.

like you shown in you example a fuw post back.

when the paragraph style is reading the text, how does he know that he must place te number on the first tab?

so i think before i enterd the number that i must say that it must placed on the first tab?

greet,

kim

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Feb 23, 2010 Feb 23, 2010

I have not clear what you want. sorry...

But i think you want insert tab within your page no. and chapter no.

here below i have added tab within your code

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].parag raphs[0].contents.length-1) + "\t";       

   myTextFrame.parentStory.paragraphs.applyParagraphStyle (myParagraphStyle, true);
   myTextFrame.parentStory.insertionPoints.item (-1).contents = page.name + "\t";

   myTextFrame.parentStory.insertionPoints.item (-1).contents = page.allPageItems[2].paragraphs[0].contents.substr(page.allPageItems[2].paragra phs[0].contents.length-1,page.allPageItems[2].paragraphs[0].contents.length);
   myTextFrame.parentStory.paragraphs.applyParagraphStyle (myParagraphStyle, true);

}

Shonky

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 25, 2010 Feb 25, 2010
LATEST

sorry i will try to clear myself

thank any way for the good respons.

when you do.

myTextFrame.parentStory.insertionPoints.item (-1).contents = page.allPageItems[2].paragraphs[0].contents.substr(0,page.allPageItems[2].parag raphs[0].contents.length-1) + "\t";

if you first word is something like this : "supercalifragalisticexpialidocus" en you do then  + "\t";

your second word will bee: "Chapter 2" + "\t".

the 2 pagenumbers arrent alling on the same tabposition.

so i was wondering is i place te tab, in the paragraph style.

and at the end of my document i want to rebuild a TOC.

that i can call the paragraph style's tabs, and say the pagenumber must stand on the first tab?

is this possible?

greetz,

kim

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines