Site Info

This web-site is created and maintained by Cari Jansen, Perth, Western Australia.


Advertisements



« | Main | »

Introducing GREP Styles (2)

Digitip 089 – Adobe InDesign CS4 – GREP your Figures

This is the second in a series of short GREP Style tutorials. I introduce GREP styles in the first post in this series. In this short tutorial we look at how we can use a GREP style to change the appearance of any figures within a paragraph style.

089_01_applied

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

Topics: Adobe, Fonts, GREP, InDesign, digitip | 8 Comments »

8 Responses to “Introducing GREP Styles (2)”

  1. Jochen F. Uebel says:
    July 6th, 2009 at 12:10 am

    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 …)?

  2. Cari Jansen says:
    July 6th, 2009 at 12:24 am

    @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. :-)

  3. Ben Rehorst says:
    April 1st, 2010 at 4:26 am

    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.

  4. Ben Rehorst says:
    April 1st, 2010 at 4:29 am

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

  5. Cari Jansen says:
    April 2nd, 2010 at 10:20 am

    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. Jongware says:
    April 13th, 2010 at 6:03 am

    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.

  7. Frank Fechner says:
    May 17th, 2010 at 4:27 am

    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.

  8. Frank Fechner says:
    May 18th, 2010 at 2:50 pm

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

Comments

Trademarks: Adobe, the Adobe logo, Acrobat, Creative Suite, Illustrator, InDesign, Photoshop, PostScript are trademarks of Adobe Systems Incorporated.

Disclaimer: While every precaution has been taken in the preparation of this web-site, the creator shall not have any liability to any person or entity with respect to any liability, loss, or damage caused or alleged to be caused directly or indirectly by the information or instructions contained in this web-site, or by the computer software and hardware products described therein.