6 Replies Latest reply on Feb 23, 2016 6:01 AM by SaucyRooster

# Calculate line count and add x picas per line to space after

Hello wiz kids,

I'm attempting to setup another document with some styles for Q & A. I've tried to setup a style that is 2 pts shy of the document baseline and want to add the two points back to the space-after depending on the line count. So, bare with me the client is very demanding as far as filling every possible gap with copy, for example say the doc is:

Baseline 12 pt

Body copy 9/12

Questions 8/10

If the line count measures 1 line the space after is 1p2

If the line count measures 2 lines the space after is 1p4

If the line count measures 3 lines the space after is 1p6

If the line count measures 4 lines the space after is 1p8

Is there a way to automagically calculate this and set it in the paragraph style?

MJ

• ###### 1. Re: Calculate line count and add x picas per line to space after

Not automatically, you have to create 4 styles and apply them at the end.

• ###### 2. Re: Calculate line count and add x picas per line to space after

I  have not played with this, but I think you're over-complicating things. It sounds like you want the first line of the paragraphs to align to the baseline grid. Why not just set first line aligns to grid as part of the style?

• ###### 3. Re: Calculate line count and add x picas per line to space after

If I understand well, not sure it can be automatically done, but sure it can be done in one click (and sure it can be easily done with Javascript/Applescript)

… as:

If more than 4 lines, nothing happens! … but, if the op wants, it could happen something!

• ###### 4. Re: Calculate line count and add x picas per line to space after

To be completed, of course!

Selecting the story (no para style researched):

var p=app.selection[0].parentStory.paragraphs;

for (i=0; i<p.length; i++) {

if (p[i].lines.length==1) { p[i].spaceAfter = "2mm" }

}

for (i=0; i<p.length; i++) {

if (p[i].lines.length==2) { p[i].spaceAfter = "4mm" }

}

for (i=0; i<p.length; i++) {

if (p[i].lines.length==3) { p[i].spaceAfter = "6mm" }

}

for (i=0; i<p.length; i++) {

if (p[i].lines.length==4) { p[i].spaceAfter = "8mm" }

}

[ Don't forget: I'm not a scripter!  ;-) ]

• ###### 5. Re: Calculate line count and add x picas per line to space after

Thanks @Willi but this is what I was trying to avoid.

• ###### 6. Re: Calculate line count and add x picas per line to space after

Obi, Thanks for this. I never thought I'd see a script for it. I'm going to try to play with this. In an effort to talk more about why I'm asking I'd like to clarify that I am not trying to overcomplicate things. After re-reading The Elements of Typographic Style I was attempting to set a subhead in Avenir at 8/10 on a 12 pt baseline. The space before is set to 18pt with a space after of 6 pt. On a one line subhead this would realign the body to the baseline. This may be an odd combo but works really well on one liners however needs adjustments on multilines. By setting the first line to align on baseline it throws the vertical alignment to something arbitrary.

I may have a very poor understanding about this topic but am willing to learn as much as I can on it if anyone has any sources I can dive into. I appreciate all of your help but I have to give the Carnival award to Obi-wan Kenobi for the answer i was looking for and effort in the script.