w:cols (Column Layout)
Defines multi-column layout for the section, specifying column count, spacing, and widths.
Description
w:cols controls the multi-column layout for a section. It is defined in ECMA-376 Part 1 §17.6.4.
When w:equalWidth is true (default), all columns share the same width, derived from w:num and w:space. When equal width is disabled, individual w:col elements define widths. A vertical line between columns is drawn when w:sep is set.
Attributes
| Attribute | Type | Possible Values | Description |
|---|---|---|---|
w:num |
xsd:integer |
Positive integer (default: 1). |
Number of text columns in the section. |
w:space |
ST_TwipsMeasure |
Positive integer (twips). | Gap between equal-width columns (default: 720, i.e. 0.5 in). |
w:equalWidth |
ST_OnOff |
true / false (default: true). |
Whether all columns are equal width. |
w:sep |
ST_OnOff |
true / false |
Draw a vertical line between columns. |
Examples
<!-- Two equal-width columns with 0.5-inch gap and separator -->
<w:cols w:num="2" w:space="720" w:sep="true"/>
new Columns { ColumnCount = 2, Space = "720", Separator = true };
<!-- Three columns with individual widths -->
<w:cols w:num="3" w:equalWidth="false" w:space="720">
<w:col w:w="1440"/>
<w:col w:w="1440" w:space="720"/>
<w:col w:w="1440" w:space="720"/>
</w:cols>
new Columns { ColumnCount = 3, EqualWidth = false, Space = "720" };
Notes
- Default: Single column (no layout applied) when
w:numis omitted. - Equal Width: When
w:equalWidth="true", all columns share equal width regardless of individualw:colsettings. - Spacing:
w:spacein twips; 720 = 0.5 inch between columns. - Separator Line:
w:sep="true"draws vertical rule between columns. - Text Flow: Flows top-to-bottom in first column, then continues at top of next column.
- Section-Specific: Layout applies to the entire section; different sections can have different column counts.
- RTL Documents: Columns flow according to text direction (right-to-left for RTL).
- Compatibility: Multi-column layouts render consistently across Office versions.