Manpages - groff_mdoc.7

A complete reference for writing

manual pages with the

macro package; a

and

formatting package for

Its predecessor, the

package, addressed page layout leaving the manipulation of fonts and other typesetting details to the individual author. In

page layout macros make up the

which consists of macros for titles, section headers, displays and lists – essentially items which affect the physical position of text on a formatted page. In addition to the page structure domain, there are two more domains, the

domain and the

text domain. The general text domain is defined as macros which perform tasks such as quoting or emphasizing pieces of text. The manual domain is defined as macros that are a subset of the day to day informal language used to describe commands, routines and related

files. Macros in the manual domain handle command names, command-line arguments and options, function names, function parameters, pathnames, variables, cross references to other manual pages, and so on. These domain items have value for both the author and the future user of the manual page. Hopefully, the consistency gained across the manual set will provide easier translation to future documentation tools.

Throughout the

manual pages, a manual entry is simply referred to as a man page, regardless of actual length and without sexist intention.

The material presented in the remainder of this document is outlined as follows:

The

package attempts to simplify the process of writing a man page. Theoretically, one should not have to learn the tricky details of

to use

however, there are a few limitations which are unavoidable and best gotten out of the way. And, too, be forewarned, this package is

fast.

As in

a macro is called by placing a

(dot character) at the beginning of a line followed by the two-character (or three-character) name for the macro. There can be space or tab characters between the dot and the macro name. Arguments may follow the macro separated by spaces (but

tabs). It is the dot character at the beginning of the line which causes

to interpret the next two (or more) characters as a macro name. A single starting dot followed by nothing is ignored. To place a

(dot character) at the beginning of an input line in some context other than a macro invocation, precede the

(dot) with the

escape sequence which translates literally to a zero-width space, and is never displayed in the output.

In general,

macros accept an unlimited number of arguments (contrary to other versions of troff which can’t handle more than nine arguments). In limited cases, arguments may be continued or extended on the next line (See

below). Almost all macros handle quoted arguments (see

below).

Most of the

general text domain and manual domain macros are special in that their argument lists are

for callable macro names. This means an argument on the argument list which matches a general text or manual domain macro name (and which is defined to be callable) will be executed or called when it is processed. In this case the argument, although the name of a macro, is not preceded by a

(dot). This makes it possible to nest macros; for example the option macro,

may

the flag and argument macros,

and

to specify an optional flag with an argument:

is produced by

To prevent a string from being interpreted as a macro name, precede the string with the escape sequence

is produced by

Here the strings

and

are not interpreted as macros. Macros whose argument lists are parsed for callable arguments are referred to as

and macros which may be called from an argument list are referred to as

throughout this document. This is a technical

as almost all of the macros in

are parsed, but as it was cumbersome to constantly refer to macros as being callable and being able to call other macros, the term parsed has been used.

In the following, we call an

macro which starts a line (with a leading dot) a

if this distinction is necessary.

Sometimes it is desirable to give as an argument a string containing one or more blank space characters, say, to specify arguments to commands which expect particular arrangement of items in the argument list. Additionally, it makes

working faster. For example, the function command

expects the first argument to be the name of a function and any remaining arguments to be function parameters. As

stipulates the declaration of function parameters in the parenthesized parameter list, each parameter is guaranteed to be at minimum a two word string. For example,

There are two possible ways to pass an argument which contains an embedded space. One way of passing a string containing blank spaces is to use the hard or unpaddable space character

that is, a blank space preceded by the escape character

This method may be used with any macro but has the side effect of interfering with the adjustment of text over the length of a line.

sees the hard space as if it were any other printable character and cannot split the string into blank or newline separated pieces as one would expect. This method is useful for strings which are not expected to overlap a line boundary. An alternative is to use

a paddable (i.e. stretchable), unbreakable space (this is a

extension). The second method is to enclose the string with double quotes.

For example:

is created by

can also be created by

If the

before the space in the first example or double quotes in the second example were omitted,

would see three arguments, and the result would be:

can be confused by blank space characters at the end of a line. It is a wise preventive measure to globally remove all blank spaces from

character sequences. Should the need arise to use a blank character at the end of a line, it may be forced with an unpaddable space and the

escape character. For example,

Special characters like the newline character

are handled by replacing the

with

