1MDOC.SAMPLES(7)      BSD Miscellaneous Information Manual      MDOC.SAMPLES(7)
2

NAME

4     mdoc.samples — tutorial sampler for writing BSD manuals with -mdoc
5

SYNOPSIS

7     man mdoc.samples
8

DESCRIPTION

10     A tutorial sampler for writing BSD manual pages with the -mdoc macro
11     package, a content-based and domain-based formatting package for
12     troff(1).  Its predecessor, the -man(7) package, addressed page layout,
13     leaving the manipulation of fonts and other typesetting details to the
14     individual author.  In -mdoc, page layout macros make up the page
15     structure domain which consists of macros for titles, section headers,
16     displays and lists.  Essentially items which affect the physical position
17     of text on a formatted page.  In addition to the page structure domain,
18     there are two more domains, the manual domain and the general text
19     domain.  The general text domain is defined as macros which perform tasks
20     such as quoting or emphasizing pieces of text.  The manual domain is
21     defined as macros that are a subset of the day to day informal language
22     used to describe commands, routines and related BSD files.  Macros in the
23     manual domain handle command names, command-line arguments and options,
24     function names, function parameters, pathnames, variables, cross refer‐
25     ences to other manual pages, and so on.  These domain items have value
26     for both the author and the future user of the manual page.  It is hoped
27     the consistency gained across the manual set will provide easier transla‐
28     tion to future documentation tools.
29
30     Throughout the UNIX manual pages, a manual entry is simply referred to as
31     a man page, regardless of actual length and without sexist intention.
32

GETTING STARTED

34     Since a tutorial document is normally read when a person desires to use
35     the material immediately, the assumption has been made that the user of
36     this document may be impatient.  The material presented in the remained
37     of this document is outlined as follows:
38
39           1.   TROFF IDIOSYNCRASIES
40                      Macro Usage.
41                      Passing Space Characters in an Argument.
42                      Trailing Blank Space Characters (a warning).
43                      Escaping Special Characters.
44
45           2.   THE ANATOMY OF A MAN PAGE
46                      A manual page template.
47
48           3.   TITLE MACROS.
49
50           4.   INTRODUCTION OF MANUAL AND GENERAL TEXT DOMAINS.
51                      What's in a name....
52                      General Syntax.
53
54           5.   MANUAL DOMAIN
55                      Addresses.
56                      Author name.
57                      Arguments.
58                      Configuration Declarations (section four only).
59                      Command Modifier.
60                      Defined Variables.
61                      Errno's (Section two only).
62                      Environment Variables.
63                      Function Argument.
64                      Function Declaration.
65                      Flags.
66                      Functions (library routines).
67                      Function Types.
68                      Interactive Commands.
69                      Names.
70                      Options.
71                      Pathnames.
72                      Variables.
73                      Cross References.
74
75           6.   GENERAL TEXT DOMAIN
76                      AT&T Macro.
77                      BSD Macro.
78                      FreeBSD Macro.
79                      UNIX Macro.
80                      Enclosure/Quoting Macros
81                                  Angle Bracket Quote/Enclosure.
82                                  Bracket Quotes/Enclosure.
83                                  Double Quote macro/Enclosure.
84                                  Parenthesis Quote/Enclosure.
85                                  Single Quotes/Enclosure.
86                                  Prefix Macro.
87                      No-Op or Normal Text Macro.
88                      No Space Macro.
89                      Section Cross References.
90                      References and Citations.
91                      Return Values (sections two and three only)
92                      Trade Names (Acronyms and Type Names).
93                      Extended  Arguments.
94
95           7.   PAGE STRUCTURE DOMAIN
96                      Section Headers.
97                      Paragraphs and Line Spacing.
98                      Keeps.
99                      Displays.
100                      Font Modes (Emphasis, Literal, and Symbolic).
101                      Lists and Columns.
102
103           8.   PREDEFINED STRINGS
104
105           9.   DIAGNOSTICS
106
107           10.  FORMATTING WITH GROFF, TROFF AND NROFF
108
109           11.  BUGS
110

TROFF IDIOSYNCRASIES

112     The -mdoc package attempts to simplify the process of writing a man page.
113     Theoretically, one should not have to learn the dirty details of troff(1)
114     to use -mdoc; however, there are a few limitations which are unavoidable
115     and best gotten out of the way.  And, too, be forewarned, this package is
116     not fast.
117
118   Macro Usage
119     As in troff(1), a macro is called by placing a ‘.’ (dot character) at the
120     beginning of a line followed by the two character name for the macro.
121     Arguments may follow the macro separated by spaces.  It is the dot char‐
122     acter at the beginning of the line which causes troff(1) to interpret the
123     next two characters as a macro name.  To place a ‘.’ (dot character) at
124     the beginning of a line in some context other than a macro invocation,
125     precede the ‘.’ (dot) with the ‘\&’ escape sequence.  The ‘\&’ translates
126     literally to a zero width space, and is never displayed in the output.
127
128     In general, troff(1) macros accept up to nine arguments, any extra argu‐
129     ments are ignored.  Most macros in -mdoc accept nine arguments and, in
130     limited cases, arguments may be continued or extended on the next line
131     (See Extensions).  A few macros handle quoted arguments (see Passing
132     Space Characters in an Argument below).
133
134     Most of the -mdoc general text domain and manual domain macros are spe‐
135     cial in that their argument lists are parsed for callable macro names.
136     This means an argument on the argument list which matches a general text
137     or manual domain macro name and is determined to be callable will be exe‐
138     cuted or called when it is processed.  In this case, the argument,
139     although the name of a macro, is not preceded by a ‘.’ (dot).  It is in
140     this manner that many macros are nested; for example the option macro,
141     ‘.Op’, may call the flag and argument macros, ‘Fl’ and ‘Ar’, to specify
142     an optional flag with an argument:
143
144           [-s bytes]         is produced by .Op Fl s Ar bytes
145
146     To prevent a two character string from being interpreted as a macro name,
147     precede the string with the escape sequence ‘\&’:
148
149           [Fl s Ar bytes]    is produced by .Op \&Fl s \&Ar bytes
150
151     Here the strings ‘Fl’ and ‘Ar’ are not interpreted as macros.  Macros
152     whose argument lists are parsed for callable arguments are referred to as
153     parsed and macros which may be called from an argument list are referred
154     to as callable throughout this document and in the companion quick refer‐
155     ence manual mdoc(7).  This is a technical faux pas as almost all of the
156     macros in -mdoc are parsed, but as it was cumbersome to constantly refer
157     to macros as being callable and being able to call other macros, the term
158     parsed has been used.
159
160   Passing Space Characters in an Argument
161     Sometimes it is desirable to give as one argument a string containing one
162     or more blank space characters.  This may be necessary to defeat the nine
163     argument limit or to specify arguments to macros which expect particular
164     arrangement of items in the argument list.  For example, the function
165     macro ‘.Fn’ expects the first argument to be the name of a function and
166     any remaining arguments to be function parameters.  As ANSI C stipulates
167     the declaration of function parameters in the parenthesized parameter
168     list, each parameter is guaranteed to be at minimum a two word string.
169     For example, int foo.
170
171     There are two possible ways to pass an argument which contains an embed‐
172     ded space.  Implementation note: Unfortunately, the most convenient way
173     of passing spaces in between quotes by reassigning individual arguments
174     before parsing was fairly expensive speed wise and space wise to imple‐
175     ment in all the macros for AT&T troff.  It is not expensive for groff but
176     for the sake of portability, has been limited to the following macros
177     which need it the most:
178
179           Cd    Configuration declaration (section 4 SYNOPSIS)
180           Bl    Begin list (for the width specifier).
181           Em    Emphasized text.
182           Fn    Functions (sections two and four).
183           It    List items.
184           Li    Literal text.
185           Sy    Symbolic text.
186           %B    Book titles.
187           %J    Journal names.
188           %O    Optional notes for a reference.
189           %R    Report title (in a reference).
190           %T    Title of article in a book or journal.
191
192     One way of passing a string containing blank spaces is to use the hard or
193     unpaddable space character ‘\ ’, that is, a blank space preceded by the
194     escape character ‘\’.  This method may be used with any macro but has the
195     side effect of interfering with the adjustment of text over the length of
196     a line.  Troff sees the hard space as if it were any other printable
197     character and cannot split the string into blank or newline separated
198     pieces as one would expect.  The method is useful for strings which are
199     not expected to overlap a line boundary.  For example:
200
201           fetch(char *str)  is created by ‘.Fn fetch char\ *str’
202
203           fetch(char *str)  can also be created by ‘.Fn fetch "char *str"’
204
205     If the ‘\’ or quotes were omitted, ‘.Fn’ would see three arguments and
206     the result would be:
207
208           fetch(char, *str)
209
210     For an example of what happens when the parameter list overlaps a newline
211     boundary, see the BUGS section.
212
213   Trailing Blank Space Characters
214     Troff can be confused by blank space characters at the end of a line.  It
215     is a wise preventive measure to globally remove all blank spaces from
216     <blank-space><end-of-line> character sequences.  Should the need arise to
217     force a blank character at the end of a line, it may be forced with an
218     unpaddable space and the ‘\&’ escape character.  For example,
219     ‘string\ \&’.
220
221   Escaping Special Characters
222     Special characters like the newline character ‘\n’, are handled by
223     replacing the ‘\’ with ‘\e’ (e.g., ‘\en’) to preserve the backslash.
224

