RTF has no table group. A table is a run of rows, and a row is a run of paragraphs
that are split into cells. \trowd starts a row’s definition,
\cell ends each cell and \row ends the row. Every paragraph in
a row has \intbl, set or inherited. A row may reuse the previous row’s
definition. Lengths are in twips.
Grammar
<row> = (<tbldef> <cell>+ <tbldef> \row) | (<tbldef> <cell>+ \row) | (<cell>+ <tbldef> \row)
<cell> = (<nestrow>? <tbldef>?) & <textpar>+ \cell
<nestrow> = <nestcell>+ '{\*' \nesttableprops <tbldef> \nestrow '}'
<nestcell> = <textpar>+ \nestcell
<tbldef> = \trowd \trgaph & <rowjust>? & <rowwrite>? & <rowtop>? & <rowbot>? & <rowleft>?
& <rowright>? & <rowhor>? & <rowvert>? & <rowpos>? & \trleft? & \trrh? \trhdr?
& \trkeep? & <rowwidth>? & <rowinv>? & \trautofit? & <rowspc>? & <rowpad>?
& \taprtl? <celldef>+
<rowjust> = \trql | \trqr | \trqc
<rowwrite> = \ltrrow | \rtlrow
<rowtop> = \trbrdrt <brdr> (and \trbrdrl, \trbrdrb, \trbrdrr, \trbrdrh, \trbrdrv likewise)
<rowpos> = <rowhorzpos> & <rowvertpos> & <rowwrap> & \tabsnoovrlp?
<rowwrap> = \tdfrmtxtLeft? & \tdfrmtxtRight? & \tdfrmtxtTop? & \tdfrmtxtBottom?
<rowhframe> = \tphmrg? | \tphpg? | \tphcol?
<rowhdist> = \tposx? | \tposnegx? | \tposxc? | \tposxi? | \tposxo? | \tposxl? | \tposxr?
<rowvframe> = \tpvmrg? | \tpvpg? | \tpvpara?
<rowvdist> = \tposy? | \tposnegy? | \tposyt? | \tposyil? | \tposyb? | \tposyc? | \tposyin | \tposyout
<rowwidth> = \trftsWidth & \trwWidth?
<rowinv> = (\trftsWidthB & \trwWidthB?)? & (\trftsWidthA & \trwWidthA?)?
<rowspc> = (\trspdl & \trspdfl?)? & (\trspdt & \trspdft?)? & (\trspdb & \trspdfb?)? & (\trspdr & \trspdfr?)?
<rowpad> = (\trpaddl & \trpaddfl?)? & (\trpaddt & \trpaddft?)? & (\trpaddb & \trpaddfb?)? & (\trpaddr & \trpaddfr?)?
<celldef> = (\clmgf? & \clmrg? & \clvmgf? & \clvmrg? <celldgu>? & <celldgl>? & <cellalign>? & <celltop>?
& <cellleft>? & <cellbot>? & <cellright>? & <cellshad>? & <cellflow>? & \clFitText?
& \clNoWrap? & <cellwidth>? & <cellpad>?) \cellx
<cellshad> = <cellpat>? \clcfpat? & \clcbpat? & \clshdng
<cellwidth> = \clftsWidth & \clwWidth?
<cellpad> = (\clpadl & \clpadfl?)? & (\clpadt & \clpadft?)? & (\clpadb & \clpadfb?)? & (\clpadr & \clpadfr?)?
A row definition has one <celldef>, ending in
\cellx, per cell, and the number of \cellx must equal the
number of \cell in the row. Word 97 wrote the definition at the start of
the row; Word 2000 writes it at the end, and a copy at the start for older readers. A
reader must not assume either place. For nested rows Word 2000 writes it only at the
end.
Rows, cells and nesting
| Control word | Meaning |
|---|---|
\trowd | Reset to the default row properties and start a row definition. |
\row | End of the row. |
\tcelld | Reset to the default cell properties. |
\cell | End of a cell. |
\cellxN | Right edge of the cell, including its half of the gap between cells, measured from the left edge of the column the table is in. Ends the cell’s definition. |
\trgaphN | Half the space between cells. |
\nestcell | End of a cell in a nested table. |
\nestrow | End of a row in a nested table. |
\nesttableprops | Destination: the definition of a nested row, written after its cells as {\*\nesttableprops … \nestrow}. |
\nonesttables | Destination: text for readers that do not understand nested tables, usually a \par to put each nested cell in its own paragraph. Readers that support nesting ignore it. |
\itapN | (Paragraph property) nesting depth of the paragraph: 1 in a table, 2 in a nested table. |
\clmgf | First cell of a range of horizontally merged cells. |
\clmrg | This cell is merged with the one before it. |
\clvmgf | First cell of a range of vertically merged cells. |
\clvmrg | This cell is merged with the one above it. |
Row properties
| Control word | Meaning |
|---|---|
\trleftN | Position of the table’s left edge relative to the left of its column. |
\trql | Row aligned to the left of the column. |
\trqr | Aligned to the right. |
\trqc | Centred. |
\trrhN | Row height: 0 fits the text, positive is a minimum, negative is exact. |
\trhdr | Header row: repeated at the top of every page the table runs onto. |
\trkeep | Do not split the row across pages. |
\trkeepfollow | Keep the row on the same page as the next row. |
\trautofitN | AutoFit: 0 off (default), 1 on. Preferred widths (\clwWidth, \trwWidth) override it. |
\taprtl | The table reads right to left. |
\rtlrow | Cells in the row run right to left. |
\ltrrow | Cells run left to right (default). |
Widths, padding and spacing
Word 2000 added preferred widths, padding (inner margins) and spacing between cells.
Each value has a companion word giving its unit; \cellx and
\trgaph are still written for older readers.
| Control word | Meaning |
|---|---|
\trwWidthN | Preferred row width; overrides \trautofit. |
\trftsWidthN | Unit of \trwWidth: see width units. With 1 (auto) there is no preferred width. |
\trwWidthBN | Width of an invisible cell before the first cell, used when rows have different widths. |
\trftsWidthBN | Unit of \trwWidthB; 0 means no invisible cell before. |
\trwWidthAN | Width of an invisible cell after the last cell. |
\trftsWidthAN | Unit of \trwWidthA; 0 means no invisible cell after. |
\clwWidthN | Preferred cell width; overrides \trautofit. |
\clftsWidthN | Unit of \clwWidth. |
\trpaddlN, \trpaddtN, \trpaddbN, \trpaddrN | Default left, top, bottom and right padding of the row’s cells. |
\trpaddflN, \trpaddftN, \trpaddfbN, \trpaddfrN | Their units: 0 ignore the padding and use \trgaph (Word 97 style); 3 twips. |
\clpadlN, \clpadtN, \clpadbN, \clpadrN | Left, top, bottom and right padding of one cell; override the row’s. |
\clpadflN, \clpadftN, \clpadfbN, \clpadfrN | Their units: 0 ignore and use \trgaph; 3 twips. |
\trspdlN, \trspdrN | Default left and right cell spacing. The space between two cells side by side is the right cell’s \trspdl plus the left cell’s \trspdr; Word writes them equal. |
\trspdtN, \trspdbN | Default top and bottom cell spacing, added in the same way between cells one above the other. |
\trspdflN, \trspdftN, \trspdfbN, \trspdfrN | Their units: 0 ignore the spacing; 3 twips. |
\clFitText | Fit the text in the cell by compressing each paragraph to the cell’s width. |
\clNoWrap | Do not wrap text in the cell. Only has an effect when the cell has no preferred width. |
Width units
Values of \trftsWidth, \trftsWidthB,
\trftsWidthA and \clftsWidth:
| N | Unit |
|---|---|
| 0 | None: ignore the width and use \cellx (Word 97 style). For B and A, no invisible cell. |
| 1 | Auto: no preferred width; the width word is usually not written. |
| 2 | Percentage, in fiftieths of a per cent (5,000 is 100%). |
| 3 | Twips. |
Positioned tables
A table that floats with text wrapped round it. Every row of the table must have the same values. The paragraphs in it also carry the matching frame words for older readers.
| Control word | Meaning |
|---|---|
\tdfrmtxtLeftN | Distance between the left of the table and the text round it (default 0). |
\tdfrmtxtRightN | Distance on the right (default 0). |
\tdfrmtxtTopN | Distance above (default 0). |
\tdfrmtxtBottomN | Distance below (default 0). |
\tabsnoovrlp | Do not overlap other tables or shapes with similar wrapping. |
\tphcol | Horizontal position relative to the column (default). |
\tphmrg | Relative to the margin. |
\tphpg | Relative to the page. |
\tposxN | N twips from the left of the reference. |
\tposnegxN | As \tposx, any negative value allowed. |
\tposxc | Centred horizontally. |
\tposxi | Inside. |
\tposxo | Outside. |
\tposxl | At the left. |
\tposxr | At the right. |
\tpvmrg | Vertical position relative to the top margin (default). |
\tpvpg | Relative to the top of the page. |
\tpvpara | Relative to the top left of the next paragraph that is not framed. |
\tposyN | N twips from the top of the reference. |
\tposnegyN | As \tposy, any negative value allowed. |
\tposyt | At the top. |
\tposyc | Centred vertically. |
\tposyb | At the bottom. |
\tposyil | In line. |
\tposyin | Inside. |
\tposyout | Outside. (The specification’s index lists it as \tposyoutv.) |
Borders
Each side word is followed by a border kind, width and colour, as for paragraph borders.
| Control word | Meaning |
|---|---|
\trbrdrt | Row border, top. |
\trbrdrl | Row border, left. |
\trbrdrb | Row border, bottom. |
\trbrdrr | Row border, right. |
\trbrdrh | Row border, inside horizontal. |
\trbrdrv | Row border, inside vertical. |
\clbrdrt | Cell border, top. |
\clbrdrl | Cell border, left. |
\clbrdrb | Cell border, bottom. |
\clbrdrr | Cell border, right. |
\cldglu | Diagonal line from top left to bottom right. |
\cldgll | Diagonal line from top right to bottom left. |
Cell shading, alignment and text flow
| Control word | Meaning |
|---|---|
\clshdngN | Shading in hundredths of a per cent. Written with the cell border words. |
\clbghoriz | Horizontal pattern. |
\clbgvert | Vertical pattern. |
\clbgfdiag | Forward diagonal pattern (\\\\). |
\clbgbdiag | Backward diagonal pattern (////). |
\clbgcross | Cross pattern. |
\clbgdcross | Diagonal cross pattern. |
\clbgdkhor | Dark horizontal pattern. |
\clbgdkvert | Dark vertical pattern. |
\clbgdkfdiag | Dark forward diagonal pattern. |
\clbgdkbdiag | Dark backward diagonal pattern. |
\clbgdkcross | Dark cross pattern. |
\clbgdkdcross | Dark diagonal cross pattern. |
\clcfpatN | Colour of the pattern lines (colour table index). |
\clcbpatN | Background colour of the cell (colour table index). |
\clvertalt | Text at the top of the cell (default). |
\clvertalc | Text centred vertically. |
\clvertalb | Text at the bottom. |
\cltxlrtb | Text flows left to right, top to bottom (default). |
\cltxtbrl | Right to left, top to bottom. |
\cltxbtlr | Left to right, bottom to top. |
\cltxlrtbv | Left to right, top to bottom, vertical. |
\cltxtbrlv | Top to bottom, right to left, vertical. |
Example
A two-by-two table with single borders, cells 1.5 inches wide, starting at the left margin:
\trowd\trgaph108\trleft-108
\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10 \cellx2052
\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10 \cellx4212
\pard\intbl A1\cell B1\cell \row
\pard\intbl A2\cell B2\cell \row
\pard\par
\trgaph108 leaves 108 twips of space each side of the text in a cell, so
\trleft-108 lines the text up with the margin. The cells end at 2,052 and
4,212 twips: 2,160 twips (1.5 inches) wide. The second row has no
\trowd and reuses the first row’s definition.
The specification also gives a complete Word 2000 example: a positioned table
(\tphmrg\tposxc\tposyc) of two rows, the first offset with an invisible
cell before it (\trftsWidthB3\trwWidthB504) and holding a nested table
(paragraphs with \itap2, cells ended by \nestcell, then
{\*\nesttableprops\trowd … \cellx2348\nestrow}{\nonesttables\par}), the
second offset with an invisible cell after it (\trwWidthA900). Each row
repeats its whole definition at its end inside {… \row }, as Word 2000
does.