July 27, 2009

Using the New Grep and Nested Line Styles Feature’s Inside InDesign CS4 — Part 2

Building a Grep Style Into a Paragraph Style

 

Continuing where I last left off with the new Nested Line feature inside my last blog, this next entry will explain how to build a Grep Style into a Paragraph Style.

 

Styles

A type sample from a clothing catalog.

 

For the Price, I needed to superscript any dollar sign, and also the cent mark. It could be possible to write a nested style that would sometimes work, but it would be quite tricky. Instead, you can use the new Grep Styles included in CS4. Since CS3, InDesign has had this advanced Find/Change feature of Grep built in. Grep lets you do very specific searches based on expressions you can create. Now in CS4 you can use Grep inside your styles!

To build a Grep Style, I started by first editing the "Price" Paragraph Style. I didn't worry about making Character Styles for this one either, because I could do it right inside the dialog box again. The first Grep Style is easy. Every time there is a dollar sign within the text that has "Price" Paragraph Style applied to it, I want it to be superscripted. I simply needed to build it as a Grep expression. I chose Grep Styles from the list on the left.  I then chose New Grep Style. For "Apply Style" I used the drop-down menu to choose New Character Style. In the New Character Style Window, I named it "Superscript," then I chose Superscript in the Basic Character Format section under Position. I then closed the New Character Style dialog box, so I could pick which specific text to apply it to. I started by first placing a back slash then a dollar sign. The \ escapes the character that follows it. For instance, in Grep, a period "." indicates any character. However if I actually want to search for a period, I need to escape it by typing \. so that it actually searches for the period. The final expression I wrote looked like this "\$" inside the Grep Style window.

 

Styles

Writing a Grep expression to find every dollar sign.

 

The next Grep Expression was a little bit trickier. I wanted the cent marks to be superscripted as well. However, I couldn't just enter two 9's because that would superscript any 9. And the price could end with 88 cents, which could throw that off. Instead, I created a Grep expression that looks behind any two numbers and a space. Then I had to make another one that looked for any two numbers and a Standard Carriage Return.

To do this, I needed to edit the Price Paragraph Style once again. I made a new Grep Style, and chose superscript for the style to apply. Then in the Apply Style area, I used the drop down menu and chose Match > Positive Lookbehind. Then I chose Wildcard > Any Digit from the menu. I then entered another forward slash, and chose Wildcard > Any Digit again. I also needed it to find the space so I added a backslash and a space. The expression should look like this: "(?<=)\d\d\ " This took care of the first 99 cents because it had a space after it.

I now had to make a second Grep Style that looked behind two digits and a Carriage Return. I made a new Grep Style, and chose superscript for the style to apply. Then in the Apply Style area, I used the drop down menu and chose Match > Positive Lookbehind. Then I chose Wildcard > Any Digit from the menu. I then entered another forward slash, and chose Wildcard > Any Digit again, just like I did for the first one. I then chose Break Character > Standard Carriage Return. The expression should look like this: "(?<=)\d\d~b"

 

Styles

Writing a Grep expression to superscript numbers before a space or return.

 

Applying Next Styles

 

Using these two new styles can really automate the styling process. But I did promise a one-click apply, and I will deliver. You can use Next Styles to apply all this styling at once. This was a new feature of InDesign CS2. It simply means that after you've typed in a certain style, once you click return you can now type in a different "next" style. This is great for programs that require heavy typing, but very often, your InDesign documents contain placed word documents, or pasted type. The way Microsoft Word uses Next Styles would not be much help to a production artist who does little typing. But ever since CS2, you can actually apply Nested Styles to selected type. Based on where your return marks are, and how you've set up which style goes into which Next Style, you can get different paragraphs to have different styles applied to them.

To create the Next Styles I first had to make a paragraph style of "Last Line" for the last line. I then opened every style and changed each style so that its next style is the style that should appear after it. I highlighted the Item Name and double-clicked the style to edit it. For the Next style, I chose Description. Then I opened Description and changed that Next Style to Price. I then changed Price's Next Style to Last Line. Then I selected all of the text and applied Basic Paragraph to it, to reset it all back to one style. To apply a series of linked Next Styles, I right-clicked the first style in the Paragraph Style panel and chose "Apply Item Name then Next Style." And with one click, I've done all the styling I needed to these little catalog item descriptions.

 

Styles

Applying Next Styles inside the Paragraph Styles panel.

 

Adding All that Styling to an Object Style

 

Why stop there? If I needed a box around these descriptions as well, I could build all the styling and next styling into an Object Style. For this next example I removed the last line rule below and added a dotted stroke to the box. I then selected the box and chose "New Object Style" from the Object Style panel drop-down menu. I gave it the name "Catalog Apparel." By default, Paragraph Style is not checked when you make a new Object Style. I checked Paragraph Style so InDesign will also apply a given paragraph style to text within the frame. But instead of just applying one Paragraph Style, I clicked the checkbox next to "Apply Next Style." This will apply the series of Next Styles I designated earlier when I defined the Next Styles. To see if it worked, I highlighted all of the text and chose "Basic Paragraph" in the Paragraph Style panel. Then I got rid the border by choosing Basic text Frame in the Object Style panel.

I then selected the text frame with the Selection tool and chose the Object Style "Catalog Apparel." Not only does the box take on the correct stroke, but all of the type is styled correctly as well with one click.

 

Styles

Making an Object Style for the Catalog Apparel box.

 

Using all of these advanced styles does take a substantial amount of thought and preparation. But once they are set up, it makes styling quick and easy in InDesign. Look for patterns in the type you use every day in InDesign to seek out places Nested, Next, Line, and Grep Styles can quicken your workflow when using InDesign CS4.

Posted at 09:40 am by Robert Underwood

Technorati Tags:Technorati Tags:

More Blogs From Author:

DPCI In The News

Article by Jill Ambroz of Folio Magazine on the rise of the open-source Web Content Management System as a way for publishers to deliver content to their sites. > more

Alltop, all the top stories