• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

Apply character style based on Chapter Number. GREP maybe?

Community Beginner ,
Aug 24, 2024 Aug 24, 2024

Copy link to clipboard

Copied

I have a long document with chapters. Each chapter has different color elements. One of those is the headings in the chapter are that color. Rather than creating a style for ever single chapter, I was wondering if there was a way to have the base paragraph style and then character styles to change the color. Is there some way to automate applying the character styles based on chapter? 

 

Something like  if chapter is 1 apply chapter 1 heading style, if 2 then apply chapter 2 heading style. 

 

Maybe GREP or a script but i'm no good at writing either of those. Any suggestions?

TOPICS
How to , Scripting

Views

1.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 24, 2024 Aug 24, 2024

Copy link to clipboard

Copied

I recommend to make for each chapter an independent INDD document and asamble all in an INDB book dokument. All styles can be the same. But use in each chapter a different defined chapter color.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 24, 2024 Aug 24, 2024

Copy link to clipboard

Copied

This is a good, simple approach — define one key color and change it for each chapter. The overall need is one of those "one and done" tasks that doesn't really need a script or GREP or automation unless the need (as for newsletters or reports is continual and ongoing. Just create a new chapter file, set the key color, and move on to the important stuff. 🙂

 

The one catch is that you will need to be very careful synchronizing the Book — be sure to omit colors from the sync list!


┋┊ InDesign to Kindle (& EPUB): A Professional Guide, v3.1 ┊ (Amazon) ┊┋

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 24, 2024 Aug 24, 2024

Copy link to clipboard

Copied

Good idea but the chapters aren't long enough to justify creating a Book document (IMHO). Each chapter is only like 3 or 4 pages. So I guess I'll continue with my initial process. Heading paragraph style and a heading character style to change the color for each chapter and then just apply the character style manually in each chapter. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 24, 2024 Aug 24, 2024

Copy link to clipboard

Copied

No matter how I work this through, that's multiplying X entities per chapter by X chapter (colors), which might get a little unwieldy. While a Book is at its best with larger collections 10 chapters or more), there's no reason not to use it for more compact projects like this, where the colors can be easily assigned by base styles in each chapter. I'm among the first to say "don't use a Book unless you have to" and "fer gossakes, don't use a Book because you think it's necessary or it's all techy or something" — but in this case, I'd say a Book is your most streamlined, manageable option.

 

Being able to change every color-key item in each chapter simply by redefining one color swatch, and not having a whole hierarchy of duplicate styles... hard to beat.


┋┊ InDesign to Kindle (& EPUB): A Professional Guide, v3.1 ┊ (Amazon) ┊┋

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 24, 2024 Aug 24, 2024

Copy link to clipboard

Copied

In InDesign's terminology an INDD file is a chapter. 
Woring with a book file is no additional work, but it is efficient. You should give it a try. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 24, 2024 Aug 24, 2024

Copy link to clipboard

Copied

If you can live with just the words "Chapter" and the number, you can use the following:

image.png

Unfortunately, you can't use a numbered list. I couldn't get the "To Text:" code to include the rest of the paragraph, but perhaps someone more skilled at GREP can make it work.

 

David Creamer: Community Expert (ACI and ACE 1995-2023)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 24, 2024 Aug 24, 2024

Copy link to clipboard

Copied

If the styles have the same name, that would cause a probelm with syncing.

 

David Creamer: Community Expert (ACI and ACE 1995-2023)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 24, 2024 Aug 24, 2024

Copy link to clipboard

Copied

I don't think so.  If each chapter has a swatch named KEY, and colors are excluded from sync, each would retain its value, and all keyed elements including styles would retain the swatch name. I'd test, but pretty sure this would work.


┋┊ InDesign to Kindle (& EPUB): A Professional Guide, v3.1 ┊ (Amazon) ┊┋

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 24, 2024 Aug 24, 2024

Copy link to clipboard

Copied

Yes, that would work of course, but any new colors would cause a sync issue. 

 

David Creamer: Community Expert (ACI and ACE 1995-2023)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 24, 2024 Aug 24, 2024

Copy link to clipboard

Copied

Hi @Tommy30053592w60v:

 

If you are comfortable using books, they really would work well for this workflow. 

 

Back to your original question, you can assign the character style based on the chapter number, but if you have a lot of chapters, this will dramatically slow down InDesign, because GREP styles are assign in realtime, as you edit.

 

This shows 3 GREP styles at play, and it's zippy. If you have 30 chapters or 300 chapters, it would not be a good way to go. 

 

2024-08-24_10-59-16 (1).gif

 

Don't give up on scripting. We have a few talented folks here who just haven't seen this question yet. 

 

~Barb

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 24, 2024 Aug 24, 2024

