DragonFly On-Line Manual Pages

Search: Section:  


ROFF(7) 	  DragonFly Miscellaneous Information Manual	       ROFF(7)

NAME

roff -- roff language reference for mandoc

DESCRIPTION

The roff language is a general purpose text formatting language. Since traditional implementations of the mdoc(7) and man(7) manual formatting languages are based on it, many real-world manuals use small numbers of roff requests and escape sequences intermixed with their mdoc(7) or man(7) code. To properly format such manuals, the mandoc(1) utility sup- ports a subset of roff requests and escapes. Even though this manual page lists all roff requests and escape sequences, it only contains par- tial information about requests not supported by mandoc(1) and about lan- guage features that do not matter for manual pages. For complete roff manuals, consult the SEE ALSO section. Input lines beginning with the control character `.' are parsed for requests and macros. Such lines are called ``request lines'' or ``macro lines'', respectively. Requests change the processing state and manipu- late the formatting; some macros also define the document structure and produce formatted output. The single quote ("'") is accepted as an alternative control character, treated by mandoc(1) just like `.' Lines not beginning with control characters are called ``text lines''. They provide free-form text to be printed; the formatting of the text depends on the respective processing context.

LANGUAGE SYNTAX

roff documents may contain only graphable 7-bit ASCII characters, the space character, and, in certain circumstances, the tab character. The backslash character `\' indicates the start of an escape sequence, used for example for Comments and Special Characters. For a complete listing of escape sequences, consult the ESCAPE SEQUENCE REFERENCE below. Comments Text following an escaped double-quote `\"', whether in a request, macro, or text line, is ignored to the end of the line. A request line begin- ning with a control character and comment escape `.\"' is also ignored. Furthermore, request lines with only a control character and optional trailing whitespace are stripped from input. Examples: .\" This is a comment line. .\" The next line is ignored: . .Sh EXAMPLES \" This is a comment, too. example text \" And so is this. Special Characters Special characters are used to encode special glyphs and are rendered differently across output media. They may occur in request, macro, and text lines. Sequences begin with the escape character `\' followed by either an open-parenthesis `(' for two-character sequences; an open- bracket `[' for n-character sequences (terminated at a close-bracket `]'); or a single one character sequence. Examples: \(em Two-letter em dash escape. \e One-letter backslash escape. See mandoc_char(7) for a complete list. Font Selection In mdoc(7) and man(7) documents, fonts are usually selected with macros. The \f escape sequence and the ft request can be used to manually change the font, but this is not recommended in mdoc(7) documents. Such manual font changes are overridden by many subsequent macros. The following fonts are supported: B Bold font. BI A font that is both bold and italic. CB Bold constant width font. Same as B in terminal output. CI Italic constant width font. Same as I in terminal output. CR Regular constant width font. Same as R in terminal output. CW An alias for CR. I Italic font. P Return to the previous font. If a macro caused a font change since the last \f eascape sequence or ft request, this returns to the font before the last font change in the macro rather than to the font before the last manual font change. R Roman font. This is the default font. 1 An alias for R. 2 An alias for I. 3 An alias for B. 4 An alias for BI. Examples: \fBbold\fR Write in bold, then switch to regular font mode. \fIitalic\fP Write in italic, then return to previous font mode. \f(BIbold italic\fP Write in bboolldd iittaalliicc, then return to previous font mode. Whitespace Whitespace consists of the space character. In text lines, whitespace is preserved within a line. In request and macro lines, whitespace delimits arguments and is discarded. Unescaped trailing spaces are stripped from text line input unless in a literal context. In general, trailing whitespace on any input line is discouraged for reasons of portability. In the rare case that a space character is needed at the end of an input line, it may be forced by `\ \&'. Literal space characters can be produced in the output using escape sequences. In macro lines, they can also be included in arguments using quotation; see MACRO SYNTAX for details. Blank text lines, which may include whitespace, are only permitted within literal contexts. If the first character of a text line is a space, that line is printed with a leading newline. Scaling Widths Many requests and macros support scaled widths for their arguments. The syntax for a scaled width is `[+-]?[0-9]*.[0-9]*[:unit:]', where a deci- mal must be preceded or followed by at least one digit. The following scaling units are accepted: c centimetre i inch P pica (1/6 inch) p point (1/72 inch) f scale `u' by 65536 v default vertical span m width of rendered `m' (em) character n width of rendered `n' (en) character u default horizontal span for the terminal M mini-em (1/100 em) Using anything other than `m', `n', or `v' is necessarily non-portable across output media. See COMPATIBILITY. If a scaling unit is not provided, the numerical value is interpreted under the default rules of `v' for vertical spaces and `u' for horizontal ones. Examples: .Bl -tag -width 2i two-inch tagged list indentation in mdoc(7) .HP 2i two-inch tagged list indentation in man(7) .sp 2v two vertical spaces Sentence Spacing Each sentence should terminate at the end of an input line. By doing this, a formatter will be able to apply the proper amount of spacing after the end of sentence (unescaped) period, exclamation mark, or ques- tion mark followed by zero or more non-sentence closing delimiters (`)', `]', `'', `"'). The proper spacing is also intelligently preserved if a sentence ends at the boundary of a macro line. Examples: Do not end sentences mid-line like this. Instead, end a sentence like this. A macro would end like this: .Xr mandoc 1 .

REQUEST SYNTAX

A request or macro line consists of: 1. the control character `.' or `'' at the beginning of the line, 2. optionally an arbitrary amount of whitespace, 3. the name of the request or the macro, which is one word of arbitrary length, terminated by whitespace, 4. and zero or more arguments delimited by whitespace. Thus, the following request lines are all equivalent: .ig end .ig end . ig end

MACRO SYNTAX

