.\" Copyright (c) 1990 The Regents of the University of California.
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" @(#)mdoc.samples.7 5.7 (Berkeley) 7/1/91
.\" This sampler invokes every macro in the package several
.\" times and is garanteed to give a worst case performance
.\" for an already extremely slow package.
.Nd writing manual pages with
A tutorial sampler for writing
addressed page structure leaving the
manipulation of fonts and other
typesetting details to the individual author.
allows the author to ignore font considerations by
pieces of text according to content.
In the context of manual pages, examples of content
are a command name, a file pathname or a cross
reference to another manual page; these
for both the author and the future user of the manual page.
It is hoped the consistency gained
across the manual set will provide easier
translation to future documentation tools.
manual pages, a manual entry
to as a man page, regardless of actual length and without
package attempts to simplify the process of writing a man page.
Theoretically, one should not have to learn the dirty details of
limitations which are unavoidable and best gotten out
of the way. And, too, be forewarned, this package is
a macro is called by placing a
a line followed by the two character name for the macro.
Arguments may follow the macro separated by spaces.
It is the dot character at the beginning of the line which causes
to interpret the next two characters as a macro name.
at the beginning of a line in some context other than
a macro macro, precede the
macros accept up to nine arguments, any
extra arguments are ignored.
accept nine arguments and,
in limited cases, arguments may be continued or extended
A few macros handle quoted aguments (see
.Sx Passing Space Characters in an Argument
name of another macro as an argument. In this case
the argument, although the name of a macro,
when the argument is processed.
It is in this manner that some macros are nested; for
the flag and argument macros,
to specify an optional flag with an argument:
.Bl -tag -width "\&.Op \&Fl s \&Ar bytes" -offset indent
.Li \&.Op \&Fl s \&Ar bytes
To prevent a two character
string from being interpreted as a macro name, precede
.Bl -tag -width "[\&Fl s \&Ar bytes]" -offset indent
.Li \&.Op \e&Fl s \e&Ar bytes
were not interpreted as macros.
Details on callable macros are presented in the
.Ss Passing Space Characters in an Argument
Sometimes it is desirable to give as one argument a string
containing one or more blank space characters. This may be necessary
to defeat the nine argument limit or to specify arguments to macros
which expect particular arrangement of items in the argument list.
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 imbedded space. Unfortunately, the most convient way
of passing such a space between quotes was too expensive to implement for
all the macros. It is however, implemented for the following macros which need
.Bl -tag -width 4n -offset indent -compact
Configuration declaration (section 4 SYNOPSIS)
Begin list (for the width specifier).
Functions (sections two and four).
Optional notes for a reference.
Report title (in a reference).
Title of article in a book or journal.
One way of passing a string
containing blank spaces is to use the hard or unpaddable space character
that is, a blank space preceeded 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. The method is useful for strings which are not expected
to overlap a line boundary. For example:
.Bl -tag -width "fetch(char *str)" -offset indent
.Ql \&.Fn fetch char\e *str
.Ql \&.Fn fetch "\\*q*char *str\\*q"
would see three arguments and
For an example of what happens when the parameter list overlaps
a newline boundary, see the
.\" Note what happens if the parameter list overlaps a newline
.\" boundary. For example, the next two examples are repeated several times
.\" to make sure a line boundary is crossed:
.\" \&.Fn struct\e\ dictionarytable\e\ *dictionarylookup struct\e\ dictionarytable\e\ *tab[]
.\" produces, nudge nudge,
.\" .Fn struct\ dictionarytable\ *dictionarylookup char\ *h struct\ dictionarytable\ *tab[] ,
.\" .Fn struct\ dictionarytable\ *dictionarylookup char\ *h struct\ dictionarytable\ *tab[] ,
.\" .Fn struct\ dictionarytable\ *dictionarylookup char\ *h struct\ dictionarytable\ *tab[] .
.\" If double quotes are used, for example:
.\" \&.Fn \*qstruct dictionarytable *dictionarylookup\*q \*qchar *h\*q \*qstruct dictionarytable *tab[]\*q
.\" produces, nudge nudge,
.\" .Fn "struct dictionarytable *dictionarylookup" "char *h" "struct dictionarytable *tab[]" ,
.\" .Fn "struct dictionarytable *dictionarylookup" "char *h" "struct dictionarytable *tab[]" ,
.\" .Fn "struct dictionarytable *dictionarylookup" "char *h" "struct dictionarytable *tab[]" .
.\" Not a pretty sight...
.\" In a paragraph, a long parameter containing unpaddable spaces as
.\" in the former example will cause
.\" to break the line and spread
.\" the remaining words out. The latter example will adjust nicely to
.\" justified margins, but may break in between an argument and its
.\" the right margin adjustment is normally ragged and the problem is
.Ss Trailing Blank Space Characters
can be confused by blank space characters at the end of a line. It
is wise preventative measure to globally remove all blank spaces
from <blank-space><end-of-line> character sequences. Should the need
arise to force a blank character at the end of a line,
it may be forced with an unpaddable space and the
.Ss Escaping Special Characters
like the newline character
are handled by replacing the
.Sh THE ANATOMY OF A MAN PAGE (Getting Started)
There are three basic groups of macros: specific header macros
called only once at the very beginning of
each manual page, page layout or structure macros
which may be called many times, and content macros which also
may be called many times.
The body of a man page is easily constructed from a basic
template found in the file:
.Bd -literal -offset indent
\&.\e" /usr/share/misc/man.tempate :
\&.\e" The following six lines are required.
\&.Dt DOCUMENT_TITLE [section number] [volume]
\&.Os OPERATING_SYSTEM [version/release]
\&.\e" The following requests should be uncommented and
\&.\e" used where appropriate. This next request is
\&.\e" for sections 2 and 3 function return values only.
\&.\e" This next request is for sections 1, 6, 7 & 8 only
\&.\e" This next request is for sections 1, 6, 7 & 8 only
\&.\e" (command return values (to shell) and
\&.\e" fprintf/stderr type diagnostics)
\&.\e" The next request is for sections 2 and 3 error
\&.\e" and signal handling only.
The first items in the template are the macros
.Pq Li \&.Dt , \&.Dd , \&.Os ;
the document or man page title
the section of the manual the page
belongs to, the (document) date,
and the operating system the man page is derived
from. These macros identify the page,
and are discussed below in
The remaining items in the template are section headers
of which NAME, SYNOPSIS and DESCRIPTION
Several content macros are used to demonstrate page layout macros;
reading about content macros before page layout macros is
Three header macros designate the document title or manual page title,
and the date of authorship.
These macros are one called once at the very beginning of the document
and are used to construct the headers and footers only.
.It Li \&.Dt DOCUMENT_TITLE section# [volume]
The document title is the
subject of the man page and must be in CAPITALS due to troff
The section number may be 1,\ ...,\ 8,
the volume title may be omitted.
A volume title may be arbitrary or one of the following:
.\" USD UNIX User's Supplementary Documents
.\" PS1 UNIX Programmers's Supplementary Documents
.Bl -column SMM -offset indent -compact
.It AMD UNIX Ancestral Manual Documents
.It SMM UNIX System Manager's Manual
.It URM UNIX Reference Manual
.It PRM UNIX Programmers's Manual
.\" MMI UNIX Manual Master Index
.\" CON UNIX Contributed Software Manual
.\" LOC UNIX Local Manual
.It Li \&.Os operating_system release#
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, e.g. 4.3, 4.3+Tahoe, V.3,
V.4. Unrecognized arguments are displayed as given in the page footer.
For instance, for the footer on this page, the 4.4 Berkeley Distribution
.It Li \&.Dd month day, year
The date should be written formally:
Content macro names are derived from the day to day
informal language used to describe commands, subroutines and related
different variations of this language are used to describe
the three different aspects of writing a man page.
First, there is the description of
Second is the description of a
description a command to a user in the verbal sense;
that is, discussion of a command in the text of a man page.
macros are themselves a type of command;
the general syntax for a troff command is:
.Bd -filled -offset indent
\&.Va argument1 argument2 ... argument9
is a macro command or request, and anything following it is an argument to
command using the content macros is a
a typical SYNOPSIS command line might be displayed as:
.Bd -filled -offset indent
is the command name and the
argument designated as optional by the option brackets.
The macros which formatted the above example:
.Bd -literal -offset indent
In the third case, discussion of commands and command syntax
includes both examples above, but may add more detail. The
from the example above might be refered to as
Some command line argument lists are quite long:
.\" .Bl -tag -width make -offset indent
.Bl -tag -width make -offset indent
Here one might talk about the command
as an argument to the flag,
In the verbal context, such detail can prevent confusion,
does not have a macro for an argument
argument macro is used for an operand or file argument like
as well as an argument to a flag like
.Bd -literal -offset indent
All content macros share a similar
syntax with a few minor deviations:
differ only when called without arguments;
impose an order on their argument lists
have nesting limitations. All content macros
are capable of handling punctuation.
Any argument which may be tested for punctuation
and contains a member of the mathematical, logical or
.Bd -literal -offset indent -compact
{+,\-,/,*,%,<,>,<=,>=,=,==,&,`,',"}
the character escaped with
Typical syntax is shown in the first content macro displayed
and the syntax for enclosure/quoting macros is shown in
.Sx Enclosure and Quoting Macros .
The address macro constructs an address
of the form addr1[,addr2[,addr3]].
.Dl Usage: .Ad address ... \*(Pu
.Bl -tag -width ".Ad f1 , f2 , f3 :" -compact -offset 14n
.It Li \&.Ad addr1\ , file2
.It Li \&.Ad f1\ , f2\ , f3\ :
.It Li \&.Ad addr\ )\ )\ ,
is callable by other macros and may call other macros.
argument macro may be used whenever
a command line argument is referenced.
.Dl Usage: .Ar argument ... \*(Pu
.Bl -tag -width ".Ar file1 file2" -compact -offset 15n
.It Li \&.Ar file\ )\ )\ ,
is called without arguments
macro may call other macros, and may be
.Ss Angle Bracket Quote/Enclosure
Encloses a string or strings in between angle brackets. The macro
encloses the remaining arguments on the macro command line, and the
(angle close) macros may be used across one or more lines.
.Dl Usage: .Aq string ... \*(Pu
.Bl -tag -width ".Aq Pa ctype.h ) ," -compact -offset 14n
.It Li \&.Aq \&Ar ctype.h\ )\ ,
for examples of the open and close
is callable by other macros and may call other macros.
.Ss Bracket Quotes/Enclosure
Bracket quotes should be used when the string being bracketed is
an option string. The brackets for an option may be different
than the default brackets. The macro
encloses the remaining arguments on a macro command line and the
may be used across one or more lines.
.Dl Usage: .Bq string ... \*(Pu
macro exists for statements which use other macros:
.Dl Li \&.Bq \&Em Greek \&, French \&.
It also could have been done using the prefix macro:
.Dl Li ".Pf [ Em Greek , French ] ."
for examples of the open and close
is callable and may call other macros.
.Ss Configuration Declaration (section four only)
macro is used to demonstrate a
declaration for a device interface in a section four manual.
This macro accepts quoted arguments (double quotes only).
.Bl -tag -width "device le0 at scode?" -offset indent
.It Cd "device le0 at scode?"
.Ql ".Cd device le0 at scode?" .
The command modifier is identical to the
(flag) command with the exception
macro does not assert a dash
in front of every argument. Traditionally flags are marked by the
preceding dash, 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.
.Ss Double Quote macro/Enclosure
any remaining strings on the command line with double quotes.
placed after the end quote.
may be used across one or more lines.
.Dl Usage: .Dq string ... \*(Pu
.Bl -tag -width ".Dq Ar patternx ) ) ," -compact -offset 14n
.It Li ".Dq string abc ."
.It Li \&.Dq \&Ar pattern\ )\ )\ ,
is called with no arguments
macro may call or be called by
A variable which is defined in an include file is specified
.Dl Usage: .Dv defined_variable ... \*(Pu
.Bl -tag -width ".Dv MAXHOSTNAMELEN" -compact -offset 14n
.It Li ".Dv MAXHOSTNAMELEN"
may call other macros and
may be called by other macros.
Text may be stressed or emphasized with the
macro. The usual font for emphasis is italic.
.Dl Usage: .Em argument ... \*(Pu
.Bl -tag -width ".Em vide infra ) ) ," -compact -offset 14n
.It Li ".Em exceed 1024 ."
.It Li ".Em vide infra ) ) ,"
The emphasis can be forced across several lines of text by using
.\" I'm certain the reason so many people desire an MBA from Harvard
.\" is because they want to be successful philanthropists.
is callable and may call other macros.
.Ss Enclosure and Quoting Macros
The concept of enclosure is similar to quoting.
The object is to enclose a string or more between
a pair of characters like quotes or parentheses.
The terms quoting and enclosure are used
interchangeably throughout this document. Many of the
one line enclosure macros end
to give a hint of quoting, but there are a few exceptions
are also enclosure macros).
there is also a pair of open and close macros which end
respectively. These can be used across one or more lines of text
and while they cannot be nested, the one line quote macros
For a good example of one these macros, see
.Bd -filled -offset indent
.Bl -column "quote" "close" "open" "Enclose Stringx(in XX)" XXstringXX
.Em " quote close open function result"
\&.Aq, .Ac, .Ao Angle Bracket Enclosure <string>
\&.Bq, .Bc, .Bo Bracket Enclosure [string]
\&.Dq, .Dc, .Do Double Quote ``string''
.Ec, .Eo Enclose String (in XX) XXstringXX
\&.Fn, .Fc, .Fo Function Enclosure function(string)
\&.Op, .Oc, .Oo Option Enclosure [string]
\&.Pq, .Pc, .Po Parenthesis Enclosure (string)
\&.Qq, .Qc, .Qo Straight Double Quote "string"
\&.Sq, .Sc, .So Single Quote `string'
\& .Xc, .Xo Extend Argument \ \-\-
allow a user to specify an open and close with the first argument as the
opening or closing string respectively.
.Ss Errno's (Section two only)
errno macro specifies the error return value
for section two library routines. The second example
macro, as it would be used in
a section two manual page.
.Dl Usage: .Er ERRNOTYPE ... \*(Pu
.Bl -tag -width ".Bq Er ENOTDIR" -compact -offset 14n
.It Li \&.Er ENOENT\ )\ ;
.It Li \&.Bq \&Er ENOTDIR
is callable and may call other macros.
.Ss Environment Variables
macro specifies a environment variable.
.Dl Usage: .Ev argument ... \*(Pu
.Bl -tag -width ".Ev PRINTER ) ) ," -compact -offset 14n
.It Li \&.Ev PRINTER\ )\ )\ ,
is callable by other macros and may call other macros.
macro is used to refer to function arguments (parameters)
outside of the SYNOPSIS section of the manual or inside
the SYNOPSIS section should a parameter list be too
macro and the enclosure macros
may also be used to refer to structure members.
.Dl Usage: .Fa function_argument ... \*(Pu
.Bl -tag -width ".Fa d_namlen\ )\ )\ ," -compact -offset 14n
.It Li \&.Fa d_namlen\ )\ )\ ,
is callable by other macros and may call other macros.
macro is used in the SYNOPSIS section with section two or three
macro does not call other macros and is not callable by other
.Dl Usage: .Fd include_file (or defined variable)
In the SYNOPSIS section a
request 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
macro handles command line flags. It prepends
to the flag. For interactive command flags, which
are not prepended with a dash, the
macro is identical, but with out the dash.
.Dl Usage: .Fl argument ... \*(Pu
.Bl -tag -width ".Fl \-s \-t \-v" -compact -offset 14n
macro without any arguments results
in a dash representing stdin/stdout.
a single dash, will result in two dashes.
is callable and may call other macros.
.Ss Functions (library routines)
The .Fn macro is modeled on ANSI C conventions.
Usage: .Fn [type] function [[type] params ... \*(Pu]
.Bl -tag -width ".Fn .int align. .const * char *sptrsxx" -compact
.It Li "\&.Fn strlen ) ,"
.It Li \&.Fn "\\*qint align\\*q" "\\*qconst * char *sptrs\\*q" ,
.Fn "int align" "const * char *sptrs" ,
is callable by other macros and may call other macros, but
note that any call to another macro signals the end of
call (it will close-paren at that point).
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.
does not check its word boundaries
against troff line lengths and may split across a newline
ungracefully. This will be fixed in the near future.
This macro is intended for the SYNOPSIS section. It may be used
anywhere else in the manpage 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 page break allowing the function name to appear
.Dl Usage: .Ft type ... \*(Pu
.Bl -tag -width "\&.Ft struct stat" -offset 14n -compact
request is not callable by other macros.
macro designates an interactive or internal command.
.Dl Usage: .Li argument ... \*(Pu
.Bl -tag -width ".Ic setenv , unsetenv" -compact -offset 14n
.It Li \&.Ic do while {...}
.It Li \&.Ic setenv\ , unsetenv
macro may call other macros and is callable.
literal macro may be used for special characters,
variable constants, anything which should be displayed as it
.Dl Usage: .Li argument ... \*(Pu
.Bl -tag -width ".Li cntrl-D ) ," -compact -offset 14n
.It Li \&.Li cntrl-D\ )\ ,
is callable by other macros and may call other macros.
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
regurgitates this initial name for the sole purpose
of making less work for the author.
or three document function name is addressed with the
in the NAME section, and with
For interactive commands, such as the
it can not recall the first argument it was invoked with.
.Dl Usage: .Nm argument ... \*(Pu
.Bl -tag -width ".Nm mdoc.samples" -compact -offset 14n
.It Li \&.Nm mdoc.samples
.It Li \&.Nm foo\ )\ )\ ,
is callable by other macros and may call other macros.
.Ss No\-Op or Normal Text Macro
a hack for words in a macro command line which should
be formatted and follows the conventional syntax
macro eliminates unwanted spaces in between macro requests.
It is useful for old style argument lists where there is no space
between the flag and argument:
.Bl -tag -width ".Op Fl I Ns Ar directory" -offset indent
.It Li ".Op Fl I Ns Ar directory"
macro after eliminating the space unless another macro name
is callable and may call other macros.
places option brackets around the any remaining arguments on the command
trailing punctuation outside the brackets. The macros
may be used across one or more lines.
.Dl Usage: .Op options ... \*(Pu
.Bl -tag -width ".Op Fl c Ar objfil Op Ar corfil ," -compact -offset indent
.It Li ".Op Fl k Ar kookfile"
.It Li ".Op Fl k Ar kookfile ,"
.It Li ".Op Ar objfil Op Ar corfil"
.Op Ar objfil Op Ar corfil
.It Li ".Op Fl c Ar objfil Op Ar corfil ,"
.Op Fl c Ar objfil Op Ar corfil ,
.Bd -literal -offset indent
\&.Op \&Fl k \&Ar kilobytes
\&.Op \&Fl i \&Ar interval
are callable and may call other macros.
.Ss Parenthesis Quote/Enclosure
follow the conventions for a typical quoting macros,
macro formats path or file names.
.Dl Usage: .Pa pathname \*(Pu
.Bl -tag -width ".Pa /tmp/fooXXXXX ) ." -compact -offset 14n
.It Li \&.Pa /tmp/fooXXXXX\ )\ .
is callable by other macros and may call other macros.
.Ss Single Quotes/Enclosure
.Sx Double Quote/Enclosure
works in the identical manner as
is a short cut for combining
two strings together, the first of which is
in the default font, and the second a content
.Bl -tag -width ".Pf ( Fa name2 " -offset 14n -compact
macro is not callable, but may call other macros. The
macro performs the analogus suffix function.
.Ss Section Cross References
macro designates a reference to a section header
within the same document. It is callable by other macros and may
.Bl -tag -width "Li \&.Sx FILES" -offset 14n
.Ss References and Citations
The following macros make a modest attempt to handle references.
At best, the macros make it convientent to manually drop in a subset of
.Bl -tag -width 6n -offset indent -compact
Reference Start. Causes a line break and begins collection
of reference information until the
reference end macro is read.
Reference End. The reference is printed.
Reference author name, one name per invocation.
are not callable, but may call only the trade name macro which
returns to its caller. The purpose is to allow trade names
to be pretty printed in troff/ditroff output. WARNING: this
has very few trade names defined at the moment and will print unknown
trade names in the default font.
The symbolic emphasis macro is generally a boldface macro in
either the symbolic sense or the traditional English usage.
.Dl Usage: .Sy symbol ... \*(Pu
.Bl -tag -width ".Sy Important Notice" -compact -offset 14n
.It Li \&.Sy Important Notice
is callable by other macros and may call other macros, except
in the second form. Arguments to
Generic variable reference:
.Dl Usage: .Va variable ... \*(Pu
.Bl -tag -width ".Va char s ] ) ) ," -compact -offset 14n
.It Li \&.Va int\ *prt\ )\ :
.It Li \&.Va char\ s\ ]\ )\ )\ ,
is callable by other macros and may call other macros.
macro expects the first argument to be
a manual page name, and the second argument, if it exists,
to be either a section page number or punctuation. Any
remaining arguments are assumed to be punctuation.
.Dl Usage: .Xr manpage [1,...,8] \*(Pu
.Bl -tag -width ".Xr mdoc 7 ) ) ," -compact -offset 14n
.It Li \&.Xr mdoc 7\ )\ )\ ,
is callable by other macros and may call other macros.
maxros allow one to extend an argument list
on a macro boundary. Argument lists cannot
be extended within a macro
which expects all of its arguments on one line such
list below are required in every
man page. The remaining section headers
are recommended at the disgression of the author
writing the manual page. The
macro can take up to nine arguments. It may call
other macros, but it may not be called by other macros.
.Bl -tag -width ".Sh SYNOPSIS"
macro is mandatory. If not specified,
the headers, footers and page layout defaults
will not be set and things will be rather unpleasant.
The NAME section consists of at least three items.
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.
The SYNOPSIS section describes the typical usage of the
subject of a man page. The macros required
for manual page sections 2 and 3, the command and general
is required for sections 1, 5, 6, 7, 8.
Section 4 manuals require a
configuration device usage macro.
Several other macros may be necessary to produce
the synopsis line as shown below:
.Bd -filled -offset indent
The following macros were used:
In most cases the first text in the DESCRIPTION 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
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 ENVIRONMENT section should reveal any related
variables and clues to their behaviour and/or usage.
There are several ways to create examples. See
the EXAMPLES section below
Files which are used or created by the man page subject
macro in the FILES section.
References to other material on the man page topic and
cross references to other relevant man pages should
be placed in the SEE ALSO section. Cross references
style references are not accommodated.
If the command, library function or file adheres to a
specific implementation such as POSIX 1003.1 or
ANSI C X3.159-1989 this should be noted here. If the
command does not adhere to any standard, its history
should be noted in the HISTORY section.
Any command which does not adhere to any specific standards
should be outlined historically in this section.
Credits, if need be, should be placed here.
Diagnostics from a command should be placed in this section.
Specific error handling, especially from library functions
(man page sections 2 and 3) should go here. The
macro is used to specify an errno.
Blatant problems with the topic go here...
for example, this section was set with:
.Ss Paragraphs and Line Spacing.
The \&.Pp paragraph command may
be used to specify a line space where necessary.
The macro is not necessary after a
macro asserts a vertical distance unless the -compact flag is given).
.\" .Cw (ax+bx+c) \ is\ produced\ by\ \&
.\" .\".Cw (ax+bx+c) \&.Va_by_) \&_and_\& \&[?/]m_b1_e1_f1[?/]\&
.\" This example shows the same equation in a different format. The spaces
.\" signs were forced with
.\" .Cw (ax\ +\ bx\ +\ c) \ is\ produced\ by\ \&
.\" .\".Cw (ax+bx+c) \&.Va_by_) \&_and_\& \&[?/]m_b1_e1_f1[?/]\&
.\" .Li \&.Cx \e\ +\e\ \e&
.\" .Li \&.Cx \e\ +\e\ \e&
.\" The incantation below was
.\" .Cw \&[?/]m_b1_e1_f1[?/]\& is\ produced\ by
.\" .Li \&.Ar \e\ b1 e1 f1
.Ss Examples and Displays
There are five types of displays, a quickie one line indented display
a quickie one line literal display
a block literal, block filled and block ragged which use
(D-one) Display one line of indented text.
Arguments are checked to see if they are callable.
.Bd -ragged -offset indent
Display one line of indented
example macro has been used throughout this
the indent (display) of one line of text.
Its default font is set to
constant width (literal) however
does check arguments to see it they are callable.
should be content macros; calling macros from
is redundant and may cause unpredictable errors.
.Bd -ragged -offset indent
.Li \&.Dl % ls -ldg /usr/local/bin
.Dl % ls -ldg /usr/local/bin
display must be ended with the
macro. Displays may be nested within displays and
has the following syntax:
.Dl ".Bd display-type [offset offset_value]"
The display-type must be one of the following four types and
may have an offset specifier for indentation:
.Bl -tag -width "literalxx" -compact
Display a block of text as typed,
right (and left) margin edges are left ragged.
Display a filled (formatted) block.
The block of text is formatted (the edges are filled \-
Display a literal block, useful for source code or
simple tabbed or spaced text.
The file name following the
flag is read and displayed. Literal mode is
asserted and tabs are set at 8 constant width character
commands in file will be processed.
is specified with one of the following strings, the string
is interpreted to indicate the level of indentation for the
forthcoming block of text:
.Bl -tag -width "indent" -compact
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.
Indents by one default indent value or tab. The default
indent value is also used for the
display so one can be garanteed of the two types of displays
lining up. This indent is nornally set to 6n or about two
thirds of an inch (six constant width characters).
Indents two times the default indent value.
aligns the block about two inches from
the right side of the page. This macro also needs
work and perhaps may never be right in
.Ss Tagged Lists and Columns
There are several types of lists which may be initiated with the
begin-list macro. Items within the list
each list must end with the
macro. Lists may be nested within themselves and within displays.
Columns may be used inside of lists, but lists are unproven
In addition, several list attributes may be specified such as
the width of a tag, the list offset, and compactness specified
(blank lines between items allowed or disallowed).
The following list types are accepted by
These three are the simplest types of lists. Once the
macro has been given, items in the list are merely
indicated by a line consisting solely of the
macro. For example, the source text for a simple enumerated list
.Bd -literal -offset indent-two
\&Lastly item three goes here.
.Bl -enum -offset indent-two -compact
Lastly item three goes here.
A simple bullet list construction:
.Bd -literal -offset indent-two
.Bl -bullet -offset indent-two -compact
These list-types collect arguments specified with the
macro and create a label which may be
into the forth coming text,
(exdented) from the forth coming text,
set above the forth coming paragraph or
(exdented and offset). This
list was constructed with the
macro may call any callable macros for the inset, hang
and tag list-types, but will not call macros for the
Here is an example of inset labels:
.Bl -inset -offset indent
The tagged list (also called a tagged paragraph) is the
most common type of list used in the Berkeley manuals.
Diag lists create section four diagnostic lists
and are similar to inset lists except callable
Hanged labels are a matter of taste.
Over hanging 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:
.Bd -literal -offset indent
\&.Bl -inset -offset indent
\&The tagged list (also called a tagged paragraph) is the
\&most common type of list used in the Berkeley manuals.
\&Diag lists create section four diagnostic lists
\&and are similar to inset lists except callable
\&Hanged labels are a matter of taste.
\&Over hanging labels are nice when space is constrained.
\&Inset labels are useful for controlling blocks of
\¶graphs and are valuable for converting
\&manuals to other formats.
Here is a hanged list with just one item:
labels appear similar to tagged lists when the
label is smaller than the label width.
.It Em Longer hanged list labels
blend in to the paragraph unlike
And the unfomatted text which created it:
.Bd -literal -offset indent
\&.Bl -hang -offset indent
\&labels appear similar to tagged lists when the
\&label is smaller than the label width.
\&.It Em Longer hanged list labels
\&blend in to the paragraph unlike
\&tagged paragraph labels.
The tagged list which follows uses an optional width specifier to controll
.Bl -tag -width "PAGEIN 10" -compact -offset indent
sleep time of the process (seconds blocked)
number of disk i/o's resulting from references
by the process to pages not loaded in core.
numerical user-id of process owner
numerical id of parent of process process priority
(non-positive when in non-interruptible wait)
.Bd -literal -offset indent
\&.Bl -tag -width "PAGEIN 10" -compact -offset indent
\&sleep time of the process (seconds blocked)
\&number of disk i/o's resulting from references
\&by the process to pages not loaded in core.
\&numerical user-id of process owner
\&numerical id of parent of process process priority
\&(non-positive when in non-interruptible wait)
Acceptable width specifiers:
.Bl -tag -width Ar -offset indent
sets the width to the default width for a flag. All callable
macros have a default width value. The
set to ten constant width characters or about five sixth of
sets the width to 24 constant width characters or about two
is absolutely necessary for the scaling to work correctly.
.It Fl width Ar "ENAMETOOLONG"
sets width to the constant width length of the
.It Fl width Ar "\\*qint mkfifo\\*q"
again, the width is set to the constant width of the string
If a width is not specified for the tag list type, the first
is invoked, an attempt is made to determine an appropriate
width. If the first argument to
is a callable macro, the default width for that macro will be used
as if the macro name had been supplied as the width. However,
if another item in the list is given with a different callable
macro name, a new and nested list is assumed. Here is an involved
example of a self nesting list:
The debugging facilities for
are limited, but can help detect subtle errors such
as the collision of an argument name with an internal
register or macro name. (A what?)
A register is an arithmetic storage class for
with a one or two character name.
All registers internal to
of the form <uppercase><lowercase> such as
<lowercase><uppercase> as
<upper or lower letter><digit> as
And adding to the muddle,
has its own internal registers all of which are either
two lowercase characters or a dot plus a letter or meta-character
In one of the introduction examples, it was shown how to
prevent the interpretation of a macro name with the escape sequence
This is sufficient for the internal register names also.
.\" Every callable macro name has a corresponding register
.\" of the same name (<Uppercase><lowercase>).
.\" There are also specific registers which have
.\" been used for stacks and arrays and are listed in the
.\" .Bd -ragged -offset 4n
.\" [A-Z][a-z] registers corresponding to macro names (example ``Ar'')
.\" [a-z][A-Z] registers corresponding to macro names (example ``aR'')
.\" C[0-9] argument types (example C1)
.\" O[0-9] offset stack (displays)
.\" h[0-9] horizontal spacing stack (lists)
.\" o[0-9] offset (stack) (lists)
.\" t[0-9] tag stack (lists)
.\" v[0-9] vertical spacing stack (lists)
.\" w[0-9] width tag/label stack
If a non-escaped register name is given in the argument list of a request
unpredictable behaviour will occur. In general, anytime huge portions
of text do not appear where expected in the output, or small strings
such as list tags disappear, chances are there is a misunderstanding
about an argument type in the argument list.
Your mother never intended for you to remember this evil stuff - so here
is a way to find out whether or not your arguments are valid: The
macro displays the interpretation of the argument list for most
macros. Macros such as the
macro do not contain debugging information. All of the callable macros do,
and it is strongly advised whenever in doubt,
.Dl Usage: \&.Db [on | off]
An example of a portion of text with
the debug macro placed above and below an
artificially created problem (a flag argument
.Bd -literal -offset indent
.Bd -literal -offset indent
DEBUG(argv) MACRO: `.Op' Line #: 2
Argc: 1 Argv: `Fl' Length: 2
Space: `' Class: Executable
Argc: 2 Argv: `aC' Length: 2
Space: `' Class: Executable
Argc: 3 Argv: `Ar' Length: 2
Space: `' Class: Executable
Argc: 4 Argv: `file' Length: 4
Argc: 5 Argv: `)' Length: 1
Space: ` ' Class: Closing Punctuation or suffix
MACRO REQUEST: .Op Fl aC Ar file )
The first line of information tells the name of the calling
and the line number it appears on. If one or more files are involved
(especially if text from another file is included) the line number
may be bogus. If there is only one file, it should be accurate.
The second line gives the argument count, the argument
and its length. If the length of an argument is two characters, the
argument is tested to see if it is executable (unfortunately, any
register which contains a non-zero value appears executable).
The third line gives the space allotted for a class, and the
class type. The problem here is the argument aC should not be
executable. The four types of classes are string, executable, closing
punctuation and opening punctuation. The last line shows the entire
argument list as it was read. In this next example, the offending
.Bd -literal -offset indent
.Bd -literal -offset indent
DEBUG(fargv) MACRO: `.Em' Line #: 2
Argc: 1 Argv: `An' Length: 2
Argc: 2 Argv: `escaped' Length: 7
Argc: 3 Argv: `aC' Length: 2
MACRO REQUEST: .Em An escaped &aC
shows up with the same length of 2 as the
sequence produces a zero width, but a register
was not found and the type classified as string.
Other diagnostics consist of usage statements and are self explanatory.
.Bl -tag -width /usr/share/man0/template.doc -compact
.It Pa /usr/share/tmac/tmac.doc
.It Pa /usr/share/man0/template.doc
template for writing a man page
Undesirable hyphenation on the dash of a flag
argument is not yet resolved, and causes
occasional mishaps in the DESCRIPTION section.
(line break on the hyphen).
Predefined strings are not declared in documentation.
Section 3f has not been added to the header routines.
font should be changed in NAME section.
needs to have a check to prevent splitting up
if the line length is too short. Right now it
separates the last parenthesis, and sometimes
looks ridiculous if a line is in fill mode.
The method used to prevent header and footer page
breaks (other than the initial header and footer) when using
nroff seems to be putting out a partially filled line
at the bottom of the page leaving an unsightly blank space.
The list and display macros to not do any keeps
and certainly should be able to.