GREP of the Month: Superscripting Suffixes
Automatically convert all your numerical suffixes to superscript when applying a paragraph style.
This article appears in Issue 66 of InDesign Magazine.
Sometimes you want to automate certain repetitive tasks, like changing numerical suffixes to superscript. Luckily, there’s a great GREP style you can use for this.
First you need to create a new character style that uses the superscript setting. Then take the paragraph style that’s applied to your text, and add a new GREP style. Type in the code (?<=\d)(st|nd|rd|th) to accomplish your goal.
Here’s the explanation: (st|nd|rd|th)Â looks for any of the sets of letters within the parentheses that will act as a suffix, for example “st” for 1st, “nd” for 2nd,” and so forth. The vertical bars in the expression mean “or.” Of course you don’t want to superscript any pair of letters, just the ones that are preceded by a number. That’s why we add the \d at the beginning of the expression. But to avoid applying the superscript to the actual number, we put it within a “Positive Lookbehind” string (available from the”@” flyout menu), giving you the (?<=\d) result.

This means that the presence of a number before any of our letter pairs is the condition upon which the superscript should be applied. Adding this ensures that numbers themselves will be left alone—only the letter pairs will receive the superscript styling.
And remember that this is all applied live, meaning that InDesign will automatically apply your superscript to the correct letter pairs even while you’re adding, changing, or removing text.
Commenting is easier and faster when you're logged in!
Recommended for you
InReview: IDMarkz
Preview and convert InDesign files to other formats without a copy of InDesign
How to Preserve Italics in an InDesign Index
How to use GREP Find/Change to apply formatting to text in an InDesign index
Making Bulleted Text Without Bullets in InDesign
How to use Paragraph Shading and Paragraph Rules to simulate bullets at the star...