Macros are provided by the mdoc(7) and man(7) languages and can be defined by the de request. When called, they follow the same syntax as requests, except that macro arguments may optionally be quoted by enclos- ing them in double quote characters (`"'). Quoted text, even if it con- tains whitespace or would cause a macro invocation when unquoted, is always considered literal text. Inside quoted text, pairs of double quote characters (`""') resolve to single double quote characters. To be recognised as the beginning of a quoted argument, the opening quote character must be preceded by a space character. A quoted argument extends to the next double quote character that is not part of a pair, or to the end of the input line, whichever comes earlier. Leaving out the terminating double quote character at the end of the line is discouraged. For clarity, if more arguments follow on the same input line, it is rec- ommended to follow the terminating double quote character by a space character; in case the next character after the terminating double quote character is anything else, it is regarded as the beginning of the next, unquoted argument. Both in quoted and unquoted arguments, pairs of backslashes (`\\') resolve to single backslashes. In unquoted arguments, space characters can alternatively be included by preceding them with a backslash (`\ '), but quoting is usually better for clarity. Examples: .Fn strlen "const char *s" Group arguments "const char *s" into one function argument. If unspecified, "const", "char", and "*s" would be consid- ered separate arguments. .Op "Fl a" Consider "Fl a" as literal text instead of a flag macro.

REQUEST REFERENCE

The mandoc(1) roff parser recognises the following requests. For requests marked as "ignored" or "unsupported", any arguments are ignored, and the number of arguments is not checked. ab [message] Abort processing. Currently unsupported. ad [b | c | l | n | r] Set line adjustment mode for subsequent text. Currently ignored. af registername format Assign an output format to a number register. Currently ignored. aln newname oldname Create an alias for a number register. Currently unsupported. als newname oldname Create an alias for a request, string, macro, or diversion. am macroname [endmacro] Append to a macro definition. The syntax of this request is the same as that of de. am1 macroname [endmacro] Append to a macro definition, switching roff compatibility mode off during macro execution (groff extension). The syntax of this request is the same as that of de1. Since mandoc(1) does not implement roff compatibility mode at all, it handles this request as an alias for am. ami macrostring [endstring] Append to a macro definition, specifying the macro name indi- rectly (groff extension). The syntax of this request is the same as that of dei. ami1 macrostring [endstring] Append to a macro definition, specifying the macro name indi- rectly and switching roff compatibility mode off during macro execution (groff extension). The syntax of this request is the same as that of dei1. Since mandoc(1) does not implement roff compatibility mode at all, it handles this request as an alias for ami. as stringname [string] Append to a user-defined string. The syntax of this request is the same as that of ds. If a user-defined string with the speci- fied name does not yet exist, it is set to the empty string before appending. as1 stringname [string] Append to a user-defined string, switching roff compatibility mode off during macro execution (groff extension). The syntax of this request is the same as that of ds1. Since mandoc(1) does not implement roff compatibility mode at all, it handles this request as an alias for as. asciify divname Fully unformat a diversion. Currently unsupported. backtrace Print a backtrace of the input stack. This is a groff extension and currently ignored. bd font [curfont] [offset] Artificially embolden by repeated printing with small shifts. Currently ignored. bleedat left top width height Set the BleedBox page parameter for PDF generation. This is a Heirloom extension and currently ignored. blm macroname Set a blank line trap. Currently unsupported. box divname Begin a diversion without including a partially filled line. Currently unsupported. boxa divname Add to a diversion without including a partially filled line. Currently unsupported. bp [*|-]pagenumber Begin a new page. Currently ignored. BP source height width position offset flags label Define a frame and place a picture in it. This is a Heirloom extension and currently unsupported. br Break the output line. break Break out of a while loop. Currently unsupported. breakchar char ... Optional line break characters. This is a Heirloom extension and currently ignored. brnl N Break output line after the next N input lines. This is a Heir- loom extension and currently ignored. brp Break and spread output line. Currently, this is implemented as an alias for br. brpnl N Break and spread output line after the next N input lines. This is a Heirloom extension and currently ignored. c2 [char] Change the no-break control character. Currently unsupported. cc [char] Change the control character. If char is not specified, the con- trol character is reset to `.'. Trailing characters are ignored. ce [N] Center the next N input lines without filling. N defaults to 1. An argument of 0 or less ends centering. Currently, high level macros abort centering. cf filename Output the contents of a file. Ignored because insecure. cflags flags char ... Set character flags. This is a groff extension and currently ignored. ch macroname [dist] Change a trap location. Currently ignored. char glyph [string] Define or redefine the ASCII character or character escape sequence glyph to be rendered as string, which can be empty. Only partially supported in mandoc(1); may interact incorrectly with tr. chop stringname Remove the last character from a macro, string, or diversion. Currently unsupported. class classname char ... Define a character class. This is a groff extension and cur- rently ignored. close streamname Close an open file. Ignored because insecure. CL color text Print text in color. This is a Heirloom extension and currently unsupported. color [1 | 0] Activate or deactivate colors. This is a groff extension and currently ignored. composite from to Define a name component for composite glyph names. This is a groff extension and currently unsupported. continue Immediately start the next iteration of a while loop. Currently unsupported. cp [1 | 0] Switch roff compatibility mode on or off. Currently ignored. cropat left top width height Set the CropBox page parameter for PDF generation. This is a Heirloom extension and currently ignored. cs font [width [emsize]] Constant character spacing mode. Currently ignored. cu [N] Underline next N input lines including whitespace. Currently ignored. da divname Append to a diversion. Currently unsupported. dch macroname [dist] Change a trap location in the current diversion. This is a Heir- loom extension and currently unsupported. de macroname [endmacro] Define a roff macro. Its syntax can be either .de macroname definition .. or .de macroname endmacro definition .endmacro Both forms define or redefine the macro macroname to represent the definition, which may consist of one or more input lines, including the newline characters terminating each line, option- ally containing calls to roff requests, roff macros or high-level macros like man(7) or mdoc(7) macros, whichever applies to the document in question. Specifying a custom endmacro works in the same way as for ig; namely, the call to `.endmacro' first ends the definition, and after that, it is also evaluated as a roff request or roff macro, but not as a high-level macro. The macro can be invoked later using the syntax .macroname [argument [argument ...]] Regarding argument parsing, see MACRO SYNTAX above. The line invoking the macro will be replaced in the input stream by the definition, replacing all occurrences of \\$N, where N is a digit, by the Nth argument. For example, .de ZN \fI\^\\$1\^\fP\\$2 .. .ZN XtFree . produces \fI\^XtFree\^\fP. in the input stream, and thus in the output: XtFree. Each occur- rence of \\$* is replaced with all the arguments, joined together with single space characters. The variant \\$@ is similar, except that each argument is individually quoted. Since macros and user-defined strings share a common string ta- ble, defining a macro macroname clobbers the user-defined string macroname, and the definition can also be printed using the `\*' string interpolation syntax described below ds, but this is rarely useful because every macro definition contains at least one explicit newline character. In order to prevent endless recursion, both groff and mandoc(1) limit the stack depth for expanding macros and strings to a large, but finite number, and mandoc(1) also limits the length of the expanded input line. Do not rely on the exact values of these limits. de1 macroname [endmacro] Define a roff macro that will be executed with roff compatibility mode switched off during macro execution. This is a groff exten- sion. Since mandoc(1) does not implement roff compatibility mode at all, it handles this request as an alias for de. defcolor newname scheme component ... Define a color name. This is a groff extension and currently ignored. dei macrostring [endstring] Define a roff macro, specifying the macro name indirectly (groff extension). The syntax of this request is the same as that of de. The effect is the same as: .de \*[macrostring] [\*[endstring]] dei1 macrostring [endstring] Define a roff macro that will be executed with roff compatibility mode switched off during macro execution, specifying the macro name indirectly (groff extension). Since mandoc(1) does not implement roff compatibility mode at all, it handles this request as an alias for dei. device string ... devicem stringname These two requests only make sense with the groff-specific inter- mediate output format and are unsupported. di divname Begin a diversion. Currently unsupported. do command [argument ...] Execute roff request or macro line with compatibility mode dis- abled. Currently unsupported. ds stringname [["]string] Define a user-defined string. The stringname and string argu- ments are space-separated. If the string begins with a double- quote character, that character will not be part of the string. All remaining characters on the input line form the string, including whitespace and double-quote characters, even trailing ones. The string can be interpolated into subsequent text by using \*[stringname] for a stringname of arbitrary length, or \*(NN or \*N if the length of stringname is two or one characters, respec- tively. Interpolation can be prevented by escaping the leading backslash; that is, an asterisk preceded by an even number of backslashes does not trigger string interpolation. Since user-defined strings and macros share a common string ta- ble, defining a string stringname clobbers the macro stringname, and the stringname used for defining a string can also be invoked as a macro, in which case the following input line will be appended to the string, forming a new input line passed to the roff parser. For example, .ds badidea .S .badidea H SYNOPSIS invokes the SH macro when used in a man(7) document. Such abuse is of course strongly discouraged. ds1 stringname [["]string] Define a user-defined string that will be expanded with roff com- patibility mode switched off during string expansion. This is a groff extension. Since mandoc(1) does not implement roff compat- ibility mode at all, it handles this request as an alias for ds. dwh dist macroname Set a location trap in the current diversion. This is a Heirloom extension and currently unsupported. dt [dist macroname] Set a trap within a diversion. Currently unsupported. ec [char] Enable the escape mechanism and change the escape character. The char argument defaults to the backslash (`\'). ecr Restore the escape character. Currently unsupported. ecs Save the escape character. Currently unsupported. el body The ``else'' half of an if/else conditional. Pops a result off the stack of conditional evaluations pushed by ie and uses it as its conditional. If no stack entries are present (e.g., due to no prior ie calls) then false is assumed. The syntax of this request is similar to if except that the conditional is missing. em macroname Set a trap at the end of input. Currently unsupported. EN End an equation block. See EQ. eo Disable the escape mechanism completely. EP End a picture started by BP. This is a Heirloom extension and currently unsupported. EQ Begin an equation block. See eqn(7) for a description of the equation language. errprint message Print a string like an error message. This is a Heirloom exten- sion and currently ignored. ev [envname] Switch to another environment. Currently unsupported. evc [envname] Copy an environment into the current environment. Currently unsupported. ex Abort processing and exit. Currently unsupported. fallback curfont font ... Select the fallback sequence for a font. This is a Heirloom extension and currently ignored. fam [familyname] Change the font family. This is a groff extension and currently ignored. fc [delimchar [padchar]] Define a delimiting and a padding character for fields. Cur- rently unsupported. fchar glyphname [string] Define a fallback glyph. Currently unsupported. fcolor colorname Set the fill color for \D objects. This is a groff extension and currently ignored. fdeferlig font string ... Defer ligature building. This is a Heirloom extension and cur- rently ignored. feature *|-name Enable or disable an OpenType feature. This is a Heirloom exten- sion and currently ignored. fi Break the output line and switch to fill mode, which is active by default but can be ended with the nf request. In fill mode, input from subsequent input lines is added to the same output line until the next word no longer fits, at which point the out- put line is broken. This request is implied by the mdoc(7) Sh macro and by the man(7) SH, SS, and EE macros. fkern font minkern Control the use of kerning tables for a font. This is a Heirloom extension and currently ignored. fl Flush output. Currently ignored. flig font string char ... Define ligatures. This is a Heirloom extension and currently ignored. fp position font [filename] Assign font position. Currently ignored. fps mapname ... Mount a font with a special character map. This is a Heirloom extension and currently ignored. fschar font glyphname [string] Define a font-specific fallback glyph. This is a groff extension and currently unsupported. fspacewidth font [afmunits] Set a font-specific width for the space character. This is a Heirloom extension and currently ignored. fspecial curfont [font ...] Conditionally define a special font. This is a groff extension and currently ignored. ft [font] Change the font; see Font Selection. The font argument defaults to P. ftr newname [oldname] Translate font name. This is a groff extension and currently ignored. fzoom font [permille] Zoom font size. Currently ignored. gcolor [colorname] Set glyph color. This is a groff extension and currently ignored. hc [char] Set the hyphenation character. Currently ignored. hcode char code ... Set hyphenation codes of characters. Currently ignored. hidechar font char ... Hide characters in a font. This is a Heirloom extension and cur- rently ignored. hla language Set hyphenation language. This is a groff extension and cur- rently ignored. hlm [number] Set maximum number of consecutive hyphenated lines. Currently ignored. hpf filename Load hyphenation pattern file. This is a groff extension and currently ignored. hpfa filename Load hyphenation pattern file, appending to the current patterns. This is a groff extension and currently ignored. hpfcode code code ... Define mapping values for character codes in hyphenation pat- terns. This is a groff extension and currently ignored. hw word ... Specify hyphenation points in words. Currently ignored. hy [mode] Set automatic hyphenation mode. Currently ignored. hylang language Set hyphenation language. This is a Heirloom extension and cur- rently ignored. hylen nchar Minimum word length for hyphenation. This is a Heirloom exten- sion and currently ignored. hym [length] Set hyphenation margin. This is a groff extension and currently ignored. hypp penalty ... Define hyphenation penalties. This is a Heirloom extension and currently ignored. hys [length] Set hyphenation space. This is a groff extension and currently ignored. ie condition body The ``if'' half of an if/else conditional. The result of the conditional is pushed into a stack used by subsequent invocations of el, which may be separated by any intervening input (or not exist at all). Its syntax is equivalent to if. if condition body Begin a conditional. This request can also be written as fol- lows: .if condition \{body body ...\} .if condition \{\ body ... .\} The condition is a boolean expression. Currently, mandoc(1) sup- ports the following subset of roff conditionals: * If `!' is prefixed to condition, it is logically inverted. * If the first character of condition is `n' (nroff mode) or `o' (odd page), it evaluates to true, and the body starts with the next character. * If the first character of condition is `e' (even page), `t' (troff mode), or `v' (vroff mode), it evaluates to false, and the body starts with the next character. * If the first character of condition is `c' (character available), it evaluates to true if the following character is an ASCII character or a valid character escape sequence, or to false otherwise. The body starts with the character following that next character. * If the first character of condition is `d', it evaluates to true if the rest of condition is the name of an existing user defined macro or string; otherwise, it evaluates to false. * If the first character of condition is `r', it evaluates to true if the rest of condition is the name of an existing num- ber register; otherwise, it evaluates to false. * If the condition starts with a parenthesis or with an option- ally signed integer number, it is evaluated according to the rules of Numerical expressions explained below. It evaluates to true if the result is positive, or to false if the result is zero or negative. * Otherwise, the first character of condition is regarded as a delimiter and it evaluates to true if the string extending from its first to its second occurrence is equal to the string extending from its second to its third occurrence. * If condition cannot be parsed, it evaluates to false. If a conditional is false, its children are not processed, but are syntactically interpreted to preserve the integrity of the input document. Thus, .if t .ig will discard the `.ig', which may lead to interesting results, but .if t .if t \{\ will continue to syntactically interpret to the block close of the final conditional. Sub-conditionals, in this case, obviously inherit the truth value of the parent. If the body section is begun by an escaped brace `\{', scope con- tinues until the end of the input line containing the matching closing-brace escape sequence `\}'. If the body is not enclosed in braces, scope continues until the end of the line. If the condition is followed by a body on the same line, whether after a brace or not, then requests and macros must begin with a control character. It is generally more intuitive, in this case, to write .if condition \{\ .request .\} than having the request or macro follow as .if condition \{.request The scope of a conditional is always parsed, but only executed if the conditional evaluates to true. Note that the `\}' is converted into a zero-width escape sequence if not passed as a standalone macro `.\}'. For example, .Fl a \} b will result in `\}' being considered an argument of the `Fl' macro. ig [endmacro] Ignore input. Its syntax can be either .ig ignored text .. or .ig endmacro ignored text .endmacro In the first case, input is ignored until a `..' request is encountered on its own line. In the second case, input is ignored until the specified `.endmacro' is encountered. Do not use the escape character `\' anywhere in the definition of endmacro; it would cause very strange behaviour. When the endmacro is a roff request or a roff macro, like in .ig if the subsequent invocation of if will first terminate the ignored text, then be invoked as usual. Otherwise, it only terminates the ignored text, and arguments following it or the `..' request are discarded. in [[*|-]width] Change indentation. See man(7). Ignored in mdoc(7). index register stringname substring Find a substring in a string. This is a Heirloom extension and currently unsupported. it expression macro Set an input line trap. The named macro will be invoked after processing the number of input text lines specified by the numer- ical expression. While evaluating the expression, the unit suf- fixes described below Scaling Widths are ignored. itc expression macro Set an input line trap, not counting lines ending with \c. Cur- rently unsupported. IX class keystring To support the generation of a table of contents, pod2man(1) emits this user-defined macro, usually without defining it. To avoid reporting large numbers of spurious errors, mandoc(1) ignores it. kern [1 | 0] Switch kerning on or off. Currently ignored. kernafter font char ... afmunits ... Increase kerning after some characters. This is a Heirloom extension and currently ignored. kernbefore font char ... afmunits ... Increase kerning before some characters. This is a Heirloom extension and currently ignored. kernpair font char ... font char ... afmunits Add a kerning pair to the kerning table. This is a Heirloom extension and currently ignored. lc [glyph] Define a leader repetition character. Currently unsupported. lc_ctype localename Set the LC_CTYPE locale. This is a Heirloom extension and cur- rently unsupported. lds macroname string Define a local string. This is a Heirloom extension and cur- rently unsupported. length register string Count the number of input characters in a string. Currently unsupported. letadj lspmin lshmin letss lspmax lshmax Dynamic letter spacing and reshaping. This is a Heirloom exten- sion and currently ignored. lf lineno [filename] Change the line number for error messages. Ignored because inse- cure. lg [1 | 0] Switch the ligature mechanism on or off. Currently ignored. lhang font char ... afmunits Hang characters at left margin. This is a Heirloom extension and currently ignored. linetabs [1 | 0] Enable or disable line-tabs mode. This is a groff extension and currently unsupported. ll [[*|-]width] Change the output line length. If the width argument is omitted, the line length is reset to its previous value. The default set- ting for terminal output is 78n. If a sign is given, the line length is added to or subtracted from; otherwise, it is set to the provided value. Using this request in new manuals is dis- couraged for several reasons, among others because it overrides the mandoc(1) -O width command line option. lnr register [*|-]value [increment] Set local number register. This is a Heirloom extension and cur- rently unsupported. lnrf register [*|-]value [increment] Set local floating-point register. This is a Heirloom extension and currently unsupported. lpfx string Set a line prefix. This is a Heirloom extension and currently unsupported. ls [factor] Set line spacing. It takes one integer argument specifying the vertical distance of subsequent output text lines measured in v units. Currently ignored. lsm macroname Set a leading spaces trap. This is a groff extension and cur- rently unsupported. lt [[*|-]width] Set title line length. Currently ignored. mc glyph [dist] Print margin character in the right margin. The dist is cur- rently ignored; instead, 1n is used. mediasize media Set the device media size. This is a Heirloom extension and cur- rently ignored. minss width Set minimum word space. This is a Heirloom extension and cur- rently ignored. mk [register] Mark vertical position. Currently ignored. mso filename Load a macro file using the search path. Ignored because inse- cure. na Disable adjusting without changing the adjustment mode. Cur- rently ignored. ne [height] Declare the need for the specified minimum vertical space before the next trap or the bottom of the page. Currently ignored. nf Break the output line and switch to no-fill mode. Subsequent input lines are kept together on the same output line even when exceeding the right margin, and line breaks in subsequent input cause output line breaks. This request is implied by the mdoc(7) Bd -unfilled and Bd -literal macros and by the man(7) EX macro. The fi request switches back to the default fill mode. nh Turn off automatic hyphenation mode. Currently ignored. nhychar char ... Define hyphenation-inhibiting characters. This is a Heirloom extension and currently ignored. nm [start [inc [space [indent]]]] Print line numbers. Currently unsupported. nn [number] Temporarily turn off line numbering. Currently unsupported. nop body Execute the rest of the input line as a request, macro, or text line, skipping the nop request and any space characters immedi- ately following it. This is mostly used to indent text lines inside macro definitions. nr register [*|-]expression [stepsize] Define or change a register. A register is an arbitrary string value that defines some sort of state, which influences parsing and/or formatting. For the syntax of expression, see Numerical expressions below. If it is prefixed by a sign, the register will be incremented or decremented instead of assigned to. The stepsize is used by the \n+ auto-increment feature. It remains unchanged when omitted while changing an existing regis- ter, and it defaults to 0 when defining a new register. The following register is handled specially: nS If set to a positive integer value, certain mdoc(7) macros will behave in the same way as in the SYNOPSIS section. If set to 0, these macros will behave in the same way as outside the SYNOPSIS section, even when called within the SYNOPSIS section itself. Note that starting a new mdoc(7) section with the Sh macro will reset this register. nrf register [*|-]expression [increment] Define or change a floating-point register. This is a Heirloom extension and currently unsupported. nroff Force nroff mode. This is a groff extension and currently ignored. ns Turn on no-space mode. Currently ignored. nx [filename] Abort processing of the current input file and process another one. Ignored because insecure. open stream file Open a file for writing. Ignored because insecure. opena stream file Open a file for appending. Ignored because insecure. os Output saved vertical space. Currently ignored. output string Output directly to intermediate output. Not supported. padj [1 | 0] Globally control paragraph-at-once adjustment. This is a Heir- loom extension and currently ignored. papersize media Set the paper size. This is a Heirloom extension and currently ignored. pc [char] Change the page number character. Currently ignored. pev Print environments. This is a groff extension and currently ignored. pi command Pipe output to a shell command. Ignored because insecure. PI Low-level request used by BP. This is a Heirloom extension and currently unsupported. pl [[*|-]height] Change page length. Currently ignored. pm Print names and sizes of macros, strings, and diversions to stan- dard error output. Currently ignored. pn [*|-]number Change the page number of the next page. Currently ignored. pnr Print all number registers on standard error output. Currently ignored. po [[*|-]offset] Set a horizontal page offset. If no argument is specified, the page offset is reverted to its previous value. If a sign is specified, the new page offset is calculated relative to the cur- rent one; otherwise, it is absolute. The argument follows the syntax of Scaling Widths and the default scaling unit is m. ps [[*|-]size] Change point size. Currently ignored. psbb filename Retrieve the bounding box of a PostScript file. Currently unsup- ported. pshape indent length ... Set a special shape for the current paragraph. This is a Heir- loom extension and currently unsupported. pso command Include output of a shell command. Ignored because insecure. ptr Print the names and positions of all traps on standard error out- put. This is a groff extension and currently ignored. pvs [[*|-]height] Change post-vertical spacing. This is a groff extension and cur- rently ignored. rchar glyph ... Remove glyph definitions. Currently unsupported. rd [prompt [argument ...]] Read from standard input. Currently ignored. recursionlimit maxrec maxtail Set the maximum stack depth for recursive macros. This is a Heirloom extension and currently ignored. return [twice] Exit the presently executed macro and return to the caller. The argument is currently ignored. rfschar font glyph ... Remove font-specific fallback glyph definitions. Currently unsupported. rhang font char ... afmunits Hang characters at right margin. This is a Heirloom extension and currently ignored. rj [N] Justify the next N input lines to the right margin without fill- ing. N defaults to 1. An argument of 0 or less ends right adjustment. rm macroname Remove a request, macro or string. rn oldname newname Rename a request, macro, diversion, or string. In mandoc(1), user-defined macros, mdoc(7) and man(7) macros, and user-defined strings can be renamed, but renaming of predefined strings and of roff requests is not supported, and diversions are not imple- mented at all. rnn oldname newname Rename a number register. Currently unsupported. rr register Remove a register. rs End no-space mode. Currently ignored. rt [dist] Return to marked vertical position. Currently ignored. schar glyph [string] Define global fallback glyph. This is a groff extension and cur- rently unsupported. sentchar char ... Define sentence-ending characters. This is a Heirloom extension and currently ignored. shc [glyph] Change the soft hyphen character. Currently ignored. shift [number] Shift macro arguments number times, by default once: \\$i becomes what \\$i+number was. Also decrement \n(.$ by number. sizes size ... Define permissible point sizes. This is a groff extension and currently ignored. so filename Include a source file. The file is read and its contents pro- cessed as input in place of the so request line. To avoid inad- vertent inclusion of unrelated files, mandoc(1) only accepts rel- ative paths not containing the strings "../" and "/..". This request requires man(1) to change to the right directory before calling mandoc(1), per convention to the root of the man- ual tree. Typical usage looks like: .so man3/Xcursor.3 As the whole concept is rather fragile, the use of so is discour- aged. Use ln(1) instead. sp [height] Break the output line and emit vertical space. The argument fol- lows the syntax of Scaling Widths and defaults to one blank line (1v). spacewidth [1 | 0] Set the space width from the font metrics file. This is a Heir- loom extension and currently ignored. special [font ...] Define a special font. This is a groff extension and currently ignored. spreadwarn [width] Warn about wide spacing between words. Currently ignored. ss wordspace [sentencespace] Set space character size. Currently ignored. sty position style Associate style with a font position. This is a groff extension and currently ignored. substring stringname startpos [endpos] Replace a user-defined string with a substring. Currently unsup- ported. sv [height] Save vertical space. Currently ignored. sy command Execute shell command. Ignored because insecure. T& Re-start a table layout, retaining the options of the prior table invocation. See TS. ta [width ... [T width ...]] Set tab stops. Each width argument follows the syntax of Scaling Widths. If prefixed by a plus sign, it is relative to the previ- ous tab stop. The arguments after the T marker are used repeat- edly as often as needed; for each reuse, they are taken relative to the last previously established tab stop. When ta is called without arguments, all tab stops are cleared. tc [glyph] Change tab repetition character. Currently unsupported. TE End a table context. See TS. ti [*|-]width Break the output line and indent the next output line by width. If a sign is specified, the temporary indentation is calculated relative to the current indentation; otherwise, it is absolute. The argument follows the syntax of Scaling Widths and the default scaling unit is m. tkf font minps width1 maxps width2 Enable track kerning for a font. Currently ignored. tl 'left'center'right' Print a title line. Currently unsupported. tm string Print to standard error output. Currently ignored. tm1 string Print to standard error output, allowing leading blanks. This is a groff extension and currently ignored. tmc string Print to standard error output without a trailing newline. This is a groff extension and currently ignored. tr glyph glyph ... Output character translation. The first glyph in each pair is replaced by the second one. Character escapes can be used; for example, tr \(xx\(yy replaces all invocations of \(xx with \(yy. track font minps width1 maxps width2 Static letter space tracking. This is a Heirloom extension and currently ignored. transchar char ... Define transparent characters for sentence-ending. This is a Heirloom extension and currently ignored. trf filename Output the contents of a file, disallowing invalid characters. This is a groff extension and ignored because insecure. trimat left top width height Set the TrimBox page parameter for PDF generation. This is a Heirloom extension and currently ignored. trin glyph glyph ... Output character translation, ignored by asciify. Currently unsupported. trnt glyph glyph ... Output character translation, ignored by \!. Currently unsup- ported. troff Force troff mode. This is a groff extension and currently ignored. TS Begin a table, which formats input in aligned rows and columns. See tbl(7) for a description of the tbl language. uf font Globally set the underline font. Currently ignored. ul [N] Underline next N input lines. Currently ignored. unformat divname Unformat spaces and tabs in a diversion. Currently unsupported. unwatch macroname Disable notification for string or macro. This is a Heirloom extension and currently ignored. unwatchn register Disable notification for register. This is a Heirloom extension and currently ignored. vpt [1 | 0] Enable or disable vertical position traps. This is a groff extension and currently ignored. vs [[*|-]height] Change vertical spacing. Currently ignored. warn flags Set warning level. Currently ignored. warnscale si Set the scaling indicator used in warnings. This is a groff extension and currently ignored. watch macroname Notify on change of string or macro. This is a Heirloom exten- sion and currently ignored. watchlength maxlength On change, report the contents of macros and strings up to the specified length. This is a Heirloom extension and currently ignored. watchn register Notify on change of register. This is a Heirloom extension and currently ignored. wh dist [macroname] Set a page location trap. Currently unsupported. while condition body Repeated execution while a condition is true, with syntax similar to if. Currently implemented with two restrictions: cannot nest, and each loop must start and end in the same scope. write ["]string Write to an open file. Ignored because insecure. writec ["]string Write to an open file without appending a newline. Ignored because insecure. writem macroname Write macro or string to an open file. Ignored because insecure. xflag level Set the extension level. This is a Heirloom extension and cur- rently ignored. Numerical expressions The nr, if, and ie requests accept integer numerical expressions as argu- ments. These are always evaluated using the C int type; integer overflow works the same way as in the C language. Numbers consist of an arbitrary number of digits `0' to `9' prefixed by an optional sign `+' or `-'. Each number may be followed by one optional scaling unit described below Scaling Widths. The following equations hold: 1i = 6v = 6P = 10m = 10n = 72p = 1000M = 240u = 240 254c = 100i = 24000u = 24000 1f = 65536u = 65536 The following binary operators are implemented. Unless otherwise stated, they behave as in the C language: * addition - subtraction * multiplication / division % remainder of division < less than > greater than == equal to = equal to, same effect as == (this differs from C) <= less than or equal to >= greater than or equal to <> not equal to (corresponds to C !=; this one is of limited portabil- ity, it is supported by Heirloom roff, but not by groff) & logical and (corresponds to C &&) : logical or (corresponds to C ||) <? minimum (not available in C) >? maximum (not available in C) There is no concept of precedence; evaluation proceeds from left to right, except when subexpressions are enclosed in parentheses. Inside parentheses, whitespace is ignored.

ESCAPE SEQUENCE REFERENCE

The mandoc(1) roff parser recognises the following escape sequences. In mdoc(7) and man(7) documents, using escape sequences is discouraged except for those described in the LANGUAGE SYNTAX section above. A backslash followed by any character not listed here simply prints that character itself. \<newline> A backslash at the end of an input line can be used to continue the logical input line on the next physical input line, joining the text on both lines together as if it were on a single input line. \<space> The escape sequence backslash-space (`\ ') is an unpaddable space-sized non-breaking space character; see Whitespace and mandoc_char(7). \! Embed text up to and including the end of the input line into the current diversion or into intermediate output without interpret- ing requests, macros, and escapes. Currently unsupported. \" The rest of the input line is treated as Comments. \# Line continuation with comment. Discard the rest of the physical input line and continue the logical input line on the next physi- cal input line, joining the text on both lines together as if it were on a single input line. This is a groff extension. \$arg Macro argument expansion, see de. \% Hyphenation allowed at this point of the word; ignored by mandoc(1). \& Non-printing zero-width character, often used for various kinds of escaping; see Whitespace, mandoc_char(7), and the ``MACRO SYNTAX'' and ``Delimiters'' sections in mdoc(7). \' Acute accent special character; use \(aa instead. \(cc Special Characters with two-letter names, see mandoc_char(7). \) Zero-width space transparent to end-of-sentence detection; ignored by mandoc(1). \*[name] Interpolate the string with the name. For short names, there are variants \*c and \*(cc. One string is predefined on the roff language level: \*(.T expands to the name of the output device, for example ascii, utf8, ps, pdf, html, or markdown. Macro sets traditionally predefine additional strings which are not portable and differ across implementations. Those supported by mandoc(1) are listed in mandoc_char(7). Strings can be defined, changed, and deleted with the ds, as, and rm requests. \, Left italic correction (groff extension); ignored by mandoc(1). \- Special character ``mathematical minus sign''; see mandoc_char(7) for details. \/ Right italic correction (groff extension); ignored by mandoc(1). \: Breaking the line is allowed at this point of the word without inserting a hyphen. \? Embed the text up to the next \? into the current diversion with- out interpreting requests, macros, and escapes. This is a groff extension and currently unsupported. \[name] Special Characters with names of arbitrary length, see mandoc_char(7). \^ One-twelfth em half-narrow space character, effectively zero- width in mandoc(1). \_ Underline special character; use \(ul instead. \` Grave accent special character; use \(ga instead. \{ Begin conditional input; see if. \| One-sixth em narrow space character, effectively zero-width in mandoc(1). \} End conditional input; see if. \~ Paddable non-breaking space character. \0 Digit width space character. \A'string' Anchor definition; ignored by mandoc(1). \a Leader character; ignored by mandoc(1). \B'string' Interpolate `1' if string conforms to the syntax of Numerical expressions explained above or `0' otherwise. \b'string' Bracket building function; ignored by mandoc(1). \C'name' Special Characters with names of arbitrary length. \c When encountered at the end of an input text line, the next input text line is considered to continue that line, even if there are request or macro lines in between. No whitespace is inserted. \D'string' Draw graphics function; ignored by mandoc(1). \d Move down by half a line; ignored by mandoc(1). \E Escape character intended to not be interpreted in copy mode. In mandoc(1), it currently does the same as \ itself. \e Backslash special character. \F[name] Switch font family (groff extension); ignored by mandoc(1). For short names, there are variants \Fc and \F(cc. \f[name] Switch to the font name, see Font Selection. For short names, there are variants \fc and \f(cc. An empty name \f[] defaults to \fP. \g[name] Interpolate the format of a number register; ignored by mandoc(1). For short names, there are variants \gc and \g(cc. \H'[+|-]number' Set the height of the current font; ignored by mandoc(1). \h'[|]width' Horizontal motion. If the vertical bar is given, the motion is relative to the current indentation. Otherwise, it is relative to the current position. The default scaling unit is m. \k[name] Mark horizontal input place in register; ignored by mandoc(1). For short names, there are variants \kc and \k(cc. \L'number[c]' Vertical line drawing function; ignored by mandoc(1). \l'width[c]' Draw a horizontal line of width using the glyph c. \M[name] Set fill (background) color (groff extension); ignored by mandoc(1). For short names, there are variants \Mc and \M(cc. \m[name] Set glyph drawing color (groff extension); ignored by mandoc(1). For short names, there are variants \mc and \m(cc. \N'number' Character number on the current font. \n[+|-][name] Interpolate the number register name. For short names, there are variants \nc and \n(cc. If the optional sign is specified, the register is first incremented or decremented by the stepsize that was specified in the relevant nr request, and the changed value is interpolated. \Odigit, \O[5arguments] Suppress output. This is a groff extension and currently unsup- ported. With an argument of 1, 2, 3, or 4, it is ignored. \o'string' Overstrike, writing all the characters contained in the string to the same output position. In terminal and HTML output modes, only the last one of the characters is visible. \p Break the output line at the end of the current word. \R'name [+|-]number' Set number register; ignored by mandoc(1). \r Move up by one line; ignored by mandoc(1). \S'number' Slant output; ignored by mandoc(1). \s'[+|-]number' Change point size; ignored by mandoc(1). Alternative forms \s[+|-]n, \s[+|-]'number', \s[[+|-]number], and \s[+|-][number] are also parsed and ignored. \t Horizontal tab; ignored by mandoc(1). \u Move up by half a line; ignored by mandoc(1). \V[name] Interpolate an environment variable; ignored by mandoc(1). For short names, there are variants \Vc and \V(cc. \v'number' Vertical motion; ignored by mandoc(1). \w'string' Interpolate the width of the string. The mandoc(1) implementa- tion assumes that after expansion of user-defined strings, the string only contains normal characters, no escape sequences, and that each character has a width of 24 basic units. \X'string' Output string as device control function; ignored in nroff mode and by mandoc(1). \x'number' Extra line space function; ignored by mandoc(1). \Y[name] Output a string as a device control function; ignored in nroff mode and by mandoc(1). For short names, there are variants \Yc and \Y(cc. \Z'string' Print string with zero width and height; ignored by mandoc(1). \z Output the next character without advancing the cursor position.

COMPATIBILITY

The mandoc(1) implementation of the roff language is incomplete. Major unimplemented features include: - For security reasons, mandoc(1) never reads or writes external files except via so requests with safe relative paths. - There is no automatic hyphenation, no adjustment to the right margin, and very limited support for centering; the output is always set flush-left. - Support for setting tabulator and leader characters is missing, and support for manually changing indentation is limited. - The `u' scaling unit is the default terminal unit. In traditional troff systems, this unit changes depending on the output media. - Width measurements are implemented in a crude way and often yield wrong results. Support for explicit movement requests and escapes is limited. - There is no concept of output pages, no support for floats, graphics drawing, and picture inclusion; terminal output is always continuous. - Requests regarding color, font families, font sizes, and glyph manip- ulation are ignored. Font support is very limited. Kerning is not implemented, and no ligatures are produced. - The "'" macro control character does not suppress output line breaks. - Diversions and environments are not implemented, and support for traps is very incomplete. - Use of macros is not supported inside tbl(7) code. The special semantics of the nS number register is an idiosyncracy of OpenBSD manuals and not supported by other mdoc(7) implementations.

SEE ALSO

mandoc(1), eqn(7), man(7), mandoc_char(7), mdoc(7), tbl(7) Joseph F. Ossanna and Brian W. Kernighan, Troff User's Manual, AT&T Bell Laboratories, Computing Science Technical Report, 54, 1976 and 1992. Joseph F. Ossanna, Brian W. Kernighan, and Gunnar Ritter, Heirloom Documentation Tools Nroff/Troff User's Manual, September 17, 2007.

HISTORY

The RUNOFF typesetting system, whose input forms the basis for roff, was written in MAD and FAP for the CTSS operating system by Jerome E. Saltzer in 1964. Doug McIlroy rewrote it in BCPL in 1969, renaming it roff. Dennis M. Ritchie rewrote McIlroy's roff in PDP-11 assembly for Version 1 AT&T UNIX, Joseph F. Ossanna improved roff and renamed it nroff for Version 2 AT&T UNIX, then ported nroff to C as troff, which Brian W. Kernighan released with Version 7 AT&T UNIX. In 1989, James Clarke re- implemented troff in C++, naming it groff.

AUTHORS

This roff reference was written by Kristaps Dzonsons <kristaps@bsd.lv> and Ingo Schwarze <schwarze@openbsd.org>. DragonFly 5.5 January 1, 2019 DragonFly 5.5 ROFF(7) ROFF(7)

NAME

roff - concepts and history of roff typesetting

DESCRIPTION

roff is the general name for a set of text formatting programs, known under names like troff, nroff, ditroff, groff, etc. A roff system con- sists of an extensible text formatting language and a set of programs for printing and converting to other text formats. Unix-like operating systems distribute a roff system as a core package. The most common roff system today is the free software implementation GNU roff, groff(1). groff implements the look-and-feel and functional- ity of its ancestors, with many extensions. The ancestry of roff is described in section HISTORY. In this docu- ment, the term roff always refers to the general class of roff pro- grams, not to the roff command provided in early UNIX systems. In spite of its age, roff is in wide use today, for example, the manual pages on UNIX systems (man pages), many software books, system documen- tation, standards, and corporate documents are written in roff. The roff output for text devices is still unmatched, and its graphical out- put has the same quality as other free type-setting programs and is better than some of the commercial systems. roff is used to format UNIX manual pages, (or man pages), the standard documentation system on many UNIX-derived operating systems. This document describes the history of the development of the roff sys- tem; some usage aspects common to all roff versions, details on the roff pipeline, which is usually hidden behind front-ends like groff(1); a general overview of the formatting language; some tips for editing roff files; and many pointers to further readings.

HISTORY

Document formatting by computer dates back to the 1960s. The roff sys- tem itself is intimately connected to the Unix operating system, but its roots go back to the earlier operating systems CTSS and Multics. The Predecessor RUNOFF roff's ancestor RUNOFF was written in the MAD language by Jerry Saltzer for the Compatible Time Sharing System (CTSS), a project of the Mas- sachusetts Institute of Technology (MIT), in 1963 and 1964 - note that CTSS commands were all uppercase. In 1965, MIT's Project MAC teamed with Bell Telephone Laboratories (BTL) and General Electric to begin the Multics system <http:// www.multicians.org>. A command called runoff was written for Multics in the late 60s in the BCPL language, by Bob Morris, Doug McIlroy, and other members of the Multics team. Like its CTSS ancestor, Multics runoff formatted an input file consist- ing of text and command lines; commands began with a period and were two letters. Output from these commands was to terminal devices such as IBM Selectric terminals. Multics runoff had additional features added, such as the ability to do two-pass formatting; it became the main format for Multics documentation and text processing. BCPL and runoff were ported to the GCOS system at Bell Labs when BTL left the development of Multics. The Classical nroff/troff System At BTL, there was a need to drive the Graphic Systems CAT typesetter, a graphical output device from a PDP-11 computer running Unix. As runoff was too limited for this task it was further developed into a more pow- erful text formatting system by Joseph F. Ossanna, who already pro- grammed several runoff ports. The name runoff was shortened to roff. The greatly enlarged language of Ossanna's version already included all elements of a full roff sys- tem. All modern roff systems try to implement compatibility to this system. So Joe Ossanna can be called the father of all roff systems. This first roff system had three formatter programs. troff (typesetter roff) generated a graphical output for the CAT type- setter as its only device. nroff produced text output suitable for terminals and line printers. roff was the reimplementation of the former runoff program with its limited features; this program was abandoned in later versions. Today, the name roff is used to refer to a troff/nroff system as a whole. Ossanna's first version was written in the PDP-11 assembly language and released in 1973. Brian Kernighan joined the roff development by rewriting it in the C programming language. The C version was released in 1975. The syntax of the formatting language of the nroff/troff programs was documented in the famous Troff User's Manual [CSTR #54], first pub- lished in 1976, with further revisions up to 1992 by Brian Kernighan. This document is the specification of the classical troff. All later roff systems tried to establish compatibility with this specification. After Ossanna's death in 1977, Kernighan went on with developing troff. In the late 1970s, Kernighan equipped troff with a general interface to support more devices, the intermediate output format, and the postpro- cessor system. This completed the structure of a roff system as it is still in use today; see section USING ROFF. In 1979, these novelties were described in the paper [CSTR #97]. This new troff version is the basis for all existing newer troff systems, including groff. On some systems, this device independent troff got a binary of its own, called ditroff(7). All modern troff programs already provide the full ditroff capabilities automatically. Availability The source code of both the ancient Unix and classical troff weren't available for two decades. Meanwhile, it is accessible again (on-line) for non-commercial use, cf. section SEE ALSO. Free roff The most important free roff project was the GNU implementation of troff, written from scratch by James Clark and put under the GNU Public License <http://www.gnu.org/copyleft>. It was called groff (GNU roff). See groff(1) for an overview. The groff system is still actively developed. It is compatible to the classical troff, but many extensions were added. It is the first roff system that is available on almost all operating systems - and it is free. This makes groff the de-facto roff standard today. An alternative is Gunnar Ritter's Heirloom Documentation Tools <http:// heirloom.sf.net> project, started in 2005, which provides enhanced ver- sions of the various roff tools found in the OpenSolaris and Plan 9 operating systems, now available under free licenses.

USING ROFF

Most people won't even notice that they are actually using roff. When you read a system manual page (man page) roff is working in the back- ground. roff documents can be viewed with a native viewer called xditview(1x), a standard program of the X window distribution, see X(7x). But using roff explicitly isn't difficult either. Some roff implementations provide wrapper programs that make it easy to use the roff system on the shell command line. For example, the GNU roff implementation groff(1) provides command line options to avoid the long command pipes of classical troff; a program grog(1) tries to guess from the document which arguments should be used for a run of groff; people who do not like specifying command line options should try the groffer(1) program for graphically displaying groff files and man pages. The roff Pipe Each roff system consists of preprocessors, roff formatter programs, and a set of device postprocessors. This concept makes heavy use of the piping mechanism, that is, a series of programs is called one after the other, where the output of each program in the queue is taken as the input for the next program. cat file | ... | preproc | ... | troff options | postproc The preprocessors generate roff code that is fed into a roff formatter (e.g. troff), which in turn generates intermediate output that is fed into a device postprocessor program for printing or final output. All of these parts use programming languages of their own; each lan- guage is totally unrelated to the other parts. Moreover, roff macro packages that were tailored for special purposes can be included. Most roff documents use the macros of some package, intermixed with code for one or more preprocessors, spiced with some elements from the plain roff language. The full power of the roff formatting language is seldom needed by users; only programmers of macro packages need to know about the gory details. Preprocessors A roff preprocessor is any program that generates output that syntacti- cally obeys the rules of the roff formatting language. Each preproces- sor defines a language of its own that is translated into roff code when run through the preprocessor program. Parts written in these lan- guages may be included within a roff document; they are identified by special roff requests or macros. Each document that is enhanced by preprocessor code must be run through all corresponding preprocessors before it is fed into the actual roff formatter program, for the for- matter just ignores all alien code. The preprocessor programs extract and transform only the document parts that are determined for them. There are a lot of free and commercial roff preprocessors. Some of them aren't available on each system, but there is a small set of pre- processors that are considered as an integral part of each roff system. The classical preprocessors are tbl for tables. eqn for mathematical formulae. pic for drawing diagrams. refer for bibliographic references. soelim for including macro files from standard locations. chem for drawing chemical formulae. Other known preprocessors that are not available on all systems include grap for constructing graphical elements. grn for including gremlin(1) pictures. Formatter Programs A roff formatter is a program that parses documents written in the roff formatting language or uses some of the roff macro packages. It gener- ates intermediate output, which is intended to be fed into a single device postprocessor that must be specified by a command-line option to the formatter program. The documents must have been run through all necessary preprocessors before. The output produced by a roff formatter is represented in yet another language, the intermediate output format or troff output. This lan- guage was first specified in [CSTR #97]; its GNU extension is docu- mented in groff_out(5). The intermediate output language is a kind of assembly language compared to the high-level roff language. The gener- ated intermediate output is optimized for a special device, but the language is the same for every device. The roff formatter is the heart of the roff system. The traditional roff had two formatters, nroff for text devices and troff for graphical devices. Often, the name troff is used as a general term to refer to both for- matters. Devices and Postprocessors Devices are hardware interfaces like printers, text or graphical termi- nals, etc., or software interfaces such as a conversion into a differ- ent text or graphical format. A roff postprocessor is a program that transforms troff output into a form suitable for a special device. The roff postprocessors are like device drivers for the output target. For each device there is a postprocessor program that fits the device optimally. The postprocessor parses the generated intermediate output and generates device-specific code that is sent directly to the device. The names of the devices and the postprocessor programs are not fixed because they greatly depend on the software and hardware abilities of the actual computer. For example, the classical devices mentioned in [CSTR #54] have greatly changed since the classical times. The old hardware doesn't exist any longer and the old graphical conversions were quite imprecise when compared to their modern counterparts. For example, the Postscript device post in classical troff had a reso- lution of 720 units per inch, while groff's ps device has 72000, a refinement of factor 100. Today the operating systems provide device drivers for most printer- like hardware, so it isn't necessary to write a special hardware post- processor for each printer.

ROFF PROGRAMMING

Documents using roff are normal text files decorated by roff formatting elements. The roff formatting language is quite powerful; it is almost a full programming language and provides elements to enlarge the lan- guage. With these, it became possible to develop macro packages that are tailored for special applications. Such macro packages are much handier than plain roff. So most people will choose a macro package without worrying about the internals of the roff language. Macro Packages Macro packages are collections of macros that are suitable to format a special kind of documents in a convenient way. This greatly eases the usage of roff. The macro definitions of a package are kept in a file called name.tmac (classically tmac.name). All tmac files are stored in one or more directories at standardized positions. Details on the nam- ing of macro packages and their placement is found in groff_tmac(5). A macro package that is to be used in a document can be announced to the formatter by the command line option -m, see troff(1), or it can be specified within a document using the file inclusion requests of the roff language, see groff(7). Famous classical macro packages are man for traditional man pages, mdoc for BSD-style manual pages; the macro sets for books, articles, and letters are me (probably from the first name of its creator Eric All- man), ms (from Manuscript Macros), and mm (from Memorandum Macros). The roff Formatting Language The classical roff formatting language is documented in the Troff User's Manual [CSTR #54]. The roff language is a full programming lan- guage providing requests, definition of macros, escape sequences, string variables, number or size registers, and flow controls. Requests are the predefined basic formatting commands similar to the commands at the shell prompt. The user can define request-like ele- ments using predefined roff elements. These are then called macros. A document writer will not note any difference in usage for requests or macros; both are written on a line on their own starting with a dot. Escape sequences are roff elements starting with a backslash `\'. They can be inserted anywhere, also in the midst of text in a line. They are used to implement various features, including the insertion of non- ASCII characters with \(, font changes with \f, in-line comments with \", the escaping of special control characters like \\, and many other features. Strings are variables that can store a string. A string is stored by the .ds request. The stored string can be retrieved later by the \* escape sequence. Registers store numbers and sizes. A register can be set with the request .nr and its value can be retrieved by the escape sequence \n.

FILE NAME EXTENSIONS

Manual pages (man pages) take the section number as a file name exten- sion, e.g., the filename for this document is roff.7, i.e., it is kept in section 7 of the man pages. The classical macro packages take the package name as an extension, e.g. file.me for a document using the me macro package, file.mm for mm, file.ms for ms, file.pic for pic files, etc. But there is no general naming scheme for roff documents, though file.tr for troff file is seen now and then. Maybe there should be a standardization for the filename extensions of roff files. File name extensions can be very handy in conjunction with the less(1) pager. It provides the possibility to feed all input into a command- line pipe that is specified in the shell environment variable LESSOPEN. This process is not well documented, so here an example: LESSOPEN='|lesspipe %s' where lesspipe is either a system supplied command or a shell script of your own.

EDITING ROFF

The best program for editing a roff document is Emacs (or Xemacs), see emacs(1). It provides an nroff mode that is suitable for all kinds of roff dialects. This mode can be activated by the following methods. When editing a file within Emacs the mode can be changed by typing `M-x nroff-mode', where M-x means to hold down the Meta key (or Alt) and hitting the x key at the same time. But it is also possible to have the mode automatically selected when the file is loaded into the editor. o The most general method is to include the following 3 comment lines at the end of the file. .\" Local Variables: .\" mode: nroff .\" End: o There is a set of file name extensions, e.g. the man pages that trigger the automatic activation of the nroff mode. o Theoretically, it is possible to write the sequence .\" -*- nroff -*- as the first line of a file to have it started in nroff mode when loaded. Unfortunately, some applications such as the man program are confused by this; so this is deprecated. All roff formatters provide automated line breaks and horizontal and vertical spacing. In order to not disturb this, the following tips can be helpful. o Never include empty or blank lines in a roff document. Instead, use the empty request (a line consisting of a dot only) or a line comment .\" if a structuring element is needed. o Never start a line with whitespace because this can lead to unexpected behavior. Indented paragraphs can be constructed in a controlled way by roff requests. o Start each sentence on a line of its own, for the spacing after a dot is handled differently depending on whether it terminates an abbreviation or a sentence. To distinguish both cases, do a line break after each sentence. o To additionally use the auto-fill mode in Emacs, it is best to insert an empty roff request (a line consisting of a dot only) after each sentence. The following example shows how optimal roff editing could look. This is an example for a .I roff document. . This is the next sentence in the same paragraph. . This is a longer sentence stretching over several lines; abbreviations like `cf.' are easily identified because the dot is not followed by a line break. . In the output, this will still go to the same paragraph. Besides Emacs, some other editors provide nroff style files too, e.g. vim(1), an extension of the vi(1) program.

SEE ALSO

There is a lot of documentation on roff. The original papers on clas- sical troff are still available, and all aspects of groff are docu- mented in great detail. Internet sites troff.org The historical troff site <http://www.troff.org> provides an overview and pointers to all historical aspects of roff. Multics The Multics site <http://www.multicians.org> contains a lot of information on the MIT projects, CTSS, Multics, early Unix, including runoff; especially useful are a glossary and the many links to ancient documents. Unix Archive The Ancient Unixes Archive <http://www.tuhs.org/Archive/> pro- vides the source code and some binaries of the ancient Unixes (including the source code of troff and its documentation) that were made public by Caldera since 2001, e.g. of the famous Unix version 7 for PDP-11 at the Unix V7 site <http://www.tuhs.org/ Archive/PDP-11/Trees/V7>. Developers at AT&T Bell Labs Bell Labs Computing and Mathematical Sciences Research <http:// www.bell-labs.com/> provides a search facility for tracking information on the early developers. Plan 9 The Plan 9 operating system <http://plan9.bell-labs.com> by AT&T Bell Labs. runoff Jerry Saltzer's home page <http://web.mit.edu/Saltzer/www/ publications/pubs.html> stores some documents using the ancient RUNOFF formatting language. CSTR Papers The Bell Labs CSTR site <http://cm.bell-labs.com/cm/cs/ cstr.html> stores the original troff manuals (CSTR #54, #97, #114, #116, #122) and famous historical documents on program- ming. GNU roff The groff web site <http://www.gnu.org/software/groff> provides the free roff implementation groff, the actual standard roff. Historical roff Documentation Many classical troff documents are still available on-line. The two main manuals of the troff language are [CSTR #54] J. F. Ossanna, Nroff/Troff User's Manual <http://cm.bell- labs.com/cm/cs/cstr/54.ps.gz>; Bell Labs, 1976; revised by Brian Kernighan, 1992. [CSTR #97] Brian Kernighan, A Typesetter-independent TROFF <http://cm.bell- labs.com/cm/cs/cstr/97.ps.gz>, Bell Labs, 1981, revised March 1982. The "little language" roff papers are [CSTR #114] Jon L. Bentley and Brian W. Kernighan, GRAP - A Language for Typesetting Graphs <http://cm.bell-labs.com/cm/cs/cstr/ 114.ps.gz>; Bell Labs, August 1984. [CSTR #116] Brian W. Kernighan, PIC - A Graphics Language for Typesetting <http://cm.bell-labs.com/cm/cs/cstr/116.ps.gz>; Bell Labs, December 1984. [CSTR #122] J. L. Bentley, L. W. Jelinski, and B. W. Kernighan, CHEM - A Program for Typesetting Chemical Structure Diagrams, Computers and Chemistry <http://cm.bell-labs.com/cm/cs/cstr/122.ps.gz>; Bell Labs, April 1986. Manual Pages Due to its complex structure, a full roff system has many man pages, each describing a single aspect of roff. Unfortunately, there is no general naming scheme for the documentation among the different roff implementations. In groff, the man page groff(1) contains a survey of all documentation available in groff. On other systems, you are on your own, but troff(1) might be a good starting point.

AUTHORS

Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. This document is distributed under the terms of the FDL (GNU Free Docu- mentation License) version 1.3 or later. You should have received a copy of the FDL on your system, it is also available on-line at the GNU copyleft site <http://www.gnu.org/copyleft/fdl.html>. This document is part of groff, the GNU roff distribution. It was written by Bernd Warken <groff-bernd.warken-72@web.de>; it is main- tained by Werner Lemberg <wl@gnu.org>. Groff Version 1.22.2 7 February 2013 ROFF(7)

Search: Section: