Finessing Files in InDesign: Adding GREP No Break to Paragraph Style

Widows, Orphans, and Runts, Oh My!

It has been my experience that nothing (except maybe bad kerning or poor font choice) makes an art director grab for a red pen like finding paragraph runts in text. A runt is a very short word or phrase that sits by itself in the last line of a paragraph. In previous posts we discussed the benefits of using a Nonbreaking Space and a No Break Character Style to help finesse your text flow.

But wouldn’t it be grand if you could actually prevent most bad breaks from occurring at all?

While these tools make it easier to control how your text flows, they will not save much proofing time on your part because you will still have to read the text to spot bad breaks and then manually apply these options to correct them. Wouldn’t it be grand if you could actually prevent most bad breaks from occurring at all? You can! With the power of GREP.

According to Wikipedia, GREP is a “command line utility for searching plain text data sets for lines matching a regular expression.” It derives its name from the command g/re/p (globally search a regular expression and print). [I know, I don’t get it either.] For years I avoided GREP because I thought it was hard. Little did I know that had I embraced it, my life would have been so much easier!

I know what you’re thinking: Why are we talking about this GREP stuff anyway? I thought this post was about InDesign Paragraph Styles and eliminating breaks! It is. Please be patient, and I’ll work you through the steps of creating a GREP Style. [Be advised: I do not claim to be an authority on GREP, nor do I understand it very well. This entry just concentrates on how I use the little I know.]

Screen Capture of Paragraph Style Window with GREP Style indicated
Paragraph Style Window with GREP Style indicated.

One of the Paragraph Style Options available in the overarching Paragraph Style menu is GREP Style. This is the option that I was afraid of for a long time. Why? Because when you click on the GREP Style button, here’s what you see:

Screen Capture of the GREP Style window enabled. Window appears to have no options.
GREP Style window enabled. Window appears to have no options.

This window is oddly empty compared to other options. The text in the window instructs you to click New GREP Style in order to create a new GREP Style. [Uh, that’s what I thought I just did.]

So, even though it seems redundant, go ahead and click New GREP Style. Here’s what you get:

Screen snap of the New GREP Style window activated in InDesign Paragraph Styles shows some options available.
After clicking New GREP Style, window shows some options.

Apply Style: [None] To Tex:t d+. I could not figure out what that meant. Every time you see an arrow character in a menu, it indicates that there are other options available via drop down menu. But this has no arrow characters. You are on your own. Until you actually click into the Apply Style: and To Text: fields. When you finally get brave enough to click in those fields, the magic starts to happen.

Clicking in Apply Style allows you to choose a drop down menu.
Clicking in Apply Style allows you to choose a drop down menu.

Clicking in the Apply Style: field activates a drop down menu that features all of your character styles. Choose the style you want (in this case: No Break). Then decide on the GREP expression you want to use to detect the text you don’t want to break. In the example above we are instructing the InDesign application to search for runts and apply the No Break character style to them as the type is being laid out. We chose a GREP expression .{10}$ which translates roughly into “ten consecutive characters followed by a return.” This will make sure that the last line of each paragraph that is styled with Body Text (or any style based thereon) has at least 10 characters. You can change that value if you want a shorter or longer line.

[Many thanks to Cross Media, David Blatner, Anne-Marie Concepcion, Lynda.com and others for that text string. Hint: if you Google “GREP in InDesign” you will get many helpful hints [most more intelligently written than mine]. InDesign Secrets has a very helpful page of GREP hints. And Jen Jones has a blog post that will show you how to actually create intelligent GREP expressions.]

The advantage to putting this GREP Style into your Body Text paragraph style is that InDesign will now do all the heavy lifting for you. No matter how many revisions the text goes through, or how many times you change the paragraph margins or type size, your body copy will not contain runts. That’s one less thing to worry about.

No Break for Trademarks, Company Names, etc.

Another way to use GREP No Break is to actually input the text that you want to keep together into the To Text: field (you don’t need GREP expressions here; actual text works). For example, let’s say you have a story that takes place in New York. “New” and “York” are two small words separated by a space. They may break at inopportune places in your text unless you:

Find/Change window replacing the space in New York with a nonbreaking space.
Find/Change window replacing the space in New York with a nonbreaking space.
  1. Use Find/Change to replace the phrase “New<press space bar>York” with the phrase “New^SYork” (where ^S equals nonbreaking space–you can find that option easily by clicking on the @ symbol to the right of the field) or
  2. [So much easier] simply type the phrase “New York” (without the quotation marks) in the To Text: line of a new GREP No Break style. Job done.
GREP No Break style applied to a nonGREP expression: New York
GREP No Break style applied to a nonGREP expression: New York

Once you get the hang of the GREP window, you will think of many uses for it. You will be able to quickly and confidently apply character styles to any text that needs to be outstanding in a paragraph. If your company logotype needs to appear in italic or small caps, just apply that character style to the text using a new GREP Style. You can combine many different GREP Style options into one paragraph style. They will work in tandem. Your workload will be cut in half and your art director will think you are a genius!