Rich Text Format (RTF) Version 規格 1.5 - 1

1 篇文章 / 0 new
author
Rich Text Format (RTF) Version 規格 1.5 - 1
版本已至 1.9.1, 下載 http://www.microsoft.com/en-us/download/confirmation.aspx?id=10725

CONVENTIONS OF AN RTF READER

The reader of an RTF stream is concerned with the following:

* Separating control information from plain text.

* Acting on control information.

* Collecting and properly inserting text into the document, as directed by the current group state.

Acting on control information is designed to be a relatively simple process. Some control information simply contributes special characters to the plain text stream. Other information serves to change the program state, which includes properties of the document as a whole, or to change any of a collection of group states, which apply to parts of the document.

As previously mentioned, a group state can specify the following:

* The destination, or part of the document that the plain text is constructing.

* Character-formatting properties, such as bold or italic.

* Paragraph-formatting properties, such as justified or centered.

* Section-formatting properties, such as the number of columns.

* Table-formatting properties, which define the number of cells and dimensions of a table row.

In practice, an RTF reader will evaluate each character it reads in sequence as follows:

* If the character is an opening brace ({), the reader stores its current state on the stack. If the character is a closing brace (}), the reader retrieves the current state from the stack.

* If the character is a backslash (\), the reader collects the control word or control symbol and its parameter, if any, and looks up the control word or control symbol in a table that maps control words to actions. It then carries out the action prescribed in the table. (The possible actions are discussed below.) The read pointer is left before or after a control-word delimiter, as appropriate.

* If the character is anything other than an opening brace ({), closing brace (}), or backslash (\), the reader assumes that the character is plain text and writes the character to the current destination using the current formatting properties.

If the RTF reader cannot find a particular control word or control symbol in the look-up table described above, the control word or control symbol should be ignored. If a control word or control symbol is preceded by an opening brace ({), it is part of a group. The current state should be saved on the stack, but no state change should occur. When a closing brace (}) is encountered, the current state should be retrieved from the stack, thereby resetting the current state. If the \* control symbol precedes a control word, then it defines a destination group and was itself preceded by an opening brace ({). The RTF reader should discard all text up to and including the closing brace (}) that closes this group. All RTF readers must recognize all destinations defined in the March 1987 RTF Specification. The reader may skip past the group, but it is not allowed to simply discard the control word. Destinations defined since March 1987 are marked with the \* control symbol.

Note All RTF readers must implement the \* control symbol so that they can read RTF files written by newer RTF writers.

For control words or control symbols that the RTF reader can find in the look-up table, the possible actions are as follows.

