Thanks for coming to, the world's #1 resource for all things InDesign!

Format page numbers using grep styles

I was working on a project recently and decided to use old style figures in the folios. While there were a number of things I could have done to accomplish this, I figured that I’d just use a grep style since the folios also used the date of the event and adding a grep style for old style figures for any digit would do the trick.

First step was to create a character style for old style figures and a paragraph style for the folios.

As part of the paragraph style I used a grep style to apply the old style character style to any digit.

use a grep style to apply a character style to any digit

But there’s a problem…the numbers in the date are perfect, but the page numbers aren’t formatted.

I was a bit surprised but it didn’t take too long to realize that this was clearly a case of operator error. InDesign doesn’t consider automatically generated page numbers as numbers; it considers them markers. So back to my paragraph style to do bit of extra work…an additional grep style to apply the old style character style to page number markers. The preset grep expressions built into the application make this a breeze.

add the character style to the page number marker

All digits properly formatted

Now, that’ more like it.

With all of the automatically generated text that InDesign is capable of, it’s important to keep in mind that formatting it properly may require a bit of extra thought.

Bob Levine

Bob Levine

Bob Levine is a graphic designer and a consultant focused on providing InDesign training and guidance in developing efficient, collaborative workflows to those moving from QuarkXPress or PageMaker. An Adobe Certified Expert in both InDesign and InCopy, Bob has written articles for InDesign Magazine and is an Adobe User to User forums host. He has more than 15 years of industry experience and has been using InDesign since version 1.0. For more background, visit his website, or his blog,
Bob Levine

Latest posts by Bob Levine (see all)

  • - November 30, -0001
Related Articles

