Changing the Color of Headings Based on Section

Our fiendish old friend can format a whole paragraph of text with a simple trigger

Some books have different-colored headings to indicate different sections. But if you have 5 sections, with 5 colors, do you need 5 different paragraph styles? There’s nothing wrong with that, but here’s another method you might consider.

What if you added a “1” at the beginning of each heading that needed to be in section 1, a “2” before the second section’s headings, and so on. For example:

Sectionhead1

Then what if those numbers could trigger InDesign to color the style differently? and make the number go away automatically so that it looked like this:

Sectionhead3

Cool? So what fiendish feature allows this kind of transformation? Why, grep styles of course! (Is there anything that our superhero friend can’t do?) :)

In this case, I made three character styles: one that set the text red, one that sets it green, and one — my favorite — makes the text disappear (defined as .1 pt tall, 1% horizontal scale, and a color of None). Then I applied it all with these grep styles:

grep styles to apply color

Nothing too fancy here. The first two styles look for the number 1 or 2 at the beginning of the paragraph (and apply the appropriate style to the entire paragraph; the last style looks for any number at the beginning of a paragraph.

Now, I know that there are plenty of complaints coming as to why this isn’t a good idea, including:

  • Never apply a character style to a whole paragraph: To which I reply, “feh? there is always an exception.”
  • You’ll see the numbers when you export to epub or html: To which I reply, “true, so you’ll need to find a way to strip them out for epub because epub can’t make that text disappear as easily”
  • I don’t want to have to type numbers in front of all the headings: To which I reply, “yeah, that’s a hassle.”

Ultimately, there are no perfect solutions to this workflow problem, but I hope this alternative may be helpful to some of you.

Bookmark
Please login to bookmark Close

This article was last modified on December 30, 2021

Comments (8)

Leave a Reply

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

Loading comments...