Insert a Special Character with GREP Styles
You want to put a logo at the end of every story. Or you want to insert a special character or picture after each instance of a word in a document. Why not automate it in InDesign CS4 with GREP Styles? Well, because GREP Styles only lets you apply a character style, not perform a find/change… that is, you cannot insert or change any characters using this feature.
Or can you?
Here’s a fun workaround: You can replace any character in your story with another by choosing a different font! For example, if you apply a character style that is defined with the Zapf Dingbats font to the letter “n” you’ll get a black square.
So what if you change a character — say, the final period at the end of a story — to a font that has your logo in it? Or a dingbat of your choice? It’s easy to do: Just create a new font with a utility such as TypeTool. [Editor’s note: A newer tool, called IndyFont, let’s you do this right inside of InDesign.] For example, I opened a font (it’s easier to start with an exsiting font, I find), found the period character, and pasted this little logo into it:
I adjusted the right bearing (side) so that it would fit both the dot and the logo. Then I changed the font information (gave it a new name, etc.) and exported my new font. The whole thing took no more than 10 minutes. (Mostly just trying to get the outlines right in the character.)
After installing my font (I just put an alias of it in the Fonts folder inside the InDesign folder), I added a GREP Style to the paragraph style definition – the paragraph style that I knew would be at the end of each story where I wanted that logo.
The backslash-period in the style above indicates a period. The backslash-Z means “at the end of the story.” The character style simply changes to my font that I created.
The result? InDesign automatically “inserts” my logo at the end of every story in that paragraph style:
And it does it on the fly, so if I add a new paragraph after this one, the logo drops off this one and is added to the new last paragraph. I love that.
I did something similar with the spacebar character: Just replaced the space with a special dingbat character (with space on either side of it). That way, I could make a grep style that searches for one space after a particular word.
Even better: When the text is exported, that formatting disappears (because the space is just a space, and the period is just a dot), so I just get the underlying story.