THE ANATOMY OF A MAN PAGE

226     The body of a man page is easily constructed from a basic template found
227     in the file /usr/share/misc/mdoc.template.  Several example man pages can
228     also be found in /usr/share/examples/mdoc.
229
230   A manual page template
231           .\" The following requests are required for all man pages.
232           .Dd Month day, year
233           .Os OPERATING_SYSTEM [version/release]
234           .Dt DOCUMENT_TITLE [section number] [volume]
235           .Sh NAME
236           .Nm name
237           .Nd one line description of name
238           .Sh SYNOPSIS
239           .Sh DESCRIPTION
240           .\" The following requests should be uncommented and
241           .\" used where appropriate.  This next request is
242           .\" for sections 2 and 3 function return values only.
243           .\" .Sh RETURN VALUE
244           .\" This next request is for sections 1, 6, 7 & 8 only
245           .\" .Sh ENVIRONMENT
246           .\" .Sh FILES
247           .\" .Sh EXAMPLES
248           .\" This next request is for sections 1, 6, 7 & 8 only
249           .\"     (command return values (to shell) and
250           .\"       fprintf/stderr type diagnostics)
251           .\" .Sh DIAGNOSTICS
252           .\" The next request is for sections 2 and 3 error
253           .\" and signal handling only.
254           .\" .Sh ERRORS
255           .\" .Sh SEE ALSO
256           .\" .Sh CONFORMING TO
257           .\" .Sh HISTORY
258           .\" .Sh AUTHORS
259           .\" .Sh BUGS
260
261     The first items in the template are the macros (.Dd, .Os, .Dt); the docu‐
262     ment date, the operating system the man page or subject source is devel‐
263     oped or modified for, and the man page title (in uppercase) along with
264     the section of the manual the page belongs in.  These macros identify the
265     page, and are discussed below in TITLE MACROS.
266
267     The remaining items in the template are section headers (.Sh); of which
268     NAME, SYNOPSIS and DESCRIPTION are mandatory.  The headers are discussed
269     in PAGE STRUCTURE DOMAIN, after presentation of MANUAL DOMAIN.  Several
270     content macros are used to demonstrate page layout macros; reading about
271     content macros before page layout macros is recommended.
272

TITLE MACROS

274     The title macros are the first portion of the page structure domain, but
275     are presented first and separate for someone who wishes to start writing
276     a man page yesterday.  Three header macros designate the document title
277     or manual page title, the operating system, and the date of authorship.
278     These macros are one called once at the very beginning of the document
279     and are used to construct the headers and footers only.
280
281     .Dt DOCUMENT_TITLE section# [volume]
282             The document title is the subject of the man page and must be in
283             CAPITALS due to troff limitations.  The section number may be
284             1, ..., 8, and if it is specified, the volume title may be omit‐
285             ted.  A volume title may be arbitrary or one of the following:
286
287                   AMD    UNIX Ancestral Manual Documents
288                   SMM    UNIX System Manager's Manual
289                   URM    UNIX Reference Manual
290                   PRM    UNIX Programmer's Manual
291
292             The default volume labeling is URM for sections 1, 6, and 7; SMM
293             for section 8; PRM for sections 2, 3, 4, and 5.
294
295     .Os operating_system release#
296             The name of the operating system should be the common acronym,
297             for example, BSD or FreeBSD or ATT.  The release should be the
298             standard release nomenclature for the system specified, for exam‐
299             ple, 4.3, 4.3+Tahoe, V.3, V.4.  Unrecognized arguments are dis‐
300             played as given in the page footer.  For instance, a typical
301             footer might be:
302
303                   .Os 4.3BSD
304
305             or
306                   .Os FreeBSD 2.2
307
308             or for a locally produced set
309
310                   .Os CS Department
311
312             The Berkeley default, ‘.Os’ without an argument, has been defined
313             as BSD in the site-specific file /usr/share/tmac/mdoc/doc-common.
314             It really should default to LOCAL.  Note, if the ‘.Os’ macro is
315             not present, the bottom left corner of the page will be ugly.
316
317     .Dd month day, year
318             The date should be written formally:
319
320                   January 25, 1989
321

INTRODUCTION OF MANUAL AND GENERAL TEXT DOMAINS

