* doc/groff.texinfo: Further checking/updating. Adding more index entries.
[s-roff.git] / tmac / groff_mdoc.samples.man
blobcdbbc21c4f6dfb51d3ab92bf5112fa5fdaf4ad22
1 .\"     $NetBSD: mdoc.samples.7,v 1.21 1999/08/23 21:54:20 ross Exp $
2 .\"
3 .\" Copyright (c) 1990, 1993
4 .\"     The Regents of the University of California.  All rights reserved.
5 .\"
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
8 .\" are met:
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\"    notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\"    notice, this list of conditions and the following disclaimer in the
13 .\"    documentation and/or other materials provided with the distribution.
14 .\" 3. All advertising materials mentioning features or use of this software
15 .\"    must display the following acknowledgement:
16 .\"     This product includes software developed by the University of
17 .\"     California, Berkeley and its contributors.
18 .\" 4. Neither the name of the University nor the names of its contributors
19 .\"    may be used to endorse or promote products derived from this software
20 .\"    without specific prior written permission.
21 .\"
22 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .\" SUCH DAMAGE.
33 .\"
34 .\"     @(#)mdoc.samples.7      8.2 (Berkeley) 12/30/93
35 .\"
36 .\" This tutorial sampler invokes every macro in the package several
37 .\" times and is guaranteed to give a worst case performance
38 .\" for an already extremely slow package.
39 .\"
40 .Dd November 24, 1997
41 .Os
42 .Dt MDOC.SAMPLES 7
43 .Sh NAME
44 .Nm mdoc.samples
45 .Nd tutorial sampler for writing
46 .Bx
47 manuals with
48 .Nm \-mdoc
49 .Sh SYNOPSIS
50 .Nm man mdoc.samples
51 .Sh DESCRIPTION
52 A tutorial sampler for writing
53 .Bx
54 manual pages with the
55 .Nm \-mdoc
56 macro package, a
57 .Em content Ns \-based
58 and
59 .Em domain Ns \-based
60 formatting
61 package for
62 .Xr troff 1 .
63 Its predecessor, the
64 .Xr \-man 7
65 package,
66 addressed page layout leaving the
67 manipulation of fonts and other
68 typesetting details to the individual author.
70 .Nm \-mdoc ,
71 page layout macros
72 make up the
73 .Em "page structure domain"
74 which consists of macros for titles, section headers, displays
75 and lists. Essentially items which affect the physical position
76 of text on a formatted page.
77 In addition to the page structure domain, there are two more domains,
78 the manual domain and the general text domain.
79 The general text domain is defined as macros which
80 perform tasks such as quoting or emphasizing pieces of text.
81 The manual domain is defined as macros that are a subset of the
82 day to day informal language used to describe commands, routines
83 and related
84 .Bx
85 files.
86 Macros in the manual domain handle
87 command names, command line arguments and options, function names,
88 function parameters, pathnames, variables, cross
89 references to other manual pages, and so on.
90 These domain
91 items have value
92 for both the author and the future user of the manual page.
93 It is hoped the consistency gained
94 across the manual set will provide easier
95 translation to future documentation tools.
96 .Pp
97 Throughout the
98 .Ux
99 manual pages, a manual entry
100 is simply referred
101 to as a man page, regardless of actual length and without
102 sexist intention.
103 .Sh GETTING STARTED
104 Since a tutorial document is normally read when a person
105 desires to use the material immediately, the assumption has
106 been made that the user of this document may be impatient.
107 The material presented in the remained of this document is
108 outlined as follows:
109 .Bl -enum -offset indent
111 .Tn "TROFF IDIOSYNCRASIES"
112 .Bl -tag -width flag -compact -offset indent
113 .It "Macro Usage" .
114 .It "Passing Space Characters in an Argument" .
115 .It "Trailing Blank Space Characters (a warning)" .
116 .It "Escaping Special Characters" .
119 .Tn "THE ANATOMY OF A MAN PAGE"
120 .Bl -tag -width flag -compact -offset indent
121 .It "A manual page template" .
124 .Tn "INTRODUCTION OF TITLE MACROS" .
126 .Tn "INTRODUCTION OF MANUAL AND GENERAL TEXT DOMAINS" .
127 .Bl -tag -width flag -compact -offset indent
128 .It "What's in a name..." .
129 .It "General Syntax" .
132 .Tn "MANUAL DOMAIN"
133 .Bl -tag -width flag -compact -offset indent
134 .It "Addresses" .
135 .It "Arguments" .
136 .It "Configuration Declarations (section four only)" .
137 .It "Command Modifier" .
138 .It "Defined Variables" .
139 .It "Errno's (Section two only)" .
140 .It "Environment Variables" .
141 .It "Function Argument" .
142 .It "Function Declaration" .
143 .It "Flags" .
144 .It "Functions (library routines)" .
145 .It "Function Types" .
146 .\" .It "Header File (including source code)" .
147 .It "Interactive Commands" .
148 .It "Literals" .
149 .It "Names" .
150 .It "Options" .
151 .It "Pathnames" .
152 .It "Variables" .
153 .It "Cross References" .
156 .Tn "GENERAL TEXT DOMAIN"
157 .Bl -tag -width flag -compact -offset indent
158 .It "AT&T Macro" .
159 .It "BSD Macro" .
160 .It "UNIX Macro" .
161 .It "Emphasis Macro" .
162 .It "Enclosure/Quoting Macros"
163 .Bl -tag -width flag -compact -offset indent
164 .It "Angle Bracket Quote/Enclosure" .
165 .It "Bracket Quotes/Enclosure" .
166 .It "Double Quote macro/Enclosure" .
167 .It "Parenthesis Quote/Enclosure" .
168 .It "Single Quotes/Enclosure" .
169 .It "Prefix Macro" .
171 .It "Extended  Arguments" .
172 .It "No\-Op or Normal Text Macro" .
173 .It "No Space Macro" .
174 .It "Section Cross References" .
175 .It "Symbolic Macro" .
176 .It "References and Citations" .
177 .It "Trade Names (Acronyms and Type Names)" .
180 .Tn "PAGE STRUCTURE DOMAIN"
181 .Bl -tag -width flag -compact -offset indent
182 .It "Section Headers" .
183 .It "Paragraphs and Line Spacing" .
184 .It "Keeps" .
185 .It "Displays" .
186 .It "Lists and Columns" .
189 .Tn "PREDEFINED STRINGS"
191 .Tn "DIAGNOSTICS"
193 .Tn "FORMATTING WITH GROFF, TROFF AND NROFF"
195 .Tn "BUGS"
197 .ne 7
198 .Sh TROFF IDIOSYNCRASIES
200 .Nm \-mdoc
201 package attempts to simplify the process of writing a man page.
202 Theoretically, one should not have to learn the dirty details of
203 .Xr troff 1
204 to use
205 .Nm \-mdoc ;
206 however, there are a few
207 limitations which are unavoidable and best gotten out
208 of the way.
209 And, too, be forewarned, this package is
210 .Em not
211 fast.
212 .Ss Macro Usage
213 As in
214 .Xr troff 1 ,
215 a macro is called by placing a
216 .Ql \&\.
217 (dot character)
218 at the beginning of
219 a line followed by the two character name for the macro.
220 Arguments may follow the macro separated by spaces.
221 It is the dot character at the beginning of the line which causes
222 .Xr troff 1
223 to interpret the next two characters as a macro name.
224 To place a
225 .Ql \&\.
226 (dot character)
227 at the beginning of a line in some context other than
228 a macro invocation, precede the
229 .Ql \&\.
230 (dot) with the
231 .Ql \e&
232 escape sequence.
234 .Ql \e&
235 translates literally to a zero width space, and is never displayed in the
236 output.
238 In general,
239 .Xr troff 1
240 macros accept up to nine arguments, any
241 extra arguments are ignored.
242 Most macros in
243 .Nm \-mdoc
244 accept nine arguments and,
245 in limited cases, arguments may be continued or extended
246 on the
247 next line (See
248 .Sx Extended Arguments ) .
249 A few macros handle quoted arguments (see
250 .Sx Passing Space Characters in an Argument
251 below).
253 Most of the
254 .Nm \-mdoc
255 general text domain and manual domain macros are special
256 in that their argument lists are
257 .Em parsed
258 for callable macro names.
259 This means an argument on the argument list which matches
260 a general text or manual domain macro name and is determined
261 to be callable will be executed
262 or called when it is processed.
263 In this case
264 the argument, although the name of a macro,
265 is not preceded by a
266 .Ql \&\.
267 (dot).
268 It is in this manner that many macros are nested; for
269 example
270 the option macro,
271 .Ql \&.Op ,
273 .Em call
274 the flag and argument macros,
275 .Ql \&Fl
277 .Ql \&Ar ,
278 to specify an optional flag with an argument:
279 .Bl -tag -width "\&.Op \&Fl s \&Ar bytes" -offset indent
280 .It Op Fl s Ar bytes
281 is produced by
282 .Li \&.Op \&Fl s \&Ar bytes
285 To prevent a two character
286 string from being interpreted as a macro name, precede
287 the string with the
288 escape sequence
289 .Ql \e& :
290 .Bl -tag -width "\&.Op \&Fl s \&Ar bytes" -offset indent
291 .It Op \&Fl s \&Ar bytes
292 is produced by
293 .Li \&.Op \e&Fl s \e&Ar bytes
296 Here the strings
297 .Ql \&Fl
299 .Ql \&Ar
300 are not interpreted as macros.
301 Macros whose argument lists are parsed for callable arguments
302 are referred to
303 as parsed and macros which may be called from an argument
304 list are referred to as callable
305 throughout this document and in the companion quick reference
306 manual
307 .Xr mdoc 7 .
308 This is a technical
309 .Em faux pas
310 as almost all of the macros in 
311 .Nm \-mdoc
312 are parsed, but as it was cumbersome to constantly refer to macros
313 as being callable and being able to call other macros,
314 the term parsed has been used.
315 .Ss Passing Space Characters in an Argument
316 Sometimes it is desirable to give as one argument a string
317 containing one or more blank space characters.
318 This may be necessary
319 to defeat the nine argument limit or to specify arguments to macros
320 which expect particular arrangement of items in the argument list.
321 For example,
322 the function macro
323 .Ql \&.Fn
324 expects the first argument to be the name of a function and any
325 remaining arguments to be function parameters.
327 .Tn "ANSI C"
328 stipulates the declaration of function parameters in the
329 parenthesized parameter list, each parameter is guaranteed
330 to be at minimum a two word string.
331 For example,
332 .Fa int foo .
334 There are two possible ways to pass an argument which contains
335 an embedded space.
336 .Em Implementation note :
337 Unfortunately, the most convenient way
338 of passing spaces in between quotes by reassigning individual
339 arguments before parsing was fairly expensive speed wise
340 and space wise to implement in all the macros for
341 .Tn AT&T
342 .Xr troff .
343 It is not expensive for
344 .Xr groff
345 but for the sake of portability, has been limited
346 to the following macros which need
347 it the most:
349 .Bl -tag -width 4n -offset indent -compact
350 .It Li \&Cd
351 Configuration declaration (section 4
352 .Sx SYNOPSIS )
353 .It Li \&Bl
354 Begin list (for the width specifier).
355 .It Li \&Em
356 Emphasized text.
357 .It Li \&Fn
358 Functions (sections two and four).
359 .It Li \&It
360 List items.
361 .It Li \&Li
362 Literal text.
363 .It Li \&Sy
364 Symbolic text.
365 .It Li \&%B
366 Book titles.
367 .It Li \&%J
368 Journal names.
369 .It Li \&%O
370 Optional notes for a reference.
371 .It Li \&%R
372 Report title (in a reference).
373 .It Li \&%T
374 Title of article in a book or journal.
377 One way of passing a string
378 containing blank spaces is to use the hard or unpaddable space character
379 .Ql \e\  ,
380 that is, a blank space preceded by the escape character
381 .Ql \e .
382 This method may be used with any macro but has the side effect
383 of interfering with the adjustment of text
384 over the length of a line.
385 .Xr Troff
386 sees the hard space as if it were any other printable character and
387 cannot split the string into blank or newline separated pieces as one
388 would expect.
389 The method is useful for strings which are not expected
390 to overlap a line boundary.
391 For example:
392 .Bl -tag -width "fetch(char *str)" -offset indent
393 .It Fn fetch char\ *str
394 is created by
395 .Ql \&.Fn fetch char\e *str
396 .It Fn fetch "char *str"
397 can also be created by
398 .Ql \&.Fn fetch "\\*q*char *str\\*q"
401 If the
402 .Ql \e
403 or quotes
404 were omitted,
405 .Ql \&.Fn
406 would see three arguments and
407 the result would be:
409 .Dl Fn fetch char *str
411 For an example of what happens when the parameter list overlaps
412 a newline boundary, see the
413 .Sx BUGS
414 section.
415 .Ss Trailing Blank Space Characters
416 .Xr Troff
417 can be confused by blank space characters at the end of a line.
419 is a wise preventive measure to globally remove all blank spaces
420 from <blank-space><end-of-line> character sequences.
421 Should the need
422 arise to force a blank character at the end of a line,
423 it may be forced with an unpaddable space and the
424 .Ql \e&
425 escape character.
426 For example,
427 .Ql string\e\ \e& .
428 .Ss Escaping Special Characters
429 Special characters
430 like the newline character
431 .Ql \en ,
432 are handled by replacing the
433 .Ql \e
434 with
435 .Ql \ee
436 (e.g.
437 .Ql \een )
438 to preserve
439 the backslash.
440 .Sh THE ANATOMY OF A MAN PAGE
441 The body of a man page is easily constructed from a basic
442 template found in the file:
443 .Bd -literal -offset indent
444 \&.\e" /usr/share/misc/mdoc.template:
445 \&.\e" The following six lines are required.
446 \&.Dd Month day, year
447 \&.Os OPERATING_SYSTEM [version/release]
448 \&.Dt DOCUMENT_TITLE [section number] [volume]
449 \&.Sh NAME
450 \&.Sh SYNOPSIS
451 \&.Sh DESCRIPTION
452 \&.\e" The following requests should be uncommented and
453 \&.\e" used where appropriate.  This next request is
454 \&.\e" for sections 2 and 3 function return values only.
455 \&.\e" .Sh RETURN VALUES
456 \&.\e" This next request is for sections 1, 6, 7 & 8 only
457 \&.\e" .Sh ENVIRONMENT
458 \&.\e" .Sh FILES
459 \&.\e" .Sh EXAMPLES
460 \&.\e" This next request is for sections 1, 6, 7 & 8 only
461 \&.\e"     (command return values (to shell) and
462 \&.\e"    fprintf/stderr type diagnostics)
463 \&.\e" .Sh DIAGNOSTICS
464 \&.\e" The next request is for sections 2 and 3 error
465 \&.\e" and signal handling only.
466 \&.\e" .Sh ERRORS
467 \&.\e" .Sh SEE ALSO
468 \&.\e" .Sh STANDARDS
469 \&.\e" .Sh HISTORY
470 \&.\e" .Sh AUTHORS
471 \&.\e" .Sh BUGS
474 The first items in the template are the macros
475 .Pq Li \&.Dd , \&.Os , \&.Dt ;
476 the document date,
477 the operating system the man page or subject source is developed
478 or modified for,
479 and the man page title
480 .Pq Em in upper case
481 along with the section of the manual the page
482 belongs in.
483 These macros identify the page,
484 and are discussed below in
485 .Sx TITLE MACROS .
487 The remaining items in the template are section headers
488 .Pq Li \&.Sh ;
489 of which
490 .Sx NAME ,
491 .Sx SYNOPSIS
493 .Sx DESCRIPTION
494 are mandatory.
496 headers are
497 discussed in
498 .Sx PAGE STRUCTURE DOMAIN ,
499 after
500 presentation of
501 .Sx MANUAL DOMAIN .
502 Several content macros are used to demonstrate page layout macros;
503 reading about content macros before page layout macros is
504 recommended.
505 .Sh TITLE MACROS
506 The title macros are the first portion of the page structure
507 domain, but are presented first and separate for someone who
508 wishes to start writing a man page yesterday.
509 Three header macros designate the document title or manual page title,
510 the operating system,
511 and the date of authorship.
512 These macros are one called once at the very beginning of the document
513 and are used to construct the headers and footers only.
514 .Bl -tag -width 6n
515 .It Li \&.Dt DOCUMENT_TITLE section# [volume]
516 The document title is the
517 subject of the man page and must be in
518 .Tn CAPITALS
519 due to troff
520 limitations.
521 The section number may be 1,\ ...,\ 9,
522 and if it is specified,
523 the volume title may be omitted.
524 A volume title may be arbitrary or one of the following:
525 .\" .Cl
526 .\" USD UNIX User's Supplementary Documents
527 .\" .Cl
528 .\" PS1 UNIX Programmer's Supplementary Documents
530 .Bl -column SMM -offset indent -compact
531 .It Li AMD      NetBSD Ancestral Manual Documents
532 .It Li SMM      NetBSD System Manager's Manual
533 .It Li URM      NetBSD Reference Manual
534 .It Li PRM      NetBSD Programmer's Manual
535 .It Li KM       NetBSD Kernel Manual
538 The default volume labeling is
539 .Li URM
540 for sections 1, 6, and 7;
541 .Li SMM
542 for section 8;
543 .Li PRM
544 for sections 2, 3, 4, and 5;
545 .Li KM
546 for section 9.
547 .\" .Cl
548 .\" MMI UNIX Manual Master Index
549 .\" .Cl
550 .\" CON UNIX Contributed Software Manual
551 .\" .Cl
552 .\" LOC UNIX Local Manual
553 .It Li \&.Os operating_system release#
554 The name of the operating system
555 should be the common acronym, e.g.
556 .Tn BSD
558 .Tn ATT .
559 The release should be the standard release
560 nomenclature for the system specified, e.g. 4.3, 4.3+Tahoe, V.3,
561 V.4.
562 Unrecognized arguments are displayed as given in the page footer.
563 For instance, a typical footer might be:
565 .Dl \&.Os BSD 4.3
567 or for a locally produced set
569 .Dl \&.Os CS Department
571 The Berkeley default,
572 .Ql \&.Os
573 without an argument, has been defined as
574 .Nx 1.4
575 in the site specific file
576 .Pa /usr/share/tmac/tmac.doc-common .
577 Note, if the
578 .Ql \&.Os
579 macro is not present, the bottom left corner of the page
580 will be ugly.
581 .It Li \&.Dd month day, year
582 The date should be written formally:
584 .ne 5
585 .Dl January 25, 1989
587 Note that the date must not be placed in quotes!
589 .Sh MANUAL DOMAIN
590 .Ss What's in a name...
591 The manual domain macro names are derived from the day to day
592 informal language used to describe commands, subroutines and related
593 files.
594 Slightly
595 different variations of this language are used to describe
596 the three different aspects of writing a man page.
597 First, there is the description of
598 .Nm \-mdoc
599 macro request usage.
600 Second is the description of a
602 command
603 .Em with
604 .Nm \-mdoc
605 macros and third,
607 description of a command to a user in the verbal sense;
608 that is, discussion of a command in the text of a man page.
610 In the first case,
611 .Xr troff 1
612 macros are themselves a type of command;
613 the general syntax for a troff command is:
614 .Bd -filled -offset indent
615 \&.Va argument1 argument2 ... argument9
619 .Ql \&.Va
620 is a macro command or request, and anything following it is an argument to
621 be processed.
622 In the second case,
623 the description of a
625 command using the content macros is a
626 bit more involved;
627 a typical
628 .Sx SYNOPSIS
629 command line might be displayed as:
630 .Bd -filled -offset indent
631 .Nm filter
632 .Op Fl flag
633 .Ar infile outfile
636 Here,
637 .Nm filter
638 is the command name and the
639 bracketed string
640 .Fl flag
641 is a
642 .Em flag
643 argument designated as optional by the option brackets.
645 .Nm \-mdoc
646 terms,
647 .Ar infile
649 .Ar outfile
651 called
652 .Em arguments .
653 The macros which formatted the above example:
654 .Bd -literal -offset indent
655 \&.Nm filter
656 \&.Op \&Fl flag
657 \&.Ar infile outfile
660 In the third case, discussion of commands and command syntax
661 includes both examples above, but may add more detail.
663 arguments
664 .Ar infile
666 .Ar outfile
667 from the example above might be referred to as
668 .Em operands
670 .Em file arguments .
671 Some command line argument lists are quite long:
672 .Bl -tag -width make -offset indent
673 .It Nm make
674 .Op Fl eiknqrstv
675 .Op Fl D Ar variable
676 .Op Fl d Ar flags
677 .Op Fl f Ar makefile
678 .Bk -words
679 .Op Fl I Ar directory
681 .Op Fl j Ar max_jobs
682 .Op Ar variable=value
683 .Bk -words
684 .Op Ar target ...
688 Here one might talk about the command
689 .Nm make
690 and qualify the argument
691 .Ar makefile ,
692 as an argument to the flag,
693 .Fl f ,
694 or discuss the optional
695 file
696 operand
697 .Ar target .
698 In the verbal context, such detail can prevent confusion,
699 however the
700 .Nm \-mdoc
701 package
702 does not have a macro for an argument
703 .Em to
704 a flag.
705 Instead the
706 .Ql \&Ar
707 argument macro is used for an operand or file argument like
708 .Ar target
709 as well as an argument to a flag like
710 .Ar variable .
711 The make command line was produced from:
712 .Bd -literal -offset indent
713 \&.Nm make
714 \&.Op Fl eiknqrstv
715 \&.Op Fl D Ar variable
716 \&.Op Fl d Ar flags
717 \&.Op Fl f Ar makefile
718 \&.Op Fl I Ar directory
719 \&.Op Fl j Ar max_jobs
720 \&.Op Ar variable=value
721 \&.Bk -words
722 \&.Op Ar target ...
723 \&.Ek
727 .Ql \&.Bk
729 .Ql \&.Ek
730 macros are explained in
731 .Sx Keeps .
732 .Ss General Syntax
733 The manual domain and general text domain macros share a similar
734 syntax with a few minor deviations:
735 .Ql \&.Ar ,
736 .Ql \&.Fl ,
737 .Ql \&.Nm ,
739 .Ql \&.Pa
740 differ only when called without arguments;
741 .Ql \&.Fn
743 .Ql \&.Xr
744 impose an order on their argument lists
745 and the
746 .Ql \&.Op
748 .Ql \&.Fn
749 macros
750 have nesting limitations.
751 All content macros
752 are capable of recognizing and properly handling punctuation,
753 provided each punctuation character is separated by a leading space.
754 If an request is given:
756 .Dl \&.Li sptr, ptr),
758 The result is:
760 .Dl Li sptr, ptr),
762 The punctuation is not recognized and all is output in the
763 literal font. If the punctuation is separated by a leading
764 white space:
766 .Dl \&.Li "sptr , ptr ) ,"
768 The result is:
770 .Dl Li sptr , ptr ) ,
772 The punctuation is now recognized and is output in the
773 default font distinguishing it from the strings in literal font.
775 To remove the special meaning from a punctuation character
776 escape it with
777 .Ql \e& .
778 .Xr Troff
779 is limited as a macro language, and has difficulty
780 when presented with a string containing
781 a member of the mathematical, logical or
782 quotation set:
783 .Bd -literal -offset indent-two
784 \&{+,\-,/,*,\&%,<,>,<=,>=,=,==,&,`,',"}
787 The problem is that
788 .Xr troff
789 may assume it is supposed to actually perform the operation
790 or evaluation suggested by the characters.  To prevent
791 the accidental evaluation of these characters,
792 escape them with
793 .Ql \e& .
794 Typical syntax is shown in the first content macro displayed
795 below,
796 .Ql \&.Ad .
797 .Ss Address Macro
798 The address macro identifies an address construct
799 of the form addr1[,addr2[,addr3]].
801 .Dl Usage: .Ad address ... \*(Pu
802 .Bl -tag -width ".Ad f1 , f2 , f3 :" -compact -offset 14n
803 .It Li \&.Ad addr1
804 .Ad addr1
805 .It Li \&.Ad addr1\ .
806 .Ad addr1 .
807 .It Li \&.Ad addr1\ , file2
808 .Ad addr1 , file2
809 .It Li \&.Ad f1\ , f2\ , f3\ :
810 .Ad f1 , f2 , f3 :
811 .It Li \&.Ad addr\ )\ )\ ,
812 .Ad addr ) ) ,
815 It is an error to call
816 .Li \&.Ad
817 without arguments.
818 .Li \&.Ad
819 is callable by other macros and is parsed.
820 .Ss Argument Macro
822 .Li \&.Ar
823 argument macro may be used whenever
824 a command line argument is referenced.
826 .Dl Usage: .Ar argument ... \*(Pu
827 .Bl -tag -width ".Ar file1 file2" -compact -offset 15n
828 .It Li \&.Ar
830 .It Li \&.Ar file1
831 .Ar file1
832 .It Li \&.Ar file1\ .
833 .Ar file1 .
834 .It Li \&.Ar file1 file2
835 .Ar file1 file2
836 .It Li \&.Ar f1 f2 f3\ :
837 .Ar f1 f2 f3 :
838 .It Li \&.Ar file\ )\ )\ ,
839 .Ar file ) ) ,
843 .Li \&.Ar
844 is called without arguments
845 .Ql Ar
846 is assumed.
848 .Li \&.Ar
849 macro is parsed and is callable.
850 .Ss Configuration Declaration (section four only)
852 .Ql \&.Cd
853 macro is used to demonstrate a
854 .Xr config 8
855 declaration for a device interface in a section four manual.
856 This macro accepts quoted arguments (double quotes only).
858 .Bl -tag -width "device le0 at scode?" -offset indent
859 .It Cd "device le0 at scode?"
860 produced by:
861 .Ql ".Cd device le0 at scode?" .
863 .Ss Command Modifier
864 The command modifier is identical to the
865 .Ql \&.Fl
866 (flag) command with the exception
868 .Ql \&.Cm
869 macro does not assert a dash
870 in front of every argument.
871 Traditionally flags are marked by the
872 preceding dash, some commands or subsets of commands do not use them.
873 Command modifiers may also be specified in conjunction with interactive
874 commands such as editor commands.
876 .Sx Flags .
877 .Ss Defined Variables
878 A variable which is defined in an include file is specified
879 by the macro
880 .Ql \&.Dv .
882 .Dl Usage: .Dv defined_variable ... \*(Pu
883 .Bl -tag -width ".Dv MAXHOSTNAMELEN" -compact -offset 14n
884 .It Li ".Dv MAXHOSTNAMELEN"
885 .Dv MAXHOSTNAMELEN
886 .It Li ".Dv TIOCGPGRP )"
887 .Dv TIOCGPGRP )
890 It is an error to call
891 .Ql \&.Dv
892 without arguments.
893 .Ql \&.Dv
894 is parsed and is callable.
895 .Ss Errno's (Section two only)
897 .Ql \&.Er
898 errno macro specifies the error return value
899 for section two library routines.
900 The second example
901 below shows
902 .Ql \&.Er
903 used with the
904 .Ql \&.Bq
905 general text domain macro, as it would be used in
906 a section two manual page.
908 .Dl Usage: .Er ERRNOTYPE ... \*(Pu
909 .Bl -tag -width ".Bq Er ENOTDIR" -compact -offset 14n
910 .It Li \&.Er ENOENT
911 .Er ENOENT
912 .It Li \&.Er ENOENT\ )\ ;
913 .Er ENOENT ) ;
914 .It Li \&.Bq \&Er ENOTDIR
915 .Bq Er ENOTDIR
918 It is an error to call
919 .Ql \&.Er
920 without arguments.
922 .Ql \&.Er
923 macro is parsed and is callable.
924 .Ss Environment Variables
926 .Ql \&.Ev
927 macro specifies an environment variable.
929 .Dl Usage: .Ev argument ... \*(Pu
930 .Bl -tag -width ".Ev PRINTER ) ) ," -compact -offset 14n
931 .It Li \&.Ev DISPLAY
932 .Ev  DISPLAY
933 .It Li \&.Ev PATH\ .
934 .Ev PATH .
935 .It Li \&.Ev PRINTER\ )\ )\ ,
936 .Ev PRINTER ) ) ,
939 It is an error to call
940 .Ql \&.Ev
941 without arguments.
943 .Ql \&.Ev
944 macro is parsed and is callable.
945 .Ss Function Argument
947 .Ql \&.Fa
948 macro is used to refer to function arguments (parameters)
949 outside of the
950 .Sx SYNOPSIS
951 section of the manual or inside
953 .Sx SYNOPSIS
954 section should a parameter list be too
955 long for the
956 .Ql \&.Fn
957 macro and the enclosure macros
958 .Ql \&.Fo
960 .Ql \&.Fc
961 must be used.
962 .Ql \&.Fa
963 may also be used to refer to structure members.
965 .Dl Usage: .Fa function_argument ... \*(Pu
966 .Bl -tag -width ".Fa d_namlen\ )\ )\ ," -compact -offset 14n
967 .It Li \&.Fa d_namlen\ )\ )\ ,
968 .Fa d_namlen ) ) ,
969 .It Li \&.Fa iov_len
970 .Fa iov_len
973 It is an error to call
974 .Ql \&.Fa
975 without arguments.
976 .Ql \&.Fa
977 is parsed and is callable.
978 .Ss Function Declaration
980 .Ql \&.Fd
981 macro is used in the
982 .Sx SYNOPSIS
983 section with section two or three
984 functions.
986 .Ql \&.Fd
987 macro does not call other macros and is not callable by other
988 macros.
990 .Dl Usage: .Fd include_file (or defined variable)
992 In the
993 .Sx SYNOPSIS
994 section a
995 .Ql \&.Fd
996 request causes a line break if a function has already been presented
997 and a break has not occurred.
998 This leaves a nice vertical space
999 in between the previous function call and the declaration for the
1000 next function.
1001 .Ss Flags
1003 .Ql \&.Fl
1004 macro handles command line flags.
1005 It prepends
1006 a dash,
1007 .Ql \- ,
1008 to the flag.
1009 For interactive command flags, which
1010 are not prepended with a dash, the
1011 .Ql \&.Cm
1012 (command modifier)
1013 macro is identical, but without the dash.
1015 .Dl Usage: .Fl argument ... \*(Pu
1016 .Bl -tag -width ".Fl \-s \-t \-v" -compact -offset 14n
1017 .It Li \&.Fl
1019 .It Li \&.Fl cfv
1020 .Fl cfv
1021 .It Li \&.Fl cfv\ .
1022 .Fl cfv .
1023 .It Li \&.Fl s v t
1024 .Fl s v t
1025 .It Li \&.Fl -\ ,
1026 .Fl - ,
1027 .It Li \&.Fl xyz\ )\ ,
1028 .Fl xyz ) ,
1032 .Ql \&.Fl
1033 macro without any arguments results
1034 in a dash representing stdin/stdout.
1035 Note that giving
1036 .Ql \&.Fl
1037 a single dash, will result in two dashes.
1039 .Ql \&.Fl
1040 macro is parsed and is callable.
1041 .Ss Functions (library routines)
1042 The .Fn macro is modeled on ANSI C conventions.
1043 .Bd -literal
1044 Usage: .Fn [type] function [[type] parameters ... \*(Pu]
1046 .Bl -tag -width ".Fn .int align. .const * char *sptrsxx" -compact
1047 .It Li "\&.Fn getchar"
1048 .Fn getchar
1049 .It Li "\&.Fn strlen ) ,"
1050 .Fn strlen ) ,
1051 .It Li \&.Fn "\\*qint align\\*q" "\\*qconst * char *sptrs\\*q" ,
1052 .Fn "int align" "const * char *sptrs" ,
1055 It is an error to call
1056 .Ql \&.Fn
1057 without any arguments.
1059 .Ql \&.Fn
1060 macro
1061 is parsed and is callable,
1062 note that any call to another macro signals the end of
1064 .Ql \&.Fn
1065 call (it will close-parenthesis at that point).
1067 For functions that have more than eight parameters (and this
1068 is rare), the
1069 macros
1070 .Ql \&.Fo
1071 (function open)
1073 .Ql \&.Fc
1074 (function close)
1075 may be used with
1076 .Ql \&.Fa
1077 (function argument)
1078 to get around the limitation. For example:
1079 .Bd -literal -offset indent
1080 \&.Fo "int res_mkquery"
1081 \&.Fa "int op"
1082 \&.Fa "char *dname"
1083 \&.Fa "int class"
1084 \&.Fa "int type"
1085 \&.Fa "char *data"
1086 \&.Fa "int datalen"
1087 \&.Fa "struct rrec *newrr"
1088 \&.Fa "char *buf"
1089 \&.Fa "int buflen"
1090 \&.Fc
1093 Produces:
1094 .Bd -filled -offset indent
1095 .Fo "int res_mkquery"
1096 .Fa "int op"
1097 .Fa "char *dname"
1098 .Fa "int class"
1099 .Fa "int type"
1100 .Fa "char *data"
1101 .Fa "int datalen"
1102 .Fa "struct rrec *newrr"
1103 .Fa "char *buf"
1104 .Fa "int buflen"
1109 .Ql \&.Fo
1111 .Ql \&.Fc
1112 macros are parsed and are callable.
1113 In the
1114 .Sx SYNOPSIS
1115 section, the function will always begin at
1116 the beginning of line.
1117 If there is more than one function
1118 presented in the
1119 .Sx SYNOPSIS
1120 section and a function type has not been
1121 given, a line break will occur, leaving a nice vertical space
1122 between the current function name and the one prior.
1123 At the moment,
1124 .Ql \&.Fn
1125 does not check its word boundaries
1126 against troff line lengths and may split across a newline
1127 ungracefully.
1128 This will be fixed in the near future.
1129 .Ss Function Type
1130 This macro is intended for the
1131 .Sx SYNOPSIS
1132 section.
1133 It may be used
1134 anywhere else in the man page without problems, but its main purpose
1135 is to present the function type in kernel normal form for the
1136 .Sx SYNOPSIS
1137 of sections two and three
1138 (it causes a page break allowing the function name to appear
1139 on the next line).
1141 .Dl Usage: .Ft type ... \*(Pu
1142 .Bl -tag -width "\&.Ft struct stat" -offset 14n -compact
1143 .It Li \&.Ft struct stat
1144 .Ft struct stat
1148 .Ql \&.Ft
1149 request is not callable by other macros.
1150 .Ss Interactive Commands
1152 .Ql \&.Ic
1153 macro designates an interactive or internal command.
1155 .Dl Usage: .Li argument ... \*(Pu
1156 .Bl -tag -width ".Ic setenv , unsetenvxx" -compact -offset 14n
1157 .It Li \&.Ic :wq
1158 .Ic :wq
1159 .It Li \&.Ic do while {...}
1160 .Ic do while {...}
1161 .It Li \&.Ic setenv\ , unsetenv
1162 .Ic setenv , unsetenv
1165 It is an error to call
1166 .Ql \&.Ic
1167 without arguments.
1169 .Ql \&.Ic
1170 macro is parsed and is callable.
1171 .Ss Literals
1173 .Ql \&.Li
1174 literal macro may be used for special characters,
1175 variable constants, anything which should be displayed as it
1176 would be typed.
1178 .Dl Usage: .Li argument ... \*(Pu
1179 .Bl -tag -width ".Li cntrl-D ) ,"  -compact -offset 14n
1180 .It Li \&.Li \een
1181 .Li \en
1182 .It Li \&.Li M1 M2 M3\ ;
1183 .Li M1 M2 M3 ;
1184 .It Li \&.Li cntrl-D\ )\ ,
1185 .Li cntrl-D ) ,
1186 .It Li \&.Li 1024\ ...
1187 .Li 1024 ...
1191 .Ql \&.Li
1192 macro is parsed and is callable.
1193 .Ss Name Macro
1195 .Ql \&.Nm
1196 macro is used for the document title or subject name.
1197 It has the peculiarity of remembering the first
1198 argument it was called with, which should
1199 always be the subject name of the page.
1200 When called without
1201 arguments,
1202 .Ql \&.Nm
1203 regurgitates this initial name for the sole purpose
1204 of making less work for the author.
1205 If trailing punctuation is required with this feature,
1208 as a first argument to
1209 .Ql \&.Nm .
1210 Note:
1211 a section two
1212 or three document function name is addressed with the
1213 .Ql \&.Nm
1214 in the
1215 .Sx NAME
1216 section, and with
1217 .Ql \&.Fn
1218 in the
1219 .Sx SYNOPSIS
1220 and remaining sections.
1221 For interactive commands, such as the
1222 .Ql while
1223 command keyword in
1224 .Xr csh 1 ,
1226 .Ql \&.Ic
1227 macro should be used.
1228 While the
1229 .Ql \&.Ic
1230 is nearly identical
1232 .Ql \&.Nm ,
1233 it can not recall the first argument it was invoked with.
1235 .Dl Usage: .Nm argument ... \*(Pu
1236 .Bl -tag -width ".Nm mdoc.samples" -compact -offset 14n
1237 .It Li \&.Nm mdoc.samples
1238 .Nm  mdoc.samples
1239 .It Li \&.Nm \e-mdoc
1240 .Nm \-mdoc
1241 .It Li \&.Nm foo\ )\ )\ ,
1242 .Nm foo ) ) ,
1243 .It Li \&.Nm
1245 .It Li \&.Nm \&"\&"\ :
1246 .Nm "" :
1250 .Ql \&.Nm
1251 macro is parsed and is callable.
1252 .Ss Options
1254 .Ql \&.Op
1255 macro
1256 places option brackets around the any remaining arguments on the command
1257 line, and places any
1258 trailing punctuation outside the brackets.
1259 The macros
1260 .Ql \&.Oc
1262 .Ql \&.Oo
1263 may be used across one or more lines.
1265 .Dl Usage: .Op options ... \*(Pu
1266 .Bl -tag -width ".Op Fl c Ar objfil Op Ar corfil ," -compact -offset indent
1267 .It Li \&.Op
1269 .It Li ".Op Fl k"
1270 .Op Fl k
1271 .It Li ".Op Fl k ) ."
1272 .Op Fl k ) .
1273 .It Li ".Op Fl k Ar kookfile"
1274 .Op Fl k Ar kookfile
1275 .It Li ".Op Fl k Ar kookfile ,"
1276 .Op Fl k Ar kookfile ,
1277 .It Li ".Op Ar objfil Op Ar corfil"
1278 .Op Ar objfil Op Ar corfil
1279 .It Li ".Op Fl c Ar objfil Op Ar corfil ,"
1280 .Op Fl c Ar objfil Op Ar corfil ,
1281 .It Li \&.Op word1 word2
1282 .Op word1 word2
1286 .Ql \&.Oc
1288 .Ql \&.Oo
1289 macros:
1290 .Bd -literal -offset indent
1291 \&.Oo
1292 \&.Op \&Fl k \&Ar kilobytes
1293 \&.Op \&Fl i \&Ar interval
1294 \&.Op \&Fl c \&Ar count
1295 \&.Oc
1298 Produce:
1300 .Op Fl k Ar kilobytes
1301 .Op Fl i Ar interval
1302 .Op Fl c Ar count
1305 The macros
1306 .Ql \&.Op ,
1307 .Ql \&.Oc
1309 .Ql \&.Oo
1310 are parsed and are callable.
1311 .Ss Pathnames
1313 .Ql \&.Pa
1314 macro formats path or file names.
1316 .Dl Usage: .Pa pathname \*(Pu
1317 .Bl -tag -width ".Pa /tmp/fooXXXXX ) ." -compact -offset 14n
1318 .It Li \&.Pa /usr/share
1319 .Pa /usr/share
1320 .It Li \&.Pa /tmp/fooXXXXX\ )\ .
1321 .Pa /tmp/fooXXXXX ) .
1325 .Ql \&.Pa
1326 macro is parsed and is callable.
1327 .Ss Variables
1328 Generic variable reference:
1330 .Dl Usage: .Va variable ... \*(Pu
1331 .Bl -tag -width ".Va char s ] ) ) ," -compact -offset 14n
1332 .It Li \&.Va count
1333 .Va count
1334 .It Li \&.Va settimer ,
1335 .Va settimer ,
1336 .It Li \&.Va int\ *prt\ )\ :
1337 .Va int\ *prt ) :
1338 .It Li \&.Va char\ s\ ]\ )\ )\ ,
1339 .Va char\ s ] ) ) ,
1342 It is an error to call
1343 .Ql \&.Va
1344 without any arguments.
1346 .Ql \&.Va
1347 macro is parsed and is callable.
1348 .Ss Manual Page Cross References
1350 .Ql \&.Xr
1351 macro expects the first argument to be
1352 a manual page name, and the second argument, if it exists,
1353 to be either a section page number or punctuation.
1355 remaining arguments are assumed to be punctuation.
1357 .Dl Usage: .Xr man_page [1,...,9] \*(Pu
1358 .Bl -tag -width ".Xr mdoc 7 ) ) ," -compact -offset 14n
1359 .It Li \&.Xr mdoc
1360 .Xr mdoc
1361 .It Li \&.Xr mdoc\ ,
1362 .Xr mdoc ,
1363 .It Li \&.Xr mdoc 7
1364 .Xr mdoc 7
1365 .It Li \&.Xr mdoc 7\ )\ )\ ,
1366 .Xr mdoc 7 ) ) ,
1370 .Ql \&.Xr
1371 macro is parsed and is callable.
1372 It is an error to call
1373 .Ql \&.Xr
1374 without
1375 any arguments.
1376 .Sh GENERAL TEXT DOMAIN
1377 .Ss AT&T Macro
1378 .Bd -literal -offset indent -compact
1379 Usage: .At [v1 .. v7 | 32v | V.1 | V.4] ... \*(Pu
1381 .Bl -tag -width ".At v6 ) ," -compact -offset 14n
1382 .It Li ".At"
1384 .It Li ".At v6 ."
1385 .At v6 .
1389 .Ql \&.At
1390 macro is
1391 .Em not
1392 parsed and
1393 .Em not
1394 callable. It accepts at most two arguments.
1395 .Ss BSD Macro
1396 .Dl Usage: .Bx [Version/release] ... \*(Pu
1397 .Bl -tag -width ".Bx 4.3 ) ," -compact -offset 14n
1398 .It Li ".Bx"
1400 .It Li ".Bx 4.3 ."
1401 .Bx 4.3 .
1405 .Ql \&.Bx
1406 macro is parsed and is callable.
1407 .Ss NetBSD Macro
1408 .Dl Usage: .Nx [Version/release] ... \*(Pu
1409 .Bl -tag -width ".Nx 1.4 ) ," -compact -offset 14n
1410 .It Li ".Nx"
1412 .It Li ".Nx 1.4 ."
1413 .Nx 1.4 .
1417 .Ql \&.Nx
1418 macro is parsed and is callable.
1419 .Ss FreeBSD Macro
1420 .Dl Usage: .Fx [Version/release] ... \*(Pu
1421 .Bl -tag -width ".Fx 2.2 ) ," -compact -offset 14n
1422 .It Li ".Fx"
1424 .It Li ".Fx 2.2 ."
1425 .Fx 2.2 .
1429 .Ql \&.Fx
1430 macro is parsed and is callable.
1431 .Ss UNIX Macro
1432 .Dl Usage: .Ux ... \*(Pu
1433 .Bl -tag -width ".Ux 4.3 ) ," -compact -offset 14n
1434 .It Li ".Ux"
1439 .Ql \&.Ux
1440 macro is parsed and is callable.
1441 .Ss Emphasis Macro
1442 Text may be stressed or emphasized with the
1443 .Ql \&.Em
1444 macro.
1445 The usual font for emphasis is italic.
1447 .Dl Usage: .Em argument ... \*(Pu
1448 .Bl -tag -width ".Em vide infra ) ) ," -compact -offset 14n
1449 .It Li ".Em does not"
1450 .Em does not
1451 .It Li ".Em exceed 1024 ."
1452 .Em exceed 1024 .
1453 .It Li ".Em vide infra ) ) ,"
1454 .Em vide infra ) ) ,
1456 .\" .Pp
1457 .\" The emphasis can be forced across several lines of text by using
1458 .\" the
1459 .\" .Ql \&.Bf
1460 .\" macro discussed in
1461 .\" .Sx Modes
1462 .\" under
1463 .\" .Sx PAGE STRUCTURE DOMAIN .
1464 .\" .Pp
1465 .\" .Bf -emphasis
1466 .\" We are certain the reason most people desire a Harvard MBA
1467 .\" so they can become to be successful philanthropists.  Only
1468 .\" mathematicians and physicists go to graduate school strictly
1469 .\" to acquire infinite wealthy and fame. Its that inifinity
1470 .\" word that does it to them. Ruins them.
1471 .\" .Ef
1474 .Ql \&.Em
1475 macro is parsed and is callable.
1476 It is an error to call
1477 .Ql \&.Em
1478 without arguments.
1479 .Ss Enclosure and Quoting Macros
1480 The concept of enclosure is similar to quoting.
1481 The object being to enclose one or more strings between
1482 a pair of characters like quotes or parentheses.
1483 The terms quoting and enclosure are used
1484 interchangeably throughout this document.
1485 Most of the
1486 one line enclosure macros end
1487 in small letter
1488 .Ql q
1489 to give a hint of quoting, but there are a few irregularities.
1490 For each enclosure macro
1491 there is also a pair of open and close macros which end
1492 in small letters
1493 .Ql o
1495 .Ql c
1496 respectively.
1497 These can be used across one or more lines of text
1498 and while they have nesting limitations, the one line quote macros
1499 can be used inside
1500 of them.
1502 .ne 5
1503 .Bd -filled -offset indent
1504 .Bl -column "quote " "close " "open " "Enclose Stringx(in XX) " XXstringXX
1505 .Em " Quote      Close   Open   Function        Result"
1506 \&.Aq   .Ac     .Ao     Angle Bracket Enclosure <string>
1507 \&.Bq   .Bc     .Bo     Bracket Enclosure       [string]
1508 \&.Dq   .Dc     .Do     Double Quote    ``string''
1509         .Ec     .Eo     Enclose String (in XX)  XXstringXX
1510 \&.Pq   .Pc     .Po     Parenthesis Enclosure   (string)
1511 \&.Ql                   Quoted Literal  `st' or string
1512 \&.Qq   .Qc     .Qo     Straight Double Quote   "string"
1513 \&.Sq   .Sc     .So     Single Quote    `string'
1517 Except for the irregular macros noted below, all
1518 of the quoting macros are parsed and callable.
1519 All handle punctuation properly, as long as it
1520 is presented one character at a time and separated by spaces.
1521 The quoting macros examine opening and closing punctuation
1522 to determine whether it comes before or after the
1523 enclosing string. This makes some nesting possible.
1524 .Bl -tag -width xxx,xxxx
1525 .It Li \&.Ec , \&.Eo
1526 These macros expect the first argument to be the
1527 opening and closing strings respectively.
1528 .It Li \&.Ql
1529 The quoted literal macro behaves differently for
1530 .Xr troff
1531 than
1532 .Xr nroff .
1533 If formatted with
1534 .Xr nroff ,
1535 a quoted literal is always quoted. If formatted with
1536 troff, an item is only quoted if the width
1537 of the item is less than three constant width characters.
1538 This is to make short strings more visible where the font change
1539 to literal (constant width) is less noticeable.
1540 .It Li \&.Pf
1541 The prefix macro is not callable, but it is parsed:
1542 .Bl -tag -width "(namexx" -offset indent
1543 .It Li ".Pf ( Fa name2"
1544 becomes
1545 .Pf ( Fa name2 .
1547 .It Li \&.Ns
1549 .Ql \&.Ns
1550 (no space) macro, which
1551 .Em is
1552 callable,
1553 performs the analogous suffix function.
1554 .It Li ".Ap
1555 The \&.Ap macro inserts an apostrophe and exits any special text modes,
1556 continuing in
1557 .Li \&.No
1558 mode.
1561 .ne 4
1562 Examples of quoting:
1563 .Bl -tag -width ".Aq Pa ctype.h ) ,xxxxxxxx" -compact -offset indent
1564 .It Li \&.Aq
1566 .It Li \&.Aq \&Ar ctype.h\ )\ ,
1567 .Aq Ar ctype.h ) ,
1568 .It Li \&.Bq
1570 .It Li \&.Bq \&Em Greek \&, French \&.
1571 .Bq Em Greek , French .
1572 .It Li \&.Dq
1574 .It Li ".Dq string abc ."
1575 .Dq string abc .
1576 .It Li ".Dq \'^[A-Z]\'"
1577 .Dq \'^[A-Z]\'
1578 .It Li "\&.Ql man mdoc"
1579 .Ql man mdoc
1580 .It Li \&.Qq
1582 .It Li "\&.Qq string ) ,"
1583 .Qq string ) ,
1584 .It Li "\&.Qq string Ns ),"
1585 .Qq string Ns ),
1586 .It Li \&.Sq
1588 .It Li "\&.Sq string
1589 .Sq string
1590 .It Li "\&.Em or Ap ing
1591 .Em or Ap ing
1594 For a good example of nested enclosure macros, see the
1595 .Ql \&.Op
1596 option macro.
1597 It was created from the same
1598 underlying enclosure macros as those presented in the list
1599 above.
1601 .Ql \&.Xo
1603 .Ql \&.Xc
1604 extended argument list macros
1605 were also built from the same underlying routines and are a good
1606 example of
1607 .Nm \-mdoc
1608 macro usage at its worst.
1609 .Ss No\-Op or Normal Text Macro
1610 The macro
1611 .Li \&.No
1613 a hack for words in a macro command line which should
1614 .Em not
1615 be formatted and follows the conventional syntax
1616 for content macros.
1617 .Ss No Space Macro
1619 .Ql \&.Ns
1620 macro eliminates unwanted spaces in between macro requests.
1621 It is useful for old style argument lists where there is no space
1622 between the flag and argument:
1623 .Bl -tag -width ".Op Fl I Ns Ar directoryxx" -offset indent
1624 .It Li ".Op Fl I Ns Ar directory"
1625 produces
1626 .Op Fl I Ns Ar directory
1629 Note: the
1630 .Ql \&.Ns
1631 macro always invokes the
1632 .Ql \&.No
1633 macro after eliminating the space unless another macro name
1634 follows it.
1635 The macro
1636 .Ql \&.Ns
1637 is parsed and is callable.
1638 .Ss Section Cross References
1640 .Ql \&.Sx
1641 macro designates a reference to a section header
1642 within the same document.
1643 It is parsed and is callable.
1645 .Bl -tag -width "Li \&.Sx FILES" -offset 14n
1646 .It Li \&.Sx FILES
1647 .Sx FILES
1649 .Ss Symbolic
1650 The symbolic emphasis macro is generally a boldface macro in
1651 either the symbolic sense or the traditional English usage.
1653 .Dl Usage: .Sy symbol ... \*(Pu
1654 .Bl -tag -width ".Sy Important Noticex" -compact -offset 14n
1655 .It Li \&.Sy Important Notice
1656 .Sy Important Notice
1660 .Ql \&.Sy
1661 macro is parsed and is callable.
1662 Arguments to
1663 .Ql \&.Sy
1664 may be quoted.
1665 .Ss References and Citations
1666 The following macros make a modest attempt to handle references.
1667 At best, the macros make it convenient to manually drop in a subset of
1668 refer style references.
1670 .Bl -tag -width 6n -offset indent -compact
1671 .It Li ".Rs"
1672 Reference Start.
1673 Causes a line break and begins collection
1674 of reference information until the
1675 reference end macro is read.
1676 .It Li ".Re"
1677 Reference End.
1678 The reference is printed.
1679 .It Li ".%A"
1680 Reference author name, one name per invocation.
1681 .It Li ".%B"
1682 Book title.
1683 .It Li ".\&%C"
1684 City/place.
1685 .It Li ".\&%D"
1686 Date.
1687 .It Li ".%J"
1688 Journal name.
1689 .It Li ".%N"
1690 Issue number.
1691 .It Li ".%O"
1692 Optional information.
1693 .It Li ".%P"
1694 Page number.
1695 .It Li ".%R"
1696 Report name.
1697 .It Li ".%T"
1698 Title of article.
1699 .It Li ".%V"
1700 Volume(s).
1703 The macros beginning with
1704 .Ql %
1705 are not callable, and are parsed only for the trade name macro which
1706 returns to its caller.
1707 (And not very predictably at the moment either.)
1708 The purpose is to allow trade names
1709 to be pretty printed in
1710 .Xr troff Ns / Ns Xr ditroff
1711 output.
1712 .Ss Trade Names (or Acronyms and Type Names)
1713 The trade name macro is generally a small caps macro for
1714 all upper case words longer than two characters.
1716 .Dl Usage: .Tn symbol ... \*(Pu
1717 .Bl -tag -width ".Tn ASCII" -compact -offset 14n
1718 .It Li \&.Tn DEC
1719 .Tn DEC
1720 .It Li \&.Tn ASCII
1721 .Tn ASCII
1725 .Ql \&.Tn
1726 macro
1727 is parsed and is callable by other macros.
1728 .Ss Extended Arguments
1730 .Li \&.Xo
1732 .Li \&.Xc
1733 macros allow one to extend an argument list
1734 on a macro boundary.
1735 Argument lists cannot
1736 be extended within a macro
1737 which expects all of its arguments on one line such
1739 .Ql \&.Op .
1741 Here is an example of
1742 .Ql \&.Xo
1743 using the space mode macro to turn spacing off:
1744 .Bd -literal -offset indent
1745 \&.Sm off
1746 \&.It Xo Sy I Ar operation
1747 \&.No \een Ar count No \een
1748 \&.Xc
1749 \&.Sm on
1752 Produces
1753 .Bd -filled -offset indent
1754 .Bl -tag -width flag -compact
1755 .Sm off
1756 .It Xo Sy I Ar operation
1757 .No \en Ar count No \en
1759 .Sm on
1763 Another one:
1764 .Bd -literal -offset indent
1765 \&.Sm off
1766 \&.It Cm S No \&/ Ar old_pattern Xo
1767 \&.No \&/ Ar new_pattern
1768 \&.No \&/ Op Cm g
1769 \&.Xc
1770 \&.Sm on
1773 Produces
1774 .Bd -filled -offset indent
1775 .Bl -tag -width flag -compact
1776 .Sm off
1777 .It Cm S No \&/ Ar old_pattern Xo
1778 .No \&/ Ar new_pattern
1779 .No \&/ Op Cm g
1781 .Sm on
1785 Another example of
1786 .Ql \&.Xo
1787 and using enclosure macros:
1788 Test the value of an variable.
1789 .Bd -literal -offset indent
1790 \&.It Xo
1791 \&.Ic .ifndef
1792 \&.Oo \e&! Oc Ns Ar variable
1793 \&.Op Ar operator variable ...
1794 \&.Xc
1797 Produces
1798 .Bd -filled -offset indent
1799 .Bl -tag -width flag -compact
1800 .It Xo
1801 .Ic .ifndef
1802 .Oo \&! Oc Ns Ar variable
1803 .Op Ar operator variable ...
1808 All of the above examples have used the
1809 .Ql \&.Xo
1810 macro on the argument list of the
1811 .Ql \&.It
1812 (list-item)
1813 macro.
1814 The extend macros are not used very often, and when they are
1815 it is usually to extend the list-item argument list.
1816 Unfortunately, this is also where the extend macros are the
1817 most finicky.
1818 In the first two examples, spacing was turned off;
1819 in the third, spacing was desired in part of the output but
1820 not all of it.
1821 To make these macros work in this situation make sure
1823 .Ql \&.Xo
1825 .Ql \&.Xc
1826 macros are placed as shown in the third example.
1827 If the
1828 .Ql \&.Xo
1829 macro is not alone on the
1830 .Ql \&.It
1831 argument list, spacing will be unpredictable.
1833 .Ql \&.Ns
1834 (no space macro)
1835 must not occur as the first or last macro on a line
1836 in this situation.
1837 Out of 900 manual pages (about 1500 actual pages)
1838 currently released with
1840 only fifteen use the
1841 .Ql \&.Xo
1842 macro.
1843 .Sh PAGE STRUCTURE DOMAIN
1844 .Ss Section Headers
1845 The first three
1846 .Ql \&.Sh
1847 section header macros
1848 list below are required in every
1849 man page.
1850 The remaining section headers
1851 are recommended at the discretion of the author
1852 writing the manual page.
1854 .Ql \&.Sh
1855 macro can take up to nine arguments.
1856 It is parsed and but is not callable.
1857 .Bl -tag -width ".Sh SYNOPSIS"
1858 .It \&.Sh NAME
1860 .Ql \&.Sh NAME
1861 macro is mandatory.
1862 If not specified,
1863 the headers, footers and page layout defaults
1864 will not be set and things will be rather unpleasant.
1866 .Sx NAME
1867 section consists of at least three items.
1868 The first is the
1869 .Ql \&.Nm
1870 name macro naming the subject of the man page.
1871 The second is the Name Description macro,
1872 .Ql \&.Nd ,
1873 which separates the subject
1874 name from the third item, which is the description.
1876 description should be the most terse and lucid possible,
1877 as the space available is small.
1878 .It \&.Sh SYNOPSIS
1880 .Sx SYNOPSIS
1881 section describes the typical usage of the
1882 subject of a man page.
1883 The  macros required
1884 are either
1885 .Ql ".Nm" ,
1886 .Ql ".Cd" ,
1887 .Ql ".Fn" ,
1888 (and possibly
1889 .Ql ".Fo" ,
1890 .Ql ".Fc" ,
1891 .Ql ".Fd" ,
1892 .Ql ".Ft"
1893 macros).
1894 The function name
1895 macro
1896 .Ql ".Fn"
1897 is required
1898 for manual page sections 2 and 3, the command and general
1899 name macro
1900 .Ql \&.Nm
1901 is required for sections 1, 5, 6, 7, 8.
1902 Section 4 manuals require a
1903 .Ql ".Nm" , ".Fd"
1904 or a
1905 .Ql ".Cd"
1906 configuration device usage macro.
1907 Several other macros may be necessary to produce
1908 the synopsis line as shown below:
1910 .Bd -filled -offset indent
1911 .Nm cat
1912 .Op Fl benstuv
1913 .Op Fl
1917 The following macros were used:
1919 .Dl \&.Nm cat
1920 .Dl \&.Op \&Fl benstuv
1921 .Dl \&.Op \&Fl
1922 .Dl \&.Ar
1924 .Sy Note :
1925 The macros
1926 .Ql \&.Op ,
1927 .Ql \&.Fl ,
1929 .Ql \&.Ar
1930 recognize the pipe bar character
1931 .Ql \*(Ba ,
1932 so a command line such as:
1934 .Dl ".Op Fl a | Fl b"
1936 will not go orbital.
1937 .Xr Troff
1938 normally interprets a \*(Ba as a special operator.
1940 .Sx PREDEFINED STRINGS
1941 for a usable \*(Ba
1942 character in other situations.
1943 .It \&.Sh DESCRIPTION
1944 In most cases the first text in the
1945 .Sx DESCRIPTION
1946 section
1947 is a brief paragraph on the command, function or file,
1948 followed by a lexical list of options and respective
1949 explanations.
1950 To create such a list, the
1951 .Ql \&.Bl
1952 begin-list,
1953 .Ql \&.It
1954 list-item and
1955 .Ql \&.El
1956 end-list
1957 macros are used (see
1958 .Sx Lists and Columns
1959 below).
1962 The following
1963 .Ql \&.Sh
1964 section headers are part of the
1965 preferred manual page layout and must be used appropriately
1966 to maintain consistency.
1967 They are listed in the order
1968 in which they would be used.
1969 .Bl -tag -width SYNOPSIS
1970 .It \&.Sh ENVIRONMENT
1972 .Sx ENVIRONMENT
1973 section should reveal any related
1974 environment
1975 variables and clues to their behavior and/or usage.
1976 .It \&.Sh EXAMPLES
1977 There are several ways to create examples.
1980 .Sx EXAMPLES
1981 section below
1982 for details.
1983 .It \&.Sh FILES
1984 Files which are used or created by the man page subject
1985 should be listed via the
1986 .Ql \&.Pa
1987 macro in the
1988 .Sx FILES
1989 section.
1990 .It \&.Sh SEE ALSO
1991 References to other material on the man page topic and
1992 cross references to other relevant man pages should
1993 be placed in the
1994 .Sx SEE ALSO
1995 section.
1996 Cross references
1997 are specified using the
1998 .Ql \&.Xr
1999 macro.
2000 At this time
2001 .Xr refer 1
2002 style references are not accommodated.
2004 It is recommended that the cross references are sorted on the section
2005 number, and then alphabetically on the names within a section.
2006 .It \&.Sh STANDARDS
2007 If the command, library function or file adheres to a
2008 specific implementation such as
2009 .St -p1003.2
2011 .St -ansiC
2012 this should be noted here.
2013 If the
2014 command does not adhere to any standard, its history
2015 should be noted in the
2016 .Sx HISTORY
2017 section.
2018 .It \&.Sh HISTORY
2019 Any command which does not adhere to any specific standards
2020 should be outlined historically in this section.
2021 .It \&.Sh AUTHORS
2022 Credits, if need be, should be placed here.
2023 .It \&.Sh DIAGNOSTICS
2024 Diagnostics from a command should be placed in this section.
2025 .It \&.Sh ERRORS
2026 Specific error handling, especially from library functions
2027 (man page sections 2 and 3) should go here.
2029 .Ql \&.Er
2030 macro is used to specify an errno.
2031 .It \&.Sh BUGS
2032 Blatant problems with the topic go here...
2035 User specified
2036 .Ql \&.Sh
2037 sections may be added,
2038 for example, this section was set with:
2039 .Bd -literal -offset 14n
2040 \&.Sh PAGE LAYOUT MACROS
2042 .Ss Paragraphs and Line Spacing.
2043 .Bl -tag -width 6n
2044 .It \&.Pp
2045 The \&.Pp paragraph command may
2046 be used to specify a line space where necessary.
2047 The macro is not necessary after a
2048 .Ql \&.Sh
2050 .Ql \&.Ss
2051 macro or before
2053 .Ql \&.Bl
2054 macro.
2055 (The
2056 .Ql \&.Bl
2057 macro asserts a vertical distance unless the -compact flag is given).
2059 .\" This worked with version one, need to redo for version three
2060 .\" .Pp
2061 .\" .Ds I
2062 .\" .Cw (ax+bx+c) \ is\ produced\ by\ \&
2063 .\" .\".Cw (ax+bx+c) \&.Va_by_) \&_and_\& \&[?/]m_b1_e1_f1[?/]\&
2064 .\" .Cl Cx \t\t
2065 .\" .Li \&.Cx\ (
2066 .\" .Cx
2067 .\" .Cl Cx \t\t
2068 .\" .Li \&.Va ax
2069 .\" .Cx
2070 .\" .Cl Cx \t\t
2071 .\" .Li \&.Sy \+
2072 .\" .Cx
2073 .\" .Cl Cx \&(\&
2074 .\" .Va ax
2075 .\" .Cx +
2076 .\" .Va by
2077 .\" .Cx +
2078 .\" .Va c )
2079 .\" .Cx \t
2080 .\" .Em is produced by
2081 .\" .Cx \t
2082 .\" .Li \&.Va by
2083 .\" .Cx
2084 .\" .Cl Cx \t\t
2085 .\" .Li \&.Sy \+
2086 .\" .Cx
2087 .\" .Cl Cx \t\t
2088 .\" .Li \&.Va c )
2089 .\" .Cx
2090 .\" .Cl Cx \t\t
2091 .\" .Li \&.Cx
2092 .\" .Cx
2093 .\" .Cw
2094 .\" .De
2095 .\" .Pp
2096 .\" This example shows the same equation in a different format.
2097 .\" The spaces
2098 .\" around the
2099 .\" .Li \&+
2100 .\" signs were forced with
2101 .\" .Li \e :
2102 .\" .Pp
2103 .\" .Ds I
2104 .\" .Cw (ax\ +\ bx\ +\ c) \ is\ produced\ by\ \&
2105 .\" .\".Cw (ax+bx+c) \&.Va_by_) \&_and_\& \&[?/]m_b1_e1_f1[?/]\&
2106 .\" .Cl Cx \t\t
2107 .\" .Li \&.Cx\ (
2108 .\" .Cx
2109 .\" .Cl Cx \t\t
2110 .\" .Li \&.Va a
2111 .\" .Cx
2112 .\" .Cl Cx \t\t
2113 .\" .Li \&.Sy x
2114 .\" .Cx
2115 .\" .Cl Cx \t\t
2116 .\" .Li \&.Cx \e\ +\e\ \e&
2117 .\" .Cx
2118 .\" .Cl Cx \&(\&
2119 .\" .Va a
2120 .\" .Sy x
2121 .\" .Cx \ +\ \&
2122 .\" .Va b
2123 .\" .Sy y
2124 .\" .Cx \ +\ \&
2125 .\" .Va c )
2126 .\" .Cx \t
2127 .\" .Em is produced by
2128 .\" .Cl Cx \t\t
2129 .\" .Li \&.Va b
2130 .\" .Cx
2131 .\" .Cl Cx \t\t
2132 .\" .Li \&.Sy y
2133 .\" .Cx
2134 .\" .Cl Cx \t\t
2135 .\" .Li \&.Cx \e\ +\e\ \e&
2136 .\" .Cx
2137 .\" .Cl Cx \t\t
2138 .\" .Li \&.Va c )
2139 .\" .Cx
2140 .\" .Cl Cx \t\t
2141 .\" .Li \&.Cx
2142 .\" .Cx
2143 .\" .Cw
2144 .\" .De
2145 .\" .Pp
2146 .\" The incantation below was
2147 .\" lifted from the
2148 .\" .Xr adb 1
2149 .\" manual page:
2150 .\" .Pp
2151 .\" .Ds I
2152 .\" .Cw \&[?/]m_b1_e1_f1[?/]\& is\ produced\ by
2153 .\" .Cl Cx \t\t
2154 .\" .Li \&.Cx Op Sy ?/
2155 .\" .Cx
2156 .\" .Cl Cx \t\t
2157 .\" .Li \&.Nm m
2158 .\" .Cx
2159 .\" .Cl Cx Op Sy ?/
2160 .\" .Nm m
2161 .\" .Ad \ b1 e1 f1
2162 .\" .Op Sy ?/
2163 .\" .Cx \t
2164 .\" .Em is produced by
2165 .\" .Cx \t
2166 .\" .Li \&.Ar \e\ b1 e1 f1
2167 .\" .Cx
2168 .\" .Cl Cx \t\t
2169 .\" .Li \&.Op Sy ?/
2170 .\" .Cx
2171 .\" .Cl Cx \t\t
2172 .\" .Li \&.Cx
2173 .\" .Cx
2174 .\" .Cw
2175 .\" .De
2176 .\" .Pp
2177 .Ss Keeps
2178 The only keep that is implemented at this time is for words.
2179 The macros are
2180 .Ql \&.Bk
2181 (begin-keep)
2183 .Ql \&.Ek
2184 (end-keep).
2185 The only option that
2186 .Ql \&.Bl
2187 accepts is
2188 .Fl words
2189 and is useful for preventing line breaks in the middle of options.
2190 In the example for the make command line arguments (see
2191 .Sx What's in a name ) ,
2192 the keep prevented
2193 .Xr nroff
2194 from placing up the
2195 flag and the argument
2196 on separate lines.
2197 (Actually, the option macro used to prevent this from occurring,
2198 but was dropped when the decision (religious) was made to force
2199 right justified margins in
2200 .Xr troff
2201 as options in general look atrocious when spread across a sparse
2202 line.
2203 More work needs to be done with the keep macros, a
2204 .Fl line
2205 option needs to be added.)
2206 .Ss Examples and Displays
2207 There are six types of displays, a quickie one line indented display
2208 .Ql \&.D1 ,
2209 a quickie one line literal display
2210 .Ql \&.Dl ,
2211 and block literal, block filled, block unfilled, and block ragged which use
2213 .Ql \&.Bd
2214 begin-display
2216 .Ql \&.Ed
2217 end-display macros.
2219 .Bl -tag -width \&.Dlxx
2220 .It Li \&.D1
2221 (D-one) Display one line of indented text.
2222 This macro is parsed, but it is not callable.
2224 .Dl Fl ldghfstru
2226 The above was produced by:
2227 .Li \&.Dl Fl ldghfstru .
2228 .It Li \&.Dl
2229 (D-ell)
2230 Display one line of indented
2231 .Em literal
2232 text.
2234 .Ql \&.Dl
2235 example macro has been used throughout this
2236 file.
2237 It allows
2238 the indent (display) of one line of text.
2239 Its default font is set to
2240 constant width (literal) however
2241 it is parsed and will recognized other macros.
2242 It is not callable however.
2244 .Dl % ls -ldg /usr/local/bin
2246 The above was produced by
2247 .Li \&.Dl % ls -ldg /usr/local/bin .
2248 .It Li \&.Bd
2249 Begin-display.
2251 .Ql \&.Bd
2252 display must be ended with the
2253 .Ql \&.Ed
2254 macro.
2255 Displays may be nested within lists, but may
2256 .Em not
2257 contain other displays; this also prohibits nesting
2258 of .D1 and .Dl one-line displays.
2259 .Ql \&.Bd
2260 has the following syntax:
2262 .Dl ".Bd display-type [-offset offset_value] [-compact]"
2264 The display-type must be one of the following four types and
2265 may have an offset specifier for indentation:
2266 .Ql \&.Bd .
2268 .Bl -tag -width "file file_name  " -compact
2269 .It Fl ragged
2270 Fill, but do not adjust the right margin.
2271 .It Fl unfilled
2272 Do not fill: display a block of text as typed, the
2273 right (and left) margin edges are left ragged.
2274 .It Fl filled
2275 Display a filled (formatted) block.
2276 The block of text is formatted (the edges are filled \-
2277 not left unjustified).
2278 .It Fl literal
2279 Display a literal block, useful for source code or
2280 simple tabbed or spaced text.
2281 .It Fl file Ar file_name
2282 The file name following the
2283 .Fl file
2284 flag is read and displayed.
2285 Literal mode is
2286 asserted and tabs are set at 8 constant width character
2287 intervals, however any
2288 .Xr troff/ Ns Nm \-mdoc
2289 commands in file will be processed.
2290 .It Fl offset Ar string
2292 .Fl offset
2293 is specified with one of the following strings, the string
2294 is interpreted to indicate the level of indentation for the
2295 forthcoming block of text:
2297 .Bl -tag -width "indent-two" -compact
2298 .It Ar left
2299 Align block on the current left margin,
2300 this is the default mode of
2301 .Ql \&.Bd .
2302 .It Ar center
2303 Supposedly center the block.
2304 At this time
2305 unfortunately, the block merely gets
2306 left aligned about an imaginary center margin.
2307 .It Ar indent
2308 Indents by one default indent value or tab.
2309 The default
2310 indent value is also used for the
2311 .Ql \&.D1
2312 display so one is guaranteed the two types of displays
2313 will line up.
2314 This indent is normally set to 6n or about two
2315 thirds of an inch (six constant width characters).
2316 .It Ar indent-two
2317 Indents two times the default indent value.
2318 .It Ar right
2319 This
2320 .Em left
2321 aligns the block about two inches from
2322 the right side of the page.
2323 This macro needs
2324 work and perhaps may never do the right thing by
2325 .Xr troff .
2328 .It ".Ed"
2329 End-display.
2331 .Ss Tagged Lists and Columns
2332 There are several types of lists which may be initiated with the
2333 .Ql ".Bl"
2334 begin-list macro.
2335 Items within the list
2336 are specified with the
2337 .Ql ".It"
2338 item macro and
2339 each list must end with the
2340 .Ql ".El"
2341 macro.
2342 Lists other than
2343 .Li \-enum
2344 may be nested within themselves and within displays.
2345 The use of columns inside of lists or lists inside of columns
2346 is unproven.
2348 In addition, several list attributes may be specified such as
2349 the width of a tag, the list offset, and compactness
2350 (blank lines between items allowed or disallowed).
2351 Most of this document has been formatted with a tag style list
2352 .Pq Fl tag .
2353 For a change of pace, the list-type used to present the list-types
2354 is an over-hanging list
2355 .Pq Fl ohang .
2356 This type of list is quite popular with
2357 .Tn TeX
2358 users, but might look a bit funny after having read many pages of
2359 tagged lists.
2360 The following list types are accepted by
2361 .Ql ".Bl" :
2363 .Bl -ohang -compact
2364 .It Fl bullet
2365 .It Fl dash
2366 .It Fl enum
2367 .It Fl hyphen
2368 .It Fl item
2369 These five are the simplest types of lists.
2370 Once the
2371 .Ql ".Bl"
2372 macro has been given, items in the list are merely
2373 indicated by a line consisting solely of the
2374 .Ql ".It"
2375 macro.
2376 For example, the source text for a simple enumerated list
2377 would look like:
2378 .Bd -literal -offset indent-two
2379 \&.Bl -enum -compact
2380 \&.It
2381 \&Item one goes here.
2382 \&.It
2383 \&And item two here.
2384 \&.It
2385 \&Lastly item three goes here.
2386 \&.El
2389 The results:
2391 .Bl -enum -offset indent-two -compact
2393 Item one goes here.
2395 And item two here.
2397 Lastly item three goes here.
2400 A simple bullet list construction:
2401 .Bd -literal -offset indent-two
2402 \&.Bl -bullet -compact
2403 \&.It
2404 \&Bullet one goes here.
2405 \&.It
2406 \&Bullet two here.
2407 \&.El
2410 Produces:
2411 .Bl -bullet -offset indent-two -compact
2413 Bullet one goes here.
2415 Bullet two here.
2418 .It Fl tag
2419 .It Fl diag
2420 .It Fl hang
2421 .It Fl ohang
2422 .It Fl inset
2423 These list-types collect arguments specified with the
2424 .Ql \&.It
2425 macro and create a label which may be
2426 .Em inset
2427 into the forthcoming text,
2428 .Em hanged
2429 from the forthcoming text,
2430 .Em overhanged
2431 from above and not indented or
2432 .Em tagged .
2433 This
2434 list was constructed with the
2435 .Ql Fl ohang
2436 list-type.
2438 .Ql \&.It
2439 macro is parsed only for the inset, hang
2440 and tag list-types and is not callable.
2441 Here is an example of inset labels:
2442 .Bl -inset -offset indent
2443 .It Em Tag
2444 The tagged list (also called a tagged paragraph) is the
2445 most common type of list used in the Berkeley manuals. Use a
2446 .Fl width
2447 attribute as described below.
2448 .It Em Diag
2449 Diag lists create section four diagnostic lists
2450 and are similar to inset lists except callable
2451 macros are ignored.
2452 .It Em Hang
2453 Hanged labels are a matter of taste.
2454 .It Em Ohang
2455 Overhanging labels are nice when space is constrained.
2456 .It Em Inset
2457 Inset labels are useful for controlling blocks of
2458 paragraphs and are valuable for converting
2459 .Nm \-mdoc
2460 manuals to other formats.
2463 Here is the source text which produced the above example:
2464 .Bd -literal -offset indent
2465 \&.Bl -inset -offset indent
2466 \&.It Em Tag
2467 \&The tagged list (also called a tagged paragraph) is the
2468 \&most common type of list used in the Berkeley manuals.
2469 \&.It Em Diag
2470 \&Diag lists create section four diagnostic lists
2471 \&and are similar to inset lists except callable
2472 \&macros are ignored.
2473 \&.It Em Hang
2474 \&Hanged labels are a matter of taste.
2475 \&.It Em Ohang
2476 \&Overhanging labels are nice when space is constrained.
2477 \&.It Em Inset
2478 \&Inset labels are useful for controlling blocks of
2479 \&paragraphs and are valuable for converting
2480 \&.Nm \-mdoc
2481 \&manuals to other formats.
2482 \&.El
2485 Here is a hanged list with just one item:
2486 .Bl -hang -offset indent
2487 .It Em Hanged
2488 labels appear similar to tagged lists when the
2489 label is smaller than the label width.
2490 .It Em Longer hanged list labels
2491 blend in to the paragraph unlike
2492 tagged paragraph labels.
2495 And the unformatted text which created it:
2496 .Bd -literal -offset indent
2497 \&.Bl -hang -offset indent
2498 \&.It Em Hanged
2499 \&labels appear similar to tagged lists when the
2500 \&label is smaller than the label width.
2501 \&.It Em Longer hanged list labels
2502 \&blend in to the paragraph unlike
2503 \&tagged paragraph labels.
2504 \&.El
2507 The tagged list which follows uses a width specifier to control
2508 the width of the tag.
2510 .Bl -tag -width "PAGEIN" -compact -offset indent
2511 .It SL
2512 sleep time of the process (seconds blocked)
2513 .It PAGEIN
2514 number of disk
2515 .Tn I/O Ns 's
2516 resulting from references
2517 by the process to pages not loaded in core.
2518 .It UID
2519 numerical user-id of process owner
2520 .It PPID
2521 numerical id of parent of process process priority
2522 (non-positive when in non-interruptible wait)
2525 The raw text:
2526 .Bd -literal -offset indent
2527 \&.Bl -tag -width "PAGEIN" -compact -offset indent
2528 \&.It SL
2529 \&sleep time of the process (seconds blocked)
2530 \&.It PAGEIN
2531 \&number of disk
2532 \&.Tn I/O Ns 's
2533 \&resulting from references
2534 \&by the process to pages not loaded in core.
2535 \&.It UID
2536 \&numerical user-id of process owner
2537 \&.It PPID
2538 \&numerical id of parent of process process priority
2539 \&(non-positive when in non-interruptible wait)
2540 \&.El
2543 Acceptable width specifiers:
2544 .Bl -tag -width Ar -offset indent
2545 .It Fl width Ar "\&Fl"
2546 sets the width to the default width for a flag.
2547 All callable
2548 macros have a default width value.
2550 .Ql \&.Fl ,
2551 value is presently
2552 set to ten constant width characters or about five sixth of
2553 an inch.
2554 .It Fl width Ar "24n"
2555 sets the width to 24 constant width characters or about two
2556 inches.
2558 .Ql n
2559 is absolutely necessary for the scaling to work correctly.
2560 .It Fl width Ar "ENAMETOOLONG"
2561 sets width to the constant width length of the
2562 string given.
2563 .It Fl width  Ar "\\*qint mkfifo\\*q"
2564 again, the width is set to the constant width of the string
2565 given.
2568 If a width is not specified for the tag list type, the first
2569 time
2570 .Ql \&.It
2571 is invoked, an attempt is made to determine an appropriate
2572 width.
2573 If the first argument to
2574 .Ql ".It"
2575 is a callable macro, the default width for that macro will be used
2576 as if the macro name had been supplied as the width.
2577 However,
2578 if another item in the list is given with a different callable
2579 macro name, a new and nested list is assumed. This effectively
2580 means that
2581 .Fl width
2582 is required for the tag list type.
2584 .It Fl column
2585 This list type generates multiple columns.
2586 The number of columns and the width of each column is determined by
2587 the arguments to the
2588 .Fl column
2589 list.
2590 Each
2591 .Ql ".It"
2592 argument is parsed to make a row, each column within the
2593 row is a separate argument separated by a tab or the
2594 .Ql ".Ta"
2595 macro.
2597 The table:
2598 .Bl -column "String" "Nroff" "Troff" -offset indent
2599 .It Sy "String" Ta Sy "Nroff" Ta Sy "Troff"
2600 .It Li "<=" Ta \&<\&= Ta \*(<=
2601 .It Li ">=" Ta \&>\&= Ta \*(>=
2604 was produced by:
2605 .Bd -literal -offset indent
2606 \&.Bl -column "String" "Nroff" "Troff" -offset indent
2607 \&.It Sy "String" Ta Sy "Nroff" Ta Sy "Troff"
2608 \&.It Li "<=" Ta \&<\&= Ta \*(<=
2609 \&.It Li ">=" Ta \&>\&= Ta \*(>=
2610 \&.El
2612 .Sh PREDEFINED STRINGS
2613 The following strings are predefined as may be used by
2614 preceding with the troff string interpreting sequence
2615 .Ql \&\e*(xx
2616 where
2617 .Em xx
2618 is the name of the defined string or as
2619 .Ql \&\e*x
2620 where
2621 .Em x
2622 is the name of the string.
2623 The interpreting sequence may be used any where in the text.
2625 .Bl -column "String " "Nroff " "Troff " -offset indent
2626 .It Sy "String  Nroff   Troff"
2627 .It Li "<=" Ta \&<\&= Ta \*(<=
2628 .It Li ">=" Ta \&>\&= Ta \*(>=
2629 .It Li "Rq" Ta "''" Ta \*(Rq
2630 .It Li "Lq" Ta "``" Ta \*(Lq
2631 .It Li "ua" Ta ^ Ta \*(ua
2632 .It Li "aa" Ta ' Ta \*(aa
2633 .It Li "ga" Ta \` Ta \*(ga
2634 .\" .It Li "sL" Ta ` Ta \*(sL
2635 .\" .It Li "sR" Ta ' Ta \*(sR
2636 .It Li "q" Ta \&" Ta \*q
2637 .It Li "Pi" Ta pi Ta \*(Pi
2638 .It Li "Ne" Ta != Ta \*(Ne
2639 .It Li "Le" Ta <= Ta \*(Le
2640 .It Li "Ge" Ta >= Ta \*(Ge
2641 .It Li "Lt" Ta < Ta \*(Gt
2642 .It Li "Gt" Ta > Ta \*(Lt
2643 .It Li "Pm" Ta +- Ta \*(Pm
2644 .It Li "If" Ta infinity Ta \*(If
2645 .It Li "Na" Ta \fINaN\fP Ta \*(Na
2646 .It Li "Ba" Ta \fR\&|\fP Ta \*(Ba
2649 .Sy Note :
2650 The string named
2651 .Ql q
2652 should be written as
2653 .Ql \e*q
2654 since it is only one char.
2655 .Sh DIAGNOSTICS
2656 The debugging facilities for
2657 .Nm \-mdoc
2658 are limited, but can help detect subtle errors such
2659 as the collision of an argument name with an internal
2660 register or macro name.
2661 (A what?)
2662 A register is an arithmetic storage class for
2663 .Xr troff
2664 with a one or two character name.
2665 All registers internal to
2666 .Nm \-mdoc
2668 .Xr troff
2670 .Xr ditroff
2671 are two characters and
2672 of the form <upper_case><lower_case> such as
2673 .Ql \&Ar ,
2674 <lower_case><upper_case> as
2675 .Ql \&aR
2677 <upper or lower letter><digit> as
2678 .Ql \&C\&1 .
2679 And adding to the muddle,
2680 .Xr troff
2681 has its own internal registers all of which are either
2682 two lower case characters or a dot plus a letter or meta-character
2683 character.
2684 In one of the introduction examples, it was shown how to
2685 prevent the interpretation of a macro name with the escape sequence
2686 .Ql \e& .
2687 This is sufficient for the internal register names also.
2689 .\" Every callable macro name has a corresponding register
2690 .\" of the same name (<upper_case><lower_case>).
2691 .\" There are also specific registers which have
2692 .\" been used for stacks and arrays and are listed in the
2693 .\" .Sx Appendix .
2694 .\" .Bd -ragged -offset 4n
2695 .\" [A-Z][a-z]  registers corresponding to macro names (example ``Ar'')
2696 .\" [a-z][A-Z]  registers corresponding to macro names (example ``aR'')
2697 .\" C[0-9]              argument types (example C1)
2698 .\" O[0-9]              offset stack (displays)
2699 .\" h[0-9]              horizontal spacing stack (lists)
2700 .\" o[0-9]              offset (stack) (lists)
2701 .\" t[0-9]              tag stack (lists)
2702 .\" v[0-9]              vertical spacing stack (lists)
2703 .\" w[0-9]              width tag/label stack
2704 .\" .Ed
2705 .\" .Pp
2706 If a non-escaped register name is given in the argument list of a request
2707 unpredictable behavior will occur.
2708 In general, any time huge portions
2709 of text do not appear where expected in the output, or small strings
2710 such as list tags disappear, chances are there is a misunderstanding
2711 about an argument type in the argument list.
2712 Your mother never intended for you to remember this evil stuff - so here
2713 is a way to find out whether or not your arguments are valid: The
2714 .Ql \&.Db
2715 (debug)
2716 macro displays the interpretation of the argument list for most
2717 macros.
2718 Macros such as the
2719 .Ql \&.Pp
2720 (paragraph)
2721 macro do not contain debugging information.
2722 All of the callable macros do,
2723 and it is strongly advised whenever in doubt,
2724 turn on the
2725 .Ql \&.Db
2726 macro.
2728 .Dl Usage: \&.Db [on | off]
2730 An example of a portion of text with
2731 the debug macro placed above and below an
2732 artificially created problem (a flag argument
2733 .Ql \&aC
2734 which should be
2735 .Ql \e&aC
2736 in order to work):
2737 .Bd -literal -offset indent
2738 \&.Db on
2739 \&.Op Fl aC Ar file )
2740 \&.Db off
2743 The resulting output:
2744 .Bd -literal -offset indent
2745 DEBUGGING ON
2746 DEBUG(argv) MACRO: `.Op'  Line #: 2
2747         Argc: 1  Argv: `Fl'  Length: 2
2748         Space: `'  Class: Executable
2749         Argc: 2  Argv: `aC'  Length: 2
2750         Space: `'  Class: Executable
2751         Argc: 3  Argv: `Ar'  Length: 2
2752         Space: `'  Class: Executable
2753         Argc: 4  Argv: `file'  Length: 4
2754         Space: ` '  Class: String
2755         Argc: 5  Argv: `)'  Length: 1
2756         Space: ` '  Class: Closing Punctuation or suffix
2757         MACRO REQUEST: .Op Fl aC Ar file )
2758 DEBUGGING OFF
2761 The first line of information tells the name of the calling
2762 macro, here
2763 .Ql \&.Op ,
2764 and the line number it appears on.
2765 If one or more files are involved
2766 (especially if text from another file is included) the line number
2767 may be bogus.
2768 If there is only one file, it should be accurate.
2769 The second line gives the argument count, the argument
2770 .Pq Ql \&Fl
2771 and its length.
2772 If the length of an argument is two characters, the
2773 argument is tested to see if it is executable (unfortunately, any
2774 register which contains a non-zero value appears executable).
2775 The third line gives the space allotted for a class, and the
2776 class type.
2777 The problem here is the argument aC should not be
2778 executable.
2779 The four types of classes are string, executable, closing
2780 punctuation and opening punctuation.
2781 The last line shows the entire
2782 argument list as it was read.
2783 In this next example, the offending
2784 .Ql \&aC
2785 is escaped:
2786 .Bd -literal -offset indent
2787 \&.Db on
2788 \&.Em An escaped \e&aC
2789 \&.Db off
2791 .Bd -literal -offset indent
2792 DEBUGGING ON
2793 DEBUG(fargv) MACRO: `.Em'  Line #: 2
2794         Argc: 1  Argv: `An'  Length: 2
2795         Space: ` '  Class: String
2796         Argc: 2  Argv: `escaped'  Length: 7
2797         Space: ` '  Class: String
2798         Argc: 3  Argv: `aC'  Length: 2
2799         Space: ` '  Class: String
2800         MACRO REQUEST: .Em An escaped &aC
2801 DEBUGGING OFF
2804 The argument
2805 .Ql \e&aC
2806 shows up with the same length of 2 as the
2807 .Ql \e&
2808 sequence produces a zero width, but a register
2809 named
2810 .Ql \e&aC
2811 was not found and the type classified as string.
2813 Other diagnostics consist of usage statements and are self explanatory.
2814 .Sh GROFF, TROFF AND NROFF
2816 .Nm \-mdoc
2817 package does not need compatibility mode with
2818 .Xr groff .
2820 The package inhibits page breaks, and the headers and footers
2821 which normally occur at those breaks with
2822 .Xr nroff ,
2823 to make the manual more efficient for viewing on-line.
2824 At the moment,
2825 .Xr groff
2826 with
2827 .Fl T Ns Ar ascii
2828 does eject the imaginary remainder of the page at end of file.
2829 The inhibiting of the page breaks makes
2830 .Xr nroff Ns 'd
2831 files unsuitable for hardcopy.
2832 There is a register named
2833 .Ql \&cR
2834 which can be set to zero in the site dependent style file
2835 .Pa /usr/src/share/tmac/doc-nroff
2836 to restore the old style behavior.
2837 .Sh FILES
2838 .Bl -tag -width /usr/share/misc/mdoc.template -compact
2839 .It Pa /usr/share/tmac/tmac.doc
2840 manual macro package
2841 .It Pa /usr/share/misc/mdoc.template
2842 template for writing a man page
2844 .Sh SEE ALSO
2845 .Xr mdoc 7 ,
2846 .Xr man 1 ,
2847 .Xr troff 1
2848 .Sh BUGS
2849 Undesirable hyphenation on the dash of a flag
2850 argument is not yet resolved, and causes
2851 occasional mishaps in the
2852 .Sx DESCRIPTION
2853 section.
2854 (line break on the hyphen).
2856 Predefined strings are not declared in documentation.
2858 Section 3f has not been added to the header routines.
2860 .Ql \&.Nm
2861 font should be changed in
2862 .Sx NAME
2863 section.
2865 .Ql \&.Fn
2866 needs to have a check to prevent splitting up
2867 if the line length is too short.
2868 Occasionally it
2869 separates the last parenthesis, and sometimes
2870 looks ridiculous if a line is in fill mode.
2872 The method used to prevent header and footer page
2873 breaks (other than the initial header and footer) when using
2874 nroff occasionally places an unsightly partially filled line (blank)
2875 at the would be bottom of the page.
2877 If the outer-most list definition doesn't have a
2878 .Fl width
2879 argument, the
2880 .Ql ".It"
2881 elements of inner lists may not work (producing a list where
2882 each successive element
2883 .Sq walks
2884 to the right).
2886 The list and display macros to not do any keeps
2887 and certainly should be able to.
2888 .\" Note what happens if the parameter list overlaps a newline
2889 .\" boundary.
2890 .\" to make sure a line boundary is crossed:
2891 .\" .Bd -literal
2892 .\" \&.Fn struct\e\ dictionarytable\e\ *dictionarylookup struct\e\ dictionarytable\e\ *tab[]
2893 .\" .Ed
2894 .\" .Pp
2895 .\" produces, nudge nudge,
2896 .\" .Fn struct\ dictionarytable\ *dictionarylookup char\ *h struct\ dictionarytable\ *tab[] ,
2897 .\" .Fn struct\ dictionarytable\ *dictionarylookup char\ *h struct\ dictionarytable\ *tab[] ,
2898 .\" nudge
2899 .\" .Fn struct\ dictionarytable\ *dictionarylookup char\ *h struct\ dictionarytable\ *tab[] .
2900 .\" .Pp
2901 .\" If double quotes are used, for example:
2902 .\" .Bd -literal
2903 .\" \&.Fn \*qstruct dictionarytable *dictionarylookup\*q \*qchar *h\*q \*qstruct dictionarytable *tab[]\*q
2904 .\" .Ed
2905 .\" .Pp
2906 .\" produces, nudge nudge,
2907 .\" .Fn "struct dictionarytable *dictionarylookup" "char *h" "struct dictionarytable *tab[]" ,
2908 .\" nudge
2909 .\" .Fn "struct dictionarytable *dictionarylookup" "char *h" "struct dictionarytable *tab[]" ,
2910 .\" nudge
2911 .\" .Fn "struct dictionarytable *dictionarylookup" "char *h" "struct dictionarytable *tab[]" .
2912 .\" .Pp
2913 .\" Not a pretty sight...
2914 .\" In a paragraph, a long parameter containing unpaddable spaces as
2915 .\" in the former example will cause
2916 .\" .Xr troff
2917 .\" to break the line and spread
2918 .\" the remaining words out.
2919 .\" The latter example will adjust nicely to
2920 .\" justified margins, but may break in between an argument and its
2921 .\" declaration.
2922 .\" In
2923 .\" .Xr nroff
2924 .\" the right margin adjustment is normally ragged and the problem is
2925 .\" not as severe.