18 Replies Latest reply on Apr 3, 2017 2:35 PM by rubikluk8

    Poetry book text formatting

    rubikluk8

      I'm currently working on a poetry book layout and I came up with this struggle:

      I have some long lines that don't fit in a single line and (without changing paragraph) and I'd like to have all of those extra lines automatically being right justified.

      I tried using nested line style, but I only manage to apply a different Character Style (not a paragraph one) on the second line.

      Is there a way to achieve what I need without having to manually format every "exceeding line"?

      To say it in other words I need to have all lines longer than the text box right justified.

      I hope I was clear enough (if not sorry, english is not my mother tongue).

        • 1. Re: Poetry book text formatting
          Steve Werner Adobe Community Professional & MVP

          It couldn't be done using the InDesign interface. It might be done using either GREP or scripting. However, since I'm not fluent in either, I'll leave it to those experts to reply.

          1 person found this helpful
          • 2. Re: Poetry book text formatting
            DBLjan Level 2

            Is there an way to estimate roughly how much characters a line/width fits? Some fonts have same space for every char, but I guess thats not poetry rather than code

            • 3. Re: Poetry book text formatting
              rubikluk8 Level 1

              I'm not using a monospaced font, but approximately every line is about 50 characters (it can be 48 or 55, depending on punctuation...)

              • 4. Re: Poetry book text formatting
                DBLjan Level 2

                Ehm, my first attemp/question – dead end.

                 

                But a script could do:

                Find out which paragraph exceeds the textframe. Scripters can tell you, if theres a value for this, or if you have to find out the hard way: Compare first characters baseline y with the last character baseline y. If they differs, your line exceeds the textframe – now the script could apply another paragraph style for the right alignment.

                1 person found this helpful
                • 5. Re: Poetry book text formatting
                  rubikluk8 Level 1

                  DBLjan

                  Now it seems I need a helping hand from a scripter...

                  I never tried to script, I have no idea where to start...

                   

                  Suggestions?

                  • 6. Re: Poetry book text formatting
                    Steve Werner Adobe Community Professional & MVP

                    If you don't get a reply here, post in the InDesign Scripting forum here:

                     

                    InDesign Scripting

                    1 person found this helpful
                    • 7. Re: Poetry book text formatting
                      [Jongware] Most Valuable Participant

                      Are the full lines fully justified? If so (or it isn't but you don't mind), then you can set the global paragraph alignment to "Right Justify". It's kind of an awkward name, but it will do what you want: justify all full lines, and put the last line on the right side (the default, for regular text, is to the left).

                       

                      Lines that wrap to a second line are justified, and only single lines that are very nearly full width are justified as well.

                       

                      Give it a try and see if you can spot the difference.

                      • 8. Re: Poetry book text formatting
                        rubikluk8 Level 1

                        The full text is left justified.

                        The option you suggest is not what I'm looking for, because, being a poetry book a lot of lines are short and they have to be left justified.

                        It's only a minority of them that, only when they exceed the textframe, they need to be right justified...

                        See attached picture as reference.

                        IMG_8608.JPG

                        • 9. Re: Poetry book text formatting
                          Obi-wan Kenobi Adobe Community Professional

                          Poetry means one line per worm, so one para!

                          If a worm has too much chars for one line, we'll have 2 lines!

                          So, as no hyphenation, a script could compare the baselines of the first char/last char!

                          If different, it could catch the first first char of the 2nd line and add 2 right indent tabs + a bracket + a space!

                           

                          Simple as The Force playing with Javacript! 

                           

                          (^/)

                          • 10. Re: Poetry book text formatting
                            vinny38 Level 4

                            I like the translation of "Vers" to "Worms"...

                            Maybe Verse would be more appropriate ^^

                             

                            Anyhow, I think this is a very interesting question...and I'm looking forward to see you coming up with a great script. Piece of cake for you, cher Obiwan ^^

                             

                            I was wondering if it couldn't be achieved by a GREP query catching the extra words after a given number of characters (lets say 50)

                            Something like (?<=^.{50,51}\w+\b)\s\w+

                            But I can't make it work

                            I fully understand this would not be as clean and accurate than a script, but for my personal information, I'd love to understand why this query fails to catch anything...

                            • 11. Re: Poetry book text formatting
                              Obi-wan Kenobi Adobe Community Professional

                              Hi Vincent! I'm a great fan of Dune! It remembers me Tatooine! 

                               

                              (^/)

                              • 12. Re: Poetry book text formatting
                                Obi-wan Kenobi Adobe Community Professional

                                Use \K

                                 

                                (^/)

                                • 13. Re: Poetry book text formatting
                                  rob day Adobe Community Professional & MVP

                                  To say it in other words I need to have all lines longer than the text box right justified.

                                  It should be easy to script. This AppleScript (OSX only) right justifies any paragraph in the selected text with more than two lines.

                                   

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

                                  tell application "Adobe InDesign CC 2014"

                                      set p to object reference of every paragraph of selection

                                      repeat with x in p

                                          if (count of lines in x) is greater than 1 then

                                              set justification of x to right justified

                                          end if

                                      end repeat

                                  end tell

                                   

                                   

                                  So it does this:

                                  Screen Shot 2017-04-03 at 8.03.57 AM.png

                                   

                                   

                                   

                                  You could also consider a negative first line to left indent, which wouldn't need a script. Something like this:

                                   

                                  Screen Shot 2017-04-03 at 7.58.09 AM.png

                                  1 person found this helpful
                                  • 14. Re: Poetry book text formatting
                                    vinny38 Level 4

                                    Ah cool! I didn't know that one...

                                    Unfortunately, Grep query applies "right" paragraph style to both $1 and $2

                                    Hopefully one day, I'll stop being a Padawan...

                                     

                                    grep.gif

                                    • 15. Re: Poetry book text formatting
                                      Obi-wan Kenobi Adobe Community Professional

                                      Well! Tested on "Les Fables de La Fontaine", 1 click with Grep!

                                       

                                      Capture d’écran 2017-04-03 à 17.23.41.png

                                       

                                      (^/)

                                      • 16. Re: Poetry book text formatting
                                        rubikluk8 Level 1

                                        I have to underline that I'm a complete newbie in scripting and grep styles...

                                        I tried to do the apple script that rob day suggested me and it seems to work.

                                        I also tried vinny38 grep expression but with no luck (and being a noob I have no idea why).

                                        Obi-wan Kenobi grep is almost perfect but it has a little problem: it puts the "[" sign before the first line instead to put it before the second one...

                                        Am I missing something?

                                        Can I ask you some link for a poor noob to learn how Grep styles expressions work?

                                         

                                        Thanks in advance...

                                        • 17. Re: Poetry book text formatting
                                          Obi-wan Kenobi Adobe Community Professional

                                          It works fine for me! [ Tested before I post it!  ]

                                           

                                          What I didn't say [obvious for me!] is that you need to include 2 "Nested line styles" in your para style to make this regex work! 

                                           

                                          Try this:

                                           

                                          /*
                                              0138_Poetry2Lines_MichelAllio.jsx
                                              Script written by Michel Allio [2017/04/03]
                                              See: https://forums.adobe.com/thread/2298581 [ Poetry book text formatting ]
                                          */
                                          
                                          
                                          app.doScript("main()", ScriptLanguage.javascript, undefined, UndoModes.ENTIRE_SCRIPT, "Poetry 2 Lines! …");
                                          
                                          
                                          function main()     
                                              {
                                                  var myStories = app.activeDocument.stories.everyItem().getElements(),
                                                  S = myStories.length;
                                                  while (S--) {           
                                                      var myParas = myStories[S].paragraphs.everyItem().getElements(),
                                                      P = myParas.length;
                                                      while (P--) if ( myParas[P].appliedParagraphStyle.name == "myPStyle" && myParas[P].lines.length > 1 ) myParas[P].lines[1].contents = "\u0008\u0008\[ " + myParas[P].lines[1].contents;
                                                  }
                                              }
                                          

                                           

                                          Just change myPStyle by your para style name!

                                           

                                          (^/)

                                          • 18. Re: Poetry book text formatting
                                            rubikluk8 Level 1

                                            Exactly what I needed. Thanks a lot.