Action Description
Change Destination The RTF reader changes the destination to the destination described in the table entry. Destination changes are legal only immediately after an opening brace ({ ). (Other restrictions may also apply; for example, footnotes cannot be nested.) Many destination changes imply that the current property settings will be reset to their default settings. Examples of control words that change destination are \footnote, \header, \footer, \pict, \info, \fonttbl, \stylesheet, and \colortbl. This Application Note identifies all destination control words where they appear in control-word tables.
Change Formatting Property The RTF reader changes the property as described in the table entry. The entry will specify whether a parameter is required. The "Appendix C: Index of RTF Control Words" section at the end of this Application Note also specifies which control words require parameters. If a parameter is needed and not specified, then a default value will be used. The default value used depends on the control word. If the control word does not specify a default, then all RTF readers should assume a default of 0.
Insert Special Character The reader inserts into the document the character code or codes described in the table entry.
Insert Special Character and Perform Action The reader inserts into the document the character code or codes described in the table entry and performs whatever other action the entry specifies. For example, when Microsoft Word interprets \par, a paragraph mark is inserted in the document and special code is run to record the paragraph properties belonging to that paragraph mark.

FORMAL SYNTAX

This Application Note describes RTF using the following syntax, based on Backus-Naur Form.

Syntax Meaning
#PCDATA Text (without control words).
#SDATA Hexadecimal data.
#BDATA Binary data.
'c' A literal.
<text> A nonterminal.
A The (terminal) control word a, without a parameter.
a or aN The (terminal) control word a, with a parameter.
a? Item a is optional.
a+ One or more repetitions of item a.
a* Zero or more repetitions of item a.
a b Item a followed by item b.
a | b Item a or item b.
a & b Item a and/or item b, in any order.

CONTENTS OF AN RTF FILE

An RTF file has the following syntax:

<File> '{' <header> <document>'}'

This syntax is the standard RTF syntax; any RTF reader must be able to correctly interpret RTF written to this syntax. It is worth mentioning again that RTF readers do not have to use all control words, but they must be able to harmlessly ignore unknown (or unused) control words, and they must correctly skip over destinations marked with the \* control symbol. There may, however, be RTF writers that generate RTF that does not conform to this syntax, and as such, RTF readers should be robust enough to handle some minor variations. Nonetheless, if an RTF writer generates RTF conforming to this specification, then any correct RTF reader should be able to interpret it.

Header

The header has the following syntax:

<header>

  \rtf <charset> \deff? <fonttbl> <filetbl>? <colortbl>? <stylesheet>? <listtables>? <revtbl>?

Each of the various header tables should appear, if they exist, in the above order. Document properties can occur before and between the header tables. A property must be defined before being referenced. Specifically:

* The style sheet must occur before any style usage.

* The font table must precede any reference to a font.

* The \deff keyword must precede any text without an explicit reference to a font, because it specifies the font to use in such cases.

RTF Version

An entire RTF file is considered a group and must be enclosed in braces. The \rtfN control word must follow the opening brace. The numeric parameter N identifies the major version of the RTF Specification used. The RTF standard described in this Application Note, although titled as version 1.5, continues to correspond syntactically to RTF Specification version 1. Therefore, the numeric parameter N for the \rtf control word should still be emitted as 1.

Character Set

After specifying the RTF version, you must declare the character set used in this document. The control word for the character set must precede any plain text or any table control words. The RTF Specification currently supports the following character sets.

Control word Character set
\ansi ANSI (the default)
\mac Apple Macintosh
\pc IBM PC code page 437
\pca IBM PC code page 850, used by IBM Personal System/2 (not implemented in version 1 of Microsoft Word for OS/2)

Unicode RTF

Word 97 is a partially Unicode-enabled application. Text is handled using the 16-bit Unicode character encoding scheme. Expressing this text in RTF requires a new mechanism, because until this release (version 1.5), RTF has only handled 7-bit characters directly and 8-bit characters encoded as hexadecimal. The Unicode mechanism described here can be applied to any RTF destination or body text.
Control word Meaning
\ansicpgN This keyword represents the ANSI code page which is used to perform the Unicode to ANSI conversion when writing RTF text. N represents the code page in decimal. This is typically set to the default ANSI code page of the run-time environment (for example \ansicpg1252 for U.S. Windows). The reader can use the same ANSI code page to convert ANSI text back to Unicode.

This keyword should be emitted in the RTF header section right after the \ansi, \mac, \pc or \pca keyword.

\upr This keyword represents a destination with two embedded destinations, one represented using Unicode and the other using ANSI. This keyword operates in conjunction with the \ud keyword to provide backward compatibility. The general syntax is as follows:
{\upr{keyword ansi_text}{\*\ud{keyword Unicode_text}}}

Notice that this keyword-destination does not use the \* keyword; this forces the old RTF readers to pick up the ANSI representation and discard the Unicode one.

\ud This is a destination which is represented in Unicode. The text is represented using a mixture of ANSI translation and use of \uN keywords to represent characters which do not have the exact ANSI equivalent.
\uN This keyword represents a single Unicode character which has no equivalent ANSI representation based on the current ANSI code page. N represents the Unicode character value expressed as a decimal number.

This keyword is followed immediately by equivalent character(s) in ANSI representation. In this way, old readers will ignore the \uN keyword and pick up the ANSI representation properly. When this keyword is encountered, the reader should ignore the next N characters, where N corresponds to the last \ucN value encountered.

As with all RTF keywords, a keyword-terminating space may be present (before the ANSI characters) which is not counted in the characters to skip. While this is not likely to occur (or recommended), a \bin keyword, its argument, and the binary data that follows are considered one character for skipping purposes. If an RTF scope delimiter character (that is, an opening or closing brace) is encountered while scanning skippable data, the skippable data is considered to be ended before the delimiter. This makes it possible for a reader to perform some rudimentary error recovery. To include an RTF delimiter in skippable data, it must be represented using the appropriate control symbol (that is, escaped with a backslash,) as in plain text. Any RTF control word or symbol is considered a single character for the purposes of counting skippable characters.

An RTF writer, when it encounters a Unicode character with no corresponding ANSI character, should output \uN followed by the best ANSI representation it can manage. Also, if the Unicode character translates into an ANSI character stream with count of bytes differing from the current Unicode Character Byte Count, it should emit the \ucN keyword prior to the \uN keyword to notify the reader of the change.

RTF control words generally accept signed 16-bit numbers as arguments. For this reason, Unicode values greater than 32767 must be expressed as negative numbers.

\ucN This keyword represents the number of bytes corresponding to a given \uN Unicode character. This keyword may be used at any time, and values are scoped like character properties. That is, a \ucN keyword applies only to text following the keyword, and within the same (or deeper) nested braces. On exiting the group, the previous \uc value is restored. The reader must keep a stack of counts seen and use the most recent one to skip the appropriate number of characters when it encounters a \uN keyword. When leaving an RTF group which specified a \uc value, the reader must revert to the previous value. A default of 1 should be assumed if no \uc keyword has been seen in the current or outer scopes.

A common practice is to emit no ANSI representation for Unicode characters within a Unicode destination context (that is, inside a \ud destination.). Typically, the destination will contain a \uc0 control sequence. There is no need to reset the count on leaving the \ud destination as the scoping rules will ensure the previous value is restored.

Document Text

Document text should be emitted as ANSI characters. If there are Unicode characters that do not have corresponding ANSI characters, they should be output using the \ucN and \uN keywords.

For example, the text Lab[Gamma]Value (Unicode characters 0x004c, 0x0061, 0x0062, 0x0393, 0x0056, 0x0061, 0x006c, 0x0075, 0x0065) should be represented as follows (assuming a previous \ucl):

Lab\u915Gvalue

Destination Text

Destination text is defined as any text represented in an RTF destination. A good example is the bookmark name in the \bkmkstart destination.

Any destination containing Unicode characters should be emitted as two destinations within a \upr destination to ensure that old readers can read it properly and that no Unicode character encoding is lost when read with a new reader.

For example, a bookmark name Lab[Gamma]Value (Unicode characters 0x004c, 0x0061, 0x0062, 0x0393, 0x0056, 0x0061, 0x006c, 0x0075, 0x0065) should be represented as follows:

{\upr{\*\bkmkstart LabGValue}{\*\ud{\*\bkmkstart Lab\u915 Value}}}

The first sub-destination contains only ANSI characters and is the representation that old readers will see. The second sub-destination is a \*\ud destination which contains a second copy of the \bkmkstart destination. This copy can contain Unicode characters and is the representation that Unicode-aware readers must pay attention to, ignoring the ANSI-only version.

Font Table

The \fonttbl control word introduces the font table group. Unique \fN control words define each font available in the document, and are used to reference that font throughout the document. This group has the syntax listed in the following table.

<fonttbl> '{' \fonttbl (<fontinfo> | ('{' <fontinfo> '}'))+ '}'
<fontinfo> <fontnum><fontfamily><fcharset>?<fprq>?<panose>?<nontaggedname>?<fontemb>?

<codepage>? <fontname><fontaltname>? ';'

<fontnum> \f
<fontfamily> \fnil | \froman | \fswiss | \fmodern | \fscript | \fdecor | \ftech | \fbidi
<fcharset> \fcharset
<fprq> \fprq
<panose> <data>
<nontaggedname> \*\fname
<fontname> #PCDATA
<fontaltname> '{\*' \falt #PCDATA '}'
<fontemb> '{\*' \fontemb <fonttype> <fontfname>? <data>? '}'
<fonttype> \ftnil | \fttruetype
<fontfname> '{\*' \fontfile <codepage>? #PCDATA '}'
<codepage> \cpg

Note for <fontemb> that either <fontfname> or <data> must be present, although both may be present.

All fonts available to the RTF writer can be included in the font table, even if the document doesn't use all the fonts.

RTF also supports font families, so that applications can attempt to intelligently choose fonts if the exact font is not present on the reading system. RTF uses the following control words to describe the various font families.

Control word Font family Examples
\fnil Unknown or default fonts (the default)  
\froman Roman, proportionally spaced serif fonts Times New Roman, Palatino
\fswiss Swiss, proportionally spaced sans serif fonts Arial
\fmodern Fixed-pitch serif and sans serif fonts Courier New, Pica
\fscript Script fonts Cursive
\fdecor Decorative fonts Old English, ITC Zapf Chancery
\ftech Technical, symbol, and mathematical fonts Symbol
\fbidi Arabic, Hebrew, or other bidirectional font Miriam

 

If an RTF file uses a default font, the default font number is specified with the \deffN control word, which must precede the font-table group. The RTF writer supplies the default font number used in the creation of the document as the numeric argument N. The RTF reader then translates this number through the font table into the most similar font available on the reader's system.

The following control words specify the character set, alternative font name, pitch of a font in the font table, and non-tagged font name.

Control word Definition
\fcharsetN Specifies the character set of a font in the font table. Values for N are defined by Windows header files, and in the file RTFDEFS.H accompanying this document.
\falt Indicates alternate font name to use if the specified font in the font table is not available. '{\*' \falt <Alternate Font Name>'}'
\fprqN Specifies the pitch of a font in the font table.
\*\panose  
\*\fname This is an optional control word in the font table to define the non-tagged font name. This is the actual name of the font without the tag, used to show which character set is being used. For example, Arial is a non-tagged font name, and Arial (Cyrillic) is a tagged font name. This control word is used by WordPad. Word ignores this control word (and never creates it).
\fbiasN Used to arbitrate between two fonts when a particular character can exist in either non-Far East or Far East font. Word 97 emits the \fbiasN keyword only in the context of bullets or list information (that is, a \listlevel destination). The default value of 0 for N indicates a non-Far East font. A value of 1 indicates a Far East font. Additional values may be defined in future releases.

 

If \fprq is specified, the N argument can be one of the following values.

Pitch Value
Default pitch 0
Fixed pitch 1
Variable pitch 2

Font Embedding

RTF supports embedded fonts with the \fontemb group located inside a font definition. An embedded font can be specified by a file name, or the actual font data may be located inside the group. If a file name is specified, it is contained in the \fontfile group. The \cpg control word can be used to specify the character set for the file name.

RTF supports TrueType® and other embedded fonts. The type of the embedded font is described by the following control words.

Control word Embedded font type
\ftnil Unknown or default font type (the default)
\fttruetype TrueType font

 

Code Page Support

A font may have a different character set from the character set of the document. For example, the Symbol font has the same characters in the same positions both on the Macintosh and in Windows. RTF describes this with the \cpg control word, which names the character set used by the font. In addition, file names (used in field instructions and in embedded fonts) may not necessarily be the same as the character set of the document; the \cpg control word can change the character set for these file names as well. However, all RTF documents must still declare a character set (that is, \ansi, \mac, \pc, or \pca) to maintain backward compatibility with earlier RTF readers.

The table below describes valid values for \cpg.

Value Description
437 United States IBM
708 Arabic (ASMO 708)
709 Arabic (ASMO 449+, BCON V4)
710 Arabic (transparent Arabic)
711 Arabic (Nafitha Enhanced)
720 Arabic (transparent ASMO)
819 Windows 3.1 (United States and Western Europe)
850 IBM multilingual
852 Eastern European
860 Portuguese
862 Hebrew
863 French Canadian
864 Arabic
865 Norwegian
866 Soviet Union
932 Japanese
1250 Windows 3.1 (Eastern European)
1251 Windows 3.1 (Cyrillic)

 

 

File Table

The \filetbl control word introduces the file table destination. The only time a file table is created in RTF is when the document contains subdocuments. This group defines the files referenced in the document and has the following syntax:

<filetbl> '{\*' \filetbl ('{' <fileinfo> '}')+ '}'
<fileinfo> \file <filenum><relpath>?<osnum>? <filesource>+ <file name>
<filenum> \fid
<relpath> \frelative
<osnum> \fosnum
<filesource> \fvalidmac | \fvaliddos | \fvalidntfs | \fvalidhpfs | \fnetwork
<file name> #PCDATA

 

Note that the file name can be any valid alphanumeric string for the named file system, indicating the complete path and file name.

Control word Definition
\filetbl A list of documents referenced by the current document. The file table has a structure analogous to the style or font table. This is a destination control word output as part of the document header.
\file Marks the beginning of a file group, which lists relevant information about the referenced file. This is a destination control word.
\fidN File ID number. Files are referenced later in the document using this number.
\frelativeN The character position within the path (starting at 0) where the referenced file's path starts to be relative to the path of the owning document. For example, if a document is saved to the path C:\Private\Resume\File1.doc and its file table contains the path C:\Private\Resume\Edu\File2.doc, then that entry in the file table will be \frelative18, to point at the character "e" in "edu". This allows preservation of relative paths.
\fosnumN Currently only filled in for paths from the Macintosh file system. It is an operating-system-specific number for identifying the file, which may be used to speed up access to the file, or find it if the file has been moved to another folder or disk. The Macintosh operating system name for this number is the "file id." Additional meanings of the \fosnumN control word may be defined for other file systems in the future.
\fvalidmac Macintosh file system.
\fvaliddos MS-DOS file system.
\fvalidntfs NTFS file system.
\fvalidhpfs HPFS file system.
\fnetwork Network file system. This control word may be used in conjunction with any of the previous file source control words.

 

Color Table

The \colortbl control word introduces the color table group, which defines screen colors, character colors, and other color information. This group has the following syntax:

<colortbl> '{' \colortbl <colordef>+ '}'
<colordef> \red ? & \green ? & \blue ? ';'

 

The following are valid control words for this group.

Control word Meaning
\redN Red index
\greenN Green index
\blueN Blue index

 

Each definition must be delimited by a semicolon, even if the definition is omitted. If a color definition is omitted, the RTF reader uses its default color. The example below defines the default color table used by Word. The first color is omitted, as shown by the semicolon following the \colortbl control word. The missing definition indicates that color 0 is the `'auto'' color.

{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;\red192\green192\blue192;}

The foreground and background colors use indexes into the color table to define a color. For more information on color setup, see your Windows documentation.

The following example defines a block of text in color (where supported). Note that the cf/cb index is the index of an entry in the color table, which represents a red/green/blue color combination.

{\f1\cb1\cf2 This is colored text. The background is color

1 and the foreground is color 2.}

If the file is translated for software that does not display color, the reader ignores the color table group.

Style Sheet

The \stylesheet control word introduces the style sheet group, which contains definitions and descriptions of the various styles used in the document. All styles in the document's style sheet can be included, even if not all the styles are used. In RTF, a style is a form of shorthand used to specify a set of character, paragraph, or section formatting.

The style-sheet group has the following syntax:

<stylesheet> '{' \stylesheet <style>+ '}'
<style> '{' <styledef>?<keycode>? <formatting> <additive>? <based>? <next>? <stylename>? ';' '}'
<styledef> \s |\*\cs | \ds
<keycode> '{' \keycode <keys> '}'
<additive> \additive
<based> \sbasedon
<next> \snext
<autoupd> \sautoupd
<hidden> \shidden
<formatting> (<brdrdef> | <parfmt> | <apoctl> | <tabdef> | <shading> | <chrfmt>)+
<stylename> #PCDATA
<keys> ( \shift? & \ctrl? & \alt?) <key>
<key> \fn | #PCDATA

 

For <style>, both <styledef> and <stylename> are optional; the default is paragraph style 0. Note for <stylename> that Microsoft Word for the Macintosh interprets commas in #PCDATA as separating style synonyms. Also, for <key>, the data must be exactly one character.

Control word Meaning
\*\csN Designates character style. Like \s, \cs is not a destination control word. However, it is important to treat it like one inside the style sheet; that is, \cs must be prefixed with \* and must appear as the first item inside a group. Doing so ensures that readers that do not understand character styles will skip the character style information correctly. When used in body text to indicate that a character style has been applied, do not include the \* prefix.
\sN Designates paragraph style.
\dsN Designates section style.
\additive Used in a character style definition ('{\*'\cs...'}'). Indicates that character style attributes are to be added to the current paragraph style attributes, rather than setting the paragraph attributes to only those defined in the character style definition.
\sbasedonN Defines the number of the style on which the current style is based (the default is 222--no style).
\snextN Defines the next style associated with the current style; if omitted, the next style is the current style.
\sautoupd Automatically update styles.
\shidden Style does not appear in the Styles drop-down list in the Style dialog box[1]

(on the Format menu, click Styles).

 
\keycode This group is specified within the description of a style in the style sheet in the RTF header. The syntax for this group is '{\*'\keycode <keys>'}' where <keys> are the characters used in the key code. For example, a style, Normal, may be defined {\s0 {\*\keycode \shift\ctrl n}Normal;} within the RTF style sheet. See the Special Character control words for the characters outside the alphanumeric range that may be used.
\alt The ALT modifier key. Used to describe shortcut-key codes for styles.
\shift The SHIFT modifier key. Used to describe shortcut-key codes for styles.
\ctrl The CTRL modifier key. Used to describe shortcut-key codes for styles.
\fnN Specifies a function key where N is the function key number. Used to describe shortcut-key codes for styles.

 

The following is an example of an RTF style sheet

{\stylesheet{\fs20 \sbasedon222\snext0{\*\keycode \shift\ctrl n} 

Normal;}{\s1\qr \fs20 \sbasedon0\snext1 FLUSHRIGHT;}{\s2\fi-720\li720\fs20\ri2880\sbasedon0\snext2 IND;}}

and RTF paragraphs to which the styles are applied:

\widowctrl\ftnbj\ftnrestart \sectd \linex0\endnhere \pard\plain 

\fs20 This is Normal style.

\par \pard\plain \s1\qr\fs20

This is right justified. I call this style FLUSHRIGHT.

\par \pard\plain \s2\fi-720\li720\fs20\ri2880

This is an indented paragraph. I call this style IND. It produces 

a hanging indent.

\par}

Some of the control words in this example are discussed in later sections. In the example, note that the properties of the style were emitted following the application of the style. This was done for two reasons: (1) to allow RTF readers that don't support styles to still retain all formatting; and, (2) to allow the additive model for styles, where additional property changes are "added" on top of the defined style. Some RTF readers may not "apply" a style upon only encountering the style number without the accompanying formatting information because of this.

List Table

Word 97 stores bullets and numbering information very differently from earlier versions of Word. In Word 6.0, for example, number formatting data is stored individually with each paragraph. In Word 97, however, all of the formatting information is stored in a pair of document-wide list tables which act as a style sheet, and each individual paragraph stores only an index to one of the tables, like a style index.

There are two list tables in Word: the List table (destination \listtable), and the List Override table (destination \listoverridetable).

The first table Word stores is the List table. A List table is a list of lists (destination \list). Each list contains a number of list properties that pertain to the entire list, and a list of levels (destination \listlevel), each of which contains properties that pertain only to that level.

Top-level List Properties

Control word Meaning
\listidN Each list must have a unique list ID that should be randomly generated. The value N is a long integer. The list ID cannot be between -1 and -5.
\listtemplateidN Each list should have a unique template ID as well, which also should be randomly generated. The template ID cannot be -1. The value N is a long integer.
\listsimpleN 1 if the list has one level; 0 if the list has nine levels
\listrestarthdnN 1 if the list restarts at each section; 0 if not. Used for Word 7.0 compatibility only.
\listname The argument for \listname is a string that is the name of this list. Names allow ListNum fields to specify the list they belong to. This is a destination control word.

 

List Levels

Each list consists of either one or nine list levels depending upon whether the \listsimple flag is set. Each list level contains a number of properties that specify the formatting for that level, such as the start-at value, the text string surrounding the number, its justification and indents, and so on.

 
Control word Meaning
\levelstartatN N specifies the start-at value for the level
\levelnfcN Specifies the number type for the level:

0 Arabic (1, 2, 3)

1 Uppercase Roman numeral (I, II, III)

2 Lowercase Roman numeral (i, ii, iii)

3 Uppercase letter (A, B, C)

4 Lowercase letter (a, b, c)

5 Ordinal number (1st, 2nd, 3rd)

6 Cardinal text number (One, Two Three)

7 Ordinal text number (First, Second, Third)

22 Arabic with leading zero (01, 02, 03, ..., 10, 11)

23 Bullet (no number at all)

255 No number

\leveljcN 0 Left justified

1 Center justified

2 Right justified

\leveloldN 1 if this level was converted from Word 6.0 or 7.0, 0 if it is a native Word 97 level.
\levelprevN 1 if this level includes the text from the previous level (used for Word 7.0 compatibility only); otherwise, the value is 0 . This keyword will only be valid if the \leveloldN keyword is emitted.
\levelprevspaceN 1 if this level includes the indentation from the previous level (used for Word 7.0 compatibility only); otherwise, the value is 0 . This keyword will only be valid if the \leveloldN keyword is emitted.
\levelindentN Minimum distance from the left indent to the start of the paragraph text (used for Word 7.0 compatibility only). This keyword will only be valid if the \leveloldN keyword is emitted.
\levelspaceN Minimum distance from the right edge of the number to the start of the paragraph text (used for Word 7.0 compatibility only). This keyword will only be valid if the \leveloldN keyword is emitted.
\leveltext The argument for this level should be the number format string for this level. The first character is the length of the string, and any numbers within the level should be replaced by the index of the level they represent. For example, a level three number such as "1.1.1." would generate the following RTF: "{\leveltext \'06\'00.\'01.\'02.}" where the '06 is the string length, the \'00, \'01, and \'02 are the level place holders, and the periods are the surrounding text. This is a destination control word.
\levelnumbers The argument for this destination should be a string that gives the offsets into the \leveltext of the level place holders. In the above example, "1.1.1.", the \levelnumbers RTF should be
{\levelnumbers \'01\'03\'05}

because the level place holders have indices 1, 3, and 5. This is a destination control word.

\levelfollowN Specifies which character follows the level text:

0 Tab

1 Space

2 Nothing

\levellegalN 1 if any list numbers from previous levels should be converted to arabic numbers; 0 if they should be left with the format specified by their own level's definition.
\levelnorestartN 1 if this level does not restart its count each time a number of a higher level is reached, 0 if this level does restart its count each time a number of a higher level is reached.

 

In addition to all of these properties, each list level can contain any character properties (all of which affect all text for that level) and any combination of three paragraph properties: left indents, first line left indents, and tabs--each of which must be of a special type: jclisttab. These paragraph properties will be automatically applied to any paragraph in the list.

List Override Table

The List Override table is a list of list overrides (destination \listoverride). Each list override contains the listid of one of the lists in the List table, as well as a list of any properties it chooses to override. Each paragraph will contain a list override index (keyword ls) which is a 1-based index into this table. Most list overrides don't override any properties--instead, they provide a level of indirection to a list. There are generally two types of list overrides: (1) formatting overrides, which allow a paragraph to be part of a list and are numbered along with the other members of the list, but have different formatting properties; and, (2) start-at overrides, which allow a paragraph to share the formatting properties of a list, but have a different start-at values. The first element in the document with each list override index takes the start-at value that the list override specifies as its value, while each subsequent element is assigned the number succeeding the previous element of the list.

List overrides have a few top-level keywords, including a \listoverridecount, which contains a count of the number of levels whose format is overridden. This \listoverridecount should always be either 1 or 9, depending upon whether the list to be overridden is simple or multilevel. All of the actual override information is stored within a list of list override levels (destination \lfolevel).

Control word Meaning
\listidN Should exactly match the \listid of one of the lists in the List table. The value N is a long integer.
\listoverridecountN Number of list override levels within this list override (from 0 or 9).
\ls The (1-based) index of this \listoverride in the \listoverride table. This value should never be zero inside a \listoverride, and must be unique for all \listoverrides within a document. The valid values are from 1 to 2000.

 

List Override Level

Each list override level contains flags to specify whether the formatting or start-at values are being overridden for each level. If the format flag (listoverrideformat) is given, the lfolevel should also contain a list level (listlevel). If the start-at flag (listoverridestart) is given, a start-at value must be provided. If the start-at is overridden but the format is not, then a levelstartat should be provided in the lfolevel itself. If both start-at and format are overridden, put the levelstartat inside the listlevel contained in the lfolevel.

Control word Meaning
\listoverridestartN Should exactly match the listID of one of the lists in the List table. The value N is a long integer.
\listoverrideformatN Number of list override levels within this list override (should be either 1 or 9).

 

Track Changes (Revision Marks)

This table allows tracking of multiple authors and reviewers of a document, and is used in conjunction with the character properties for tracking changes (using revision marks).

Control word Definition
\*\revtbl This group consists of subgroups that each identify the author of a revision in the document, as in {Author1;}. This is a destination control word.

Revision conflicts, such as one author deleting another's additions, are stored as one group, in the following form:

CurrentAuthor\'00\'<length of previous author's name>PreviousAuthor\'00

PreviousRevisionTime

The 4 bytes of the Date/Time (DTTM) structure are emitted as ASCII characters, so values greater than 127 should be emitted as hexadecimal values enclosed in quotation marks.

 

 

All time references for revision marks use the following bit field structure, DTTM.

Bit numbers Information Range
0-5 Minute 0-59
6-10 Hour 0-23
11-15 Day of month 1-31
16-19 Month 1-12
20-28 Year = Year - 1900
29-31 Day of week 0 (Sun)-6 (Sat)

 

Document Area

Once the RTF header is defined, the RTF reader has enough information to correctly read the actual document text. The document area has the following syntax.

<document> <info>? <docfmt>* <section>+

 

Information Group

The \info control word introduces the information group, which contains information about the document. This can include the title, author, keywords, comments, and other information specific to the file. This information is for use by a document-management utility, if available.

This group has the following syntax.

<info> '{' <title>? & <subject>? & <author>? & <manager>? & <company>? <operator>? & <category>? & <keywords>? & <comment>? & \version? & <doccomm>? & \vern? & <creatim>? & <revtim>? & <printim>? & <buptim>? & \edmins? & \nofpages? & \nofwords? \nofchars? & \id? '}'
<title> '{' \title #PCDATA '}'
<subject> '{' \subject #PCDATA '}'
<author> '{' \author #PCDATA '}'
<manager> {' \manager #PCDATA '}'
<company> {' \company #PCDATA '}'
<operator> '{' \operator #PCDATA '}'
<category> {' \category #PCDATA '}'
<keywords> '{' \keywords #PCDATA '}'
<comment> '{' \comment #PCDATA '}'
<doccomm> '{' \doccomm #PCDATA '}'
<hlinkbase> '{' \hlinkbase #PCDATA '}'
<creatim> '{' \creatim <time> '}'
<revtim> '{' \revtim <time> '}'
<printim> '{' \printim <time> '}'
<buptim> '{' \buptim <time> '}'
<time> \yr? \mo? \dy? \hr? \min? \sec?

 

Some applications, such as Word, ask the user to type this information when saving the document in its native format. If the document is then saved as an RTF file or translated into RTF, the RTF writer specifies this information using the following control words. These control words are destinations and both the control words and the text should be enclosed in braces ({ }).

Control word Meaning
\title Title of the document. This is a destination control word.
\subject Subject of the document. This is a destination control word.
\author Author of the document. This is a destination control word.
\manager Manager of the author. This is a destination control word.
\company Company of the author. This is a destination control word
\operator Person who last made changes to the document. This is a destination control word.
\category Category of the document. This is a destination control word.
\keywords Selected keywords for the document. This is a destination control word.
\comment Comments; text is ignored. This is a destination control word.
\versionN Version number of the document.
\doccomm Comments displayed in the Summary Info or Properties dialog box in Word. This is a destination control word.
\hlinkbase The base address that is used for the path of all relative hyperlinks inserted in the document. This can be a path or an Internet address (URL).

 

The \userprops control word introduces the user-defined document properties. Unique \propname control words define each user-defined property in the document. The group has the following syntax.

\userprops `{\*' \userprops (`{' <propinfo> `}'*) `}'
<propinfo> <propname><proptype><staticval><linkval>?
<propname> `{' \propname #PCDATA `}'
<proptype> \proptype
<staticval> \staticval
<linkval> \linkval

 

