Page x of y and sequential numbering in the same page

Community Beginner ,
Feb 12, 2021 Feb 12, 2021

Copy link to clipboard

Copied

Hi,

 

I'm working on a online user manual that will have around 1.500 pages and a multiple chapters structure. I would like the file to have sequential numbering across the whole document, but also section numbering (Page X of Y) for each chapter so users can keep track of sections size.

 

I know how to do the two functions separately but haven't figured out how to do it in the same file. Is there a way of doing this without relying in some scripting solution? Not really my thing... 

 

I'm currently numbering Pages X of Y manually, so it would sure make my life easier to solve this automatically.

 

Thanks!

 

print-numbering-issue.png

TOPICS
How to, Publish online

Views

143

Likes

translate

Translate

Translate

Report

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

Adobe Community Professional , Feb 12, 2021 Feb 12, 2021
Hi Gabriel, you said: "Is there a way of doing this without relying in some scripting solution?" I say: Why not using a script for this?   Let's think this through. All the formatting of the text frame and its contents with the page numbers can go into an object style. Position and size of the text frame, the applied paragraph style. The text frame will be built on a distinct layer, solely for that purpose. The auto page numbering could be done on a different layer and a different text frame usi...

Likes

translate

Translate

Translate
Adobe Community Professional ,
Feb 12, 2021 Feb 12, 2021

Copy link to clipboard

Copied

There is, but it's a pretty cumbersome workaround ... and near-entirely a manual one. As I suspect, unfortunately, is something you well know.

 

Rather than putting your page numbering on a Document Page, which requires each entry be made for each page — or as I suspect in your case, twice for each page, with entries placed on two discrete layers which are overlaying each page — put your two page numbering options on discrete layers on the Master Page, where one entry will be distributed automatically. You'll have to manually switch between layers to create and display each page numbering model. Or if it's your druthers, display both or neither of the page numbering options.

 

That's the best way I can think of to differentiate your two page numbering models for your documentation.

 

Hope this helps,

 

Randy

Likes

translate

Translate

Translate

Report

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 Beginner ,
Feb 12, 2021 Feb 12, 2021

Copy link to clipboard

Copied

Hi Randy,

Thanks for the fast reply.

 

