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

Char style to first word of paragraph

Contributor ,
Apr 30, 2025 Apr 30, 2025

Hi, Dear Friends!

I think this question has been addressed before, but I don't recall the final verdict.

Is there a way to have a certain PAR style cause the first word of that paragraph to have a certain character style? Or as a workaround to cause ID to format the first word of all, or some, paragraphs with a certain character style.

Thank you, and have a good day!
Susan Flamingo

TOPICS
Print , Type
1.3K
Translate
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
Contributor ,
Apr 30, 2025 Apr 30, 2025

I needed this really fast for a job toady, so I "cheated" and asked ChatGPT and here is the answer it gave:

To use a grep style within the paragraph style and use the syntax: ^\w+ and apply the character style.

Actually worked.

I wonder if this community will someday be connected to an AI LLM system for instant answers to posted questions. It could be done in a day of programming, I think. But thanks to all anyway!

Thank you, and have a good day!
Susan Flamingo

 

Translate
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 ,
Apr 30, 2025 Apr 30, 2025

Yeh that's the way to do it.

 

You can also use Nested Styles and apply it the first word. 

 

Using ChatGPT is not cheating, it's working smart. 

 

I'd hate the forums to be automated messaging, it's a user to user forum. 

 

Translate
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
People's Champ ,
Apr 30, 2025 Apr 30, 2025

And in fact I think that nested styles is the better option. Paragraph GREP styles that are heavily used in a document can cause slowdown...

 

Translate
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 ,
Apr 30, 2025 Apr 30, 2025

Right! GREP is a horrible idea for this and a nested style would take about a minute or two to create.

Translate
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 ,
Apr 30, 2025 Apr 30, 2025

My first instinct when people request GREP styles is to use Nested Styles. 

 

I don't know why everyone looks for GREP styles, I guess it's cool. But nested styles requires zero GREP knowledge and tends to work better.

 

Many a time I've suggested using Nested Styles, seems to be an overlooked and underused feature - not as 'cool' as GREP or something.

 

 

Translate
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
LEGEND ,
Apr 30, 2025 Apr 30, 2025

@SuzzyFlamingo

 

And ChatGPT gave you the wrong answer 😉

 

It's a tool - powerful tool - but it isn't smart. It's just a very advanced statistical model - it just guesses the right answer... 

 

Translate
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
Contributor ,
Apr 30, 2025 Apr 30, 2025

No. You are wrong.

It gave the exact answer that worked perfectly. (It could be scrapped from this forum, but it was correct!)

Translate
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 ,
Apr 30, 2025 Apr 30, 2025

Hi @SuzzyFlamingo , You may or may not notice the performance hit using a GREP Syle, but when you can use a Nested Style instead it is always preferable—ChatGPT must have forgotten about the performance issues.

 

Screen Shot 9.png

Translate
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 ,
Apr 30, 2025 Apr 30, 2025

@SuzzyFlamingo  You're absolutely right  ChatGPT did give a correct answer. Using a GREP style with ^\w+ to apply a character style to the first word of a paragraph is totally valid and works exactly as described. Just because there's another way to do it (like nested styles) doesn't make the GREP method wrong.

 

InDesign often gives us multiple tools to do the same thing, and which one you use can depend on your specific needs, deadlines, familiarity, document complexity and all that.

 

ChatGPT got it right for your use case, and it's good to see you got the result you needed fast. The solution worked. And that's the whole idea, isn't it?

 

For future reference and based on user experience, which ChatGPT doesn't have, Nested Styles are usually better for this kind of task, especially performance-wise. But there's nothing wrong with doing it either way. Your solution worked, and that’s what matters.

Translate
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
LEGEND ,
Apr 30, 2025 Apr 30, 2025
quote

No. You are wrong.

It gave the exact answer that worked perfectly. (It could be scrapped from this forum, but it was correct!)


By @SuzzyFlamingo

 

Yes, technically - as one of possible solutions - it's correct - but it should've suggested Nested Styles instead. 

 

Translate
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 ,
Apr 30, 2025 Apr 30, 2025

I've got a question for those who believe that nested styles do better and perform better than GREP styles:

