9 Replies Latest reply on Dec 3, 2013 12:01 PM by Peter Spier

    GREP Styles, format the last line before a page break

    Scorpio17523 Level 1

      Hi all,

       

      I'm trying to learn to use GREP Style in the Paragraph Styles sheets to help my company save some time when formatting.

       

      A lot of us use linked text boxes to include information across 4 - 8 pages.

       

      This information mainly contains headers, sometimes with a subheader and then a body of text.

       

      A HEADER has one particular style (e.g. all caps and in bold)

      A sub header = just in bold

      Body text = normal font (regular)

       

      I've developed some GREP expressions that formats this how it needs to be by identifying the patterns however I need some help in perfecting it.

       

      If a header is the last line before a page break, GREP sees it as body text and doesn't format it.

       

      If anyone could assist in this it would be much appreciated.

       

      Below I will type a basic example of what needs to be formated.

       

       

       

      HEADER (Bold all caps)

       

       

      HEADER (Bold all caps)

      Sub Header (Bold)

       

      Body (Regular)

      Body (Regular)

      Body (Regular)

       

       

      HEADER (Bold all caps) (PAGE BREAK)

       

      NEW PAGE

       

      HEADER (Bold all caps)

       

       

      HEADER (Bold all caps)

      Sub Header (Bold)

       

      Body (Regular)

      Body (Regular)

      Body (Regular)

       

      HEADER (Bold all caps) (END OF STORY)

        • 1. Re: GREP Styles, format the last line before a page break
          Peter Spier Most Valuable Participant (Moderator)

          I'm not sure you can do what you want to do with GREP styles (because I think you intend to apply paragraph styles based on the formatting, but perhaps I'm not reading this correctly).

           

          GREP styles defined as part of a Paragraph Style can ONLY apply a defined character style to the matching text. They cannot change the text, nor apply a different paragraph style. To change paragraph styles you would need to use Find/Change.

           

          Are your page breaks "real" breaks, or are they automatic breaks? Real breaks would be those you enter deliberately, and ~P is the GREP term to find them. Automatic breaks are those ID makes when the frame is full and aren't really there at all. What expression are you using now to find HEADER text?

          • 2. Re: GREP Styles, format the last line before a page break
            Scorpio17523 Level 1

            Hi Petere,

             

            Thank you for your reply.

             

            I'm using real breaks.

             

            I don't want the expression to change anything, simply apply a character style which is already set up.

             

            My expressions may be wrong but this is what I have so far.

             

            .+\n

             

            I've been playing around with how to define the difference between headers and body text and at the moment I've been switching between using hard (normal) and soft returns (forced line breaks)

             

            For sub headers (see original post) which following on the next line from a header, I'm currently using this expression

             

            \n.+\n

             

            Each of these expressions apply a different character style.

             

            My problem is, if I have a header on it's own at the bottom of a page followed by a forced page break a style isn't applied. I've tried ~P and it won't work e.g.

             

            .+~P

             

            Am I missing something? I've even tried Positive Lookaheads but that doesn't work either.

            • 3. Re: GREP Styles, format the last line before a page break
              Peter Spier Most Valuable Participant (Moderator)

              So your headers and sub-heads are divided by forced line breaks (\n) and are not separate paragraphs?

               

              Can you show us a screen shot of an actual page, with non-printing characters showing?

              • 4. Re: GREP Styles, format the last line before a page break
                Scorpio17523 Level 1

                Ok, I've found out the reason why it wasn't working... It wasn't a page break I was using, it was a column break.

                 

                The problem I have now is with the expression

                 

                .+~M

                 

                it only applies the style to the first 2 character before the coloum break.

                 

                How can I write the expression to include all the characters on that line? (As it was my understanding that .+ meant any character that repeats 1 or more times.)

                • 5. Re: GREP Styles, format the last line before a page break
                  Peter Spier Most Valuable Participant (Moderator)

                  .+ should match everything from the beginning of the paragraph, including forced linebreaks. The order of your GREP styles is going to be very important.

                   

                  Frankly, I don't think this is a good way to do your work. Headings, subheadings, and body text ought, in my opinion, to each be separate paragraphs, and each have a pragraph style. Nor would I ever leave a heading at the bottom of a column or page, separated from the content to which it refers.

                  • 6. Re: GREP Styles, format the last line before a page break
                    Scorpio17523 Level 1

                    I completely understand what you mean regarding formatting. Normally I wouldn't do this, especially for a document.

                     

                    They are Order of Service sheets for funeral homes. So when I say headers, I mean things like Tribute, Eulogy etc. They are simple 4 page booklets e.g.

                     

                    Welcome and Opening Prayers (Header)

                     

                     

                    Hymn (Header)

                    All Things Bright And Beautiful (Sub Header)

                     

                    Hymn lyrics (Body)

                    Hymn lyrics (Body)

                    Hymn lyrics (Body)

                    Hymn lyrics (Body)

                     

                     

                    Tribute (Header)

                    John Smith (Body)

                     

                     

                    Eulogy (Header) (Column Break)  ------  When I use the GREP expression .+~M here only 'gy' of Eulogy get the style applied to them.

                     

                    (New Column/Page)

                     

                    Prayers (Header)

                     

                     

                    The Lord's Prayer (Header)

                    The Lord's Prayer Text (Body)

                    The Lord's Prayer Text (Body)

                    The Lord's Prayer Text (Body)

                     

                     

                    Closing Music (Header)

                    Title by Artist Name (Body)

                    • 7. Re: GREP Styles, format the last line before a page break
                      M-S-Miller Level 1

                      While I agree with Peter Spier that the best way would be to have these as each their own paragraph, if you are stuck with them all in one paragraph, wouldn't Nested Styles be a better answer? In the "Dropcaps and Nested Styles" at the bottom is a section for nested line styles. First line is Header. Second line is Subheader. Hope that helps.

                      • 8. Re: GREP Styles, format the last line before a page break
                        Scorpio17523 Level 1

                        Yes I agree, these are ways I could do it if it was always the same, but these orders change and they are never in the same order.

                         

                        Yes, nested style would work if I had different paragraph styles set up for each type of section. The problem is we already have character styles set up and it's just as quick to select the headings and apply the character style (using shortcuts). These aren't 20+ pages, just short 4 - 8 page booklets and I was trying to find a way to select all the text inside the document and format it instantly and I'm already able to do this with what I've setup with GREP so far.

                         

                        My problem at the moment is now when I use .+~M it only applies the style to the last 2 characters on the line. I've even set up a brand new paragraph style sheet with only 1 GREP style so that no others can conflict with it (as I'm aware the order is important), and it still wont work.

                         

                        Can anyone help me understand why?