Killing Runts in InDesign with Grep

There's always been a certain degree of confusion as to the definition of "orphans", "widows" and "runts" in typography. Runts are occasionally referred to as orphans, which does not help matters. And they are sometimes (mistakenly) called widows, too. So let's just clear this up once and for all:

  • Orphans are, to quote Bringhurst, "isolated lines created when paragraphs begin on the last line of a page… They have no past, but they have a future, and they need not trouble the typographer". As a rule, I try to avoid them without going too far out of my way.
  • Widows are "the stub-ends left when paragraphs end on the first line of a page… They have a past but not a future, and they look foreshortened and forlorn. It is the custom… to give them one additional line for company".
  • Runts are words which share this demeanour: they are short words at the end of a multiline paragraph, or the short, last part of a longer hyphenated word which ends a paragraph. The definition of "short" is really a visual one, but certainly if it ends before the first line indent of the following paragraph, it's not going to look terribly nice.

InDesign has a few features to help deal with runts. The first of these is in the hyphenation control. You can disable the hyphenation of the last word in a paragraph in that paragraph's style options (and set various other limits, too). So far, so good.

To deal with runts that are whole words, we need to bring out the big guns: GREP styles. It's worth getting to grips with GREPs if you manipulate text a lot, as they can save a lot of time in typesetting. Here's how I do things:

  • Create a new character style called "no-break", based on "none". Under "Basic Character Formats", just tick "No Break". 
GREP - no break char
Simple "no break" character style
  • In the paragraph style in which you want to kill off runts, go to "GREP Style" [why not plural?!]
  • Create a new GREP style. We want to use the following GREP (note the space character at the very start):
  •  [^ ]{1,5}[[:space:]]*$
GREP - no break style
Applying the style with a GREP
  • In plain(er) English, this means "find a space, followed by 1-5 non-spaces, and ending either with a carriage return or some empty space and then a carriage return (because quite often you end up working with texts that have pointless but harmless spaces at the end of paragraphs).

That's all there is to it. If you want to change the length of what's considered a "runt" (to make it shorter, for example), just change the 5 to 3 or 4.

Unfortunately, InDesign has precious few to deal with orphans and widows, which I check for manually. This is a bit tedious and I've developed some scripts to locate them, but really it all depends on the dynamics of the text on the page, so it needs a bit of human love.

Comments

Bobi · Jul 4, 2012

Hi, thanks for taking the time to write this, but it's not working for me. I've done exactly as you said and copied, pasted and checked the characters in the Grep style (including the one space at the beginning), but no worky. Any ideas?

Tetragon · Jul 4, 2012

You're welcome! Which version of ID are you using? You could try temporarily changing no-break to bold or red or something, so you can see what's going on. You could also try removing that whole end bit: [[:space:]]* …if your paragraphs end as they should (without any extraneous spaces). Remember to keep the dollar sign at the end though!

Raphael Freeman · Dec 21, 2014

I tried this with InDesign CC (2014). Funnily enough when doing a grep search this worked great, but when I tried to make it a style it didn't work. So I simply did a search and replace.

Susan · Aug 3, 2012

I was really excited to find this technique. Unfortunately, when I used it for my body style, it deleted all the text in the story before the first runt on. When I removed that section of the script as directed, it did the same thing. CS6.

In regard to orphans and widows, is using Keep lines together (keep options) ineffective? I have been successful with this. Also, for keeping subheads with their paragraphs, using "keep with" next 2 lines works well (Keep Options).

sooshi · Oct 14, 2012

The last space, between the last two words of a paragraph, can be a non-breaking space.

Tetragon · Oct 15, 2012

I know, but thanks anyway: I'm not sure it's something I'd like to always enforce on a site though. With books, the layout is fixed and you can override if you're not happy. I'm a bit cautious of treating print and digital media in the same way as lonely lines are sometimes better than very gappy / tight lines.

heymcdermott · Mar 13, 2014

You can run your HTML through a text editor like BareBones free TextWrangler, which is very GREP friendly. Just use a similar search term to find short word before the <br> or </p> tag, and replace the space with a non-breaking space.

Ben Wilson · Oct 17, 2012

Brilliant! It worked perfectly for me (CS6) – thanks for posting. Any tips on where to learn more about GREP? You've got me interested now…

Aubrey MillerSchmidt · Apr 2, 2013

Thank you – this saved me hours and hours of work!

Matt Hodtwalker · May 16, 2013

I never noticed that "GREP Style" wasn't pluralized in the paragraph styles menu before I read your article, and now that's really bothering me! Oh, and thanks for a terrific piece of knowledge, too!

Angelo KW · Nov 2, 2014

Awesome – much appreciated. Am attempting to develop code in grep for runting bullet points – will come back and update if successful.

PS, love that the little bastards are called runts.

David Hillel · Jan 18, 2015

Thank you. It helps me a lot. But for some reason, the GREP search query interprets footnote markers as CR symbol. This means it changes every space preceding a word with footnote marker on it. Any solution for that?

Robert Mayers · Mar 2, 2015

Just curious as to whether anyone has had any issues/crashes with this GREP command in InDesign CC?

Tetragon · Jun 2, 2017

An update on this: for some reason the latest version of InDesign doesn't seem to like the $ at the end of the expression (though previous versions were fine with it). If you replace it with a \r, you should be in luck. If you want to test how it works, change your no-break character style to another colour to see what it's applied to.

— Tetragon