Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
In addition to quick and easy formatting, GREP Styles also let you do something that's otherwise impossible in InDesign, and that is to simultaneously apply more than one character style to the same bit of text. The Paragraph Style applied to the body copy in this document already has a GREP Style built into it that automatically detects prices and formats them by changing their color and typeface. What I want to do is change a small portion of that price, just the cents and I want to apply the superscript attribute through another character style.
I have another character style in this document, called Cents. I'll right-click on the Cents Style in the Character Styles panel and choose Edit Cents, from the context menu. In the Character Style Options dialog, let's take a look at what's going on in this particular character style. Under Basic Character Formats, nothing about the style is defined uniquely except that it uses the OpenType Superior/Superscript attribute. In addition, under Advanced Character Formats, there's a slight Baseline Shift that positions the numbers exactly where I want.
I'm not making any changes, so I am just going to click Cancel. Now I am going to go back into the Paragraph Style that's being used here, which is Body Text, right-click on that, choose Edit Body Text, and go to the GREP Style area. There are already two GREP Styles built-in here, one for the Figure References that we saw in a previous movie as well as for the Prices. What I want to do is take this last portion of the expression, which describes the cents, which is any two digits.
I am going to copy that to the clipboard using Command+C, or Ctrl+C, and I am going to create a New GREP Style, and in this To Text field, I am going to paste in, what I just copied out of the previous style. And to that I want to apply the style Cents that we just looked at. If I click off here to see what happens on the page, we instantly have a problem. I haven't properly defined the cents. It's taken every pair of digits and applied that Superscript style to it.
What I need to do is require that those two digits be preceded by the decimal point in the price. And to do that I am going to use Positive Lookbehind, from the Special Characters menu, I'll go to Match, Positive Lookbehind, and as my Positive Lookbehind criteria, which goes in right after the equals sign, I'll type backslash, period, which defines a literal period, not the any character metacharacter, and I'll click off here, and that's what I want. I want to have that Cents style applied only to two digits that follow a period, and it'll give me that price look that I'm going for.
So here, in this one Paragraph Style, I've got a GREP Style that formats the entire price with one character style and another GREP Style that formats only a portion of that price with yet another character style. This is something you just can't do any other way. As long as there are no conflicts between the styles I'm using, I can apply many, many character styles to the same type of text using GREP Styles, and what do I mean by conflicts? Let's take a look. Right now, the Cents style doesn't define anything except the superscript position and that slight baseline shift and that's all it does.
I am going to click OK to commit to this and go back to the Character Styles panel, and make a change to that Cents Style. I'll right-click and choose Edit Cents and I'll go to Character Color, which right now, is undefined. You see the question mark on the Swatch icons. I am going to switch that color to Blue, and because Preview is on, you can see that my cents have now all been colored Blue, overriding the Red in the other GREP Style. Why did that happen? Let's take a look. I'll click OK, and go back to the Paragraph Styles panel, right-click on Body Text to Edit it, go back to GREP Style.
There is a specific order in which styles will be applied and honored in the GREP Style work area. The lowest priority is the first item in the list. Now, if you only have one GREP Style, that's not an issue. But as you add more GREP Styles, the lower they are in the list, the higher priority they get and one will override the other, on and on, as you go down the list. So because Cents is the lowest style in this list, it gets the highest priority and the Blue attribute that I added to it overrides the red attribute that's part of the overall price.
If I change the order by selecting the Cents GREP Style here in the list and clicking the Up Arrow down here, it shifts Cents up one level, and now you'll notice on the page that the numbers are red again. Prices now trumps cents and it wipes out the blue attribute. It doesn't wipe out the superscript attribute, however. When GREP Styles conflict, it's only the conflicting attributes that gets thrown out. If another aspect of a character style doesn't conflict, it gets preserved.
So here, the superscript part is preserved, the blue is thrown out. If I shifted it back down in the list again, with the Down Arrow then that character style now has a higher priority and the blue overrides the red. This is how conflicts and priorities are resolved within GREP Styles, but GREP Styles can also be applied in combination with Nested styles and Nested line styles. As long as there are no conflicts among those style attributes, they'll all be applied simultaneously. If a conflict occurs, InDesign has a specific pecking order, for which it honors, and in what order, GREP Styles get the top priority.
Nested Styles are obeyed next, and Nested Line Styles get the lowest priority. Knowing how InDesign prioritizes style conflicts can help you structure multiple GREP Styles to apply complex, layered formatting that no other InDesign feature is capable of.
Get unlimited access to all courses for just $25/month.Become a member
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.