Fan of creative technology, elearning, instructional design and a little geeky

InDesign: Introducing GREP Styles (2)

089_01_applied

This is the second in a series of four short GREP Style tutorials.

Part 1: Automatically apply a character style to all text between parentheses

Part 3: Converting text typed in Capital Letters to Small Caps (OpenType feature)

Part 4: Formatting price tags containing dollars and cents with multiple character styles

In this second tutorial we look at how we can use a GREP style to change the appearance of any figures within a paragraph style.

Task at hand

Task for this GREP Style is that it changes the formatting on any numerical characters (figures) throughout the Body Text paragraph style.

We’re starting the same way once again. By creating a Character Style that sets the formatting for the figures.

OpenType Fonts and Figures

As I’m using a Open Type font in this example (Minion Pro). I can use OpenType features for figure formatting. Kind of cool.

To create a Character Style that has my figure settings included, I start by highlighting a figure and from the Control Panel menu choose OpenType.

Any OpenType font features listed between square brackets [] are not available to the font. The last group of features are figure specific features: Tabular Lining, Proportional Oldstyle, Proportional Lining, Tabular Oldstyle and the default setting Default Figure Style.

There’s much more to OpenType then just being a cross-platform font. As these fonts are double byte fonts they can contain an expanded character set and provide cool typographical features.  Adobe Systems Inc. has a good OpenType Q&A page available as part of their Open Type ‘branch’ on their web-site

In brief (and I’m not font expert to be honest): Oldstyle figures, are generally designed smaller and match with lowercase characters. Lining figures are designed to match uppercase characters. Tabular figures are designed for figure placement in tabular (tabbed/tables) format, e.g. as in financial reports etc. Proportional figures are designed to be proportionaly spaced.

I’m a fan of Proportional Oldstyle, I like the smaller font size.

089_02_propoldstyle

From the Character Style panel menu choose New Character Style and set the Style Name for the style. I’m setting mine to “Proportional Oldstyle”.

Click OK to add the style to the Character Styles panel.

089_03_newcharstyle

Paragraph Style

Time to start GREPPING again… and this one will be a quickie 🙂

From the Paragraph Styles panel, right-click “Body Text” (or the style that you want to edit) and choose Edit “Body Text”.

The Paragraph Style Options dialog appears.

Click GREP Style, and click New Grep Style… to add another GREP style to the paragraph style.

089_04_newgrepstyle

Choose the “Proportional Oldstyle” Character Style from the Apply Style list. And believe it or not you’re done.

That’s because the default expression that InDesign inserts is “Any Digit, One or More times”. But let’s imagine your setting the expression anyway 🙂

Clear the field data in To Text. Then from the Special Characters for Search pop-up choose: Wildcards > Any Character

Follow this with: Repeat > One or More times.

Click OK and you’re done 🙂

089_01_applied

Video Tutorial

 

Similar posts
  • Adobe InDesign and XML: A Reference Guide The following is a reference guide I have compiled over time for those of you who are looking at doing a little more with XML in InDesign (originally published Feb. 2011, last updated Feb 2018). If you have any extra information you’d like to see added to this guide, feel free to message me. Mapping XML tags to InDesign [...]
  • How to change the colour of bullet points in InDesig... A few weeks ago I recorded a short quick tip tutorial. InDesign’s Control panel, gives users a quick and easy way to format text as a bulleted list. Highlight the text, and click the Bulleted List button in the Paragraph Formatting Controls mode for the Control panel. This applies a universal bullet character as the [...]
  • Creating a pop-up window in a PDF with Adobe InDesig... In the following YouTube tutorial, we’ll create an interactive PDF from Adobe InDesign, in which we click on a button, which in turn opens up a simple pop-up window containing a close-box. When the close-box is clicked the pop-up window disappears [...]
  • InDesign: Facing pages with odd-numbered left pages Back in 2004 I wrote a tip for InDesign CS on how you could have the first page of your document be a left page AND have it start with page number 1. It’s hard to believe this is almost a decade ago… But a recent question on Facebook, made me think I should really [...]
  • Negative Lookbehind – GREP for Designers This is the fourth and final blog-posts in a series of posts on lookaheads and lookbehinds in GREP, written after speaking at the Perth InDesign User Group. My speaker notes are also available: What is GREP? (PDF download) (2.4Mb). In the previous three posts I briefly introduced GREP, and we took a look at Positive [...]

