is now part of CreativePro.com!

A Fix for a Missing Field: Table Width

8

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:

centered table

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:

  1. Select any row of the table.
  2. Choose Merge Cells from the Table menu or contextual (right-click) menu.
    merge cells
  3. Look at the Column Width field in the Control or Table palette; that’s your table width.
    column width
  4. 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:

  1. 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.
  2. Merge the cells in the empty row.
  3. 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.
  4. 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!

Anne-Marie “Her Geekness” Concepción is the co-founder (with David Blatner) and CEO of Creative Publishing Network, which produces InDesignSecrets, InDesign Magazine, and other resources for creative professionals. Through her cross-media design studio, Seneca Design & Training, Anne-Marie develops ebooks and trains and consults with companies who want to master the tools and workflows of digital publishing. She has authored over 20 courses on lynda.com on these topics and others. Keep up with Anne-Marie by subscribing to her ezine, HerGeekness Gazette, and contact her by email at [email protected] or on Twitter @amarie
  • David Mendez says:

    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.

  • Scott Lalonde says:

    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.

  • Guido Benigni (Rome, Italy) says:

    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.

  • Anne-Marie says:

    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.

  • Jennie says:

    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
    }

  • Rod Macey says:

    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?

  • Hopsa says:

    I’m impressed! Now that’s intuitive thinking. Big ups 2 Dorothy, from Holland. I’m definately going to use that trick! Peace

  • >