23 Comments on “Format page numbers using grep styles

  1. Bit confused: as you want ALL numbers in this style to be old style, why not simply assign Open type Old styles to the complete paragraph-style itself?
    (like you would in CS3)…

  2. Hey Bob, great catch (and solution) regarding page folios!

    But you don’t need a GREP style for the dates. Just specify the old style numbers in the paragraph style itself (OpenType Features > Figure Style > Proportional Oldstyle).

    Just itching for reasons to use GREP styles? ;-)

  3. Like I said in the beginning of the post…there were a number of ways to accomplish this.

    And yes, I was just itching to use grep styles. What good are all these new goodies if they just sit there unused? :)

    As for assigning the entire paragraph an opentype old style setting, sure I could have done that but what if it were an older type 1 font that required an expert set to use the old style figures?

    There are other reasons to do this. If you just want to format the page number then can’t simply add a blanket format to the entire paragraph.

  4. >As for assigning the entire paragraph an opentype old style setting, sure I could have done that but what if it were an older type 1 font that required an expert set to use the old style figures?

    true, in that case you could use this GREP to assign a Type 1 Expert font.

  5. I think the title of the post is throwing some people off, no?

    “Format page numbers using grep styles”

    Perhaps “Format numbers using grep styles” or “Format using grep styles”.

    Either way, it’s nice to know that the option is there and there are even more ways to make this number formatting happen.

  6. Is there a way to format a GREP style to place the following month. I am building a newsletter that is printed one week prior to the coming month. I am not sure I am making myself clear. If its October I would need it to say November when I go to press. I hope that is clear enough.

  7. @Rudy – I think text variables might be what you’re looking for (Type > Text Variables > Define?). At which point you can used the pre-installed text variables (Modification Date, Creation Date or Output Date) or create your own.

    If you edit the variable, you can control the formatting with the help of the flyout menus to the right of the three fields (Text Before, Date Format, Text After)

  8. I know the Variables are very useful. But I’m unaware of a Variable setting for dates that show the NEXT month instead of the current month.

    If you set your computer clock forward one month, then use the variable for Output Date, the date will show next month. All you have to do is remember you’re one month ahead, so technically today would be Christmas for your computer :)

    Although this worked for my computer, the date did reset itself from the server, so the date reverted back to November, so not sure it’s a solution after all.

    Although, if you do name your document the Date of the output, so you name the file December for example, you can create a new Variable that will insert the File Name.

    So then next month you can simply copy that document and/or change the name of the document to the month you want to appear.

    That way the file name controls the Variable text.

  9. Eugene, you are a Mad Scientist, man. I love it. I might steal your trick the next time I do a talk on variables.

    Although unless I’m missing something, in Rudy’s case, it seems simplest just to do a Find/Change and be done with it.

  10. Thanks Mike, just don’t go about celebrating the holidays just yet though :)

    Well, there are always different ways to do something, but this was the “Way of the Variable” and of course it can be done.

    Pity you can’t put some sort of condition in the variable say: mm{1}/dd/yy

    So that the mm is changed up 1 month, that’s what the “{1}” could be used for.

    That way you wouldn’t have to do anything.

    Of course using the variable of the file name would work very well, because who saves over monthly work, certainly any magazine I’ve done is named with the month in the file name.

    I was thinking of a similar problem I have, as we put issue numbers on each magazine cover. And it’s a pain to remember to change this. So, I would like to have a variable that would change the issue number, some way of linking to the other files variable so that it knows that it already as done Issue 5 and we’re on Issue 6.

    But I guess I can only dream for such a feature, for now, a NOTES non-printing layer will be used to serve as a reminder.

  11. Eugene said,
    “I know the Variables are very useful. But I?m unaware of a Variable setting for dates that show the NEXT month instead of the current month.”

    You must not have purchased the InDesign Pro Extended 3D “Prize Inside!” version, then. Not only does it allow you to do next day/year/month variables, but also has the enhanced Undo features, About to Do (Command-Shift-Enter-Z) and Should Have Done (fn-Z).

  12. Yeh certainly though, just giving it a paragraph style of it’s own, then you can search for that paragraph style and the month in question and just replace, less hassle and doesn’t call for a new “name convention”.

    Of course you can save the searches, so it would be easy to create a “find change by list” script as soon as you start work on the new document… which was talked about recently and I can’t find the link?

    Well the find change by list could easily be edited to run a number of find changes that is necessary before you start working on a new monthly magazine.

    I suppose.

  13. Yikes Anne-Marie, didn’t even know about it.

    I’ll have to look into that. Thanks for the never-ending info!

    Ha, pulling my leg there, I didn’t get to the last part of the paragraph as I rushed to google with the excitement of InDesign Pro Extended, as I know photoshop has a similar product.

    Good one :)

  14. That’s the version of InDesign that comes bundled with the Photoshop CSI edition.

    All you need is a reflection in a pair of sunglasses on someone 300 feet away to make out a license plate and the driver in the rear view mirror.

    Fascinating stuff. :)

  15. Wow, I feel little a sillyhead. I read that totally wrong.

    You could create a “Custom Text” text variable. Name it something like “Edition” and type in “November”.

    Insert that text variable wherever, cover, folios, masthead, etc.
    The following month, just change the Custom Text text variable.

    Just another way… :)

    I’ve created generic templates that use these custom text variables as company placeholders, i.e. quick branding minus logos and artwork. Works great for items like name, address, taglines. Usually in the case of an InDesign book (.indb), where I can change the text variable(s), then sync the text variable(s) across all the InDesign documents within the book.

    but find/replace works for your approach, too… :)

    (what’s my obsession with parentheses)

  16. I want a some help.

    I have 3 line of text and each line end has hard return (e.g. #Name of location.
    Address of location.
    Town, State, Zip).

    i want a apply one character style to each of line text. so please suggest how could i achieve it using grep style in indesing CS4
    What is the code of change it.

  17. GREP styles do not support multi-line searches. If your character style should be applied to entire paragraphs, you’re better off just changing the paragraph style.

  18. I know this is an old thread, but I have one thing that I would like to know about inserting page numbers. The default page numbering is 1, 2, 3 and so on but how can I change it to 01, 02, 03…….or 001, 002, 003…. etc…?

Leave a Reply

Your email address will not be published. Required fields are marked *