Using GREP as Part of a Style
Erica Gamet
Lessons
Conditional Text
16:00 2Auto Captions
10:37 3Bullets and Numbering
25:53 4Data Merge
16:54 5Using Find/Change to Automate Text Cleanup
22:10 6Automate with Styles
09:13 7Nesting Styles
15:55 8Using GREP as Part of a Style
10:37Lesson Info
Using GREP as Part of a Style
Couple other things. I told you that GREP in an earlier segment, that GREP also lives in the paragraph styles, so the difference being from find change, in find change you can find text based on GREP, which is finding a pattern of text, and you can rearrange it, add, subtract, do all sorts of magic with it. With paragraph styles it's more limited. The upside is that as, if you have a paragraph style assigned to something, as you type and the pattern, you know, fits whatever you've typed, it suddenly, it styles it for you. You don't have to run find change every time. But the only thing you can do with it in a paragraph style is you can apply a character style to the text it finds using that pattern, using those expressions. So I'm actually going to jump and find another page here. I believe, we'll go with this one here. So what I wanna do is I want to take some text and I want to apply a character style to it that lets me not have any orphans. So orphans are when we get really short li...
nes at the beginning or the end, sometimes called widows, sometimes called orphans, oh, sorry, widows or runts is what you'd kinda use to describe the whole group. I'm trying to get one, there we go. So I've got this really short word at the end and I don't want that but this is how wide I want my text to be, everything else is exactly how I want it to be. But what I wanna do is I wanna make sure that I never have these short little lines. Well I can create a character style called No Break and we could just assign a No Break if we wanted to. I can grab the last two words and assign No Break to it, which I always forget where it is, I think it's in Character, yeah, No Break. And that means that it will never break across the line. I'm gonna undo that. I can also create a character style that has that same thing. So I'm gonna do Character Style, nothing's selected, and Option or Alt click and I'll call this No Break. And the only thing I'm going to assign is this No Break down here. So now if I assigned that character style here, No Break, it does the same thing. I'm gonna undo that. What I wanna do instead is I don't wanna just have to manually do No Break, that's a lotta work. I wanna actually instead build it into my character, my paragraph style so that it applies it to a certain place. And what I wanna do is I wanna tell it the last 12 characters should never break, or whatever I've decided, so it needs to change depending on how wide your text frame is, how big your text is, what you deem, you know, an acceptable amount on the last line. So I'm gonna do 12 characters in this case. So this is, the paragraph style is Body Text. So in my Body Text I'm gonna make a change and I'm going to tell it apply No Break to the last 12 characters. So I'm gonna show you how to build a GREP expression to do that. So I'm gonna open that up and let's see, we're getting crowded in here, we'll see what we can do, we may have to just keep jumping out to it. So in Body Text I'm gonna come down to what's called GREP Style. Come in here and I'm gonna click New GREP Style, yes I am, there we go, and it automatically has a little formula in here. First thing I wanna do, delete that. Why it's there, I don't know. But I wanna tell it what style we're going to apply. We're gonna apply that No Break to the last 12 characters in a paragraph, so now we have to create a GREP style for that. We're gonna actually build this, kind of on the fly. So I'm gonna use this little menu off to the side and I need to tell it any character. So there's a wild card character for that and that's a period, so period just stands for any character. It's really super simple, but if you can't remember that we can come into the menu and choose Wildcards and choose Any Character. So that's absolutely anything except hard return, a carriage return, so any character. Now if I say Any Character and I click off of it, all my text goes away, because I assigned a No Break to every character in that entire every paragraph that's in there, so that's no good, we don't want that. We have to keep building out this formula. The next thing I wanna do is I wanna tell it exactly how many characters. So in the prior segment we saw how many spaces and we did two comma, which meant two or more, well in this case I'm gonna tell it exactly how many and I'm gonna tell it 12 and when we're telling a value we put that in curly brackets. That's something you're just gonna have to remember. That's what your local search engine is for if you can't remember, putting GREP InDesign and then what you're looking for. That's a great way to find new formulas. So that's basically telling me any character 12 times, boom. But not any 12 characters, because then it will just keep finding 12 characters and assigning No Break and 12 characters and we'll end up with no text again. I need to tell it where this occurs. This occurs at the end of a paragraph. And I need to put the end of the paragraph marker at the end of this segment, so it's gonna be any 12 characters at the end of a paragraph. And that is also in this menu, End of Paragraph. Whoops, that is not what I wanted, End of, yes, End of Paragraph, that's weird. I usually do a dollar sign not that, was that End of Paragraph? Yeah, End of Paragraph, I use a dollar sign. I don't know why it has a different one there. A lot of times there's several different ways to write an expression. I've written some pretty sloppy ones in the beginning and actually there's ways to tighten them up. I use the dollar sign for that, so when I click off, just to see what happens, I can now see that I don't have a break there at all. In fact what I normally do is normally make the No Break character style, I'm gonna come in here to Character Style and change the No Break, and I just wanna give it a color, just so that you can see where that's happening. So we'll just go ahead and make it in this orange. So now you can see that the last 12 characters of every paragraph have that No Break applied to it. So it will never break on those last 12 characters so as we shorten that up and we get to the bottom here, or let's actually look at the value added up above, it never breaks, even on that hyphen. I mean, it's a hyphenated word and it should break across it but I didn't wanna have that short little orphan that's there. So you'll never end up with just 12 or fewer characters ending up on that line. So you can build that into your Body Text paragraph style and then you're building all those other styles based on Body Text, so that information, that GREP Style, will continue throughout all those styles that are based on that. So that's one quick GREP expression. There's, like I say, GREP is a whole topic in and of itself, but I just want you to see what you can do with that, how it can change your automation so you're not sitting there trying to find those short little orphans and manually applying No Breaks to them. Some other things that we can do are things like dollar signs, I'm just gonna move this guy outta the way, just to kinda give you an idea, one of the Character Style might be Superscript and the only thing that you define in that is that you want it to be, sorry position is Superscript, so that's it, that's the only thing you've defined in that style is Superscript. And I can come in here and, again, maybe I do this in Body Text, I do not want that to be a sidebar, so I need to go back and change my styles here, my Object Styles and I wanna change my default Object Style to not that, just a basic text frame is good. And I am just going to type in that and I just, all I want is for the dollar sign to be superscripted. And I don't wanna have to find that every time, I just want that to automatically happen when I create a price. So I can do the same thing, I can assign a style, again it needs to be in a paragraph style. So let's assign one, that sidebar header, let's actually go ahead and give it, let's give it Sidebar Header. That's perfect, I'll just zoom in a little so we can see it, so in Sidebar Header I've decided that I need my dollar signs to be superscripted. So I go down to the GREP Style, click New GREP Style and tell it to apply Superscript to, and in this case if I put a dollar sign, it doesn't work, why is that? Well dollar sign means something special in GREP, so if a character means something special in GREP, try throwing a backslash in front of it, right? So now I click off of that and now it superscripts it. So again, if you don't know what that is you can always do a search, GREP InDesign and what it is you're looking for. Make sure you put InDesign only because GREP lives in other places, it's from the programming world, so you don't wanna end up with something that doesn't look like InDesign. And InDesign uses a smaller subset of GREP, so you wanna make sure when you're doing a search that you're looking specifically for InDesign. But there you go, I just put superscript backslash dollar sign, that means anytime there's a dollar sign in this particular style it will automatically do that for me. So as I'm typing along and if I say the, let's actually do the dollar sign, as soon as I hit dollar sign it should automatically do that, except this is not the right style, there we go, and because I hit return and we've told it it returns to sidebar text. So again, as I'm typing, any time I type a dollar sign it automatically superscripts it for me and then it doesn't superscript anything else. I didn't have to go back and select that and choose superscripting. So that's building in nested GREP styles inside paragraph styles as well. And there's several other things that we can cover in styles, like I said I've covered it in other segments, or other courses as well. There's just so much automation that we can put inside there and that's the whole point of styles, is that we can come in here and style things super quickly. We can say does this, is this right, sidebar text? No, it's a sidebar header, no, it's some other kind of header. It's a subheader or a section header, all right? So we wanna be able to automate that and we don't wanna have to sit and select all the text specifically and assign character styling to that. And then when it comes time, when the client comes back and changes the font we can change it in one or two places and it ripples down through all those other places.
Ratings and Reviews
a Creativelive Student
OWESOME!!! I looooove her classes. Such an easy going approach and teaching. She knows so much about indesign and presentations in general but the way she explains is just really pleasant and fun. Thank you so much, Erica !!! I have several of your classes and the color one is owesome as well.
Alice Stoicescu
Student Work
Related Classes
Adobe InDesign