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

GREP for underlining text in a Table of Contents

Community Beginner ,
Jul 02, 2024 Jul 02, 2024

How can I crate a GREP that will underline a part of an entry in a table of contents?

I know how to bold certain words using a GREP but cannot figure out how to underline certai words!!

Any ideas???

TOPICS
How to , Scripting
2.4K
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

correct answers 1 Correct answer

Community Expert , Jul 02, 2024 Jul 02, 2024

It looks as if you are attempting to apply HTML-like formatting markup instead of applying an InDesign Character Style. That might work, in certain circumstances, but it's not the right approach.

 

  • Create an "underline" style that works when you apply it directly.
  • Create a GREP string that finds the word or string you want to underline.
  • Set the GREP style to apply the "underline" style.

 

Don't try to do anything else in the process. It should not be necessary.

 

And, since this is unclear: us

...
Translate
Community Expert ,
Jul 02, 2024 Jul 02, 2024

It should be an identical process except that the applied Character Style adds an underline, which can be defined in the style for optimum appearance.

 

Create and optimize the "underline" style first. Then use GREP to apply it according to your rules.

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 Beginner ,
Jul 02, 2024 Jul 02, 2024

I have done that but do not know what character to use to determine the underline.
For the bold I have: Apply Style: Bold    To Text: <b>.+?</b>

I tried to do the same for underlining...  Apply Style: Underlined    To Text:  <ul>.+?</ul>
But it does not work...   the <ul> and </ul> show up in the text of the table of contents.

 

 

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 ,
Jul 02, 2024 Jul 02, 2024

@pcfiles

 

Exactly the same as when you set bold - just a different setting in the CharStyle definition.

 

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 Beginner ,
Jul 02, 2024 Jul 02, 2024

I have a character style setting for "underlined" but it does not work when using the GREP.

 

I need to know what character has to be in...  <XXX>.+?</XXX>    in place of the XXX to make it work.
I use character style constantly in my projects but getting the underline to work in a table of contents is not working.
As soon as I update the TOC the underline goes away if I manually underline the text!!

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 ,
Jul 02, 2024 Jul 02, 2024

@pcfiles

 

I don't see where you ESCape "/" - so your <b>...</b> shouldn't work either: 

 

https://creativepro.com/using-grep-styles-to-format-html-code-in-indesign/ 

 

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 ,
Jul 02, 2024 Jul 02, 2024

It looks as if you are attempting to apply HTML-like formatting markup instead of applying an InDesign Character Style. That might work, in certain circumstances, but it's not the right approach.

 

  • Create an "underline" style that works when you apply it directly.
  • Create a GREP string that finds the word or string you want to underline.
  • Set the GREP style to apply the "underline" style.

 

Don't try to do anything else in the process. It should not be necessary.

 

And, since this is unclear: use a Paragraph Style-based GREP Style, to apply the underline automatically, and not a manual GREP search and replace.

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 Beginner ,
Jul 02, 2024 Jul 02, 2024

You don't seem to understand what I am asking...

 

If I use "2.^tSurvivors of Active Participants (ineligible for retirement) with <b>fewer than five years</b> of continuous participation
The...  "fewer than five years"  will be bold!
I  need to know what character to use in place of the "b" to signify underlining with the underlined character style... 

 

 I have CHARACTER STYLES created that are used throughout the document...   Hidden; Bold; Bold Italic; Bold Italic Underlined; Italic; Underlined; Bold Underlined; Italic Underlined.    I use these on a daily basis!!!   

My GREPs is a PARAGRAPH STYLE...   with the bold that works, but the underlined does not.    
Can someone tell me what letter/character I should be using to get an underline GREP to work??

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 ,
Jul 02, 2024 Jul 02, 2024

@pcfiles

 

This forum doesn't indicate to which post you are replying - so could you please, next time, include poster's name? 

 

Or better yet - use "@" in front of the name - then this poster will receive notification. 

 

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 ,
Jul 02, 2024 Jul 02, 2024

From his examples, he is using GREP to insert HTML-like formatting codes into the text, a wholly off-track approach having nothing to do with proper use of GREP styles.

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 ,
Jul 02, 2024 Jul 02, 2024

You need to reread my prior answer.

 

You don't apply direct formatting codes using GREP, as if it's HTML/CSS content.

 

You tell InDesign to apply a defined Character Style to text selected by the GREP string.

 

