Skip to main content
Participant
September 5, 2022
Answered

Is it possible to program indesign to make a line break to little words besides 4 letters ?

  • September 5, 2022
  • 4 replies
  • 572 views

Hi,

Is it possible to program indesign to make a line break to words of 4 letters or less that are at the end of the line? I don't like to have these little words at the end of the lines.

Thank you very much !

 

Sincerely

Arthur 

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

Eugene's expression works at paragraph end (because of the $). To avoid words of 4 characters or fewer at any line, apply no-break to the space after all those words:

Find what: \b\w{1,4}\b\K\h
Change to: <Leave empty>
Change format: no-break

 

\b\w{1,4}\b matches words of 4 characters or fewer, \K is a look-behind (so that the words aren't actually selected, so to speak), and \h is any horizontal space.

 

As Peter S. said, that could produce some ugly type.

4 replies

Peter Kahrel
Community Expert
Peter KahrelCommunity ExpertCorrect answer
Community Expert
September 6, 2022

Eugene's expression works at paragraph end (because of the $). To avoid words of 4 characters or fewer at any line, apply no-break to the space after all those words:

Find what: \b\w{1,4}\b\K\h
Change to: <Leave empty>
Change format: no-break

 

\b\w{1,4}\b matches words of 4 characters or fewer, \K is a look-behind (so that the words aren't actually selected, so to speak), and \h is any horizontal space.

 

As Peter S. said, that could produce some ugly type.

Community Expert
September 6, 2022

Thanks that's much cleaner 

Community Expert
September 6, 2022

Apologies for misinterpeting your issue 

 

This GREP should work

\w+?.\b\w{1,4}\>.$

 

Participant
September 6, 2022

No problem. 

The line didn't work for me, I tried both with no break et [without] style and nothing happened. I checked that my style was successfully applied to my text. It didn't manage to prevent short words from ending any line.

Peter Spier
Community Expert
Community Expert
September 5, 2022

The way I read the question the OP wants to prevent words of 4 characters or less at the end of ANY line, not prevent words of 4 characters from breaking at the end of the story.

As far as I know this can only be done by scripting, if at all.

I would also say it is a recipe for really ugly pages.

Dave Creamer of IDEAS
Community Expert
Community Expert
September 5, 2022

Couldn't the GREP be modified to apply any 4-letter words? I imagine if a space precedes it, and a space or punctuation follows it, would find most of the culprits. It really wouldn't matter if it was at the end of a line or not. 


David Creamer: Community Expert (ACI and ACE 1995-2023)
Peter Spier
Community Expert
Community Expert
September 6, 2022

The request, as I read it is not to prevent breaking 4-letter words (which can be accomplished in hyphenation settings), but to prevent short words from ending a line.

Scanning the posts here, I see, I believe, nine lines ending in short words, including several that end paragraphs.

Community Expert
September 5, 2022

Use GREP styles in your paragraph styles.

First, create a character style, and call it no break or something like that - in the Font section you can set it to No Break tick mark- don't include any styles or font infomration.

 

In your paragraph style go to the Grep Style and search for the last 4 words in a paragraph

something like 

( \w+?){4}.$

 

Then select the no break character style.