No one likes formatting prices, but in this week’s free InDesign Secrets video, Adobe InDesign guru David Blatner shows you how to add custom dollar signs and superscripts for your cents with one single paragraph style. The magic lies with nested styles and GREP styles. Let David show you how these work.
First you need to create separate character styles for each pricing element: one for the dollar sign, one for the cents, and one for the decimal.
To hide the decimal, David suggests creating a character style that changes the font size to 1 pt and change the Character Color to None. David named this style “disappear.”
1. The trick is to embed these character styles in a paragraph style. First, select the price you would like to format and choose New Paragraph Style from the Paragraph Styles panel. Go to the General pane and choose Apply Style to Selection.
2. Go to the Drop Caps and Nested Styles pane. Click New Nested Style. Select your dollar symbol style and apply it through the first character. It is important to change the default Words to Characters in this menu.
3. Click New Nested Style again and choose [None] up to 1 and replace the default Words with a period by actually typing the character (.) in the menu.
4. Click New Nested Style a third time and apply your disappear style through 1 Characters.
5. Finally, choose your cents style through 2 Characters.
6. Click the Preview check box to see the immediate results and click OK to create your new paragraph style.
Now this method only works when your price is in its own paragraph, not inline with other text. To format a price in running text, you need to use a GREP style. This technique still requires the 3 separate character styles for the dollar sign, decimal, and cents.
1. Once again, choose New Paragraph Style from the Paragraph Styles panel. Go to the GREP Style pane. Click New GREP Style.
2. Choose your dollar symbol style from the Apply Style menu and type \$ in the To Text field.
The dollar sign is a reserved character in GREP and the backslash tells it to treat it as a normal character, not a special code.
3. Click New GREP Style again. Choose your cents style from the Apply Style menu and type \d\d in the To Text field. This tells InDesign to look for two digits in a row. But we want to make sure these numbers are preceded by a period.
4. Click the @ button and choose Match > Positive Lookbehind from the flyout menu. This inserts the GREP code (?<=).
5. Between the equal sign and closing parenthesis, type \. to ask InDesign to look for a literal decimal character behind our two digits.
6. Now to make that decimal disappear! Click New GREP Style, choose your disappear style, and type \. in the To Text field. Next, click the @ button and choose Match Positive Lookahead from the flyout menu to insert the code (?=). Lastly, before the closing parenthesis, type \d\d.
7. Click OK to create your new GREP style. The style will be accessible from the normal Paragraph Styles menu and you can apply it to any text that might contain an inline price.
Both nested styles and GREP styles are great for boosting your efficiency in InDesign. They can seem intimidating at first, but they’re well worth investing some time in—it will quickly pay off. To learn more about GREP styles, check out David’s course called InDesign: 10 Things to Know About GREP.
And for more InDesign insider tips, join Anne-Marie Concepción in a member-exclusive video called Checking out the Gridify tricks.
The InDesign Secrets dynamic duo will be back in two weeks with more tips.
Interested in more?