I have what I hope is a simple question !
I am generating a simple RTF table that is subsequently opened in MS Word. The table is generating fine but the column widths are a little small and causing some word wrapping (not what I want).
The RTF code I generate is for a two line, three column table and is of the form:
\trowd \trautofit1
\intbl
\cellx1
\cellx2
\cellx3
{a\cell b\cell c\cell }{\trowd \trautofit1
\intbl
\cellx1
\cellx2
\cellx3
\row}
\trowd \trautofit1
\intbl
\cellx1
\cellx2
\cellx3
{d\cell e\cell f\cell }{\trowd \trautofit1
\intbl
\cellx1
\cellx2
\cellx3
\row}
What do I need to add to set a column width ? I have tried altering the column width in word and then examining the output but it is a little obscure to say the least !
The control words you are looking for are \clwWidthN
and \clftsWidthN
Microsoft RTF Specification v1.9.1:
- \clwWidthN
Preferred cell width. Overrides \trautofitN.
- \clftsWidthN
Units for \clwWidthN:
- 0 : Null. Ignore \clwWidthN in favor of \cellxN (Word 97 style of determining cell and row width).
- 1 : Auto, no preferred cell width, ignores \clwWidthN if present; \clwWidthN will generally not be written, giving precedence to row defaults.
- 2 : Percentage (in 50ths of a percent).
- 3 : Twips.
So, in your case, you could just use \clftsWidth1
(automatically set width) or set the preferred percentages yourself e.g. \clwWidth2\clwWidth2500
(2500 = 50%)
\trowd \trautofit1
\intbl
\clftsWidth1\cellx1
\clftsWidth1\cellx2
\clftsWidth1\cellx3
{a\cell b\cell c\cell }
\trowd \trautofit1
\intbl
\clftsWidth2\clwWidth2000\cellx1
\clftsWidth2\clwWidth1500\cellx2
\clftsWidth2\clwWidth1500\cellx3
{a\cell b\cell c\cell }
The problem is in that you have set very small width for column:
\cellx1
\cellx2
\cellx3
To set width for column in RTF there is a keyword '\cellxN', where N - is column width in twips. 15 twips is 1px.
So if you want to create a simple RTF table with 1 row and 3 columns, 100px each, use this syntax:
\trowd\cellx1500\cellx3000\cellx4500
\intbl A\cell B\cell C\cell\row
You will get a simple table by 300px, 3 columns - 100px each, with invisible borders.
Cheers, Max
You need to either use cellx0, so that autofit tag applies, or explicity set the number to the number of twips from the left border. In your example, you use 1 2 and 3 which is explicity setting the column widths to be very skinny. For example, something like:
\cellx5125 \Cellx6000 \Cellx8000
Note that these numbers are offsets from the left margin.
If you are going to do any RTF, I highly recomend the RTF Pocket Guide from O'Rielly
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With