InDesign Grep Styles, Prevent Units of Measurement from Breaking

GREP Units - Not Working

Is there a name for units of measurements that break to a new line and leave behind their number? Let’s call them strays. If strays bug you, GREP is here to help.

1. Establish your character style

no break styleSet up a character style, which has No Break set.

2. Creating the basic GREP Style

GREP - Style ShortSet up a GREP Style in your default paragraph style or each paragraph style you would like to prevent strays. Assign your No Break character style and add the following expression:
\d+\x20(?i)SF

\d+ “one or more digits”
\x20 “normal space”
(?i) “case insensitive”

3. Adding additional units of measurement

GREP UnitsThis GREP Style will find a number followed by SF or sf and apply No Break. The next step is to add all of the units that you typically find in your documents. To do this, we wrap all of the units in parentheses and use a pipe to separate them. In my documents, I typically run into SF, Sq. Ft., CY, and Cu. Yd.

\d+\x20(?i)(SF|Sq\. Ft\.|CY|Cu\. Yd\.)

Periods are used by GREP so you must escape them using a backslash in order to represent a regular period. Since we wrap all of the units within parentheses, the (?i) case insensitive apply to all.

GREP Units - WorkingYour new GREP Style will find strays and apply no break to the number and the unit of measurement.