ROFF(7)

๐Ÿ“ฆ
version 1.14.6 ยท 2 versions
, in arch rolling, debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

๐ŸŒธ ROFF(7) โ€” Miscellaneous Information Manual ๐ŸŒธ

okay bestie, sit DOWN, because we're about to get into roff, the roff language reference for mandoc ๐Ÿ’–


โœจ NAME โœจ

roff โ€” the roff language reference, but for mandoc specifically ๐ŸŽ€</purl>


๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

So roff is a general purpose text formatting language โœจ and here's the tea: the classic implementations of the mdoc(7) and man(7) manual formatting languages are literally built on top of it. That means a LOT of real-world manuals have lil sprinkles of roff requests and escape sequences mixed right into their mdoc(7) or man(7) code. To format those manuals correctly, mandoc(1) supports a subset of roff requests and escapes ๐Ÿซถ

โš ๏ธ real talk: even though this manual page lists all roff requests and escape sequences, it only has partial info about the requests that mandoc(1) does not support, and about language features that just don't matter for manual pages. For the full, complete roff manuals, go check the "SEE ALSO" section, iykyk ๐Ÿ“š

Input lines that start with the control character '.' get parsed for requests and macros. Those lines are called "request lines" or "macro lines" respectively ๐Ÿ’… Requests change the processing state and mess with the formatting; some macros also define the document structure and produce formatted output. The single quote ("'") is accepted as an alternative control character, and mandoc(1) treats it exactly the same as '.' โญ

Lines that don't start with control characters are called "text lines" ๐ŸŒธ They give you free-form text to be printed; how that text actually gets formatted 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 '\' marks the start of an escape sequence, used for stuff like "Comments" and "Special Characters" โœจ For a complete listing of escape sequences, go look at "ESCAPE SEQUENCE REFERENCE" down below ๐Ÿ‘‘

๐Ÿ’ฌ Comments ๐Ÿ’ฌ

Text following an escaped double-quote '\"' โ€” whether it's in a request, macro, or text line โ€” is ignored to the end of the line. A request line beginning with a control character and the comment escape '.\"' is also ignored. And on top of that, request lines with only a control character and optional trailing whitespace get stripped from input entirely ๐Ÿงน

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 encode special glyphs and they get rendered differently across output media. They can show up in request, macro, and text lines. Sequences begin with the escape character '\' followed by one of:

  • an open-parenthesis '(' for two-character sequences
  • an open-bracket '[' for n-character sequences (terminated at a close-bracket ']')
  • or just 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 get overridden by many subsequent macros, no cap ๐Ÿ˜ญ

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 bold italic, then return to previous font mode.

๐Ÿซง Whitespace ๐Ÿซง

Whitespace = the space character. In text lines, whitespace is preserved within a line. In request and macro lines, whitespace delimits arguments and gets discarded ๐Ÿ’จ

Unescaped trailing spaces get stripped from text line input unless you're in a literal context. In general, trailing whitespace on any input line is discouraged for reasons of portability. In the rare case that you genuinely need a space character at the end of an input line, you can force it with '\ \&' โœจ

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 the 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 decimal 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 โ€” that's an (unescaped) period, exclamation mark, or question 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 โœจ

If an input line happens to end with a period, exclamation or question mark that isn't the end of a sentence, append a zero-width space ('\&') ๐Ÿ’…

Examples:

Do not end sentences mid-line like this.  Instead,
end a sentence like this.
A macro would end like this:
.Xr mandoc 1 .
An abbreviation at the end of an input line needs escaping, e.g.\&
like this.

๐Ÿ’œ 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.

