1 .\" $Id: man.7,v 1.60 2010/03/27 10:22:28 kristaps Exp $
3 .\" Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se>
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: March 27 2010 $
24 .Nd man language reference
30 language was historically used to format
32 manuals. This reference document describes its syntax, structure, and
39 to write your manuals.
48 document follows simple rules: lines beginning with the control
51 are parsed for macros. Other lines are interpreted within the scope of
53 .Bd -literal -offset indent
54 \&.SH Macro lines change control state.
55 Other lines are interpreted within the current state.
61 documents may contain only graphable 7-bit ASCII characters, the
62 space character, and the tabs character. All manuals must have
67 Blank lines are acceptable; where found, the output will assert a
74 whether in a macro or free-form text line, is ignored to the end of
75 line. A macro line with only a control character and comment escape,
77 is also ignored. Macro lines with only a control character and
78 optionally whitespace are stripped from input.
81 .Ss Special Characters
82 Special characters may occur in both macro and free-form lines.
83 Sequences begin with the escape character
85 followed by either an open-parenthesis
87 for two-character sequences; an open-bracket
89 for n-character sequences (terminated at a close-bracket
91 or a single one-character sequence. See
93 for a complete list. Examples include
102 Terms may be text-decorated using the
104 escape followed by an indicator: B (bold), I, (italic), R (Roman), or P
105 (revert to previous mode):
107 .D1 \efBbold\efR \efIitalic\efP
109 A numerical representation 3, 2, or 1 (bold, italic, and Roman,
110 respectively) may be used instead. A text decoration is only valid, if
111 specified in free-form text, until the next macro invocation; if
112 specified within a macro, it's only valid until the macro closes scope.
113 Note that macros like
115 open and close a font scope with each argument.
117 Text may also be sized with the
119 escape, whose syntax is one of
121 for one-digit numerals;
125 for two-digit numerals; and
131 for arbitrary-digit numerals:
134 .D1 \es[+10]much bigger\es[-10]
135 .D1 \es+(10much bigger\es-(10
136 .D1 \es+'100'much much bigger\es-'100'
142 attributes are forgotten when entering or exiting a macro block.
146 Unless specifically escaped, consecutive blocks of whitespace are pruned
147 from input. These are later re-added, if applicable, by a front-end
157 macro that requires a date. The form for this date is the ISO-8601
163 Many macros support scaled widths for their arguments, such as
164 stipulating a two-inch paragraph indentation with the following:
165 .Bd -literal -offset indent
170 The syntax for scaled widths is
171 .Sq Li [+-]?[0-9]*.[0-9]*[:unit:]? ,
172 where a decimal must be preceded or proceeded by at least one digit.
173 Negative numbers, while accepted, are truncated to zero. The following
174 scaling units are accepted:
177 .Bl -tag -width Ds -offset indent -compact
190 default vertical span
202 default horizontal span
207 Using anything other than
213 is necessarily non-portable across output media.
216 If a scaling unit is not provided, the numerical value is interpreted
217 under the default rules of
219 for vertical spaces and
225 which, if a unit is not provided, will instead interpret the string as
232 document must contain contains at least the
234 macro describing the document's section and title. It may occur
235 anywhere in the document, although conventionally, it appears as the
241 at least one macro or text node must appear in the document. Documents
242 are generally structured as follows:
243 .Bd -literal -offset indent
244 \&.TH FOO 1 2009-10-10
247 \efBfoo\efR \e(en a description goes here
248 \&.\e\*q The next is for sections 2 & 3 only.
252 \efBfoo\efR [\efB\e-options\efR] arguments...
255 The \efBfoo\efR utility processes files...
257 \&.\e\*q .SH IMPLEMENTATION NOTES
258 \&.\e\*q The next is for sections 1 & 8 only.
259 \&.\e\*q .SH EXIT STATUS
260 \&.\e\*q The next is for sections 2, 3, & 9 only.
261 \&.\e\*q .SH RETURN VALUES
262 \&.\e\*q The next is for sections 1, 6, 7, & 8 only.
263 \&.\e\*q .SH ENVIRONMENT
265 \&.\e\*q .SH EXAMPLES
266 \&.\e\*q The next is for sections 1, 4, 6, 7, & 8 only.
267 \&.\e\*q .SH DIAGNOSTICS
268 \&.\e\*q The next is for sections 2, 3, & 9 only.
270 \&.\e\*q .SH SEE ALSO
271 \&.\e\*q .BR foo ( 1 )
272 \&.\e\*q .SH STANDARDS
277 \&.\e\*q .SH SECURITY CONSIDERATIONS
282 document are conventionally ordered as they appear above. Sections
283 should be composed as follows:
284 .Bl -ohang -offset indent
286 The name(s) and a short description of the documented material. The
287 syntax for this is generally as follows:
289 .D1 \efBname\efR \e(en description
291 The name of the library containing the documented material, which is
292 assumed to be a function in a section 2 or 3 manual. For functions in
293 the C library, this may be as follows:
295 .D1 Standard C Library (libc, -lc)
297 Documents the utility invocation syntax, function call syntax, or device
300 For the first, utilities (sections 1, 6, and 8), this is
301 generally structured as follows:
303 .D1 \efBname\efR [-\efBab\efR] [-\efBc\efR\efIarg\efR] \efBpath\efR...
305 For the second, function calls (sections 2, 3, 9):
307 .D1 \&.B char *name(char *\efIarg\efR);
309 And for the third, configurations (section 4):
311 .D1 \&.B name* at cardbus ? function ?
313 Manuals not in these sections generally don't need a
316 This expands upon the brief, one-line description in
318 It usually contains a break-down of the options (if documenting a
320 .It Em IMPLEMENTATION NOTES
321 Implementation-specific notes should be kept here. This is useful when
322 implementing standard functions that may have side effects or notable
323 algorithmic implications.
325 Command exit status for section 1, 6, and 8 manuals. This section is
328 which is used for functions. Historically, this information was
331 a practise that is now discouraged.
334 This section is the dual of
336 which is used for commands. It documents the return values of functions
337 in sections 2, 3, and 9.
340 Documents any usages of environment variables, e.g.,
344 Documents files used. It's helpful to document both the file and a
345 short description of how the file is used (created, modified, etc.).
348 Example usages. This often contains snippets of well-formed,
349 well-tested invocations. Make doubly sure that your examples work
353 Documents error conditions. This is most useful in section 4 manuals.
354 Historically, this section was used in place of
356 for manuals in sections 1, 6, and 8; however, this practise is
360 Documents error handling in sections 2, 3, and 9.
363 References other manuals with related topics. This section should exist
366 .D1 \&.BR bar \&( 1 \&),
368 Cross-references should conventionally be ordered
369 first by section, then alphabetically.
372 References any standards implemented or used, such as
374 .D1 IEEE Std 1003.2 (\e(lqPOSIX.2\e(rq)
376 If not adhering to any standards, the
378 section should be used.
381 The history of any manual without a
383 section should be described in this section.
386 Credits to authors, if applicable, should appear in this section.
387 Authors should generally be noted by both name and an e-mail address.
390 Explanations of common misuses and misunderstandings should be explained
394 Extant bugs should be described in this section.
396 .It Em SECURITY CONSIDERATIONS
397 Documents any security precautions that operators should consider.
403 Macros are one to three three characters in length and begin with a
406 at the beginning of the line. The
408 macro control character is also accepted. An arbitrary amount of
409 whitespace (spaces or tabs) may sit between the control character and
410 the macro name. Thus, the following are equivalent:
411 .Bd -literal -offset indent
419 macros are classified by scope: line scope or block scope. Line
420 macros are only scoped to the current line (and, in some situations,
421 the subsequent line). Block macros are scoped to the current line and
422 subsequent lines until closed by another block macro.
426 Line macros are generally scoped to the current line, with the body
427 consisting of zero or more arguments. If a macro is scoped to the next
428 line and the line arguments are empty, the next line, which must be
429 text, is used instead. Thus:
430 .Bd -literal -offset indent
438 If next-line macros are invoked consecutively, only the last is used.
439 If a next-line macro is followed by a non-next-line macro, an error is
440 raised (unless in the case of
447 The syntax is as follows:
448 .Bd -literal -offset indent
449 \&.YO \(lBbody...\(rB
454 .Bl -column -compact -offset indent "MacroX" "ArgumentsX" "ScopeXXXXX" "CompatX"
455 .It Em Macro Ta Em Arguments Ta Em Scope Ta Em Notes
456 .It Sx \&B Ta n Ta next-line Ta \&
457 .It Sx \&BI Ta n Ta current Ta \&
458 .It Sx \&BR Ta n Ta current Ta \&
459 .It Sx \&DT Ta 0 Ta current Ta \&
460 .It Sx \&I Ta n Ta next-line Ta \&
461 .It Sx \&IB Ta n Ta current Ta \&
462 .It Sx \&IR Ta n Ta current Ta \&
463 .\" .It Sx \&PD Ta n Ta current Ta compat
464 .It Sx \&R Ta n Ta next-line Ta \&
465 .It Sx \&RB Ta n Ta current Ta \&
466 .It Sx \&RI Ta n Ta current Ta \&
467 .It Sx \&SB Ta n Ta next-line Ta \&
468 .It Sx \&SM Ta n Ta next-line Ta \&
469 .It Sx \&TH Ta >1, <6 Ta current Ta \&
470 .\" .It Sx \&UC Ta n Ta current Ta compat
471 .It Sx \&br Ta 0 Ta current Ta compat
472 .It Sx \&fi Ta 0 Ta current Ta compat
473 .It Sx \&i Ta n Ta current Ta compat
474 .It Sx \&na Ta 0 Ta current Ta compat
475 .It Sx \&nf Ta 0 Ta current Ta compat
476 .It Sx \&r Ta 0 Ta current Ta compat
477 .It Sx \&sp Ta 1 Ta current Ta compat
478 .\" .It Sx \&Sp Ta 0 Ta current Ta compat
479 .\" .It Sx \&Vb Ta <1 Ta current Ta compat
480 .\" .It Sx \&Ve Ta 0 Ta current Ta compat
486 are included for compatibility with the significant corpus of existing
487 manuals that mix dialects of roff. These macros should not be used for
494 Block macros are comprised of a head and body. Like for in-line macros,
495 the head is scoped to the current line and, in one circumstance, the
496 next line (the next-line stipulations as in
500 The syntax is as follows:
501 .Bd -literal -offset indent
502 \&.YO \(lBhead...\(rB
508 The closure of body scope may be to the section, where a macro is closed
511 sub-section, closed by a section or
513 part, closed by a section, sub-section, or
515 or paragraph, closed by a section, sub-section, part,
523 No closure refers to an explicit block closing macro.
526 As a rule, block macros may not be nested; thus, calling a block macro
527 while another block macro scope is open, and the open scope is not
528 implicitly closed, is syntactically incorrect.
531 .Bl -column -compact -offset indent "MacroX" "ArgumentsX" "Head ScopeX" "sub-sectionX" "compatX"
532 .It Em Macro Ta Em Arguments Ta Em Head Scope Ta Em Body Scope Ta Em Notes
533 .It Sx \&HP Ta <2 Ta current Ta paragraph Ta \&
534 .It Sx \&IP Ta <3 Ta current Ta paragraph Ta \&
535 .It Sx \&LP Ta 0 Ta current Ta paragraph Ta \&
536 .It Sx \&P Ta 0 Ta current Ta paragraph Ta \&
537 .It Sx \&PP Ta 0 Ta current Ta paragraph Ta \&
538 .It Sx \&RE Ta 0 Ta current Ta none Ta compat
539 .It Sx \&RS Ta 1 Ta current Ta part Ta compat
540 .It Sx \&SH Ta >0 Ta next-line Ta section Ta \&
541 .It Sx \&SS Ta >0 Ta next-line Ta sub-section Ta \&
542 .It Sx \&TP Ta n Ta next-line Ta paragraph Ta \&
552 If a block macro is next-line scoped, it may only be followed by in-line
553 macros for decorating text.
557 This section is a canonical reference to all macros, arranged
558 alphabetically. For the scoping of individual macros, see
563 Text is rendered in bold face.
575 Text is rendered alternately in bold face and italic. Thus,
576 .Sq .BI this word and that
581 to render in bold face, while
585 render in italics. Whitespace between arguments is omitted in output.
589 .D1 \&.BI bold italic bold italic
591 The output of this example will be emboldened
595 with spaces stripped between arguments.
607 Text is rendered alternately in bold face and roman (the default font).
608 Whitespace between arguments is omitted in output.
612 for an equivalent example.
624 Has no effect. Included for compatibility.
628 Begin a paragraph whose initial output line is left-justified, but
629 subsequent output lines are indented, with the following syntax:
630 .Bd -filled -offset indent
637 argument must conform to
639 If specified, it's saved for later paragraph left-margins; if unspecified, the
640 saved or default width is used.
652 Text is rendered in italics.
664 Text is rendered alternately in italics and bold face. Whitespace
665 between arguments is omitted in output.
669 for an equivalent example.
681 Begin an indented paragraph with the following syntax:
682 .Bd -filled -offset indent
684 .Op Cm head Op Cm width
689 argument defines the width of the left margin and is defined by
691 It's saved for later paragraph left-margins; if unspecified, the saved or
692 default width is used.
696 argument is used as a leading term, flushed to the left margin. This is
697 useful for bulleted paragraphs and so on.
709 Text is rendered alternately in italics and roman (the default font).
710 Whitespace between arguments is omitted in output.
714 for an equivalent example.
726 Begin an undecorated paragraph. The scope of a paragraph is closed by a
727 subsequent paragraph, sub-section, section, or end of file. The saved
728 paragraph left-margin width is re-set to the default.
766 Text is rendered in roman (the default font).
778 Text is rendered alternately in roman (the default font) and bold face.
779 Whitespace between arguments is omitted in output.
783 for an equivalent example.
795 Explicitly close out the scope of a prior
800 Text is rendered alternately in roman (the default font) and italics.
801 Whitespace between arguments is omitted in output.
805 for an equivalent example.
817 Begin a part setting the left margin. The left margin controls the
818 offset, following an initial indentation, to un-indented text such as
821 This has the following syntax:
822 .Bd -filled -offset indent
829 argument must conform to
831 If not specified, the saved or default width is used.
835 Text is rendered in small size (one point smaller than the default font)
840 Begin a section. The scope of a section is only closed by another
841 section or the end of file. The paragraph left-margin width is re-set
846 Text is rendered in small size (one point smaller than the default
851 Begin a sub-section. The scope of a sub-section is closed by a
852 subsequent sub-section, section, or end of file. The paragraph
853 left-margin width is re-set to the default.
857 Sets the title of the manual page with the following syntax:
858 .Bd -filled -offset indent
861 .Op Cm date Op Cm source Op Cm volume
864 At least the upper-case document title
866 and numeric manual section
868 arguments must be provided. The
870 argument should be formatted as described in
872 if it does not conform, the current date is used instead. The
874 string specifies the organisation providing the utility. The
876 string replaces the default rendered volume, which is dictated by the
881 .D1 \&.TH CVS 5 "1992-02-12" GNU
885 Begin a paragraph where the head, if exceeding the indentation width, is
886 followed by a newline; if not, the body follows on the same line after a
887 buffer to the indentation width. Subsequent output lines are indented.
888 The syntax is as follows:
889 .Bd -filled -offset indent
896 argument must conform to
898 If specified, it's saved for later paragraph left-margins; if
899 unspecified, the saved or default width is used.
911 .\" Has no effect. Included for compatibility.
915 .\" Has no effect. Included for compatibility.
919 Breaks the current line. Consecutive invocations have no further effect.
926 End literal mode begun by
931 Italicise arguments. Synonym for
944 Don't align to the right margin.
948 Begin literal mode: all subsequent free-form lines have their end of
949 line boundaries preserved. May be ended by
954 Fonts and styles (bold face, italics) reset to roman (default font).
966 Insert vertical spaces into output with the following syntax:
967 .Bd -filled -offset indent
974 spaces, which must conform to
976 If 0, this is equivalent to the
978 macro. Defaults to 1, if unspecified.
991 .\" Accepts an argument (the height of the formatted space) which is
1000 This section documents areas of questionable portability between
1001 implementations of the
1008 In quoted literals, GNU troff allowed pair-wise double-quotes to produce
1009 a standalone double-quote in formatted output. It is not known whether
1010 this behaviour is exhibited by other formatters.
1013 Blocks of whitespace are stripped from macro and free-form text lines
1014 (except when in literal mode) in mandoc. This is not the case for GNU
1015 troff: for maximum portability, whitespace sensitive blocks should be
1016 enclosed in literal contexts.
1021 macro does not accept negative values in mandoc. In GNU troff, this
1022 would result in strange behaviour.
1027 macro control character, in GNU troff (and prior troffs) suppresses a
1028 newline before macro output; in mandoc, it is an alias for the standard
1042 reference was written by
1043 .An Kristaps Dzonsons Aq kristaps@kth.se .
1047 Do not use this language. Use