11 Replies Latest reply on Jan 2, 2013 9:21 AM by peter minneapolis

    GREP Style : Find second occurrence of a word on the page and style it

    garek007 Level 1

      Hi,

      I've been searching for this for hours, but I'm running out of time and so I thought I'd ask for help. I have a Table of contents and within each chapter I want to list the pages at the top (like a running header). A running header woudl be easy enough, but I want to show all pages in that chapter in grey, with the current page in black and bold (the page the reader is on is highlighted, like a website).

      I figured the only way to do this was using a GREP expression that would look for the page title in a certain paragraph style, then find the second occurrence of that word or phrase and style it using a character style.

      If there's a better way please let me know, but I can't see how to get this done any other way.

      Thanks,

      Stan

        • 1. Re: GREP Style : Find second occurrence of a word on the page and style it
          Peter Spier Most Valuable Participant (Moderator)

          I'm having trouble visualizing what you want to do. Can you give us a screen shot of a mockup? I'm having a lot of trouble figuring out what a TOC has to do with a running header.

           

          For a running header that needs multiple styles it is possible to use the character style version and apply the same or different character styles to the words you want to pick up (which can be applied by use of a grep style, if you want to apply it to all instances of that word in a paragraph). You could then, for example pick up boththe first occurrence and last occurrence of your styled word on the page using running header variables and format them differently.

          • 2. Re: GREP Style : Find second occurrence of a word on the page and style it
            garek007 Level 1

            I'm sorry. Look along the top. The grey text is each page in the chapter (I'm building a brand book). I want the page they are on to be bold and black to indicate which page they are looking at and which pages also exist in the chapter. Make sense?

            7.jpg

            • 3. Re: GREP Style : Find second occurrence of a word on the page and style it
              John Mensinger Adobe Community Professional & MVP

              I figured the only way to do this was using a GREP expression that would look for the page title in a certain paragraph style, then find the second occurrence of that word or phrase and style it using a character style.

              Hmmm...

               

              I'm pretty certain you won't be able to set up a GREP style to do that, seeing as they operate from within a single paragraph style and can't interpret findings on a page-wide basis.

               

              You may have a shot with multiple chapter-specific GREP searches, (find/replace), but formulating and executing that might not be much quicker than just doing it manually. How big is the book?

              • 4. Re: GREP Style : Find second occurrence of a word on the page and style it
                garek007 Level 1

                Book is probably not big enough to justify a GREP style, I just like to do things the hard way . Still would be cool if it could do this. Probably could write a script to do this, but the book is only about 30 pages, so like I said probably not worth it.

                • 5. Re: GREP Style : Find second occurrence of a word on the page and style it
                  garek007 Level 1

                  Peter, can you explain what you listed at the bottom of your post a little more elaborately? Sounds like it might work, but I don't quite follow.

                  • 6. Re: GREP Style : Find second occurrence of a word on the page and style it
                    Peter Spier Most Valuable Participant (Moderator)

                    I don't think it's going to work at all. What I mentioned in my previous post was the ability to appy a character style to any word of your choice uing a grep style, the word logo, for example, and you could then use running header (character style) variables to pick up boththe first and last instances of that word on the page, and you could apply differnt formatting to the two variables, but that isn't going to help here.

                     

                    I would approach this by making a master page with the header styled in gray, then on each document page override the header and apply the bold black character style to whichever piece is appropriate manually.

                    • 7. Re: GREP Style : Find second occurrence of a word on the page and style it
                      garek007 Level 1

                      That's what I'll do then, bummer though because any changes I go back and make on the master don't show up on the pages. That's why I was trying to avoid breaking that link.

                      • 8. Re: GREP Style : Find second occurrence of a word on the page and style it
                        Peter Spier Most Valuable Participant (Moderator)

                        You can wait until the editing is final to do any overrrides....

                        • 9. Re: GREP Style : Find second occurrence of a word on the page and style it
                          peter minneapolis Level 4

                          Thanks for the idea kernel, Peter S!

                           

                          It's got me thinking of:

                           

                          * A single master page with gray text for all category titles, on which text frames that contain running header text variables overlie each title. Each title has a unique paragraph or character format for a matching unique running header to capture. The text variables are set to display their captured text in bold. The "trick" is to make sure the captured titles align completely over their gray background text frame. Perhaps a tiny gray stroke on the bold captured text, or a tiny white stroke on the gray background text, would work like a trap to avoid bleeding edges. Or, slightly larger or smaller text sizes, like .05 pt?

                           

                          [EDIT]Ooops! It'll be very hard to align the bold running header text variables over the gray text. Instead:

                           

                          * Create the master page title text items each in its own text frame. Copy these frames and paste in place on top of the original frames. Create a paragraph style for the bold headers that includes a Paper colored paragraph rule below, the width of the text, height and offset sufficient to overlie the background gray title. Insert the unique running header text variables in each frame. Each captured running header will block the gray text behind it. The Paper paragraph rule blends with the page background. [/EDIT]

                           

                          Peter Spier wrote:

                           

                          I don't think it's going to work at all. What I mentioned in my previous post was the ability to appy a character style to any word of your choice uing a grep style, the word logo, for example, and you could then use running header (character style) variables to pick up boththe first and last instances of that word on the page, and you could apply differnt formatting to the two variables, but that isn't going to help here.

                           

                          I would approach this by making a master page with the header styled in gray, then on each document page override the header and apply the bold black character style to whichever piece is appropriate manually.

                          HTH

                           

                           

                          Regards,

                           

                           

                          Peter

                          _______________________

                          Peter Gold

                          KnowHow ProServices    

                           

                          Message was edited by: peter at knowhowpro

                          • 10. Re: GREP Style : Find second occurrence of a word on the page and style it
                            garek007 Level 1

                            Thanks Peter G. I am not sure that will help though because it sounds like just as much work as activating the running header on every page and styling the element. I was looking for a quick and easily updatable answer to my problem, but it seems like it doesn't exist.

                            • 11. Re: GREP Style : Find second occurrence of a word on the page and style it
                              peter minneapolis Level 4

                              Try a quick test and decide. My test wasn't much of a challenge. It's self maintaining.

                               

                              You can try out a commercial third-party script that applies master pages based on the presence of a style on a page, from freelancebookdesign.com. You need to remember to run the script, of course.

                               

                               

                              HTH

                               

                               

                              Regards,

                               

                               

                              Peter

                              _______________________

                              Peter Gold

                              KnowHow ProServices    

                               

                              garek007 wrote:

                               

                              Thanks Peter G. I am not sure that will help though because it sounds like just as much work as activating the running header on every page and styling the element. I was looking for a quick and easily updatable answer to my problem, but it seems like it doesn't exist.