So like, 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 enclosing them in double quote characters ('"') โœจ Quoted text โ€” even if it contains 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's recommended 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 considered 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] โ€” appends to a macro definition, but you name the macro indirectly (groff extension, bestie). Same syntax rules as dei. โœจ
  • ami1 macrostring [endstring] โ€” same deal, but it flips roff compatibility mode off while the macro runs, and names the macro indirectly (groff extension). Syntax is identical to dei1. Since mandoc(1) doesn't do roff compatibility mode at all, it just treats this as an alias for ami. ๐Ÿ’…
  • as stringname [string] โ€” append to a user-defined string. Syntax = same as ds. And lowkey important: if a string with that name doesn't exist yet, it gets set to the empty string first, then the appending happens. ๐ŸŽ€
  • as1 stringname [string] โ€” append to a user-defined string while switching roff compatibility mode off during macro execution (groff extension). Syntax = same as ds1. Again, since mandoc(1) never implements roff compatibility mode, it handles this as an alias for as. ๐Ÿฆ‹
  • asciify divname โ€” fully unformat a diversion. Currently unsupported. ๐Ÿ™ˆ
  • backtrace โ€” print a backtrace of the input stack. It's a groff extension and currently ignored.
  • bd font [curfont] [offset] โ€” artificially embolden by printing repeatedly with tiny shifts. Currently ignored.
  • bleedat left top width height โ€” set the BleedBox page parameter for PDF generation. Heirloom extension, 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 drop a picture into it. Heirloom extension, currently unsupported.
  • br โ€” break the output line. โœ‚๏ธ
  • break โ€” break out of the innermost while loop. ๐Ÿšช
  • breakchar char ... โ€” optional line break characters. Heirloom extension, currently ignored.
  • brnl N โ€” break the output line after the next N input lines. Heirloom extension, currently ignored.
  • brp โ€” break and spread the output line. Currently implemented as an alias for br.
  • brpnl N โ€” break and spread the output line after the next N input lines. Heirloom extension, currently ignored.
  • c2 [char] โ€” change the no-break control character. Currently unsupported.
  • cc [char] โ€” change the control character. If you don't pass char, the control character resets to .. Any trailing characters? Ignored, bestie. ๐Ÿ’…
  • ce [N] โ€” center the next N input lines without filling them. 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. groff extension, 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 so it renders 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. groff extension, currently ignored.
  • close streamname โ€” close an open file. Ignored because insecure. ๐Ÿšจ
  • CL color text โ€” print text in color. Heirloom extension, currently unsupported.
  • color [1 | 0] โ€” activate or deactivate colors. groff extension, currently ignored.
  • composite from to โ€” define a name component for composite glyph names. groff extension, 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. Heirloom extension, currently ignored.
  • cs font [width [emsize]] โ€” constant character spacing mode. Currently ignored.
  • cu [N] โ€” underline the next N input lines, whitespace included. Currently ignored.
  • da divname โ€” append to a diversion. Currently unsupported.
  • dch macroname [dist] โ€” change a trap location in the current diversion. Heirloom extension, currently unsupported.
  • de macroname [endmacro] โ€” define a roff macro. Okay so this one's the big one, and 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 โ€” newline characters terminating each line included, bestie โ€” optionally 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 the same way as for ig; namely, the call to .endmacro first ends the definition, and after that it's 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 ...]]

For how arguments get parsed, go read โ€œMACRO SYNTAXโ€ above. ๐Ÿ‘†

The line invoking the macro gets replaced in the input stream by the definition, with every occurrence of \\$N โ€” where N is a digit โ€” swapped for the *N*th 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 occurrence of \\$* gets replaced with all the arguments, joined together with single space characters. The variant \\$@ is similar, except each argument is individually quoted. ๐ŸŒธ

