Learning GREP with InDesign
Illustration by John Hersey

Inserting anchored objects with GREP


From:

Learning GREP with InDesign

with Michael Murphy

Video: Inserting anchored objects with GREP

Although GREP is primarily a text- based feature, you can actually use GREP to insert graphics too. By combining GREP Find/Change, Styles and Anchored objects, we're going to see how you can insert hundreds of anchored object frames in mere seconds. To finish off the layout of this directory of embassies, I want to add before each country name, a small graphic frame into which artwork for the flag of that country is going to be placed. They are going to go in as anchored objects, so that they flow with the text and they all appear in the same place above each line.
Expand all | Collapse all
  1. 1m 33s
    1. Welcome
      1m 4s
    2. Using the exercise files
      29s
  2. 7m 56s
    1. What is GREP?
      1m 53s
    2. Text searching vs. GREP searching
      2m 35s
    3. Working with GREP and InDesign
      3m 28s
  3. 46m 4s
    1. Using metacharacters, the building blocks of GREP
      6m 37s
    2. Escaping out metacharacters
      2m 49s
    3. Building with wild cards
      9m 9s
    4. Understanding undocumented wild card "opposites"
      3m 11s
    5. Specifying locations
      7m 4s
    6. Learning the undocumented location metacharacters
      4m 45s
    7. Using repeat metacharacters and defining the shortest match
      5m 45s
    8. Specifying exact matches and ranges
      2m 52s
    9. Finding content that doesn't exist with zero functions
      3m 52s
  4. 43m 26s
    1. Creating "or" conditions
      5m 24s
    2. Building subexpressions
      5m 52s
    3. Using character sets to create custom wild cards
      7m 3s
    4. Using negative character sets
      3m 2s
    5. Finding around text with lookbehind and lookahead
      8m 1s
    6. Building with modifiers: Case sensitivity
      4m 0s
    7. Building with modifiers: Single-line and multi-line
      3m 10s
    8. Using InDesign-compatible Posix expressions
      6m 54s
  5. 49m 18s
    1. GREP styles vs. nested styles
      6m 10s
    2. Styling specific words or phrases
      3m 18s
    3. Describing inconsistent text
      6m 59s
    4. Describing and styling prices
      6m 55s
    5. Applying multiple character styles to the same text
      6m 8s
    6. Describing and styling email addresses
      10m 48s
    7. Dynamically fixing orphaned words with GREP
      9m 0s
  6. 33m 30s
    1. Adding more to the mix: GREP Find/Change
      1m 41s
    2. Understanding queries
      8m 20s
    3. Using formatting and styles as Find/Change criteria
      5m 20s
    4. Preserving and recalling using subexpressions
      7m 49s
    5. Backreferences in search queries
      3m 8s
    6. Cleaning up text with GREP
      2m 45s
    7. Creating a GREP-based text cleanup script
      4m 27s
  7. 43m 45s
    1. Describing imported spreadsheet data
      6m 56s
    2. Rearranging imported spreadsheet data
      7m 17s
    3. Applying styles and formatting with GREP
      11m 14s
    4. Describing and standardizing phone numbers
      9m 20s
    5. Inserting anchored objects with GREP
      8m 58s
  8. 27s
    1. Goodbye
      27s

Start your free trial now, and begin learning software, business and creative skills—anytime, anywhere—with video instruction from recognized industry experts.

Start Your Free Trial Now
please wait ...
Watch the Online Video Course Learning GREP with InDesign
3h 45m Intermediate Nov 18, 2009

Viewers: in countries Watching now:

Learning GREP with InDesign decodes the language of GREP for InDesign users. It shows how this versatile tool can be used for describing text, which can speed up or automate everyday formatting tasks. InDesign expert and graphic designer Michael Murphy introduces the basic concepts of GREP, and shows how to build powerful expressions using metacharacters. Michael also explores many of the little-known features of GREP, explaining how GREP styles and Find/Change can be used to rearrange data and dynamically format text. Exercise files accompany this course.

Topics include:
  • Using metacharacters, the building blocks of GREP
  • Describing text that may not exist with zero operators
  • Applying multiple character styles to the same text with GREP styles
  • Eliminating orphaned words at the ends of paragraphs
  • Preserving and recalling subexpressions
  • Customizing a GREP-based text cleanup script for long documents
Subject:
Design
Software:
InDesign
Author:
Michael Murphy

Inserting anchored objects with GREP

Although GREP is primarily a text- based feature, you can actually use GREP to insert graphics too. By combining GREP Find/Change, Styles and Anchored objects, we're going to see how you can insert hundreds of anchored object frames in mere seconds. To finish off the layout of this directory of embassies, I want to add before each country name, a small graphic frame into which artwork for the flag of that country is going to be placed. They are going to go in as anchored objects, so that they flow with the text and they all appear in the same place above each line.

So the first thing I'm going to do is create a graphic frame for myself as a placeholder to receive those files when I'm ready to place them. I will draw a frame out here with the Frame tool, roughly the size and dimensions of a small flag. I'll switch to the Selection tool and then from the Edit men, choose Cut to copy it to the Clipboard. I'm going to put my cursor in at the beginning of the very first letter in the very first country in this list and then I'll go to Edit>Paste to insert that object and by default, it goes in as an inline anchored object.

I will switch back to the Direct Selection tool, click on the Graphic frame and then right-click and go to Anchored Object>Options. By default, this is an Inline object that sits to the left of the text. I actually want to make it an Above Line object so that it sits above that line and I want to add a little space after it, so I am just going to notch that up in the Space After field and that's about what I want. I will click OK and now that I've got this positioned and anchored exactly the way I want, I want to save all of those settings as an Object Style.

From the Window menu, I'll choose Objects Styles and I'm going to create a New Object Style by choosing that option from the panel menu. I'll name this object style 'Anchored Flags' and then I'll go over the Anchored Object Options for this style and we can see that what I just did, has been picked up and built into the style automatically. I'm going to add one more feature in here. I'm going to activate Frame Fitting Options. I want to make sure that whatever graphics get placed in these frames, when I am ready to take that step, will fit proportionally in that frame, so I will choose Fit Content Proportionally.

That's going to resize the graphics as they are placed. One last thing I want to do though is go to General and make sure that Apply Style to Selection is on, so that when I click OK, you can see that the selected object, which I already pasted, has Anchored Flags applied to it automatically. I'll close Object Styles because I am done with that and then I'll select this frame again and I'm going to cut it to the Clipboard. Now that that frame is in the Clipboard, I'm going to start inserting it everywhere that I need it using Find/Change and GREP.

I will hit Command+F, or Ctrl+F, on Windows to open the Find/Change dialog. I'm in the GREP tab, but I want to make sure that I click More Options because I'm going to want to describe formatting as a search criteria to make this work. Before I start entering anything in the Find what field, let me think about exactly what I'm trying to do. I have something in my Clipboard. I want to insert that object that's copied to the Clipboard at the beginning of every line that's using the Country Paragraph Style.

I know that I need to describe a location at the beginning of a paragraph, which I can do with the caret metacharacter. Because a location can't actually be changed, this isn't enough for me to carry out what I need to do. I also need to describe the first letter at the beginning of that paragraph. But I'm going to need to remember what that letter is and ask for it back again when I'm ready to make my changes. So I'm going start a Marking Subexpression with an opening parenthesis and put the any character meta character in it and close off the Subexpression with a closing parentheses.

So I'm asking for one single character that exists at the beginning of a paragraph but not any paragraph, only paragraphs that use the Country Paragraph Style. So I need to go down and specify formatting attributes to find. Click this icon here and I'm going to select my Country Paragraph Style and click OK. Now I've defined any character at the beginning of a line using the Country Paragraph Style. So, I'm ready to start writing my Change Expression.

What I'm trying to insert is a Graphic Frame. I've copied it to the Clipboard, but I can't just paste it into the Change to field. It doesn't work that way. However, there is a little known meta character in both Text Find/Change and GREP Find/Change that I can use to accomplish the same thing. From the Special characters for replace menu, I'll go to the Other submenu and I'm going to choose Clipboard Contents, Formatted. This is the only way, in InDesign, where you can actually use Text-based Find/Change to put in anything you want.

It could be a Graphic Frame, like I'm trying to do. It could be a Stroke. It could be another Text Frame. It could be anything that's copied to the Clipboard. So I will choose Clipboard Contents, Formatted. It puts in the tilde C meta-character. But I also want to recall the first letter that I defined up here in that paragraph and put it back. So after the Clipboard contents metacharacter, I'll go to the Special characters menu to Found and choose Found Text 1, the first Subexpression in here, the first bit of Found Text.

I'm asking for that back and it's going to be put back in, preceded by this anchored Text Frame. Let's try a test, and I'm going to do the first one. So it's found what I've described, any character at the beginning of a paragraph that's using the Country Paragraph style. I am going to click Change and let's see what we get. It's inserted my object above that line and replaced that first character that it's found. Let's click Find Next just to be sure. It's finding what I want. I'll click Change and it's changing what I want.

So I'm confident that I have structured this Find/Change operation to do exactly what I want, consistently, through the document. Just to make sure I don't accidentally repeat inserting those in the two instances where I've already put it in, I'm going to click into the text in the frame on the page. And then I'm going to go back to Find /Change and change my search criteria to To End of Story. And now, I'm going click Change All and InDesign will process this for a moment, and it's processed to 164.

Let's click OK and there you can see them on the page. Let me zoom out and go to page 1 in this document and there's 166 anchored Text Frames placed in a precise location through out a multi-page document using one Find/Change operation. So, now I've got 166 placeholder frames exactly where I want them, ready to start to receive graphics. I'm going close the Find/Change dialog because I've gone as far as I can go in this process using Find/Change and GREP.

But let's just take a look at how you would finish this off, starting with say, the first 10 flags. I'll choose File>Place and from the Links folder, I'll select the first piece of flag art in the list by clicking its name and Shift+Clicking on the last name in the list to select all 10. I'm going to turn-off Show Import options because I want to see 10 successive Show Import options dialogs when I do this. Now I'll click Open and I get InDesign's loaded multi-file place gun and a preview of the first of the 10 images that I'm ready to place.

I can just hover over one of the frames that I placed using GREP earlier, click in that, and it automatically places the art and sizes it to the frame. I'll go ahead and click the next one and the next one and the next one, so on and so on. And this is exactly how I would go about finishing off this project if I was going to take it to conclusion and do all 166 countries. So let's just review what we've done here. We've used GREP Find/Change to identify a specific location within text that uses a specific paragraph style.

We've also used it to insert objects pasted to the Clipboard as anchored objects within that text. After that, that's as far as we could go with Find/Change, but we were able to take advantage of other InDesign features to drop in multiple images throughout a project.

Find answers to the most frequently asked questions about Learning GREP with InDesign .


Expand all | Collapse all
please wait ...
Q: In the “Dynamically fixing orphaned words with GREP” tutorial the author uses the term:
(?<=\w)\s(?=\w+[[:punct:]]+$)
In an earlier course the author described the + (one or more) modifier as unusable in a lookbehind or lookahead i.e. (?<=.+). What's the difference here?
A: The limitation mentioned in an earlier movie referred only to positive lookbehind and negative lookbehind. I was able to use the one or more times (+) metacharacter in the positive lookahead portion of the expression because that limitation doesn't affect either positive or negative lookahead. It's only when looking backward that GREP ignores the repeat metacharacters.
 
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ .

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now Already a member? Log in

* Estimated file size

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Learning GREP with InDesign.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member ?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferences from the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Learn more, save more. Upgrade today!

Get our Annual Premium Membership at our best savings yet.

Upgrade to our Annual Premium Membership today and get even more value from your lynda.com subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.