Copy link to clipboard

Copied

Sorry, Barb. I was testing a sample file and didn't see your post until I refreshed! Great minds...

 

David Creamer: Community Expert (ACI and ACE 1995-2023)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 24, 2024 Aug 24, 2024

Copy link to clipboard

Copied

I like being included on your list of great minds! 😊

 

~Barb

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 24, 2024 Aug 24, 2024

Copy link to clipboard

Copied

@Tommy30053592w60v

 

Script would be the simplest solution.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 24, 2024 Aug 24, 2024

Copy link to clipboard

Copied

I think the simplest solution would be to create a parent style and make a series of child styles. 

David Creamer: Community Expert (ACI and ACE 1995-2023)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 24, 2024 Aug 24, 2024

Copy link to clipboard

Copied

quote

I think the simplest solution would be to create a parent style and make a series of child styles. 


By @Dave Creamer of IDEAS

 

Yes, but that's a lot of manual work. 

 

Script could go through all Char/ParaStyles used in each Story / Section - and create copies and base them on an extra "master" style for each Story / Section - unless there is a proper BasedOn structure already - which would require only one "master" style. 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 24, 2024 Aug 24, 2024

Copy link to clipboard

Copied

>>Yes, but that's a lot of manual work. 

 

After the parent style, one could whip out a dozen styles in about a minute or two. 

David Creamer: Community Expert (ACI and ACE 1995-2023)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 24, 2024 Aug 24, 2024

Copy link to clipboard

Copied

quote

>>Yes, but that's a lot of manual work. 

 

After the parent style, one could whip out a dozen styles in about a minute or two. 


By @Dave Creamer of IDEAS

 

Is there a shortcut to duplicate style and change BasedOn at the same time - to a specific parent? 

 

For example, 20 styles * 20 chapters = 400 new styles - that you need to edit manually - name AND BasedOn.

 

Not to mention - that you need to re-apply those new styles for each Story in the Chapter... and if you have multiple Stories per Chapter... 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 24, 2024 Aug 24, 2024

Copy link to clipboard

Copied

Did I miss something? Why 20 styles per "chapter"? I was thinking of just the title, so one parent style and, using your example, 19 child styles. 

David Creamer: Community Expert (ACI and ACE 1995-2023)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 24, 2024 Aug 24, 2024

Copy link to clipboard

Copied

quote

Did I miss something? Why 20 styles per "chapter"? I was thinking of just the title, so one parent style and, using your example, 19 child styles. 


By @Dave Creamer of IDEAS

 

Maybe I'm wrong, but I think there is a whole "color structure/scheme" - so multiple colors and multiple styles? 

 

20/20 was just an example. 

 

From the OP:

 

Each chapter has different color elements. One of those is the headings in the chapter are that color.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 24, 2024 Aug 24, 2024

Copy link to clipboard

Copied

I perhaps misread the OP. If the, er, OP only wants the chapter titles to change color, a simple cascade of styles would be the efficient choice; I'd just stick them in a folder to keep them from cluttering the styles list.

 

I read/assumed that the key color would apply to all chapter headings, subheadings, highlight elements, etc. — which is common, but apparently not the case here.


┋┊ InDesign to Kindle (& EPUB): A Professional Guide, v3.1 ┊ (Amazon) ┊┋

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 24, 2024 Aug 24, 2024

Copy link to clipboard

Copied

@James Gifford—NitroPress

 

No, we don't know how many styles and colors are involved... 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 24, 2024 Aug 24, 2024

Copy link to clipboard

Copied

This would be good if the only keyed item was the chapter name, but my reading is that all the headings change as well, and it would probably be nice to change elements like a separator bullet, paragraph rules, etc. A cascade of styles for each of those would get... overwhelming.

 

Any method that shifts things based on one color swatch would seem to be easier to manage.


┋┊ InDesign to Kindle (& EPUB): A Professional Guide, v3.1 ┊ (Amazon) ┊┋

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 24, 2024 Aug 24, 2024

Copy link to clipboard

Copied

quote

[...] A cascade of styles for each of those would get... overwhelming. [...] 

 

By @James Gifford—NitroPress

 

That's why script would be much more effective. 

 

Copies of the styles for each Chapter could be moved to a separate groups. 

 

And script wouldn't even have to be very complicated. 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 24, 2024 Aug 24, 2024

Copy link to clipboard

Copied

In lieu of a script, I would go with @James Gifford—NitroPress idea of a "key" color linked to all the heading styles. Then change the heading parent once per chapter. However, this would require a book file be used. 

 

I know the OP was concerned that the chapters only have 3-4 pages, but I've had single-page "chapters" in a book at times.

David Creamer: Community Expert (ACI and ACE 1995-2023)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines