Throughout the UNIX manual pages, a manual entry is simply referred to as a man page, regardless of actual length and without sexist intention.
In general, GNU troff(1) 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 Extended Arguments below). Almost all macros handle quoted arguments (see Passing Space Characters in an Argument below).
Most of the -mdoc general text domain and manual domain macros are special in that their argument lists are parsed 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, `.Op', may call the flag and argument macros, `Fl' and `Ar', to specify an optional flag with an argument:
To prevent a string from being interpreted as a macro name, precede the string with the escape sequence `\&':
Here the strings `Fl' and `Ar' are not interpreted as macros. Macros whose argument lists are parsed for callable arguments are referred to as parsed and macros which may be called from an argument list are referred to as callable throughout this document. This is a technical faux pas as almost all of the macros in -mdoc 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 -mdoc macro which starts a line (with a leading dot) a command if this distinction is necessary.
int
foo
.
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.
Troff
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
GNU
troff(1)
extension).
The second method is to enclose the string with double quotes.
For example:
char *str
)
char *str
)If the `\' before the space in the first example or double quotes in the second example were omitted, `.Fn' would see three arguments, and the result would be:
fetch(
char
, *str
)
Troff
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
blank-space<.blm Ppend-of-line<.blm Pp > >
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,
`string\ \&'.
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 not replaced with a single space.
You can't pass `"' directly as an argument. Use `\*[q]' (or `\*q') instead.
By default, troff(1) 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 `'. characterThe `.' character.
test. test
test. test
As can be seen in the first and third line, -mdoc handles punctuation characters specially in macro arguments. This will be explained in section General Syntax below. In the same way, you have to protect trailing full stops of abbreviations with a trailing zero-width space: `e.g.\&'.
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 GNU troff(1) extension); the rest of such a line is ignored.
.\" The following commands are required for all man pages.
.Dd Month day, year
.Os [OPERATING_SYSTEM] [version/release]
.Dt DOCUMENT_TITLE [section number] [architecture/volume]
.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 function
.\" return values only.
.\" .Sh RETURN VALUES
.\" This next command is for sections 1, 6, 7 and 8 only.
.\" .Sh ENVIRONMENT
.\" .Sh FILES
.\" .Sh EXAMPLES
.\" This next command is for sections 1, 6, 7, 8 and 9 only
.\" (command return values (to shell) and
.\" fprintf/stderr type diagnostics).
.\" .Sh DIAGNOSTICS
.\" .Sh COMPATIBILITY
.\" This next command is for sections 2, 3 and 9 error
.\" and signal handling only.
.\" .Sh ERRORS
.\" .Sh SEE ALSO
.\" .Sh STANDARDS
.\" .Sh HISTORY
.\" .Sh AUTHORS
.\" .Sh BUGS
The first items in the template are the commands `.Dd', `.Os', and `.Dt'; the document date, the operating system the man page or subject source is developed or modified for, and the man page title (in upper case) along with the section of the manual the page belongs in. These commands identify the page and are discussed below in TITLE MACROS.
The remaining items in the template are section headers
(.Sh
);
of which
NAME,
SYNOPSIS,
and
DESCRIPTION
are mandatory.
The headers are discussed in
PAGE STRUCTURE DOMAIN,
after presentation of
MANUAL DOMAIN.
Several content macros are used to demonstrate page layout macros; reading
about content macros before page layout macros is recommended.
Example:
.Xx
Xo
Except stated explicitly, all macros are parsed and callable.
Note that a macro takes effect up to the next nested macro.
For example,
`.Ic foo Aq bar'
doesn't produce
`foo
Most macros have a default width value which can be used to specify a label
width
(-width)
or offset
(-offset)
for the
`.Bl'
and
`.Bd'
macros.
It is recommended not to use this rather obscure feature to avoid
dependencies on local modifications of the
-mdoc
package.
Under
,
the following sections are defined:
A volume name may be arbitrary or one of the following:
For compatibility,
`MMI'
can be used for
`IND',
and
`LOC'
for
`LOCAL'.
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:
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
This macro is neither callable nor parsed.
For
ATT,
an unknown second parameter will be replaced with the string
UNIX;
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
`4.3 Berkeley Distribution',
or for a locally produced set
which will produce
`CS Department'.
If the
`.Os'
macro is not present, the bottom left corner of the manual page will be
ugly.
This macro is neither callable nor parsed.
<month>
<day>,
<year>
[
The month's name shall not be abbreviated.
With any other number of arguments, the current date is used, ignoring
the parameters.
This macro is neither callable nor parsed.
In the first case,
troff(1)
macros are themselves a type of command; the general syntax for a troff
command is:
`.Xx'
is a macro command, and anything following it are arguments to
be processed.
In the second case, the description of a
UNIX
command using the content macros is a bit more involved; a typical
SYNOPSIS
command line might be displayed as:
Here,
filter
is the command name and the
bracketed string
-flag
is a
flag
argument designated as optional by the option brackets.
In
-mdoc
terms,
infile<.blm Pp >
and
outfile<.blm Pp >
are called
meta arguments;
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
-mdoc
commands; in most man pages, meta variables are not specifically written
with angle brackets.
The macros which formatted the above example:
In the third case, discussion of commands and command syntax includes both
examples above, but may add more detail.
The arguments
infile<.blm Pp >
and
outfile<.blm Pp >
from the example above might be referred to as
operands
or
file arguments.
Some command line argument lists are quite long:
Here one might talk about the command
make
and qualify the argument,
makefile,
as an argument to the flag,
-f,
or discuss the optional file operand
target.
In the verbal context, such detail can prevent confusion, however the
-mdoc
package does not have a macro for an argument
to
a flag.
Instead the
`Ar'
argument macro is used for an operand or file argument like
target
as well as an argument to a flag like
variable.
The make command line was produced from:
The
`.Bk'
and
`.Ek'
macros are explained in
Keeps.
The result is:
The punctuation is not recognized and all is output in the
font used by
`.Ar'.
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
-mdoc:
The problem is that
The default width is 12n.
The default width is 12n.
In the
AUTHORS
section, the
`.An'
command causes a line break allowing each new name to appear on its own
line.
If this is not desirable,
call will turn this off.
To turn splitting back on, write
The default width is 12n.
In the
SYNOPSIS
section a
`.Cd'
command causes a line break before and after its arguments are printed.
The default width is 12n.
The default width is 10n.
The default width is 12n.
The default width is 17n.
The default width is 15n.
The
`.Fl'
macro without any arguments results in a dash representing stdin/stdout.
Note that giving
`.Fl'
a single dash will result in two dashes.
The default width is 12n.
In the
SYNOPSIS
section a
`.Fd'
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
`.In'
macro, while in the
SYNOPSIS
section, represents the
While not in the
SYNOPSIS
section, it represents the header file enclosed in angle brackets.
Note that any call to another macro signals the end of the
`.Fn'
call (it will insert a closing parenthesis at that point).
For functions with many parameters (which is rare), the macros
`.Fo'
(function open)
and
`.Fc'
(function close)
may be used with
`.Fa'
(function argument).
Example:
Produces:
In the
SYNOPSIS
section, the function will always begin at the beginning of line.
If there is more than one function presented in the
SYNOPSIS
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
`.Fn'
and
`.Fo'
are 12n and 16n, respectively.
The default width is 12n.
For example,
`.Rv -std atexit'
produces:
The
-std
option is valid only for manual page sections 2 and 3.
Currently, this macro does nothing if used without the
-std
flag.
For example,
`.Ex -std cat'
produces:
The
-std
option is valid only for manual page sections 1, 6 and 8.
Currently, this macro does nothing if used without the
-std
flag.
The default width is 12n.
Available arguments to
`.Lb'
and their results are:
Local, OS-specific additions might be found in the file
In the
LIBRARY
section an
`.Lb'
command causes a line break before and after its arguments are printed.
The default width is 16n.
The default width is 10n.
Here a typical example of the
`.Oo'
and
`.Oc'
macros:
Produces:
The default width values of
`.Op'
and
`.Oo'
are 14n and 10n, respectively.
The default width is 32n.
Available pairs for
``Abbreviation/Formal Name''
are:
ANSI/ISO C
POSIX
Part 1: System API
POSIX
Part 2: Shell and Utilities
X/Open
Miscellaneous
The default width is 12n.
The default width is 10n.
The following values for
version<.blm Pp >
are possible:
version<.blm Pp >
will be prepended to the string
`BSD'.
The following values for
release<.blm Pp >
are possible:
For possible values of
version<.blm Pp >
see the description of the
`.Os'
command above in section
TITLE MACROS.
For possible values of
version<.blm Pp >
see the description of the
`.Os'
command above in section
TITLE MACROS.
The default width is 10n.
`.Bf'
has the following syntax:
font mode<.blm Pp >
must be one of the following three types:
Both macros are neither callable nor parsed.
All macros ending with
`q'
and
`o'
have a default width value of 12n.
The default width is 16n.
The default width is 12n.
The
`.Ns'
macro (see below) performs the analogous suffix function.
Examples of quoting:
For a good example of nested enclosure macros, see the
`.Op'
option macro.
It was created from the same underlying enclosure macros as those presented
in the list above.
The
`.Xo'
and
`.Xc'
extended argument list macros are discussed below.
The default width is 12n.
Note: The
`.Ns'
macro always invokes the
`.No'
macro after eliminating the space unless another macro name follows it.
If used as a command (i.e., the second form above in the
`Usage'
line),
`.Ns'
is identical to
`.No'.
The default width is 16n.
The default width is 6n.
The default width is 6n.
Macros beginning with
`%'
are not callable but accept multiple arguments in the usual way.
Only the
`.Tn'
macro is handled properly as a parameter; other macros will cause strange
output.
`.%B'
and
`.%T'
can be used outside of the
`.Rs/.Re'
environment.
Example:
produces
The default width is 10n.
Here is an example of
`.Xo'
using the space mode macro to turn spacing off:
produces
Another one:
produces
Another example of
`.Xo'
and enclosure macros: Test the value of a variable.
produces
The default width is 8n.
`.Nd'
first prints
`-',
then all its arguments.
The following macros were used:
The following
`.Sh'
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.
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:
User-specified
`.Sh'
sections may be added; for example, this section was set with:
The default width is 8n.
The macro is neither callable nor parsed and takes no arguments; an
alternative name is
`.Lp'.
Both macros are neither callable nor parsed.
More work needs to be done with the keep macros; specifically, a
-line
option should be added.
The above was produced by:
The above was produced by:
If
string<.blm Pp >
is a valid numeric expression instead
(with a scale indicator other than
`u'),
use that value for indentation.
The most useful scale indicators are
`m'
and
`n',
specifying the so-called
Em
and
En square.
This is approximately the width of the letters
`m'
and
`n'
respectively
of the current font (for nroff output, both scale indicators give the same
values).
If
string<.blm Pp >
isn't a numeric expression, it is tested whether it is an
-mdoc
macro name, and the default offset value associated with this macro is used.
Finally, if all tests fail,
the width of
string<.blm Pp >
(typeset with a fixed-width font) is taken as the offset.
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
(-tag).
It has the following syntax forms:
And now a detailed description of the list types.
Produces:
Produces:
The result:
If you want to nest enumerated lists, use the
-nested
flag (starting with the second-level list):
Result:
Produces:
The raw text:
Example:
produces
And the unformatted text which created it:
The raw text:
Here is the source text which produced the above example:
Each
`.It'
argument is parsed to make a row, each column within the row is a separate
argument separated by a tab or the
`.Ta'
macro.
The table:
was produced by:
Other keywords:
Example:
gives:
(Note that the current state of
-mdoc
is saved before
<string>
is interpreted; afterwards, all variables are restored again.
However, boxes (used for enclosures) can't be saved in
GNU
troff(1);
as a consequence, arguments must always be
balanced
to avoid nasty errors.
For example, do not write
`.Ao Ar string'
but
`.Ao Ar string Xc'
instead if you really need only an opening angle bracket.)
Otherwise, if
<string>
is a valid numeric expression
(with a scale indicator other than
`u'),
use that value for indentation.
The most useful scale indicators are
`m'
and
`n',
specifying the so-called
Em
and
En square.
This is approximately the width of the letters
`m'
and
`n'
respectively
of the current font (for nroff output, both scale indicators give the same
values).
If
<string>
isn't a numeric expression, it is tested whether it is an
-mdoc
macro name, and the default width value associated with this macro is used.
Finally, if all tests fail,
the width of
<string>
(typeset with a fixed-width font) is taken as the width.
If a width is not specified for the tag list type, every time
`.It'
is invoked, an attempt is made to determine an appropriate width.
If the first argument to
`.It'
is a callable macro, the default width for that macro will be used;
otherwise, the default width of
`.No'
is used.
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.
It is neither callable nor parsed.
Its default width is 6n.
If space mode is off, no spaces between macro arguments are inserted.
If called without a parameter (or if the next parameter is neither
`on'
nor
`off',
`.Sm'
toggles space mode.
It is neither callable nor parsed and takes no arguments.
The names of the columns
Nroff
and
Troff
are a bit misleading;
Nroff
shows the
ASCII
representation, while
Troff
gives the best glyph form available.
For example, a Unicode enabled
TTY-
device will have proper glyph representations for all strings, whereas the
enhancement for a Latin1
TTY-
device is only the plus-minus sign.
String names which consist of two characters can be written as
`\*(xx';
string names which consist of one character can be written as
`\*x'.
A generic syntax for a string name of any length is
`\*[xxx]'
(this is a
GNU
troff(1)
extension).
The only remaining debugging macro is
`.Rd'
which yields a register dump of all global registers and strings.
A normal user will never need it.
For double-sided printing, set register
`D'
to 1:
To change the document font size to 11pt or 12pt, set register
`S'
accordingly:
Register
`S'
is ignored for
TTY
devices.
The line and title length can be changed by setting the registers
`LL'
and
`LT',
respectively:
If not set, both registers default to 78n for TTY devices and 6.5i
otherwise.
`.Nm'
font should be changed in
NAME
section.
`.Fn'
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.
TITLE MACROS
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.
.Dt
Xo
1
2
3
4
5
6
7
8
9
USD
PS1
AMD
SMM
URM
PRM
KM
IND
LOCAL
CON
alpha, acorn26, acorn32, algor, amd64, amiga, arc, arm26,
arm32, atari, bebox, cats, cesfic, cobalt, dreamcast, evbarm,
evbmips, evbppc, evbsh3, hp300, hp700, hpcmips, i386, luna68k,
m68k, mac68k, macppc, mips, mmeye, mvme68k, mvmeppc, netwinder,
news68k, newsmips, next68k, ofppc, pc532, pmax, pmppc, powerpc,
prep, sandpoint, sgimips, sh3, shark, sparc, sparc64, sun3,
tahoe, vax, x68k, x86_64
.Dt FOO 7
.Dt FOO 7 bar
.Dt FOO \&7 bar
.Dt FOO 2 i386
.Dt FOO "" bar
mdoc.local
;
look for strings named
`volume-ds-XXX'
(for the former type) and
`volume-as-XXX'
(for the latter type);
`XXX'
then denotes the keyword to be used with the
`.Dt'
macro.
.Os
Xo
mdoc.local
.
In general, the name of the operating system should be the common acronym,
e.g.
BSD
or
ATT.
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
`.Dt',
local additions might be defined in
mdoc.local
;
look for strings named
`operating-system-XXX-YYY',
where
`XXX'
is the acronym for the operating system and
`YYY'
the release ID.
.Os
BSD
4.3
.Os
CS
Department
.Dd
.Dd
January
25,
2001
INTRODUCTION OF MANUAL AND GENERAL TEXT DOMAINS
What's in a Name Ns ...
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
-mdoc
macro command usage.
Second is the description of a
UNIX
command
with
-mdoc
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.
.Xx argument1 argument2
...
filter
[-flag]
infile<.blm Pp outfile<.blm Pp > >
.Nm filter
.Op Fl flag
.Ao Ar infile Ac Ao Ar outfile Ac
.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
General Syntax
The manual domain and general text domain macros share a similar syntax with
a few minor deviations; most notably,
`.Ar',
`.Fl',
`.Nm',
and
`.Pa'
differ only when called without arguments; and
`.Fn'
and
`.Xr'
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:
.Ar
sptr,
ptr),
sptr, ptr),
.Ar
sptr , ptr ) ,
sptr, ptr),
.
,
:
;
(
)
[
]
?
!
Troff
is limited as a macro language, and has difficulty when presented with a
string containing a member of the mathematical, logical or quotation set:
{+,-,/,*,%,<,>,<=,>=,=,==,&,`,',"}
troff
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,
`.Ad'.
MANUAL DOMAIN
Addresses
The address macro identifies an address construct.
Usage:
.Ad
address<.blm Pp
...
>
.Ad addr1
.Ad addr1 .
.Ad addr1 , file2
.Ad f1 , f2 , f3 :
.Ad addr ) ) ,
Author Name
The
`.An'
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.
Usage:
.An
author
name<.blm Pp
...
>
.An "Joe Author"
.An "Joe Author" ,
,
.An "Joe Author" Aq nobody@FreeBSD.org
.An "Joe Author" ) ) ,
)),
.An -nosplit
.An -split
Arguments
The
.Ar
argument macro may be used whenever an argument is referenced.
If called without arguments, the
`'
string is output.
Usage:
.Ar
argument[<.blm Pp
...
>
]
.Ar
.Ar file1
.Ar file1 .
.Ar file1 file2
.Ar f1 f2 f3 :
.Ar file ) ) ,
Configuration Declaration (Section Four Only)
The
`.Cd'
macro is used to demonstrate a
config(1)
declaration for a device interface in a section four manual.
Usage:
.Cd
argument<.blm Pp
...
>
.Cd "device le0 at scode?"
Command Modifiers
The command modifier is identical to the
`.Fl'
(flag) command with the exception that the
`.Cm'
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
Flags.
Defined Variables
A variable (or constant) which is defined in an include file
is specified by the macro
`.Dv'.
Usage:
.Dv
defined
variable<.blm Pp
...
>
.Dv MAXHOSTNAMELEN
MAXHOSTNAMELEN
.Dv TIOCGPGRP )
TIOCGPGRP
)
Errno's
The
`.Er'
errno macro specifies the error return value for section 2, 3, and 9 library
routines.
The second example below shows
`.Er'
used with the
`.Bq'
general text domain macro, as it would be used in a section two manual page.
Usage:
.Er
errno
type<.blm Pp
...
>
.Er ENOENT
ENOENT
.Er ENOENT ) ;
ENOENT
);
.Bq Er ENOTDIR
ENOTDIR
]
Environment Variables
The
`.Ev'
macro specifies an environment variable.
Usage:
.Ev
argument<.blm Pp
...
>
.Ev DISPLAY
DISPLAY
.Ev PATH .
PATH
.
.Ev PRINTER ) ) ,
PRINTER
)),
Flags
The
`.Fl'
macro handles command line flags.
It prepends a dash,
`-',
to the flag.
For interactive command flags, which are not prepended with a dash, the
`.Cm'
(command modifier)
macro is identical, but without the dash.
Usage:
.Fl
argument<.blm Pp
...
>
.Fl
.Fl cfv
.Fl cfv .
.Cm cfv .
.Fl s v t
.Fl - ,
.Fl xyz ) ,
.Fl |
Function Declarations
The
`.Fd'
macro is used in the
SYNOPSIS
section with section two or three functions.
It is neither callable nor parsed.
Usage:
.Fd
argument<.blm Pp
...
>
.Fd "#include
#include #include
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.
Usage:
.In
header
file<.blm Pp
>
.In stdio.h
.In stdio.h
Function Types
This macro is intended for the
SYNOPSIS
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
SYNOPSIS
of sections two and three (it causes a line break, allowing the function
name to appear on the next line).
Usage:
.Ft
type<.blm Pp
...
>
.Ft struct stat
struct
stat
Functions (Library Routines)
The
`.Fn'
macro is modeled on
ANSI C
conventions.
Usage:
.Fn
function<.blm Pp
parameter[<.blm Pp
...
>
>
]
.Fn getchar
)
.Fn strlen ) ,
)),
.Fn align "char *ptr" ,
char *ptr
),
.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
int
res_mkquery(
int op
char *dname
int class
int type
char *data
int datalen
struct rrec *newrr
char *buf
int buflen
)
Function Arguments
The
`.Fa'
macro is used to refer to function arguments (parameters) outside of the
SYNOPSIS
section of the manual or inside the
SYNOPSIS
section if the enclosure macros
`.Fo'
and
`.Fc'
instead of
`.Fn'
are used.
`.Fa'
may also be used to refer to structure members.
Usage:
.Fa
function
argument<.blm Pp
...
>
.Fa d_namlen ) ) ,
d_namlen
)),
.Fa iov_len
iov_len
Return Values
The
`.Rv'
macro generates text for use in the
RETURN VALUES
section.
Usage:
.Rv
-std[.blm Pp[
function<.blm Pp
...
] >]
Exit Status
The
`.Ex'
macro generates text for use in the
DIAGNOSTICS
section.
Usage:
.Ex
-std[.blm Pp[
utility<.blm Pp
...
] >]
Interactive Commands
The
`.Ic'
macro designates an interactive or internal command.
Usage:
.Ic
argument<.blm Pp
...
>
.Ic :wq
.Ic "do while {...}"
.Ic setenv , unsetenv
Library Names
The
`.Lb'
macro is used to specify the library where a particular function is compiled
in.
Usage:
.Lb
argument<.blm Pp
...
>
libarm
libarm32
libc
libcdk
libcompat
libcrypt
libcurses
libedit
libevent
libform
libi386
libintl
libipsec
libkvm
libm
libm68k
libmagic
libmenu
libossaudio
libpam
libpcap
libpci
libpmc
libposix
libpthread
libresolv
librt
libtermcap
libusbhid
libutil
libx86_64
libz
mdoc.local
;
look for strings named
`str-Lb-XXX'.
`XXX'
then denotes the keyword to be used with the
`.Lb'
macro.
Literals
The
`.Li'
literal macro may be used for special characters, variable constants, etc.
-- anything which should be displayed as it would be typed.
Usage:
.Li
argument<.blm Pp
...
>
.Li \en
\n
.Li M1 M2 M3 ;
M1
M2
M3
;
.Li cntrl-D ) ,
cntrl-D
),
.Li 1024 ...
1024
...
Names
The
`.Nm'
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,
`.Nm'
regurgitates this initial name for the sole purpose of making less work for
the author.
Note: A section two or three document function name is addressed with the
`.Nm'
in the
NAME
section, and with
`.Fn'
in the
SYNOPSIS
and remaining sections.
For interactive commands, such as the
`while'
command keyword in
csh(1),
the
`.Ic'
macro should be used.
While
`.Ic'
is nearly identical
to
`.Nm',
it can not recall the first argument it was invoked with.
Usage:
.Nm
argument[<.blm Pp
...
>
]
.Nm groff_mdoc
.Nm \-mdoc
.Nm foo ) ) ,
.Nm :
Options
The
`.Op'
macro places option brackets around any remaining arguments on the
command line, and places any trailing punctuation outside the brackets.
The macros
`.Oo'
and
`.Oc'
(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.
Usage:
.Op
option[<.blm Pp
...
>
]
.Op
.Op Fl k
.Op Fl k ) .
.Op Fl k Ar kookfile
.Op Fl k Ar kookfile ,
.Op Ar objfil Op Ar corfil
.Op Fl c Ar objfil Op Ar corfil ,
.Op word1 word2
.Li .Op Oo Ao option Ac Oc ...
.Op
option[<.blm Pp
...
>
]
.Oo
.Op Fl k Ar kilobytes
.Op Fl i Ar interval
.Op Fl c Ar count
.Oc
[-i interval]
[-c count]
[[-k kilobytes]]
Pathnames
The
`.Pa'
macro formats path or file names.
If called without arguments, the
`'
string is output, which represents the current user's home directory.
Usage:
.Pa
pathname[<.blm Pp
...
>
]
.Pa
.Pa /usr/share
/usr/share
.Pa /tmp/fooXXXXX ) .
/tmp/fooXXXXX
).
Standards
The
`.St'
macro replaces standard abbreviations with their formal names.
Usage:
.St
abbreviation<.blm Pp
...
>
-ansiC
-ansiC-89
-isoC
-isoC-90
-isoC-99
-iso9945-1-90
-iso9945-1-96
-p1003.1
-p1003.1-88
-p1003.1-90
-p1003.1-96
-p1003.1b-93
-p1003.1c-95
-p1003.1g-2000
-p1003.1i-95
-p1003.1-2001
-p1003.1-2004
-iso9945-2-93
-p1003.2
-p1003.2-92
-p1003.2a-92
-susv2
-svid4
-xbd5
-xcu5
-xcurses4.2
-xns5
-xns5.2
-xpg3
-xpg4
-xpg4.2
-xsh5
-ieee754
-iso8802-3
Variable Types
The
`.Vt'
macro may be used whenever a type is referenced.
In the
SYNOPSIS
section, it causes a line break (useful for old style variable declarations).
Usage:
.Vt
type<.blm Pp
...
>
.Vt extern char *optarg ;
.Vt FILE *
Variables
Generic variable reference.
Usage:
.Va
variable<.blm Pp
...
>
.Va count
.Va settimer ,
.Va "int *prt" ) :
.Va "char s" ] ) ) ,
Manual Page Cross References
The
`.Xr'
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.
Usage:
.Xr
man
page
name<.blm Pp
section[<.blm Pp
...
>
>
]
.Xr mdoc
mdoc
.Xr mdoc ,
mdoc
.Xr mdoc 7
.Xr xinit 1x ;
xinit
;
GENERAL TEXT DOMAIN
AT&T Macro
Usage:
.At
version[<.blm Pp
...
>
]
.At
AT&T UNIX
.At v6 .
AT&T UNIX
.
32v,
v1,
v2,
v3,
v4,
v5,
v6,
v7,
V,
V.1,
V.2,
V.3,
V.4
BSD Macro
Usage: .Bx
-alpha
|
-beta
|
-devel{.blm Pp
...
}
.Bx
version
release[<[<.blm Pp
...
>
>
]]
.Bx
.Bx 4.3 .
.Bx -devel
Reno,
reno,
Tahoe,
tahoe,
Lite,
lite,
Lite2,
lite2
NetBSD Macro
Usage:
.Nx
version[<.blm Pp
...
>
]
.Nx
.Nx 1.4 .
FreeBSD Macro
Usage:
.Fx
version[<.blm Pp
...
>
]
.Fx
.Fx 2.2 .
OpenBSD Macro
Usage:
.Ox
version[<.blm Pp
...
>
]
.Ox 1.0
BSD/OS Macro
Usage:
.Bsx
version[<.blm Pp
...
>
]
.Bsx 1.0
UNIX Macro
Usage:
.Ux
...
.Ux
Emphasis Macro
Text may be stressed or emphasized with the
`.Em'
macro.
The usual font for emphasis is italic.
Usage:
.Em
argument<.blm Pp
...
>
.Em does not
.Em exceed 1024 .
.Em vide infra ) ) ,
Font Mode
The
`.Bf'
font mode must be ended with the
`.Ef'
macro (the latter takes no arguments).
Font modes may be nested within other font modes.
.Bf
font
mode<.blm Pp
>
Enclosure and Quoting Macros
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
`q'
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
`o'
and
`c'
respectively.
Quote
Open Close Function Result
.Eo
, .Ec
.Es
, .En
.Eq
.Ql
nroff
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.
.Pf
.Pf ( Fa name2
name2
.Ap
.Aq
.Aq Pa ctype.h ) ,
ctype.h
>),
.Bq
.Bq Em Greek , French .
.Dq
.Dq string abc .
.Dq ´^[A-Z]´
.Ql man mdoc
.Qq
.Qq string ) ,
.Qq string Ns ),
.Sq
.Sq string
.Em or Ap ing
No-Op or Normal Text Macro
The
`.No'
macro can be used in a macro command line for parameters which should
not
be formatted.
Be careful to add
`\&'
to the word
`No'
if you really want that English word (and not the macro) as a parameter.
Usage:
.No
argument<.blm Pp
...
>
.No test Ta with Ta tabs
with tabs
No-Space Macro
The
`.Ns'
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:
Usage:
...
argument<.blm Pp
Ns
argument[<.blm Pp
...
>
>
]
.Ns
argument<.blm Pp
...
>
.Op Fl I Ns Ar directory
Section Cross References
The
`.Sx'
macro designates a reference to a section header within the same document.
Usage:
.Sx
section
reference<.blm Pp
...
>
.Sx FILES
Symbolics
The symbolic emphasis macro is generally a boldface macro in either the
symbolic sense or the traditional English usage.
Usage:
.Sy
symbol<.blm Pp
...
>
.Sy Important Notice
Mathematical Symbols
Use this macro for mathematical symbols and similar things.
Usage:
.Ms
math
symbol<.blm Pp
...
>
.Ms sigma
References and Citations
The following macros make a modest attempt to handle references.
At best, the macros make it convenient to manually drop in a subset of
refer(1)
style references.
.Rs
.Re
.%A
.%B
.%C
.%D
.%I
.%J
.%N
.%O
.%P
.%Q
.%R
.%T
.%V
.Rs
.%A "Matthew Bar"
.%A "John Foo"
.%T "Implementation Notes on foobar(1)"
.%R "Technical Report ABC-DE-12-345"
.%Q "Drofnats College, Nowhere"
.%D "April 1991"
.Re
Trade Names (or Acronyms and Type Names)
The trade name macro prints its arguments in a smaller font.
Its intended use is to imitate a small caps fonts for uppercase acronyms.
Usage:
.Tn
symbol<.blm Pp
...
>
.Tn DEC
.Tn ASCII
Extended Arguments
The
.Xo
and
.Xc
macros allow one to extend an argument list on a macro boundary for the
`.It'
macro (see below).
Note that
.Xo
and
.Xc
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.
.Sm off
.It Xo Sy I Ar operation
.No \en Ar count No \en
.Xc
.Sm on
.Sm off
.It Cm S No / Ar old_pattern Xo
.No / Ar new_pattern
.No / Op Cm g
.Xc
.Sm on
.It Xo
.Ic .ifndef
.Oo \&! Oc Ns Ar variable Oo
.Ar operator variable ...
.Oc Xc
PAGE STRUCTURE DOMAIN
Section Headers
The following
`.Sh'
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
`.Sh'
macro is parsed but not generally callable.
It can be used as an argument in a call to
`.Sh'
only; it then reactivates the default font for
`.Sh'.
.Sh NAME
.Sh LIBRARY
.Sh SYNOPSIS
cat
[-benstuv]
[-]
.Nm cat
.Op Fl benstuv
.Op Fl
.Ar
.Sh DESCRIPTION
.Sh IMPLEMENTATION NOTES
.Sh RETURN VALUES
.Sh ENVIRONMENT
.Sh FILES
.Sh EXAMPLES
.Sh DIAGNOSTICS
.Sh COMPATIBILITY
.Sh ERRORS
.Sh SEE ALSO
.Sh STANDARDS
.Sh HISTORY
.Sh AUTHORS
.Sh BUGS
.Sh "PAGE STRUCTURE DOMAIN"
Subsection Headers
Subsection headers have exactly the same syntax as section headers:
`.Ss'
is parsed but not generally callable.
It can be used as an argument in a call to
`.Ss'
only; it then reactivates the default font for
`.Ss'.
Paragraphs and Line Spacing
.Pp
Keeps
The only keep that is implemented at this time is for words.
The macros are
`.Bk'
(begin keep)
and
`.Ek'
(end keep).
The only option that
`.Bk'
accepts currently is
-words
(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
What's in a Name),
the keep prevented
nroff
from placing up the flag and the argument on separate lines.
Examples and Displays
There are seven types of displays.
.D1
-ldghfstru
.D1 Fl ldghfstru
.
.Dl
%
ls
-ldg
/usr/local/bin
.Dl % ls -ldg /usr/local/bin
.
.Bd
.Bd
Xo
troff/
-mdoc
commands in the file will be processed.
troff
.Ed
Lists and Columns
There are several types of lists which may be initiated with the
`.Bl'
begin-list macro.
Items within the list are specified with the
`.It'
item macro, and each list must end with the
`.El'
macro.
Lists may be nested within themselves and within displays.
The use of columns inside of lists or lists inside of columns is unproven.
.Bl
Xo
.Bl
Xo
.Bl
Xo
.Bl -bullet -offset indent -compact
.It
Bullet one goes here.
.It
Bullet two here.
.El
.Bl -dash -offset indent -compact
.It
Dash one goes here.
.It
Dash two here.
.El
.Bl -enum -offset indent -compact
.It
Item one goes here.
.It
And item two here.
.El
.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
.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
.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
.Bl -diag
.It You can't use Sy here.
The message says all.
.El
.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
.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
.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
String Nroff Troff
<=
<=
<=
>=
>=
>=
.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
.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
MISCELLANEOUS MACROS
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:
`.Me'
and
`.Ot'.
They are documented here for completeness - if you know how to use them
properly please send a mail to
bug-groff@gnu.org
(including an example).
.Bt
.Fr
Usage:
.Fr
function
return
value<.blm Pp
...
>
.Hf
Usage:
.Hf
file<.blm Pp
>
.Lk
Usage:
.Lk
href<.blm Pp
anchor-text[.blm Pp
>
]
.Me
.Mt
Usage:
.Mt
email_address<.blm Pp
>
.Ot
.Sm
Usage:
.Sm
on
|
off[.blm Pp
...
]
.Ud
PREDEFINED STRINGS
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
DIAGNOSTICS
The debugging macro
`.Db'
available in previous versions of
-mdoc
has been removed since
GNU
troff(1)
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.
FORMATTING WITH GROFF, TROFF, AND NROFF
By default, the package inhibits page breaks, headers, and footers if
displayed with a
TTY
device like
`latin1'
or
`unicode',
to make the manual more efficient for viewing on-line.
This behaviour can be changed (e.g. to create a hardcopy of the
TTY
output) by setting the register
`cR'
to zero while calling
groff(1),
resulting in multiple pages instead of a single, very long page:
groff
-Tlatin1
-rcR=0
-mdoc
foo.man
>
foo.txt
groff
-Tps
-rD1
-mdoc
foo.man
>
foo.ps
groff
-Tdvi
-rS11
-mdoc
foo.man
>
foo.dvi
groff
-Tutf8
-rLL=100n
-rLT=100n
-mdoc
foo.man
|
less
FILES
doc.tmac
mdoc.tmac
doc.tmac
.
mdoc/doc-common
mdoc/doc-nroff
mdoc/doc-ditroff
mdoc.local
andoc.tmac
SEE ALSO
groff(1),
man(1),
troff(1),
groff_man(7)
BUGS
Section 3f has not been added to the header routines.