9 Comments

  1. Peter S. Peter S.
    August 14, 2013    

    @Frank – Vielen Dank für deinen Beitrag, ich hätte nicht gedacht das man so etwas mit GREP machen kann 😀

    @Cari Jansen – this series is great 🙂

  2. Frank Fechner Frank Fechner
    May 18, 2010    

    Sorry for my poor english at 4:30 am 😉
    with colon I meant comma actually.

  3. Frank Fechner Frank Fechner
    May 17, 2010    

    Hi Ben,
    I was fiddling around with these some weeks ago, and there are some major problems with inserting spaces into numbers is a) line braking and b) copy and paste out of the resulting pdfs if for some reason someone needs those numbers (screenreaders do that and searchengines too).
    What I’m always trying is to format this spacing inline as an characterstyle set as an GREP-style in the paragraph style.
    I define a character style with an letterspacing of 300/1000 and give an name like 1000-spacing.
    then my paragraph style gets an additional GREP-style to apply that character style for every 3rd digit before the decimal seperator – a colon for the german and I think most of europe – US and others using a point instead.
    the GREP rule is the following: (according to DIN 5008 for germany ISO 31 international)

    ((?<=\d)\d(?=(\d{3}[^\d])))|(\d(?=((\d{3}){2,}[^\d])))

    This is a two term rule (separated by the pipe |).
    The first part applies to numbers larger than 9999 because the separation should only take place for 5 and more digits before the colon.
    The second part applies to every 3rd digit beginning with the 6th (counting from right to left).
    This only works correct for the digits left of the colon and does not "break" the rules if there are only 3 digits behind the colon (I never needed more than 2 ;). It works in table cells as well as inline any text for numbers with decimal digits like 10000,00. For some strange reason it will not work for numbers like 10000 if they are located inside a table cell but I could'n figure out why (\z and \Z as "End of Story, Footnote, Cell" and $ as end of the string are not working ID CS 4 6.0.5. for the positive lookahead)

    To fix that bizzare behavior I usually have an space behind each number without decimal digits. These are not shown in right justified cells. You can search and replace them by do a GREP search over the table for "(\d+)$" which finds any number at the end of the line / last in the cell and replace by "$1 " dollar-sign-1 is the 1. match-group of the search term followed by an space.

    Explaing the GREP rules in detail:
    ( (?<=\d)\d(?=(\d{3}[^\d])) ) | ( \d(?=((\d{3}){2,}[^\d])) )

    select the digit if it follows a digit and is followed by exactly 3 digits and then anything other than a digit OR select the digit if it is followed by two or more groups of exactly 3 digits and then anything other than a digit.

    I hope that helps, even if its far away from perfect. I'm using this on an paragraph style which is the base style for numbers in finance tables a lot together with rules for marking negative numbers red and some other goodies.

  4. Jongware Jongware
    April 13, 2010    

    Ben,

    Not in one go (*), since there can be more than one group of 3 (plus one in front) digits. You cannot use the wildcards in combination with (\d)(\d\d\d)+(?!\d), where the middle ($2) group can be repeated indefinitely. Would this one help?
    Search: (?<=\d)\d\d\d(?!\d) and Replace: (space)$0
    You repeat this same replacement until it reports "No match found".

    (*) I bet it's possible in one go when using an If/Then for the Search bit, but you'd have the same problem in the Replace part. Perl supports (?R), meaning the expression should recurse on itself (run again), but ID's implementation can't do that.

  5. Cari Jansen Cari Jansen
    April 2, 2010    

    Hi Ben,

    Just trying to figure out what you are trying to do, don’t quite understand it Sorry!. (and yep “je kunt ook in het Nederlands schrijven!”… Jansen is indeed very much a Dutch surname 😉 )

    what is the current data format in the table cells?

    and what do you want to replace it with?

    Even a screenshot of ‘before’ and ‘after’ view would probably be sufficient to give me a better idea, and I’ll look at it for you.

    Cheers,

    Cari

  6. Ben Rehorst Ben Rehorst
    April 1, 2010    

    \d{6},\d*$|\d{6}$ must by \d{3},\d*$|\d{3}$ for digit like 1 000

  7. Ben Rehorst Ben Rehorst
    April 1, 2010    

    Hi Cari,
    Iam from Holland if i hear the name Jansen than i think your from Holland too.
    Here My question. Can i make a Grep search and replace to split numbers (1 000) and 1 1111 111) and so on. I do this in two greps to spilt 1 111 111 i use \d{6},\d*$|\d{6}$ and than i split 1 000 with \d{6},\d*$|\d{6}$. But is there a other way to do this. I have tables with thousands of cels with digit as 12,2 and 1200,33 and 120000,99 and so on.

  8. Cari Jansen Cari Jansen
    July 6, 2009    

    @Jochen:

    Absolutely. 🙂

    I am trying to provide some demonstrations of what GREP can be used for, and by no means saying that there are no other ways to achieve a similar result 🙂

    I think each InDesign user develops his or her preferred ways of doing things over time. 🙂

  9. July 6, 2009    

    Hi Carl, that’s a good example for learning GREP, indeed. But: As soon you’re defining Old Style Figures in the Paragraph Style your job is done already – without GREP. What could be a more convincing and yet simple example in regard to figures (thinking …)?

Leave a Reply

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