Skip to main content
Participating Frequently
August 26, 2022
Answered

Can you insert number increment in a parent page?

  • August 26, 2022
  • 3 replies
  • 1143 views

I have a book where each page is a day and I need each page to have Day 1 / Day 2 / Day 3 at the top (along with some other text) 

 

I was going to add this to a Parent and then apply it to all pages - meaning I don't have to update all 120 pages with different text. 

 

Sort of what the Page number does - I would have used the page number only for the fact I need to use page numbering as well. 

 

So is this possible?

Can I have incremental numbers on each page using a Parent? 

 

thanks.

This topic has been closed for replies.
Correct answer m1b

Mark, on second thought, I think they want the numbering to be automated for the day. Not necessarily a continuation. 


Ah I see. You're probably right. This is how I would approach that problem...

1. Open attached indesign sample file. I've set up the Day numbers in a character style "Day Placeholder".

2. run the below script. It will replace the contents of any text set in that style with an incrementing number, starting at 1. Important note: you can use master pages to place the day number text frames, but they must each be overridden before the script will see them.

- Mark

 

function main() {

    enumerateTextsInCharacterStyle(app.activeDocument, 'Day Placeholder');


    /**
     * Replaces any text in specified character style
     * with an index, starting at 1.
     * @7111211 m1b
     * @version 2022-08-27
     * @9397041 {Document} doc - an Indesign Document.
     * @9397041 {String} styleName - the characterStyle name.
     */
    function enumerateTextsInCharacterStyle(doc, styleName) {

        var changeStyle = doc.characterStyles.itemByName(styleName);

        if (!changeStyle.isValid) {
            alert('There is no character style named "' + styleName + '".');
            return;
        }

        app.findGrepPreferences = NothingEnum.NOTHING;
        app.findGrepPreferences.appliedCharacterStyle = changeStyle;

        var found = doc.stories.everyItem().paragraphs.everyItem().findGrep();

        for (var i = 0, counter = 1; i < found.length; i++) {
            for (var j = 0; j < found.length; j++) {
                if (
                    found[i][j] != undefined
                    && found[i][j].hasOwnProperty('texts')
                )
                    found[i][j].contents = String(counter++);

            }

        }

    }

} // end main

app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Update Day Numbers');

 

3 replies

Participant
June 25, 2023
quote

I have a book where each page is a day and I need each page to have Day 1 / Day 2 / Day 3 at the top (along with some other text) 

 

I was going to add this to a Parent and then apply it to all pages - meaning I don't have to update all 120 pages with different text. 

 

Sort of what the Page number does - I would have used the page number only for the fact I need to use page numbering as well. 

 

So is this possible?

Can I have incremental numbers on each page using a Parent? 

 

thanks.


By @David25117528512j

 

m1b
Community Expert
Community Expert
August 26, 2022

Hi @David25117528512j, this would be a good use of text variables, especially running header variables.

- Mark

Participating Frequently
August 26, 2022

I looked at this, but I couldn't figure out how to get running numbers. 

m1b
Community Expert
Community Expert
August 26, 2022

I've attached a sample document to look at. Also look at this dialog:

- Mark

 

brian_p_dts
Community Expert
Community Expert
August 26, 2022

You can insert a page number special marker as many times as you want on a parent page. Just right click in the text frame, go to Insert Special Character >> Markers, and choose Current Page Number

 

 

Participating Frequently
August 26, 2022

Can they start at different points? 

 

Example: 

The "Day 1" page is really the 4th Page - So I would need to have pages starting at 1 and at 4 in the same parent - can that be done?