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

GREP phrase not taking effect when added as an update to a paragraph style

Engaged ,
Nov 30, 2022 Nov 30, 2022

Copy link to clipboard

Copied

I have searched and found probably four or five different GREP expressions that are supposed to prevent single-letter words from landing at the end of a line of text in mid-paragraph (also found some for end of paragraph, but that isn't my goal at the moment).

 

I've edited my paragraph style to test each expression I've found and, so far, the page I hoped would adjust doesn't even flicker. I still have three "I"s hanging out at the ends of lines in the middle of the paragraph, and that's just one page of the book I'm working on. Now I'm wondering if a GREP expression perhaps does not work if it isn't implemented from the beginning of a project.  If this is NOT the case, how do I get my GREP expression to work?

 

And also, and does anyone know an expression for this situation that actually DOES work? With so many out there online -- and none of them similar to one another -- I'm pretty confused about which expression I SHOULD try as none seem to work right now. All of them say to apply the No Break character style, and I have, but nothing ever changes. Is there something else I should be doing to make a GREP work?

 

Hope this makes sense. Any help is appreciated -- especially quick responses, since I'm in the middle of this mess right now -- and thanks in advance!

TOPICS
Type

Views

972

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 ,
Nov 30, 2022 Nov 30, 2022

Copy link to clipboard

Copied

GREP tricks can be applied to paragraph styles early or late in the layout process. That should not be a factor.

 

The one I usually do is a passive GREP style in my BodyCopy paragraph style:

Apply Style: NoBreak

.{24}$

 

My last paragraph lines have to be at least 24 characters long, thus discouraging short runt lines.

Mike Witherell

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
Engaged ,
Nov 30, 2022 Nov 30, 2022

Copy link to clipboard

Copied

Thanks, Mike. Good to know that the GREP should work no matter when incorporated into the paragraph style. I thought it odd that it wasn't taking effect, so it must be the GREP expressions I've found that aren't working for some reason.

 

I'll try your expression, but if I'm reading correctly, it sounds like it is mainly to make sure there are no runts at the end of paragraphs. That is also something I need, so thank you. But right now I'm primarily needing a GREP expression that will prevent words like "I" and "a" from landing -- and staying -- at the end of any line in a paragraph; I would like to push them to the next line in the para. Do you have any ideas about that?

 

I really need to learn more about GREP! <sigh>

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 ,
Nov 30, 2022 Nov 30, 2022

Copy link to clipboard

Copied

You say these expressions are meant to prevent single character words at the end of a line mid-paragraph. That's a really tough task given that line ends are in constant flux, and I'm actually not sure it can be accomplished with GREP.

Can you share the expressions you think are supposed to do that?

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
Engaged ,
Nov 30, 2022 Nov 30, 2022

Copy link to clipboard

Copied

Most of the solutions I've found are part of a Q&A in support or elseewhere on the net, so rather than type out all of that, I'll give you a few links to look at where I found expressions I tried:

 

https://creativepro.com/topic/grep-moving-one-letter-words-to-next-line/ -- this one, the questioner seemed happy with but it made not an iota of difference when I applied it to my paragraph style.

 

https://graphicdesign.stackexchange.com/questions/84523/indesign-grep-style-to-move-single-i-words-t... -- another expression given in this answer

 

https://community.adobe.com/t5/indesign-discussions/avoid-a-single-letter-at-the-end-of-a-line/m-p/1... -- There are a couple expressions offered in these answers.

 

I've tried them all so far and have seen no difference, though some of the questioners seem to have had success when they tried what the answers offered.  I personally don't know enough about GREP to "read" the expressions to compare their purposes, but it seems odd to me that so many different expressions would supposedly work for this one need or function.

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 ,
Dec 01, 2022 Dec 01, 2022

Copy link to clipboard

Copied

OK, in the first link I think the problem is the forum software has messed up the code that Jongware wrote (and I can promise you the correct version would have worked -- Jongware is a legend). Unfortunatley I'm not sure quite what the "real expression looked like.

In the seond link, (?<=\s)i\W+ is looking for the letter i with a space before, and any "non-word" characters following. You could change that to (?<=\s)[\u\l]\W+ to find any single letter followed by a non-word character rather than restricting it to the letter i. This would find not only single letters folloed by a space, but also by numbers or punctuation, including at the end of a paragraph, but I don't see this as a serious problem.

I think any of the expressions listed in the third link also should work, so if none of these are working for you I suspect that the miossing part is the creation of the "no-break" character style and applying it as part of the paragraph style.

I see that in the third link I mentioned that this method (globally applying No Break to single letters and the next character to prevent a line break) is likely to put some drag on the performance, and James Gifford offered a possible solution for using Find/Change to replace an ordinary space with a non-breaking space after a single letter. While not automatic, I think this is actually a better way to go.

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
Engaged ,
Dec 01, 2022 Dec 01, 2022

Copy link to clipboard

Copied

Peter, thanks SO much for taking the time to go through these links I sent you and giving me such great feedback. I'm going to try the one you provided as a rewrite to the second link -- it makes sense to be able to find more than just an "I" when running the GREP -- and also I like the idea of the non-breaking space after a single letter, mentioned in the third link.

 

I'm certain I have had the No Break style applied each time, but I'll make sure I do as I try all this again.  If nothing works for me from here on out, maybe I'll discover some other reason ... or maybe I'll be back asking you for more help! 🙂  -- thanks again, and happy holidays!

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 ,
Dec 01, 2022 Dec 01, 2022

Copy link to clipboard

Copied

You're welcome. And not that the first grep found only lower case i, not the upper case I you were concerned about, so that could also have been part of your problem.

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
Engaged ,
Dec 01, 2022 Dec 01, 2022

Copy link to clipboard

Copied

Totally makes sense. It might be all in the way I typed it! GREP being case sensitive didn't cross my mind, but it definitely should have. 🙂

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
Engaged ,
Dec 01, 2022 Dec 01, 2022

Copy link to clipboard

Copied

Oops, one more question for clarity re the Find/Change to replace an ordinary space with a non-breaking space after a single letter -- I presume this means to run separate find/change processes for "a," "i," etc. separately -- i.e., not with any kind of GREP or batch search/replace, etc.  I just wanted to be sure I'm not missing some fine point here. Not to sound like a newbie, as I'm not, but thought I'd better ask in case there is some fancy-dancy thing I ought to know about beyound regular/singular find/replace.  As many years as I've been using InD, I totally know there is always more to learn!

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 ,
Dec 01, 2022 Dec 01, 2022

Copy link to clipboard

Copied

For the find/Change method, one expression that will find ordinary spaces after a single character is

(?<=\b\w)\x{20}

\x{20} is the hexadecimal code representaion in GREP for the ordinary space. You can just hit the sapcebar, but it's hard to tell you've done it. 

(?<=\b\w) is a Positive Lookbehind match that requires the space to be preceded by a word boundary (\b) and a single word character (\w, which is any letter, number, or underline character), in other words a single character word, in order to match the space, so it won't match other spaces in your text.

Change to ~S which is the non-breaking space.

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
Engaged ,
Dec 01, 2022 Dec 01, 2022

Copy link to clipboard

Copied

Peter, thanks so much. This is very helpful. I look forward to trying this on my manuscript and will strive to do it correctly. You and others here have been very generous to me these last couple of days. I really appreciate it. -- C.

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 ,
Dec 01, 2022 Dec 01, 2022

Copy link to clipboard

Copied

I agree with Peter S. that doing this with a GREP style could cause some serious lags. I would use this expression:

\b[\u\l]\h.

that is, a word boundary followed by an upper- or lower-case letter followed by a space (which is not a return) and any character.

 

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
Engaged ,
Dec 01, 2022 Dec 01, 2022

Copy link to clipboard

Copied

Thank you, Peter. I will give this expression a try for sure. Looks like I'm going to be doing a lot of experimenting today!

Happy holidays to you. 🙂

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 ,
Dec 01, 2022 Dec 01, 2022

Copy link to clipboard

Copied

Peter, what does \h mean and do in the above expression?

Mike Witherell

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 ,
Dec 01, 2022 Dec 01, 2022

Copy link to clipboard

Copied

\h is 'horizontal space'. It's basically \s minus \n and \r, so to speak. It's a good one because it includes all the spaces (normal, en, em, fixed, sixth, etc.) but excludes the line breaks. 

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
Engaged ,
Dec 01, 2022 Dec 01, 2022

Copy link to clipboard

Copied

I tried this expression (still need to try all others suggested) and it flipping worked!  Thanks!  First one under my belt, and now on to experiment with a few others.

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 ,
Dec 01, 2022 Dec 01, 2022

Copy link to clipboard

Copied

In order to be able to create the grep, you definitely have to know at which positions the individual letters are to be searched for. And no. There are wildcard searches in Grep. For example, [\l\u] finds every upper and/or lower case letter.

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
Engaged ,
Dec 01, 2022 Dec 01, 2022

Copy link to clipboard

Copied

I definitely need to study GREP more thoroughly! I don't use it often but when I need it, it sure would be good to have a better familiarity than I do. Thanks for your help. 🙂

 

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 ,
Dec 01, 2022 Dec 01, 2022

Copy link to clipboard

Copied

Get yourself a copy of Peter Kahrel's fabulous tutorial PDF: https://creativepro.com/now-available-grep-in-indesign-3rd-edition/

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
Engaged ,
Dec 01, 2022 Dec 01, 2022

Copy link to clipboard

Copied

LATEST

Thanks for the suggesstion!  I will!

 

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