Not sure I understood all you said (english isn't my first language), but might be way I'm currently doing.

 

I have, in a master page, a Special Character for Current Page Number and a Text Frame with the X of Y. The first is solved, but in the second I was only able to "automate" the Y part of the text, in which I can insert the total of pages for each section once in the respective master page and it will distribute throughout the document... so I still need to edit the X number in each page. A near-entirely manual solution, as you said.

 

But thanks anyway!

Likes

translate

Translate

Translate

Report

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
Adobe Community Professional ,
Feb 12, 2021 Feb 12, 2021

Copy link to clipboard

Copied

Hi Gabriel,

you said: "Is there a way of doing this without relying in some scripting solution?"

I say: Why not using a script for this?

 

Let's think this through. All the formatting of the text frame and its contents with the page numbers can go into an object style. Position and size of the text frame, the applied paragraph style. The text frame will be built on a distinct layer, solely for that purpose. The auto page numbering could be done on a different layer and a different text frame using the master pages with the auto page number text variable as usual. The script will not do the ordinary page numbers.

 

With that in mind consider the following script code that will do the numbering for you:

[1] The script will add a new layer with name "SectionNumbering"; it will remove the layer with that name first, if that named layer already exists before the script starts, the script will remove the layer and built it again; change the name of the layer in the script code if you like.

 

[2] The script will add an object style named "SectionNumberingStyle" if that style does not exist, it will use the object style if it already exists, change that name of that object style in the script code if you like.

 

[3] The script will calculate the appropriate page numbers in the form 001/999 or 01/10, just as you showed in your screenshot with leading zeros. The number of leading zeros is calculated from the maximum amount of pages that go into a distinct section; it is calculated individually for every section so that numbering like 001/010 will not happen. Instead it will be 01/10.

 

The script code is written in ExtendScript (JavaScript):

 

/**
* @@@BUILDINFO@@@ NumberPagesOfAllSections-v1.jsx !Version! Fri Feb 12 2021 21:18:59 GMT+0100
*/

/*
	See discussion:
	Page x of y and sequential numbering in the same page
	GabrielS_131022
	https://community.adobe.com/t5/indesign/page-x-of-y-and-sequential-numbering-in-the-same-page/td-p/11827656
	
	Script code by Uwe Laubender
	for InDesign CS6 to InDesign 2021 on every OS platform
	on the Adobe InDesign Forum
	
*/

( function()
{
	
	if(app.documents.length == 0 ){ return };

	var doc = app.documents[0];
	
	// Change this name if you like:
	var layerName = "SectionNumbering";
	
	// Change this name if you like:
	var objectStyleForSectionNumbers = "SectionNumberingStyle";
	
	/*
		Currently used separator string between the two numbers: "/"
		That means:
		
		001/999, 01/99, 1/9
		
		If you change that e.g, to: " of " it will show like that:
		001 of 999, 01 of 99, 1 of 9
		
	*/
	// Change the separator string if you like:
	var separatorString = "/" ;

	var layer = doc.layers.itemByName( layerName );
	var objectStyle = doc.objectStyles.itemByName( objectStyleForSectionNumbers );

	if( layer.isValid ){ layer.remove() };
	layer = doc.layers.add( { name : layerName } );
	
	if( !objectStyle.isValid )
	{
		doc.objectStyles.add( { name : objectStyleForSectionNumbers } );
	};

	var allSections = doc.sections.everyItem().getElements();
	var allSectionLength = allSections.length;

	for( var n=0; n<allSectionLength; n++ )
	{
		var currentSection = allSections[n];
		var pageLength = currentSection.length;
		var startPageIndex = currentSection.pageStart.documentOffset;
		
		var maxDigitsLength = pageLength.toString().length;
		
		for( var p=0; p<pageLength; p++ )
		{
			var currentPage = doc.pages[ startPageIndex + p ];
			var currentNumber = p+1;
			var currentDigitString = currentNumber.toString();
			
			while( currentDigitString.length < maxDigitsLength )
			{
				currentDigitString = "0" + currentDigitString;
			};
			
			currentPage.textFrames.add
			(
				{
					contents : currentDigitString + separatorString + pageLength ,
					appliedObjectStyle : objectStyle ,
					itemLayer : layer
				}
			)
		};
	};


}() )

 

How to save the script code to a script file, install the script file so that it is available in InDesign's Scripts Panel and how to execute the script from the Scripts Panel see: https://www.indiscripts.com/pages/help#hd0sb2

 

Use this InDesign 2021 document for testing purposes where I did several sections with several page lengths:

https://www.dropbox.com/s/ajtlc6o6mx3o18t/NumberPagesOfAllSections-2021.indd?dl=1

 

I already built an object style and a paragraph style so that you can see how much power can go into an object style.

 

Regards,
Uwe Laubender

( ACP )

Likes

translate

Translate

Translate

Report

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 Beginner ,
Feb 12, 2021 Feb 12, 2021

Copy link to clipboard

Copied

Laubender,

 

You are completely right, I shouldn't have dimissed the script solution on the spot. Maybe because I know nothing about it I felt I wouldn't be able to properly discuss it. But I wasn't at all expecting a script solution just appearing in front of me like that. 

 

Thanks so much for this, I'm speechless! Just by setting object and paragraph styles I can adapt my layout to make it work with this solution.

 

If I'm not being to pushy, though, would like to check with you if the following adaptation are possible:

 

1) The title text frame uses a Paragraph Style that sets the dark blue typeface for the section name and a GREP Style that applies the grey superscript character style to any set of numbers divided by "/".

 

So it's [Section Marker + Punctuation Space + Numbers], like the imagem below.

 

GabrielS_131022_0-1613181969207.png

If it's possible to make the script also add a section marker in the same text frame as an action, I believe the title would be fully automated. Makes sense?

____

2) This one is not at all necessary, just an additional facilitation. I have a variation in the title position: one for cover and another for regular pages, as the image below.

 

page comparison.png

 

I have created object styles for both situation, so I could easily run the script to create all titles with "Regular Page" settings and then manually apply the "Cover Page" object style to quickly switch the position. But if the script could use one object style for the first page of each section and another for the remaining pages it would be a big plus.

 

In any case, the script you provided me is a fantastic help. Can't thank you enough.

 

Regards,

Gabriel Scherer

Likes

translate

Translate

Translate

Report

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
Adobe Community Professional ,
Feb 15, 2021 Feb 15, 2021

Copy link to clipboard

Copied

Hi Gabriel,

consider one additional tool in your toolbox after running the script:
You could pull the contents of the new text frames with the numbering on that new layer to every text insertion point on your page. Just use a text variable for this. A running header text variable would be perfect.

 

Here a sample document with section numbering as well ( code below) :

https://www.dropbox.com/s/fpauw970iaryoyg/NumberPagesOfAllSections-RunningHeader-2021.indd?dl=1

 

Screenshot from my German InDesign 2021 on WIndows 10:

NumberSections-NumberPagesInSections.PNG

 

Enhanced script code v2:

 