Control Word Meaning
\propname The name of the user-defined property.
\staticval The value of the property.
\linkval The name of a bookmark that contains the text to display as the value of the property.
\proptype \proptypeN Specifies the type of the property.

 

For \proptype, the N argument can have the following values.

Value Description
3 Integer
5 Real number
7 Date
11 Boolean
30 Text

 

The RTF writer may automatically enter other control words, including the following.

Control word Meaning
\vernN Internal version number
\creatim Creation time
\revtim Revision time
\printim Last print time
\buptim Backup time
\edminsN Total editing time (in minutes)
\yrN Year
\moN Month
\dyN Day
\hrN Hour
\minN Minute
\secN Seconds
\nofpagesN Number of pages
\nofwordsN Number of words
\nofcharsN Number of characters including spaces
\nofcharsws Number of characters not including spaces
\idN Internal ID number

 

Any control word described in the previous table that does not have a numeric parameter specifies a date; all dates are specified with the \yr \mo \dy \hr \min \sec controls. An example of an information group follows:

{\info{\title The Panda's Thumb}{\author Stephen J Gould}{\keywords 
science natural history }}

Document Formatting Properties

After the information group (if there are any), there may be some document formatting control words (described as <docfmt> in the document area syntax description). These control words specify the attributes of the document, such as margins and footnote placement. These attributes must precede the first plain-text character in the document.

