Menu

Need training at your office? Request a quote for custom training.

Home / Adobe InDesign / Adobe InDesign: Nested style, nested line style or GREP style?

Adobe InDesign: Nested style, nested line style or GREP style?

by Barb Binder, Adobe Certified Instructor

What is the difference between a nested style, a nested line style and a GREP style?

At first glance, they may appear similar. They are all variations on the same theme—each of the three allow you identify a text string in a paragraph and assign a character style to format that string. All three styles can be included in a paragraph style definition so that you can assign a character style at the same time you assign a paragraph style.

One important difference between them is where you can use them: nested styles and nested line styles must start at the beginning of a paragraph, GREP styles can appear anywhere within the paragraph. Another difference is that nested styles and nested line styles are somewhat limited in what they can match. GREP styles are much more flexible—and so there is a steeper learning curve.

Nested styles and nested line styles

You might use a nested style to format a run-in head. A nested style allows us to apply a character style to text within a paragraph, starting at the beginning of a paragraph, and ending at a specific character or defined end point. In this example, the bold character style is applied from the beginning of the paragraph to a defined end point—the period at the end of the first sentence. In this example, the nested style is built into the Body paragraph style.
Adobe InDesign: Nested styles

You might use a nested line style to format the first line of a paragraph. A nested line style is virtually identical to a nested style, including starting at the beginning of a paragraph, but always ends at the end of that line. If you edit the text or change the width of the column, a nested line style adjusts so that it still stops formatting at the end of the line. In this example, the Light blue character style was applied to the first line of each paragraph using the Body paragraph style.
Adobe InDesign: Nested Line styles

If you would like more details on how to work with nested styles and nested line styles, scroll down to the links at the bottom of the post.

GREP Styles

So what about GREP styles? Unlike nested styles and nested line styles which always start styling at the beginning of a paragraph, a GREP style can be applied anywhere within a paragraph: beginning, middle or end. GREP identifies a pattern, wherever the pattern appears. Patterns can be simple, challenging or extremely complex.

Let’s take a look at some examples. In this first screen shot, the body text is black. But what if we want to emphasize the word “Alice” wherever it appears in the text?

Adobe InDesign: Nested style, nested line style, GREP style

The letters “Alice” form a very simple pattern. You can define the pattern and assign a GREP style to it, as part of the paragraph style definition. By assigning a paragraph style with an embedded GREP style, every time Alice appears in the body text, it is blue and bold—no matter where it appears in the text.

Adobe InDesign: Nested style, nested line style, GREP style

Some patterns can be difficult to define, but this one isn’t. I clicked the New GREP style button in Paragraph Style Options > GREP Style and told InDesign to apply the Light blue character style any time it finds an uppercase A followed by lice. The expression reads:

Alice and matches all occurrences of Alice, and applies the character style.

Adobe InDesign: Nested style, nested line style, GREP style

Now perhaps we want to highlight all occurrences of both Alice and Rabbit. The pipe character “|” means “or”. So while the character style is still Light blue, let’s add |Rabbit after Alice (Alice or Rabbit), which tells InDesign to style either Alice or Rabbit. (Spoken language is different from the boolean operators used in GREP expressions. I might say out loud “I want to match Alice and Rabbit”, but I need to write “Alice or Rabbit”, so that it can match either one. I know. Google Boolean operators for more information on this logic.) Anyway, the expression now reads:

Alice|Rabbit and will match all occurrences of either Alice or Rabbit, and applies the character style.

Adobe InDesign: Nested style, nested line style, GREP style

We have now matched all occurrences of both Alice or Rabbit, but look at the end of the second paragraph. Sometimes White precedes Rabbit. In other places it doesn’t. As I said, building GREP expressions can get complex quickly, but we’re not scared. Let’s add (White)? to the expression so that it reads:

Alice|(White)?Rabbit and it will match all occurrences of Alice. Maybe White precedes Rabbit and maybe it doesn’t, but it will match either White Rabbit or Rabbit.

Adobe InDesign: Nested style, nested line style, GREP style

Ok, it really does get complex, fast. But help is at hand. I own two copies of Peter Kahrel’s GREP in InDesign: An InDesignSecrets Guide: an ebook on my computer and a paperback that I bring to the classroom when I am teaching. I love this book because Peter explains how to build GREP expressions step-by-step. He uses simple language, shares plenty of examples, and each chapter builds on the next. Sometimes I get lucky: I need an expression he listed as an example and I can just copy it from the e-book and paste it into InDesign. If you find GREP pattern-matching intriguing, I definitely recommend tracking down his book.

Meanwhile, the answer to the question posed in the title is, Location, location, location. Nested styles and nested line styles start at the beginning of a paragraph. GREP styles can appear anywhere within the paragraph, unless you learn enough about them to define a specific location, which is also an option. And they are way more flexible than the Nested styles and nested line styles.

For more information on nested styles and nested line styles

Adobe InDesign: Use nested styles to format run-in heads

Leave a Comment

Your email address will not be published. Required fields are marked *