Linux cli command groff_man
8 minute read
Name
groff_man - compose manual pages with GNU roff
Synopsis
groff -man [*option *. . .] [*file *. . .] groff -m man [*option *. . .] [*file *. . .]
Description
The GNU implementation of the man macro package is part of the groff document formatting system. It is used to produce manual pages (“man pages”) like the one you are reading.
This document presents the macros thematically; for those needing only a quick reference, the following table lists them alphabetically, with cross references to appropriate subsections below.
Man page authors and maintainers who are not already experienced groff users should consult
an expanded version of this document, for additional explanations and advice. It covers only those concepts required for man page document maintenance, and not the full breadth of the groff typesetting system.
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 | Paragraphing macros |
.IR | Italic, roman alternating | Font style macros |
.LP | Begin paragraph | Paragraphing macros |
.ME | Mail-to end | Hyperlink macros |
.MR | Man page cross reference | Hyperlink macros |
.MT | Mail-to start | Hyperlink macros |
.P | Begin paragraph | Paragraphing macros |
.PP | Begin paragraph | Paragraphing macros |
.RB | Roman, bold alternating | Font style macros |
.RE | Relative inset end | Document structure macros |
.RI | Roman, italic alternating | Font style macros |
.RS | Relative inset start | Document structure macros |
.SB | Small bold | Font style macros |
.SH | Section heading | Document structure macros |
.SM | Small | Font style macros |
.SS | Subsection heading | Document structure macros |
.SY | Synopsis start | Command synopsis macros |
.TH | Title heading | Document structure macros |
.TP | Tagged paragraph | Paragraphing macros |
.TQ | Supplemental paragraph tag | Paragraphing macros |
.UE | URI end | Hyperlink macros |
.UR | URI start | Hyperlink macros |
.YS | Synopsis end | Command synopsis macros |
We discuss other macros (.AT, .DT, .HP, .OP, .PD, and .UC) in subsection “Deprecated features” below.
Throughout Unix documentation, a manual entry is referred to simply as a “man page”, regardless of its length, without gendered implication, and irrespective of the macro package selected for its composition.
Macro reference preliminaries
A tagged paragraph describes each macro. We present coupled pairs together, as with .EX and .EE.
An empty macro argument can be specified with a pair of double-quotes (""), but the man package is designed such that this should seldom be necessary. Most macro arguments will be formatted as text in the output; exceptions are noted.
Document structure macros
Document structure macros organize a man page’s content. All of them break the output line. .TH (title heading) identifies the document as a man page and configures the page headers and footers. Section headings (.SH), one of which is mandatory and many of which are conventionally expected, facilitate location of material by the reader and aid the man page writer to discuss all essential aspects of the topic. Subsection headings (.SS) are optional and permit sections that grow long to develop in a controlled way. Many technical discussions benefit from 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, use .RS/.RE to inset a region within a (sub)section.
.TH* topic section*
[footer-middle] [footer-inside] [header-middle] Determine the contents of the page header and footer. The subject of the man page is topic and the section of the manual to which it belongs is section. See
or
for the manual sectioning applicable to your system. topic and section are positioned together at the left and right in the header (with section in parentheses immediately appended to topic). footer-middle is centered in the footer. The arrangement of the rest of the footer depends on whether double-sided layout is enabled with the option -rD1. When disabled (the default), footer-inside is positioned at the bottom left. Otherwise, footer-inside appears at the bottom left on recto (odd-numbered) pages, and at the bottom right on verso (even-numbered) pages. The outside footer is the page number, except in the continuous-rendering mode enabled by the option -rcR=1, in which case it is the topic and section, as in the header. header-middle is centered in the header. If section is an integer between 1 and 9 (inclusive), there is no need to specify header-middle; an.tmac will supply text for it. The macro package may also abbreviate topic and footer-inside with ellipses if they would overrun the space available in the header and footer, respectively. For HTML output, headers and footers are suppressed.
Additionally, this macro breaks the page, resetting the number to 1 (unless the -rC1 option is given). This feature is intended only for formatting multiple man documents in sequence.
A valid man document calls .TH once, early in the file, prior to any other macro calls.
.SH [
heading-text] Set heading-text as a section heading. If no argument is given, a one-line input trap is planted; text on the next line becomes heading-text. The left margin is reset to zero to set the heading text in bold (or the font specified by the string HF), and, on typesetting devices, slightly larger than the base type size. If the heading font \[HF] is bold, use of an italic style in heading-text is mapped to the bold-italic style if available in the font family. The inset level is reset to 1, setting the left margin to the value of the IN register. Text after heading-text is set as an ordinary paragraph (.P).
The content of heading-text and ordering of sections follows a set of common practices, 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 .TH call, and must contain only text of the form
topic[ ,* another-topic* ]. . . \ summary-description
for a man page to be properly indexed. See
for suggestions and
for the conventions prevailing on your system.
.SS [
subheading-text] Set subheading-text as a subsection heading indented between a section heading and an ordinary paragraph (.P). If no argument is given, a one-line input trap is planted; text on the next line becomes subheading-text. The left margin is reset to the value of the SN register to set the heading text in bold (or the font specified by the string HF). If the heading font \[HF] is bold, use of an italic style in subheading-text is mapped to the bold-italic style if available in the font family. The inset level is reset to 1, setting the left margin to the value of the IN register. Text after subheading-text is set as an ordinary paragraph (.P).
.EX
.EE
Begin and end example. After .EX, filling is disabled and a constant-width (monospaced) font is selected. Calling .EE enables filling and restores the previous font.
These macros are extensions introduced in Ninth Edition Research Unix. Systems running that troff, or those from Documenter’s Workbench, Heirloom Doctools, or Plan 9 troff support them. To be certain your page will be portable to systems that do not, copy their definitions from the an-ext.tmac file of a groff installation.
.RS [
inset-amount] Start a new relative inset level. The position of the left margin is saved, then moved right by inset-amount, if specified, and by the amount of the IN register otherwise. Calls to .RS can be nested; each increments by 1 the inset level used by .RE. The level prior to any .RS calls is 1.
.RE [
level] End a relative inset. The left margin corresponding to inset level level is restored. If no argument is given, the inset level is reduced by 1.
Paragraphing macros
An ordinary paragraph (.P) is set without a first-line indentation at the current left margin. In man pages and other technical literature, definition lists are frequently encountered; these can be set as “tagged paragraphs”, which have one (.TP) or more (.TQ) leading tags followed by a paragraph that has an additional indentation. 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. All of these macros break the output line. If another paragraph macro has occurred since the previous .SH or .SS, they (except for .TQ) follow the break with a default amount of vertical space, which can be changed by the deprecated .PD macro; see subsection “Horizontal and vertical spacing” below. They also reset the type size and font style to defaults (.TQ again excepted); see subsection “Font style macros” below.
.P
.LP
.PP
Begin a new paragraph; these macros are synonymous. The indentation is reset to the default value; the left margin, as affected by .RS and .RE, is not.
.TP [
indentation] Set a paragraph with a leading tag, and the remainder of the paragraph indented. A one-line input trap is planted; text on the next line, which can be formatted with a macro, becomes the tag, which is placed at the current left margin. The tag can be extended with the **
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.