what engine do you think is under the hood of nested styles?

GREP or magic?

 


Acrobate du PDF, InDesigner et Photoshopographe
Translate
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
LEGEND ,
Apr 30, 2025 Apr 30, 2025

@JR Boulay

 

😄 Nested are much simpler in implementation and were first - so most likely two different "technologies".

 

You don't have dynamic comparison - just character/glyph or word.

 

Translate
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 ,
Apr 30, 2025 Apr 30, 2025

That's a great question

Nested Styles are built into InDesign’s text formatting engine as a simpler, rule-based system. They’re not powered by the full GREP engine. Instead, they use positional and word-based logic, things like "up to 1 word", "through 1 sentence", "up to a specific character", not regex parsing.

 

GREP Styles, on the other hand, use InDesign’s implementation of the Perl-Compatible Regular Expressions (PCRE) engine. It's heavier, more flexible, but also more processing-intensive, especially in documents with lots of live GREP rules.

 

So while both affect how styles are applied dynamically at render time, Nested Styles are a lightweight, custom-built rule set, and GREP Styles are regex-driven, which can mean a performance hit in complex documents.

 

 

Translate
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
People's Champ ,
May 01, 2025 May 01, 2025

Nested styles use the old "Seattle" magic...

Translate
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 ,
May 03, 2025 May 03, 2025

Nested Styles predate GREP by several versions, so whatever algorithm Adobe uses to implement Nested Styles, it’s much simpler than GREP.

Translate
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 ,
May 03, 2025 May 03, 2025

Back in Version 3 aka CS, Adobe published a copy of the generated documentation, a newer version of that still comes with the plug-in SDK downloads.

 

InDesign has indeed dedicated functions (in the compose scanner) to deal with words, considering the language and custom criteria what characters belong into a word. My first thought, but wrong here.

 

You're right that expressions are used, just not regular expressions.

The mechanism for nested styles and drop caps internally is called RunInStyle.

When we look at the attribute storing the "through 1 Word" nested style, the trigger expression is "(^w)1"

The expression for "through 1 Sentence" is "(^S)" and "up to 2 End Nested Style" is "[^p]2"

So, "through" is round brackets, "up to" is square brackets, followed by the count without curly brackets.

Very different from regular expressions.

 

This is an expression engine at work, but a much simpler one - therefor faster.

As @TᴀW calls it - Seattle magic.

Translate
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 ,
May 01, 2025 May 01, 2025

You're quibbling, whatever the implementation method, it's always regular expressions under the hood.


Acrobate du PDF, InDesigner et Photoshopographe
Translate
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 ,
May 01, 2025 May 01, 2025

Interesting take on it - can you share where you found this information? 

I am pretty sure that it's not using the same engine as GREP - but would love to know more about it and if you have any information or resources to share it'd be great to read up on. 

 

I thought I explained it wasn't quite well, but you have piqued my interest to learn more.

Translate
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 ,
May 02, 2025 May 02, 2025

Please, be lenient since English is not my native language.

I didn't mean to imply that they were the same engine, I just meant that no matter how you implement them, it's always regular expressions that are under the hood.


Acrobate du PDF, InDesigner et Photoshopographe
Translate
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
LEGEND ,
May 02, 2025 May 02, 2025
quote

Please, be lenient since English is not my native language.

I didn't mean to imply that they were the same engine, I just meant that no matter how you implement them, it's always regular expressions that are under the hood.


By @JR Boulay

 

Why do you think that? 

 

If that would be true - then GREP Styles would be from the start - and probably instead of Nested. 

 

Translate
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 ,
May 03, 2025 May 03, 2025

Of course, no problem, just curious to your claims and wanted to know more. 

I think they might use expressions but different engines as @Dirk Becker points out expertly. 

Nested styles are a simpler implementation and works quicker. 

GREP is a different engine and more complex. 

 

But both use expressions but different engines.

Translate
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 ,
May 03, 2025 May 03, 2025
LATEST

That's exactly what I meant. 🙂


Acrobate du PDF, InDesigner et Photoshopographe
Translate
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