16 Replies Latest reply on Jan 16, 2012 1:46 AM by கற்பனை (Imagine)

# Equal space for Table column Gutter?

Hi All,

I want to make the tables column between space equally by using the Scripting (InDesign CS5.5 Windows).  I'm stuggled in creating the algorithm to this task.  Is any one already completed this type of automation means please share your thoughts, or please suggest the algorithm you are using.?

Regards,
Imagine.

• ###### 1. Re: Equal space for Table column Gutter?

I'm having trouble understanding your English. A picture?

• ###### 2. Re: Equal space for Table column Gutter?

How to set the even space between columns.?

• ###### 3. Re: Equal space for Table column Gutter?

That is not much of a picture .

Do you mean the equivalent of Table > Distribute Columns Evenly?

• ###### 4. Re: Equal space for Table column Gutter?

In the above snapshot In between columns are having the uneven spaces.  I need to give the even space between columns based on the maximum characters on that columns.

Do you mean the equivalent of Table > Distribute Columns Evenly?

No.

• ###### 5. Re: Equal space for Table column Gutter?

OK, so:

1. Iterate over the rows, and find the maximum width row in each column.
2. Sum the widths (1).
3. Subtract (2) from the total width of all columns
4. Divide (3) by the number of columns
5. Set each column to it's max width (1) plus its portion of the space (4)

What's the problem?

• ###### 6. Re: Equal space for Table column Gutter?

Thanks John,

But this algorithm will change the table width. right?  So that table width to be expanded and allocating the between spaces evenly.   I need the algorithm to unchange the width of the table.  Is there any other alternate ways?

• ###### 7. Re: Equal space for Table column Gutter?

But this algorithm will change the table width. right?

No. Total width should be unchanged.

• ###### 8. Re: Equal space for Table column Gutter?

OK, so:

1. Iterate over the rows, and find the maximum width row in each column.
2. Sum the widths (1).
3. Subtract (2) from the total width of all columns
4. Divide (3) by the number of columns
5. Set each column to it's max width (1) plus its portion of the space (4)

Step 1:  Gives the width of the columns.

Step 2:  Sum of all columns width.

Step 3:  Step2 - total width of all colums.

Third step confusing me.  If I subtract the values result will be zero.  so zero divide by anything also zero.  Please clarify the problem.

• ###### 9. Re: Equal space for Table column Gutter?

I'm sure John means to subtract the total width of your longest lines in each column from the total width of the table. That would leave you with the total white space to be distributed evenly between the columns.

Depending on what you want this to look like, you might want to tweak the formula a bit in steps 4 and 5. If you have four columns, you have three spaces in between them, so you may want to divide your total white space by three rather than four and add the extra space only to the first three columns.

• ###### 10. Re: Equal space for Table column Gutter?

Hi Mary Posner,

I followed the algorithm into my script, but finally doing the algorithm fifth step, that columns are resized so that columns cell contents will be reflowed, due to this space between the columns are not even.

• ###### 11. Re: Equal space for Table column Gutter?

Yes, that would be the case. Besides adding that space to the columns, you'll have to set the columns' right inset to the same amount as your space to retain the wrap you want.

• ###### 12. Re: Equal space for Table column Gutter?

Hi Mary,

Thanks for given the solution.  I've one more queries about getting the text max width on columns cells.  I fetching the values using horizontaloffset of the text InsertionPoint object.   Please confirm is it right approach?.

• ###### 13. Re: Equal space for Table column Gutter?

That sounds like absolutely the wrong approach. The horizontalOffset is the position of one point. You should test the width with the width property of the cell.

• ###### 14. Re: Equal space for Table column Gutter?

I use the simple calculation to getting the text object width in Cells i.e text.insertionpoints[-1].endhorizontaloffset and text.insertionPoints[0].horizontaloffset.  Subtract the values i got the text object width.  If i  use the cell property width means i got only the Cell object width not the Text object width within the cell.

Is it right?.

• ###### 15. Re: Equal space for Table column Gutter?

Sorry, I misunderstood you. Yes, that sounds correct.

• ###### 16. Re: Equal space for Table column Gutter?

Thanks to everyone for spending your valuable time for me...