AutoFit Tables
In an AutoFit table (one which specifies that it should “AutoFit to table contents”), the table information is used in the following manner:
Perform the steps above to lay out the fixed width version of the table.
Calculate the minimum content width - the width of the cell's contents including all possible line breaking locations (or the cell's width, if the width of the content is smaller), and the maximum content width -the width of the cell's contents (assuming no line breaking not generated by explicit line breaks).
The minimum and maximum content width of all cells that span a single grid column is the minimum and maximum content width of that column.
For cells which span multiple grid columns, enlarge all cells which it spans as needed to meet that cell's minimum width.
If any cell in a grid column has a preferred width, the first such width overrides the maximum width of the column's contents.
Place the text in the cells in the table, respecting the minimum content width of each cell's content. If a cell's minimum content width exceeds the cell's current width, preferences are overridden as follows:
First, override the column widths by making all other grid columns proportionally smaller until each it at its minimum width. This cell may then grow to any width between its own minimum and maximum width.
Next, override the preferred table width until the table reaches the page width.
Finally, force a line break in each cell's contents as needed