A Fix for a Missing Field: Table Width
When you insert a table into a text frame (Table > Insert Table) , by default the table’s width exactly matches the text frame’s width. But as anyone who’s worked with InDesign tables knows, the two measures are actually independent. If you drag a side handle of a text frame, the table stays the same width; if you change the width or number of table columns, the text frame stays the same width.
A table can easily extend beyond the boundaries of its containing text frame (as anyone who’s ever imported a Word file with a table has discovered) or be much narrower than the frame, such as when you want the table centered in the frame:
With all this flexibility InDesign offers to table designers, one important feature is missing: An editable Table Width field. I’ve been working with ID for years but it took a student in a class I’m teaching this week to point this out to me.
And it’s true – all we have is a single Column Width field. You might guess that selecting multiple columns and entering a measure in the field would set the total width for the selection, but all it does is apply that same measure to every column in the selection. If you select three columns and enter “5 in” you get three 5″ columns. (Which can be useful, of course, but doesn’t help us here.)
There are ways to ascertain a table’s width by using the Rulers or the Measure tool, but neither helps when you want to precisely *set* a width for a table.
The Merge Workaround
The same student who asked “Is there a way to set the width of a table?” had a workaround she’d been using which I thought was clever, and I told her I’d post it here.
If you just want to know the width of a table, not change it, do this:
- Select any row of the table.
- Choose Merge Cells from the Table menu or contextual (right-click) menu.
- Look at the Column Width field in the Control or Table palette; that’s your table width.
- Now immediately Undo (Command/Ctrl-Z) to get your separate cells and their contents back.
If you might want to change the width of the table, start with an empty row:
- Select an empty row (no content) in your table. If none exists, add one temporarily (click an insertion point in any cell and choose Insert > Row from the Table menu or the contextual menu), and select that empty row.
- Merge the cells in the empty row.
- Enter the desired width of the table in the Column Width field in the Control or Table palette and press Return/Enter. The entire table resizes to match.
- Delete the empty row, which should still be selected (choose Delete > Row from the Table menu or contextual menu).
Thanks very much to Dorothy at HDR in Omaha, Nebraska, for this tip. She’s one of almost 50 HDR staff members from around the country who have flown in for training this week as the company prepares to officially move to Adobe InDesign. Woo-hoo!
Very Clever!, I’m more of a “Table width=Column width x Number of Columns” type of guy. Math make me giddy.
Normally what i do is insert the table and delete any hidden character to make the text frame hug the table, then i “option, command, C” to Fit frame to content and it gives me the table width.
Hi Anne Marie, I have a way I’ve been using that’s quite a bit easier. Since InDesign’s fields can do math, all you have to do is make sure your type cursor is somewhere in the table, and then use this formula in the Column Width field; [total table width you’d like/number of columns in the selected row] Basically, you’re putting in the total width you’d like the table to be and dividing it by the number of columns already in the table (in the row you have your cursor in). InDesign does the math, and voila? Table width heaven. Have a super-wide table and don’t want to count the number of columns? Check the Table Options dialog box (Opt-Shift-Cmd-B) and it will tell you.
Hi there.
The two comments are actually all right, but ONLY if all of your columns are the same width. Dorothy’s tip should work better (haven’t tried it out yet) in case of not homogenous column widths.
Grazie, Guido!
You’re exactly right, the fix I described works for all kinds of tables, including ones with mixed column widths (and split cells etc.) … as in the screen shot. I seldom use tables in ID whose columns are all exactly the same width.
but I do appreciate Scott and David’s contributions, they’re right that you can use ID’s math in the column width field, which can come in handy! Thanks for posting.
Hi Anne Marie, I don’t know much (anything) about scripting or macros, so please bear with me. Would it be possible to write one that ran on a selected table? I am thinking something along the lines of: insert row>merge columns>evaluate for w>display w in some field>delete row. Does that make any sense?
Thanks
The width of a table is directly available to a script, so (hoping this dosn’t get mangled):
if (app.documents.length == 0 || app.selection.length == 0) { exit() }
alert(findTable(app.selection[0]).width.toFixed(3));
function findTable(obj) {
while (obj.constructor.name != “Table”) {
obj = obj.parent;
if (obj.constructor.name == “Application”) {
alert(“Can’t find table”); exit();
}
}
return obj
}
The ideal table scenario would be a table width field (that could be locked), with a variable option for column widths a little like HTML tables. In the table example here, you would set the widths of columns 1 and 3, and let Indesign do the math for column 2 to fit the table to the specified width.
Any chance to get this by CS3 – or are there any plugins that might do this already?
I’m impressed! Now that’s intuitive thinking. Big ups 2 Dorothy, from Holland. I’m definately going to use that trick! Peace