Skip to main content
Inspiring
April 12, 2022
Answered

No Break with minimum-word limits

  • April 12, 2022
  • 4 replies
  • 954 views

I have this working, but wanted to make sure I did not overlook something.

My book looks best with a character style "No break" applied as a grep style within my paragraph style.  Because the book is in Spanish, there are some very short words I wanted to account for.  I chose 5 words as the quantifying value.

Here is my GREP.  Let me know if I have left out anything.

 

\w{5}

This topic has been closed for replies.
Correct answer Peter Kahrel

So you did mean word,not word character. Your \w{5} means 'keep 5 word characters together'. To keep 5 words together  at the end of the paragraph (which is excessive by any standard), you need this:

 

(\h[^\s]+){4}$

 

 

4 replies

Peter Kahrel
Community Expert
Peter KahrelCommunity ExpertCorrect answer
Community Expert
April 13, 2022

So you did mean word,not word character. Your \w{5} means 'keep 5 word characters together'. To keep 5 words together  at the end of the paragraph (which is excessive by any standard), you need this:

 

(\h[^\s]+){4}$

 

 

MadMac55Author
Inspiring
April 13, 2022

After testing, I believe the \h was hanging this up.  I was wrong; it was an extra space between words that caused the problem.  Works great.  Thank you again.

Peter Kahrel
Community Expert
Community Expert
April 13, 2022

@MadMac55 

 

> I chose 5 words as the quantifying value.

 

You mean 5 word characters (letters and digits), right?

MadMac55Author
Inspiring
April 13, 2022

Mr Kahrel!   No I meant words.  Because the book is Spanish, there are very short words that could encourage very short lines (this sounds picky, but...).  So, to minimize the presentation of the short lines, I used an arbitrary number of words (5) to have the No Break control the presentation.  If that makes sense.

 

As I poured my first coffee, I did have a thought along this line that I did not take into account digits and should have included /w|/d

rob day
Community Expert
Community Expert
April 13, 2022

Hi @MadMac55 , have you considered setting a Hyphenation rule in your Paragraph Style?

 

Setting Words with at Least to 6 would prevent any words with 5 characters or less from breaking:

 

MadMac55Author
Inspiring
April 13, 2022

Thanks, Rob.  The style for body text in the book is justified, no hyphenation, so that alone wouldn't keep a minimum word count at the end of a paragraph where No Break actually impacts it. 

ajabon grinsmith
Community Expert
Community Expert
April 13, 2022

My language environment is Japanese, but the regular expression part would be helpful.
Note that it is a backslash, not a slash.

MadMac55Author
Inspiring
April 13, 2022

Very cool, Ajabon.   Are these approaches just different with the same result, or do they add on checks and balances to mine?  Thanks!

ajabon grinsmith
Community Expert
Community Expert
April 13, 2022

I divided the regular expression into three parts because I thought it would be better to emphasize visibility than to write it on a single line in a cool way.
The first is at the beginning of a paragraph, the second in the middle of a paragraph, and the third at the end of a paragraph. But this may not be necessary since I think there is usually punctuation at the end of a line. But just in case.

Regards.