MAN(7)

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

๐Ÿ’– MAN โ€” the legacy manual-page formatting language, bestie ๐Ÿ’–

(that's MAN(7) from the Miscellaneous Information Manual, if we're being official about it โœจ)


๐ŸŒธ NAME ๐ŸŒธ

man โ€” the legacy formatting language for manual pages ๐Ÿซถ


๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

okay so storytime ๐Ÿ“–: the man language was THE standard formatting language for AT&T UNIX manual pages from 1979 to 1989. iconic run, honestly. butโ€”

๐Ÿšจ DO NOT use it to write new manual pages. ๐Ÿšจ

fr fr. it's a purely presentational language and it lacks support for semantic markup ๐Ÿ˜ญ. use the mdoc(7) language instead. periodt. ๐Ÿ’…


so in a man document, any line that starts with the control character '.' is called a โ€œmacro lineโ€ โœจ. the first word is the macro name, and it usually consists of two capital letters. for a list of portable macros, go peek at โ€œMACRO OVERVIEWโ€ below ๐Ÿ‘€. the words that come after the macro name are the arguments to the macro.

lines that don't start with the control character are called โ€œtext linesโ€ ๐ŸŽ€. they give you free-form text to be printed, and ngl the formatting of that 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 the deets, in particular regarding comments, escape sequences, whitespace, and quoting.


every single man document starts with the TH macro, which specifies the document's name and section, followed by the โ€œNAMEโ€ section formatted like this:

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

๐Ÿ‘‘ MACRO OVERVIEW ๐Ÿ‘‘

this overview is sorted so that macros of similar purpose are listed together ๐Ÿซถ. deprecated and non-portable macros are not included in the overview, but you can find them in the alphabetical reference below โฌ‡๏ธ.

  • TH โ€” set the title: name section date [source [volume]]
  • AT โ€” display AT&T UNIX version in the page footer (<= 1 argument)
  • UC โ€” display BSD version in the page footer (<= 1 argument)

๐ŸŒˆ Sections and paragraphs ๐ŸŒˆ

  • SH โ€” section header (one line)
  • SS โ€” subsection header (one line)
  • PP โ€” start an undecorated paragraph (no arguments)
  • RS, RE โ€” reset the left margin: [width]
  • IP โ€” indented paragraph: [head [width]]
  • TP โ€” tagged paragraph: [width]
  • PD โ€” set vertical paragraph distance: [height]
  • in โ€” additional indent: [width]

๐Ÿ’… Physical markup ๐Ÿ’…

  • B โ€” boldface font
  • I โ€” italic font
  • SB โ€” small boldface font
  • SM โ€” small roman font
  • BI โ€” alternate between boldface and italic fonts
  • BR โ€” alternate between boldface and roman fonts
  • IB โ€” alternate between italic and boldface fonts
  • IR โ€” alternate between italic and roman fonts
  • RB โ€” alternate between roman and boldface fonts
  • RI โ€” alternate between roman and italic fonts

๐Ÿ’– MACRO REFERENCE ๐Ÿ’–

ok bestie, this is the canonical list โ€” every single macro, alphabetized, nothing skipped, no cap. ๐Ÿซถ Wanna know how the scoping of each macro works (like who's in charge until when)? That's over in MACRO SYNTAX, go peek there. โœจ


AT ๐Ÿ“ผ

Sets the volume for the footer, for compatibility with man pages from AT&T UNIX releases. The optional arguments tell it which release it's from. This macro is an extension that first showed up in 4.3BSD. ๐Ÿ’…

B ๐Ÿ…ฑ๏ธ

Text is rendered in bold face. periodt.

BI ๐ŸŽ€

Text is rendered alternately in bold and italic. So like, .BI this word and that makes this and and go bold, while word and that go italic. Any whitespace between arguments gets dropped in the output. ๐Ÿซฅ

Example:

.BI bold italic bold italic

BR ๐ŸŒธ

Text is rendered alternately in bold face and roman (that's the default font, girly). Whitespace between arguments is omitted in output. Also see BI. ๐Ÿ‘€

DT ๐Ÿ“

Restore the default tabulator positions โ€” they sit at intervals of 0.5 inches. This does literally nothing unless the tabulator positions got changed with the roff(7) ta request. ๐Ÿ˜Œ

EE ๐Ÿ›‘

This is a non-standard Version 9 AT&T UNIX extension that GNU later adopted. In mandoc(1), it does the exact same thing as the roff(7) fi request โ€” switch to fill mode. โœจ

EX ๐Ÿšซ

Also a non-standard 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 ๐Ÿ“

Begins a paragraph whose first output line is left-justified, but every line after that is indented. Syntax goes like this:

.HP [width]

The width argument is a roff(7) scaling width. If you specify it, it gets saved for later paragraph left margins; if you don't, the saved-or-default width is used. ๐Ÿซถ

This macro is portable, but it's deprecated, because it has no good representation in HTML output โ€” it usually ends up indistinguishable from PP. ๐Ÿ˜ญ

I โœ๏ธ

Text is rendered in italics.

IB ๐Ÿ”

Text is rendered alternately in italics and bold face. Whitespace between arguments is omitted in output. Also see BI. ๐ŸŽ€

IP ๐Ÿ”˜

Begins an indented paragraph, syntax:

.IP [head [width]]

The width argument is a roff(7) scaling width that defines the left margin. It's saved for later paragraph left-margins; if unspecified, the saved-or-default width gets used. ๐Ÿ’…

The head argument is used as a leading term, flushed to the left margin. Super handy for bulleted paragraphs and stuff like that. ๐ŸŒŸ

IR ๐Ÿฆ‹

Text is rendered alternately in italics and roman (the default font). Whitespace between arguments is omitted in output. Also see BI. ๐Ÿ‘‘

LP ๐Ÿชž

Just a synonym for PP. that's it, that's the whole macro.

ME ๐Ÿ“ง

Ends a mailto block that was started with MT. This is a non-standard GNU extension. ๐Ÿซถ

MT ๐Ÿ’Œ

Begins a mailto block. Also a non-standard GNU extension. Syntax:

.MT address
link description to be shown
.ME

OP ๐Ÿšฉ

Optional command-line argument. This one is a non-standard DWB extension. Syntax:

.OP key [value]

The key is usually a command-line flag, and value is its argument. ๐Ÿ˜Œ

P ๐Ÿช„

This synonym for PP is an AT&T System III UNIX extension that 4.3BSD later adopted. โœจ

PD ๐Ÿ“Š

Specify the vertical space to be inserted before each new paragraph. Syntax:

.PD [height]

The height argument is a roff(7) scaling width. It defaults to 1v. If you leave the unit off, v is assumed. ๐Ÿ’…

This macro affects the spacing before any subsequent instances of HP, IP, LP, P, PP, SH, SS, SY, and TP. so like, it's a whole vibe-shifter for spacing.

PP ๐Ÿ“

Begins an undecorated paragraph. A paragraph's scope gets closed by a subsequent paragraph, sub-section, section, or end of file. The saved paragraph left-margin width gets reset to the default. ๐ŸŒธ

RB ๐Ÿ”„

Text is rendered alternately in roman (the default font) and bold face. Whitespace between arguments is omitted in output. Also see BI. ๐Ÿ‘€

RE โ†ฉ๏ธ

Explicitly closes out the scope of a prior RS. The default left margin gets restored to whatever it was before that RS invocation. ๐Ÿ’–

Syntax:

.RE [level]

With no 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 stay open. ๐Ÿซถ

RI ๐ŸŽญ

Text is rendered alternately in roman (the default font) and italics. Whitespace between arguments is omitted in output. Also see BI. ๐ŸŒˆ

RS ๐Ÿ“

Temporarily resets the default left margin. Syntax:

.RS [width]

The width argument is a roff(7) scaling width. If it's not specified, the saved-or-default width is used. โœจ

Also see 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 ๐Ÿ›๏ธ

Begins a section. A section's scope is only closed by another section or the end of file. The paragraph left-margin width gets reset to the default. ๐ŸŽ€

SM ๐Ÿค

Text is rendered in small size โ€” one point smaller than the default font.

SS ๐Ÿชœ

Begins a sub-section. A sub-section's scope is closed by a subsequent sub-section, section, or end of file. The paragraph left-margin width gets reset to the default. โœจ

SY ๐Ÿ’ป

Begins a synopsis block, syntax:

.SY command
arguments
.YS

This is a non-standard GNU extension and it's very rarely used, even in GNU manual pages. Formatting works similar to IP. ๐Ÿ‘€

TH ๐Ÿ‘‘

Sets the name of the manual page, for use in the page header and footer. Syntax:

.TH name section date [source [volume]]

Conventionally, the document name is given in all caps. The section is usually a single digit, and in a few cases it's followed by a letter. ๐Ÿ“š

The recommended date format is YYYY-MM-DD, exactly as specified in the ISO-8601 standard; if the argument doesn't conform, it gets 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 it's 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 ๐Ÿ“Œ

Begins a paragraph where the head โ€” if it goes past the indentation width โ€” is followed by a newline; if it doesn't, the body follows on the same line, after advancing to the indentation width. Subsequent output lines are indented. ๐ŸŒธ

Syntax:

.TP [width]
head \" one line
body

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

TQ ๐Ÿ˜ถโ€๐ŸŒซ๏ธ

Like TP, except no vertical spacing is inserted before the paragraph. This is a non-standard GNU extension and it's very rarely used, even in GNU manual pages. ๐Ÿ’€

UC ๐Ÿ•ฐ๏ธ

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

UE ๐Ÿ”—

Ends a uniform resource identifier block that was started with UR. This is a non-standard GNU extension. ๐Ÿซถ

UR ๐ŸŒ

Begins a uniform resource identifier block. Also a non-standard GNU extension. Syntax:

.UR uri
link description to be shown
.UE

YS โœ…

Ends a synopsis block that was started with SY. This is a non-standard GNU extension. ๐ŸŽ€

in ๐Ÿ“ฅ

Indent relative to the current indentation:

.in [width]

If width is signed, the new offset is relative. Otherwise, it's absolute. This value gets reset upon the next paragraph, section, or sub-section. ๐Ÿ’…

โœจ Line Macros โœจ

Line macros are only scoped to the current line โ€” that's their whole thing. The body is zero or more arguments. But plot twist: if a macro is scoped to the next line and its line arguments are empty, then the next line (which has to be text, bestie) gets used instead. So like:

.I
foo

is literally the same as .I foo. ๐Ÿซถ

And now the messy part:

  • If next-line macros get invoked consecutively, only the last one is used. ๐Ÿ™ˆ
  • If a next-line macro is followed by a non-next-line macro, an error is raised. ๐Ÿ’€

The syntax goes like this:

.YO [body...]
[body...]

And here's the full lineup of line macros, with how many args they eat, where they're scoped, and any receipts:

  • AT โ€” arguments: <=1, scope: current
  • B โ€” arguments: n, scope: next-line
  • BI โ€” arguments: n, scope: current
  • BR โ€” arguments: n, scope: current
  • DT โ€” arguments: 0, scope: current
  • EE โ€” arguments: 0, scope: current (Version 9 AT&T UNIX)
  • EX โ€” arguments: 0, scope: current (Version 9 AT&T UNIX)
  • I โ€” arguments: n, scope: next-line
  • IB โ€” arguments: n, scope: current
  • IR โ€” arguments: n, scope: current
  • OP โ€” arguments: >=1, scope: current (DWB)
  • PD โ€” arguments: 1, scope: current
  • RB โ€” arguments: n, scope: current
  • RI โ€” arguments: n, scope: current
  • SB โ€” arguments: n, scope: next-line
  • SM โ€” arguments: n, scope: next-line
  • TH โ€” arguments: >1, <6, scope: current
  • UC โ€” arguments: <=1, scope: current
  • in โ€” arguments: 1, scope: current (roff(7))

๐Ÿงฑ Block Macros ๐Ÿงฑ

Block macros are built different: they've got a head and a body. Just like the in-line ones, the head is scoped to the current line and โ€” in exactly one situation โ€” the next line (yes, the same next-line stipulations from "Line Macros" apply here too, no cap).

The syntax:

.YO [head...]
[head...]
[body...]

So when does the body scope actually close? Depends:

  • section โ€” closed by SH
  • sub-section โ€” closed by a section or SS
  • paragraph โ€” closed by a section, sub-section, HP, IP, LP, P, PP, RE, SY, or TP

And ngl: no closure refers to an explicit block closing macro. That's just how it is.

Also, as a rule, block macros may not be nested. So calling a block macro while another block macro scope is still open โ€” and that open scope isn't implicitly closed โ€” is syntactically incorrect. ๐Ÿšซ

Here's the whole roster:

  • HP โ€” arguments: <2, head scope: current, body scope: paragraph
  • IP โ€” arguments: <3, head scope: current, body scope: paragraph
  • LP โ€” arguments: 0, head scope: current, body scope: paragraph
  • ME โ€” arguments: 0, head scope: none, body scope: none (GNU)
  • MT โ€” arguments: 1, head scope: current, body scope: to ME (GNU)
  • P โ€” arguments: 0, head scope: current, body scope: paragraph
  • PP โ€” arguments: 0, head scope: current, body scope: paragraph
  • RE โ€” arguments: <=1, head scope: current, body scope: none
  • RS โ€” arguments: 1, head scope: current, body scope: to RE
  • SH โ€” arguments: >0, head scope: next-line, body scope: section
  • SS โ€” arguments: >0, head scope: next-line, body scope: sub-section
  • SY โ€” arguments: 1, head scope: current, body scope: to YS (GNU)
  • TP โ€” arguments: n, head scope: next-line, body scope: paragraph
  • TQ โ€” arguments: n, head scope: next-line, body scope: paragraph (GNU)
  • UE โ€” arguments: 0, head scope: current, body scope: none (GNU)
  • UR โ€” arguments: 1, head scope: current, body scope: part (GNU)
  • YS โ€” arguments: 0, head scope: none, body scope: none (GNU)

One more lil rule: if a block macro is next-line scoped, it may only be followed by in-line macros for decorating text. That's it, that's the boundary. ๐Ÿ’…


๐ŸŽจ Font handling ๐ŸŽจ

In man documents you've got two ways to pick a font: the "Physical markup" macros, or roff(7)'s \f font escape sequences. Both valid, bestie. โœจ

Here's the tea on how long each one sticks around:

  • 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.

And heads up: macros like BR open and close a font scope for each argument. So it's giving very much per-argument energy. ๐Ÿ‘‘


๐Ÿ‘€ SEE ALSO ๐Ÿ‘€

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


๐Ÿ“œ HISTORY ๐Ÿ“œ

The man language first showed up as a macro package for the roff typesetting system in Version 7 AT&T UNIX. Iconic origin story honestly. ๐Ÿ›๏ธ

The stand-alone implementation that's part of the mandoc(1) utility? That first appeared in OpenBSD 4.6. ๐ŸŒธ


๐Ÿ’– AUTHORS ๐Ÿ’–

  • Douglas McIlroy <m.douglas.mcilroy@dartmouth.edu> โ€” 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. main character energy fr. ๐Ÿ‘‘
  • James Clark โ€” later rewrote the macros for groff.
  • Eric S. Raymond <esr@thyrsus.com> and Werner Lemberg <wl@gnu.org> โ€” added the extended man macros to groff in 2007.
  • Kristaps Dzonsons <kristaps@bsd.lv> โ€” wrote the mandoc(1) program and this man reference. ๐Ÿซถ

and that's the whole page bestie!! ๐ŸŽ€ This one ships from Debian, dated August 5, 2021, and it's page MAN(7) โ€” go forth and write some gorgeous man pages, you absolute legend ๐Ÿ’…โœจ๐Ÿฆ‹

๐Ÿ“ฆ where this page comes from