Since macros and user-defined strings share a common string table, 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. groff extension. Since mandoc(1) doesn't implement roff compatibility mode at all, it handles this request as an alias for de. โœจ
  • defcolor newname scheme component ... โ€” define a color name. groff extension, currently ignored.
  • dei macrostring [endstring] โ€” define a roff macro while specifying the macro name indirectly (groff extension). Same syntax as 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, naming the macro indirectly (groff extension). Since mandoc(1) doesn't 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 intermediate output format, and are unsupported. ๐Ÿ™ˆ

  • di divname โ€” begin a diversion. Currently unsupported.
  • do command [argument ...] โ€” execute a roff request or macro line with compatibility mode disabled. Currently unsupported.
  • ds stringname [["]string] โ€” define a user-defined string. The stringname and string arguments are space-separated. If the string begins with a double-quote character, that character will not be part of the string. All the 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, respectively. 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 table, 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] โ€” Defines a user-defined string, but this one gets expanded with roff compatibility mode switched off during string expansion. It's a groff extension. And since mandoc(1) doesn't do roff compatibility mode at all, bestie, it just treats this as an alias for ds. ๐Ÿ’…
  • dwh dist macroname โ€” Sets a location trap inside the current diversion. This is a Heirloom extension and rn it's currently unsupported. ๐Ÿ˜ญ
  • dt [dist macroname] โ€” Sets a trap within a diversion. Also currently unsupported. ๐Ÿ™ˆ
  • ec [char] โ€” Turns the escape mechanism on and swaps out the escape character. The char argument defaults to the backslash (\). โœจ
  • ecr โ€” Restores the escape character. Currently unsupported. ๐Ÿ’€
  • ecs โ€” Saves the escape character. Currently unsupported. ๐Ÿ’€
  • el body โ€” The โ€œelseโ€ half of an if/else conditional, no cap. It pops a result off the stack of conditional evaluations that ie pushed, and uses that as its conditional. If there are no stack entries at all (like, say, because nobody called ie first) then it just assumes false. The syntax here is basically if but with the conditional part missing. ๐ŸŽ€
  • em macroname โ€” Sets a trap at the end of input. Currently unsupported. ๐Ÿ˜ญ
  • EN โ€” Ends an equation block. Peep EQ. ๐Ÿงฎ
  • eo โ€” Disables the escape mechanism completely. Like, gone gone. ๐Ÿซถ
  • EP โ€” Ends a picture that was started by BP. This is a Heirloom extension and currently unsupported. ๐Ÿ–ผ๏ธ
  • EQ โ€” Begins an equation block. Go read eqn(7) for the whole rundown on the equation language, bestie. โœจ
  • errprint message โ€” Prints a string that looks like an error message. This is a Heirloom extension and currently ignored. ๐Ÿ™ˆ
  • ev [envname] โ€” Switches to another environment. Currently unsupported. ๐ŸŒˆ
  • evc [envname] โ€” Copies an environment into the current environment. Currently unsupported. ๐Ÿ’€
  • ex โ€” Aborts processing and exits. Currently unsupported. ๐Ÿšช
  • fallback curfont font ... โ€” Picks the fallback sequence for a font. This is a Heirloom extension and currently ignored. ๐ŸŽ€
  • fam [familyname] โ€” Changes the font family. This is a groff extension and currently ignored. ๐Ÿ”ค
  • fc [delimchar [padchar]] โ€” Defines a delimiting character and a padding character for fields. Currently unsupported. ๐Ÿ˜ญ
  • fchar glyphname [string] โ€” Defines a fallback glyph. Currently unsupported. ๐Ÿ’€
  • fcolor colorname โ€” Sets the fill color for \D objects. This is a groff extension and currently ignored. ๐ŸŽจ
  • fdeferlig font string ... โ€” Defers ligature building. This is a Heirloom extension and currently ignored. โœจ
  • feature +|-name โ€” Enables or disables an OpenType feature. This is a Heirloom extension and currently ignored. ๐Ÿ”ฅ
  • fi โ€” Breaks the output line and switches over to fill mode, which is active by default but can be ended with the nf request. In fill mode, input from the following input lines keeps getting added to the same output line until the next word no longer fits โ€” and at that point the output line gets broken. This request is implied by the mdoc(7) Sh macro and by the man(7) SH, SS, and EE macros. ๐Ÿ“
  • fkern font minkern โ€” Controls whether kerning tables get used for a font. This is a Heirloom extension and currently ignored. ๐Ÿ”ค
  • fl โ€” Flushes output. Currently ignored. ๐Ÿšฟ
  • flig font string char ... โ€” Defines ligatures. This is a Heirloom extension and currently ignored. ๐Ÿ”—
  • fp position font [filename] โ€” Assigns a font position. Currently ignored. ๐Ÿ“Œ
  • fps mapname ... โ€” Mounts a font that has a special character map. This is a Heirloom extension and currently ignored. ๐Ÿ—บ๏ธ
  • fschar font glyphname [string] โ€” Defines a font-specific fallback glyph. This is a groff extension and currently unsupported. ๐Ÿ’€
  • fspacewidth font [afmunits] โ€” Sets a font-specific width for the space character. This is a Heirloom extension and currently ignored. โฃ
  • fspecial curfont [font ...] โ€” Conditionally defines a special font. This is a groff extension and currently ignored. โœจ
  • ft [font] โ€” Changes the font; check out โ€œFont Selectionโ€. The font argument defaults to P. ๐ŸŽ€
  • ftr newname [oldname] โ€” Translates a font name. This is a groff extension and currently ignored. ๐Ÿ”ค
  • fzoom font [permille] โ€” Zooms the font size. Currently ignored. ๐Ÿ”
  • gcolor [colorname] โ€” Sets the glyph color. This is a groff extension and currently ignored. ๐ŸŒˆ
  • hc [char] โ€” Sets the hyphenation character. Currently ignored. โœ‚๏ธ
  • hcode char code ... โ€” Sets hyphenation codes for characters. Currently ignored. ๐Ÿ”ข
  • hidechar font char ... โ€” Hides characters in a font. This is a Heirloom extension and currently ignored. ๐Ÿ™ˆ
  • hla language โ€” Sets the hyphenation language. This is a groff extension and currently ignored. ๐ŸŒ
  • hlm [number] โ€” Sets the maximum number of consecutive hyphenated lines. Currently ignored. ๐Ÿ“
  • hpf filename โ€” Loads a hyphenation pattern file. This is a groff extension and currently ignored. ๐Ÿ“‚
  • hpfa filename โ€” Loads a hyphenation pattern file, appending it to the current patterns. This is a groff extension and currently ignored. ๐Ÿ“‚
  • hpfcode code code ... โ€” Defines mapping values for character codes in hyphenation patterns. This is a groff extension and currently ignored. ๐Ÿ”ข
  • hw word ... โ€” Specifies hyphenation points in words. Currently ignored. โœ‚๏ธ
  • hy [mode] โ€” Sets the automatic hyphenation mode. Currently ignored. โœ‚๏ธ
  • hylang language โ€” Sets the hyphenation language. This is a Heirloom extension and currently ignored. ๐ŸŒ
  • hylen nchar โ€” Sets the minimum word length for hyphenation. This is a Heirloom extension and currently ignored. ๐Ÿ“
  • hym [length] โ€” Sets the hyphenation margin. This is a groff extension and currently ignored. ๐Ÿ“
  • hypp penalty ... โ€” Defines hyphenation penalties. This is a Heirloom extension and currently ignored. โš ๏ธ
  • hys [length] โ€” Sets the 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 gets pushed onto a stack that later el invocations use โ€” and those can be separated by literally any amount of input in between (or not exist at all, no pressure). Its syntax is equivalent to if. ๐Ÿ’–
  • if condition body โ€” Begins a conditional. This request can also be written like this:
.if condition \{body
body ...\}

.if condition \{\
body ...
.\}

The condition is a boolean expression. Right now, mandoc(1) supports this subset of roff conditionals:

  • If ! is prefixed to condition, it gets 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, and 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's false.
  • If the first character of condition is r, it evaluates to true if the rest of condition is the name of an existing number register; otherwise it's false.
  • If the condition starts with a parenthesis or with an optionally signed integer number, it gets evaluated according to the rules of โ€œNumerical expressionsโ€ explained below. It evaluates to true if the result is positive, and false if the result is zero or negative.
  • Otherwise, the first character of condition is treated as a delimiter, and it evaluates to true if the string from its first to its second occurrence is equal to the string from its second to its third occurrence.
  • If condition can't be parsed, it evaluates to false. ๐Ÿ’€

If a conditional is false, its children are not processed โ€” but they are syntactically interpreted, so the integrity of the input document stays intact. So like:

.if t .ig

will discard the .ig, which may lead to interesting results, but

.if t .if t \{\

will keep syntactically interpreting all the way 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 continues 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. In that case it's generally more intuitive 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. โœจ

Heads up bestie: the \} gets converted into a zero-width escape sequence if it's not passed as a standalone macro .\}. For example,
.Fl a \} b

will result in \} being considered an argument of the Fl macro. ๐Ÿ˜ญ

  • ig [endmacro] โ€” Ignores input. Its syntax can be either
