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

Running Para Numbers

Explorer ,
Feb 07, 2024 Feb 07, 2024

Hello,
I need help for two questions.
1) How to add paragraph (note) numbers related to the specific Paragraph style in to the master page? Please check the sample pages I attached ID and PDF. When this paragraph style found in three times in a single page, it should show all numbers like it show in PDF. And they should be automatically updatable.
If it is possible, then try to show fist and the last numbers only?

2. Anybody know, the shortcut to apply Text anchor? I need to select the word and press the shortcut to apply text anchor. Because I have to add lot of text anchors.

I am very greatfull to your kind attention about this matter.

Thank you.

TOPICS
How to
921
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

correct answers 1 Correct answer

Participant , Feb 26, 2024 Feb 26, 2024

Try this update:

 

app.doScript(Main, undefined, undefined, UndoModes.ENTIRE_SCRIPT,"Run Script");
function Main(){

// Declare variables
var myDoc = app.activeDocument;
var myPages = myDoc.pages;
var myPage;
var myFrames;
var myFrame;
var myParas;
var myPara;
var headerStyle = myDoc.paragraphStyles.item("Note_para");
var marginNumberParaStyle;
var marginNumberObjStyle;
var noteNumber;
var ip;

// If "Margin_number" para style doesn't exist, create it
if(myDoc.paragraphStyles.item("Margin_number")
...
Translate
Explorer ,
Feb 08, 2024 Feb 08, 2024

Anybody have any iea about my above post? Please  let me know it's posible or not. 

Thanks. 

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
Participant ,
Feb 08, 2024 Feb 08, 2024

1. In the paragraph style, go to the Bullets and Numbering tab and select the following options:

  • List Type: Numbers
  • Format: 1, 2, 3, 4...
  • Number: ^#.  (make sure to include a space after the period)
  • Mode: Continue from Previous Number

 

2. You can create your own keyboard shortcuts!

  • Edit > Keyboard Shortcuts > New Set
  • In the Product Area dropdown, select Panel Menus
  • Select Hyperlinks: New Hyperlink Destination... 
  • While your cursor is in the New Shortcut field, type your preferred shortcut (for example, Opt + 1 on Mac or Alt + 1 on PC)
  • Assign
  • OK
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
Explorer ,
Feb 08, 2024 Feb 08, 2024

danaken3, 

Thanks for your guide.

Somehow your first answer was based on a little misunderstanding. 

Auto numbering to paragraph style is OK to me. But I want to use that paragraph style in masterpage to create text variable like running header. But it needs to show paragraph number only.  I have an experience about use text variable to make first on the page, and last on the page. (Dictionaries use this methord mostly) But here I need to show all paragraph numbers of the page. Doesn't matter paragraph's are auto numbered or not. Please see the PDF and ID file I attached. 

And thanks for your second answer about showrtcut key.  It works well !!!!!!

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
Participant ,
Feb 09, 2024 Feb 09, 2024

I don't know of an easy way to do that. The only thing I can think of is the following:

  1. Type the numbers into the titles manually.
  2. Create a new character style (for example, "title number") and apply that character style to the numbers.
  3. Create a new Text Variable for the left-page running header:
    • Type: Running Header (Character Style)
    • Style: [your new character style]
    • Use: First on Page
  4.  Create a new Text Variable for the right-page running header (using Last on Page)
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
Explorer ,
Feb 22, 2024 Feb 22, 2024

If someone can give a solution for my first question, please let me know. 

I explain it here again, 

I have notes with numbers and I style them as a paragraph style. 

I want to show all note numbers in each page in outer margin. 

That means, if a page 05 found note number 5,6 and 7, then I want to show them in outer margin of the page 05. I want to do that automatically. I know that running variable with a character style can use for the first an the last. But I need all of the page. This is a big book and I want to do that automatically and smart. 

Thanks for all your efforts.  

 

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
Participant ,
Feb 24, 2024 Feb 24, 2024

The following script will set up an object style and paragraph style for the margin numbers (mimicking the format from your template) and will insert the numbers automatically (as an anchored object). If you want to update the appearance/position of the margin numbers, edit the paragraph style and/or object style.

The margin numbers will not automatically update when your pages shift; however, you can run the same script again and it will delete the existing margin numbers and insert new ones. Let me know if you run into any issues.

 

app.doScript(Main, undefined, undefined, UndoModes.ENTIRE_SCRIPT,"Run Script");
function Main(){
// Declare variables
var myDoc = app.activeDocument;
var myPages = myDoc.pages;
var myPage;
var myFrames;
var myFrame;
var myParas;
var myPara;
var headerStyle = myDoc.paragraphStyles.item("Note_para");
var marginNumberParaStyle;
var marginNumberObjStyle;
var noteNumber;
var ip;

// If "Margin_number" para style doesn't exist, create it
if(myDoc.paragraphStyles.item("Margin_number") == null) {
    var paraProps = {
        name: "Margin_number",
        appliedFont: "Minion Pro",
        basedOn: myDoc.paragraphStyles.item("[No Paragraph Style]"),
        fillColor: myDoc.swatches.itemByName("Paper"),
        fontStyle: "Regular",
        justification: Justification.CENTER_ALIGN,
        leading: Leading.AUTO,
        paragraphShadingBottomOffset: "0p1",
        paragraphShadingColor: myDoc.swatches.itemByName("C=75 M=5 Y=100 K=0"),
        paragraphShadingOn: true,
        paragraphShadingTint: 100,
        paragraphShadingTopOffset: "0p5",
        paragraphShadingWidth: ParagraphShadingWidthEnum.COLUMN_WIDTH,
        pointSize: 14,
        spaceAfter: "0p7.5"
    };
    myDoc.paragraphStyles.add(paraProps);
}
marginNumberParaStyle = myDoc.paragraphStyles.item("Margin_number");

// If "Margin_number" object style doesn't exist, create it
if(myDoc.objectStyles.itemByName("Margin_number") == null) {
    var objProps = {
        name: "Margin_number",
        anchoredObjectSettings: {
            anchorPoint: AnchorPoint.BOTTOM_RIGHT_ANCHOR,
            anchorXoffset: "2p9",
            anchorYoffset: "-0p5",
            anchoredPosition: AnchorPosition.ANCHORED,
            horizontalReferencePoint: AnchoredRelativeTo.PAGE_MARGINS,
            spineRelative: true,
            verticalReferencePoint: AnchoredRelativeTo.PAGE_MARGINS
        },
        appliedParagraphStyle: marginNumberParaStyle,
        basedOn: myDoc.objectStyles.itemByName("[None]"),
        enableAnchoredObjectOptions: true,
        enableParagraphStyle: true,
        enableStroke: false,
        enableTextFrameAutoSizingOptions: true,
        enableTextFrameGeneralOptions: true,
        enableTransformAttributes: true,
        textFramePreferences: {
            autoSizingReferencePoint: AutoSizingReferenceEnum.BOTTOM_CENTER_POINT,
            autoSizingType: AutoSizingTypeEnum.HEIGHT_AND_WIDTH,
            minimumWidthForAutoSizing: "1p8",
            useMinimumWidthForAutoSizing: true,
            verticalJustification: VerticalJustification.BOTTOM_ALIGN
        }
    };
    myDoc.objectStyles.add(objProps);
}
var marginNumberObjStyle = myDoc.objectStyles.itemByName("Margin_number");

// Delete all text frames with "Margin_number" object style applied
app.findObjectPreferences.appliedObjectStyles = marginNumberObjStyle;
var objectList = myDoc.findObject();
if (objectList.length >0) {
    for (var i=objectList.length-1; i>=0; i--) {
        objectList[i].remove();
    }
    alert("Deleted all existing margin numbers.");
}

// Loop through pages
for (var i=0; i<myPages.length; i++) {
    myPage = myPages[i];
    var noteNumbers = null;

    // Loop through text frames
    myFrames = myPage.textFrames;
    for (var j=myFrames.length-1; j>=0; j--) {
        myFrame = myFrames[j];

        // Loop through paragraphs
        myParas = myFrame.paragraphs;
        for (var k=0; k<myParas.length; k++) {
            myPara = myParas[k];
            // Check if para has header style applied
            if (myPara.appliedParagraphStyle == headerStyle) {
                ip = myPara.insertionPoints[0];

                // Get paragraph's number and add it to noteNumbers string
                try {
                    noteNumber = myPara.numberingResultNumber.toString();
                    if(noteNumbers==null) {
                        noteNumbers = noteNumber;
                    }
                    else noteNumbers = noteNumbers.concat("\r" + noteNumber);
                }
                catch(err) {
                }
            }
        }
    }
    // Create text frame and add noteNumbers string
    if (noteNumbers != null) {
        myTextFrame = ip.textFrames.add();
        myTextFrame.appliedObjectStyle = marginNumberObjStyle;
        myTextFrame.contents = noteNumbers;
    }
}
alert ("Script complete");
}

 

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
Explorer ,
Feb 26, 2024 Feb 26, 2024

Marvelous !!!!!! You are super creative.... 

This works fine.... Thank you very much danaken3. 

 

And another little thing came to my mind to develop this, and also very usefull to all. 

If you can try to behave margin numbers like running headers. That means, if note number 3 starting from page 2 and it continue upto page 4, then page 2 and 3 also need to show note number 3 on the margin. Normally running headers doing that. 

Is it possible ? 

Somehow you make my works so easy...... Thanks again and again........ 

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
Participant ,
Feb 26, 2024 Feb 26, 2024
LATEST

Try this update:

 

app.doScript(Main, undefined, undefined, UndoModes.ENTIRE_SCRIPT,"Run Script");
function Main(){

// Declare variables
var myDoc = app.activeDocument;
var myPages = myDoc.pages;
var myPage;
var myFrames;
var myFrame;
var myParas;
var myPara;
var headerStyle = myDoc.paragraphStyles.item("Note_para");
var marginNumberParaStyle;
var marginNumberObjStyle;
var noteNumber;
var ip;

// If "Margin_number" para style doesn't exist, create it
if(myDoc.paragraphStyles.item("Margin_number") == null) {
    var paraProps = {
        name: "Margin_number",
        appliedFont: "Minion Pro",
        basedOn: myDoc.paragraphStyles.item("[No Paragraph Style]"),
        fillColor: myDoc.swatches.itemByName("Paper"),
        fontStyle: "Regular",
        justification: Justification.CENTER_ALIGN,
        leading: Leading.AUTO,
        paragraphShadingBottomOffset: "0p1",
        paragraphShadingColor: myDoc.swatches.itemByName("C=75 M=5 Y=100 K=0"),
        paragraphShadingOn: true,
        paragraphShadingTint: 100,
        paragraphShadingTopOffset: "0p5",
        paragraphShadingWidth: ParagraphShadingWidthEnum.COLUMN_WIDTH,
        pointSize: 14,
        spaceAfter: "0p7.5"
    };
    myDoc.paragraphStyles.add(paraProps);
}
marginNumberParaStyle = myDoc.paragraphStyles.item("Margin_number");

// If "Margin_number" object style doesn't exist, create it
if(myDoc.objectStyles.itemByName("Margin_number") == null) {
    var objProps = {
        name: "Margin_number",
        anchoredObjectSettings: {
            anchorPoint: AnchorPoint.BOTTOM_RIGHT_ANCHOR,
            anchorXoffset: "2p9",
            anchorYoffset: "-0p5",
            anchoredPosition: AnchorPosition.ANCHORED,
            horizontalReferencePoint: AnchoredRelativeTo.PAGE_MARGINS,
            spineRelative: true,
            verticalReferencePoint: AnchoredRelativeTo.PAGE_MARGINS
        },
        appliedParagraphStyle: marginNumberParaStyle,
        basedOn: myDoc.objectStyles.itemByName("[None]"),
        enableAnchoredObjectOptions: true,
        enableParagraphStyle: true,
        enableStroke: false,
        enableTextFrameAutoSizingOptions: true,
        enableTextFrameGeneralOptions: true,
        enableTransformAttributes: true,
        textFramePreferences: {
            autoSizingReferencePoint: AutoSizingReferenceEnum.BOTTOM_CENTER_POINT,
            autoSizingType: AutoSizingTypeEnum.HEIGHT_AND_WIDTH,
            minimumWidthForAutoSizing: "1p8",
            useMinimumWidthForAutoSizing: true,
            verticalJustification: VerticalJustification.BOTTOM_ALIGN
        }
    };
    myDoc.objectStyles.add(objProps);
}
marginNumberObjStyle = myDoc.objectStyles.itemByName("Margin_number");

// Delete all text frames with "Margin_number" object style applied
app.findObjectPreferences.appliedObjectStyles = marginNumberObjStyle;
var objectList = myDoc.findObject();
if (objectList.length >0) {
    for (var i=objectList.length-1; i>=0; i--) {
        objectList[i].remove();
    }
    alert("Deleted all existing margin numbers.");
}

// Loop through pages
for (var i=0; i<myPages.length; i++) {
    myPage = myPages[i];
    var noteNumbers = null;

    
    if (!myPage.textFrames) {
        break;
    }
    // Loop through text frames
    myFrames = myPage.textFrames;
    for (var j=myFrames.length-1; j>=0; j--) {
        myFrame = myFrames[j];

        // Loop through paragraphs
        myParas = myFrame.paragraphs;
        for (var k=0; k<myParas.length; k++) {
            myPara = myParas[k];
            // Check if para has header style applied
            if (myPara.appliedParagraphStyle == headerStyle) {
                ip = myPara.insertionPoints[0];

                // Get paragraph's number and add it to noteNumbers string
                try {
                    noteNumber = myPara.numberingResultNumber.toString();
                    if(noteNumbers==null) {
                        noteNumbers = noteNumber;
                    }
                    else noteNumbers = noteNumbers.concat("\r" + noteNumber);
                }
                catch(err) {
                }
            }
        }
    }

    // If no paras on pg. are header, use final para as insertion point
    if (ip==null && myPara != null) {
        ip = myPara.insertionPoints[0];
    }

    // Create text frame and add noteNumbers string
    if (ip!=null){
        myTextFrame = ip.textFrames.add();
        myTextFrame.appliedObjectStyle = marginNumberObjStyle;
        if (noteNumbers != null) {
            myTextFrame.contents = noteNumbers;
        }
        // If no paras on pg. are header, insert last note number of prev. pg.
        else if (noteNumber != null) {
            myTextFrame.contents = noteNumber;
        }
    }
    // Reset insertion point variable to null
    ip = null;
}
alert ("Script complete");
}

 

 

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