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

GENERAL TEXT DOMAIN

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

PAGE STRUCTURE DOMAIN

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

PREDEFINED STRINGS

1401     The following strings are predefined as may be used by preceding with the
1402     troff string interpreting sequence ‘\*(xx’ where xx is the name of the
1403     defined string or as ‘\*x’ where x is the name of the string.  The inter‐
1404     preting sequence may be used any where in the text.
1405
1406           String     Nroff     Troff
1407           <=         <=        ≤
1408           >=         >=        ≥
1409           Rq         ''        ”
1410           Lq         ``        “
1411           ua         ^         ↑
1412           aa         '         ´
1413           ga         `         `
1414           q          "         "
1415           Pi         pi        π
1416           Ne         !=        ≠
1417           Le         <=        ≤
1418           Ge         >=        ≥
1419           Lt         <         >
1420           Gt         >         <
1421           Pm         +-        ±
1422           If         infinity  ∞
1423           Na         NaN       NaN
1424           Ba         |         |
1425
1426     Note: The string named ‘q’ should be written as ‘\*q’ since it is only
1427     one char.
1428

DIAGNOSTICS

1430     The debugging facilities for -mdoc are limited, but can help detect sub‐
1431     tle errors such as the collision of an argument name with an internal
1432     register or macro name.  (A what?)  A register is an arithmetic storage
1433     class for troff with a one or two character name.  All registers internal
1434     to -mdoc for troff and ditroff are two characters and of the form
1435     <upper_case><lower_case> such as ‘Ar’, <lower_case><upper_case> as ‘aR’
1436     or <upper or lower letter><digit> as ‘C1’.  And adding to the muddle,
1437     troff has its own internal registers all of which are either two lower
1438     case characters or a dot plus a letter or metacharacter character.  In
1439     one of the introduction examples, it was shown how to prevent the inter‐
1440     pretation of a macro name with the escape sequence ‘\&’.  This is suffi‐
1441     cient for the internal register names also.
1442
1443     If a nonescaped register name is given in the argument list of a request
1444     unpredictable behavior will occur.  In general, any time huge portions of
1445     text do not appear where expected in the output, or small strings such as
1446     list tags disappear, chances are there is a misunderstanding about an
1447     argument type in the argument list.  Your mother never intended for you
1448     to remember this evil stuff - so here is a way to find out whether or not
1449     your arguments are valid: The ‘.Db’ (debug) macro displays the interpre‐
1450     tation of the argument list for most macros.  Macros such as the ‘.Pp’
1451     (paragraph) macro do not contain debugging information.  All of the
1452     callable macros do, and it is strongly advised whenever in doubt, turn on
1453     the ‘.Db’ macro.
1454
1455           Usage: .Db [on | off]
1456
1457     An example of a portion of text with the debug macro placed above and
1458     below an artificially created problem (a flag argument ‘aC’ which should
1459     be ‘\&aC’ in order to work):
1460
1461           .Db on
1462           .Op Fl aC Ar file )
1463           .Db off
1464
1465     The resulting output:
1466
1467           DEBUGGING ON
1468           DEBUG(argv) MACRO: `.Op'  Line #: 2
1469                   Argc: 1  Argv: `Fl'  Length: 2
1470                   Space: `'  Class: Executable
1471                   Argc: 2  Argv: `aC'  Length: 2
1472                   Space: `'  Class: Executable
1473                   Argc: 3  Argv: `Ar'  Length: 2
1474                   Space: `'  Class: Executable
1475                   Argc: 4  Argv: `file'  Length: 4
1476                   Space: ` '  Class: String
1477                   Argc: 5  Argv: `)'  Length: 1
1478                   Space: ` '  Class: Closing Punctuation or suffix
1479                   MACRO REQUEST: .Op Fl aC Ar file )
1480           DEBUGGING OFF
1481
1482     The first line of information tells the name of the calling macro, here
1483     ‘.Op’, and the line number it appears on.  If one or more files are
1484     involved (especially if text from another file is included) the line num‐
1485     ber may be bogus.  If there is only one file, it should be accurate.  The
1486     second line gives the argument count, the argument (‘Fl’) and its length.
1487     If the length of an argument is two characters, the argument is tested to
1488     see if it is executable (unfortunately, any register which contains a
1489     nonzero value appears executable).  The third line gives the space allot‐
1490     ted for a class, and the class type.  The problem here is the argument aC
1491     should not be executable.  The four types of classes are string, exe‐
1492     cutable, closing punctuation and opening punctuation.  The last line
1493     shows the entire argument list as it was read.  In this next example, the
1494     offending ‘aC’ is escaped:
1495
1496           .Db on
1497           .Em An escaped \&aC
1498           .Db off
1499
1500           DEBUGGING ON
1501           DEBUG(fargv) MACRO: `.Em'  Line #: 2
1502                   Argc: 1  Argv: `An'  Length: 2
1503                   Space: ` '  Class: String
1504                   Argc: 2  Argv: `escaped'  Length: 7
1505                   Space: ` '  Class: String
1506                   Argc: 3  Argv: `aC'  Length: 2
1507                   Space: ` '  Class: String
1508                   MACRO REQUEST: .Em An escaped &aC
1509           DEBUGGING OFF
1510
1511     The argument ‘\&aC’ shows up with the same length of 2 as the ‘\&’
1512     sequence produces a zero width, but a register named ‘\&aC’ was not found
1513     and the type classified as string.
1514
1515     Other diagnostics consist of usage statements and are self explanatory.
1516

GROFF, TROFF AND NROFF

1518     The -mdoc package does not need compatibility mode with groff.
1519
1520     The package inhibits page breaks, and the headers and footers which nor‐
1521     mally occur at those breaks with nroff, to make the manual more efficient
1522     for viewing on-line.  At the moment, groff with -Tascii does eject the
1523     imaginary remainder of the page at end of file.  The inhibiting of the
1524     page breaks makes nroff'd files unsuitable for hardcopy.  There is a reg‐
1525     ister named ‘cR’ which can be set to zero in the site dependent style
1526     file /usr/src/share/tmac/doc-nroff to restore the old style behavior.
1527

FILES

1529     /usr/share/tmac/doc.tmac      manual macro package
1530     /usr/share/misc/mdoc.template
1531                                   template for writing a man page
1532     /usr/share/examples/mdoc/*    several example man pages
1533

BUGS

1535     Undesirable hyphenation on the dash of a flag argument is not yet
1536     resolved, and causes occasional mishaps in the DESCRIPTION section.
1537     (line break on the hyphen).
1538
1539     Predefined strings are not declared in documentation.
1540
1541     Section 3f has not been added to the header routines.
1542
1543     ‘.Nm’ font should be changed in NAME section.
1544
1545     ‘.Fn’ needs to have a check to prevent splitting up if the line length is
1546     too short.  Occasionally it separates the last parenthesis, and sometimes
1547     looks ridiculous if a line is in fill mode.
1548
1549     The method used to prevent header and footer page breaks (other than the
1550     initial header and footer) when using nroff occasionally places an
1551     unsightly partially filled line (blank) at the would be bottom of the
1552     page.
1553
1554     The list and display macros to not do any keeps and certainly should be
1555     able to.
1556

SEE ALSO

1558     man(1), troff(1), groff_mdoc(7), mdoc(7)
1559

COLOPHON

1561     This page is part of release 3.25 of the Linux man-pages project.  A
1562     description of the project, and information about reporting bugs, can be
1563     found at http://www.kernel.org/doc/man-pages/.
1564
1565BSD                            December 30, 1993                           BSD
Impressum