The May meeting of the Portland InDesign User Group focused on Paragraph & Character Styles, with a considerable portion of the time devoted to Nested Styles and GREP. The purpose of this article is to summarize the information I presented in the meeting.
- Apply Paragraph Styles to everything. Apply Character Styles only to text that is different from the rest of the paragraph.
- Use Nested & GREP Styles to automatically apply Character Styles within a Paragraph Style.
- Nested Styles are best for formatting that happens in a predictable order starting at the beginning of the paragraph and continuing throughout the end. GREP Styles are best for when the desired text could be located anywhere in the paragraph, or at the end.
3 Paragraph Style Settings Guaranteed to Improve your Typography
- Keep Options: for body text, keep 2 at start and 2 at end to prevent widows & orphans; for headings, keep with next.
- Hyphenation: Default settings are terrible. Recommend 8-4-4-1, all 3 checkboxes at bottom off, and then adjust as needed.
- Justification: Default settings will cause awkward gaps in justified text. Recommend letter spacing of -5, 0, 5 for starters; adjust settings as needed.
Style Order of Operations
- Paragraph Styles are applied first. All other formatting overrides them.
- Nested Styles are overridden by GREP styles.
- GREP styles are applied in the order in which they appear in the list. Styles down the list override previous styles.
- Manually applied Character Styles override Grep Styles.
- And of course you can always apply local overrides.
What is GREP?
(from wikipedia) Grep is a command-line utility for searching plain-text data sets for lines matching a regular expression. Its name comes from the ed command g/re/p (globally search a regular expression and print).
GREP has been incorporated into InDesign as a powerful means to search for patterns in text. It can be used either in the Find/Change dialog or in a paragraph style, to apply character styles automatically through the use of GREP styles.
Here is a copy of the example InDD file used in the meeting. It is in IDML format for backward compatibility to CS4.
It includes examples of the following GREP queries in action:
- Automatically format English text and numbers found in otherwise non-Latin languages (Chinese, Japanese, Thai, Arabic, etc).
- Automatically format prices, in this example to hide the $ and . characters and superscript the cents.
- change the formatting of a single character (In this example, the ‘?’.
- Format HTML so that tags, URLs, etc. are color coded.
- Prevent runts (also called orphans, when you have a single word on the last line of a paragraph).
So you want to learn GREP? I’d recommend you start with the excellent interactive GREP Tutor at rorohiko.com. It’s how I learned the basics of GREP. It features a series of easy-to-understand lessons as well as a real-time GREP query testing area.
Then there is this excellent GREP test utility. I use this to troubleshoot and figure out GREP strings that aren’t quite working in InDesign.
InDesign Secrets has a page listing many resources:
And then there is the InDesign help page listing many GREP codes:
Multiple Find/Change Scripts
We also discussed two great free scripts that can run multiple find/changes in your document. Both of these offer a GUI and support GREP as well as regular InDesign find/replace functionality.
XStrings saves find/change or GREP replacements in a text file and allows you to apply them individually or in sequence. It does not use InDesign’s own saved queries, so it’s good for special uses in which you don’t want your list of queries to be stored in your InDesign Find/Change dialog. I used this tool for the Victor Borge Inflationary English example.
DoQueryList allows you to run multiple InDesign saved queries in sequence. If you’ve already saved your queries in InDesign but want to run several succession, this tool works great.
Related Creative Progression Articles