323   What's in a name...
324     The manual domain macro names are derived from the day to day informal
325     language used to describe commands, subroutines and related files.
326     Slightly different variations of this language are used to describe the
327     three different aspects of writing a man page.  First, there is the
328     description of -mdoc macro request usage.  Second is the description of a
329     UNIX command with -mdoc macros and third, the description of a command to
330     a user in the verbal sense; that is, discussion of a command in the text
331     of a man page.
332
333     In the first case, troff(1) macros are themselves a type of command; the
334     general syntax for a troff command is:
335
336           .Va argument1 argument2 ... argument9
337
338     The ‘.Va’ is a macro command or request, and anything following it is an
339     argument to be processed.  In the second case, the description of a UNIX
340     command using the content macros is a bit more involved; a typical
341     SYNOPSIS command line might be displayed as:
342
343           filter [-flag] infile outfile
344
345     Here, filter is the command name and the bracketed string -flag is a flag
346     argument designated as optional by the option brackets.  In -mdoc terms,
347     infile and outfile are called arguments.  The macros which formatted the
348     above example:
349
350           .Nm filter
351           .Op Fl flag
352           .Ar infile outfile
353
354     In the third case, discussion of commands and command syntax includes
355     both examples above, but may add more detail.  The arguments infile and
356     outfile from the example above might be referred to as operands or file
357     arguments.  Some command-line argument lists are quite long:
358
359           make  [-eiknqrstv] [-D variable] [-d flags] [-f makefile]
360                 [-I directory] [-j max_jobs] [variable=value] [target ...]
361
362     Here one might talk about the command make and qualify the argument
363     makefile, as an argument to the flag, -f, or discuss the optional file
364     operand target.  In the verbal context, such detail can prevent confu‐
365     sion, however the -mdoc package does not have a macro for an argument to
366     a flag.  Instead the ‘Ar’ argument macro is used for an operand or file
367     argument like target as well as an argument to a flag like variable.  The
368     make command line was produced from:
369
370           .Nm make
371           .Op Fl eiknqrstv
372           .Op Fl D Ar variable
373           .Op Fl d Ar flags
374           .Op Fl f Ar makefile
375           .Op Fl I Ar directory
376           .Op Fl j Ar max_jobs
377           .Op Ar variable=value
378           .Bk -words
379           .Op Ar target ...
380           .Ek
381
382     The ‘.Bk’ and ‘.Ek’ macros are explained in Keeps.
383
384   General Syntax
385     The manual domain and general text domain macros share a similar syntax
386     with a few minor deviations: ‘.Ar’, ‘.Fl’, ‘.Nm’, and ‘.Pa’ differ only
387     when called without arguments; ‘.Fn’ and ‘.Xr’ impose an order on their
388     argument lists and the ‘.Op’ and ‘.Fn’ macros have nesting limitations.
389     All content macros are capable of recognizing and properly handling punc‐
390     tuation, provided each punctuation character is separated by a leading
391     space.  If a request is given:
392
393           .Li sptr, ptr),
394
395     The result is:
396
397           sptr, ptr),
398
399     The punctuation is not recognized and all is output in the literal font.
400     If the punctuation is separated by a leading white space:
401
402           .Li sptr , ptr ) ,
403
404     The result is:
405
406           sptr, ptr),
407
408     The punctuation is now recognized and is output in the default font dis‐
409     tinguishing it from the strings in literal font.
410
411     To remove the special meaning from a punctuation character escape it with
412     ‘\&’.  Troff is limited as a macro language, and has difficulty when pre‐
413     sented with a string containing a member of the mathematical, logical or
414     quotation set:
415
416                 {+,-,/,*,%,<,>,<=,>=,=,==,&,`,',"}
417
418     The problem is that troff may assume it is supposed to actually perform
419     the operation or evaluation suggested by the characters.  To prevent the
420     accidental evaluation of these characters, escape them with ‘\&’.  Typi‐
421     cal syntax is shown in the first content macro displayed below, ‘.Ad’.
422

MANUAL DOMAIN

424   Address Macro
425     The address macro identifies an address construct of the form
426     addr1[,addr2[,addr3]].
427
428           Usage: .Ad address ... [.,:;()[]?!]
429                   .Ad addr1           addr1
430                   .Ad addr1 .         addr1.
431                   .Ad addr1 , file2   addr1, file2
432                   .Ad f1 , f2 , f3 :  f1, f2, f3:
433                   .Ad addr ) ) ,      addr)),
434
435     It is an error to call ‘.Ad’ without arguments.  ‘.Ad’ is callable by
436     other macros and is parsed.
437
438   Author Name
439     The ‘.An’ macro is used to specify the name of the author of the item
440     being documented, or the name of the author of the actual manual page.
441     Any remaining arguments after the name information are assumed to be
442     punctuation.
443
444           Usage: .An author_name [.,:;()[]?!]
445                   .An Joe Author        Joe Author
446                   .An Joe Author ,      Joe Author,
447                   .An Joe Author Aq nobody@FreeBSD.ORG
448                                         Joe Author <nobody@FreeBSD.ORG>
449                   .An Joe Author ) ) ,  Joe Author)),
450
451     The ‘.An’ macro is parsed and is callable.  It is an error to call ‘.An’
452     without any arguments.
453
454   Argument Macro
455     The ‘.Ar’ argument macro may be used whenever a command-line argument is
456     referenced.
457
458           Usage: .Ar argument ... [.,:;()[]?!]
459                    .Ar              file ...
460                    .Ar file1        file1
461                    .Ar file1 .      file1.
462                    .Ar file1 file2  file1 file2
463                    .Ar f1 f2 f3 :   f1 f2 f3:
464                    .Ar file ) ) ,   file)),
465
466     If ‘.Ar’ is called without arguments, ‘Ar’ is assumed.  The ‘.Ar’ macro
467     is parsed and is callable.
468
469   Configuration Declaration (section four only)
470     The ‘.Cd’ macro is used to demonstrate a config(8) declaration for a
471     device interface in a section four manual.  This macro accepts quoted
472     arguments (double quotes only).
473
474           device le0 at scode?  produced by: ‘.Cd device le0 at scode?’.
475
476   Command Modifier
477     The command modifier is identical to the ‘.Fl’ (flag) command with the
478     exception the ‘.Cm’ macro does not assert a dash in front of every argu‐
479     ment.  Traditionally flags are marked by the preceding dash, some com‐
480     mands or subsets of commands do not use them.  Command modifiers may also
481     be specified in conjunction with interactive commands such as editor com‐
482     mands.  See Flags.
483
484   Defined Variables
485     A variable which is defined in an include file is specified by the macro
486     ‘.Dv’.
487
488           Usage: .Dv defined_variable ... [.,:;()[]?!]
489                   .Dv MAXHOSTNAMELEN  MAXHOSTNAMELEN
490                   .Dv TIOCGPGRP )     TIOCGPGRP)
491
492     It is an error to call ‘.Dv’ without arguments.  ‘.Dv’ is parsed and is
493     callable.
494
495   Errno's (Section two only)
496     The ‘.Er’ errno macro specifies the error return value for section two
497     library routines.  The second example below shows ‘.Er’ used with the
498     ‘.Bq’ general text domain macro, as it would be used in a section two
499     manual page.
500
501           Usage: .Er ERRNOTYPE ... [.,:;()[]?!]
502                   .Er ENOENT      ENOENT
503                   .Er ENOENT ) ;  ENOENT);
504                   .Bq Er ENOTDIR  [ENOTDIR]
505
506     It is an error to call ‘.Er’ without arguments.  The ‘.Er’ macro is
507     parsed and is callable.
508
509   Environment Variables
510     The ‘.Ev’ macro specifies an environment variable.
511
512           Usage: .Ev argument ... [.,:;()[]?!]
513                   .Ev DISPLAY        DISPLAY
514                   .Ev PATH .         PATH.
515                   .Ev PRINTER ) ) ,  PRINTER)),
516
517     It is an error to call ‘.Ev’ without arguments.  The ‘.Ev’ macro is
518     parsed and is callable.
519
520   Function Argument
521     The ‘.Fa’ macro is used to refer to function arguments (parameters) out‐
522     side of the SYNOPSIS section of the manual or inside the SYNOPSIS section
523     should a parameter list be too long for the ‘.Fn’ macro and the enclosure
524     macros ‘.Fo’ and ‘.Fc’ must be used.  ‘.Fa’ may also be used to refer to
525     structure members.
526
527           Usage: .Fa function_argument ... [.,:;()[]?!]
528                   .Fa d_namlen ) ) ,  d_namlen)),
529                   .Fa iov_len         iov_len
530
531     It is an error to call ‘.Fa’ without arguments.  ‘.Fa’ is parsed and is
532     callable.
533
534   Function Declaration
535     The ‘.Fd’ macro is used in the SYNOPSIS section with section two or three
536     functions.  The ‘.Fd’ macro does not call other macros and is not
537     callable by other macros.
538
539           Usage: .Fd include_file (or defined variable)
540
541     In the SYNOPSIS section a ‘.Fd’ request causes a line break if a function
542     has already been presented and a break has not occurred.  This leaves a
543     nice vertical space in between the previous function call and the decla‐
544     ration for the next function.
545
546   Flags
547     The ‘.Fl’ macro handles command-line flags.  It prepends a dash, ‘-’, to
548     the flag.  For interactive command flags, which are not prepended with a
549     dash, the ‘.Cm’ (command modifier) macro is identical, but without the
550     dash.
551
552           Usage: .Fl argument ... [.,:;()[]?!]
553                   .Fl           -
554                   .Fl cfv       -cfv
555                   .Fl cfv .     -cfv.
556                   .Fl s v t     -s -v -t
557                   .Fl - ,       --,
558                   .Fl xyz ) ,   -xyz),
559
560     The ‘.Fl’ macro without any arguments results in a dash representing
561     stdin/stdout.  Note that giving ‘.Fl’ a single dash, will result in two
562     dashes.  The ‘.Fl’ macro is parsed and is callable.
563
564   Functions (library routines)
565     The .Fn macro is modeled on ANSI C conventions.
566
567     Usage: .Fn [type] function [[type] parameters ... [ .,:;()[]?! ]]
568     .Fn getchar                             getchar()
569     .Fn strlen ) ,                          strlen()),
570     .Fn "int align" "const * char *sptrs",  int align(const * char *sptrs),
571
572     It is an error to call ‘.Fn’ without any arguments.  The ‘.Fn’ macro is
573     parsed and is callable, note that any call to another macro signals the
574     end of the ‘.Fn’ call (it will close-parenthesis at that point).
575
576     For functions that have more than eight parameters (and this is rare),
577     the macros ‘.Fo’ (function open) and ‘.Fc’ (function close) may be used
578     with ‘.Fa’ (function argument) to get around the limitation.  For exam‐
579     ple:
580
581           .Fo "int res_mkquery"
582           .Fa "int op"
583           .Fa "char *dname"
584           .Fa "int class"
585           .Fa "int type"
586           .Fa "char *data"
587           .Fa "int datalen"
588           .Fa "struct rrec *newrr"
589           .Fa "char *buf"
590           .Fa "int buflen"
591           .Fc
592
593     Produces:
594
595           int   res_mkquery(int op,   char *dname,    int class,    int type,
596           char *data, int datalen, struct rrec *newrr, char *buf, int buflen)
597
598     The ‘.Fo’ and ‘.Fc’ macros are parsed and are callable.  In the SYNOPSIS
599     section, the function will always begin at the beginning of line.  If
600     there is more than one function presented in the SYNOPSIS section and a
601     function type has not been given, a line break will occur, leaving a nice
602     vertical space between the current function name and the one prior.  At
603     the moment, ‘.Fn’ does not check its word boundaries against troff line
604     lengths and may split across a newline ungracefully.  This will be fixed
605     in the near future.
606
607   Function Type
608     This macro is intended for the SYNOPSIS section.  It may be used anywhere
609     else in the man page without problems, but its main purpose is to present
610     the function type in kernel normal form for the SYNOPSIS of sections two
611     and three (it causes a line break allowing the function name to appear on
612     the next line).
613
614           Usage: .Ft type ... [.,:;()[]?!]
615                   .Ft struct stat  struct stat
616
617     The ‘.Ft’ request is not callable by other macros.
618
619   Interactive Commands
620     The ‘.Ic’ macro designates an interactive or internal command.
621
622           Usage: .Ic argument ... [.,:;()[]?!]
623                   .Ic :wq                  :wq
624                   .Ic do while {...}       do while {...}
625                   .Ic setenv , unsetenv    setenv, unsetenv
626
627     It is an error to call ‘.Ic’ without arguments.  The ‘.Ic’ macro is
628     parsed and is callable.
629
630   Name Macro
631     The ‘.Nm’ macro is used for the document title or subject name.  It has
632     the peculiarity of remembering the first argument it was called with,
633     which should always be the subject name of the page.  When called without
634     arguments, ‘.Nm’ regurgitates this initial name for the sole purpose of
635     making less work for the author.  Note: a section two or three document
636     function name is addressed with the ‘.Nm’ in the NAME section, and with
637     ‘.Fn’ in the SYNOPSIS and remaining sections.  For interactive commands,
638     such as the ‘while’ command keyword in csh(1), the ‘.Ic’ macro should be
639     used.  While the ‘.Ic’ is nearly identical to ‘.Nm’, it can not recall
640     the first argument it was invoked with.
641
642           Usage: .Nm argument ... [.,:;()[]?!]
643                   .Nm mdoc.sample  mdoc.sample
644                   .Nm \-mdoc       -mdoc.
645                   .Nm foo ) ) ,    foo)),
646                   .Nm              mdoc.samples
647
648     The ‘.Nm’ macro is parsed and is callable.
649
650   Options
651     The ‘.Op’ macro places option brackets around the any remaining arguments
652     on the command line, and places any trailing punctuation outside the
653     brackets.  The macros ‘.Oc’ and ‘.Oo’ may be used across one or more
654     lines.
655
656           Usage: .Op options ... [.,:;()[]?!]
657           .Op                                []
658           .Op Fl k                           [-k]
659           .Op Fl k ) .                       [-k]).
660           .Op Fl k Ar kookfile               [-k kookfile]
661           .Op Fl k Ar kookfile ,             [-k kookfile],
662           .Op Ar objfil Op Ar corfil         [objfil [corfil]]
663           .Op Fl c Ar objfil Op Ar corfil ,  [-c objfil [corfil]],
664           .Op word1 word2                    [word1 word2]
665
666     The ‘.Oc’ and ‘.Oo’ macros:
667
668           .Oo
669           .Op Fl k Ar kilobytes
670           .Op Fl i Ar interval
671           .Op Fl c Ar count
672           .Oc
673
674     Produce: [[-k kilobytes] [-i interval] [-c count]]
675
676     The macros ‘.Op’, ‘.Oc’ and ‘.Oo’ are parsed and are callable.
677
678   Pathnames
679     The ‘.Pa’ macro formats pathnames or filenames.
680
681           Usage: .Pa pathname [.,:;()[]?!]
682                   .Pa /usr/share         /usr/share
683                   .Pa /tmp/fooXXXXX ) .  /tmp/fooXXXXX).
684
685     The ‘.Pa’ macro is parsed and is callable.
686
687   Variables
688     Generic variable reference:
689
690           Usage: .Va variable ... [.,:;()[]?!]
691                   .Va count           count
692                   .Va settimer,       settimer,
693                   .Va int *prt ) :    int *prt):
694                   .Va char s ] ) ) ,  char s])),
695
696     It is an error to call ‘.Va’ without any arguments.  The ‘.Va’ macro is
697     parsed and is callable.
698
699   Manual Page Cross References
700     The ‘.Xr’ macro expects the first argument to be a manual page name, and
701     the second argument, if it exists, to be either a section page number or
702     punctuation.  Any remaining arguments are assumed to be punctuation.
703
704           Usage: .Xr man_page [1,...,8] [.,:;()[]?!]
705                   .Xr mdoc          mdoc
706                   .Xr mdoc ,        mdoc,
707                   .Xr mdoc 7        mdoc(7)
708                   .Xr mdoc 7 ) ) ,  mdoc(7))),
709
710     The ‘.Xr’ macro is parsed and is callable.  It is an error to call ‘.Xr’
711     without any arguments.
712

GENERAL TEXT DOMAIN

714   AT&T Macro
715           Usage: .At [v6 | v7 | 32v | V.1 | V.4] ... [ .,:;()[]?! ]
716                   .At         AT&T UNIX
717                   .At v6 .    Version 6 AT&T UNIX.
718
719     The ‘.At’ macro is not parsed and not callable It accepts at most two
720     arguments.
721
722   BSD Macro
723           Usage: .Bx [Version/release] ... [.,:;()[]?!]
724                   .Bx          BSD
725                   .Bx 4.3 .    4.3BSD.
726
727     The ‘.Bx’ macro is parsed and is callable.
728
729   FreeBSD Macro
730           Usage: .Fx Version.release ... [ .,:;()[]?! ]
731                   .Fx 2.2 .    FreeBSD 2.2.
732
733     The ‘.Fx’ macro is not parsed and not callable It accepts at most two
734     arguments.
735
736   UNIX Macro
737           Usage: .Ux ... [.,:;()[]?!]
738                   .Ux          UNIX
739
740     The ‘.Ux’ macro is parsed and is callable.
741
742   Enclosure and Quoting Macros
743     The concept of enclosure is similar to quoting.  The object being to
744     enclose one or more strings between a pair of characters like quotes or
745     parentheses.  The terms quoting and enclosure are used interchangeably
746     throughout this document.  Most of the one line enclosure macros end in
747     small letter ‘q’ to give a hint of quoting, but there are a few irregu‐
748     larities.  For each enclosure macro there is also a pair of open and
749     close macros which end in small letters ‘o’ and ‘c’ respectively.  These
750     can be used across one or more lines of text and while they have nesting
751     limitations, the one line quote macros can be used inside of them.
752
753            Quote    Close    Open   Function                  Result
754           .Aq      .Ac      .Ao     Angle Bracket Enclosure   <string>
755           .Bq      .Bc      .Bo     Bracket Enclosure         [string]
756           .Dq      .Dc      .Do     Double Quote              ``string''
757                    .Ec      .Eo     Enclose String (in XX)    XXstringXX
758           .Pq      .Pc      .Po     Parenthesis Enclosure     (string)
759           .Ql                       Quoted Literal            `st' or string
760           .Qq      .Qc      .Qo     Straight Double Quote     "string"
761           .Sq      .Sc      .So     Single Quote              `string'
762
763     Except for the irregular macros noted below, all of the quoting macros
764     are parsed and callable.  All handle punctuation properly, as long as it
765     is presented one character at a time and separated by spaces.  The quot‐
766     ing macros examine opening and closing punctuation to determine whether
767     it comes before or after the enclosing string This makes some nesting
768     possible.
769
770     .Ec, .Eo  These macros expect the first argument to be the opening and
771               closing strings respectively.
772
773     .Ql       The quoted literal macro behaves differently for troff than
774               nroff.  If formatted with nroff, a quoted literal is always
775               quoted.  If formatted with troff, an item is quoted only if the
776               width of the item is less than three constant width characters.
777               This is to make short strings more visible where the font
778               change to literal (constant width) is less noticeable.
779
780     .Pf       The prefix macro is not callable, but it is parsed:
781
782                     .Pf ( Fa name2
783                              becomes (name2.
784
785               The ‘.Ns’ (no space) macro performs the analogous suffix func‐
786               tion.
787
788     Examples of quoting:
789           .Aq                         ⟨⟩
790           .Aq Ar ctype.h ) ,          ⟨ctype.h⟩),
791           .Bq                         []
792           .Bq Em Greek , French .     [Greek, French].
793           .Dq                         “”
794           .Dq string abc .            “string abc”.
795           .Dq ´^[A-Z]´                “´^[A-Z]´”
796           .Ql man mdoc                ‘man mdoc’
797           .Qq                         ""
798           .Qq string ) ,              "string"),
799           .Qq string Ns ),            "string),"
800           .Sq                         ‘’
801           .Sq string                  ‘string’
802
803     For a good example of nested enclosure macros, see the ‘.Op’ option
804     macro.  It was created from the same underlying enclosure macros as those
805     presented in the list above.  The ‘.Xo’ and ‘.Xc’ extended argument list
806     macros were also built from the same underlying routines and are a good
807     example of -mdoc macro usage at its worst.
808
809   No-Op or Normal Text Macro
810     The macro ‘.No’ is a hack for words in a macro command line which should
811     not be formatted and follows the conventional syntax for content macros.
812
813   Space Macro
814     The ‘.Ns’ macro eliminates unwanted spaces in between macro requests.  It
815     is useful for old style argument lists where there is no space between
816     the flag and argument:
817
818           .Op Fl I Ns Ar directory    produces [-Idirectory]
819
820     Note: the ‘.Ns’ macro always invokes the ‘.No’ macro after eliminating
821     the space unless another macro name follows it.  The macro ‘.Ns’ is
822     parsed and is callable.
823
824   Section Cross References
825     The ‘.Sx’ macro designates a reference to a section header within the
826     same document.  It is parsed and is callable.
827
828                   .Sx FILES     FILES
829
830   References and Citations
831     The following macros make a modest attempt to handle references.  At
832     best, the macros make it convenient to manually drop in a subset of refer
833     style references.
834
835           .Rs     Reference Start.  Causes a line break and begins collection
836                   of reference information until the reference end macro is
837                   read.
838           .Re     Reference End.  The reference is printed.
839           .%A     Reference author name, one name per invocation.
840           .%B     Book title.
841           .%C     City/place.
842           .%D     Date.
843           .%J     Journal name.
844           .%N     Issue number.
845           .%O     Optional information.
846           .%P     Page number.
847           .%R     Report name.
848           .%T     Title of article.
849           .%V     Volume(s).
850
851     The macros beginning with ‘%’ are not callable, and are parsed only for
852     the trade name macro which returns to its caller.  (And not very pre‐
853     dictably at the moment either.)  The purpose is to allow trade names to
854     be pretty printed in troff/ditroff output.
855
856   Return Values
857     The ‘.Rv’ macro generates text for use in the RETURN VALUE section.
858
859           Usage: .Rv [-std function]
860
861     ‘.Rv -std atexit’ will generate the following text:
862
863     The atexit() function returns the value 0 if successful; otherwise the
864     value -1 is returned and the global variable errno is set to indicate the
865     error.
866
867     The -std option is valid only for manual page sections 2 and 3.
868
869   Trade Names (or Acronyms and Type Names)
870     The trade name macro is generally a small caps macro for all uppercase
871     words longer than two characters.
872
873           Usage: .Tn symbol ... [.,:;()[]?!]
874                   .Tn DEC    DEC
875                   .Tn ASCII  ASCII
876
877     The ‘.Tn’ macro is parsed and is callable by other macros.
878
879   Extended Arguments
880     The ‘.Xo’ and ‘.Xc’ macros allow one to extend an argument list on a
881     macro boundary.  Argument lists cannot be extended within a macro which
882     expects all of its arguments on one line such as ‘.Op’.
883
884     Here is an example of ‘.Xo’ using the space mode macro to turn spacing
885     off:
886
887           .Sm off
888           .It Xo Sy I Ar operation
889           .No \en Ar count No \en
890           .Xc
891           .Sm on
892
893     Produces
894
895           Ioperation\ncount\n
896
897     Another one:
898
899           .Sm off
900           .It Cm S No / Ar old_pattern Xo
901           .No / Ar new_pattern
902           .No / Op Cm g
903           .Xc
904           .Sm on
905
906     Produces
907
908           S/old_pattern/new_pattern/[g]
909
910     Another example of ‘.Xo’ and using enclosure macros: Test the value of a
911     variable.
912
913           .It Xo
914           .Ic .ifndef
915           .Oo \&! Oc Ns Ar variable
916           .Op Ar operator variable ...
917           .Xc
918
919     Produces
920
921           .ifndef [!]variable [operator variable ...]
922
923     All of the above examples have used the ‘.Xo’ macro on the argument list
924     of the ‘.It’ (list-item) macro.  The extend macros are not used very
925     often, and when they are it is usually to extend the list-item argument
926     list.  Unfortunately, this is also where the extend macros are the most
927     finicky.  In the first two examples, spacing was turned off; in the
928     third, spacing was desired in part of the output but not all of it.  To
929     make these macros work in this situation make sure the ‘.Xo’ and ‘.Xc’
930     macros are placed as shown in the third example.  If the ‘.Xo’ macro is
931     not alone on the ‘.It’ argument list, spacing will be unpredictable.  The
932     ‘.Ns’ (no space macro) must not occur as the first or last macro on a
933     line in this situation.  Out of 900 manual pages (about 1500 actual
934     pages) currently released with BSD only fifteen use the ‘.Xo’ macro.
935

PAGE STRUCTURE DOMAIN

937   Section Headers
938     The first three ‘.Sh’ section header macros list below are required in
939     every man page.  The remaining section headers are recommended at the
940     discretion of the author writing the manual page.  The ‘.Sh’ macro can
941     take up to nine arguments.  It is parsed and but is not callable.
942
943     .Sh NAME      The ‘.Sh NAME’ macro is mandatory.  If not specified, the
944                   headers, footers and page layout defaults will not be set
945                   and things will be rather unpleasant.  The NAME section
946                   consists of at least three items.  The first is the ‘.Nm’
947                   name macro naming the subject of the man page.  The second
948                   is the Name Description macro, ‘.Nd’, which separates the
949                   subject name from the third item, which is the description.
950                   The description should be the most terse and lucid possi‐
951                   ble, as the space available is small.
952
953     .Sh SYNOPSIS  The SYNOPSIS section describes the typical usage of the
954                   subject of a man page.  The macros required are either
955                   ‘.Nm’, ‘.Cd’, ‘.Fn’, (and possibly ‘.Fo’, ‘.Fc’, ‘.Fd’,
956                   ‘.Ft’ macros).  The function name macro ‘.Fn’ is required
957                   for manual page sections 2 and 3, the command and general
958                   name macro ‘.Nm’ is required for sections 1, 5, 6, 7, 8.
959                   Section 4 manuals require a ‘.Nm’, ‘.Fd’ or a ‘.Cd’ config‐
960                   uration device usage macro.  Several other macros may be
961                   necessary to produce the synopsis line as shown below:
962
963           cat [-benstuv] [-] file ...
964
965     The following macros were used:
966
967           .Nm cat
968           .Op Fl benstuv
969           .Op Fl
970           .Ar
971
972     Note: The macros ‘.Op’, ‘.Fl’, and ‘.Ar’ recognize the pipe bar character
973     ‘|’, so a command line such as:
974
975           .Op Fl a | Fl b
976
977     will not go orbital.  Troff normally interprets a | as a special opera‐
978     tor.  See PREDEFINED STRINGS for a usable | character in other situa‐
979     tions.
980
981     .Sh DESCRIPTION
982                   In most cases the first text in the DESCRIPTION section is
983                   a brief paragraph on the command, function or file, fol‐
984                   lowed by a lexical list of options and respective explana‐
985                   tions.  To create such a list, the ‘.Bl’ begin-list, ‘.It’
986                   list-item and ‘.El’ end-list macros are used (see Lists and
987                   Columns below).
988
989     The following ‘.Sh’ section headers are part of the preferred manual page
990     layout and must be used appropriately to maintain consistency.  They are
991     listed in the order in which they would be used.
992
993     .Sh ENVIRONMENT
994               The ENVIRONMENT section should reveal any related environment
995               variables and clues to their behavior and/or usage.
996
997     .Sh EXAMPLES
998               There are several ways to create examples.  See the EXAMPLES
999               section below for details.
1000
1001     .Sh FILES
1002               Files which are used or created by the man page subject should
1003               be listed via the ‘.Pa’ macro in the FILES section.
1004
1005     .Sh SEE ALSO
1006               References to other material on the man page topic and cross
1007               references to other relevant man pages should be placed in the
1008               SEE ALSO section.  Cross references are specified using the
1009               ‘.Xr’ macro.  Cross references in the SEE ALSO section should
1010               be sorted by section number, and then placed in alphabetical
1011               order and comma separated.  For example:
1012
1013               ls(1), ps(1), group(5), passwd(5).
1014
1015               At this time refer(1) style references are not accommodated.
1016
1017     .Sh CONFORMING TO
1018               If the command, library function or file adheres to a specific
1019               implementation such as IEEE Std 1003.2 (“POSIX.2”) or ANSI
1020               X3.159-1989 (“ANSI C89”) this should be noted here.  If the
1021               command does not adhere to any standard, its history should be
1022               noted in the HISTORY section.
1023
1024     .Sh HISTORY
1025               Any command which does not adhere to any specific standards
1026               should be outlined historically in this section.
1027
1028     .Sh AUTHORS
1029               Credits, if need be, should be placed here.
1030
1031     .Sh DIAGNOSTICS
1032               Diagnostics from a command should be placed in this section.
1033
1034     .Sh ERRORS
1035               Specific error handling, especially from library functions (man
1036               page sections 2 and 3) should go here.  The ‘.Er’ macro is used
1037               to specify an errno.
1038
1039     .Sh BUGS  Blatant problems with the topic go here...
1040
1041     User specified ‘.Sh’ sections may be added, for example, this section was
1042     set with:
1043
1044                   .Sh PAGE STRUCTURE DOMAIN
1045
1046   Paragraphs and Line Spacing.
1047     .Pp     The ‘.Pp’ paragraph command may be used to specify a line space
1048             where necessary.  The macro is not necessary after a ‘.Sh’ or
1049             ‘.Ss’ macro or before a ‘.Bl’ macro.  (The ‘.Bl’ macro asserts a
1050             vertical distance unless the -compact flag is given).
1051
1052   Keeps
1053     The only keep that is implemented at this time is for words.  The macros
1054     are ‘.Bk’ (begin-keep) and ‘.Ek’ (end-keep).  The only option that ‘.Bk’
1055     accepts is -words and is useful for preventing line breaks in the middle
1056     of options.  In the example for the make command-line arguments (see
1057     What's in a name), the keep prevented nroff from placing up the flag and
1058     the argument on separate lines.  (Actually, the option macro used to pre‐
1059     vent this from occurring, but was dropped when the decision (religious)
1060     was made to force right justified margins in troff as options in general
1061     look atrocious when spread across a sparse line.  More work needs to be
1062     done with the keep macros, a -line option needs to be added.)
1063
1064   Examples and Displays
1065     There are five types of displays, a quickie one line indented display
1066     ‘.D1’, a quickie one line literal display ‘.Dl’, and a block literal,
1067     block filled and block ragged which use the ‘.Bd’ begin-display and ‘.Ed’
1068     end-display macros.
1069
1070     .D1    (D-one) Display one line of indented text.  This macro is parsed,
1071            but it is not callable.
1072
1073                  -ldghfstru
1074
1075            The above was produced by: .Dl -ldghfstru.
1076
1077     .Dl    (D-ell) Display one line of indented literal text.  The ‘.Dl’
1078            example macro has been used throughout this file.  It allows the
1079            indent (display) of one line of text.  Its default font is set to
1080            constant width (literal) however it is parsed and will recognized
1081            other macros.  It is not callable however.
1082
1083                  % ls -ldg /usr/local/bin
1084
1085            The above was produced by .Dl % ls -ldg /usr/local/bin.
1086
1087     .Bd    Begin-display.  The ‘.Bd’ display must be ended with the ‘.Ed’
1088            macro.  Displays may be nested within displays and lists.  ‘.Bd’
1089            has the following syntax:
1090
1091                  .Bd display-type [-offset offset_value] [-compact]
1092
1093            The display-type must be one of the following four types and may
1094            have an offset specifier for indentation: ‘.Bd’.
1095
1096     -ragged           Display a block of text as typed, right (and left) mar‐
1097                       gin edges are left ragged.
1098     -filled           Display a filled (formatted) block.  The block of text
1099                       is formatted (the edges are filled - not left unjusti‐
1100                       fied).
1101     -literal          Display a literal block, useful for source code or sim‐
1102                       ple tabbed or spaced text.
1103     -file file_name   The filename following the -file flag is read and dis‐
1104                       played.  Literal mode is asserted and tabs are set at 8
1105                       constant width character intervals, however any
1106                       troff/-mdoc commands in file will be processed.
1107     -offset string    If -offset is specified with one of the following
1108                       strings, the string is interpreted to indicate the
1109                       level of indentation for the forthcoming block of text:
1110
1111                       left        Align block on the current left margin,
1112                                   this is the default mode of ‘.Bd’.
1113                       center      Supposedly center the block.  At this time
1114                                   unfortunately, the block merely gets left
1115                                   aligned about an imaginary center margin.
1116                       indent      Indents by one default indent value or tab.
1117                                   The default indent value is also used for
1118                                   the ‘.D1’ display so one is guaranteed the
1119                                   two types of displays will line up.  This
1120                                   indent is normally set to 6n or about two
1121                                   thirds of an inch (six constant width char‐
1122                                   acters).
1123                       indent-two  Indents two times the default indent value.
1124                       right       This left aligns the block about two inches
1125                                   from the right side of the page.  This
1126                                   macro needs work and perhaps may never do
1127                                   the right thing by troff.
1128     .Ed               End-display.
1129
1130   Font Modes
1131     There are five macros for changing the appearance of the manual page
1132     text:
1133
1134     .Em    Text may be stressed or emphasized with the ‘.Em’ macro.  The
1135            usual font for emphasis is italic.
1136
1137                  Usage: .Em argument ... [.,:;()[]?!]
1138                          .Em does not          does not
1139                          .Em exceed 1024 .     exceed 1024.
1140                          .Em vide infra ) ) ,  vide infra)),
1141
1142            The ‘.Em’ macro is parsed and is callable.  It is an error to call
1143            ‘.Em’ without arguments.
1144
1145     .Li    The ‘.Li’ literal macro may be used for special characters, vari‐
1146            able constants, anything which should be displayed as it would be
1147            typed.
1148
1149                  Usage: .Li argument ... [.,:;()[]?!]
1150                          .Li \en          \n
1151                          .Li M1 M2 M3 ;   M1 M2 M3;
1152                          .Li cntrl-D ) ,  cntrl-D),
1153                          .Li 1024 ...     1024 ...
1154
1155            The ‘.Li’ macro is parsed and is callable.
1156
1157     .Sy    The symbolic emphasis macro is generally a boldface macro in
1158            either the symbolic sense or the traditional English usage.
1159
1160                  Usage: .Sy symbol ... [.,:;()[]?!]
1161                          .Sy Important Notice   Important Notice
1162
1163                                                 The ‘.Sy’ macro is parsed and
1164                                                 is callable.  Arguments to
1165                                                 ‘.Sy’ may be quoted.
1166
1167     .Bf    Begin font mode.  The ‘.Bf’ font mode must be ended with the ‘.Ef’
1168            macro.  Font modes may be nested within other font modes.  ‘.Bf’
1169            has the following syntax:
1170
1171                  .Bf font-mode
1172
1173            The font-mode must be one of the following three types: ‘.Bf’.
1174
1175            Em | -emphasis    Same as if the ‘.Em’ macro was used for the
1176                              entire block of text.
1177            Li | -literal     Same as if the ‘.Li’ macro was used for the
1178                              entire block of text.
1179            Sy | -symbolic    Same as if the ‘.Sy’ macro was used for the
1180                              entire block of text.
1181
1182     .Ef    End font mode.
1183
1184   Tagged Lists and Columns
1185     There are several types of lists which may be initiated with the ‘.Bl’
1186     begin-list macro.  Items within the list are specified with the ‘.It’
1187     item macro and each list must end with the ‘.El’ macro.  Lists may be
1188     nested within themselves and within displays.  Columns may be used inside
1189     of lists, but lists are unproven inside of columns.
1190
1191     In addition, several list attributes may be specified such as the width
1192     of a tag, the list offset, and compactness (blank lines between items
1193     allowed or disallowed).  Most of this document has been formatted with a
1194     tag style list (-tag).  For a change of pace, the list-type used to
1195     present the list-types is an over-hanging list (-ohang).  This type of
1196     list is quite popular with TeX users, but might look a bit funny after
1197     having read many pages of tagged lists.  The following list types are
1198     accepted by ‘.Bl’:
1199
1200     -bullet
1201     -item
1202     -enum
1203     These three are the simplest types of lists.  Once the ‘.Bl’ macro has
1204     been given, items in the list are merely indicated by a line consisting
1205     solely of the ‘.It’ macro.  For example, the source text for a simple
1206     enumerated list would look like:
1207
1208                 .Bl -enum -compact
1209                 .It
1210                 Item one goes here.
1211                 .It
1212                 And item two here.
1213                 .It
1214                 Lastly item three goes here.
1215                 .El
1216
1217     The results:
1218
1219               1.   Item one goes here.
1220               2.   And item two here.
1221               3.   Lastly item three goes here.
1222
1223     A simple bullet list construction:
1224
1225                 .Bl -bullet -compact
1226                 .It
1227                 Bullet one goes here.
1228                 .It
1229                 Bullet two here.
1230                 .El
1231
1232     Produces:
1233               ·   Bullet one goes here.
1234               ·   Bullet two here.
1235
1236     -tag
1237     -diag
1238     -hang
1239     -ohang
1240     -inset
1241     These list-types collect arguments specified with the ‘.It’ macro and
1242     create a label which may be inset into the forthcoming text, hanged from
1243     the forthcoming text, overhanged from above and not indented or tagged.
1244     This list was constructed with the ‘Fl ohang’ list-type.  The ‘.It’ macro
1245     is parsed only for the inset, hang and tag list-types and is not
1246     callable.  Here is an example of inset labels:
1247
1248           Tag The tagged list (also called a tagged paragraph) is the most
1249           common type of list used in the Berkeley manuals.
1250
1251           Diag Diag lists create section four diagnostic lists and are simi‐
1252           lar to inset lists except callable macros are ignored.
1253
1254           Hang Hanged labels are a matter of taste.
1255
1256           Ohang Overhanging labels are nice when space is constrained.
1257
1258           Inset Inset labels are useful for controlling blocks of paragraphs
1259           and are valuable for converting -mdoc manuals to other formats.
1260
1261     Here is the source text which produced the above example:
1262
1263           .Bl -inset -offset indent
1264           .It Em Tag
1265           The tagged list (also called a tagged paragraph) is the
1266           most common type of list used in the Berkeley manuals.
1267           .It Em Diag
1268           Diag lists create section four diagnostic lists
1269           and are similar to inset lists except callable
1270           macros are ignored.
1271           .It Em Hang
1272           Hanged labels are a matter of taste.
1273           .It Em Ohang
1274           Overhanging labels are nice when space is constrained.
1275           .It Em Inset
1276           Inset labels are useful for controlling blocks of
1277           paragraphs and are valuable for converting
1278           .Nm -mdoc
1279           manuals to other formats.
1280           .El
1281
1282     Here is a hanged list with two items:
1283
1284           Hanged  labels appear similar to tagged lists when the label is
1285                   smaller than the label width.
1286
1287           Longer hanged list labels blend in to the paragraph unlike tagged
1288                   paragraph labels.
1289
1290     And the unformatted text which created it:
1291
1292           .Bl -hang -offset indent
1293           .It Em Hanged
1294           labels appear similar to tagged lists when the
1295           label is smaller than the label width.
1296           .It Em Longer hanged list labels
1297           blend in to the paragraph unlike
1298           tagged paragraph labels.
1299           .El
1300
1301     The tagged list which follows uses an optional width specifier to control
1302     the width of the tag.
1303
1304           SL      sleep time of the process (seconds blocked)
1305           PAGEIN  number of disk I/O's resulting from references by the
1306                   process to pages not loaded in core.
1307           UID     numerical user-id of process owner
1308           PPID    numerical ID of parent of process process priority (nonpos‐
1309                   itive when in noninterruptible wait)
1310
1311     The raw text:
1312
1313           .Bl -tag -width "PAGEIN" -compact -offset indent
1314           .It SL
1315           sleep time of the process (seconds blocked)
1316           .It PAGEIN
1317           number of disk
1318           .Tn I/O Ns 's
1319           resulting from references
1320           by the process to pages not loaded in core.
1321           .It UID
1322           numerical user ID of process owner
1323           .It PPID
1324           numerical ID of parent of process process priority
1325           (nonpositive when in noninterruptible wait)
1326           .El
1327
1328     Acceptable width specifiers:
1329
1330           -width Fl     sets the width to the default width for a flag.  All
1331                         callable macros have a default width value.  The
1332                         ‘.Fl’, value is presently set to ten constant width
1333                         characters or about five sixth of an inch.
1334
1335           -width 24n    sets the width to 24 constant width characters or
1336                         about two inches.  The ‘n’ is absolutely necessary
1337                         for the scaling to work correctly.
1338
1339           -width ENAMETOOLONG
1340                         sets width to the constant width length of the string
1341                         given.
1342
1343           -width "int mkfifo"
1344                         again, the width is set to the constant width of the
1345                         string given.
1346
1347     If a width is not specified for the tag list type, the first time ‘.It’
1348     is invoked, an attempt is made to determine an appropriate width.  If the
1349     first argument to ‘.It’ is a callable macro, the default width for that
1350     macro will be used as if the macro name had been supplied as the width.
1351     However, if another item in the list is given with a different callable
1352     macro name, a new and nested list is assumed.
1353

PREDEFINED STRINGS

1355     The following strings are predefined as may be used by preceding with the
1356     troff string interpreting sequence ‘\*(xx’ where xx is the name of the
1357     defined string or as ‘\*x’ where x is the name of the string.  The inter‐
1358     preting sequence may be used any where in the text.
1359
1360           String     Nroff     Troff
1361           <=         <=        ≤
1362           >=         >=        ≥
1363           Rq         ''        ”
1364           Lq         ``        “
1365           ua         ^         ↑
1366           aa         '         ´
1367           ga         `         `
1368           q          "         "
1369           Pi         pi        π
1370           Ne         !=        ≠
1371           Le         <=        ≤
1372           Ge         >=        ≥
1373           Lt         <         >
1374           Gt         >         <
1375           Pm         +-        ±
1376           If         infinity  ∞
1377           Na         NaN       NaN
1378           Ba         |         |
1379
1380     Note: The string named ‘q’ should be written as ‘\*q’ since it is only
1381     one char.
1382

DIAGNOSTICS

1384     The debugging facilities for -mdoc are limited, but can help detect sub‐
1385     tle errors such as the collision of an argument name with an internal
1386     register or macro name.  (A what?)  A register is an arithmetic storage
1387     class for troff with a one or two character name.  All registers internal
1388     to -mdoc for troff and ditroff are two characters and of the form
1389     <upper_case><lower_case> such as ‘Ar’, <lower_case><upper_case> as ‘aR’
1390     or <upper or lower letter><digit> as ‘C1’.  And adding to the muddle,
1391     troff has its own internal registers all of which are either two lower‐
1392     case characters or a dot plus a letter or metacharacter character.  In
1393     one of the introduction examples, it was shown how to prevent the inter‐
1394     pretation of a macro name with the escape sequence ‘\&’.  This is suffi‐
1395     cient for the internal register names also.
1396
1397     If a nonescaped register name is given in the argument list of a request,
1398     unpredictable behavior will occur.  In general, any time huge portions of
1399     text do not appear where expected in the output, or small strings such as
1400     list tags disappear, chances are there is a misunderstanding about an
1401     argument type in the argument list.  Your mother never intended for you
1402     to remember this evil stuff - so here is a way to find out whether or not
1403     your arguments are valid: The ‘.Db’ (debug) macro displays the interpre‐
1404     tation of the argument list for most macros.  Macros such as the ‘.Pp’
1405     (paragraph) macro do not contain debugging information.  All of the
1406     callable macros do, and it is strongly advised whenever in doubt, turn on
1407     the ‘.Db’ macro.
1408
1409           Usage: .Db [on | off]
1410
1411     An example of a portion of text with the debug macro placed above and
1412     below an artificially created problem (a flag argument ‘aC’ which should
1413     be ‘\&aC’ in order to work):
1414
1415           .Db on
1416           .Op Fl aC Ar file )
1417           .Db off
1418
1419     The resulting output:
1420
1421           DEBUGGING ON
1422           DEBUG(argv) MACRO: `.Op'  Line #: 2
1423                   Argc: 1  Argv: `Fl'  Length: 2
1424                   Space: `'  Class: Executable
1425                   Argc: 2  Argv: `aC'  Length: 2
1426                   Space: `'  Class: Executable
1427                   Argc: 3  Argv: `Ar'  Length: 2
1428                   Space: `'  Class: Executable
1429                   Argc: 4  Argv: `file'  Length: 4
1430                   Space: ` '  Class: String
1431                   Argc: 5  Argv: `)'  Length: 1
1432                   Space: ` '  Class: Closing Punctuation or suffix
1433                   MACRO REQUEST: .Op Fl aC Ar file )
1434           DEBUGGING OFF
1435
1436     The first line of information tells the name of the calling macro, here
1437     ‘.Op’, and the line number it appears on.  If one or more files are
1438     involved (especially if text from another file is included), the line
1439     number may be bogus.  If there is only one file, it should be accurate.
1440     The second line gives the argument count, the argument (‘Fl’) and its
1441     length.  If the length of an argument is two characters, the argument is
1442     tested to see if it is executable (unfortunately, any register which con‐
1443     tains a nonzero value appears executable).  The third line gives the
1444     space allotted for a class, and the class type.  The problem here is the
1445     argument aC should not be executable.  The four types of classes are
1446     string, executable, closing punctuation and opening punctuation.  The
1447     last line shows the entire argument list as it was read.  In this next
1448     example, the offending ‘aC’ is escaped:
1449
1450           .Db on
1451           .Em An escaped \&aC
1452           .Db off
1453
1454           DEBUGGING ON
1455           DEBUG(fargv) MACRO: `.Em'  Line #: 2
1456                   Argc: 1  Argv: `An'  Length: 2
1457                   Space: ` '  Class: String
1458                   Argc: 2  Argv: `escaped'  Length: 7
1459                   Space: ` '  Class: String
1460                   Argc: 3  Argv: `aC'  Length: 2
1461                   Space: ` '  Class: String
1462                   MACRO REQUEST: .Em An escaped &aC
1463           DEBUGGING OFF
1464
1465     The argument ‘\&aC’ shows up with the same length of 2 as the ‘\&’
1466     sequence produces a zero width, but a register named ‘\&aC’ was not found
1467     and the type classified as string.
1468
1469     Other diagnostics consist of usage statements and are self explanatory.
1470

GROFF, TROFF AND NROFF

1472     The -mdoc package does not need compatibility mode with groff.
1473
1474     The package inhibits page breaks, and the headers and footers which nor‐
1475     mally occur at those breaks with nroff, to make the manual more efficient
1476     for viewing on-line.  At the moment, groff with -Tascii does eject the
1477     imaginary remainder of the page at end of file.  The inhibiting of the
1478     page breaks makes nroff'd files unsuitable for hardcopy.  There is a reg‐
1479     ister named ‘cR’ which can be set to zero in the site dependent style
1480     file /usr/src/share/tmac/doc-nroff to restore the old style behavior.
1481

FILES

1483     /usr/share/tmac/doc.tmac      manual macro package
1484     /usr/share/misc/mdoc.template
1485                                   template for writing a man page
1486     /usr/share/examples/mdoc/*    several example man pages
1487

BUGS

1489     Undesirable hyphenation on the dash of a flag argument is not yet
1490     resolved, and causes occasional mishaps in the DESCRIPTION section.
1491     (line break on the hyphen).
1492
1493     Predefined strings are not declared in documentation.
1494
1495     Section 3f has not been added to the header routines.
1496
1497     ‘.Nm’ font should be changed in NAME section.
1498
1499     ‘.Fn’ needs to have a check to prevent splitting up if the line length is
1500     too short.  Occasionally it separates the last parenthesis, and sometimes
1501     looks ridiculous if a line is in fill mode.
1502
1503     The method used to prevent header and footer page breaks (other than the
1504     initial header and footer) when using nroff occasionally places an
1505     unsightly partially filled line (blank) at the would be bottom of the
1506     page.
1507
1508     The list and display macros to not do any keeps and certainly should be
1509     able to.
1510

SEE ALSO

1512     man(1), troff(1), groff_mdoc(7), mdoc(7)
1513

COLOPHON

1515     This page is part of release 4.15 of the Linux man-pages project.  A
1516     description of the project, information about reporting bugs, and the
1517     latest version of this page, can be found at
1518     https://www.kernel.org/doc/man-pages/.
1519
1520BSD                            December 30, 1993                           BSD
Impressum