Reference

man(7)

legacy formatting language for manual pages

NAME

man – legacy formatting language for manual pages

DESCRIPTION

The man language was used universally for Unix manual pages from 1979 to 1989. It remains popular in Linux and keeps being actively maintained and extended by the GNU roff project. All the same, do not use it to write new manual pages. Instead, use the mdoc(7) language, which provides both significantly better semantic markup facilities and is easier to use correctly. Consequently, this document does not provide advice on how to use the man language; for such advice, refer to the GNU roff project instead.

In a man document, lines beginning with the control character ‘.’ are called “macro lines”. The first word is the macro name. It usually consists of two capital letters. For a list of portable macros, see MACRO OVERVIEW. The words following the macro name are arguments to the macro.

Lines not beginning with the control character are called “text lines”. They provide free-form text to be printed; the formatting of the text depends on the respective processing context:

.SH Macro lines change control state.
Text lines are interpreted within the current state.

Many aspects of the basic syntax of the man language are based on the roff(7) language; see the LANGUAGE SYNTAX and MACRO SYNTAX sections in the roff(7) manual for details, in particular regarding comments, escape sequences, whitespace, and quoting.

Each man document starts with the TH macro specifying the document's name and section, followed by the NAME section formatted as follows:

.TH PROGNAME 1 1979-01-10
.SH NAME
\fBprogname\fR \(en one line about what it does

MACRO OVERVIEW

This overview is sorted such that macros of similar purpose are listed together. Deprecated and non-portable macros are not included in the overview, but can be found in the alphabetical reference below.

Page header and footer meta-data

THset the title: name section date [source [volume]]
ATdisplay AT&T UNIX version in the page footer (<= 2 arguments)
UCdisplay BSD version in the page footer (<= 1 argument)

Sections and paragraphs

SHsection header (one line)
SSsubsection header (one line)
PPstart an undecorated paragraph (no arguments)
IPindented paragraph: [head [width]]
TPtagged paragraph: [width]
HPhanged paragraph: [width]
PDset vertical paragraph distance: [height]
EX, EEdisplay an example (no arguments)
RS, REreset the left margin: [width]
inadditional indent: [width]

Physical markup

Bboldface font
Iitalic font
SBsmall boldface font
SMsmall roman font
BIalternate between boldface and italic fonts
BRalternate between boldface and roman fonts
IBalternate between italic and boldface fonts
IRalternate between italic and roman fonts
RBalternate between roman and boldface fonts
RIalternate between roman and italic fonts

MACRO REFERENCE

This section is a canonical reference to all macros, arranged alphabetically. For the scoping of individual macros, see MACRO SYNTAX.

AT

Sets the volume for the footer for compatibility with man pages from AT&T UNIX releases. The optional arguments specify which release it is from. This macro is an extension that first appeared in 4.3BSD.

B

Text is rendered in bold face.

BI

Text is rendered alternately in bold face and italic. Thus, ‘.BI this word and that’ causes ‘this’ and ‘and’ to render in bold face, while ‘word’ and ‘that’ render in italics. Whitespace between arguments is omitted in output.

Example:

.BI bold italic bold italic

BR

Text is rendered alternately in bold face and roman (the default font). Whitespace between arguments is omitted in output. See also BI.

DT

Restore the default tabulator positions. They are at intervals of 0.5 inches. This has no effect unless the tabulator positions were changed with the roff(7) ta request.

EE

End an example block started with EX. This is a Version 9 AT&T UNIX extension later adopted by GNU. In mandoc(1), it does the same as the roff(7) fi request (switch to fill mode).

EX

Begin a block to display an example. This is a Version 9 AT&T UNIX extension later adopted by GNU. In mandoc(1), it does the same as the roff(7) nf request (switch to no-fill mode).

HP

Begin a paragraph whose initial output line is left-justified, but subsequent output lines are indented, with the following syntax:

.HP [width]

The width argument is a roff(7) scaling width. If specified, it's saved for later paragraph left margins; if unspecified, the saved or default width is used.

I

Text is rendered in italics.

IB

Text is rendered alternately in italics and bold face. Whitespace between arguments is omitted in output. See also BI.

IP

Begin an indented paragraph with the following syntax:

.IP [head [width]]

The width argument is a roff(7) scaling width defining the left margin. It's saved for later paragraph left-margins; if unspecified, the saved or default width is used.

The head argument is used as a leading term, flushed to the left margin. This is useful for bulleted paragraphs and so on.

IR

Text is rendered alternately in italics and roman (the default font). Whitespace between arguments is omitted in output. See also BI.

LP

A synonym for PP.

ME

End a mailto block started with MT. This is a GNU extension.

MR

Reference another manual page. This is a Plan 9 extension also supported by GNU. It has the following syntax:

.MR name section [suffix]

The optional, single suffix argument is appended without preceding whitespace and typically used for trailing punctuation.

MT

Begin a mailto block. This is a GNU extension. It has the following syntax:

.MT address
link description to be shown
.ME

OP

Optional command-line argument. This is a deprecated GNU extension. The name and purpose of the macro match an earlier DWB extension, but both the syntax and semantics are incompatible. In GNU and mandoc(1), it has the following syntax:

.OP key [value]

The key is usually a command-line flag and value its argument.

P

This synonym for PP is an AT&T System III UNIX extension later adopted by 4.3BSD.

PD

Specify the vertical space to be inserted before each new paragraph.
The syntax is as follows:

.PD [height]

The height argument is a roff(7) scaling width. It defaults to 1v. If the unit is omitted, v is assumed.

This macro affects the spacing before any subsequent instances of HP, IP, LP, P, PP, SH, SS, SY, and TP.

PP

Begin an undecorated paragraph. The scope of a paragraph is closed by a subsequent paragraph, sub-section, section, or end of file. The saved paragraph left-margin width is reset to the default.

RB

Text is rendered alternately in roman (the default font) and bold face. Whitespace between arguments is omitted in output. See also BI.

RE

Explicitly close out the scope of a prior RS. The default left margin is restored to the state before that RS invocation.

The syntax is as follows:

.RE [level]

Without an argument, the most recent RS block is closed out. If level is 1, all open RS blocks are closed out. Otherwise, level − 1 nested RS blocks remain open.

RI

Text is rendered alternately in roman (the default font) and italics. Whitespace between arguments is omitted in output. See also BI.

RS

Temporarily reset the default left margin. This has the following syntax:

.RS [width]

The width argument is a roff(7) scaling width. If not specified, the saved or default width is used.

See also RE.

SB

Text is rendered in small size (one point smaller than the default font) bold face. This macro is an extension that probably first appeared in SunOS 4.0 and was later adopted by GNU and by 4.4BSD.

SH

Begin a section. The scope of a section is only closed by another section or the end of file. The paragraph left-margin width is reset to the default.

SM

Text is rendered in small size (one point smaller than the default font).

SS

Begin a sub-section. The scope of a sub-section is closed by a subsequent sub-section, section, or end of file. The paragraph left-margin width is reset to the default.

SY

Begin a synopsis block with the following syntax:

.SY command
arguments
.YS

This is a GNU extension and rarely used even in GNU manual pages. Formatting is similar to IP.

TH

Set the name of the manual page for use in the page header and footer with the following syntax:

.TH name section date [source [volume]]

Conventionally, the document name is given in all caps. The section is usually a single digit, in a few cases followed by a letter. The recommended date format is YYYY-MM-DD as specified in the ISO-8601 standard; if the argument does not conform, it is printed verbatim. If the date is empty or not specified, the current date is used. The optional source string specifies the organisation providing the utility. When unspecified, mandoc(1) uses its -Ios argument. The volume string replaces the default volume title of the section.

Examples:

.TH CVS 5 1992-02-12 GNU

TP

Begin a paragraph where the head, if exceeding the indentation width, is followed by a newline; if not, the body follows on the same line after advancing to the indentation width. Subsequent output lines are indented. The syntax is as follows:

.TP [width]
head \" one line
body

The width argument is a roff(7) scaling width. If specified, it's saved for later paragraph left-margins; if unspecified, the saved or default width is used.

TQ

Like TP, except that no vertical spacing is inserted before the paragraph. This is a GNU extension.

UC

Sets the volume for the footer for compatibility with man pages from BSD releases. The optional first argument specifies which release it is from. This macro is an extension that first appeared in 3BSD.

UE

End a uniform resource identifier block started with UR. This is a GNU extension.

UR

Begin a uniform resource identifier block. This is a GNU extension. It has the following syntax:

.UR uri
link description to be shown
.UE

YS

End a synopsis block started with SY. This is a GNU extension.

in

Indent relative to the current indentation:

.in [width]

If width is signed, the new offset is relative. Otherwise, it is absolute. This value is reset upon the next paragraph, section, or sub-section.

MACRO SYNTAX

The man macros are classified by scope: line scope or block scope. Line macros are only scoped to the current line (and, in some situations, the subsequent line). Block macros are scoped to the current line and subsequent lines until closed by another block macro.

Line Macros

Line macros are generally scoped to the current line, with the body consisting of zero or more arguments. If a macro is scoped to the next line and the line arguments are empty, the next line, which must be text, is used instead. Thus:

.I
foo

is equivalent to ‘.I foo’. If next-line macros are invoked consecutively, only the last is used. If a next-line macro is followed by a non-next-line macro, an error is raised.

The syntax is as follows:

.\" current-line syntax
.YO [body ...]
.\" next-line syntax
.YO
body ...

MacroArgumentsLine ScopeNotes
AT0 to 2current
B1 or morecurr or next
BI2 or morecurrent
BR2 or morecurrent
DT0none
EE0noneVersion 9 AT&T UNIX
EX0noneVersion 9 AT&T UNIX
I1 or morecurr or next
IB2 or morecurrent
IR2 or morecurrent
MR2 or 3currentPlan 9
OP1 or 2currentGNU
PD0 or 1current
RB2 or morecurrent
RI2 or morecurrent
SB1 or morecurr or next
SM1 or morecurr or next
TH3 to 5current
UC0 or 1current
in0 or 1currentroff(7)

Block Macros

Block macros comprise a head and body. As with in-line macros, the head is scoped to the current line or, for some macros, to the next line (the next-line stipulations as in Line Macros apply here as well).

The syntax is as follows:

.\" current-line syntax
.YO [head ...]
body ...
...
.\" next-line syntax
.YO [head]
head ...
body ...
...

The closure of body scope may be to the section, where a macro is closed by SH; sub-section, closed by a section or SS; paragraph, closed by a section, sub-section, HP, IP, LP, P, PP, RS, SY, TP, or TQ; or to an explicit block closing macro.

As a rule, block macros may not be nested; thus, calling a block macro while another block macro scope is open, and the open scope is not implicitly closed, is syntactically incorrect.

MacroArgumentsHead ScopeBody ScopeNotes
HP0 or 1currentparagraph
IP0 to 2currentparagraph
LP0noneparagraph
ME0 or 1currentnoneGNU
MT1currentto MEGNU
P0noneparagraph
PP0noneparagraph
RE0 or 1currentnone
RS0 or 1currentto RE
SH1 or morecurr or nextsection
SS1 or morecurr or nextsub-section
SY1currentto YSGNU
TP0 or 1curr and nextparagraph
TQ0 or 1curr and nextparagraphGNU
UE0 or 1currentnoneGNU
UR1currentto UEGNU
YS0nonenoneGNU

If a block macro is next-line scoped, it may only be followed by in-line macros for decorating text.

Font handling

In man documents, both Physical markup macros and roff(7) ‘\f’ font escape sequences can be used to choose fonts. In text lines, the effect of manual font selection by escape sequences only lasts until the next macro invocation; in macro lines, it only lasts until the end of the macro scope. Note that macros like BR open and close a font scope for each argument.

SEE ALSO

man(1), mandoc(1), eqn(7), mandoc_char(7), mdoc(7), roff(7), tbl(7)

HISTORY

The man language first appeared as a macro package for the roff typesetting system in Version 7 AT&T UNIX.

The stand-alone implementation that is part of the mandoc(1) utility first appeared in OpenBSD 4.6.

AUTHORS

Douglas McIlroy ⟨[email protected]⟩ designed and implemented the original version of these macros, wrote the original version of this manual page, and was the first to use them when he edited volume 1 of the Version 7 AT&T UNIX manual pages.

James Clark later rewrote the macros for groff. Eric S. Raymond ⟨[email protected]⟩ and Werner Lemberg ⟨[email protected]⟩ added the extended man macros to groff in 2007.

The mandoc(1) program and this man reference were written by Kristaps Dzonsons ⟨[email protected]⟩.

History