/**
* @@@BUILDINFO@@@ NumberPagesOfAllSections-v2.jsx !Version! Mon Feb 15 2021 21:23:12 GMT+0100
*/

/*
	See discussion:
	Page x of y and sequential numbering in the same page
	GabrielS_131022
	https://community.adobe.com/t5/indesign/page-x-of-y-and-sequential-numbering-in-the-same-page/td-p/11827656
	
	Script code by Uwe Laubender
	for InDesign CS6 to InDesign 2021 on every OS platform
	on the Adobe InDesign Forum
	
*/

( function()
{
	
	if(app.documents.length == 0 ){ return };

	var doc = app.documents[0];
	
	// Change this name if you like:
	var layerName = "SectionNumbering";
	
	// Change this name if you like:
	var objectStyleForSectionNumbers = "SectionNumberingStyle";
	
	/*
		Currently used separator string between the two numbers: "/"
		That means:
		
		001/999, 01/99, 1/9
		
		If you change that e.g, to: " of " it will show like that:
		001 of 999, 01 of 99, 1 of 9
		
	*/
	// Change the separator string if you like:
	var separatorString = "/" ;

	var layer = doc.layers.itemByName( layerName );
	var objectStyle = doc.objectStyles.itemByName( objectStyleForSectionNumbers );

	if( layer.isValid ){ layer.remove() };
	layer = doc.layers.add( { name : layerName } );
	
	if( !objectStyle.isValid )
	{
		doc.objectStyles.add( { name : objectStyleForSectionNumbers } );
	};

	var allSections = doc.sections.everyItem().getElements();
	var allSectionLength = allSections.length;

	for( var n=0; n<allSectionLength; n++ )
	{
		var currentSection = allSections[n];
		var pageLength = currentSection.length;
		var startPageIndex = currentSection.pageStart.documentOffset;
		
		var sectionNumber = n+1 ;
		var sectionNumberString = sectionNumber.toString();
		
		var maxDigitsLength = pageLength.toString().length;
		
		for( var p=0; p<pageLength; p++ )
		{
			var currentPage = doc.pages[ startPageIndex + p ];
			var currentNumber = p+1;
			var currentDigitString = currentNumber.toString();
			
			while( currentDigitString.length < maxDigitsLength )
			{
				currentDigitString = "0" + currentDigitString;
			};
			
			currentPage.textFrames.add
			(
				{
					contents : "Section: "+sectionNumberString +"Page: "+ currentDigitString + separatorString + pageLength ,
					appliedObjectStyle : objectStyle ,
					itemLayer : layer
				}
			)
		};
	};


}() )

 

 

Look into the line of code that says contents at the beginning.

There I added a couple of strings, the words "Section: " and "Page: " and one variable that holds the current section number in the form of a digit in between. Feel free to change the wording there and perhaps add another separator string  in the "Page: " string, perhaps this: ", Page: ".

 

Regards,
Uwe Laubender

( ACP )

Likes

translate

Translate

Translate

Report

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 Beginner ,
Feb 15, 2021 Feb 15, 2021

Copy link to clipboard

Copied

Hi Laubender,

 

This is just great, never thought of using running header like this before. In the end, the problem was already solved with v1 of your script.

 

This is just fantastic, had a real class with your solution. Thank you so much!

 

Regards,

Gabriel Scherer

Likes

translate

Translate

Translate

Report

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
Adobe Community Professional ,
Feb 15, 2021 Feb 15, 2021

Copy link to clipboard

Copied

Not being a scripter, in my ignorance I would use the following...

  • Standard page numbering for pages 1 to 1500.
  • Section page numbering from an imported Excel file with simple consecutive numbering. This can be set to jump from page to page with a next-page setting in the paragraph style.
  • Section total page counts can be done with variables per section. This can also be done from the Excel file too. For example, you can link to the Excel file with each section on a separate worksheet. You can put the entire "Section page X of Y" in the Excel file.
 

Likes

translate

Translate

Translate

Report

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 Beginner ,
Feb 17, 2021 Feb 17, 2021

Copy link to clipboard

Copied

Interesting!

Certainly easier to control the numbering in a excel file than on each page.

 

The script worked perfectly, but good to know other ways of getting there.

 

Thanks!

Likes

translate

Translate

Translate

Report

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
Adobe Community Professional ,
Feb 17, 2021 Feb 17, 2021

Copy link to clipboard

Copied

Other options for the total page counts per section I forgot to mention...

If the sections are in one document, ID has a variable for the document page count.

If the sections span multiple documents, you can put a single paragraph with a unique style name (e.g. "z_LastSectionPg") and create cross references to it from the other same-section documents.

 

Likes

translate

Translate

Translate

Report

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