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

GREP first character of a chapter (after End Paragraph)

Community Beginner ,
Aug 30, 2018 Aug 30, 2018

Copy link to clipboard

Copied

Good afternoon,

I would like to auto-format the first character of the first paragraph of each chapter in order to apply a Drop Cap of 2-3 Lines height and a different font (or charachter style).

-There are many short chapters in my text (and each chapter, as obvious, it is build from many paragraphs).

-The text of all paragraphs (except the heading/title of every chapter) has the same style.

-Between the heading and the first paragraph there is at least one ^p, sometimes two.

screenshot.jpg

I've been trying to found a proper way of autoformating it all day . I've played with the Drop Caps and Nested Styles but my nearest result is formating the first charachter of every paragraph as shown in the image below.

nested style.jpg

I guess paragraph GREP Styles might be the way. They work well if I apply them to the first character or every uppercase after a tab but they don't work at all when applying them to find the first charachter after the space in the beggining of each chapter (end of a paragraph).  ^p = \r in GREP, isn't it? Why is it not working at all?

I'm looking forward to your answers. How would you autoformat it?

Many thanks for your necessary help!

TOPICS
Scripting

Views

1.5K

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 30, 2018 Aug 30, 2018

Copy link to clipboard

Copied

Hi Elizabet:

You will need to create a new paragraph style for the first paragraph of each chapter. Then add the drop cap to that paragraph, and used a nested character style to format it the way you want it to look. Once it is working on the first paragraph, you can manually assign it to the other first paragraphs in each chapter.

You are asking in the InDesign scripting forum—is that because you don't want to manually assign the paragraph tag to the first paragraph of each chapter? It won't take that long. I can't tell if you are stuck on how to assign the drop cap to just the desired paragraphs, or if you need this to be automated.

~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 Beginner ,
Aug 30, 2018 Aug 30, 2018

Copy link to clipboard

Copied

Hi, BarbBinder,

I'm posting here because I would really like it to be automated.

Thank you for your answer anyways!

Regards,

Elisabet

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
Guide ,
Aug 30, 2018 Aug 30, 2018

Copy link to clipboard

Copied

Hi,

Surely not automatic but 1 simple regex could be enough (no need to use another para style or a script)!

So, just 1 click!

Best,

Michel, for FRIdNGE

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 ,
Sep 01, 2018 Sep 01, 2018

Copy link to clipboard

Copied

Hi Michel [FRIdNGE],

Since I'm new in the regex use, it would be really helpful if you can provide the expression. Thanks !

Sincerely,

Elisabet

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
Guide ,
Sep 01, 2018 Sep 01, 2018

Copy link to clipboard

Copied

LATEST

Hi,

Your question could be summarized as:

Find any not-empty paragraph preceded by an empty paragraph!

In Grep, as previously indicated, this is simply written:

^\r\K.

^\r for any empty paragraph

. for any character (excluding jumps! this avoids to catch any empty paragraph preceded by an empty paragraph)

\K syntax [CS6 +] for lookbehind = "preceded by ..."

Capture d’écran 2018-08-30 à 21.02.35.png

I'd linked this thread yesterday [for fun] and posted this screenshot on "The Treasures of Grep" Facebook group of our friend Jean-Claude Tremblay, imho the finest place to find answers to Grep issues!

https://www.facebook.com/groups/TreasuresofGrep/

Best,

Michel

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 31, 2018 Aug 31, 2018

Copy link to clipboard

Copied

Hi Elizabeth...

Try finding this: ^\r{1,}\K^\u
With your drop caps attributs in the change to field.
Screen Shot 2018-08-31 at 3.49.01 PM.png

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 ,
Sep 01, 2018 Sep 01, 2018

Copy link to clipboard

Copied

Hi Jean-Claude

I've just tried what you suggest on my file but when I try "Find" it shows the message "Cannot find match". What can I do?

I think the idea is great, it's exactly what I was looking for!

Thank you very much,

Elisabet

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
Mentor ,
Sep 01, 2018 Sep 01, 2018

Copy link to clipboard

Copied

elisabetd51242557  wrote

[...] it shows the message "Cannot find match". What can I do?

Elisabeth, Jean-Claude’s regex works just fine, and does what intended.

2 things first:

1. Ensure you’re working in a GREP tab of Find/Change panel.

2. Double check if you copied the code right. Don’t rewrite it looking at the browser window, just copy/paste directly to Find What field.

Another thing, I would create a separate para style with drop cap, to put in Change Format field, instead of entering format settings directly. Just for better future management.

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