-
1. Re: Add empty gutter columns to spread table to page width
[Jongware] Feb 18, 2010 1:34 AM (in response to Kenneth Benson)Let's write one shall we. Just a mo'.
[Ed.] How do you determine what the 'widest entry' is? Are there wrapping lines involved, or multi-paragraph contents? For that matter, are there empty cells as well? (These may muck up calculations )
[Ed.#2] Merged columns and/or rows? These muck up *everything* you would want to do with a script
-
2. Re: Add empty gutter columns to spread table to page width
[Jongware] Feb 18, 2010 4:20 AM (in response to [Jongware])Okay, did some experiments with a random selection of tables I had.
The results are not aestetically pleasing ... consider a table of numbers, with headings "Value", "Sum", "Subtotal", "Total". All numbers are less wide than the headings, so these will be used for the column widths. Therefore, they will all be different, and "Total", for example, will be noticeable less wide than "Subtotal". Formatting manually, I would spot this and give all columns the same width.
Do all your tables have the same number of columns, and the same kind of data? It might be far easier, faster, and more pleasing to the eye to format *one* manually and then apply its column widths to all other tables.
-
3. Re: Add empty gutter columns to spread table to page width
Harbs. Feb 18, 2010 4:25 AM (in response to [Jongware])Sounds like it's going to be a long moment...
Harbs
-
4. Re: Add empty gutter columns to spread table to page width
[Jongware] Feb 18, 2010 5:07 AM (in response to Harbs.)I have a working version (at least, working for simple tables, one line per cell, no merge-trickery) -- but the mathematically correct widths are not really satisfying. One of my sample tables started with a numbered column ("Item #", followed by "1", "2", "3" etc.). That column got the same width as the 'real' data ones, whereas I manually would make the first one as tight as possible and divide only the rest evenly.
-
5. Re: Add empty gutter columns to spread table to page width
Kenneth Benson Feb 18, 2010 5:23 AM (in response to [Jongware])Widest entry is determined by reducing column width until a line breaks or oversets and then backing off 1 pt so it fits. There may be some multiline entries, but most entries are short. In any case, I don't mind so much determining column widths. Many of them are repetitive, so I know already that a five-digit dollar amount (like $10,800) requires 26 pts. And very frequently the table consists of a stub on the left and several rows of numbers. I size the stub and then swipe all the number columns and set them to 26, or 32, or whatever.
Occasionally, there are merged columns. I never start out with merged rows (although I end up with merged column head rows). In any case, the drudgery here is adding the gutter columns and assigning a size to them. Sizing the data columns and determining the size of the gutter columns is relatively painless, so I'd be ecstatic if I had a script that only (1) inserted gutter columns between data columns and (2) assigned a width to the gutter columns, even if I was the one to determine the width. If it makes it easier to work with no merged columns, I'd be happy to unmerge all first and then merge after the script runs.
I've zipped up a small CS4 file showing a sample before and after table and put it at
http://www.pegtype.com/sampletable.zip
Not my design (kinda ugly), and don't worry about aesthetically pleasing. Most of these need some attention after the drudgery, but a script would get me there faster.
Ken Benson
-
6. Re: Add empty gutter columns to spread table to page width
[Jongware] Feb 18, 2010 6:08 AM (in response to Kenneth Benson)Just adding blank columns inbetween? Oomph -- that's so much easier
This script does the job for the 'current' table, the one your text cursor is in:
aTable = app.selection[0].parent; if (aTable.constructor.name == "Cell") aTable = app.selection[0].parent.parent; for (a=aTable.columns.length-1; a>=1; a--) { if (aTable.columns[a].width > 75) { aTable.columns[a].width -= 60; aTable.columns.add(LocationOptions.BEFORE, aTable.columns[a], {width:60}); } }(Note the dirty little check on a minimum column width ... This was necessary for your sample table, as it already contained a single thin gutter column.)
If you get ecstatic about this one, I'll concoct something for you to use on *all* tables in your document.
(By the way, an alternative would be to not add gutter columns, but either use Figure spaces or a tab with Decimal Align to line up the numbers.)
-
7. Re: Add empty gutter columns to spread table to page width
[Jongware] Feb 18, 2010 7:17 AM (in response to [Jongware])(After re-reading your posts -- I might have read more carefully the first time:)
This new scriptlet goes more towards what you asked. For this to work as intended, you have to size all columns to its minimum width, leaving lots of space on the right hand side. Then click your cursor inside the table and run the script.
I think it now exactly follows your current mode d'emploi -- the current width of the table is subtracted from the space remaining (504 pts), which is divided over (NumColumns - 1) gutter columns inbetween the existing ones.
aTable = app.selection[0].parent; if (aTable.constructor.name == "Cell") aTable = app.selection[0].parent.parent; extraGutter = (504 - aTable.width)/(aTable.columns.length-1); for (a=aTable.columns.length-1; a>=1; a--) { aTable.columns.add(LocationOptions.BEFORE, aTable.columns[a], {width:extraGutter}); } -
8. Re: Add empty gutter columns to spread table to page width
Kenneth Benson Feb 18, 2010 8:25 AM (in response to [Jongware])This is excellent. Even works with merged cells. Should save me several days of work.
Ken Benson




