In this article, you will learn how to automate superscripting the letter portion of 1st, 2nd, 3rd etc in your InDesign document using Find/Change and GREP.
As a developer, I always think about reducing repetition (DRY, anyone?).
So, not surprisingly, when tasked with a repetitive styling task in an Adobe InDesign manuscript, I’m quick to use Find/Change, specifically the GREP tab options.
Recently, I needed to search a 700+ page InDesign document for any time 1st, 2nd, 3rd, 4th, 100th, 59th, etc was included and to change the letter formatting to superscript. This task is perfect for programming.
Code Snippet to Search InDesign for 1st or 2nd and other Ordinal Numbers
First, I wanted to query and find instances of ordinal numbers (1st, 2nd, etc) in my document. To do this I used a custom query in the Find/Change area of InDesign.
(?<=\d)(th|st|nd|rd)\>
This GREP code snippet queries your document for where there are instances of th, st, nd, or rd with a number before them.
Using GREP in the InDesign Find/Change Box
First, select Edit > Find/Change or use Command + F on a Mac.
By default, in Find/Change you’ll have the Text tab selected. Choose the GREP tab. Next, copy and paste the code snippet into the Find What: field.
In my case, I want to change the letters to superscript, so I will use the Change Format field, too. Click the T with the magnifying glass icon (labeled Specify Attributes to Change) on the right in the Change Format area. This will bring up a Change Format Settings window. You’ll want to navigate to Basic Character Formats on the left. Then, choose Superscript from the drop-down options for Position.
Once this is completed, you’ll be ready to start searching and replacing. Your Find/Change settings should look like this screenshot.
I often search my document for ordinals, one by one, using the Find Next button. If it’s an instance I want changed, I click the Change button and go to the next one; however, you can use the Change All button and save lots of time in large documents.
And that’s it. Success.
Video showing how to Find and Change 1st, 2nd and 3rd to Superscript in InDesign
Questions and Resources
Ordinal numbers are numbers used to represent order; this could also be rank or position, such as first, second, or third.
David Platner writes more about using GREP in InDesign, specifically on this topic, in his post Quick GREP To Superscript Ordinals.
GREP is a code snippet. It can also be called an expression or a formula. GREP stands for Global Regular Expression Parser.
I hope this helps you speed up superscripting the letters in your ordinal numbers — like 1st, 2nd, and 3rd.