Enter the following source with your text editor, and save the result
as coffee.man:
1 .TH COFFEE 1 "23 March 94"
2 .SH NAME
3 coffee \- Control remote coffee machine
4 .SH SYNOPSIS
5 \fBcoffee\fP [ -h | -b ] [ -t \fItype\fP ] \fIamount\fP
6 .SH DESCRIPTION
7 \fIcoffee\fP queues a request to the remote coffee machine at the
8 device \fB/dev/cf0\fR. The required \fIamount\fP argument specifies
9 the number of cups, generally between 0 and 15 on ISO standard
10 coffee machines.
11 .SS Options
12 .TP
13 \fB-h\fP
14 Brew hot coffee. Cold is the default.
15 .TP
16 \fB-b\fP
17 Burn coffee. Especially useful when executing \fIcoffee\fP on behalf
18 of your boss.
19 .TP
20 \fB-t \fItype\fR
21 Specify the type of coffee to brew, where \fItype\fP is one of
22 \fBcolombian\fP, \fBregular\fP, or \fBdecaf\fP.
23 .SH FILES
24 .TP
25 \fI/dev/cf0\fR
26 The remote coffee machine device
27 .SH "SEE ALSO"
28 milk(5), sugar(5)
29 .SH BUGS
30 May require human intervention if coffee supply is exhausted.
Don't let the amount of obscurity in this source file frighten you. It
helps to know that the character sequences \fB,
\fI, and \fR are used to change
the font to boldface, italics, and roman type,
respectively. \fP resets the font to the one
previously selected.
Other groff requests appear on lines beginning with
a dot (.). On line 1, we see that the
.TH request sets the title of the manual page to
COFFEE and the manual section to
1. (Manual section 1 is used for user commands,
section 2 for system calls, and so forth.) The .TH
request also sets the date of the last manual page revision.
On line 2, the .SH request starts a section
entitled NAME. Note that almost all
Unix manual pages use the section progression
NAME, SYNOPSIS,
DESCRIPTION, FILES, SEE
ALSO, NOTES, AUTHOR,
and BUGS, with extra optional sections as
needed. This is just a convention used when writing manual pages and
isn't enforced by the software at all.
Line 3 gives the name of the command and a short description, after a
dash (\-). You should use this format for the
NAME section so that your manual page can be added
to the whatis database used by the man
-k and apropos commands.
On lines 4-5, we give the synopsis of the command syntax for
coffee. Note that italic type
\fI…\fP is used to denote parameters on the
command line, and that optional arguments are enclosed in square
brackets.
Lines 6-10 give a brief description of the command. Italic type
generally denotes commands, filenames, and user options. On line 11, a
subsection named Options is started with the
.SS request. Following this on lines 11-22 is a
list of options, presented using a tagged list. Each item in the
tagged list is marked with the .TP request; the
line after .TP is the tag,
after which follows the item text itself. For example, the source on
lines 12-14:
.TP
\fB-h\fP
Brew hot coffee. Cold is the default.
will appear as the following in the output:
-h Brew hot coffee. Cold is the default.
You should document each command-line option for your program in this way.
Lines 23-26 make up the FILES section of the
manual page, which describes any files the command might use to do its
work. A tagged list using the .TP request is used
for this as well.
On lines 27-28, the SEE ALSO section is
given, which provides cross references to other manual pages of
note. Notice that the string "SEE ALSO" following
the .SH request on line 27 is in quotation marks; this is
because .SH uses the first whitespace-delimited
argument as the section title. Therefore any section titles that are
more than one word need to be enclosed in quotation marks to make up a single
argument. Finally, on lines 29-30, the BUGS
section is presented.