1 .\" $Id: man.7,v 1.66 2010/05/08 22:26:39 kristaps Exp $
3 .\" Copyright (c) 2009 Kristaps Dzonsons <kristaps@bsd.lv>
5 .\" Permission to use, copy, modify, and distribute this software for any
6 .\" purpose with or without fee is hereby granted, provided that the above
7 .\" copyright notice and this permission notice appear in all copies.
9 .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 .Dd $Mdocdate: May 8 2010 $
22 .Nd man language reference
26 language was historically used to format
28 manuals. This reference document describes its syntax, structure, and
34 to write your manuals.
42 document follows simple rules: lines beginning with the control
45 are parsed for macros. Other lines are interpreted within the scope of
47 .Bd -literal -offset indent
48 \&.SH Macro lines change control state.
49 Other lines are interpreted within the current state.
53 documents may contain only graphable 7-bit ASCII characters, the
54 space character, and the tabs character. All manuals must have
58 Blank lines are acceptable; where found, the output will assert a
63 whether in a macro or free-form text line, is ignored to the end of
64 line. A macro line with only a control character and comment escape,
66 is also ignored. Macro lines with only a control character and
67 optionally whitespace are stripped from input.
68 .Ss Special Characters
69 Special characters may occur in both macro and free-form lines.
70 Sequences begin with the escape character
72 followed by either an open-parenthesis
74 for two-character sequences; an open-bracket
76 for n-character sequences (terminated at a close-bracket
78 or a single one-character sequence. See
80 for a complete list. Examples include
87 Terms may be text-decorated using the
89 escape followed by an indicator: B (bold), I, (italic), R (Roman), or P
90 (revert to previous mode):
92 .D1 \efBbold\efR \efIitalic\efP
94 A numerical representation 3, 2, or 1 (bold, italic, and Roman,
95 respectively) may be used instead. A text decoration is only valid, if
96 specified in free-form text, until the next macro invocation; if
97 specified within a macro, it's only valid until the macro closes scope.
100 open and close a font scope with each argument.
102 Text may also be sized with the
104 escape, whose syntax is one of
106 for one-digit numerals;
110 for two-digit numerals; and
116 for arbitrary-digit numerals:
119 .D1 \es[+10]much bigger\es[-10]
120 .D1 \es+(10much bigger\es-(10
121 .D1 \es+'100'much much bigger\es-'100'
127 attributes are forgotten when entering or exiting a macro block.
129 Whitespace consists of the space character.
130 In free-form lines, whitespace is preserved within a line; un-escaped
131 trailing spaces are stripped from input (unless in a literal context).
132 Blank free-form lines, which may include spaces, are permitted and
133 rendered as an empty line.
135 In macro lines, whitespace delimits arguments and is discarded. If
136 arguments are quoted, whitespace within the quotes is retained.
142 macro that requires a date. The form for this date is the ISO-8601
146 Many macros support scaled widths for their arguments, such as
147 stipulating a two-inch paragraph indentation with the following:
148 .Bd -literal -offset indent
152 The syntax for scaled widths is
153 .Sq Li [+-]?[0-9]*.[0-9]*[:unit:]? ,
154 where a decimal must be preceded or proceeded by at least one digit.
155 Negative numbers, while accepted, are truncated to zero. The following
156 scaling units are accepted:
158 .Bl -tag -width Ds -offset indent -compact
171 default vertical span
183 default horizontal span
188 Using anything other than
194 is necessarily non-portable across output media.
196 If a scaling unit is not provided, the numerical value is interpreted
197 under the default rules of
199 for vertical spaces and
205 which, if a unit is not provided, will instead interpret the string as
210 document must contain contains at least the
212 macro describing the document's section and title. It may occur
213 anywhere in the document, although conventionally, it appears as the
218 at least one macro or text node must appear in the document. Documents
219 are generally structured as follows:
220 .Bd -literal -offset indent
221 \&.TH FOO 1 2009-10-10
224 \efBfoo\efR \e(en a description goes here
225 \&.\e\*q The next is for sections 2 & 3 only.
229 \efBfoo\efR [\efB\e-options\efR] arguments...
232 The \efBfoo\efR utility processes files...
234 \&.\e\*q .SH IMPLEMENTATION NOTES
235 \&.\e\*q The next is for sections 1 & 8 only.
236 \&.\e\*q .SH EXIT STATUS
237 \&.\e\*q The next is for sections 2, 3, & 9 only.
238 \&.\e\*q .SH RETURN VALUES
239 \&.\e\*q The next is for sections 1, 6, 7, & 8 only.
240 \&.\e\*q .SH ENVIRONMENT
242 \&.\e\*q .SH EXAMPLES
243 \&.\e\*q The next is for sections 1, 4, 6, 7, & 8 only.
244 \&.\e\*q .SH DIAGNOSTICS
245 \&.\e\*q The next is for sections 2, 3, & 9 only.
247 \&.\e\*q .SH SEE ALSO
248 \&.\e\*q .BR foo ( 1 )
249 \&.\e\*q .SH STANDARDS
254 \&.\e\*q .SH SECURITY CONSIDERATIONS
259 document are conventionally ordered as they appear above. Sections
260 should be composed as follows:
261 .Bl -ohang -offset indent
263 The name(s) and a short description of the documented material. The
264 syntax for this is generally as follows:
266 .D1 \efBname\efR \e(en description
268 The name of the library containing the documented material, which is
269 assumed to be a function in a section 2 or 3 manual. For functions in
270 the C library, this may be as follows:
272 .D1 Standard C Library (libc, -lc)
274 Documents the utility invocation syntax, function call syntax, or device
277 For the first, utilities (sections 1, 6, and 8), this is
278 generally structured as follows:
280 .D1 \efBname\efR [-\efBab\efR] [-\efBc\efR\efIarg\efR] \efBpath\efR...
282 For the second, function calls (sections 2, 3, 9):
284 .D1 \&.B char *name(char *\efIarg\efR);
286 And for the third, configurations (section 4):
288 .D1 \&.B name* at cardbus ? function ?
290 Manuals not in these sections generally don't need a
293 This expands upon the brief, one-line description in
295 It usually contains a break-down of the options (if documenting a
297 .It Em IMPLEMENTATION NOTES
298 Implementation-specific notes should be kept here. This is useful when
299 implementing standard functions that may have side effects or notable
300 algorithmic implications.
302 Command exit status for section 1, 6, and 8 manuals. This section is
305 which is used for functions. Historically, this information was
308 a practise that is now discouraged.
310 This section is the dual of
312 which is used for commands. It documents the return values of functions
313 in sections 2, 3, and 9.
315 Documents any usages of environment variables, e.g.,
318 Documents files used. It's helpful to document both the file and a
319 short description of how the file is used (created, modified, etc.).
321 Example usages. This often contains snippets of well-formed,
322 well-tested invocations. Make doubly sure that your examples work
325 Documents error conditions. This is most useful in section 4 manuals.
326 Historically, this section was used in place of
328 for manuals in sections 1, 6, and 8; however, this practise is
331 Documents error handling in sections 2, 3, and 9.
333 References other manuals with related topics. This section should exist
336 .D1 \&.BR bar \&( 1 \&),
338 Cross-references should conventionally be ordered
339 first by section, then alphabetically.
341 References any standards implemented or used, such as
343 .D1 IEEE Std 1003.2 (\e(lqPOSIX.2\e(rq)
345 If not adhering to any standards, the
347 section should be used.
349 The history of any manual without a
351 section should be described in this section.
353 Credits to authors, if applicable, should appear in this section.
354 Authors should generally be noted by both name and an e-mail address.
356 Explanations of common misuses and misunderstandings should be explained
359 Extant bugs should be described in this section.
360 .It Em SECURITY CONSIDERATIONS
361 Documents any security precautions that operators should consider.
364 Macros are one to three three characters in length and begin with a
367 at the beginning of the line. The
369 macro control character is also accepted. An arbitrary amount of
370 whitespace (spaces or tabs) may sit between the control character and
371 the macro name. Thus, the following are equivalent:
372 .Bd -literal -offset indent
379 macros are classified by scope: line scope or block scope. Line
380 macros are only scoped to the current line (and, in some situations,
381 the subsequent line). Block macros are scoped to the current line and
382 subsequent lines until closed by another block macro.
384 Line macros are generally scoped to the current line, with the body
385 consisting of zero or more arguments. If a macro is scoped to the next
386 line and the line arguments are empty, the next line, which must be
387 text, is used instead. Thus:
388 .Bd -literal -offset indent
395 If next-line macros are invoked consecutively, only the last is used.
396 If a next-line macro is followed by a non-next-line macro, an error is
397 raised (unless in the case of
403 The syntax is as follows:
404 .Bd -literal -offset indent
405 \&.YO \(lBbody...\(rB
409 .Bl -column -compact -offset indent "MacroX" "ArgumentsX" "ScopeXXXXX" "CompatX"
410 .It Em Macro Ta Em Arguments Ta Em Scope Ta Em Notes
411 .It Sx \&B Ta n Ta next-line Ta \&
412 .It Sx \&BI Ta n Ta current Ta \&
413 .It Sx \&BR Ta n Ta current Ta \&
414 .It Sx \&DT Ta 0 Ta current Ta \&
415 .It Sx \&I Ta n Ta next-line Ta \&
416 .It Sx \&IB Ta n Ta current Ta \&
417 .It Sx \&IR Ta n Ta current Ta \&
418 .\" .It Sx \&PD Ta n Ta current Ta compat
419 .It Sx \&R Ta n Ta next-line Ta \&
420 .It Sx \&RB Ta n Ta current Ta \&
421 .It Sx \&RI Ta n Ta current Ta \&
422 .It Sx \&SB Ta n Ta next-line Ta \&
423 .It Sx \&SM Ta n Ta next-line Ta \&
424 .It Sx \&TH Ta >1, <6 Ta current Ta \&
425 .\" .It Sx \&UC Ta n Ta current Ta compat
426 .It Sx \&br Ta 0 Ta current Ta compat
427 .It Sx \&fi Ta 0 Ta current Ta compat
428 .It Sx \&i Ta n Ta current Ta compat
429 .It Sx \&na Ta 0 Ta current Ta compat
430 .It Sx \&nf Ta 0 Ta current Ta compat
431 .It Sx \&r Ta 0 Ta current Ta compat
432 .It Sx \&sp Ta 1 Ta current Ta compat
433 .\" .It Sx \&Sp Ta 0 Ta current Ta compat
434 .\" .It Sx \&Vb Ta <1 Ta current Ta compat
435 .\" .It Sx \&Ve Ta 0 Ta current Ta compat
440 are included for compatibility with the significant corpus of existing
441 manuals that mix dialects of roff. These macros should not be used for
446 Block macros are comprised of a head and body. Like for in-line macros,
447 the head is scoped to the current line and, in one circumstance, the
448 next line (the next-line stipulations as in
452 The syntax is as follows:
453 .Bd -literal -offset indent
454 \&.YO \(lBhead...\(rB
459 The closure of body scope may be to the section, where a macro is closed
462 sub-section, closed by a section or
464 part, closed by a section, sub-section, or
466 or paragraph, closed by a section, sub-section, part,
474 No closure refers to an explicit block closing macro.
476 As a rule, block macros may not be nested; thus, calling a block macro
477 while another block macro scope is open, and the open scope is not
478 implicitly closed, is syntactically incorrect.
480 .Bl -column -compact -offset indent "MacroX" "ArgumentsX" "Head ScopeX" "sub-sectionX" "compatX"
481 .It Em Macro Ta Em Arguments Ta Em Head Scope Ta Em Body Scope Ta Em Notes
482 .It Sx \&HP Ta <2 Ta current Ta paragraph Ta \&
483 .It Sx \&IP Ta <3 Ta current Ta paragraph Ta \&
484 .It Sx \&LP Ta 0 Ta current Ta paragraph Ta \&
485 .It Sx \&P Ta 0 Ta current Ta paragraph Ta \&
486 .It Sx \&PP Ta 0 Ta current Ta paragraph Ta \&
487 .It Sx \&RE Ta 0 Ta current Ta none Ta compat
488 .It Sx \&RS Ta 1 Ta current Ta part Ta compat
489 .It Sx \&SH Ta >0 Ta next-line Ta section Ta \&
490 .It Sx \&SS Ta >0 Ta next-line Ta sub-section Ta \&
491 .It Sx \&TP Ta n Ta next-line Ta paragraph Ta \&
499 If a block macro is next-line scoped, it may only be followed by in-line
500 macros for decorating text.
502 This section is a canonical reference to all macros, arranged
503 alphabetically. For the scoping of individual macros, see
506 Text is rendered in bold face.
516 Text is rendered alternately in bold face and italic. Thus,
517 .Sq .BI this word and that
522 to render in bold face, while
526 render in italics. Whitespace between arguments is omitted in output.
530 .D1 \&.BI bold italic bold italic
532 The output of this example will be emboldened
536 with spaces stripped between arguments.
546 Text is rendered alternately in bold face and roman (the default font).
547 Whitespace between arguments is omitted in output.
551 for an equivalent example.
561 Has no effect. Included for compatibility.
563 Begin a paragraph whose initial output line is left-justified, but
564 subsequent output lines are indented, with the following syntax:
565 .Bd -filled -offset indent
572 argument must conform to
574 If specified, it's saved for later paragraph left-margins; if unspecified, the
575 saved or default width is used.
585 Text is rendered in italics.
595 Text is rendered alternately in italics and bold face. Whitespace
596 between arguments is omitted in output.
600 for an equivalent example.
610 Begin an indented paragraph with the following syntax:
611 .Bd -filled -offset indent
613 .Op Cm head Op Cm width
618 argument defines the width of the left margin and is defined by
620 It's saved for later paragraph left-margins; if unspecified, the saved or
621 default width is used.
625 argument is used as a leading term, flushed to the left margin. This is
626 useful for bulleted paragraphs and so on.
636 Text is rendered alternately in italics and roman (the default font).
637 Whitespace between arguments is omitted in output.
641 for an equivalent example.
651 Begin an undecorated paragraph. The scope of a paragraph is closed by a
652 subsequent paragraph, sub-section, section, or end of file. The saved
653 paragraph left-margin width is re-set to the default.
685 Text is rendered in roman (the default font).
695 Text is rendered alternately in roman (the default font) and bold face.
696 Whitespace between arguments is omitted in output.
700 for an equivalent example.
710 Explicitly close out the scope of a prior
713 Text is rendered alternately in roman (the default font) and italics.
714 Whitespace between arguments is omitted in output.
718 for an equivalent example.
728 Begin a part setting the left margin. The left margin controls the
729 offset, following an initial indentation, to un-indented text such as
732 This has the following syntax:
733 .Bd -filled -offset indent
740 argument must conform to
742 If not specified, the saved or default width is used.
744 Text is rendered in small size (one point smaller than the default font)
747 Begin a section. The scope of a section is only closed by another
748 section or the end of file. The paragraph left-margin width is re-set
751 Text is rendered in small size (one point smaller than the default
754 Begin a sub-section. The scope of a sub-section is closed by a
755 subsequent sub-section, section, or end of file. The paragraph
756 left-margin width is re-set to the default.
758 Sets the title of the manual page with the following syntax:
759 .Bd -filled -offset indent
762 .Op Cm date Op Cm source Op Cm volume
765 At least the upper-case document title
767 and numeric manual section
769 arguments must be provided. The
771 argument should be formatted as described in
773 if it does not conform, the current date is used instead. The
775 string specifies the organisation providing the utility. The
777 string replaces the default rendered volume, which is dictated by the
782 .D1 \&.TH CVS 5 "1992-02-12" GNU
784 Begin a paragraph where the head, if exceeding the indentation width, is
785 followed by a newline; if not, the body follows on the same line after a
786 buffer to the indentation width. Subsequent output lines are indented.
787 The syntax is as follows:
788 .Bd -filled -offset indent
795 argument must conform to
797 If specified, it's saved for later paragraph left-margins; if
798 unspecified, the saved or default width is used.
810 .\" Has no effect. Included for compatibility.
814 .\" Has no effect. Included for compatibility.
816 Breaks the current line. Consecutive invocations have no further effect.
821 End literal mode begun by
824 Italicise arguments. Synonym for
835 Don't align to the right margin.
837 Begin literal mode: all subsequent free-form lines have their end of
838 line boundaries preserved. May be ended by
841 Fonts and styles (bold face, italics) reset to roman (default font).
851 Insert vertical spaces into output with the following syntax:
852 .Bd -filled -offset indent
859 spaces, which must conform to
861 If 0, this is equivalent to the
863 macro. Defaults to 1, if unspecified.
875 .\" Accepts an argument (the height of the formatted space) which is
883 This section documents areas of questionable portability between
884 implementations of the
890 In quoted literals, GNU troff allowed pair-wise double-quotes to produce
891 a standalone double-quote in formatted output. It is not known whether
892 this behaviour is exhibited by other formatters.
896 macro does not accept negative values in mandoc. In GNU troff, this
897 would result in strange behaviour.
901 macro control character, in GNU troff (and prior troffs) suppresses a
902 newline before macro output; in mandoc, it is an alias for the standard
912 reference was written by
913 .An Kristaps Dzonsons Aq kristaps@bsd.lv .
915 Do not use this language. Use