Posts Tagged ‘ GREP

Adobe InDesign: Assigning Old Style Figures through GREP Styles

By Barb Binder

GREP (General Regular Expression Print) made its first appearance in Adobe InDesign CS3 as a major upgrade to the Find/Change dialog box. By using GREP searches, we could search for patterns instead of literal text/numeric strings. Document clean-up took a giant step forward with this addition. (For more information on GREP Find/Change, visit “Adobe InDesign: Removing Unwanted Spaces, Fast!” and “Adobe InDesign: GREP to Replace Hyphens with En Dashes”. )

In Adobe InDesign CS4, GREP Styles made a fairly quiet appearance. In my observation, they were ignored by most InDesign users, most likely because they didn’t appreciate the power that was suddenly at their fingertips. Instead of a Find/Change update that you have to initiate, these GREP Styles work automatically, as you enter and edit text.

I’m going to use the example of Old Style figures to illustrate the point. If you aren’t familiar with the term, please study the illustration below. Both sets of numbers are set in Garamond Premier Pro 23/27, but the figures on the left are “Lining figures”, a modern style of numerals where all figures are of the same height and rest on the baseline. The “Old Style” figures on the right vary in height and position, and can have either ascenders or descenders. If you decide you want to use the Old Style in place of the default lining style, you’ll have a little work ahead of you. (But if you read this whole article, it’s really just a little work.)

Adobe InDesign: Lining vs Old Style Figures

One more note, make sure you choose an OpenType font for this tutorial. You get a bunch of them with your Creative Suite installation. for example, Adobe Garamond Pro, Adobe Caslon Pro, Minion Pro and Myriad Pro will all work.

Technique Number 1: Find/Change with GREP

  1. Open up a document with lining figures:
    Adobe InDesign: Lining Figures
  2. Choose Edit > Find/Change. Begin by clicking on the GREP tab, and then search for \d, which means any digit. Finally, click the Specify Attributes to Change button.Adobe InDesign: GREP Find/Change
  3. In the Change Format Settings dialog box, pick the OpenType Features from the category list on the left, and change the Figure Style to Proportional Oldstyle. Click OK.Adobe InDesign: Change Format Settings to Oldstyle
  4. Set the Search range (i.e., document, story, selection) and Change All.Adobe InDesign: Find/Change results
  5. Click OK and admire the Old Style figures:
    Adobe InDesign: Oldstyle figures
  6. It’s great, but if you add any more numbers, you’ll have to run the search again (and again and again):
    Adobe InDesign: No automatic update


Technique Number 2: GREP Style

  1. Let’s start over again, and try the same thing with a GREP Style:
    Adobe InDesign: Lining Figures
  2. This time, select the text and create a new Paragraph Style. Choose Window > Type & Tables > Paragraph Styles. Hold the Alt/Opt key as you click the Create New Style button:Adobe InDesign: Paragraph Styles panel
  3. Give your style a descriptive name (I called mine “Address”). Click on Apply Style to Selection and Preview before clicking on GREP Style in the category list on the left.Adobe InDesign: New Paragraph Style dialog box
  4. Click the “New GREP Style” button:Adobe InDesign: Add a new GREP style
  5. Notice that the new style already conveniently shows \d+, which means apply to one or more digits. That works.Adobe InDesign: To text defaults to \d+
  6. Now we need to apply a Character Style to change all the numbers to Old Style, but we forgot to create it in advance. No worries, just click the word [None] after the words Apply Style, and click on the create New Character Style option:Adobe InDesign: Add a Character Style on the fly
  7. Give the new Character Style a descriptive name (I used “Old Style Figures”), and click the OpenType category from the list on the left. Change the Figure Style to Proportional Oldstyle and click OK until you are back to your document.Adobe InDesign: Character Style options set to Old Style Figures
  8. Not only is your existing text using Old Style figures, try adding some more text. WOW! All numbers within the Address paragraph format will automatically shift to Old Style, with no additional work on your part. Now that’s a timesaver.Adobe InDesign: Old style figures are now automatic

Post to Twitter

Adobe InDesign: Removing Unwanted Spaces, Fast!

By Barb Binder

People preparing files for me to place into a page layout program do some very wacky things in their files. Besides being unable to resist formatting their Word files (even though they’ve hired me for formatting) there’s a lot of extra spacing going on that needs to be removed. There’s intentional spacing like the double spaces after sentences (I’m not going to argue with you here—I just challenge you to pick up any professionally-printed publication off your desk and note the sentence spacing) and double hard returns between paragraphs. There’s also going to be unintentional spacing as well—triple and quadruple spaces, tab space space tab sequences, tabs in the middle of paragraphs, hard returns in usual places, and on and on and on. I want all of these spaces out before I begin laying out a new document.

