Skip navigation
Tony Toy
Currently Being Moderated

Prevent Indenting of first paragraphs

Oct 8, 2009 1:15 PM

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

Attachments:
 
Replies
  • Currently Being Moderated
    Oct 8, 2009 1:17 PM   in reply to Tony Toy

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 8, 2009 1:29 PM   in reply to Tony Toy

    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.)

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 8, 2009 1:55 PM   in reply to Tony Toy

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 8, 2009 6:28 PM   in reply to [Jongware]

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 9, 2009 4:38 AM   in reply to [Jongware]

    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);
      }
     }
    }
    
     
    |
    Mark as:
  • Currently Being Moderated
    Oct 9, 2009 5:23 AM   in reply to Tony Toy

    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...

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points