InDesign CS4 Styling Priority

Adobe InDesign CS4 contains a couple of powerful enhancements to Paragraph Styles. In addition to Nested Styles, CS4 enables you to apply character level styling on a line-by-line basis within a paragraph, or using GREP to identify and style runs of text. For example, you can use a GREP Style to automatically italicize any URL that appears in your text.

Here is the UI for Line Styles and GREP Styles:

These features give rise to a practical question: if a nested style, line style, and/or GREP style overlap, which formatting gets priority?

According to the composition engineer:

There can be ranges of text that have overlapping character styles
applied using GREP styles, line styles & nested styles all interacting.
If the style definitions don’t clash, they will ALL apply. For example,
if the first line is all-caps (line styles), and the first word is bold
(nested styles), then the first word will be both all-caps & bold.
Pretty trivial example, but they can stack. In the case where there is
a clash, the choice is pretty fixed:

Line-styles are lowest priority

Nested Styles are next

GREP styles are top priority

If you have multiple GREP expressions that match the same text, then the
styles will still stack, and the order of the expressions in the dialog
controls this.

4 Responses to InDesign CS4 Styling Priority

  1. Mike Perry says:

    One question, if you please.

    Does GREP styles let us change the text itself (like GREP S&R) in addition to applying a character style to it?

    Example: To italicize book titles in an index, I currently place « » characters around the title in the index panel and, after generating an index, run a GREP S&R that eliminates the « » characters and italicizes the text they enclose. It works marvelously. Will GREP styles let me add or delete characters that same way, so I don’t need to run the S&R?

    Doing this would allow user to take advantage of MultiMarkdown type formatting in text editors to tell InDesign how to handle formatting chores. No more reading through line by line to locate what needs to be in italics or small caps.

    And as one InDesign podcast mentioned, it would let M-dashes automatically become hairspace M-dash hairspace.

    [TC: Good question. The GREP Styles feature does not enable you to swap out characters as you describe.

    What you’re describing is, fundamentally, a Find and Change operation rather than just a styling operation, because the text itself is actually being modified. GREP Styles is means of applying character level styling to a run of text, so it can only do what you can do via character level formatting. The purpose is to give you the power of GREP pattern searching when it comes to applying character styling within a paragraph.

    The GREP Styles feature is dynamic in that it’s continuously evaluating text in a paragraph to identify a specified pattern. If your tag characters are removed, then the pattern no longer exists…so it ceases to be a match, and the text would no longer be italicized (using your example).

    So, in the scenario you describe, Find and Change remains the way you’ll need to perform that type of task, unless you can come up with some sort of invisible delimiter to use instead of “« »”. GREP Styles is used for automatically formatting identifiable patterns of text that remain unchanged. ]

  2. Anne-Marie says:

    Pretty cool Tim, thanks! Especially the part about multiple GREP expressions that match the same text.

    Because I was curious, I tested this exact same “what trumps what” for one of the videos in the ID CS4 New Features title I did last month (coming soon! … forgive the plug); and demo’d it in action.

    Here’s another tidbit: a locally-applied character style trumps all the automatic ones, but as with the rest, it’s additive. (Only the conflicting attributes in the locally-applied style appear to be applied.)

    Also, a Drop Cap character style has a place in the pecking order.

    So the complete list, from the top dog down, is:

    1. Manually-applied character style*

    … then the automatic ones:

    2. GREP style (priority is reversed for multiple GREP styles … last one in the list is the “strongest”)

    3. Drop Cap style

    4. Nested style

    5. Line style

    * (Only stacks on auto-applied character styles, on manually-applied character styles it replaces)

    Unfortunately, when multiple automatic character styles are affecting a given instance of text in this way, there’s no UI to show exactly which styles. When the text is active, the Character Style panel just says “Mixed” in its nested styles reporting corner.


    [TC: Yes, the GREP Styles are applied in order–from first to last–as per the dialog. And also “yes”, a manually applied character style overrides everything, because you’ve decided to take matters into your own hands.]

  3. Anne-Marie says:

    Hey Mike, it was me that gave that example for using GREP styles in the podcast, and as I was mentioning it I *knew* I was not being quite accurate … couldn’t remember exactly why though… but I also knew I had made it work in CS4 so I said it anyway. 😉

    So after we recorded I went back to my test file to see what I did.

    As Tim said, no, you can’t find/change in GREP styles. To add space around em dashes with GREP styles (the example I talked about in the podcast), what I should’ve said was this:

    Assuming you’ve got a ton of text with spaces before and after em dashes, or you’re in the habit of doing that as you write ….

    1. Create a character style whose only attribute is severely negative tracking. Call it “Tighten Up” or something.

    2. Add a GREP style to the text’s paragraph style that applies the “Tighten Up” character style to the spaces surrounding the em dash. (You can do this with one expression, one of those “look around” thingies. Though I don’t know it off-hand.)

    The GREP style tightens up the space around em dashes automatically in any text with that paragraph style applied.

    I’ll elucidate in the next podcast/show notes. 😉

  4. Mike Perry says:

    Being able to apply multiple search results to one GREP styling will be very useful. In a typical document, I have terms like IBM, BC, and AD that need to be in small caps.Now all I have to to is list them with a little GREP code that’d exclude uses inside some other word. I have to see if GREP can manage properly something like IBM’s.

    [TC: You can use multiple GREP styles in a single paragraph if necessary].

    Nuther question, if I may.

    When does GREP-search-and-style-apply run? I can see the following times when it would need to run.

    1. When new text is entered, GREP style for a paragraph would need to be running, maybe in idle CPU time. Trigger: Text being entered.

    2. When the paragraph style is changed to a style with a GREP style. That could get interesting if one paragraph style is changed to another en masse. Trigger: Paragraph style change.

    3. When search & replace is used, either one at a time or globally. Trigger: Text being changed in a paragraph during S&R.

    4. When text is generated by InDesign as in a table of contents, index or cross reference. Trigger: Text generation by ID.

    Is it correct to assume that each of these events triggers a GREP style action? Somehow I can’t see this code being written to scan an entire document continually.

    [TC: Any time there is a composition change in a paragraph to which a GREP Style is applied, the text will be analyzed to see if there’s a matching text run…so, your comments above are correct.]