1MAN(7)                     Linux Programmer's Manual                    MAN(7)
2
3
4

NAME

6       man - macros to format man pages
7

SYNOPSIS

9       groff -Tascii -man file ...
10
11       groff -Tps -man file ...
12
13       man [section] title
14

DESCRIPTION

16       This manual page explains the groff an.tmac macro package (often called
17       the man macro package).  This macro package should be used by  develop‐
18       ers when writing or porting man pages for Linux.  It is fairly compati‐
19       ble with other versions of this macro package,  so  porting  man  pages
20       should  not  be  a  major  problem  (exceptions  include  the NET-2 BSD
21       release, which uses a totally different macro package called mdoc;  see
22       mdoc(7)).
23
24       Note  that  NET-2  BSD  mdoc man pages can be used with groff simply by
25       specifying the -mdoc option instead of  the  -man  option.   Using  the
26       -mandoc  option is, however, recommended, since this will automatically
27       detect which macro package is in use.
28
29       For conventions that should be employed when writing man pages for  the
30       Linux man-pages package, see man-pages(7).
31
32   Title line
33       The  first  command  in a man page (after comment lines, that is, lines
34       that start with .\") should be
35
36              .TH title section date source manual
37
38       For details of the arguments that should be supplied to the TH command,
39       see man-pages(7).
40
41       Note  that  BSD mdoc-formatted pages begin with the Dd command, not the
42       TH command.
43
44   Sections
45       Sections are started with .SH followed by the heading name.
46
47       The only mandatory heading is NAME, which should be the  first  section
48       and  be followed on the next line by a one-line description of the pro‐
49       gram:
50
51              .SH NAME
52              item \- description
53
54       It is extremely important that this format is followed, and that  there
55       is  a  backslash  before  the  single dash which follows the item name.
56       This syntax is used by the mandb(8) program to  create  a  database  of
57       short  descriptions  for  the  whatis(1) and apropos(1) commands.  (See
58       lexgrog(1) for further details on the syntax of the NAME section.)
59
60       For a list of other sections that might appear in a  manual  page,  see
61       man-pages(7).
62
63   Fonts
64       The commands to select the type face are:
65
66       .B  Bold
67
68       .BI Bold alternating with italics (especially useful for function spec‐
69           ifications)
70
71       .BR Bold alternating with Roman (especially  useful  for  referring  to
72           other manual pages)
73
74       .I  Italics
75
76       .IB Italics alternating with bold
77
78       .IR Italics alternating with Roman
79
80       .RB Roman alternating with bold
81
82       .RI Roman alternating with italics
83
84       .SB Small alternating with bold
85
86       .SM Small (useful for acronyms)
87
88       Traditionally,  each  command can have up to six arguments, but the GNU
89       implementation removes this limitation (you might still want  to  limit
90       yourself  to 6 arguments for portability's sake).  Arguments are delim‐
91       ited by spaces.  Double quotes can be used to specify an argument which
92       contains  spaces.   All  of  the arguments will be printed next to each
93       other without intervening spaces, so that the .BR command can  be  used
94       to  specify  a word in bold followed by a mark of punctuation in Roman.
95       If no arguments are given, the command is applied to the following line
96       of text.
97
98   Other macros and strings
99       Below  are  other relevant macros and predefined strings.  Unless noted
100       otherwise, all macros cause a break (end the  current  line  of  text).
101       Many of these macros set or use the "prevailing indent."  The "prevail‐
102       ing indent" value is set by any  macro  with  the  parameter  i  below;
103       macros  may  omit i in which case the current prevailing indent will be
104       used.  As a result, successive indented paragraphs  can  use  the  same
105       indent  without  respecifying the indent value.  A normal (nonindented)
106       paragraph resets the prevailing indent value to its default value  (0.5
107       inches).   By default a given indent is measured in ens; try to use ens
108       or ems as units for indents, since these will automatically  adjust  to
109       font size changes.  The other key macro definitions are:
110
111   Normal paragraphs
112       .LP      Same as .PP (begin a new paragraph).
113
114       .P       Same as .PP (begin a new paragraph).
115
116       .PP      Begin a new paragraph and reset prevailing indent.
117
118   Relative margin indent
119       .RS i    Start  relative  margin indent: moves the left margin i to the
120                right (if i is omitted, the prevailing indent value is  used).
121                A  new  prevailing  indent is set to 0.5 inches.  As a result,
122                all following paragraph(s) will be indented until  the  corre‐
123                sponding .RE.
124
125       .RE      End  relative margin indent and restores the previous value of
126                the prevailing indent.
127
128   Indented paragraph macros
129       .HP i    Begin paragraph with a hanging indent (the first line  of  the
130                paragraph  is at the left margin of normal paragraphs, and the
131                rest of the paragraph's lines are indented).
132
133       .IP x i  Indented paragraph with optional hanging tag.  If the tag x is
134                omitted,  the entire following paragraph is indented by i.  If
135                the tag x is provided, it is hung at the  left  margin  before
136                the following indented paragraph (this is just like .TP except
137                the tag is included with the command instead of being  on  the
138                following  line).   If the tag is too long, the text after the
139                tag will be moved down to the next line (text will not be lost
140                or  garbled).   For  bulleted  lists, use this macro with \(bu
141                (bullet) or \(em (em dash) as the tag, and for numbered lists,
142                use the number or letter followed by a period as the tag; this
143                simplifies translation to other formats.
144
145       .TP i    Begin paragraph with hanging tag.  The tag  is  given  on  the
146                next line, but its results are like those of the .IP command.
147
148   Hypertext link macros
149       (Feature  supported  with  groff only.)  In order to use hypertext link
150       macros, it is necessary to load the www.tmac macro  package.   Use  the
151       request .mso www.tmac to do this.
152
153       .URL url link trailer
154                Inserts  a  hypertext  link to the URI (URL) url, with link as
155                the text of the link.  The trailer will be printed immediately
156                afterward.   When  generating  HTML this should translate into
157                the HTML command <A HREF="url">link</A>trailer.
158
159                This and other related macros are new, and many tools won't do
160                anything  with  them,  but  since many tools (including troff)
161                will simply ignore undefined macros (or at worst insert  their
162                text) these are safe to insert.
163
164                It  can be useful to define your own URL macro in manual pages
165                for the benefit of those viewing it with a roff  viewer  other
166                than  groff.   That  way, the URL, link text, and trailer text
167                (if any) are still visible.
168
169                Here's an example:
170                      .de URL
171                      \\$2 \(laURL: \\$1 \(ra\\$3
172                      ..
173                      .if \n[.g] .mso www.tmac
174                      .TH ...
175                      (later in the page)
176                      This software comes from the
177                      .URL "http://www.gnu.org/" "GNU Project" " of the"
178                      .URL "http://www.fsf.org/" "Free Software Foundation" .
179
180                In the above, if groff is being used, the www.tmac macro pack‐
181                age's  definition  of the URL macro will supersede the locally
182                defined one.
183
184       A number of other link macros are available.  See groff_www(7) for more
185       details.
186
187   Miscellaneous macros
188       .DT      Reset  tabs to default tab values (every 0.5 inches); does not
189                cause a break.
190
191       .PD d    Set  inter-paragraph  vertical  distance  to  d  (if  omitted,
192                d=0.4v); does not cause a break.
193
194       .SS t    Subheading  t  (like  .SH,  but used for a subsection inside a
195                section).
196
197   Predefined strings
198       The man package has the following predefined strings:
199
200       \*R    Registration Symbol: ®
201
202       \*S    Change to default font size
203
204       \*(Tm  Trademark Symbol: ™
205
206       \*(lq  Left angled double quote: “
207
208       \*(rq  Right angled double quote: ”
209
210   Safe subset
211       Although technically man is a troff macro package, in reality  a  large
212       number  of  other tools process man page files that don't implement all
213       of troff's abilities.  Thus, it's best to avoid some  of  troff's  more
214       exotic  abilities  where  possible  to permit these other tools to work
215       correctly.  Avoid using the various troff preprocessors (if  you  must,
216       go  ahead and use tbl(1), but try to use the IP and TP commands instead
217       for two-column tables).  Avoid using  computations;  most  other  tools
218       can't  process them.  Use simple commands that are easy to translate to
219       other formats.  The following troff macros  are  believed  to  be  safe
220       (though  in many cases they will be ignored by translators): \", ., ad,
221       bp, br, ce, de, ds, el, ie, if, fi, ft, hy, ig, in, na, ne, nf, nh, ps,
222       so, sp, ti, tr.
223
224       You may also use many troff escape sequences (those sequences beginning
225       with \).  When you need to include the backslash  character  as  normal
226       text, use \e.  Other sequences you may use, where x or xx are any char‐
227       acters and N is any digit, include: \', \`, \-, \., \", \%, \*x, \*(xx,
228       \(xx,  \$N,  \nx,  \n(xx,  \fx,  and  \f(xx.   Avoid  using  the escape
229       sequences for drawing graphics.
230
231       Do not use the optional parameter for bp (break page).  Use only  posi‐
232       tive  values  for  sp (vertical space).  Don't define a macro (de) with
233       the same name as a macro in this or the mdoc macro package with a  dif‐
234       ferent  meaning;  it's  likely that such redefinitions will be ignored.
235       Every positive indent (in) should be paired with  a  matching  negative
236       indent  (although  you  should  be using the RS and RE macros instead).
237       The condition test (if,ie) should only have 't' or 'n'  as  the  condi‐
238       tion.  Only translations (tr) that can be ignored should be used.  Font
239       changes (ft and the \f escape sequence) should only have the values  1,
240       2,  3,  4,  R,  I, B, P, or CW (the ft command may also have no parame‐
241       ters).
242
243       If you use capabilities beyond these, check the  results  carefully  on
244       several tools.  Once you've confirmed that the additional capability is
245       safe, let the maintainer of this document know about the  safe  command
246       or sequence that should be added to this list.
247

FILES

249       /usr/share/groff/[*/]tmac/an.tmac
250       /usr/man/whatis
251

NOTES

253       By all means include full URLs (or URIs) in the text itself; some tools
254       such as man2html(1) can automatically turn them into  hypertext  links.
255       You  can also use the new URL macro to identify links to related infor‐
256       mation.    If   you   include   URLs,   use   the   full   URL   (e.g.,
257http://www.kernelnotes.org⟩)  to  ensure  that tools can automatically
258       find the URLs.
259
260       Tools processing these files should open the file and examine the first
261       nonwhitespace  character.   A  period  (.)  or  single quote (') at the
262       beginning of a line indicates a troff-based file (such as man or mdoc).
263       A left angle bracket (<) indicates an SGML/XML-based file (such as HTML
264       or Docbook).  Anything else suggests simple ASCII text (e.g.,  a  "cat‐
265       man" result).
266
267       Many man pages begin with ´\" followed by a space and a list of charac‐
268       ters, indicating how the page is to be preprocessed.  For portability's
269       sake  to  non-troff  translators we recommend that you avoid using any‐
270       thing other than tbl(1), and Linux can detect that automatically.  How‐
271       ever,  you  might want to include this information so your man page can
272       be handled by other (less capable) systems.  Here are  the  definitions
273       of the preprocessors invoked by these characters:
274
275       e  eqn(1)
276
277       g  grap(1)
278
279       p  pic(1)
280
281       r  refer(1)
282
283       t  tbl(1)
284
285       v  vgrind(1)
286

BUGS

288       Most  of  the  macros describe formatting (e.g., font type and spacing)
289       instead of marking semantic content (e.g., this text is a reference  to
290       another page), compared to formats like mdoc and DocBook (even HTML has
291       more semantic markings).  This situation makes it harder  to  vary  the
292       man format for different media, to make the formatting consistent for a
293       given media, and to automatically insert cross-references.  By sticking
294       to  the  safe  subset  described above, it should be easier to automate
295       transitioning to a different reference page format in the future.
296
297       The Sun macro TX is not implemented.
298

SEE ALSO

300       apropos(1),  groff(1),  lexgrog(1),  man(1),  man2html(1),   whatis(1),
301       groff_man(7), groff_www(7), man-pages(7), mdoc(7), mdoc.samples(7)
302

COLOPHON

304       This  page  is  part of release 3.53 of the Linux man-pages project.  A
305       description of the project, and information about reporting  bugs,  can
306       be found at http://www.kernel.org/doc/man-pages/.
307
308
309
310Linux                             2012-08-05                            MAN(7)
Impressum