.ig
ignored text
..

or

okay so bestie, first case? everything gets ignored until we bump into a .. request sitting all alone on its own line ๐Ÿ’…. Second case? input stays ignored until that specific .endmacro you named rolls up.

.ig endmacro
ignored text
.endmacro

And omg please listen โ€” do not use the escape character \ anywhere in the definition of endmacro. It would cause very strange behaviour and that's not the vibe we're going for ๐Ÿ˜ญ.

When the endmacro is a roff request or a roff macro, like in

.ig if

then the subsequent invocation of if will first terminate the ignored text, and then be invoked as usual โœจ. Otherwise, it only terminates the ignored text, and arguments following it โ€” or the .. request โ€” get discarded. gone. bye ๐Ÿซถ.


  • in [[+|-]width] โ€” change the indentation. See man(7). It gets ignored in mdoc(7) ๐Ÿ™ˆ.
  • index register stringname substring โ€” find a substring inside a string. This is a Heirloom extension and it's currently unsupported, so no slay today ๐Ÿ’€.
  • it expression macro โ€” set an input line trap ๐Ÿ”ฅ. The named macro gets invoked after processing the number of input text lines specified by the numerical expression. And while it's evaluating that expression, the unit suffixes described below under โ€œScaling Widthsโ€ are ignored.
  • itc expression macro โ€” set an input line trap, but it does not count lines ending with \c. Currently unsupported.
  • IX class keystring โ€” to support the generation of a table of contents, pod2man(1) emits this user-defined macro, usually without ever defining it. To avoid reporting large numbers of spurious errors, mandoc(1) just ignores it ๐Ÿ˜Œ.
  • kern [1 | 0] โ€” switch kerning on or off. Currently ignored.
  • kernafter font char ... afmunits ... โ€” increase kerning after some characters. Heirloom extension, currently ignored.
  • kernbefore font char ... afmunits ... โ€” increase kerning before some characters. Heirloom extension, currently ignored.
  • kernpair font char ... font char ... afmunits โ€” add a kerning pair to the kerning table. Heirloom extension, currently ignored.
  • lc [glyph] โ€” define a leader repetition character. Currently unsupported.
  • lc_ctype localename โ€” set the LC_CTYPE locale. Heirloom extension, currently unsupported.
  • lds macroname string โ€” define a local string. Heirloom extension, currently 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 โœจ. Heirloom extension, currently ignored.
  • lf lineno [filename] โ€” change the line number for error messages. Ignored because insecure ๐Ÿ”’.
  • lg [1 | 0] โ€” switch the ligature mechanism on or off. Currently ignored.
  • lhang font char ... afmunits โ€” hang characters at the left margin. Heirloom extension, 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 setting 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 discouraged for several reasons โ€” among others, because it overrides the mandoc(1) -O width command line option. So likeโ€ฆ don't, bestie ๐Ÿ’….
  • lnr register [+|-]value [increment] โ€” set local number register. Heirloom extension, currently unsupported.
  • lnrf register [+|-]value [increment] โ€” set local floating-point register. Heirloom extension, currently unsupported.
  • lpfx string โ€” set a line prefix. Heirloom extension, 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 currently unsupported.
  • lt [[+|-]width] โ€” set title line length. Currently ignored.
  • mc glyph [dist] โ€” print margin character in the right margin. The dist is currently ignored; instead, 1n is used.
  • mediasize media โ€” set the device media size. Heirloom extension, currently ignored.
  • minss width โ€” set minimum word space. Heirloom extension, currently ignored.
  • mk [register] โ€” mark vertical position. Currently ignored.
  • mso filename โ€” load a macro file using the search path. Ignored because insecure ๐Ÿ”’.
  • na โ€” disable adjusting without changing the adjustment mode. Currently 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. Heirloom extension, 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 immediately 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 register, 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. Heirloom extension, 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. Heirloom extension, currently ignored.
  • papersize media โ€” set the paper size. Heirloom extension, 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 standard 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 current 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 unsupported.
  • pshape indent length ... โ€” set a special shape for the current paragraph. Heirloom extension, 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 output. This is a groff extension and currently ignored.
  • pvs [[+|-]height] โ€” change post-vertical spacing. This is a groff extension and currently 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.

