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

How to automatically prevent Widows/Orphans in InDesign

Explorer ,
Feb 28, 2013 Feb 28, 2013

Copy link to clipboard

Copied

Hi,

I constantly create multi-languaged leaflets within InDesign CS5 and the one thing I often find is that I constantly have to revisit the entire document to prevent widows (or orphans - whatever you call them) at the end of a paragraph.

Is there a way to setup within my paragraph style to prevent, lets say, anything less then 10 characters at the end of the paragraph?

I am aware of using the White-Space non break command, but the amount of text I have to visit I wondered if it could be setup in the first instance and prevent widows appearing at the end of a paragraph.

Thanks for taking the time to read

Steve

TOPICS
How to , Type

Views

67.4K

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

correct answers 2 Correct answers

Community Expert , Feb 28, 2013 Feb 28, 2013

To prevent last lines shorter than 10 characters, run this Grep query:

Find what: .{10}$

Change to: <leave empty>

Change format: No Break

Or you can do this as a Grep style.

Widow and orphan prevention is set in the paragraph style, see Keep Options.

Peter

Votes

Translate

Translate
Community Expert , Feb 28, 2013 Feb 28, 2013

This comes up from time to time, and usually sparks a discussion about why it might not be adviseable, but I'll dispense with that for now and say that you can create a character style that applies No Break, then use a GREP style to apply it to the last n characters in a paragraph in the GREP Styles section of your Paragraph Style definition.  The expression .{n}$ should work, where n = the number of characters you want to keep from breaking.

Votes

Translate

Translate
Community Expert ,
Feb 28, 2013 Feb 28, 2013

Copy link to clipboard

Copied

To prevent last lines shorter than 10 characters, run this Grep query:

Find what: .{10}$

Change to: <leave empty>

Change format: No Break

Or you can do this as a Grep style.

Widow and orphan prevention is set in the paragraph style, see Keep Options.

Peter

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
Explorer ,
Feb 28, 2013 Feb 28, 2013

Copy link to clipboard

Copied

Thats exactly it! Thanks ever so much Peter!

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
New Here ,
Jun 01, 2021 Jun 01, 2021

Copy link to clipboard

Copied

Hi There, I'm not following how to change the format to No Break.  I see that in the character style options, but it makes all the text disappear.  Could someone post a video showing the steps also?  Would be a HUGE timesaver to finally figure this out.

 

Many thanks

Kendra

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 ,
Feb 28, 2013 Feb 28, 2013

Copy link to clipboard

Copied

This comes up from time to time, and usually sparks a discussion about why it might not be adviseable, but I'll dispense with that for now and say that you can create a character style that applies No Break, then use a GREP style to apply it to the last n characters in a paragraph in the GREP Styles section of your Paragraph Style definition.  The expression .{n}$ should work, where n = the number of characters you want to keep from breaking.

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
New Here ,
Apr 01, 2014 Apr 01, 2014

Copy link to clipboard

Copied

I created a grep that assigns a NOBREAK character style the last word of every paragraph: (\s\w+.?)$

This should apply the NOBREAK character style to...

a space (\s)

+ word (\w+)

+ optional punctuation (.?) - really any character

at the end of every paragraph ($)

I think my parenthesis are actually optional as well, and I'm sure I could get more specific with the punctuation part too but this seems to the the trick for me.

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
New Here ,
Dec 15, 2015 Dec 15, 2015

Copy link to clipboard

Copied

I searched for an answer to this question, and I found these. I am not following how to create a GREP style. Can someone walk me through that process either by clear instructions or screen shots? I tried a few different things, but I must not be fully comprehending how to do this. TIA

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
New Here ,
Feb 08, 2016 Feb 08, 2016

Copy link to clipboard

Copied

MarketingMama: Here's a screenshot video I make adding this GREP to a paragraph style sheet in InDesign: Dropbox - GREP_Widows.mov

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 Beginner ,
Apr 05, 2016 Apr 05, 2016

Copy link to clipboard

Copied

Cowanji,

Thanks for the video. I'm sure that's the best way to show how to accomplish a task.

Unfortunately, it is too blurry to see, and you move too quickly for me to follow what you're doing.

Is there a step-by-step instruction available somewhere?

Thanks again!

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
Explorer ,
Jun 17, 2016 Jun 17, 2016

Copy link to clipboard

Copied

I had to watch this again as I had forgotten. This is so awesome. So glad I saved the link. Really saving me a lot of time of double checking copy breaks. Thank you so much.

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 Beginner ,
Jan 18, 2018 Jan 18, 2018