It’s tough getting people to change their typing habits, so what’s a girl to do? I find it easiest to accept the files they way they were submitted, and then run a series of Find/Change sequences on them to clean them up and get them ready for my formatting. This works in any page layout program, from FrameMaker to Quark to InDesign. However, InDesign has added some GREP pattern queries to the Find and Change dialog box for this exact scenario, beginning with InDesign CS3. Here’s the best part: you don’t need to know what GREP means (General Regular Expression Print) or how it works. Try it:

  1. Place all your files into the InDesign document. (I place stories on the Pasteboard when I’m not ready to place them on the actual pages.)
  2. Choose Type > Show Hidden Characters so that you can see the spacing indicators.
    Adobe InDesign: Example of extra spacing.
  3. Chose Edit > Find/Change.
  4. Drop down the Query list on the top line and run each of these queries with the Search parameter set to Document (to search all the stories in the InDesign document):
    1. Multiple Space to Single Space. In lieu of running a series of searches to weed out all extra spaces, I can now just pick this one preset. The Find What line looks very scary, so just don’t look too closely. If you can’t look away, just understand that it’s a string of GREP characters that looks for two or more spaces (i.e., em spaces, en spaces, flush spaces, hairspaces, etc.) and replaces with one spacebar space. Hit Change All and poof! All extra spaces are gone.
      Adobe InDesign: Mulitple Space to Single Space query
    2. Multiple Returns to Single Return. Another preset, this one pulls out all the extra carriage returns and replaces with one.
      Adobe InDesign: Multiple Return to Single Return query
    3. Remove Trailing Whitespace. Trailing whitespace refers to one or more spaces at the end of a paragraph, between the final punctuation and the hard return(s). Most of the time these spaces don’t cause any problems, but sometimes they don’t fit on the same line as the punctuation and they force a new line or even a new page. For long documents, this can be a real nightmare. This query also picks up the double returns and even multiple spaces (but only when the spaces are at the end of a paragraph) so I tend to run this one first.
      Adobe InDesign: Remove Trailing Whitespace query

You may find you need some additional queries to deal with the spacing issues in your own files. For a compete list of the GREP search characters, see http://help.adobe.com/en_US/InDesign/6.0/WSa285fff53dea4f8617383751001ea8cb3f-6f59a.html) Give it a shot! Once you figure out the pattern that you need, don’t forget to click the little diskette button next to the Query list so that you can save your query for future document clean-up.

Adobe InDesign: Extra spacing removed.

Post to Twitter

Adobe InDesign: GREP to Replace Hyphens with En Dashes

By Barb Binder

What in the world is General Regular Expression Print (GREP)? Wikipedia defines it as “… a command line utility that was originally written for use with the Unix operating system. Given a list of files or standard input to read, GREP searches for lines of text that match one or many regular expressions, and outputs only the matching lines.”

What? Well, in plainer language, by searching for patterns rather than specific characters, GREP is a way to a take InDesign’s Find/Change to a whole new level.

As my good friend and grammar teacher extraordinaire Jennie Ruby once told me, use an en dash between ranges of numbers when you would say the words “to” or “through”, as in “see pages 14-20 in the reference guide.” So what do you do when your writers use hyphens between digits instead of en dashes? You certainly can’t just search for all hyphens and replace with en dashes (you’ll mess up all the hyphenated words).

Find/Change Text comes so close. You can use the special character list to search for any digit, an en dash and any digit, but there’s no way to replace the digits. In my pre-GREP life, my best bet was to run 10 individual searches: Search for 1-, replace with 1–; search for 2-, replace with 2–; etc.

Enter GREP. You can enter in a fairly simple GREP query that will find all Arabic numerals with a single hyphen and change those hyphens to en dashes. Try this one next time you have to update your hypens to en dashes:

  1. Choose Edit>Find/Change
  2. Click the GREP tab
  3. Add the following strings:
    Find What: (?x)\b(\d+)-(\d+)\b
    Change to: $1~=$2
    GREP 2
  4. Use the Find, Change, Find & Change and Change All buttons to update your documents.
  5. And don’t forget to save the Query so that you can use it again and again!

Try it and tell me that isn’t awesome! I just wish Adobe would add GREP support to FrameMaker, too.

By the way, the best resource I’ve found so far to teach myselft GREP is “GREP in InDesign CS3/CS4″ by Peter Kahrel. You can purchase his e-book for just $10 here. It offers clear explanations and numerous examples of common searches.

Post to Twitter