The control words that specify document formatting are listed in the following table (measurements are in twips; a twip is one-twentieth of a point). For omitted control words, RTF uses the default values.

Control word Meaning
\deftabN Default tab width in twips (the default is 720).
\hyphhotzN Hyphenation hot zone in twips (the amount of space at the right margin in which words are hyphenated).
\hyphconsecN N is the maximum number of consecutive lines that will be allowed to end in a hyphen. 0 means no limit.
\hyphcaps Toggles hyphenation of capitalized words (the default is on). Append 1 or leave control word by itself to toggle property on; append 0 to turn it off.
\hyphauto Toggles automatic hyphenation (the default is off). Append 1 or leave control word by itself to toggle property on; append 0 to turn it off.
\linestartN Beginning line number (the default is 1).
\fracwidth Uses fractional character widths when printing (QuickDraw only).
\*\nextfile Destination. The argument is the name of the file to print or index next; it must be enclosed in braces. This is a destination control word.
\*\template Destination. The argument is the name of a related template file; it must be enclosed in braces. This is a destination control word.
\makebackup Backup copy is made automatically when the document is saved.
\defformat Tells the RTF reader that the document should be saved in RTF format.
\psover Prints PostScript over the text.
\doctemp Document is a boilerplate document. For Word for Windows, this is a template; for Word for the Macintosh, this is a stationery file.
\deflangN Defines the default language used in the document used with a \plain control word. See the section "Character Formatting Properties" on page 34 of this Application Note for a list of possible values for N.
\deflangfe Default language ID for Asian versions of Word.
\windowcaption Sets the caption text for the document window. This is a string value.
\doctypeN An integer (0-2) that describes the document type for AutoFormat.

0 General Document (for formatting most documents, the default)

1 Letter (for formatting letters, and used by Letter Wizard)

2 E-mail (for formatting e-mail, and used by WordMail)

\fromtext Indicates document was originally plain text.

Document views and zoom level

\viewkindN An integer (0-5) that represents the view mode of the document.

0 None

1 Page Layout view

2 Outline view

3 Master Document view

4 Normal view

5 Online Layout view

\viewscaleN Zoom level of the document; the N argument is a value representing a percentage (the default is 100).
\viewzkN An integer (0 to 2) that represents the zoom kind of the document.

0 None

1 Full page

2 Best fit

\private Obsolete destination. It has no leading \*. It should be skipped.

Footnotes and Endnotes

\fetN Footnote/endnote type. This indicates what type of notes are present in the document.

0 Footnotes only or nothing at all (the default).

1 Endnotes only.

2 Footnotes and endnotes both.

For backward compatibility, if \fet1 is emitted, \endnotes or \enddoc will be emitted along with \aendnotes or \aenddoc. RTF readers that understand \fet will need to ignore the footnote-positioning control words, and use the endnote control words instead.

\ftnsep Text argument separates footnotes from the document. This is a destination control word.
\ftnsepc Text argument separates continued footnotes from the document. This is a destination control word.
\ftncn Text argument is a notice for continued footnotes. This is a destination control word.
\aftnsep Text argument separates endnotes from the document. This is a destination control word.
\aftnsepc Text argument separates continued endnotes from the document. This is a destination control word.
\aftncn Text argument is a notice for continued endnotes. This is a destination control word.
\endnotes Footnotes at the end of the section (the default).
\enddoc Footnotes at the end of the document.
\ftntj Footnotes beneath text (top justified).
\ftnbj Footnotes at the bottom of the page (bottom justified).
\aendnotes Endnotes at end of section (the default).
\aenddoc Endnotes at end of document.
\aftnbj Endnotes at bottom of page (bottom justified).
\aftntj Endnotes beneath text (top justified).
\ftnstartN Beginning footnote number (the default is 1).
\aftnstartN Beginning endnote number (the default is 1).
\ftnrstpg Restart footnote numbering each page.
\ftnrestart Footnote numbers restart at each section. Microsoft Word for the Macintosh uses this control to restart footnote numbering at each page.
\ftnrstcont Continuous footnote numbering (the default).
\aftnrestart Restart endnote numbering each section.
\aftnrstcont Continuous endnote numbering (the default).
\ftnnar Footnote numbering--Arabic numbering (1, 2, 3, ...)
\ftnnalc Footnote numbering--Alphabetic lowercase (a, b, c, ...)
\ftnnauc Footnote numbering--Alphabetic uppercase (A, B, C, ...)
\ftnnrlc Footnote numbering--Roman lowercase (i, ii, iii, ...)
\ftnnruc Footnote numbering--Roman uppercase (I, II, III, ...)
\ftnnchi Footnote numbering--Chicago Manual of Style (*, [dagger], [daggerdbl], §)
\aftnnar Endnote numbering--Arabic numbering (1, 2, 3, ...)
\aftnnalc Endnote numbering--Alphabetic lowercase (a, b, c, ...)
\aftnnauc Endnote numbering--Alphabetic uppercase (A, B, C, ...)
\aftnnrlc Endnote numbering--Roman lowercase (i, ii, iii, ...)
\aftnnruc Endnote numbering--Roman uppercase (I, II, III, ...)
\aftnnchi Endnote numbering--Chicago Manual of Style (*, [dagger], [daggerdbl], §)

Page Information

\paperwN Paper width in twips (the default is 12,240).
\paperhN Paper height in twips (the default is 15,840).
\pszN Used to differentiate between paper sizes with identical dimensions under Windows NT. Values 1-41 correspond to paper sizes defined in DRIVINI.H in the Windows 3.1 SDK (DMPAPER_ values). Values greater than or equal to 42 correspond to user-defined forms under Windows NT.
\marglN Left margin in twips (the default is 1800).
\margrN Right margin in twips (the default is 1800).
\margtN Top margin in twips (the default is 1440).
\margbN Bottom margin in twips (the default is 1440).
\facingp Facing pages (activates odd/even headers and gutters).
\gutterN Gutter width in twips (the default is 0).
\margmirror Switches margin definitions on left and right pages. Used in conjunction with \facingp.
\landscape Landscape format.
\pgnstartN Beginning page number (the default is 1).
\widowctrl Enable widow and orphan control.

Linked Styles

\linkstyles Update document styles automatically based on template.

Compatibility Options

