10 Replies Latest reply on Feb 1, 2015 2:14 PM by Eiranix

    Different Style on Last Paragraph?

    Eiranix Level 1

      I have a style that sets a paragraph rule below each paragraph to act as a divider. I need to apply this in many paces, however I would like the last paragraph in each section to have no rule. Is this possible?

      I don't want to have to apply a different style to the last paragraph in each section because the text is regularly updated...

        • 1. Re: Different Style on Last Paragraph?
          Peter Spier Most Valuable Participant (Moderator)

          It would be relatively easy to use find/change to identify the last paragraph in a story, but I can't think of an automatic way to determine if a paragraph is the last, and once you change the style (and I think that, too, is a given) there is no automatic way to "unchange" if if more text is added a the end.

          • 2. Re: Different Style on Last Paragraph?
            Eiranix Level 1

            It would be really easy using a GREP style, but for reasons unknown, it only allows you to set a Character Style and not another Paragraph Style...

            • 3. Re: Different Style on Last Paragraph?
              Peter Spier Most Valuable Participant (Moderator)

              Not reasons unknown. GREP styles are designed to apply character styles to selected text within a paragraph, not to alter an entire paragraph.

              • 4. Re: Different Style on Last Paragraph?
                Eiranix Level 1

                What I mean is, the mechanic is there, but they have chosen to only allow character styles which is unnecessarily limiting.

                • 5. Re: Different Style on Last Paragraph?
                  TᴀW Adobe Community Professional & MVP

                  What do you mean "the last paragraph in the section"? What, in your

                  case, is a "section"?

                  • 6. Re: Different Style on Last Paragraph?
                    Eiranix Level 1

                    Just wherever I have applied that paragraph style.

                    So for example, I might have a textbox with three paragraphs in which case I'd want 2 paragraph rules in total (ie none at the beginning or end).

                     

                    That is unless there is an entirely different way to achieve this effect?

                    • 7. Re: Different Style on Last Paragraph?
                      rob day Adobe Community Professional & MVP

                      It could be scripted. What OS are you using?

                      • 8. Re: Different Style on Last Paragraph?
                        Peter Spier Most Valuable Participant (Moderator)

                        Which is still not an automated solution. You would need to have the script check to be sure a paragraph that the rule is removed from is still the last paragraph in the frame and restore it if it is not, as well as remove the rule from any new "last" paragraphs, and it would need to be run after every edit.

                         

                        I'm curious, too, now that this seems to be a frame-based rather than story-based request, how one deals with a paragraph split between frames?

                        • 9. Re: Different Style on Last Paragraph?
                          rob day Adobe Community Professional & MVP

                          Which is still not an automated solution...it would need to be run after every edit.

                           

                          Right it wouldn't be completely automatic, but you wouldn't have to run it after every edit—just after the final edit.

                           

                          It isn't clear if the text is flowing between frames, the OP's #6 makes it sound like it's 1 frame. If it is flowing you can check if a paragraph's last line is the last line of a frame, so it still could be done with flowing text.

                           

                          So this AppleScript gets every story in the document and checks the story's paragraphs. If the paragraph has a style sheet applied with rule below on and it's the last paragraph, the rule below gets turned off, otherwise the rule gets turned on.

                           

                          ---------------------------------------

                          tell application "Adobe InDesign CC 2014"

                              tell active document

                                 

                                  --get the document stories

                                  set s to every story

                                  repeat with x in s

                                     

                                      --check each paragraph

                                      set ps to object reference of every paragraph of x

                                      repeat with i from 1 to count of ps

                                          set p to item i of ps

                                         

                                          --if it's the last paragraph and the p style has a rule below set it to off, else make sure it is on

                                          if i is equal to (count of ps) then

                                              if rule below of applied paragraph style of p then set rule below of p to false

                                          else

                                              if rule below of applied paragraph style of p then set rule below of p to true

                                          end if

                                      end repeat

                                  end repeat

                              end tell

                          end tell

                          • 10. Re: Different Style on Last Paragraph?
                            Eiranix Level 1

                            A script like that looks like the best solution, thanks. Unfortunately I'm on windows so I'll need to figure out how to translate that to javascript!

                             

                            In response to the split paragraph question, none of it will be flowing so that won't happen in this case.