GREP and Styles

Just a few last things to touch on regarding GREP in InDesign. Last week’s piece went over the basics.

GREP-1

Apply a style

One of the great features that InDesign’s Find/Change dialog offers is the ability to apply styles to what you find. Speaking of style, if you’re not all that familiar with the difference in usage between paragraph and character styles, I recommend looking back over the piece on understanding styles, and a related exercise.

So, say I want all numbers to be sized down by a half a point. First, highlight one such number, size it down appropriately, and keeping it highlighted, create a new character style called, say, fig.

Next, open the Find/Change dialog (it’s under the Edit menu), make sure you’re on the GREP tab, and in the first field, type in \d. Then, in the Change Format field, select fig, the character style you just made. Hit change all, and you’ve now applied the character style to all digits everywhere in your document. (You can change the scope of your finding/changing in the box below the Change to field.) You can also (obviously) narrow the scope of your search by specifying a paragraph or character style in the Find Format field.

Grep style

That’s great, but it still means I have to remember to go back through these steps at the very end of modifying my document in order to catch any digits that weren’t previously converted.

Not necessarily. With Grep styles, set up the rule, and it will automatically be applied when anything changes. To illustrate, let’s apply a character style that turns on the OpenType fractions feature whenever there are fractions in a document.

This all happens inside a paragraph style’s settings dialog, so let’s make sure we’ve got a paragraph style already set up. Okay, I made one called Entry and applied it to all the rows in a table of fractions and their decimal equivalents.

Screen Shot 2013-08-01 at 4.52.30 PM

Next, I turn on the fraction feature through the OpenType menu in the Character palette. Then I keep that fraction highlighted while I create a new character style called Fraction.

Last, I go into Entry’s style settings, create a new GREP style, and apply Fraction to the following expression:

\d*\/\d*

Just to decode the regular expression above, that’s \d any digit, * occurring zero or more times (applied to the thing immediately before the asterisk), followed by \/ a slash (typed backslash slash), followed by the same thing at the start, zero or more digits, \d*

Screen Shot 2013-08-01 at 5.15.12 PM

Line it all up with some decimal tabs, and that’s it. The examples today are set in Jordi Embodas’s Pona. Using Type continues here Thursday.

GREP-Styles-2

PS. I’ve sat through a number of talks that encourage designers and developers to learn each others’ skills, and inevitably during the question and answer period the designers ask where to start with programming. My answer? Start wherever you’re comfortable, whether that be editing markup, such as HTML, or writing some javascript in an online environment such as CodePen, but somewhere early along the way, learn something about regular expressions. You’ll find that using them trains your mind to think logically, and that when understood, they can save you a lot of effort. By the way: how do you use regular expressions?

2 Comments

  1. Posted August 2, 2013 at 3:24 AM | Permalink

    Nice. Now to find a designer’s guide to regular expressions “for dummies”. ;-)

  2. Posted August 2, 2013 at 9:55 AM | Permalink

    http://help.adobe.com/en_US/indesign/cs/using/WSFB3603CC-8D84-48d8-9F77-F3E0644CB0B6a.html

    Here’s the best one for starter-outers.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 61,745 other followers