\notabind Don't add automatic tab stop for hanging indent.
\wraptrsp Wrap trailing spaces onto the next line.
\prcolbl Print all colors as black.
\noextrasprl Don't add extra space to line height for showing raised/lowered characters.
\nocolbal Don't balance columns.
\cvmme Treat old-style escaped quotation marks (\") as current style ("") in mail merge data documents.
\sprstsp Suppress extra line spacing at top of page. Basically, this means to ignore any line spacing larger than Auto at the top of a page.
\sprsspbf Suppress space before paragraph property after hard page or column break.
\otblrul Combine table borders as done in Word 5.x for the Macintosh. Contradictory table border information is resolved in favor of the first cell.
\transmf Metafiles are considered transparent; don't blank the area behind metafiles.
\ swpbdr If a paragraph has a left border (not a box) and the Different Odd And Even or Mirror Margins check box is selected, Word will print the border on the right for odd-numbered pages.
\brkfrm Show hard (manual) page breaks and column breaks in frames.
\sprslnsp Suppress extra line spacing like WordPerfect version 5.x.
\subfontby

size

Substitute fonts based on size first.
\truncatefont

height

Round down to the nearest font size instead of rounding up.
\truncex Don't add leading (extra space) between rows of text
\bdbfhdr  
\dntblnsbdb Don't balance SBCS/DBCS characters. Option for compatibility with Word 6.0 (Japanese).
\expshrtn Expand character spaces on line-ending with SHIFT+RETURN. Option for compatibility with Word 6.0 (Japanese).
\lytexcttp Don't center exact line height lines.
\lytprtmet Use printer metrics to lay out document.
\msmcap Small caps like Word for the Macintosh 5.x.
\nolead No external leading. Option for compatibility with Word for the Macintosh 5.x
\nospaceforul Don't add space for underline. Option for compatibility with Word 6.0 (Japanese).
\noultrlspc Don't underline trailing spaces. Option for compatibility with Word 6.0 (Japanese).
\noxlattoyen Don't translate backslash to Yen sign. Option for compatibility with Word 6.0 (Japanese).
\oldlinewrap Lines wrap like Word 6.0.
\sprsbsp Suppress extra line spacing at bottom of page.
\sprstsm Does nothing. This keyword should be ignored.
\wpjst Do full justification like WordPerfect 6.x for Windows.
\wpsp Set the width of a space like WordPerfect 5.x.
\wptab Advance to next tab stop like WordPerfect 6.x.

Forms

\formprot This document is protected for forms.
\allprot This document has no unprotected areas.
\formshade This document has form field shading on.
\formdisp This document currently has a forms drop-down box or check box selected.
\printdata This document has print form data only on.

Revision Marks

\revprot This document is protected for revisions. The user can edit the document, but revision marking cannot be disabled.
\revisions Turns on revision marking.
\revpropN Argument indicates how revised text will be displayed: 0 for no properties shown; 1 for bold; 2 for italic; 3 for underline (the default); 4 for double underline.
\revbarN Vertical lines mark altered text, based on the argument: 0 for no marking; 1 for left margin; 2 for right margin; 3 for outside (the default: left on left pages, right on right pages).

Comments (Annotations)

\annotprot This document is protected for comments (annotations). The user cannot edit the document but can insert comments (annotations).

Bidirectional Controls

\rtldoc This document will be formatted to have Arabic-style pagination.
\ltrdoc This document will have English-style pagination (the default).

Note that the three document-protection control words (\formprot, \revprot, and \annotprot) are mutually exclusive; only one of the three can apply to any given document. Also, there is currently no method for storing passwords in RTF, so any document that associates a password with a protection level will lose the password protection in RTF.

For more information about bidirectional controls, see "Bidirectional Language Support" in this Application Note.

Page Borders

\pgbrdrhead Page border surrounds header.
\pgbrdrfoot Page border surrounds footer.
\pgbrdrt Page border top.
\pgbrdrb Page border bottom.
\pgbrdrl Page border left.
\pgbrdrr Page border right.
\brdrartN Page border art; the N argument is a value from 1-165 representing the number of the border.
\pgbrdroptN 8 Page border measure from text. Always display in front option is set to off.

32 Page border measure from edge of page. Always display in front option is set to on.

40 Page border measure from edge of page. Always display in front option is set to off.

\pgbrdrsnap Align paragraph borders and table edges with page border.

 

The color, width, border style, and border spacing keywords for page borders are the same as the keywords defined for paragraph borders.

Section Text

Each section in the RTF file has the following syntax:

<section> <secfmt>* <hdrftr>? <para>+ (\sect <section>)?

 

Section Formatting Properties

At the beginning of each section, there may be some section-formatting control words (described as <secfmt> in the section text syntax description). These control words specify section-formatting properties, which apply to the text following the control word, with the exception of the section-break control words (those beginning with \sbk). Section-break control words describe the break preceding the text. These control words can appear anywhere in the section, not just at the start.

Note that if the \sectd control word is not present, the current section inherits all section properties defined in the previous section.

The section-formatting control words are listed in the following table.

Control word Meaning
\sect New section.
\sectd Reset to default section properties.
\endnhere Endnotes included in the section.
\binfsxnN N is the printer bin used for the first page of the section. If this control is not defined, then the first page uses the same printer bin as defined by the \binsxnN control.
\binsxnN N is the printer bin used for the pages of the section.
\dsN Designates section style. If a section style is specified, style properties must be specified with the section.
\pnseclvlN Used for multilevel lists. This property sets the default numbering style for each corresponding \pnlvlN control word (bullets and numbering property for paragraphs) within that section. This is a destination control word.
\sectunlocked This section is unlocked for forms.

Section Break

\sbknone No section break.
\sbkcol Section break starts a new column.
\sbkpage Section break starts a new page (the default).
\sbkeven Section break starts at an even page.
\sbkodd Section break starts at an odd page.

Columns

\colsN Number of columns for "snaking" (the default is 1).
\colsxN Space between columns in twips (the default is 720).
\colnoN Column number to be formatted; used to specify formatting for variable-width columns.
\colsrN Space to right of column in twips; used to specify formatting for variable-width columns.
\colwN Width of column in twips; used to override the default constant width setting for variable-width columns.
\linebetcol Line between columns.

Line Numbering

\linemodN Line-number modulus amount to increase each line number (the default is 1).
\linexN Distance from the line number to the left text margin in twips (the default is 360). The automatic distance is 0.
\linestartsN Beginning line number (the default is 1).
\linerestart Line numbers restart at \linestarts value.
\lineppage Line numbers restart on each page.
\linecont Line numbers continue from the preceding section.

Page Information

\pgwsxnN N is the page width in twips. A \sectd resets the value to that specified by \paperwN in the document properties.
\pghsxnN N is the page height in twips. A \sectd resets the value to that specified by \paperhN in the document properties.
\marglsxnN N is the left margin of the page in twips. A \sectd resets the value to that specified by \marglN in the document properties.
\margrsxnN N is the right margin of the page in twips. A \sectd resets the value to that specified by \margrN in the document properties.
\margtsxnN N is the top margin of the page in twips. A \sectd resets the value to that specified by \margtN in the document properties.
\margbsxnN N is the bottom margin of the page in twips. A \sectd resets the value to that specified by \margbN in the document properties.
\guttersxnN N is the width of the gutter margin for the section in twips. A \sectd resets the value to that specified by \gutterN from the document properties. If Facing Pages is turned off, the gutter will be added to the left margin of all pages. If Facing Pages is turned on, the gutter will be added to the left side of odd-numbered pages and the right side of even-numbered pages.
\margmirsxn Switches margin definitions on left and right pages. Used in conjunction with \facingp.
\lndscpsxn Page orientation is in landscape format. To mix portrait and landscape sections within a document, the \landscape control should not be used so that the default for a section is portrait, which may be overridden by the \lndscpsxn control.
\titlepg First page has a special format.
\headeryN Header is N twips from the top of the page (the default is 720).
\footeryN Footer is N twips from the bottom of the page (the default is 720).

Page Numbers

\pgnstartsN Beginning page number (the default is 1).
\pgncont Continuous page numbering (the default).
\pgnrestart Page numbers restart at \pgnstarts value.
\pgnxN Page number is N twips from the right margin (the default is 720). This control word is understood but not used by current versions (6.0 or later) of Word.
\pgnyN Page number is N twips from the top margin (the default is 720). This control word is understood but not used by current versions (6.0 or later) of Word.
\pgndec Page-number format is decimal.
\pgnucrm Page-number format is uppercase roman numeral.
\pgnlcrm Page-number format is lowercase roman numeral.
\pgnucltr Page-number format is uppercase letter.
\pgnlcltr Page-number format is lowercase letter.
\pgnhnN Indicates which heading level is used to prefix a heading number to the page number. This control word can only be used in conjunction with numbered heading styles. 0 specifies to not show heading level (the default). Values 1-9 correspond to heading levels 1 through 9.
\pgnhnsh Hyphen separator character. This separator and the successive ones appear between the heading level number and the page number.
\pgnhnsp Period separator character.
\pgnhnsc Colon separator character.
\pgnhnsm Em-dash (--) separator character.
\pgnhnsn En-dash (-) separator character.

Vertical Alignment

\vertalt Text is top-aligned (the default).
\vertalb Text is bottom-aligned.
\vertalc Text is centered vertically.
\vertalj Text is justified vertically.

Bidirectional Controls

\rtlsect This section will snake (newspaper style) columns from right to left.
\ltrsect This section will snake (newspaper style) columns from left to right (the default).

Text Flow

\stextflow Section property for specifying text flow.

0 Text flows left to right and top to bottom

1 Text flows top to bottom and right to left, vertical

2 Text flows left to right and bottom to top

3 Text flows right to left and top to bottom

4 Text flows left to right and top to bottom, vertical

5 Text flows vertically, non-vertical font

Page Borders

\pgbrdrhead Page border surrounds header.
\pgbrdrfoot Page border surrounds footer.
\pgbrdrt Page border top.
\pgbrdrb Page border bottom.
\pgbrdrl Page border left.
\pgbrdrr Page border right.
\brdrartN Page border art; the N argument is a value from 1-165 representing the number of the border.
\pgbrdroptN 8 Page border measure from text. Always display in front option is set to off.

32 Page border measure from edge of page. Always display in front option is set to on.

40 Page border measure from edge of page. Always display in front option is set to off.

\pgbrdrsnap Align paragraph borders and table edges with page border.

 

 

The color, width, border style, and border spacing keywords for page borders are the same as the keywords defined for paragraph borders.

Headers and Footers

Headers and footers are RTF destinations. Each section in the document can have its own set of headers and footers. If no headers or footers are defined for a given section, the headers and footers from the previous section (if any) are used. Headers and footers have the following syntax:

<hdrftr> '{' <hdrctl> <para>+ '}' <hdrftr>?
<hdrctl> \header | \footer | \headerl | \headerr | \headerf | \footerl | \footerr | \footerf

Note that each separate <hdrftr> group must have a distinct <hdrctl> introducing it.

Control word Meaning
\header Header on all pages. This is a destination control word.
\footer Footer on all pages. This is a destination control word.
\headerl Header on left pages only. This is a destination control word.
\headerr Header on right pages only. This is a destination control word.
\headerf Header on first page only. This is a destination control word.
\footerl Footer on left pages only. This is a destination control word.
\footerr Footer on right pages only. This is a destination control word.
\footerf Footer on first page only. This is a destination control word.

 

The \headerl, \headerr, \footerl, and \footerr control words are used in conjunction with the \facingp control word, and the \headerf and \footerf control words are used in conjunction with the \titlepg control word. Many RTF readers will not function correctly if the appropriate document properties are not set. In particular, if \facingp is not set, then only \header and \footer should be used; if \facingp is set, then only \headerl, \headerr, \footerl, and \footerr should be used. Combining both \facingp and \titlepg is allowed. You should not use \header to set the headers for both pages when \facingp is set. You can use \headerf if \titlepg is not set, but no header will appear. For more information, see "Document Formatting Properties" on page 20 and "Section Formatting Properties" on page 26 of this Application Note.

If the previous section had a first page header or footer and had \titlepg set, and the current section does not, then the previous section's first page header or footer is disabled. However, it is not destroyed; if subsequent sections have \titlepg set, then the first page header or footer is restored.

Paragraph Text

There are two kinds of paragraphs: plain and table. A table is a collection of paragraphs, and a table row is a continuous sequence of paragraphs partitioned into cells. The \intbl paragraph-formatting control word identifies the paragraph as part of a table. For more information, see "Table Definitions" on page 40 of this Application Note. This control is inherited between paragraphs that do not have paragraph properties reset with \pard.

<para> <textpar> | <row>
<textpar> <pn>? <brdrdef>? <parfmt>* <apoctl>* <tabdef>? <shading>? (\subdocument | <char>+) (\par <para>)?
<row> <tbldef> <cell>+ \row
<cell> <textpar>+ \cell

 

Paragraph Formatting Properties

These control words (described as <parfmt> in the paragraph-text syntax description) specify generic paragraph formatting properties. These control words can appear anywhere in the body of the paragraph, not just at the beginning.

Note that if the \pard control word is not present, the current paragraph inherits all paragraph properties defined in the previous paragraph.

The paragraph-formatting control words are listed in the following table.

Control word Meaning
\par New paragraph.
\ pard Resets to default paragraph properties.
\sN Designates paragraph style. If a paragraph style is specified, style properties must be specified with the paragraph. N references an entry in the stylesheet.
\hyphpar Toggles automatic hyphenation for the paragraph. Append 1 or nothing to toggle property on; append 0 to turn it off.
\intbl Paragraph is part of a table.
\keep Keep paragraph intact.
\nowidctlpar No widow/orphan control. This is a paragraph-level property and is used to override the document-level \widowctrl.
\widctlpar Widow/orphan control is used for the current paragraph. This is a paragraph property used to override the absence of the document-level \widowctrl
\keepn Keep paragraph with the next paragraph.
\levelN N is the outline level of the paragraph.
\noline No line numbering.
\outlinelevelN Outline level of paragraph. The N argument is a value from 0-8 representing the outline level of the paragraph. In the default case, no outline level is specified (same as body text).
\pagebb Break page before the paragraph.
\sbys Side-by-side paragraphs.

Alignment

\ql Left-aligned (the default).
\qr Right-aligned.
\qj Justified.
\qc Centered.

Indentation

\fiN First-line indent (the default is 0).
\liN Left indent (the default is 0).
\riN Right indent (the default is 0).

Spacing

\sbN Space before (the default is 0).
\saN Space after (the default is 0).
\slN Space between lines. If this control word is missing or if \sl1000 is used, the line spacing is automatically determined by the tallest character in the line; if N is a positive value, this size is used only if it is taller than the tallest character (otherwise, the tallest character is used); if N is a negative value, the absolute value of N is used, even if it is shorter than the tallest character.
\slmultN Line spacing multiple. Indicates that the current line spacing is a multiple of "Single" line spacing. This control word can follow only the \sl control word and works in conjunction with it.

0 "At Least" or "Exactly" line spacing.

1 Multiple line spacing, relative to "Single."

Subdocuments

\subdocumentN This indicates that a subdocument in a master document/subdocument relationship should occur here. N represents an index into the file table. This control word must be the only item in a paragraph.

Bidirectional Controls

\rtlpar Text in this paragraph will be displayed with right-to-left precedence.
\ltrpar Text in this paragraph will be displayed with left-to-right precedence (the default).

 

Tabs

Any paragraph may have its own set of tabs. Tabs must follow this syntax:

<tabdef> (<tab> | <bartab>) +
<tab> <tabkind>? <tablead>? \tx
<bartab> <tablead>? \tb
<tabkind> \tqr | \tqc | \tqdec
<tablead> \tldot | \tlhyph | \tlul | \tlth | \tleq

 

Control word Meaning
\txN Tab position in twips from the left margin.
\tqr Flush-right tab.
\tqc Centered tab.
\tqdec Decimal tab.
\tbN Bar tab position in twips from the left margin.
\tldot Leader dots.
\tlhyph Leader hyphens.
\tlul Leader underline.
\tlth Leader thick line.
\tleq Leader equal sign.

 

Bullets and Numbering

Word 6.0/95 RTF

To provide compatibility with existing RTF readers, all applications that can automatically format paragraphs with bullets or numbers will also emit the generated text as plain text in the \pntext group. This will allow existing RTF readers to capture the plain text and safely ignore the autonumber instructions. This group precedes all bulleted or numbered paragraphs, and will contain all the text and formatting that would be auto-generated. It should precede the '{'\*\pn ... '}' destination, and it is the responsibility of RTF readers that understand the '{'\*\pn ... '}' destination to ignore the \pntext group.

<pn> <pnseclvl> | <pnpara>
<pnseclvl> '{\*' \pnseclvl <pndesc>'}'
<pnpara> <pntext> <pnprops>
<pntext> '{' \pntext <char> '}'
<pnprops> '{\*' \pn <pnlevel> <pndesc>'}'
<pnlevel> \pnlvl | \pnlvlblt | \pnlvlbody | \pnlvlcont
<pndesc> <pnnstyle> & <pnchrfmt> & <pntxtb> & <pntxta> & <pnfmt>
<pnnstyle> \pncard | \pndec | \pnucltr | \pnucrm | \pnlcltr | \pnlcrm | \pnord | \pnordt
<pnchrfmt> \pnf? & \pnfs? & \pnb? & \pni? & \pncaps? & \pnscaps? & <pnul>? & \pnstrike? & \pncf?
<pnul> \pnul | \pnuld | \pnuldb | \pnulnone | \pnulw
<pnfmt> \pnnumonce? & \pnacross? & \pnindent? & \pnsp? & \pnprev? & <pnjust>? & \pnstart? & \pnhang? & \pnrestart?
<pnjust> \pnqc | \pnql | \pnqr
<pntxtb> '{' \pntxtb #PCDATA'}'
<pntxta> '{' \pntxta #PCDATA'}'

Settings below marked with an asterisk can be turned off by appending 0 to the control word.

Control word Definition
\pntext This group precedes all numbered/bulleted paragraphs, and contains all auto-generated text and formatting. It should precede the '{\*'\pn ... '}' destination, and it is the responsibility of RTF readers that understand the '{\*'\pn ... '}' destination to ignore this preceding group. This is a destination control word.
\pn Turns on paragraph numbering. This is a destination control word.
\pnlvlN Paragraph level, where N is a level from 1 to 9. Default set by \pnseclvlN section formatting property.
\pnlvlblt Bulleted paragraph (corresponds to level 11). The actual character used for the bullet is stored in the \pntxtb group.
\pnlvlbody Simple paragraph numbering (corresponds to level 10).
\pnlvlcont Continue numbering but do not display number ("skip numbering").
\pnnumonce Number each cell only once in a table (the default is to number each paragraph in a table).
\pnacross Number across rows (the default is to number down columns).
\pnhang Paragraph uses a hanging indent.
\pnrestart Restart numbering after each section break. Note that this control word is used only in conjunction with the Heading Numbering feature (applying multilevel numbering to Heading style definitions).
\pncard Cardinal numbering (One, Two, Three).
\pndec Decimal numbering (1, 2, 3).
\pnucltr Uppercase alphabetic numbering (A, B, C).
\pnucrm Uppercase roman numbering (I, II, III).
\pnlcltr Lowercase alphabetic numbering (a, b, c).
\pnlcrm Lowercase roman numbering. (i, ii, iii).
\pnord Ordinal numbering (1st, 2nd, 3rd).
\pnordt Ordinal text numbering (First, Second, Third).
\pnb Bold numbering.*
\pni Italic numbering.*
\pncaps All Caps numbering.*
\pnscaps Small Caps numbering.*
\pnul Continuous underline.*
\pnuld Dotted underline.
\pnuldb Double underline.
\pnulnone Turns off underlining.
\pnulw Word underline.
\pnstrike Strikethrough numbering.*
\pncfN Foreground color--index into color table (the default is 0).
\pnfN Font number.
\pnfsN Font size (in half-points).
\pnindentN Minimum distance from margin to body text.
\pnspN Distance from number text to body text.
\pnprev Used for multilevel lists. Include information from previous level in this level; for example, 1, 1.1, 1.1.1, 1.1.1.1
\pnqc Centered numbering.
\pnql Left-justified numbering.
\pnqr Right-justified numbering.
\pnstartN Start at number.
\pntxta Text after. This group contains the text that succeeds the number. This is a destination control word.
\pntxtb Text before. This group contains the text that precedes the number. This is a destination control word.

 

Note that there is a limit of 32 characters total for the sum of text before and text after for simple numbering. Multilevel numbering has a limit of 64 characters total for the sum of all levels.

Word 97 RTF

Each paragraph that is part of a list must contain some keyword to indicate which list it's in, and which level of the list it belongs to. Word 97 also provides the flat text representation of each number (in the \listtext destination); so, RTF readers that don't understand Word 97 numbering will get the paragraph number, along with appropriate character properties, inserted into their document at the beginning of the paragraph. Any RTF reader that does understand Word 97 numbering should ignore the entire \listtext destination.

Control word Meaning
\ls Should exactly match the ls for one of the list overrides in the List Override table.
\ilvl The 0-based level of the list to which the paragraph belongs. For all simple lists, this should always be 0 . For multilevel lists, it can be 0-8.
\listtext Contains the flat text representation of the number, including character properties. Should be ignored by any reader that understands Word 97 numbering. This is a destination control word.

 

REVISION MARKS FOR PARAGRAPH NUMBERS

Paragraph numbers and ListNum fields track revision information with special properties applied to the paragraph mark and ListNum field, respectively. The special properties hold the "old" value of the number--the value it held when revision-mark tracking began. At display time, Word checks the number's current value and compares it with this "old" value to tell if it has changed. If the numbers are different, the old value shows up as deleted and the new value as inserted; if the numbers are the same, Word displays the new value normally, with no revision information. If there was no old value, the new value shows up as inserted. The following table lists the RTF specifications for these special properties.

Track Changes (Revision mark) properties for paragraph numbers

\pnrauthN Index into the revision table. The content of the Nth group in the revision table is considered to be the author of that revision.

Note This keyword is used to indicate paragraph number revisions.

\pnrdateN Time of the revision. The 32-bit DTTM structure is emitted as a long integer.
\pnrnot Indicates if the paragraph number for the current paragraph is marked as "inserted."
\pnrxstN The keywords \pnrxst, \pnrrgb, \pnrpnbr, and \pnrnfc describe the "deleted number" text for the paragraph number. Their values are binary. Each of these keywords is represented as an array. The deleted number is written out with a \pnrstart keyword, followed by the array's keyword, followed by the first byte of the array, followed by the array's keyword, followed by the second byte of the array's keyword, followed by the array's keyword, followed by the third byte of the array's keyword, and so on. This sequence is followed by the \pnrstop keyword.

\pnrxst is a 32-item Unicode character array (double bytes for each character) with a length byte as the first number--it has the actual text of the number, with "level" place holders written out as digits from 0-8.

\pnrrgbN Nine-item array of indices of the level place holders in the \pnrxst array.
\pnrnfcN Nine-item array containing the number format codes of each level (using the same values as the \levelnfc keyword). The number format code is represented as a short integer.
\pnrpnbrN Nine-item array of the actual values of the number in each level. The number is represented as a long integer
\pnrstartN The \pnrxst, \pnrrgb, \pnrpnbr, and \pnrnfc arrays are each preceded by the \pnrstart keyword, whose argument is 0-3 depending on the array.
\pnrstopN The \pnrxst, \pnrrgb, \pnrpnbr, and \pnrnfc arrays are each terminated by the \pnrstop keyword, whose argument is the number of bytes written out in the array.

 

Example:

Let's take an example of the number "3-4b." which represents the third level of the list. The following table lists the values of each array.

Array Binary Comment
pnrxst \'05\'00-\'01\'02 The length of the string is 5. Then, first level (level 0), followed by a dash, followed by the second and third levels (levels 1 and 2), followed by a period.
Pnrrgb \'01\'03\'04 The level place holders are at indices 1, 3, and 4 in the string.
Pnrnfc \'00\'00\'04 The nfc values are Arabic (0), Arabic (0), and lowercase letter (4).
Pnrpnbr \'03\'04\'02 The numbers or 3, 4, and 2 (b)

 

Here is the RTF for this number:

\pnrstart0

\pnrxst0\pnrxst5\pnrxst0\pnrxst1\pnrxst0\pnrxst45\pnrxst0\pnrxst2\pnrxst0\pnrxst3\pnrxst0\pnrxst46

\pnrstop12

\pnrstart1

\pnrrgb1\pnrrgb3\pnrrgb4

\pnrrgb0\pnrrgb0\pnrrgb0

\pnrrgb0\pnrrgb0\pnrrgb0

\pnrstop9

\pnrstart2

\pnrnfc0\pnrnfc0\pnrnfc0\pnrnfc0\pnrnfc0\pnrnfc4

\pnrnfc0\pnrnfc0\pnrnfc0\pnrnfc0\pnrnfc0\pnrnfc0

\pnrnfc0\pnrnfc0\pnrnfc0\pnrnfc0\pnrnfc0\pnrnfc0

\pnrstop18

\pnrstart3

\pnrpnbr0\pnrpnbr0\pnrpnbr0\pnrpnbr3

\pnrpnbr0\pnrpnbr0\pnrpnbr0\pnrpnbr4

\pnrpnbr0\pnrpnbr0\pnrpnbr0\pnrpnbr2

\pnrpnbr0\pnrpnbr0\pnrpnbr0\pnrpnbr0

\pnrpnbr0\pnrpnbr0\pnrpnbr0\pnrpnbr0

\pnrpnbr0\pnrpnbr0\pnrpnbr0\pnrpnbr0

\pnrpnbr0\pnrpnbr0\pnrpnbr0\pnrpnbr0

\pnrpnbr0\pnrpnbr0\pnrpnbr0\pnrpnbr0

\pnrpnbr0\pnrpnbr0\pnrpnbr0\pnrpnbr0

\pnrstop36

Control word Meaning

Track Changes (Revision mark) properties for ListNum fields

\dfrauthN Index into the revision table. The content of the Nth group in the revision table is considered the author of that revision.

Note This keyword is used to indicate the deleted value of a ListNum field.

\dfrdateN Time of the revision. The 32-bit DTTM structure is emitted as a long integer.
\dfrxst Unicode character array with a length byte.
\dfrstart The \dfrxst array is preceded by the \dfrstart keyword.
\dfrstop The \dfrxst array is terminated by the \dfrstop keyword.

 

Example:

Let's take the sample example from above. The deleted value is "3-4b." The RTF would then be

\dfrstart0\dfrxst0\dfrxst5\dfrxst0\dfrxst51\dfrxst0\dfrxst45\dfrxst0\dfrxst52

\dfrxst0\dfrxst66\dfrxst0\dfrxst46\dfrstop10

where 5 is the length byte, 51 is Unicode for "3", 45 is Unicode for "-", 52 is Unicode for "4", and so on.

Paragraph Borders

Paragraph borders have the following syntax:

<brdrdef> (<brdrseg> <brdr> )+
<brdrseg> \brdrt | \brdrb | \brdrl | \brdrr | \brdrbtw | \brdrbar | \box
<brdr> <brdrk> \brdrw? \brsp? \brdrcf?
<brdrk> \brdrs | \brdrth | \brdrsh | \brdrdb | \brdrdot | \brdrdash | \brdrhair

 

Control word Meaning
\brdrt Border top.
\brdrb Border bottom.
\brdrl Border left.
\brdrr Border right.
\brdrbtw Consecutive paragraphs with identical border formatting are considered part of a single group with the border information applying to the entire group. To have borders around individual paragraphs within the group, the \brdrbtw control must be specified for that paragraph.
\brdrbar Border outside (right side of odd-numbered pages, left side of even-numbered pages).
\box Border around the paragraph (box paragraph).
\brdrs Single-thickness border.
\brdrth Double-thickness border.
\brdrsh Shadowed border.
\brdrdb Double border.
\brdrdot Dotted border.
\brdrdash Dashed border.
\brdrhair Hairline border.
\brdrdashsm Dash border (small).
\brdrdashd Dot dash border.
\brdrdashdd Dot dot dash border.
\brdrtriple Triple border.
\brdrtnthsg Thick thin border (small).
\brdrthtnsg Thin thick border (small).
\brdrtnthtnsg Thin thick thin border (small).
\brdrtnthmg Thick thin border (medium).
\brdrthtnmg Thin thick border (medium).
\brdrtnthtnmg Thin thick thin border (medium).
\brdrtnthlg Thick thin border (large).
\brdrthtnlg Thin thick border (large).
\brdrtnthtnlg Thin thick thin border (large).
\brdrwavy Wavy border.
\brdrwavydb Double wavy border.
\brdrdashdotstr Striped border.
\brdremboss Emboss border.
\brdrengrave Engrave border.
\brdrwN N is the width in twips of the pen used to draw the paragraph border line. N cannot be greater than 75. To obtain a larger border width, the \brdth control word can be used to obtain a width double that of N.
\brdrcfN N is the color of the paragraph border, specified as an index into the color table in the RTF header.
\brspN Space in twips between borders and the paragraph.

 

Paragraph Shading

Paragraph shading has the following syntax:

<shading> (\shading | <pat>) \cfpat? \cbpat?
<pat> \bghoriz | \bgvert | \bgfdiag | \bgbdiag | \bgcross | \bgdcross | \bgdkhoriz | \bgdkvert | \bgdkfdiag | \bgdkbdiag | \bgdkcross | \bgdkdcross

 

Control word Meaning
\shadingN N is the shading of the paragraph in hundredths of a percent.
\bghoriz Specifies a horizontal background pattern for the paragraph.
\bgvert Specifies a vertical background pattern for the paragraph.
\bgfdiag Specifies a forward diagonal background pattern for the paragraph (\\\\).
\bgbdiag Specifies a backward diagonal background pattern for the paragraph (////).
\bgcross Specifies a cross background pattern for the paragraph.
\bgdcross Specifies a diagonal cross background pattern for the paragraph.
\bgdkhoriz Specifies a dark horizontal background pattern for the paragraph.
\bgdkvert Specifies a dark vertical background pattern for the paragraph.
\bgdkfdiag Specifies a dark forward diagonal background pattern for the paragraph (\\\\).
\bgdkbdiag Specifies a dark backward diagonal background pattern for the paragraph (////).
\bgdkcross Specifies a dark cross background pattern for the paragraph.
\bgdkdcross Specifies a dark diagonal cross background pattern for the paragraph.
\cfpatN N is the fill color, specified as an index into the document's color table.
\cbpatN N is the background color of the background pattern, specified as an index into the document's color table.

 

Positioned Objects and Frames

The following paragraph-formatting control words specify the location of a paragraph on the page. Consecutive paragraphs with the same frame formatting are considered part of the same frame. For two framed paragraphs to appear at the same position on a page, they must be separated by a paragraph with different or no frame information.

Note that if any paragraph in a table row has any of these control words specified, then all paragraphs in the table row must have the same control words specified, either by inheriting the properties from the previous paragraph or by re-specifying the controls.

Paragraph positioning has the following syntax:

<apoctl> <framesize> & <horzpos> & <vertpos> & <txtwrap> & <dropcap>
<framesize> \absw? & \absh?
<horzpos> <hframe> & <hdist>
<vertpos> <vframe> & <vdist>
<txtwrap> \nowrap? & \dxfrtext? & \dfrmtxtx? &\dfrmtxty?
<dropcap> \dropcapli? & \dropcapt?
<hframe> \phmrg? | \phpg? | \phcol?
<hdist> \posx? | \posnegx? | \posxc? | \posxi? | \posxo? | \posxl? | \posxr?
<vframe> \pvmrg? | \pvpg? | \pvpara?
<vdist> \posy? | \posnegy? | \posyt? | \posyil? | \posyb? | \posyc? & \abslock

 

Control word Meaning
\abswN N is the width of the frame in twips.
\abshN N is the height of the frame in twips. A positive number indicates the minimum height of the frame and a negative number indicates the exact height of the frame. A value of zero indicates that the height of the frame adjusts to the contents of the frame. This is the default for frames where no height is given.

Horizontal Position

\phmrg Use the margin as the horizontal reference frame.
\phpg Use the page as the horizontal reference frame.
\phcol Use the column as the horizontal reference frame. This is the default if no horizontal reference frame is given.
\posxN Positions the frame N twips from the left edge of the reference frame.
\posnegxN Same as \posx but allows arbitrary negative values.
\posxc Centers the frame horizontally within the reference frame.
\posxi Positions the paragraph horizontally inside the reference frame.
\posxo Positions the paragraph horizontally outside the reference frame.
\posxr Positions the paragraph to the right within the reference frame.
\posxl Positions the paragraph to the left within the reference frame. This is the default if no horizontal positioning information is given.

Vertical Position

\pvmrg Positions the reference frame vertically relative to the margin. This is the default if no vertical frame positioning information is given.
\pvpg Positions the reference frame vertically relative to the page.
\pvpara Positions the reference frame vertically relative to the top of the top left corner of the next unframed paragraph in the RTF stream.
\posyN Positions the paragraph N twips from the top edge of the reference frame.
\posnegyN Same as \posy but allows arbitrary negative values.
\posyil Positions the paragraph vertically to be in-line.
\posyt Positions the paragraph at the top of the reference frame.
\posyc Centers the paragraph vertically within the reference frame.
\posyb Positions the paragraph at the bottom of the reference frame.
\abslock Locks a frame anchor to the current paragraph that it is associated with.

Text Wrapping

\nowrap Prevents text from flowing around the positioned object.
\dxfrtextN Distance in twips of a positioned paragraph from text in the main text flow in all directions.
\dfrmtxtxN N is the horizontal distance in twips from text on both sides of the frame.
\dfrmtxtyN N is the vertical distance in twips from text on both sides of the frame.
\overlay Text flows underneath frame.
\posyin Positions the paragraph vertically inside the reference frame.
\posyout Positions the paragraph vertically outside the reference frame.

Drop Caps

\dropcapliN Number of lines drop cap is to occupy. The range is 1 through 10.
\dropcaptN Type of drop cap:

1 In-text drop cap

2 Margin drop cap

 

The following is an example of absolute-positioned text in a document:

\par \pard \pvpg\phpg\posxc\posyt\absw5040\dxfrtest173 First APO para
\par \pard \phmrg\posxo\posyc\dxfrtext1152 Second APO para

Table Definitions

There is no RTF table group; instead, tables are specified as paragraph properties. A table is represented as a sequence of table rows. A table row is a continuous sequence of paragraphs partitioned into cells. The table row begins with the \trowd control word and ends with the \row control word. Every paragraph that is contained in a table row must have the \intbl control word specified or inherited from the previous paragraph. A cell may have more than one paragraph in it; the cell is terminated by a cell mark (the \cell control word), and the row is terminated by a row mark (the \row control word). Table rows can also be positioned. In this case, every paragraph in a table row must have the same positioning controls (see the <apoctl> controls on page 29 of this Application Note). Table properties may be inherited from the previous row; therefore, a series of table rows may be introduced by a single <tbldef>.

An RTF table row has the following syntax, as shown in the general paragraph-text syntax shown on page 23 of this Application Note.

<row> <tbldef> <cell>+ \row
<cell> <textpar>+ \cell

A table definition has the following syntax:

<tbldef> \trowd \trgaph <rowjust>? & <rowwrite>? <rowtop>? & <rowbot>? & <rowleft>? & <rowright>? & <rowhor>? & <rowvert>? & \trleft? & \trrh? \trhdr? & \trkeep? <celldef>+
<rowjust> \trql | \trqr | \trqc
<rowwrite> \ltrrow | \rtlrow
<rowtop> \trbrdrt <brdr>
<rowbot> \trbrdrl <brdr>
<rowleft> \trbrdrb <brdr>
<rowright> \trbrdrr <brdr>
<rowhor> \trbrdrh <brdr>
<rowvert> \trbrdrv <brdr>
<celldef> (\clmgf? & \clmrg? <celltop>? & <cellleft>? & <cellbot>? & <cellright>? & <cellshad>?) \cellx
<celltop> \clbrdrt <brdr>
<cellleft> \clbrdrl <brdr>
<cellbot> \clbrdrb <brdr>
<cellright> \clbrdrr <brdr>
<cellshad> <cellpat>? \clcfpat? & \clcbpat? & \clshdng
<cellpat> \clbghoriz | \clbgvert | \clbgfdiag | \clbgbdiag | \clbgcross | \clbgdcross | \clbgdkhor | \clbgdkvert | \clbgdkfdiag | \clbgdkbdiag | \clbgdkcross | \clbgdkdcross

 

Note for <tbldef> that the number of \cellxs must match the number of \cells in the \row.

The following control words further define options for each row of the table.

Control word Meaning
\trowd Sets table row defaults.
\tcelld Sets table cell defaults.
\trgaphN Half the space between the cells of a table row in twips.
\cellxN Defines the right boundary of a table cell, including its half of the space between cells.
\clmgf The first cell in a range of table cells to be merged.
\clmrg Contents of the table cell are merged with those of the preceding cell.

Row Formatting

\trql Left-justifies a table row with respect to its containing column.
\trqr Right-justifies a table row with respect to its containing column.
\trqc Centers a table row with respect to its containing column.
\trleftN Position of the leftmost edge of the table with respect to the left edge of its column.
\trrhN Height of a table row in twips. When 0, the height is sufficient for all the text in the line; when positive, the height is guaranteed to be at least the specified height; when negative, the absolute value of the height is used, regardless of the height of the text in the line.
\trhdr Table row header. This row should appear at the top of every page the current table appears on.
\trkeep Table row keep together. This row cannot be split by a page break. This property is assumed to be off unless the control word is present.

Bidirectional Controls

\rtlrow Cells in this table row will have right-to-left precedence.
\ltrrow Cells in this table row will have left-to-right precedence (the default).

Row Borders

\trbrdrt Table row border top.
\trbrdrl Table row border left.
\trbrdrb Table row border bottom.
\trbrdrr Table row border right.
\trbrdrh Table row border horizontal (inside).
\trbrdrv Table row border vertical (inside).

Cell Borders

\clbrdrb Bottom table cell border.
\clbrdrt Top table cell border.
\clbrdrl Left table cell border.
\clbrdrr Right table cell border.

Cell Shading and Background Pattern

\clshdngN N is the shading of a table cell in hundredths of a percent. This control should be included in RTF along with cell border information.
\clbghoriz Specifies a horizontal background pattern for the cell.
\clbgvert Specifies a vertical background pattern for the cell.
\clbgfdiag Specifies a forward diagonal background pattern for the cell (\\\\).
\clbgbdiag Specifies a backward diagonal background pattern for the cell (////).
\clbgcross Specifies a cross background pattern for the cell.
\clbgdcross Specifies a diagonal cross background pattern for the cell.
\clbgdkhor Specifies a dark horizontal background pattern for the cell.
\clbgdkvert Specifies a dark vertical background pattern for the cell.
\clbgdkfdiag Specifies a dark forward diagonal background pattern for the cell (\\\\).
\clbgdkbdiag Specifies a dark backward diagonal background pattern for the cell (////).
\clbgdkcross Specifies a dark cross background pattern for the cell.
\clbgdkdcross Specifies a dark diagonal cross background pattern for the cell.
\clcfpatN N is the line color of the background pattern.
\clcbpatN N is the background color of the background pattern.

Vertical Text Alignment

\clvertalt Text is top-aligned in cell (the default).
\clvertalc Text is centered vertically in cell.
\clvertalb Text is bottom-aligned in cell.
\cltxlrtb Vertical text aligned left (direction bottom up).
\cltxtbrl Vertical text aligned right (direction top down).

 

The following is an example of table text:

\par \trowd \trqc\trgaph108\trrh280\trleft36
\clbrdrt\brdrth \clbrdrl\brdrth \clbrdrb\brdrdb
\clbrdrr\brdrdb \cellx3636\clbrdrt\brdrth
\clbrdrl\brdrdb \clbrdrb\brdrdb \clbrdrr\brdrdb
\cellx7236\clbrdrt\brdrth \clbrdrl\brdrdb
\clbrdrb\brdrdb \clbrdrr\brdrdb \cellx10836\pard \intbl
\cell \pard \intbl \cell \pard \intbl \cell \pard \intbl \row
\trowd \trqc\trgaph108\trrh280\trleft36 \clbrdrt\brdrdb
\clbrdrl\brdrth \clbrdrb \brdrsh\brdrs \clbrdrr\brdrdb
\cellx3636\clbrdrt\brdrdb \clbrdr \brdrdb
\clbrdrb\brdrsh\brdrs \clbrdrr\brdrdb
\cellx7236\clbrdrt\brdrdb \clbrdr \brdrdb
\clbrdrb\brdrsh\brdrs \clbrdrr\brdrdb \cellx10836\pard
\intbl \cell \pard \intbl \cell \pard \intbl \cell \pard
\intbl \row \pard
Free Web Hosting