Site Info

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


Advertisements



« | Main | »

Introducing GREP Styles (4)

Digitip 090 – InDesign CS4 – GREPpin’ ahead or GREPpin’ behind

The following tip is the 4th tip in a series of tips on GREP that I’m working on. It’s one of my personal favourites. Probably because I’ve worked with so many people in my carreer who set those Ads you find in your letter box twice a week. The local supermarket product advertising material is what I’m talking about.

091_14_Done

Because of the amount of GREP styles involved in creating this Paragraph Style, I won’t add screenshots for each step, but instead provide you with step-by-steps on how to get to the end result.

Let’s start working.

Paragraph Style

We will be formatting our Paragraph Style with 6 different character styles, in order to do this I’ve started out by creating a very simple Paragraph Style called “PriceTag”. It merely sets the Alignment of the style and nothing else.

091_01_ParaStyle

Character Styles

Next with the Paragraph Style applied to two samples, format the samples as you would like them to look. Basically what you’re doing is prepping for the Character Styles. One tip is that I would advice you to change the Kerning setting to Optical so that the  spacing for figure pairs is just that bit better looking.

091_02_CharStyle

Once you’ve got the format right. select the formatted text bit-by-bit and define Character Styles for all of the components.

Dollar Symbol is used to set the ‘$’ in $99.99
Dollars is used to set the first ‘99′ (or other number) in $99.99
Decimal Point is used to make the full-stop . disappear in $99.99
Cents is used to set the second ‘99′ in $99.99 in a smaller font and with baseline shift (or superscript if you prefer).
Cents Big is used only when defining a 99c type price and sets the ‘99′.
Cents Symbol sets the ‘c’

Make the decimal disappear

To make the decimal disappear, I set it to 1pt font size and 1% horizontal scaling and change the fill colour to [none]. You might need to play around with this a little till you get things right.

Before we start with the GREP styles… Let’s reset our original text again and clear the character formatting changes we applied for the purpose of character style development.

Right-click the Paragraph Style, and choose Apply “PriceTag” Clear Overrides.

GREP Styles

Time to start creating our 6 different GREP styles that will make up this PriceTag style.

Right-click the Paragraph Style and choose Edit “PriceTag”… Then in the Paragraph Style Options, click the New GREP style button for each of the styles listed below and follow the rest of the prompts listed.

Setting Dollar Symbol

Change Apply Style to: Dollar Symbol

Clear the Expression in To Text. Cool so the literal text we’re look at here is the dollar sign itself. Unfortunately we can’t just enter a $, as that character is one of the reserved characters for GREP. We’ll “escape” it by placing a backslash in front of it ‘\‘.

To Text: \$

Setting Dollars

Now to those dollars. Change Apply Style to: Dollar Symbol

The Expression in To Text has already got the /d+ in it (Wildcards > Any Digit, Repeat > One or More Times), to allow for the dollars digits to be formatted.

Place the cursor after the /d+

It’s now time to insert a Positive Lookahead. The dollar ‘digits’ are placed ahead of the full-stop (decimal point) and that’s what we’re looking for when defining the GREP expression that sets these. We need to tell the expression that ‘if’ the digits are ahead of the full-stop, then the character style must be applied.

From Special Characters for Search choose: Match > Positive Lookahead. This adds (?=) to the expression. All we need to do know is, insert the full-stop inside this part of the expression.  Again, the ‘.‘ actually has a reserved meaning in GREP, so we must escape it with the ‘\‘.  Insert these characters before the closing parenthesis.

To Text: \d+(?=\.)

Setting Decimal Point

Change Apply Style to: Decimal Point.

Clear the Expression in To Text.We’re once again inserting literal text here ‘.’ and as in the previous GREP style we must escape the character and are thus inserting ‘\.

To Text: \.

Setting Cents

Wow, we’ve made it to the Cents. That means we’re half way there :-)   Change Apply Style to: Cents.

As previously mentioned the expression in To Text has already got the /d+ in it (Wildcards > Any Digit, Repeat > One or More Times), to allow for the cents digits to be formatted.