That is, you don't need, want or use any "code" for underlining in your applied string. You search using the string; you apply a defined Character Style using the GREP Style feature.

 

Put even more simply, your bolding method is doing it wrong; there is no "right" way to use it to apply underlining.

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 Beginner ,
Jul 02, 2024 Jul 02, 2024

Nobody seems to understand how to crate a GREP that will underline text in a table of contents.

Thanks anyways.

 

 

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 ,
Jul 02, 2024 Jul 02, 2024
quote

Nobody seems to understand how to crate a GREP that will underline text in a table of contents.

Thanks anyways.


By @pcfiles

 

Can you post some screenshots - of your text, with hidden characters visible - and GREP settings. 

 

And sample INDD also would be great - to eliminate "hidden" problems. 

 

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 ,
Jul 02, 2024 Jul 02, 2024

Nobody seems to understand how to crate a GREP that will underline text in a table of contents.

 

You mean like this, which took me about thirty seconds following the instructions given above? (Including the time to find and open a suitable test file?)

 

JamesGiffordNitroPress_0-1719943086505.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 Beginner ,
Jul 02, 2024 Jul 02, 2024

If it took 30 seconds then show me the GREP settings!

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 ,
Jul 02, 2024 Jul 02, 2024

JamesGiffordNitroPress_0-1719948874515.png

 

I've used a simple 'hard' GREP string here; substitute any that selects your desired text. A fancier one to select, say, any four-letter word in uppercase (such as several I am thinking of at the moment) would be \u\u\u\u .

 

"Unnaline" is my simple underline Character Style—

JamesGiffordNitroPress_1-1719949430885.png

 

You could make this a manual operation by using the same elements in a GREP Find/Change, but that's pretty pointless given that ID will do it for you, automatically and on the fly, with this method. But if you insist:

JamesGiffordNitroPress_0-1719949306925.png

 

This is not complex if you let go of the idea that you somehow have to apply inline formatting codes to the text using a GREP result. You don't. That's just not how it works.

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 ,
Jul 02, 2024 Jul 02, 2024
quote

Nobody seems to understand how to crate a GREP that will underline text in a table of contents.

Thanks anyways.

 

 

By @pcfiles

 

Actually, most of the answers given were clearly understandable.

 

But to bring the topic to a successful conclusion:

Just tell us which word or words you would like to have underlined.

 

Or, as requested by the others:
Show us a screenshot of your TOC, the words to be underlined should be recognisable. Or upload a simplified example file (without confidential data) to a hoster of your choice and link it here.

 

The more precise your details are, the more likely it is that we will find a suitable solution.

By the way: Everyone who has replied to you so far is very good at using 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
LEGEND ,
Jul 02, 2024 Jul 02, 2024

@pixxxelschubser

 

OP needs to underline text between <ul>...</ul>.

 

Same as with bold that is supposedly working for him - which shouldn't work either as there is no "\" before the "/".

 

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 ,
Jul 02, 2024 Jul 02, 2024

I know.

 

And I suspect that he is trying to apply this technique https://creativepro.com/using-grep-styles-to-format-html-code-in-indesign/. But that won't get him anywhere. So without real examples, it's just poking around in the dark ...

 

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 ,
Jul 02, 2024 Jul 02, 2024

@pixxxelschubser

 

The same link I've posted earlier today 😉 

 

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 ,
Jul 02, 2024 Jul 02, 2024

Haha.
I completely overlooked that.

😄

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 ,
Jul 02, 2024 Jul 02, 2024
quote

Haha.
I completely overlooked that.

😄


By @pixxxelschubser

 

No problem. 

 

If that link doesn't help OP - then there is something wrong with the text - and screenshots would really help. 

 

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 ,
Jul 02, 2024 Jul 02, 2024
quote

 

If that link doesn't help OP - then there is something wrong with the text - …

 


By @Robert at ID-Tasker

 

I don't think so.

It is more likely that he is not using the correct paragraph style in his table of contents. But you can really only see that in a real example file with paragraph styles and TOC definitions.

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 ,
Jul 02, 2024 Jul 02, 2024

There is clearly confusion between GREP practices and HTML markup, but I can't sort out the end goal here, especially with respect to a TOC.

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 ,
Jul 02, 2024 Jul 02, 2024

@pcfiles

 

I think we all have drifted too far from the obvious thing - TOC will retain CharStyles applied in the text...

 

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