14 Replies Latest reply on Oct 20, 2016 12:52 AM by Spenno

    Horizontal alignment of text in InDesign

    Spenno Level 1

      Hi there. I have a question regarding horizontal alignment in InDesign.

      I have books of short poems (one per page) where the text needs to be left aligned. Easy enough! But the frame on each page needs to be centred on that page! So for example if a poem has ten lines each containing only a few words, the poem appears quite far to the left of the page. It's an aesthetic thing.

      I did wonder about individual text frames anchored within the main story, which involves a lot of copy-pasting. I'm suspecting a script is my best bet?

        • 1. Re: Horizontal alignment of text in InDesign
          Peter Spier Most Valuable Participant (Moderator)

          Some screen shots would help a lot to explain the problem....

          • 2. Re: Horizontal alignment of text in InDesign
            Spenno Level 1

            Sure, here are some screen grabs of the unaltered pages and then the ideal outcome. First the original spread with both pages left aligned.

            align_issue.png

            And below the 'ideal' layout for these pages. You can see how the left-hand poem appears further to the right, and the right-hand poem a touch to the left, in order to get both to appear more central horizontally.

            align_ideal.png

            • 3. Re: Horizontal alignment of text in InDesign
              John Mensinger Adobe Community Professional & MVP

              Okay, so it has more to do with line-length than anything. To get what you seek, here's what I'd do:

               

              Assuming all the line breaks are manually imposed (as I expect they'd have to be), and will persist, I'd center each text frame on the page, remove any left/right indents, then in Text Frame Options, set all insets to 0 and apply these Auto-Size settings:

              This can all be done en masse using Find/Change.

              • 4. Re: Horizontal alignment of text in InDesign
                Spenno Level 1

                That looks promising, but maybe I should have mentioned we are using CS5.5 not 6, so I don't have that Auto-Size feature

                Is it similar to Margins and Columns>Enable Layout Adjustment?

                • 5. Re: Horizontal alignment of text in InDesign
                  BarbBinder Adobe Community Professional

                  Is it similar to Margins and Columns>Enable Layout Adjustment?

                  No. Layout-adjustment was used to resize/reposition frames in a layout when the margins, columns or paper size was updated.

                  • 6. Re: Horizontal alignment of text in InDesign
                    John Mensinger Adobe Community Professional & MVP

                    Spenno wrote:

                    That looks promising, but maybe I should have mentioned we are using CS5.5 not 6, so I don't have that Auto-Size feature

                    Ack. Add this to your unwritten list of reasons to upgrade.

                    Is it similar to Margins and Columns>Enable Layout Adjustment?

                    No, not really.

                    • 7. Re: Horizontal alignment of text in InDesign
                      Peter Spier Most Valuable Participant (Moderator)

                      Perhaps a script to fit frame to content and position the frame centered? You could also do that in a roundabout way by putting the poem into a left aligned frame, then making that an anchored object in a larger frame with center alignment.

                      • 8. Re: Horizontal alignment of text in InDesign
                        [Jongware] Most Valuable Participant

                        This sounds familiar; and a quick Google query indeed turned up:

                         

                        http://indesignsecrets.com/setting-poetry-flush-left-center-on-longest-line.php

                        • 9. Re: Horizontal alignment of text in InDesign
                          Obi-wan Kenobi Adobe Community Professional

                          Hi Jongware,

                           

                          Too cool, as usual! Thanks for it! 

                           

                          As I saw in Spenno's screenshots (independent text frames], I've, humbly, added a loop to play all the poems in one click!

                          For love of laziness (and unfortunately not of poetry)! 

                           

                          /*
                          Original script written by Jongware [16/02/2011]
                          See his comment in:
                              Setting Poetry, Flush Left, Center on Longest Line, by David Blatner [16/02/2011]
                              http://indesignsecrets.com/setting-poetry-flush-left-center-on-longest-line.php, 
                          See topic:
                              https://forums.adobe.com/thread/2224183 [19/10/2016]
                          */
                          
                          
                          var myDoc = app.documents.item(0);
                          app.findGrepPreferences = app.changeGrepPreferences = null;
                          app.findGrepPreferences.findWhat = "(?s).+";
                          mySelection = myDoc.findGrep();
                          
                          
                          for(var i = 0; i < mySelection.length; i++){
                              p = mySelection[i];
                              s = p;
                              pos = 1e9;
                              do
                              {
                              p.leftIndent = 0;
                              l = p.insertionPoints[0].horizontalOffset;
                              p.justification = Justification.CENTER_ALIGN;
                              if (p.insertionPoints[0].horizontalOffset-l < pos)
                              pos = p.insertionPoints[0].horizontalOffset-l;
                              p.justification = Justification.LEFT_ALIGN;
                              } while ((p = p.parentStory.paragraphs.nextItem(p)) != null && p.contents.length > 1);
                              do
                              {
                              s.leftIndent = pos;
                              } while ((s = s.parentStory.paragraphs.nextItem(s)) != null && s.contents.length > 1);
                          } 
                          

                           

                           

                          (^/)

                           

                          Just a question:  why do you use this code (because 1e9 = 1000000000, and so a very big number!)?

                           

                              pos = 1e9;
                          

                           

                           

                          Thanks in advance! 

                          • 10. Re: Horizontal alignment of text in InDesign
                            [Jongware] Most Valuable Participant

                            Obi-wan, I have no idea. Usually, when you have to compare a set of values, you need to start with an unlikely high or low value. But in this case it's a simple assignment. I guess I started out with a comparison and decided later on that I did not need it after all. ... C'mon, it has been 4 years since then

                             

                            (I'm also not quite sure anymore from whence came that haiku ...)

                            • 11. Re: Horizontal alignment of text in InDesign
                              Obi-wan Kenobi Adobe Community Professional

                              Thanks! 

                               

                              I've modified your script (just a little!) to take in account the soft-return at line-end:

                               

                              Before:

                               

                              Capture d’écran 2016-10-19 à 22.11.59.png

                               

                              After:

                               

                              Capture d’écran 2016-10-19 à 22.12.23.png

                               

                              /*
                              Original script written by Jongware [16/02/2011]
                              See his comment in:
                                  Setting Poetry, Flush Left, Center on Longest Line, by David Blatner [16/02/2011]
                                  http://indesignsecrets.com/setting-poetry-flush-left-center-on-longest-line.php, 
                              See topic:
                                  https://forums.adobe.com/thread/2224183 [19/10/2016]
                              */
                              
                              
                              var myDoc = app.documents.item(0);
                              app.findGrepPreferences = app.changeGrepPreferences = null;
                              app.findGrepPreferences.findWhat = "(?s).+";
                              mySelection = myDoc.findGrep();
                              
                              
                              for(var i = 0; i < mySelection.length; i++){
                                  p = mySelection[i];
                                  s = p;
                                  pos = 1e9;
                                  do
                                  {
                                  p.leftIndent = 0;
                                  l = p.insertionPoints[0].horizontalOffset;
                                  p.justification = Justification.CENTER_ALIGN;
                                  if (p.insertionPoints[0].horizontalOffset-l < pos)
                                  pos = p.insertionPoints[0].horizontalOffset-l;
                                  p.justification = Justification.LEFT_ALIGN;
                                  } while ((p = p.parentStory.paragraphs.nextItem(p)) != null && p.contents.length > 1);
                                  do
                                  {
                                  s.leftIndent = pos;
                                  s.rightIndent = pos;
                                  } while ((s = s.parentStory.paragraphs.nextItem(s)) != null && s.contents.length > 1);
                              } 
                              
                              
                              app.findGrepPreferences = app.changeGrepPreferences = null;
                              app.findGrepPreferences.findWhat = "\n";
                              app.changeGrepPreferences.changeTo = "\n~y";
                              myDoc.changeGrep();
                              app.findGrepPreferences = app.changeGrepPreferences = null;
                              

                               

                               

                              (^/)

                              • 12. Re: Horizontal alignment of text in InDesign
                                donayer Level 1

                                Wacky. I had to do this exact same thing recently for a client still stuck using 5.5. I set the whole 200+ page poetry book in CC with autosize boxes. After their first review, I exported to IDML and converted it to 5.5 for the rest of the review rounds. Of course it lost the autosize feature, but it did maintain the custom box sizes through the conversion. Thankfully, the edits were light and I didn't have to resize anything manually.

                                • 13. Re: Horizontal alignment of text in InDesign
                                  Obi-wan Kenobi Adobe Community Professional

                                  Not easy to do this kind of layout with autosized text frames!  … but there will always be someone to try!

                                   

                                  Jongware's code will do it in 1 second, for 2 or 1,000 pages!

                                   

                                  Capture d’écran 2016-10-20 à 00.48.08.png

                                   

                                  In everyday language, Ockham's razor could be expressed by the phrase:

                                   

                                                  "Why complicate things when they can be simple?"

                                   

                                  Simplicity does't mean that the most simplistic assumption (without pejorative connotation!), the most obvious or the most conventional is necessarily good!

                                   

                                  Just think different! …

                                   

                                  (^/)

                                  • 14. Re: Horizontal alignment of text in InDesign
                                    Spenno Level 1

                                    Thanks Jongware and everyone else for these very informative replies! I installed that script and ran it on a simple test book, and it appears almost perfect ... except for the very shortest poems such as the one on the left page, which are still not centred horizontally. I made the pages 2 columns with no gutter to create a centre line as a guide and wondered if that was interfering, but it happened when I removed that too.

                                    Poem examples.png