Copy link to clipboard

Copied

Thank you! That was very helpful!

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
Explorer ,
Feb 19, 2021 Feb 19, 2021

Copy link to clipboard

Copied

I tried this, but the problem I found is that if the last two words already had a character style, like italic on them, then the NOBREAK style would knock any other character style that is already on the words. So the last two words of an italic paragraph ended up coming out non italic. Also did the same with bold text, it knocked the bold off. Is there a way to apply a NOBREAK character style without removing a style already applied?

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
Enthusiast ,
Oct 13, 2021 Oct 13, 2021

Copy link to clipboard

Copied

Thank you for that. This is fantasic. 

Is there a way to find the only the space before the last word of the paragraph?

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 ,
Apr 30, 2021 Apr 30, 2021

Copy link to clipboard

Copied

"…Is there a way to apply a NOBREAK character style without removing a style already applied?"

 

Hi Matthew,

basically no, if you try this "by hand".

 

BUT:

It's different if you apply the two character styles with two GREP Styles using a paragraph style.

Or if you apply the "Bold" character style "by hand" and the "No Break" character style through a GREP Style like Peter Kahrel suggested.

 

IMPORTANT:

There must be no entry for font style in the "No Break" character style.

There must be no entry for No Break in the "Bold" character style.

No entry with a check box means this state: [-] .

 

Regards,
Uwe Laubender

( ACP )

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 ,
Oct 14, 2021 Oct 14, 2021

Copy link to clipboard

Copied

Is there a way to find the only the space before the last word of the paragraph?

\s(?=[^\s]+$)

This one matches only the space before the last word in a paragraph.

P.

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
Enthusiast ,
Oct 14, 2021 Oct 14, 2021

Copy link to clipboard

Copied

Thank you so much! 

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
Enthusiast ,
Oct 14, 2021 Oct 14, 2021

Copy link to clipboard

Copied

I just found out that it's also find and select return if it's appear without text before it.

 

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 ,
Oct 14, 2021 Oct 14, 2021

Copy link to clipboard

Copied

Ok. Then try this:

\h(?=[^\s]+$)

to find horizontal spaces (spaces and tabs) or

\x20(?=[^\s]+$)

which matches only the normal 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
Enthusiast ,
Oct 14, 2021 Oct 14, 2021

Copy link to clipboard

Copied

Thank you so much Peter! 

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 ,
Oct 14, 2021 Oct 14, 2021

Copy link to clipboard

Copied

I prefer the method that adds the GREP style into the paragraph style. I usually add it into the main Body style so all my derivative, based-on styles pick it up. You just have to change it based on the font size and column width once, rather than remembering to do the find/change.

David Creamer: Community Expert (ACI and ACE 1995-2023)

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 ,
Oct 15, 2021 Oct 15, 2021

Copy link to clipboard

Copied

The problem with GREP styles is that they can slow down a document. Every time a story recomposes -- a character is inserted (or deleted), a float is placed or moved, in index marker is added, etc. -- all GREP styles execute. That can cause delays.

 

In addition, a GREP style that keeps a certain number of characters together always pulls characters from the paragraph's penultimate line to the last one. But tightening a paragraph a bit so that the short last line is removed often leads to a better result.

 

P.

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 ,
Oct 15, 2021 Oct 15, 2021

Copy link to clipboard

Copied

"Slow down" is a relative term. With my system and my documents (that I use it on), I haven't noticed much difference. 

 

Peter K.--question: does ID recompose every paragraph in a story or just the edited* paragraphs?

*Anything causing rewrap, such as edited by user, change in column width, or affected by text wrap upon reflow. 

If the former, it would seem a colossal waste of computing resources.

David Creamer: Community Expert (ACI and ACE 1995-2023)

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 ,
Oct 18, 2021 Oct 18, 2021

Copy link to clipboard

Copied

LATEST

> does ID recompose every paragraph in a story or just the edited* paragraphs?

 

I a text I maintain, the whole story is composed. I conclude that from the time it takes for the cursor to come back alive: if only the edited paragraph had been composed, it would have been dramatic. This particular document uses a lot of GREP styles, most of them complex (they do syntax-highlighting in code fragments), so the document may be a brutal test.  I've contemplated ditching the GREP styles and using a sript to do the highlighting, but GREP styles are convenient!

 

> If the former, it would seem a colossal waste of computing resources. Agreed. But recomposing a single paragrph doesn't make much sense because ID has to sort out footnotes, tables, etc.

 

Anyway, GREP styles are very powerful and in relatively short documents, with relatively simple GREP styles, things should be fine.

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