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
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
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.
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
Copy link to clipboard
Copied
Thats exactly it! Thanks ever so much Peter!
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
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.
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.
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
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
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!
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.
Copy link to clipboard
Copied
Thank you! That was very helpful!
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?
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?
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 )
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.
Copy link to clipboard
Copied
Thank you so much!
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.
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.
Copy link to clipboard
Copied
Thank you so much Peter!
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.
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.
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.
Copy link to clipboard
Copied
> 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.