Skip to main content
Participant
February 7, 2024
Answered

GREP: Find paragraph after a specific paragraph style

  • February 7, 2024
  • 2 replies
  • 2957 views

Hey there,

 

today I’m looking for a solution in this case. I got a book with 500+ pages with hundreds
of headlines. This document contains just a paragraph style for the headlines and one for
following copytext of each chapter.

 

Now I want to apply a new paragraph style "subtitle text" to every first paragraph
after the headlines. The second one is normal copytext until the next headline.

 

I tried to:

  • Working with "next style" in the paragraph style option, but it is necessary to mark the paragraphs to utilize the function. This doesn’t work so smart, because I have to mark it for every occurrence.
  • Searching with GREP-styles (lookahead for example) combined with the paragraph
    "find-"selection

 

But nothing worked very well. Do you have an idea?

Correct answer FRIdNGE

Bad!

 

2 replies

FRIdNGE
Inspiring
February 7, 2024

Supposing 3 para styles:

 

"ps1" for headlines

"ps2" for sub-headlines

"ps3" for current-text.

 

and "ps1" and "ps3" alrready applied!

 

The question is:

 

How to apply "ps2" to each para following each para with "ps1" applied?

 

Simplistically with the Grep Find/Replace:

 

Find:  (?<!\r)^. + "ps3"

Replace by: "ps2"

 

(^/)  The Jedi

Participant
February 7, 2024

Thank you!

 

Hm, this doesn’t work in my case.

Do you have some documentaries of "how to include a specific paragraph style
in a grep expression" as you did? Looks interesting. Maybe I have to adjust something.

FRIdNGE
FRIdNGECorrect answer
Inspiring
February 7, 2024

Bad!

 

Peter Spier
Community Expert
Community Expert
February 7, 2024

I don't think you can do this with GREP, but next style is absolutley an option.

To use it, correct the style definitions to cycle as you wish, then you can select entire stories in one go (or the whole document if it's one long thread, and right click the headline style in the Paragraph Styles panel and choose Apply [headline stylename] and Next Style.