8 Replies Latest reply: Oct 9, 2009 5:23 AM by mariana pineda RSS

    Prevent Indenting of first paragraphs

    Tony Toy

      Hi,

      Is there a way to set the indents to indent all paragraphs EXCEPT first paragraph of a story? As a general rule you don't indent the first paragraph, so i have a style setup without indents which i set on the first paragraph, and an alt style, w/indents, which is used on the rest of the paragraphs.

       

      Is there an automatic way to do this?

       

      Thanks,

      tony

        • 1. Re: Prevent Indenting of first paragraphs
          [Jongware] MVP

          Automatically: no. InDesign does not format any paragraphs automatically (although GREP styles do, for character styles).

           

          You can set the 'with' paragraph as "Next Style" in the 'without' paragraph, and in the 'with' paragraph style, set "Same Style" as its next style. Then select a range of paragraphs and choose "Apply this style, then next" from the Paragraph Style menu.

          • 2. Re: Prevent Indenting of first paragraphs
            Tony Toy Community Member

            Thanks for the quick reply. This saves me some time.

            • 3. Re: Prevent Indenting of first paragraphs
              [Jongware] MVP

              If you know how to use scripts, well, I could whip up a javascript in minutes that goes over your document and changes any 'with' paragraph without a previous 'with' or 'without' to 'without' and any 'without' not preceeded by 'with' or 'without' to 'with'. With out, I mean without a problem. (Sorry, ran out of my withs.)

              • 4. Re: Prevent Indenting of first paragraphs
                Tony Toy Community Member

                thanks, i use scripts a great deal. mostly for find+replace type stuff. I think the "apply this + next style" tip you gave me would be suffient. but if you write one i'd be greatful because I could use it for other projects.

                • 5. Re: Prevent Indenting of first paragraphs
                  [Jongware] MVP

                  Here you go, fresh out of TextPad. Be sure to change the style names in the first 2 lines.

                   

                  a = "without";
                  b = "with";if (app.selection.length != 1 || !app.selection[0].hasOwnProperty("baseline"))
                  {
                   alert ("Please click the text cursor in a story before running this script.");
                   exit(0);
                  }
                  try {
                   stylea = app.activeDocument.paragraphStyles.item(a);
                  } catch (e) { }
                  if (stylea == null)
                  {
                   alert ("Eh. Style "+a+" doesn't seem to exist.\nChange the name in this script");
                   exit(0);
                  }
                  try {
                   styleb = app.activeDocument.paragraphStyles.item(b);
                  } catch (e) { }
                  if (styleb == null)
                  {
                   alert ("Oh. Now style "+b+" doesn't exist either.\nChange the name in this script");
                   exit(0);
                  }
                  allpars = app.selection[0].parentStory.paragraphs;
                  for (p=0; p<allpars.length; p++)
                  {
                   if (allpars[p].appliedParagraphStyle == stylea ||
                    allpars[p].appliedParagraphStyle == styleb)
                   {
                    if (p > 0 &&
                     (allpars[p-1].appliedParagraphStyle == stylea ||
                      allpars[p-1].appliedParagraphStyle == styleb))
                     allpars[p].applyParagraphStyle(styleb,false);
                    else
                     allpars[p].applyParagraphStyle(stylea,false);
                   }
                  }
                  

                   

                  Not tested on CS3 or newer, but it oughta work. Supposedly, it changes all occurrences of one of the styles to the 'without' style, except when one of the preceding is one of same. Theoretically, it should leave manual formatting alone, but do a "Save" first just in case.

                  • 6. Re: Prevent Indenting of first paragraphs
                    M.Jay.Victor Community Member

                    You can also apply the paragraph style to an object style and check the "apply with next style" box, then set it to a hotkey.

                    • 7. Re: Prevent Indenting of first paragraphs
                      [Jongware] MVP

                      Hm. It seems to toggle some paragraphs when run more than once! This version is slightly improved:

                       

                      a = "without";
                      b = "with";
                      if (app.selection.length != 1 || !app.selection[0].hasOwnProperty("baseline"))
                      {
                       alert ("Please click the text cursor in a story before running this script.");
                       exit(0);
                      }
                      try {
                       stylea = app.activeDocument.paragraphStyles.item(a);
                      } catch (e) { }
                      if (stylea == null)
                      {
                       alert ("Eh. Style "+a+" doesn't seem to exist.\nChange the name in this script");
                       exit(0);
                      }
                      try {
                       styleb = app.activeDocument.paragraphStyles.item(b);
                      } catch (e) { }
                      if (styleb == null)
                      {
                       alert ("Oh. Now style "+b+" doesn't exist either.\nChange the name in this script");
                       exit(0);
                      }
                      allpars = app.selection[0].parentStory.paragraphs;
                      for (p=0; p<allpars.length; p++)
                      {
                       if (allpars[p].appliedParagraphStyle == stylea ||
                        allpars[p].appliedParagraphStyle == styleb)
                       {
                        if (allpars[p].appliedParagraphStyle != stylea)
                        {
                         allpars[p].applyParagraphStyle(stylea,false);
                        }
                        if (p > 0 &&
                         (allpars[p-1].appliedParagraphStyle == stylea ||
                         allpars[p-1].appliedParagraphStyle == styleb) &&
                         allpars[p].appliedParagraphStyle != styleb)
                        {
                         allpars[p].applyParagraphStyle(styleb,false);
                        }
                       }
                      }
                      
                      • 8. Re: Prevent Indenting of first paragraphs
                        mariana pineda Community Member

                        What is the difference between using this script (it works very fast!!!) or using a paragraph style?

                        I mean in terms of manual operations...

                         

                        Both oblige to insert the cursor in the without paragraph.

                         

                        What is de idea behind this? It seems powerful but I do not know how to use it extensively...