Table Width
By default, a table will span the width of the content area.
Fixed width
To constrain the width of the table to a fixed value, set the width
attribute in the table’s attribute list.
The width is an integer percentage value ranging from 1 to 100.
The %
sign is optional.
[width=75%]
|===
|Column 1, header row |Column 2, header row |Column 3, header row
|Cell in column 1, row 2
|Cell in column 2, row 2
|Cell in column 3, row 2
|Cell in column 1, row 3
|Cell in column 2, row 3
|Cell in column 3, row 3
|===
Column 1, header row | Column 2, header row | Column 3, header row |
---|---|---|
Cell in column 1, row 2 |
Cell in column 2, row 2 |
Cell in column 3, row 2 |
Cell in column 1, row 3 |
Cell in column 2, row 3 |
Cell in column 3, row 3 |
Autowidth
Alternately, you can make the width fit the content by setting the autowidth
option.
The columns inherit this setting, so individual columns will also be sized according to the content.
[%autowidth]
|===
|Column 1, header row |Column 2, header row |Column 3, header row
|Cell in column 1, row 2
|Cell in column 2, row 2
|Cell in column 3, row 2
|Cell in column 1, row 3
|Cell in column 2, row 3
|Cell in column 3, row 3
|===
Column 1, header row | Column 2, header row | Column 3, header row |
---|---|---|
Cell in column 1, row 2 |
Cell in column 2, row 2 |
Cell in column 3, row 2 |
Cell in column 1, row 3 |
Cell in column 2, row 3 |
Cell in column 3, row 3 |
If you want each column to have an automatic width, but want the table to span the width of the content area, add the stretch
role to the table.
(Alternatively, you can set the width
attribute to 100%
.)
[%autowidth.stretch]
|===
|Column 1, header row |Column 2, header row |Column 3, header row
|Cell in column 1, row 2
|Cell in column 2, row 2
|Cell in column 3, row 2
|Cell in column 1, row 3
|Cell in column 2, row 3
|Cell in column 3, row 3
|===
The table from Example 3 is rendered below. The columns are sized to the content, but the table spans the width of the page.
Column 1, header row | Column 2, header row | Column 3, header row |
---|---|---|
Cell in column 1, row 2 |
Cell in column 2, row 2 |
Cell in column 3, row 2 |
Cell in column 1, row 3 |
Cell in column 2, row 3 |
Cell in column 3, row 3 |
The autowidth option is not recognized by the DocBook converter.
|
Mix fixed and autowidth columns
If you want to apply autowidth
only to certain columns, use the special value ~
as the width of the column.
In this case, width values are assumed to be a percentage value (i.e., 100-based).
[cols="25h,~,~"]
|===
|small |as big as the column needs to be |the rest
|===
small |
as big as the column needs to be |
the rest |
---|