Place the cursor in front the /d+

It’s now time to insert a Positive Lookbehind. The cents ‘digits’ are placed behind of the full-stop (decimal point) and that’s what we’re looking for when defining the GREP expression that sets these. We need to tell the expression that ‘if’ the digits are behind the full-stop, then the character style must be applied.

From Special Characters for Search choose: Match > Positive Lookbehind. This adds (?<=) to the expression. All we need to do know is, insert the full-stop inside this part of the expression, similar to how we did this for the Positive Lookahead (?<=\.)

To Text: (?<=\.)

Setting Cents Big

Ha, time for another Positive Lookahead  the bigger cent digits ahead of the ‘c’ ;-)

Character Style setting first… Change Apply Style to: Cents Big

The Expression in To Text has already got the /d+ in it. Place the cursor after the /d+

It’s now time to insert the second Positive Lookahead. The bigger cent ‘digits’ are placed ahead of the ‘c‘. We need to tell the expression that ‘if’ the digits are ahead of the ‘c‘, then the character style must be applied.

From Special Characters for Search choose: Match > Positive Lookahead. This adds (?=) to the expression. Then insert ‘c‘  characters before the closing parenthesis.

To Text: \d+(?=c)

Setting Cents Symbol

We’ve made it to the last GREP style, another Positive Lookbehind… remember the ‘c’ behind the bigger cent digits :-)

Character Style setting first… Change Apply Style to: Cents Symbol.

The Expression in To Text has  got the /d+ in it. This time we’ll clear that.

Instead we will insert the ‘c’ first and place our cursor in front of the ‘c’.

We’ll insert a Positive Lookbehind. The ‘c’ is placed behind the bigger cent ‘digits’. We need to tell the expression that ‘if’ the c is behind the digits then the character style must be applied.

From Special Characters for Search choose: Match > Positive Lookbehind. This adds (?<=) to the expression.

My instinct was to insert \d+ inside this expression, but that doesn’t work. Instead we’ll have to insert a Character Set that tells the expression the c can sit behind a 0,1,2,3,4,5,6,7,8 or 9.

Place the cursor in front of the closing parenthesis. Then choose from Special Characters for Search choose: Match > Character Set. This adds [] to the previous insertion.

We’ll now insert the characters, and if we enter 0-9 we’re basically defining all of digits.

To Text: (?<=[0-9])c

Wow… we’ve made it to the end :-) Click OK to update the Paragraph Style.

091_15_PStyleOptions

Ready to apply our new Paragraph Style with Grep Styles to our Price Tag text frames.

If you want to make things even more exciting, then enable the Paragraph Style option as part of a fancy Object Style… and all your formatting will be applied through the Object Style.

Video Tutorial

Topics: Adobe, GREP, InDesign, digitip | 3 Comments »

3 Responses to “Introducing GREP Styles (4)”

  1. Leo says:
    August 18th, 2009 at 9:18 pm

    Hello Cari,
    this is an SOS from the Netherlands. Love your site en above all your tuts about GREP. I’ve got a problem which I can’t solve. What I want is this: Any filename with any extension as in newsletter.psd and adverb.tif has to be a different style.
    I found out this \.*[.].*$ but it works only for the dot+extension. I know you can! But please will you help me? Greetings from Holland. Leo

  2. Kerry says:
    July 20th, 2010 at 10:53 am

    Hi Cari

    I am very new to Grep styles and want to know is it possible to make a line of text disappear using GREP. I am working with large document and have set up a paragraph style for my running head text variable. I would like to make my paragraph style be invisible in the main copy but still be there to be picked up for the running head. Is this at all possible?

  3. Cari Jansen says:
    August 11th, 2010 at 9:04 am

    @Kerry that is definitely possible, but to pick up the content for the text variable, you must ensure the text physically exists within the main copy. So you’d need to define this paragraph style as something that is like 1pt font and 1pt leading and make the stroke and fill colour none. So although the text is physically there… it won’t be visible :-)

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.