Advertisement
Designing

Quick Tip: Automatic Formatting using GREP Styles in Adobe InDesign

by

InDesign's GREP styles are the magic of automatic formatting. In this Quick Tip we will explain how to set up GREP styles and how you can use them to for a consistent and efficient design.


Step 1: Understanding Regular Expressions

GREP styles are character styles that InDesign applies to a specific part of the text in a document. This part can be a single character, word or a pattern of characters. To specify the part a language called regular expressions is used.

With this language you can describe patterns in the text that need to have special formatting applied. You can do this in InDesign using the GREP Style option in the Paragraph Style Options dialog.


Step 2: Creating a New GREP Style

You can use GREP styles for a lot of things. To start simple, I'm going to use a GREP style to format image captions. Click the button New GREP Style. You'll see a new style rule appear. First, we need to create a new character style. Click the option menu and choose New Character Style.


Step 3: Setting up the Character Style

For the captions, I'm using Myriad Pro Semibold in Small Caps as my new character style.


Step 4: GREP options

InDesign automatically puts the regular expression \d+ in the To Text field. \d is a wildcard which stands for Any digit and the plus symbol means repeat one or more times. So, as default, InDesign will apply your character style to digits as 14, 001 or 2010.

To see all the options available to construct a regular expression, click on the @ button.


Step 5: Setting up the Regular Expression

I'm going to delete the default regular expression and construct a new one for the image captions. The words I want to format with the new character style are top, left, right, bottom and middle. The expression I'm using is:

^(top|left|right|bottom|middle)\s

You should read this as: paragraph begins (^) with the words top or (|) left or right or bottom or middle, followed by a whitespace character (\s). In this way, only if the words appear at the beginning of a paragraph and are followed by whitespace get the character style applied. You can see the final result below:

Photo by peasap on flickr


Step 6: Preventing Orphans

One of the most useful things you can do with GREP styles is preventing orphans in your layout. An orphan is a single word that appears at the last line of a paragraph. With GREP you can apply a character style with No break checked to the last whitespace character in a paragraph. This will ensure the last line of a paragraph has at least two words on it. The expression for this is:

(?<=\w)\s(?=\w+[[:punct:]]*\r)

This expression uses positive lookbehind (?<=) to check if there is a word character (\w) before the whitespace (\s), and positive lookahead (?=) to check if there are one or more word characters (\w+) and zero or more punctuation characters ([[:punct:]]*) before the end of a paragraph (\r). As you can see, GREP styles can become somewhat complex.


Conclusion

GREP takes some time to master but when you do, you can save a lot of time with automatically applying formatting depending on the text. Various examples of other expressions can be found on the web. Please tell us in the comments which GREP styles you're using!

Related Posts
  • Design & Illustration
    Tools & Tips
    Give Your Design Extra Style With Alternate CharactersAlternate characters
    Do you know that many fonts have alternate characters such as logotypes and swashes? Take advantage of these hidden gems and elevate your design from boom to kaboom! Read More…
  • Computer Skills
    App Training
    How To Create an MLA Template in Word and PagesPreview
    In this tutorial, I will show you how to make MLA style templates in Pages and Microsoft Word to eliminate the need to remember each and every style rule each time you write an MLA style paper. You'll only need to make the template once, and every time after that it'll only take a click to get your paper formatted correctly.Read More…
  • Design & Illustration
    Designing
    Create a Stand-Out Portfolio Book in InDesign: Part Two - the InsidePreview image 400by400
    In the second part of this two-part tutorial you'll learn how to design the interior pages for an Illustration Portfolio book intended for print, in Adobe InDesign. We will create a number of different page layouts and explore how layout styles can showcase your work to its best potential. In this tutorial I will be using vector assets from other Tuts+ tutorials, but the tutorial is designed so that you can interchange these with your own illustration work to create your personal portfolio. Refer to part one for creating the portfolio cover.Read More…
  • Design & Illustration
    Layout
    Create a Stand-Out Portfolio Book in InDesign: Part One - the CoverFinal cover 400by400 revised
    In the first part of this two-part tutorial you'll learn how to create a high-impact cover for an Illustration Portfolio book intended for print, in Adobe InDesign. In these tutorials I will be using vector assets from other Tuts+ tutorials, but the tutorial is designed so that you can interchange these with your own illustration work to create your personal portfolio.Read More…
  • Computer Skills
    App Training
    How to Effortlessly Create Markdown With TextSoap Textsoap400
    TextSoap is an invaluable utility that I find increasingly useful. It comes with special text cleaners -- little routines for processing text. In this tutorial, I will introduce TextSoap and create a custom text cleaner for processing an article written in Markdown to make it ready for adding into WordPress.Read More…
  • Design & Illustration
    Designing
    Create a Trendy One Page, Print Ready Newsletter in Adobe InDesignPreview retina image v2
    A newsletter is a common business tool to inform customers and employees of company accomplishments and upcoming events. Adobe InDesign is the perfect software to do this. In this tutorial, you'll learn how to properly set up the document with bleed, create columns and set guides, set paragraph styles, and utilize text column breaks and text threading options. We'll start by creating graphical elements in Adobe Illustrator and then bringing them over to InDesign to create our newsletter. Finally, you'll save the file as a print ready PDF for your local printer or Online printing service. Read More…