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
Try it yourself
You can try superscripting the ordinals in InDesign by copying and pasting the paragraphs below or downloading our sample InDesign document.
On the 20th day of the month, under the azure sky, a procession of regal carriages traversed the cobblestone streets. Each carriage, adorned with intricate golden filigree, bore nobles clad in resplendent attire, attending the grand anniversary celebration. The town square, bustling with fervent activity, welcomed guests from the four corners of the kingdom, eager to partake in the festivities. Amidst the jubilant throng, the 21st Duke of Westshire stood at the forefront, a beacon of prestige and grace, as he addressed the assembled multitude, commemorating the 25th year of his esteemed reign.
In the shimmering ballroom of the grand palace, adorned with a myriad of crystal chandeliers, the illustrious event unfolded. Tables, draped in satin cloths of royal blue, were meticulously arranged, each bearing an array of delectable delicacies. Dancers moved in synchrony to the 24th waltz, their graceful movements mirroring the elegance of the occasion. At the stroke of midnight, as the clock chimed the 30th hour, the Duke, accompanied by the 26th Duchess of Westshire, raised a crystal goblet in a toast to prosperity, marking the culmination of a truly remarkable celebration.
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.