and we're still going, bestie โ€” more requests coming right up ๐Ÿ’–

  • return [twice] โ€” Bail out of the macro you're currently vibing in and hand control back to whoever called it ๐Ÿซถ. That twice argument? Yeah it's just sitting there. Currently ignored, bestie.
  • rfschar font glyph ... โ€” Deletes the font-specific fallback glyph definitions. Currently unsupported ๐Ÿ˜ญ.
  • rhang font char ... afmunits โ€” Hangs characters off the right margin. This one's a Heirloom extension and it's currently ignored ๐Ÿ’€.
  • rj [N] โ€” Right-justifies the next N input lines to the right margin, no filling involved. N defaults to 1. And if you pass 0 or anything less, right adjustment just... ends. Bye ๐Ÿ‘‹.
  • rm macroname โ€” Yeets a request, macro or string out of existence โœจ.
  • rn oldname newname โ€” Renames a request, macro, diversion, or string. Okay so real talk: in mandoc(1), user-defined macros, mdoc(7) and man(7) macros, and user-defined strings can be renamed. But renaming predefined strings and roff requests is not supported, and diversions aren't implemented at all ๐Ÿ™ˆ.
  • rnn oldname newname โ€” Renames a number register. Currently unsupported.
  • rr register โ€” Removes a register. Gone, periodt ๐Ÿ’….
  • rs โ€” Ends no-space mode. Currently ignored.
  • rt [dist] โ€” Returns to the marked vertical position. Currently ignored.
  • schar glyph [string] โ€” Defines a global fallback glyph. This is a groff extension and currently unsupported.
  • sentchar char ... โ€” Defines sentence-ending characters. Heirloom extension, currently ignored ๐Ÿฅฒ.
  • shc [glyph] โ€” Swaps out the soft hyphen character. Currently ignored.
  • shift [number] โ€” Shifts macro arguments number times (default is once): \\$i becomes what \\$i+number was. Also decrements \n(.$ by number. Sliding everything over, iconic behaviour honestly โœจ.
  • sizes size ... โ€” Defines the permissible point sizes. groff extension, currently ignored.
  • so filename โ€” Includes a source file ๐Ÿซถ. The file gets read and its contents are processed as input right in place of the so request line. Now, to avoid accidentally slurping up unrelated files, mandoc(1) only accepts relative paths that don't contain the strings "../" and "/..".

This request needs man(1) to change to the right directory before calling mandoc(1) โ€” per convention, the root of the manual tree. Typical usage looks like this:

.so man3/Xcursor.3
But ngl, the whole concept is rather fragile, so using so is discouraged. Use ln(1) instead, bestie ๐Ÿ’–.
  • sp [height] โ€” Breaks the output line and emits vertical space. The argument follows the syntax of "Scaling Widths" and defaults to one blank line (1v).
  • spacewidth [1 | 0] โ€” Sets the space width from the font metrics file. Heirloom extension, currently ignored.
  • special [font ...] โ€” Defines a special font. groff extension, currently ignored.
  • spreadwarn [width] โ€” Warns you about wide spacing between words. Currently ignored.
  • ss wordspace [sentencespace] โ€” Sets the space character size. Currently ignored.
  • sty position style โ€” Associates a style with a font position. groff extension, currently ignored.
  • substring stringname startpos [endpos] โ€” Replaces a user-defined string with a substring. Currently unsupported ๐Ÿ˜ญ.
  • sv [height] โ€” Saves vertical space. Currently ignored.
  • sy command โ€” Executes a shell command. Ignored because insecure ๐Ÿšจ.
  • T& โ€” Re-starts a table layout, keeping all the options from the prior table invocation. See TS.
  • ta [width ... [T width ...]] โ€” Sets tab stops โœจ. Every width argument follows the syntax of "Scaling Widths". If it's prefixed with a plus sign, it's relative to the previous tab stop. The arguments after the T marker get used over and over, as often as needed; and for each reuse they're taken relative to the last previously established tab stop. Call ta with no arguments at all and every tab stop gets cleared ๐Ÿ’….
  • tc [glyph] โ€” Changes the tab repetition character. Currently unsupported.
  • TE โ€” Ends a table context. See TS.
  • ti [+|-]width โ€” Breaks the output line and indents the next output line by width. If you specify a sign, the temporary indentation is calculated relative to the current indentation; otherwise it's absolute. The argument follows the syntax of "Scaling Widths", and the default scaling unit is m.
  • tkf font minps width1 maxps width2 โ€” Enables track kerning for a font. Currently ignored.
  • tl 'left'center'right' โ€” Prints a title line. Currently unsupported.
  • tm string โ€” Prints to standard error output. Currently ignored.
  • tm1 string โ€” Prints to standard error output, but allows leading blanks. groff extension, currently ignored.
  • tmc string โ€” Prints to standard error output without a trailing newline. groff extension, currently ignored.
  • tr glyph glyph ... โ€” Output character translation ๐Ÿ”. The first glyph in each pair gets replaced by the second one. Character escapes work here too โ€” for example:
tr \(xx\(yy

replaces all invocations of \(xx with \(yy.

  • track font minps width1 maxps width2 โ€” Static letter space tracking. Heirloom extension, currently ignored.
  • transchar char ... โ€” Defines transparent characters for sentence-ending. Heirloom extension, currently ignored.
  • trf filename โ€” Outputs the contents of a file, disallowing invalid characters. groff extension, ignored because insecure ๐Ÿšจ.
  • trimat left top width height โ€” Sets the TrimBox page parameter for PDF generation. Heirloom extension, currently ignored.
  • trin glyph glyph ... โ€” Output character translation, ignored by asciify. Currently unsupported.
  • trnt glyph glyph ... โ€” Output character translation, ignored by \!. Currently unsupported.
  • troff โ€” Forces troff mode. groff extension, currently ignored.
  • TS โ€” Begins a table, which formats input in aligned rows and columns ๐Ÿ“Š. See tbl(7) for a description of the tbl language.
  • uf font โ€” Globally sets the underline font. Currently ignored.
  • ul [N] โ€” Underlines the next N input lines. Currently ignored.
  • unformat divname โ€” Unformats spaces and tabs in a diversion. Currently unsupported.
  • unwatch macroname โ€” Disables notification for a string or macro. Heirloom extension, currently ignored.
  • unwatchn register โ€” Disables notification for a register. Heirloom extension, currently ignored.
  • vpt [1 | 0] โ€” Enables or disables vertical position traps. groff extension, currently ignored.
  • vs [[+|-]height] โ€” Changes vertical spacing. Currently ignored.
  • warn flags โ€” Sets the warning level. Currently ignored.
  • warnscale si โ€” Sets the scaling indicator used in warnings. groff extension, currently ignored.
  • watch macroname โ€” Notifies you when a string or macro changes. Heirloom extension, currently ignored.
  • watchlength maxlength โ€” On change, reports the contents of macros and strings up to the specified length. Heirloom extension, currently ignored.
  • watchn register โ€” Notifies you when a register changes. Heirloom extension, currently ignored.
  • wh dist [macroname] โ€” Sets a page location trap. Currently unsupported.
  • while condition body โ€” Repeatedly executes while a condition is true, with syntax similar to if. Currently implemented with two restrictions: it cannot nest, and each loop must start and end in the same scope ๐Ÿ‘€.
  • write ["]string โ€” Writes to an open file. Ignored because insecure ๐Ÿšจ.
  • writec ["]string โ€” Writes to an open file without appending a newline. Ignored because insecure ๐Ÿšจ.
  • writem macroname โ€” Writes a macro or string to an open file. Ignored because insecure ๐Ÿšจ.
  • xflag level โ€” Sets the extension level. Heirloom extension, currently ignored.

๐Ÿ”ข Numerical expressions ๐Ÿ”ข

The nr, if, and ie requests accept integer numerical expressions as arguments. These are always evaluated using the C int type; integer overflow works the same way as in the C language. Numbers are made 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 down below in "Scaling Widths". These equations hold, no cap:

1i = 6v = 6P = 10m = 10n = 72p = 1000M = 240u = 240
254c = 100i = 24000u = 24000
1f = 65536u = 65536

The following binary operators are implemented. Unless stated otherwise, they behave just like 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 portability โ€” it's 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)

And here's the tea: there is no concept of precedence โ˜•. Evaluation just proceeds from left to right, except when subexpressions are wrapped in parentheses. Inside parentheses, whitespace is ignored ๐Ÿซถ.

The mandoc(1) roff parser is out here recognising the following escape sequences, bestie. But real talk: in mdoc(7) and man(7) documents, using escape sequences is discouraged โ€” except for the ones described up in the โ€œLANGUAGE SYNTAXโ€ section above. So don't get cute unless you know what you're doing. ๐Ÿ’…

And here's the chill part: a backslash followed by any character that's not listed here just prints that character itself. No drama, no error. ๐Ÿซถ

  • \<newline> โ€” a backslash chillin' at the very end of an input line continues the logical input line onto the next physical input line. Basically it joins the text on both lines together like they were always one single input line. Girlboss line-wrapping. โœจ
  • \<space> โ€” the backslash-space combo (\ ) is an unpaddable space-sized non-breaking space character. Peep โ€œWhitespaceโ€ and mandoc_char(7) for the lore.
  • \! โ€” embeds text up to and including the end of the input line into the current diversion, or into intermediate output, without interpreting requests, macros, and escapes. Currently unsupported, so don't hold your breath. ๐Ÿ˜ญ
  • \" โ€” everything left on this input line gets treated as โ€œCommentsโ€. Ghosted, fr fr. ๐Ÿ’€
  • \# โ€” line continuation, but make it a comment. It discards the rest of the physical input line and continues the logical input line on the next physical input line, joining the text on both lines together as if it were a single input line. This one's a groff extension, iykyk. ๐Ÿฆ‹
  • \$arg โ€” macro argument expansion. Go read de for the full tea.
  • \% โ€” hyphenation is allowed at this point of the word. mandoc(1) ignores it. Iconic of it honestly.
  • \& โ€” a non-printing, zero-width character. It's the it-girl of escaping tricks. Check โ€œWhitespaceโ€, mandoc_char(7), and the โ€œMACRO SYNTAXโ€ and โ€œDelimitersโ€ sections in mdoc(7).
  • \' โ€” acute accent special character. But bestie, use \(aa instead. ๐Ÿ™ˆ
  • \(cc โ€” โ€œSpecial Charactersโ€ with two-letter names. See mandoc_char(7).
  • \) โ€” a zero-width space that's transparent to end-of-sentence detection. mandoc(1) ignores it. She's there but she's not there. โœจ
  • \*[name] โ€” interpolates the string with the name. For short names there are variants \*c and \*(cc.

One string comes predefined right at the roff language level: \*(.T expands to the name of the output device โ€” like ascii, utf8, ps, pdf, html, or markdown. Slay. ๐Ÿ’…

Macro sets traditionally predefine extra strings on top of that, but those are not portable and differ across implementations. The ones mandoc(1) supports 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). mandoc(1) ignores it.
  • \- โ€” the special character โ€œmathematical minus signโ€. Details are in mandoc_char(7).
  • \/ โ€” right italic correction (groff extension). mandoc(1) ignores it.
  • \: โ€” breaking the line is allowed at this point of the word, without inserting a hyphen. Sneaky lil line break.
  • \? โ€” embeds the text up to the next \? into the current diversion without 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).
  • \^ โ€” a one-twelfth em half-narrow space character. In mandoc(1) it's effectively zero-width. Basically a ghost. ๐Ÿ‘ป
  • \_ โ€” underline special character. Use \(ul instead, bestie.
  • **\``** โ€” grave accent special character. Use (ga` instead.
  • \{ โ€” begin conditional input. See if.
  • \| โ€” a one-sixth em narrow space character. In mandoc(1) it's effectively zero-width too.
  • \} โ€” end conditional input. See if.
  • \~ โ€” a paddable non-breaking space character.
  • \0 โ€” a digit width space character.
  • \A'string' โ€” anchor definition. mandoc(1) ignores it.
  • \a โ€” leader character. mandoc(1) ignores it.
  • \B'string' โ€” interpolates '1' if the string conforms to the syntax of โ€œNumerical expressionsโ€ explained above, or '0' otherwise. Built-in vibe check, honestly. โœจ
  • \b'string' โ€” bracket building function. mandoc(1) ignores it.
  • \C'name' โ€” โ€œSpecial Charactersโ€ with names of arbitrary length.
  • \c โ€” when it shows up 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. And no whitespace is inserted. Periodt.
  • \D'string' โ€” draw graphics function. mandoc(1) ignores it.
  • \d โ€” move down by half a line. mandoc(1) ignores it.
  • \E โ€” escape character intended to not be interpreted in copy mode. In mandoc(1) it currently does the exact same thing as \ itself. Twins. ๐Ÿ’œ
  • \e โ€” backslash special character.
  • \F[name] โ€” switch font family (groff extension). mandoc(1) ignores it. 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. mandoc(1) ignores it. For short names there are variants \gc and \g(cc.
  • \H'[+|-]number' โ€” set the height of the current font. mandoc(1) ignores it.
  • \h'[|]width' โ€” horizontal motion. If the vertical bar is given, the motion is relative to the current indentation. Otherwise it's relative to the current position. The default scaling unit is m. ๐Ÿ’ซ
  • \k[name] โ€” mark horizontal input place in register. mandoc(1) ignores it. For short names there are variants \kc and \k(cc.
  • \L'number[c]' โ€” vertical line drawing function. mandoc(1) ignores it.
  • \l'width[c]' โ€” draw a horizontal line of width using the glyph c. Slay, actual drawing.
  • \M[name] โ€” set fill (background) color (groff extension). mandoc(1) ignores it. For short names there are variants \Mc and \M(cc.
  • \m[name] โ€” set glyph drawing color (groff extension). mandoc(1) ignores it. 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 then the changed value is what gets interpolated. Glow up, then show up. ๐Ÿ’…
  • \Odigit, \O[5arguments] โ€” suppress output. This is a groff extension and currently unsupported. 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. They're all stacked and only the top one gets the spotlight. ๐Ÿ‘‘
  • \p โ€” break the output line at the end of the current word.
  • \R'name [+|-]number' โ€” set number register. mandoc(1) ignores it.
  • \r โ€” move up by one line. mandoc(1) ignores it.
  • \S'number' โ€” slant output. mandoc(1) ignores it.
  • \s'[+|-]number' โ€” change point size. mandoc(1) ignores it. The alternative forms \s[+|-]n, \s[+|-]'number', \s[[+|-]number], and \s[+|-][number] are also parsed and ignored. So many fits, all of them ghosted. ๐Ÿ˜ญ
  • \t โ€” horizontal tab. mandoc(1) ignores it.
  • \u โ€” move up by half a line. mandoc(1) ignores it.
  • \V[name] โ€” interpolate an environment variable. mandoc(1) ignores it. For short names there are variants \Vc and \V(cc.
  • \v'number' โ€” vertical motion. mandoc(1) ignores it.
  • \w'string' โ€” interpolate the width of the string. The mandoc(1) implementation 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. Very much an approximation era. ๐Ÿ™ˆ
  • \X'string' โ€” output string as device control function. Ignored in nroff mode and by mandoc(1).
  • \x'number' โ€” extra line space function. mandoc(1) ignores it.
  • \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. mandoc(1) ignores it.
  • \z โ€” output the next character without advancing the cursor position.

๐Ÿ’€ COMPATIBILITY ๐Ÿ’€

Real talk: the mandoc(1) implementation of the roff language is incomplete. Not everything made it to the party. The major unimplemented features include:

  • For security reasons, mandoc(1) never reads or writes external files โ€” except via so requests with safe relative paths. ๐Ÿ”’
  • There's no automatic hyphenation, no adjustment to the right margin, and only very limited support for centering; the output is always set flush-left. Minimalist queen. โœจ
  • 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's no concept of output pages, no support for floats, graphics drawing, and picture inclusion; terminal output is always continuous. No page breaks, just vibes. ๐Ÿ’€
  • Requests regarding color, font families, font sizes, and glyph manipulation 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. ๐Ÿšซ
Also, the special semantics of the nS number register is an idiosyncrasy of OpenBSD manuals and is not supported by other mdoc(7) implementations. So don't expect everyone to get it. ๐Ÿซถ

๐ŸŒˆ 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, http://www.kohala.com/start/troff/cstr54.ps, Murray Hill, New Jersey, 1976 and 1992.

Joseph F. Ossanna, Brian W. Kernighan, and Gunnar Ritter, Heirloom Documentation Tools Nroff/Troff User's Manual, http://heirloom.sourceforge.net/doctools/troff.pdf, September 17, 2007. ๐Ÿ“š

๐Ÿ“œ HISTORY ๐Ÿ“œ

okay so bestie, storytime, because the roff lore is genuinely iconic ๐Ÿ’–

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. โœจ

Then Doug McIlroy rewrote it in BCPL in 1969, renaming it roff. ๐Ÿ‘‘

And THEN Dennis M. Ritchie rewrote McIlroy's roff in PDP-11 assembly for Version 1 AT&T UNIX, and 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. ๐Ÿ’…

Then in 1989, James Clark re-implemented troff in C++, naming it groff. ๐Ÿฆ‹

the way this is literally a whole lineage of absolute legends passing the torch... main character energy for SIXTY YEARS straight, no cap ๐Ÿซถ


๐Ÿ’œ AUTHORS ๐Ÿ’œ

This roff reference was written by Kristaps Dzonsons <kristaps@bsd.lv> and Ingo Schwarze <schwarze@openbsd.org>. ๐ŸŽ€

ngl bestie, these two ate and left absolutely no crumbs โ€” every single flag, escape, macro and cursed corner of this page? theirs. periodt. ๐Ÿ’–


and that's a wrap on the whole roff saga, fr fr ๐ŸŒธ this version is from the Debian crew, dated September 18, 2021 โ€” go forth and typeset something gorgeous, bestie, you've got this ๐Ÿ‘‘โœจ๐Ÿ’…

๐Ÿ“ฆ where this page comes from