groff_man (7) Linux Manual Page
groff_man – GNU roff macro package for formatting man pages
Synopsis
[option …] [input-file …] [option …] [input-file …]
Description
The man macro package for groff is used to produce manual pages (“man~pages”) like the one you are reading. GNU roff‘s implementation was written by James Clark. This document presents the macros thematically to aid learners; for those needing only a quick reference, the following table lists them alphabetically, with cross-references to appropriate subsections below.
| Macro | Meaning | Subsection |
|
|
||
.B |
Bold | Font style macros |
.BI |
Bold, italic alternating | Font style macros |
.BR |
Bold, roman alternating | Font style macros |
.EE |
Example end | Document structure macros |
.EX |
Example begin | Document structure macros |
.I |
Italic | Font style macros |
.IB |
Italic, bold alternating | Font style macros |
.IP |
Indented paragraph | Paragraph macros |
.IR |
Italic, roman alternating | Font style macros |
.LP |
(Left) paragraph | Paragraph macros |
.ME |
Mail-to end | Hyperlink and email macros |
.MT |
Mail-to start | Hyperlink and email macros |
.OP |
(Command-line) option | Command synopsis macros |
.P |
Paragraph | Paragraph macros |
.PP |
Paragraph | Paragraph macros |
.RB |
Roman, bold alternating | Font style macros |
.RE |
Relative-indent end | Document structure macros |
.RI |
Roman, italic alternating | Font style macros |
.RS |
Relative-indent start | Document structure macros |
.SB |
Small bold | Font style macros |
.SH |
Section heading | Document structure macros |
.SM |
Small | Font style macros |
.SS |
Subection heading | Document structure macros |
.SY |
Synopsis start | Command synopsis macros |
.TH |
Title heading | Document structure macros |
.TP |
Tagged paragraph | Paragraph macros |
.TQ |
Tagged paragraph continuation | Paragraph macros |
.UE |
URL end | Hyperlink and email macros |
.UR |
URL start | Hyperlink and email macros |
.YS |
Synopsis end | Command synopsis macros |
Macros whose use we discourage (.AT, .BT, .DT, .HP, .PD, .PT, and .UC) are described in subsection “Deprecated features”, below.
Macro reference preliminaries
Each macro is described in a tagged paragraph. Closely related macros, such as .EX and .EE, are grouped together. Optional macro arguments are indicated by surrounding them with square brackets. If a macro accepts multiple arguments, arguments containing whitespace must be double-quoted ("one two"), to be interpreted correctly. Most macro arguments are strings that will be output as text; exceptions are noted. Bear in mind that groff is fundamentally a programming system for typesetting. Consequently, the verb “to set” is frequently used below in the sense “to typeset”.
Document structure macros
The highest level of organization of a man page is determined by this group of macros. .TH (title heading) identifies the document as a man page and defines information enabling its indexing by mandb(8) or a similar tool. Sections (.SH), one of which is mandatory and many of which are standardized, facilitate quick location of relevant material by the reader and aid the man page writer to discuss all essential aspects of the topic. Subsections (.SS) are optional and permit sections that grow long to develop in a controlled way. Many technical discussions require examples; lengthy ones, especially those reflecting multiple lines of input to or output from the system, are usefully bracketed by .EX and .EE. When none of the foregoing meets a structural demand, a section of the discussion can be manually indented within .RS and .RE macros.
.THtitle section- [footer-middle] [footer-outside] [header-middle] Define the title of the man page as title and the section as section. See man(1) for details on the section numbers and suffixes applicable to your system. title and section are positioned together at the left and right in the header line (with section in parentheses immediately appended to title). footer-middle is centered in the footer line. footer-outside is positioned at the left in the footer line (or at the left on even pages and at the right on odd pages if double-sided printing is active). header-middle is centered in the header line. If section is a simple integer between 1 and~9 (inclusive), or is exactly “3p”, there is no need to specify header-middle; the macro package will supply text for it.
- For HTML output, headers and footers are completely suppressed.
- Additionally, this macro starts a new page; the page number is reset to~1 (unless the
-rC1option is given on the command line). This feature is intended only for formatting multiple man pages.- A man page should contain exactly one
.THcall at or near the beginning of the file, prior to any other macro calls.- By convention, footer-middle is the most recent modification date of the man page source document, and footer-outside is the name and version or release of the project providing it.
- For HTML output, headers and footers are completely suppressed.
.SH[- heading-text] Set heading-text as a section heading flush left. The text following
.SHup to the end of the line, or the text on the next input line if.SHis given no arguments, is set in bold (or the font specified by the string registerHF) slightly larger than the base font size. Additionally, the left margin and indentation affecting subsequent text are reset to their default values. Text on input lines after heading-text is set as a normal paragraph (.PP).- The content of heading-text and ordering of sections has been standardized by common practice, as has much of the layout of material within sections. For example, a section called “Name” or “NAME” must exist, must be the first section after the
.THcall, and must contain only a line of the form- " Invisibly move left margin to current .IP indent.
- " Now indent further, visibly. page-topic[
,…]\-summary-description
for a man page to be properly indexed. See man(7) for the conventions prevailing on your system.
- " Now indent further, visibly. page-topic[
- The content of heading-text and ordering of sections has been standardized by common practice, as has much of the layout of material within sections. For example, a section called “Name” or “NAME” must exist, must be the first section after the
.SS[- subheading-text] Set subheading-text as a subsection heading indented (by default) partway between a section heading and a normally-indented paragraph (
.PP). The text following.SSup to the end of the line, or the text on the next input line if.SSis given no arguments, is set in bold (or the font specified by the string registerHF) at the base font size. Additionally, the left margin and indentation affecting subsequent text are reset to their default values. Text on input lines after subheading-text is set as a normal paragraph (.PP). .EX.EEBegin and end example. After.EX, filling and hyphenation are disabled and a constant-width (monospaced) font is selected. Calling.EEenables filling and restores the previous hyphenation setting and font.- Example regions are useful for formatting code, shell sessions, and text file contents.
- These macros are defined on many (but not all) legacy Unix systems running classic troff. To be certain your page will be portable to those systems, copy their definitions from the an-ext.tmac file of a groff installation.
- Example regions are useful for formatting code, shell sessions, and text file contents.
.RS[- indent] Move the left margin to the right by the value indent, if specified, and by a default amount otherwise; see subsection “Horizontal and vertical spacing” below. Calls to
.RScan be nested; each call increments by~1 the indentation level used by.RE. The indentation level prior to any.RScalls is~1. .RE[- level] Move the left margin back to that corresponding to indentation level level. If no argument is given, move the left margin one level back.
Paragraph macros
A typical paragraph (.PP) is set at the current left margin, which by default is indented from the left margin of the output device. In man pages and other technical literature, definition lists are frequently encountered; these can be set as “tagged paragraphs” (.TP and .TQ), which have one or more leading tags followed by a paragraph that has an additional left indent. The indented paragraph (.IP) macro is useful to continue the indented content of a narrative started with .TP, or to present an itemized or ordered list.
.LP.PP.PBegin a new paragraph; these macros are synonymous. They break the output line at the current position, followed by a vertical space downward by a default amount (which can be changed by the deprecated.PDmacro). The font size and style are reset to defaults; see subsection “Font style macros” below. Finally, the left margin and indentation are reset to default values..TP[- indent] Set a tagged, indented paragraph. The input line following this macro, known as the tag, is printed at the current left margin. Subsequent text is indented by indent, if specified, and by a default amount otherwise; see subsection “Horizontal and vertical spacing” below.
- If the tag is not as wide as the indentation, the paragraph starts on the same line as the tag, at the applicable indentation, and continues on the following lines. Otherwise, the descriptive part of the paragraph begins on the line following the tag, entirely indented. The line containing the tag can include a macro call, for instance to set the tag in bold with
.B..TPwas used to write the first paragraph of this description of.TP, and.IPthe subsequent ones. - If the tag is not as wide as the indentation, the paragraph starts on the same line as the tag, at the applicable indentation, and continues on the following lines. Otherwise, the descriptive part of the paragraph begins on the line following the tag, entirely indented. The line containing the tag can include a macro call, for instance to set the tag in bold with
.TQ- Set an additional tag for a paragraph tagged with
.TP. The pending output line is broken. The tag on the input line following this macro and subsequent lines are handled as with.TP.- This macro is not defined on legacy Unix systems running classic troff. To be certain your page will be portable to those systems, copy its definition from the an-ext.tmac file of a groff installation.
- The descriptions of
.LP,.PP, and.Pabove were written using.TPand.TQ. - This macro is not defined on legacy Unix systems running classic troff. To be certain your page will be portable to those systems, copy its definition from the an-ext.tmac file of a groff installation.
.IP[- tag] [indent] Set an indented paragraph with an optional tag. The tag and indent arguments, if present, are handled as with
.TP, with the exception that the tag argument to.IPcannot include a macro call.- Two convenient use cases for
.IPare- " Invisibly move left margin to current .IP indent.
- " Now indent further, visibly.
- (1)
- to start a new paragraph with the same indentation as the previous
.IPor.TPparagraph, if no indent argument is given; and - (2)
- to set a paragraph with a short tag that is not semantically important, such as a bullet (•)—obtained with the ‘\(bu’ character escape—or list enumerator, as seen in this very paragraph.
- " Now indent further, visibly.
- Two convenient use cases for
Command synopsis macros
Command synopses are a staple of section~1 and~8 man pages. These macros aid you to construct one that has the classical Unix appearance. Furthermore, some tools are able to interpret these macros semantically and treat them appropriately for localization and/or presentation. A command synopsis is wrapped in .SY/.YS calls, with command-line options of some formats indicated by .OP. These macros are not defined on legacy Unix systems running classic troff. To be certain your page will be portable to those systems, copy their definitions from the an-ext.tmac file of a groff installation.
.SYcommand- Begin synopsis. Hyphenation is turned off. The command argument is set in bold. The output line is filled as normal, but if a break is required, subsequent output lines are indented by the width of command plus a space.
.OPoption-name/- [option-argument] Indicate an optional command parameter called option-name, which is set in bold. If the option takes an argument, specify option-argument using a noun, abbreviation, or hyphenated noun phrase. If present, option-argument is preceded by a space and set in italics. Square brackets (in roman) surround both arguments.
.YS- End synopsis. Restore indentation and hyphenation to previous values.
Multiple .SY/.YS blocks can be specified, for instance to distinguish differing modes of operation of a complex command like tar(1); each will be separated by a paragraph space. .SY can also be repeated multiple times before a closing .YS, which is useful to indicate synonymous ways of invoking a particular mode of operation. For example,
- .SY groff .OP \-abcegiklpstzCEGNRSUVXZ .OP \-d cs .OP \-f fam .OP \-F dir .OP \-I dir .OP \-K arg .OP \-L arg .OP \-m name .OP \-M dir .OP \-n num .OP \-o list .OP \-P arg .OP \-r cn .OP \-T dev .OP \-w name .OP \-W name .RI [ file \&.\|.\|.\&] .YS . .SY groff .B \-h .SY groff .B \-\-help .YS
- produces the following output.
- [
-abcegiklpstzCEGNRSUVXZ] [-dcs ] [-ffam ] [-Fdir ] [-Idir ] [-Karg ] [-Larg ] [-mname ] [-Mdir ] [-nnum ] [-olist ] [-Parg ] [-rcn ] [-Tdev ] [-wname ] [-Wname ] [file …]-h–help
Several features of the above example are of note.
- •
- The empty request (.), which does nothing, is used for vertical spacing in the input file for readability by the document maintainer. Do not put empty lines in a roff source document.
- •
- The command and option names are presented in
boldto cue the user that they should be input literally. - •
- Option dashes are specified with the ‘\-‘ escape sequence; this is an important practice to make them clearly visible and to facilitate cut-and-paste from the rendered man page to a shell prompt or text file.
- •
- Option arguments and command operands are presented in italics (underlined on some output devices, such as terminals and emulators), to cue the user that they must be replaced with appropriate text.
- •
- Symbols that are neither to be typed literally nor simply replaced appear in the roman style; brackets surround optional arguments, and an ellipsis indicates that the previous syntactical element may be repeated arbitrarily.
- Some man pages use a brace-and-pipe notation such as “{
–diff|–compare}” to indicate that one and only one of the ‘|’-separated items within the braces must be input. If this braced construct is furthermore surrounded by square brackets, it means that at most one of the items is accepted.- Authors of man pages should note the use of the zero-width space escape sequence ‘\&’ on both sides of the ellipsis; this is a good practice to avoid surprises in the event the ellipsis gets refilled in your text editor. See “Portability”, below. The morbidly curious may consult groff(7) regarding the narrow-space escape sequence ‘\|’.
- Some man pages use a brace-and-pipe notation such as “{
Hyperlink and email macros
Email addresses are bracketed with
.MT/.MEand URL hyperlinks with.UR/.UE. These macros are not defined on legacy Unix systems running classic troff. To be certain your page will be portable to those systems, copy their definitions from the an-ext.tmac file of a groff installation..MTaddress.ME[punctuation] Identify address as an RFC 6068 addr-spec for a “mailto:” URI with the text between the two macro calls as the link text. A punctuation argument to.MEis placed at the end of the link text without intervening space. Note that address may not be visible in the output text, particularly if the man page is being viewed as HTML. On a device that is not a browser, address is set in angle brackets after the link text and before punctuation.- When rendered by groff to a TTY or PostScript output device,
-
- Contact .MT fred.foonly@\:fubar.net Fred Foonly .ME for more information.
- displays as: “Contact Fred Foonly <fred.foonly@:fubar.net> for more information.”.
- The use of ‘\:’ to insert hyphenless discretionary breaks is a groff extension and can be omitted.
- When rendered by groff to a TTY or PostScript output device,
.URURL.UE[punctuation] Identify URL as an RFC 3986 URI hyperlink with the text between the two macro calls as the link text. A punctuation argument to.UEis placed at the end of the link text without intervening space. Note that URL may not be visible in the output text, particularly if the man page is being viewed as HTML. On a device that is not a browser, URL is set in angle brackets after the link text and before punctuation.- When rendered by groff to a TTY or PostScript output device,
-
- The GNU Project of the Free Software Foundation hosts the .UR https://\:www.gnu.org/\:software/\:groff/ Groff home page .UE .
- displays as: “The GNU Project of the Free Software Foundation hosts the Groff home page <https://:www.gnu.org/:software/:groff/>.”.
- The use of ‘\:’ to insert hyphenless discretionary breaks is a groff extension and can be omitted.
- When rendered by groff to a TTY or PostScript output device,
Font style macros
The man macro package is limited in its font styling options, offering only
bold~(.B), italic~(.I), and roman (the default). Italic text is usually set underscored instead on terminals and other classical nroff-style output devices. The.SMand.SBmacros set text in roman or bold, respectively, at a smaller point size; these differ visually from regular-sized roman or bold text only on troff-style output devices. The foregoing macros cause word breaks before and after their arguments, but it is often necessary to set text in different styles without intervening whitespace. The macros.BI,.BR,.IB,.IR,.RB, and.RI, where ‘B’, ‘I’, and ‘R’ indicate bold, italic, and roman, respectively, set their odd- and even-numbered arguments in alternating styles, with no whitespace separating them. Because font styles are presentational rather than semantic, conflicting traditions have arisen regarding which font styles should be used to mark file or path names, environment variables, in-line literals, and even man page cross-references. The default font size and family (for troff output devices) is 10-point Times. The default style is roman..B~[- text] Set text in bold. If the macro is given no arguments, the text of the next input line is set in bold.
- Use bold for literal portions of syntax synopses, for command-line options in running text, and for literals that are major topics of the subject under discussion; for example, this page uses bold for macro and register names. In
.EX/.EEexamples of interactive I/O (such as a shell session), set only the user-typed input in bold. - Use bold for literal portions of syntax synopses, for command-line options in running text, and for literals that are major topics of the subject under discussion; for example, this page uses bold for macro and register names. In
.I~[- text] Set text in italics. If the macro is given no arguments, the text of the next input line is set in italics.
- Use italics for file and path names, for environment variables, for enumeration or preprocessor constants in C, for variable (user-determined) portions of syntax synopses, for the first occurrence only of a technical concept being introduced, for names of works of software (including commands and functions, but excluding names of operating systems or their kernels), and anywhere a parameter requiring replacement by the user is encountered. An exception involves variable text in a context that is already marked up in italics, such as file or path names with variable components; in such cases, follow the convention of mathematical typography: set the file or path name in italics as usual (see
.IRbelow), but use roman for the variable part, and italics again in running roman text when referring to the variable material. - Use italics for file and path names, for environment variables, for enumeration or preprocessor constants in C, for variable (user-determined) portions of syntax synopses, for the first occurrence only of a technical concept being introduced, for names of works of software (including commands and functions, but excluding names of operating systems or their kernels), and anywhere a parameter requiring replacement by the user is encountered. An exception involves variable text in a context that is already marked up in italics, such as file or path names with variable components; in such cases, follow the convention of mathematical typography: set the file or path name in italics as usual (see
.SM~[- text] Set text one point size smaller than the default size. If the macro is given no arguments, the text of the next input line is set smaller.
- Note: nroff-style output devices, such as terminals, will render text at the normal font size instead. Do not rely upon
.SMto communicate semantic information distinct from using roman style at the normal size; it will be hidden from readers using such devices. - Note: nroff-style output devices, such as terminals, will render text at the normal font size instead. Do not rely upon
.SB~[- text] Set text in bold, one point size smaller than the default size. If the macro is given no arguments, the text of the next input line is set smaller and in bold.
- Note: nroff-style output devices, such as terminals, will render text in bold at the normal font size instead. Do not rely upon
.SBto communicate semantic information distinct from using bold style at the normal size; it will be hidden from readers using such devices. - Note: nroff-style output devices, such as terminals, will render text in bold at the normal font size instead. Do not rely upon
Note what is not prescribed for setting in bold or italics above: elements of “synopsis language” such as ellipses and brackets around options; proper names and adjectives; titles of anything other than works of literature or software; identifiers for standards documents or technical reports such as CSTR~#54, RFC~1918, Unicode~11.0, or POSIX.1-2017; acronyms; and occurrences after the first of a technical term or piece of jargon. Again, the names of operating systems and their kernels are, by practically universal convention, set in roman. Be frugal with the use of italics for emphasis, and particularly with the use of bold. Brief runs of literal text, such as references to individual characters or short strings, including section and subsection headings of man pages, are suitable objects for quotation; see the ‘\(lq’, ‘\(rq’, ‘\(oq’, and ‘\(cq’ escapes in subsection “Portability” below. Unlike the above font style macros, the font alternation macros below accept only arguments on the same line as the macro call. If whitespace is required within one of the arguments, first consider whether the same result could be achieved with as much clarity by using the single-style macros on separate input lines. When it cannot, double-quote an argument with one or more embedded space characters. Setting all three different styles within one whitespace-delimited word presents challenges; it is possible with the ‘
- produces the following output.