(e.g.

to preserve the backslash.

A warning is emitted when an empty input line is found outside of displays (see below). Use

instead. (Well, it is even better to use

macros to avoid the usage of low-level commands.)

Leading spaces will cause a break and are output directly. Avoid this behaviour if possible. Similarly, do not use more than one space character between words in an ordinary text line; contrary to other text formatters, they are

replaced with a single space.

You can’t pass

directly as an argument. Use

(or

instead.

By default,

inserts two space characters after a punctuation mark closing a sentence; characters like

or

are treated transparently, not influencing the sentence-ending behaviour. To change this, insert

before or after the dot:

The .Ql . character. .Pp The .Ql \&. character. .Pp .No test . test .Pp .No test. test

gives

The

character

The

character.

test

test

As can be seen in the first and third line,

handles punctuation characters specially in macro arguments. This will be explained in section

below. In the same way, you have to protect trailing full stops of abbreviations with a trailing zero-width space:

A comment in the source file of a man page can be either started with

on a single line,

after some input, or

anywhere (the latter is a

extension); the rest of such a line is ignored.

The body of a man page is easily constructed from a basic template:

.\“ The following commands are required for all man pages. .Dd Month day, year .Dt DOCUMENT_TITLE [section number] [architecture/volume] .Os [OPERATING_SYSTEM] [version/release] .Sh NAME .Nm name .Nd one line description of name .\” This next command is for sections 2 and 3 only. .\“ .Sh LIBRARY .Sh SYNOPSIS .Sh DESCRIPTION .\” The following commands should be uncommented and .\“ used where appropriate. .\” .Sh IMPLEMENTATION NOTES .\“ This next command is for sections 2, 3, and 9 only .\” (function return values). .\“ .Sh RETURN VALUES .\” This next command is for sections 1, 6, 7, and 8 only. .\“ .Sh ENVIRONMENT .\” .Sh FILES .\“ This next command is for sections 1, 6, and 8 only .\” (command return values to the shell). .\“ .Sh EXIT STATUS .\” .Sh EXAMPLES .\“ This next command is for sections 1, 4, 6, 7, 8, and 9 only .\” (fprintf/stderr type diagnostics). .\“ .Sh DIAGNOSTICS .\” .Sh COMPATIBILITY .\“ This next command is for sections 2, 3, 4, and 9 only .\” (settings of the errno variable). .\“ .Sh ERRORS .\” .Sh SEE ALSO .\“ .Sh STANDARDS .\” .Sh HISTORY .\“ .Sh AUTHORS .\” .Sh CAVEATS .\“ .Sh BUGS

The first items in the template are the commands

and

the document date, the operating system the man page or subject source is developed or modified for, and the man page title (in

along with the section of the manual the page belongs in. These commands identify the page and are discussed below in

The remaining items in the template are section headers

of which

and

are mandatory. The headers are discussed in

after presentation of

Several content macros are used to demonstrate page layout macros; reading about content macros before page layout macros is recommended.

In the description of all macros below, optional arguments are put into brackets. An ellipsis

represents zero or more additional arguments. Alternative values for a parameter are separated with

If there are alternative values for a mandatory parameter, braces are used (together with

to enclose the value set. Meta-variables are specified within angles.

Example:

Except stated explicitly, all macros are parsed and callable.

Note that a macro takes effect up to the next nested macro. For example,

doesn’t produce

but

Consequently, a warning message is emitted for most commands if the first argument is a macro itself since it cancels the effect of the calling command completely. Another consequence is that quoting macros never insert literal quotes;

has been produced by

Most macros have a default width value which can be used to specify a label width

or offset

for the

and

macros. It is recommended not to use this rather obscure feature to avoid dependencies on local modifications of the

package.

The title macros are part of the page structure domain but are presented first and separately for someone who wishes to start writing a man page yesterday. Three header macros designate the document title or manual page title, the operating system, and the date of authorship. These macros are called once at the very beginning of the document and are used to construct headers and footers only.

The document title is the subject of the man page and must be in

due to troff limitations. If omitted,

is used. The section number may be a number in the range

or

or

If it is specified, and no volume name is given, a default volume name is used.

Under

the following sections are defined:

1    
2    
3    
4    
5    
6    
7    
8    
9    

A volume name may be arbitrary or one of the following:

USD  
PS1  
AMD  
SMM  
URM  
PRM  
KM  
IND  
LOCAL  
CON  

For compatibility,

can be used for

and

for

Values from the previous table will specify a new volume name. If the third parameter is a keyword designating a computer architecture, its value is prepended to the default volume name as specified by the second parameter. By default, the following architecture keywords are defined: .Bd -ragged -offset indent

If the section number is neither a numeric expression in the range 1 to 9 nor one of the above described keywords, the third parameter is used verbatim as the volume name.

In the following examples, the left (which is identical to the right) and the middle part of the manual page header strings are shown. Note how

prevents the digit 7 from being a valid numeric expression.

Local, OS-specific additions might be found in the file

look for strings named

(for the former type) and

(for the latter type);

then denotes the keyword to be used with the

macro.

This macro is neither callable nor parsed.

If the first parameter is empty, the default

is used. This may be overridden in the local configuration file,

In general, the name of the operating system should be the common acronym, e.g.

or

The release should be the standard release nomenclature for the system specified. In the following table, the possible second arguments for some predefined operating systems are listed. Similar to

local additions might be defined in

look for strings named

where

is the acronym for the operating system and

the release ID.

7th, 7, III, 3, V, V.2, V.3, V.4

3, 4, 4.1, 4.2, 4.3, 4.3t, 4.3T, 4.3r, 4.3R, 4.4

0.8, 0.8a, 0.9, 0.9a, 1.0, 1.0a, 1.1, 1.2, 1.2a, 1.2b, 1.2c, 1.2d, 1.2e, 1.3, 1.3a, 1.4, 1.4.1, 1.4.2, 1.4.3, 1.5, 1.5.1, 1.5.2, 1.5.3, 1.6, 1.6.1, 1.6.2, 1.6.3, 2.0, 2.0.1, 2.0.2, 2.0.3, 2.1, 3.0, 3.0.1, 3.0.2, 3.0.3, 3.1, 3.1.1, 4.0, 4.0.1, 5.0, 5.0.1, 5.0.2, 5.1, 5.1.2, 5.1.3, 5.1.4, 5.2, 5.2.1, 5.2.2, 6.0, 6.0.1, 6.0.2, 6.0.3, 6.0.4, 6.0.5, 6.1, 6.1.1, 6.1.2, 6.1.3, 6.1.4

1.0, 1.1, 1.1.5, 1.1.5.1, 2.0, 2.0.5, 2.1, 2.1.5, 2.1.6, 2.1.7, 2.2, 2.2.1, 2.2.2, 2.2.5, 2.2.6, 2.2.7, 2.2.8, 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 4.0, 4.1, 4.1.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.6.2, 4.7, 4.8, 4.9, 4.10, 4.11, 5.0, 5.1, 5.2, 5.2.1, 5.3, 5.4, 5.5, 6.0, 6.1, 6.2, 6.3, 6.4, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4, 9.0, 9.1, 9.2, 9.3, 10.0

2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.7, 4.8, 4.9, 5.0, 5.1, 5.2, 5.3, 5.4, 5.5, 5.6

1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.8, 1.8.1, 1.9, 1.10, 1.12, 1.12.2, 1.13, 2.0, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 2.9.1, 2.10, 2.10.1, 2.11, 2.12, 2.13, 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8

8.0.0, 8.1.0, 8.2.0, 8.3.0, 8.4.0, 8.5.0, 8.6.0, 8.7.0, 8.8.0, 8.9.0, 8.10.0, 8.11.0, 9.0.0, 9.1.0, 9.2.0, 9.3.0, 9.4.0, 9.5.0, 9.6.0, 9.7.0, 9.8.0, 10.1.0, 10.2.0, 10.3.0, 10.4.0, 10.5.0, 10.6.0, 10.7.0, 10.8.0, 11.0.0, 11.1.0, 11.2.0, 11.3.0, 11.4.0, 11.5.0, 12.0.0, 12.1.0, 12.2.0, 13.0.0, 13.1.0, 13.2.0, 13.3.0, 13.4.0, 14.0.0

For

an unknown second parameter will be replaced with the string

for the other predefined acronyms it will be ignored and a warning message emitted. Unrecognized arguments are displayed as given in the page footer. For instance, a typical footer might be:

giving

or for a locally produced set

which will produce

If the

macro is not present, the bottom left corner of the manual page will be ugly.

This macro is neither callable nor parsed.

If

has no arguments,

is used for the date string. If it has exactly three arguments, they are concatenated, separated with unbreakable space:

The month’s name shall not be abbreviated.

With any other number of arguments, the current date is used, ignoring the parameters.

As a special exception, the format

is also recognized. It is used in

manuals to automatically insert the current date when committing.

This macro is neither callable nor parsed.

The manual domain macro names are derived from the day to day informal language used to describe commands, subroutines and related files. Slightly different variations of this language are used to describe the three different aspects of writing a man page. First, there is the description of

macro command usage. Second is the description of a

command

macros, and third, the description of a command to a user in the verbal sense; that is, discussion of a command in the text of a man page.

In the first case,

macros are themselves a type of command; the general syntax for a troff command is:

is a macro command, and anything following it are arguments to be processed. In the second case, the description of a

command using the content macros is a bit more involved; a typical

command line might be displayed as:

Here,

is the command name and the bracketed string

is a

argument designated as optional by the option brackets. In

terms,

and

are called

in this example, the user has to replace the meta expressions given in angle brackets with real file names. Note that in this document meta arguments are used to describe

commands; in most man pages, meta variables are not specifically written with angle brackets. The macros which formatted the above example:

.Nm filter .Op Fl flag .Ao Ar infile Ac Ao Ar outfile Ac

In the third case, discussion of commands and command syntax includes both examples above, but may add more detail. The arguments

and

from the example above might be referred to as

or

Some command-line argument lists are quite long:

Here one might talk about the command

and qualify the argument,

as an argument to the flag,

or discuss the optional file operand

In the verbal context, such detail can prevent confusion, however the

package does not have a macro for an argument

a flag. Instead the

argument macro is used for an operand or file argument like

as well as an argument to a flag like

The make command line was produced from:

.Nm make .Op Fl eiknqrstv .Op Fl D Ar variable .Op Fl d Ar flags .Op Fl f Ar makefile .Op Fl I Ar directory .Op Fl j Ar max_jobs .Op Ar variable Ns = Ns Ar value .Bk .Op Ar target … .Ek

The

and

macros are explained in

The manual domain and general text domain macros share a similar syntax with a few minor deviations; most notably,

and

differ only when called without arguments; and

and

impose an order on their argument lists. All content macros are capable of recognizing and properly handling punctuation, provided each punctuation character is separated by a leading space. If a command is given:

The result is:

The punctuation is not recognized and all is output in the font used by

If the punctuation is separated by a leading white space:

The result is:

The punctuation is now recognized and output in the default font distinguishing it from the argument strings. To remove the special meaning from a punctuation character escape it with

The following punctuation characters are recognized by

is limited as a macro language, and has difficulty when presented with a string containing a member of the mathematical, logical or quotation set:

{+,-,/,*,%,<,>,<=,>=,=,==,&,`,’,“}

The problem is that

may assume it is supposed to actually perform the operation or evaluation suggested by the characters. To prevent the accidental evaluation of these characters, escape them with

Typical syntax is shown in the first content macro displayed below,

The address macro identifies an address construct.

The default width is 12n.

The

macro is used to specify the name of the author of the item being documented, or the name of the author of the actual manual page.

The default width is 12n.

In the

section, the

command causes a line break allowing each new name to appear on its own line. If this is not desirable,

.An -nosplit

call will turn this off. To turn splitting back on, write

.An -split

The

argument macro may be used whenever an argument is referenced. If called without arguments, the

string is output.

The default width is 12n.

The

macro is used to demonstrate a

declaration for a device interface in a section four manual.

In the

section a

command causes a line break before and after its arguments are printed.

The default width is 12n.

The command modifier is identical to the

(flag) command with the exception that the

macro does not assert a dash in front of every argument. Traditionally flags are marked by the preceding dash, however, some commands or subsets of commands do not use them. Command modifiers may also be specified in conjunction with interactive commands such as editor commands. See

The default width is 10n.

A variable (or constant) which is defined in an include file is specified by the macro

The default width is 12n.

The

errno macro specifies the error return value for section 2, 3, and 9 library routines. The second example below shows

used with the

general text domain macro, as it would be used in a section two manual page.

The default width is 17n.

The

macro specifies an environment variable.

The default width is 15n.

The

macro handles command-line flags. It prepends a dash,

to the flag. For interactive command flags, which are not prepended with a dash, the

(command modifier) macro is identical, but without the dash.

The

macro without any arguments results in a dash representing stdin/stdout. Note that giving

a single dash will result in two dashes.

The default width is 12n.

The

macro is used in the

section with section two or three functions. It is neither callable nor parsed.

In the

section a

command causes a line break if a function has already been presented and a break has not occurred. This leaves a nice vertical space in between the previous function call and the declaration for the next function.

The

macro, while in the

section, represents the

statement, and is the short form of the above example. It specifies the C header file as being included in a C program. It also causes a line break.

While not in the

section, it represents the header file enclosed in angle brackets.

This macro is intended for the

section. It may be used anywhere else in the man page without problems, but its main purpose is to present the function type in kernel normal form for the

of sections two and three (it causes a line break, allowing the function name to appear on the next line).

The

macro is modeled on

conventions.

Note that any call to another macro signals the end of the

call (it will insert a closing parenthesis at that point).

For functions with many parameters (which is rare), the macros

(function open) and

(function close) may be used with

(function argument).

Example:

.Ft int .Fo res_mkquery .Fa “int op” .Fa “char *dname” .Fa “int class” .Fa “int type” .Fa “char *data” .Fa “int datalen” .Fa “struct rrec *newrr” .Fa “char *buf” .Fa “int buflen” .Fc

Produces:

In the

section, the function will always begin at the beginning of line. If there is more than one function presented in the

section and a function type has not been given, a line break will occur, leaving a nice vertical space between the current function name and the one prior.

The default width values of

and

are 12n and 16n, respectively.

The

macro is used to refer to function arguments (parameters) outside of the

section of the manual or inside the

section if the enclosure macros

and

instead of

are used.

may also be used to refer to structure members.

The default width is 12n.

The

macro generates text for use in the

section.

For example,

produces:

.ds doc-section-old “

The

option is valid only for manual page sections 2 and 3. Currently, this macro does nothing if used without the

flag.

The

macro generates text for use in the

section.

For example,

produces:

.ds doc-section-old “”

The

option is valid only for manual page sections 1, 6 and 8. Currently, this macro does nothing if used without the

flag.

The

macro designates an interactive or internal command.

The default width is 12n.

The

macro is used to specify the library where a particular function is compiled in.

Available arguments to

and their results are:

Local, OS-specific additions might be found in the file

look for strings named

then denotes the keyword to be used with the

macro.

In the

section an

command causes a line break before and after its arguments are printed.

The

literal macro may be used for special characters, variable constants, etc. - anything which should be displayed as it would be typed.

The default width is 16n.

The

macro is used for the document title or subject name. It has the peculiarity of remembering the first argument it was called with, which should always be the subject name of the page. When called without arguments,

regurgitates this initial name for the sole purpose of making less work for the author.

causes a line break within the

section.

Note: A section two or three document function name is addressed with the

in the

section, and with

in the

and remaining sections. For interactive commands, such as the

command keyword in

the

macro should be used. While

is nearly identical to

it can not recall the first argument it was invoked with.

The default width is 10n.

The

macro places option brackets around any remaining arguments on the command line, and places any trailing punctuation outside the brackets. The macros

and

(which produce an opening and a closing option bracket respectively) may be used across one or more lines or to specify the exact position of the closing parenthesis.

Here a typical example of the

and

macros:

.Oo .Op Fl k Ar kilobytes .Op Fl i Ar interval .Op Fl c Ar count .Oc

Produces:

The default width values of

and

are 14n and 10n, respectively.

The

macro formats path or file names. If called without arguments, the

string is output, which represents the current user’s home directory.

The default width is 32n.

The

macro replaces standard abbreviations with their formal names.

Available pairs for

are:

Part 1: System API

Part 2: Shell and Utilities

X/Open

Miscellaneous

The

macro may be used whenever a type is referenced. In the

section, it causes a line break (useful for old style variable declarations).

Generic variable reference.

The default width is 12n.

The

macro expects the first argument to be a manual page name. The optional second argument, if a string (defining the manual section), is put into parentheses.

The default width is 10n.

The following values for

are possible:

will be prepended to the string

The following values for

are possible:

For possible values of

see the description of the

command above in section

For possible values of

see the description of the

command above in section

For possible values of

see the description of the

command above in section

Text may be stressed or emphasized with the

macro. The usual font for emphasis is italic.

The default width is 10n.

The

font mode must be ended with the

macro (the latter takes no arguments). Font modes may be nested within other font modes.

has the following syntax:

must be one of the following three types:

Same as if the

macro was used for the entire block of text.

Same as if the

macro was used for the entire block of text.

Same as if the

macro was used for the entire block of text.

Both macros are neither callable nor parsed.

The concept of enclosure is similar to quoting. The object being to enclose one or more strings between a pair of characters like quotes or parentheses. The terms quoting and enclosure are used interchangeably throughout this document. Most of the one-line enclosure macros end in small letter

to give a hint of quoting, but there are a few irregularities. For each enclosure macro there is also a pair of open and close macros which end in small letters

and

respectively.

.if t . ne 10

Quote Open Close Function Result
.Aq .Ao .Ac Angle Bracket Enclosure <string>
.Bq .Bo .Bc Bracket Enclosure [string]
.Brq .Bro .Brc Brace Enclosure {string}
.Dq .Do .Dc Double Quote “string”
.Eq .Eo .Ec Enclose String (in XX) XXstring
.Pq .Po .Pc Parenthesis Enclosure (string)
.Ql     Quoted Literal string or string
.Qq .Qo .Qc Straight Double Quote “string”
.Sq .So .Sc Single Quote ’string’

All macros ending with

and

have a default width value of 12n.

These macros expect the first argument to be the opening and closing strings respectively.

Due to the nine-argument limit in the original troff program two other macros have been implemented which are now rather obsolete:

takes the first and second parameter as the left and right enclosure string, which are then used to enclose the arguments of

The default width value is 12n for both macros.

The first and second arguments of this macro are the opening and closing strings respectively, followed by the arguments to be enclosed.

The quoted literal macro behaves differently in troff and nroff mode. If formatted with

a quoted literal is always quoted. If formatted with troff, an item is only quoted if the width of the item is less than three constant width characters. This is to make short strings more visible where the font change to literal (constant width) is less noticeable.

The default width is 16n.

The prefix macro suppresses the whitespace between its first and second argument:

The default width is 12n.

The

macro (see below) performs the analogous suffix function.

The

macro inserts an apostrophe and exits any special text modes, continuing in

mode.

Examples of quoting:

For a good example of nested enclosure macros, see the

option macro. It was created from the same underlying enclosure macros as those presented in the list above. The

and

extended argument list macros are discussed below.

The

macro can be used in a macro command line for parameters which should

be formatted. Be careful to add

to the word

if you really want that English word (and not the macro) as a parameter.

The default width is 12n.

The

macro suppresses insertion of a space between the current position and its first parameter. For example, it is useful for old style argument lists where there is no space between the flag and argument:

Note: The

macro always invokes the

macro after eliminating the space unless another macro name follows it. If used as a command (i.e., the second form above in the

line),

is identical to

The

macro designates a reference to a section header within the same document.

The default width is 16n.

The symbolic emphasis macro is generally a boldface macro in either the symbolic sense or the traditional English usage.

The default width is 6n.

Use this macro for mathematical symbols and similar things.

The default width is 6n.

The following macros make a modest attempt to handle references. At best, the macros make it convenient to manually drop in a subset of

style references.

Reference start (does not take arguments). Causes a line break in the

section and begins collection of reference information until the reference end macro is read.

Reference end (does not take arguments). The reference is printed.

Reference author name; one name per invocation.

Book title.

City/place.

Date.

Issuer/publisher name.

Journal name.

Issue number.

Optional information.

Page number.

Corporate or foreign author.

Report name.

Title of article.

Optional hypertext reference.

Volume.

Macros beginning with

are not callable but accept multiple arguments in the usual way. Only the

macro is handled properly as a parameter; other macros will cause strange output.

and

can be used outside of the

environment.

Example:

.Rs .%A “Matthew Bar” .%A “John Foo” .%T “Implementation Notes on foobar(1)” .%R “Technical Report ABC-DE-12-345” .%Q “Drofnats College” .%C “Nowhere” .%D “April 1991” .Re

produces

The trade name macro prints its arguments in a smaller font. Its intended use is to imitate a small caps fonts for uppercase acronyms.

The default width is 10n.

The

and

macros allow one to extend an argument list on a macro boundary for the

macro (see below). Note that

and

are implemented similarly to all other macros opening and closing an enclosure (without inserting characters, of course). This means that the following is true for those macros also.

Here is an example of

using the space mode macro to turn spacing off:

.Sm off .It Xo Sy I Ar operation .No \en Ar count No \en .Xc .Sm on

produces

Another one:

.Sm off .It Cm S No / Ar old_pattern Xo .No / Ar new_pattern .No / Op Cm g .Xc .Sm on

produces

Another example of

and enclosure macros: Test the value of a variable.

.It Xo .Ic .ifndef .Oo \&! Oc Ns Ar variable Oo .Ar operator variable … .Oc Xc

produces

The following

section header macros are required in every man page. The remaining section headers are recommended at the discretion of the author writing the manual page. The

macro is parsed but not generally callable. It can be used as an argument in a call to

only; it then reactivates the default font for

The default width is 8n.

The

macro is mandatory. If not specified, headers, footers and page layout defaults will not be set and things will be rather unpleasant. The

section consists of at least three items. The first is the

name macro naming the subject of the man page. The second is the name description macro,

which separates the subject name from the third item, which is the description. The description should be the most terse and lucid possible, as the space available is small.

first prints

then all its arguments.

This section is for section two and three function calls. It should consist of a single

macro call; see

The

section describes the typical usage of the subject of a man page. The macros required are either

or

(and possibly

and

The function name macro

is required for manual page sections 2 and 3; the command and general name macro

is required for sections 1, 5, 6, 7, and 8. Section 4 manuals require a

or a

configuration device usage macro. Several other macros may be necessary to produce the synopsis line as shown below:

The following macros were used:

In most cases the first text in the

section is a brief paragraph on the command, function or file, followed by a lexical list of options and respective explanations. To create such a list, the

(begin list),

(list item) and

(end list) macros are used (see

below).

Implementation specific information should be placed here.

Sections 2, 3 and 9 function return values should go here. The

macro may be used to generate text for use in the

section for most section 2 and 3 library functions; see

The following

section headers are part of the preferred manual page layout and must be used appropriately to maintain consistency. They are listed in the order in which they would be used.

The

section should reveal any related environment variables and clues to their behavior and/or usage.

Files which are used or created by the man page subject should be listed via the

macro in the

section.

There are several ways to create examples. See the

section below for details.

Diagnostic messages from a command should be placed in this section. The

macro may be used to generate text for use in the

section for most section 1, 6 and 8 commands; see

Known compatibility issues (e.g. deprecated options or parameters) should be listed here.

Specific error handling, especially from library functions (man page sections 2, 3, and 9) should go here. The

macro is used to specify an error (errno).

References to other material on the man page topic and cross references to other relevant man pages should be placed in the

section. Cross references are specified using the

macro. Currently

style references are not accommodated.

It is recommended that the cross references are sorted on the section number, then alphabetically on the names within a section, and placed in that order and comma separated. Example:

If the command, library function or file adheres to a specific implementation such as

or

this should be noted here. If the command does not adhere to any standard, its history should be noted in the

section.

Any command which does not adhere to any specific standards should be outlined historically in this section.

Credits should be placed here. Use the

macro for names and the

macro for e-mail addresses within optional contact information. Explicitly indicate whether the person authored the initial manual page or the software or whatever the person is being credited for.

Blatant problems with the topic go here.

User-specified

sections may be added; for example, this section was set with:

.Sh “PAGE STRUCTURE DOMAIN”

Subsection headers have exactly the same syntax as section headers:

is parsed but not generally callable. It can be used as an argument in a call to

only; it then reactivates the default font for

The default width is 8n.

The

paragraph command may be used to specify a line space where necessary. The macro is not necessary after a

or

macro or before a

or

macro (which both assert a vertical distance unless the

flag is given).

The macro is neither callable nor parsed and takes no arguments; an alternative name is

The only keep that is implemented at this time is for words. The macros are

(begin keep) and

(end keep). The only option that

accepts currently is

(this is also the default if no option is given) which is useful for preventing line breaks in the middle of options. In the example for the make command-line arguments (see

the keep prevented

from placing up the flag and the argument on separate lines.

Both macros are neither callable nor parsed.

More work needs to be done with the keep macros; specifically, a

option should be added.

There are seven types of displays.

(This is D-one.) Display one line of indented text. This macro is parsed but not callable.

The above was produced by:

(This is D-ell.) Display one line of indented

text. The

example macro has been used throughout this file. It allows the indentation (display) of one line of text. Its default font is set to constant width (literal).

is parsed but not callable.

The above was produced by:

Begin display. The

display must be ended with the

macro. It has the following syntax:

Fill, but do not adjust the right margin (only left-justify).

Center lines between the current left and right margin. Note that each single line is centered.

Do not fill; display a block of text as typed, using line breaks as specified by the user. This can produce overlong lines without warning messages.

Display a filled block. The block of text is formatted (i.e., the text is justified on both the left and right side).

Display block with literal font (usually fixed-width). Useful for source code or simple tabbed or spaced text.

The file whose name follows the

flag is read and displayed before any data enclosed with

and

using the selected display type. Any

commands in the file will be processed.

If

is specified with one of the following strings, the string is interpreted to indicate the level of indentation for the forthcoming block of text:

Align block on the current left margin; this is the default mode of

Supposedly center the block. At this time unfortunately, the block merely gets left aligned about an imaginary center margin.

Indent by one default indent value or tab. The default indent value is also used for the

and

macros, so one is guaranteed the two types of displays will line up. The indentation value is normally set to 6n or about two thirds of an inch (six constant width characters).

Indent two times the default indent value.

This

aligns the block about two inches from the right side of the page. This macro needs work and perhaps may never do the right thing within

If

is a valid numeric expression instead

use that value for indentation. The most useful scale indicators are

and

specifying the so-called

and

This is approximately the width of the letters

and

respectively of the current font (for nroff output, both scale indicators give the same values). If

isn’t a numeric expression, it is tested whether it is an

macro name, and the default offset value associated with this macro is used. Finally, if all tests fail, the width of

(typeset with a fixed-width font) is taken as the offset.

Suppress insertion of vertical space before begin of display.

End display (takes no arguments).

There are several types of lists which may be initiated with the

begin-list macro. Items within the list are specified with the

item macro, and each list must end with the

macro. Lists may be nested within themselves and within displays. The use of columns inside of lists or lists inside of columns is unproven.

In addition, several list attributes may be specified such as the width of a tag, the list offset, and compactness (blank lines between items allowed or disallowed). Most of this document has been formatted with a tag style list

It has the following syntax forms:

And now a detailed description of the list types.

A bullet list.

.Bl -bullet -offset indent -compact .It Bullet one goes here. .It Bullet two here. .El

Produces:

Bullet one goes here.

Bullet two here.

A dash list.

.Bl -dash -offset indent -compact .It Dash one goes here. .It Dash two here. .El

Produces:

Dash one goes here.

Dash two here.

An enumerated list.

.Bl -enum -offset indent -compact .It Item one goes here. .It And item two here. .El

The result:

Item one goes here.

And item two here.

If you want to nest enumerated lists, use the

flag (starting with the second-level list):

.Bl -enum -offset indent -compact .It Item one goes here .Bl -enum -nested -compact .It Item two goes here. .It And item three here. .El .It And item four here. .El

Result:

Item one goes here.

Item two goes here.

And item three here.

And item four here.

A list of type

without list markers.

.Bl -item -offset indent .It Item one goes here. Item one goes here. Item one goes here. .It Item two here. Item two here. Item two here. .El

Produces:

Item one goes here. Item one goes here. Item one goes here.

Item two here. Item two here. Item two here.

A list with tags. Use

to specify the tag width.

sleep time of the process (seconds blocked)

number of disk

resulting from references by the process to pages not loaded in core.

numerical user-id of process owner

numerical id of parent of process priority (non-positive when in non-interruptible wait)

The raw text:

.Bl -tag -width “PPID” -compact -offset indent .It SL sleep time of the process (seconds blocked) .It PAGEIN number of disk .Tn I/O Ns ’s resulting from references by the process to pages not loaded in core. .It UID numerical user-id of process owner .It PPID numerical id of parent of process priority (non-positive when in non-interruptible wait) .El

Diag lists create section four diagnostic lists and are similar to inset lists except callable macros are ignored. The

flag is not meaningful in this context.

Example:

.Bl -diag .It You can’t use Sy here. The message says all. .El

produces

The message says all.

A list with hanging tags.

labels appear similar to tagged lists when the label is smaller than the label width.

blend into the paragraph unlike tagged paragraph labels.

And the unformatted text which created it:

.Bl -hang -offset indent .It Em Hanged labels appear similar to tagged lists when the label is smaller than the label width. .It Em Longer hanged list labels blend into the paragraph unlike tagged paragraph labels. .El

Lists with overhanging tags do not use indentation for the items; tags are written to a separate line.

sleep time of the process (seconds blocked)

number of disk

resulting from references by the process to pages not loaded in core.

numerical user-id of process owner

numerical id of parent of process priority (non-positive when in non-interruptible wait)

The raw text:

.Bl -ohang -offset indent .It Sy SL sleep time of the process (seconds blocked) .It Sy PAGEIN number of disk .Tn I/O Ns ’s resulting from references by the process to pages not loaded in core. .It Sy UID numerical user-id of process owner .It Sy PPID numerical id of parent of process priority (non-positive when in non-interruptible wait) .El

Here is an example of inset labels:

The tagged list (also called a tagged paragraph) is the most common type of list used in the Berkeley manuals. Use a

attribute as described below.

Diag lists create section four diagnostic lists and are similar to inset lists except callable macros are ignored.

Hanged labels are a matter of taste.

Overhanging labels are nice when space is constrained.

Inset labels are useful for controlling blocks of paragraphs and are valuable for converting

manuals to other formats.

Here is the source text which produced the above example:

.Bl -inset -offset indent .It Em Tag The tagged list (also called a tagged paragraph) is the most common type of list used in the Berkeley manuals. .It Em Diag Diag lists create section four diagnostic lists and are similar to inset lists except callable macros are ignored. .It Em Hang Hanged labels are a matter of taste. .It Em Ohang Overhanging labels are nice when space is constrained. .It Em Inset Inset labels are useful for controlling blocks of paragraphs and are valuable for converting .Nm -mdoc manuals to other formats. .El

This list type generates multiple columns. The number of columns and the width of each column is determined by the arguments to the

list,

etc. If

starts with a

(dot) immediately followed by a valid

macro name, interpret

and use the width of the result. Otherwise, the width of

(typeset with a fixed-width font) is taken as the

column width.

Each

argument is parsed to make a row, each column within the row is a separate argument separated by a tab or the

macro.

The table:

was produced by:

.Bl -column -offset indent “.Sy String” “.Sy Nroff” “.Sy Troff” .It Sy String Ta Sy Nroff Ta Sy Troff .It Li <= Ta <= Ta \*(<= .It Li >= Ta >= Ta \*(>= .El

Don’t abuse this list type! For more complicated cases it might be far better and easier to use

the table preprocessor.

Other keywords:

If

starts with a

(dot) immediately followed by a valid

macro name, interpret

and use the width of the result. Almost all lists in this document use this option.

Example:

.Bl -tag -width “.Fl test Ao Ar string Ac” .It Fl test Ao Ar string Ac This is a longer sentence to show how the .Fl width flag works in combination with a tag list. .El

gives:

This is a longer sentence to show how the

flag works in combination with a tag list.

(Note that the current state of

is saved before

is interpreted; afterwards, all variables are restored again. However, boxes (used for enclosures) can’t be saved in

as a consequence, arguments must always be

to avoid nasty errors. For example, do not write

but

instead if you really need only an opening angle bracket.)

Otherwise, if

is a valid numeric expression

use that value for indentation. The most useful scale indicators are

and

specifying the so-called

and

This is approximately the width of the letters

and

respectively of the current font (for nroff output, both scale indicators give the same values). If

isn’t a numeric expression, it is tested whether it is an

macro name, and the default width value associated with this macro is used. Finally, if all tests fail, the width of

(typeset with a fixed-width font) is taken as the width.

If a width is not specified for the tag list type,

is used.

If

is

a default indent value (normally set to 6n, similar to the value used in

or

is used. If

is a valid numeric expression instead

use that value for indentation. The most useful scale indicators are

and

specifying the so-called

and

This is approximately the width of the letters

and

respectively of the current font (for nroff output, both scale indicators give the same values). If

isn’t a numeric expression, it is tested whether it is an

macro name, and the default offset value associated with this macro is used. Finally, if all tests fail, the width of

(typeset with a fixed-width font) is taken as the offset.

Suppress insertion of vertical space before the list and between list items.

Here a list of the remaining macros which do not fit well into one of the above sections. We couldn’t find real examples for the following macros:

and

They are documented here for completeness - if you know how to use them properly please send a mail to

(including an example).

prints

It is neither callable nor parsed and takes no arguments.

Don’t use this macro. It allows a break right before the return value (usually a single digit) which is bad typographical behaviour. Use

to tie the return value to the previous word.

Use this macro to include a (header) file literally. It first prints

followed by the file name, then the contents of

It is neither callable nor parsed.

To be written.

Exact usage unknown. The documentation in the

source file describes it as a macro for

Its default width is 6n.

To be written.

Exact usage unknown. The documentation in the

source file describes it as

Activate (toggle) space mode.

If space mode is off, no spaces between macro arguments are inserted. If called without a parameter (or if the next parameter is neither

nor

toggles space mode.

prints

It is neither callable nor parsed and takes no arguments.

The following strings are predefined:

String Nroff Troff Meaning
<= <=   less equal
>= >=   greater equal
Rq ’’   right double quote
Lq ``   left double quote
ua ^   upwards arrow
aa   acute accent
ga `   grave accent
q   straight double quote
Pi pi   greek pi
Ne !=   not equal
Le <=   less equal
Ge >=   greater equal
Lt <   less than
Gt >   greater than
Pm +-   plus minus
If infinity   infinity
Am     ampersand
Na     not a number
Ba     vertical bar

The names of the columns

and

are a bit misleading;

shows the

representation, while

gives the best glyph form available. For example, a Unicode enabled

device will have proper glyph representations for all strings, whereas the enhancement for a Latin1

device is only the plus-minus sign.

String names which consist of two characters can be written as

string names which consist of one character can be written as

A generic syntax for a string name of any length is

(this is a

extension). .Sh DIAGNOSTICS The debugging macro

available in previous versions of

has been removed since

provides better facilities to check parameters; additionally, many error and warning messages have been added to this macro package, making it both more robust and verbose.

The only remaining debugging macro is

which yields a register dump of all global registers and strings. A normal user will never need it.

By default, the package inhibits page breaks, headers, and footers if displayed with a

device like

or

to make the manual more efficient for viewing on-line. This behaviour can be changed (e.g. to create a hardcopy of the

output) by setting the register

to zero while calling

resulting in multiple pages instead of a single, very long page:

For double-sided printing, set register

to 1:

To change the document font size to 11pt or 12pt, set register

accordingly:

Register

is ignored for

devices.

The line and title length can be changed by setting the registers

and

respectively:

If not set, both registers default to 78n for TTY devices and 6.5i otherwise.

The main manual macro package.

A wrapper file to call

Common strings, definitions, stuff related typographic output.

Definitions used for a

output device.

Definitions used for all other devices.

Local additions and customizations.

Use this file if you don’t know whether the

or the

package should be used. Multiple man pages (in either format) can be handled.

Section 3f has not been added to the header routines.

font should be changed in

section.

needs to have a check to prevent splitting up if the line length is too short. Occasionally it separates the last parenthesis, and sometimes looks ridiculous if a line is in fill mode.

The list and display macros do not do any keeps and certainly should be able to.

Author: dt

Created: 2022-02-20 Sun 09:40