1 .\" $Id: man.7,v 1.69 2010/05/12 17:08:03 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 12 2010 $
22 .Nd man language reference
26 language was historically used to format
29 This reference document describes its syntax, structure, and usage.
34 to write your manuals.
42 document follows simple rules: lines beginning with the control
45 are parsed for macros.
46 Other lines are interpreted within the scope of
48 .Bd -literal -offset indent
49 \&.SH Macro lines change control state.
50 Other lines are interpreted within the current state.
54 documents may contain only graphable 7-bit ASCII characters, the
55 space character, and the tabs character.
60 Blank lines are acceptable; where found, the output will assert a
65 whether in a macro or free-form text line, is ignored to the end of
67 A macro line with only a control character and comment escape,
70 Macro lines with only a control character and optionally whitespace are
72 .Ss Special Characters
73 Special characters may occur in both macro and free-form lines.
74 Sequences begin with the escape character
76 followed by either an open-parenthesis
78 for two-character sequences; an open-bracket
80 for n-character sequences (terminated at a close-bracket
82 or a single one-character sequence.
93 Terms may be text-decorated using the
95 escape followed by an indicator: B (bold), I, (italic), R (Roman), or P
96 (revert to previous mode):
98 .D1 \efBbold\efR \efIitalic\efP
100 A numerical representation 3, 2, or 1 (bold, italic, and Roman,
101 respectively) may be used instead.
102 A text decoration is only valid, if specified in free-form text, until
103 the next macro invocation; if specified within a macro, it's only valid
104 until the macro closes scope.
105 Note that macros like
107 open and close a font scope with each argument.
109 Text may also be sized with the
111 escape, whose syntax is one of
113 for one-digit numerals;
117 for two-digit numerals; and
123 for arbitrary-digit numerals:
126 .D1 \es[+10]much bigger\es[-10]
127 .D1 \es+(10much bigger\es-(10
128 .D1 \es+'100'much much bigger\es-'100'
134 attributes are forgotten when entering or exiting a macro block.
136 Whitespace consists of the space character.
137 In free-form lines, whitespace is preserved within a line; un-escaped
138 trailing spaces are stripped from input (unless in a literal context).
139 Blank free-form lines, which may include spaces, are permitted and
140 rendered as an empty line.
142 In macro lines, whitespace delimits arguments and is discarded.
143 If arguments are quoted, whitespace within the quotes is retained.
149 macro that requires a date.
150 The form for this date is the ISO-8601
154 Many macros support scaled widths for their arguments, such as
155 stipulating a two-inch paragraph indentation with the following:
156 .Bd -literal -offset indent
160 The syntax for scaled widths is
161 .Sq Li [+-]?[0-9]*.[0-9]*[:unit:]? ,
162 where a decimal must be preceded or proceeded by at least one digit.
163 Negative numbers, while accepted, are truncated to zero.
164 The following scaling units are accepted:
166 .Bl -tag -width Ds -offset indent -compact
179 default vertical span
191 default horizontal span
196 Using anything other than
202 is necessarily non-portable across output media.
204 If a scaling unit is not provided, the numerical value is interpreted
205 under the default rules of
207 for vertical spaces and
213 which, if a unit is not provided, will instead interpret the string as
216 When composing a manual, make sure that your sentences end at the end of
218 By doing so, front-ends will be able to apply the proper amount of
219 spacing after the end of sentence (unescaped) period, exclamation, or question
224 document must contain contains at least the
226 macro describing the document's section and title.
227 It may occur anywhere in the document, although conventionally, it
228 appears as the first macro.
232 at least one macro or text node must appear in the document.
233 Documents are generally structured as follows:
234 .Bd -literal -offset indent
235 \&.TH FOO 1 2009-10-10
238 \efBfoo\efR \e(en a description goes here
239 \&.\e\*q The next is for sections 2 & 3 only.
243 \efBfoo\efR [\efB\e-options\efR] arguments...
246 The \efBfoo\efR utility processes files...
248 \&.\e\*q .SH IMPLEMENTATION NOTES
249 \&.\e\*q The next is for sections 2, 3, & 9 only.
250 \&.\e\*q .SH RETURN VALUES
251 \&.\e\*q The next is for sections 1, 6, 7, & 8 only.
252 \&.\e\*q .SH ENVIRONMENT
254 \&.\e\*q The next is for sections 1 & 8 only.
255 \&.\e\*q .SH EXIT STATUS
256 \&.\e\*q .SH EXAMPLES
257 \&.\e\*q The next is for sections 1, 4, 6, 7, & 8 only.
258 \&.\e\*q .SH DIAGNOSTICS
259 \&.\e\*q The next is for sections 2, 3, & 9 only.
261 \&.\e\*q .SH SEE ALSO
262 \&.\e\*q .BR foo ( 1 )
263 \&.\e\*q .SH STANDARDS
268 \&.\e\*q .SH SECURITY CONSIDERATIONS
273 document are conventionally ordered as they appear above.
274 Sections should be composed as follows:
275 .Bl -ohang -offset indent
277 The name(s) and a short description of the documented material.
278 The syntax for this is generally as follows:
280 .D1 \efBname\efR \e(en description
282 The name of the library containing the documented material, which is
283 assumed to be a function in a section 2 or 3 manual.
284 For functions in the C library, this may be as follows:
286 .D1 Standard C Library (libc, -lc)
288 Documents the utility invocation syntax, function call syntax, or device
291 For the first, utilities (sections 1, 6, and 8), this is
292 generally structured as follows:
294 .D1 \efBname\efR [-\efBab\efR] [-\efBc\efR\efIarg\efR] \efBpath\efR...
296 For the second, function calls (sections 2, 3, 9):
298 .D1 \&.B char *name(char *\efIarg\efR);
300 And for the third, configurations (section 4):
302 .D1 \&.B name* at cardbus ? function ?
304 Manuals not in these sections generally don't need a
307 This expands upon the brief, one-line description in
309 It usually contains a break-down of the options (if documenting a
311 .It Em IMPLEMENTATION NOTES
312 Implementation-specific notes should be kept here.
313 This is useful when implementing standard functions that may have side
314 effects or notable algorithmic implications.
316 This section is the dual of
318 which is used for commands.
319 It documents the return values of functions in sections 2, 3, and 9.
321 Documents any usages of environment variables, e.g.,
324 Documents files used.
325 It's helpful to document both the file and a short description of how
326 the file is used (created, modified, etc.).
328 Command exit status for section 1, 6, and 8 manuals.
329 This section is the dual of
331 which is used for functions.
332 Historically, this information was described in
334 a practise that is now discouraged.
337 This often contains snippets of well-formed,
338 well-tested invocations.
339 Make doubly sure that your examples work properly!
341 Documents error conditions.
342 This is most useful in section 4 manuals.
343 Historically, this section was used in place of
345 for manuals in sections 1, 6, and 8; however, this practise is
348 Documents error handling in sections 2, 3, and 9.
350 References other manuals with related topics.
351 This section should exist for most manuals.
353 .D1 \&.BR bar \&( 1 \&),
355 Cross-references should conventionally be ordered
356 first by section, then alphabetically.
358 References any standards implemented or used, such as
360 .D1 IEEE Std 1003.2 (\e(lqPOSIX.2\e(rq)
362 If not adhering to any standards, the
364 section should be used.
366 The history of any manual without a
368 section should be described in this section.
370 Credits to authors, if applicable, should appear in this section.
371 Authors should generally be noted by both name and an e-mail address.
373 Explanations of common misuses and misunderstandings should be explained
376 Extant bugs should be described in this section.
377 .It Em SECURITY CONSIDERATIONS
378 Documents any security precautions that operators should consider.
381 Macros are one to three three characters in length and begin with a
384 at the beginning of the line.
387 macro control character is also accepted.
388 An arbitrary amount of whitespace (spaces or tabs) may sit between the
389 control character and the macro name.
390 Thus, the following are equivalent:
391 .Bd -literal -offset indent
398 macros are classified by scope: line scope or block scope.
399 Line macros are only scoped to the current line (and, in some
400 situations, the subsequent line).
401 Block macros are scoped to the current line and subsequent lines until
402 closed by another block macro.
404 Line macros are generally scoped to the current line, with the body
405 consisting of zero or more arguments.
406 If a macro is scoped to the next line and the line arguments are empty,
407 the next line, which must be text, is used instead.
409 .Bd -literal -offset indent
416 If next-line macros are invoked consecutively, only the last is used.
417 If a next-line macro is followed by a non-next-line macro, an error is
418 raised (unless in the case of
424 The syntax is as follows:
425 .Bd -literal -offset indent
426 \&.YO \(lBbody...\(rB
430 .Bl -column -compact -offset indent "MacroX" "ArgumentsX" "ScopeXXXXX" "CompatX"
431 .It Em Macro Ta Em Arguments Ta Em Scope Ta Em Notes
432 .It Sx \&B Ta n Ta next-line Ta \&
433 .It Sx \&BI Ta n Ta current Ta \&
434 .It Sx \&BR Ta n Ta current Ta \&
435 .It Sx \&DT Ta 0 Ta current Ta \&
436 .It Sx \&I Ta n Ta next-line Ta \&
437 .It Sx \&IB Ta n Ta current Ta \&
438 .It Sx \&IR Ta n Ta current Ta \&
439 .\" .It Sx \&PD Ta n Ta current Ta compat
440 .It Sx \&R Ta n Ta next-line Ta \&
441 .It Sx \&RB Ta n Ta current Ta \&
442 .It Sx \&RI Ta n Ta current Ta \&
443 .It Sx \&SB Ta n Ta next-line Ta \&
444 .It Sx \&SM Ta n Ta next-line Ta \&
445 .It Sx \&TH Ta >1, <6 Ta current Ta \&
446 .\" .It Sx \&UC Ta n Ta current Ta compat
447 .It Sx \&br Ta 0 Ta current Ta compat
448 .It Sx \&fi Ta 0 Ta current Ta compat
449 .It Sx \&i Ta n Ta current Ta compat
450 .It Sx \&na Ta 0 Ta current Ta compat
451 .It Sx \&nf Ta 0 Ta current Ta compat
452 .It Sx \&r Ta 0 Ta current Ta compat
453 .It Sx \&sp Ta 1 Ta current Ta compat
454 .\" .It Sx \&Sp Ta 0 Ta current Ta compat
455 .\" .It Sx \&Vb Ta <1 Ta current Ta compat
456 .\" .It Sx \&Ve Ta 0 Ta current Ta compat
461 are included for compatibility with the significant corpus of existing
462 manuals that mix dialects of roff.
463 These macros should not be used for portable
467 Block macros are comprised of a head and body.
468 Like for in-line macros, the head is scoped to the current line and, in
469 one circumstance, the next line (the next-line stipulations as in
473 The syntax is as follows:
474 .Bd -literal -offset indent
475 \&.YO \(lBhead...\(rB
480 The closure of body scope may be to the section, where a macro is closed
483 sub-section, closed by a section or
485 part, closed by a section, sub-section, or
487 or paragraph, closed by a section, sub-section, part,
495 No closure refers to an explicit block closing macro.
497 As a rule, block macros may not be nested; thus, calling a block macro
498 while another block macro scope is open, and the open scope is not
499 implicitly closed, is syntactically incorrect.
501 .Bl -column -compact -offset indent "MacroX" "ArgumentsX" "Head ScopeX" "sub-sectionX" "compatX"
502 .It Em Macro Ta Em Arguments Ta Em Head Scope Ta Em Body Scope Ta Em Notes
503 .It Sx \&HP Ta <2 Ta current Ta paragraph Ta \&
504 .It Sx \&IP Ta <3 Ta current Ta paragraph Ta \&
505 .It Sx \&LP Ta 0 Ta current Ta paragraph Ta \&
506 .It Sx \&P Ta 0 Ta current Ta paragraph Ta \&
507 .It Sx \&PP Ta 0 Ta current Ta paragraph Ta \&
508 .It Sx \&RE Ta 0 Ta current Ta none Ta compat
509 .It Sx \&RS Ta 1 Ta current Ta part Ta compat
510 .It Sx \&SH Ta >0 Ta next-line Ta section Ta \&
511 .It Sx \&SS Ta >0 Ta next-line Ta sub-section Ta \&
512 .It Sx \&TP Ta n Ta next-line Ta paragraph Ta \&
520 If a block macro is next-line scoped, it may only be followed by in-line
521 macros for decorating text.
523 This section is a canonical reference to all macros, arranged
525 For the scoping of individual macros, see
528 Text is rendered in bold face.
538 Text is rendered alternately in bold face and italic.
540 .Sq .BI this word and that
545 to render in bold face, while
550 Whitespace between arguments is omitted in output.
554 .D1 \&.BI bold italic bold italic
556 The output of this example will be emboldened
560 with spaces stripped between arguments.
570 Text is rendered alternately in bold face and roman (the default font).
571 Whitespace between arguments is omitted in output.
575 for an equivalent example.
586 Included for compatibility.
588 Begin a paragraph whose initial output line is left-justified, but
589 subsequent output lines are indented, with the following syntax:
590 .Bd -filled -offset indent
597 argument must conform to
599 If specified, it's saved for later paragraph left-margins; if unspecified, the
600 saved or default width is used.
610 Text is rendered in italics.
620 Text is rendered alternately in italics and bold face. Whitespace
621 between arguments is omitted in output.
625 for an equivalent example.
635 Begin an indented paragraph with the following syntax:
636 .Bd -filled -offset indent
638 .Op Cm head Op Cm width
643 argument defines the width of the left margin and is defined by
645 It's saved for later paragraph left-margins; if unspecified, the saved or
646 default width is used.
650 argument is used as a leading term, flushed to the left margin.
651 This is useful for bulleted paragraphs and so on.
661 Text is rendered alternately in italics and roman (the default font).
662 Whitespace between arguments is omitted in output.
666 for an equivalent example.
676 Begin an undecorated paragraph.
677 The scope of a paragraph is closed by a subsequent paragraph,
678 sub-section, section, or end of file.
679 The saved paragraph left-margin width is re-set to the default.
711 Text is rendered in roman (the default font).
721 Text is rendered alternately in roman (the default font) and bold face.
722 Whitespace between arguments is omitted in output.
726 for an equivalent example.
736 Explicitly close out the scope of a prior
739 Text is rendered alternately in roman (the default font) and italics.
740 Whitespace between arguments is omitted in output.
744 for an equivalent example.
754 Begin a part setting the left margin.
755 The left margin controls the offset, following an initial indentation,
756 to un-indented text such as that of
758 This has the following syntax:
759 .Bd -filled -offset indent
766 argument must conform to
768 If not specified, the saved or default width is used.
770 Text is rendered in small size (one point smaller than the default font)
774 The scope of a section is only closed by another section or the end of
776 The paragraph left-margin width is re-set to the default.
778 Text is rendered in small size (one point smaller than the default
782 The scope of a sub-section is closed by a subsequent sub-section,
783 section, or end of file.
784 The paragraph left-margin width is re-set to the default.
786 Sets the title of the manual page with the following syntax:
787 .Bd -filled -offset indent
790 .Op Cm date Op Cm source Op Cm volume
793 At least the upper-case document title
795 and numeric manual section
797 arguments must be provided.
800 argument should be formatted as described in
802 if it does not conform, the current date is used instead.
805 string specifies the organisation providing the utility.
808 string replaces the default rendered volume, which is dictated by the
813 .D1 \&.TH CVS 5 "1992-02-12" GNU
815 Begin a paragraph where the head, if exceeding the indentation width, is
816 followed by a newline; if not, the body follows on the same line after a
817 buffer to the indentation width.
818 Subsequent output lines are indented.
819 The syntax is as follows:
820 .Bd -filled -offset indent
827 argument must conform to
829 If specified, it's saved for later paragraph left-margins; if
830 unspecified, the saved or default width is used.
842 .\" Has no effect. Included for compatibility.
846 .\" Has no effect. Included for compatibility.
848 Breaks the current line.
849 Consecutive invocations have no further effect.
854 End literal mode begun by
869 Don't align to the right margin.
871 Begin literal mode: all subsequent free-form lines have their end of
872 line boundaries preserved.
876 Fonts and styles (bold face, italics) reset to roman (default font).
886 Insert vertical spaces into output with the following syntax:
887 .Bd -filled -offset indent
894 spaces, which must conform to
896 If 0, this is equivalent to the
899 Defaults to 1, if unspecified.
911 .\" Accepts an argument (the height of the formatted space) which is
919 This section documents areas of questionable portability between
920 implementations of the
926 In quoted literals, GNU troff allowed pair-wise double-quotes to produce
927 a standalone double-quote in formatted output.
928 It is not known whether this behaviour is exhibited by other formatters.
932 macro does not accept negative values in mandoc.
933 In GNU troff, this would result in strange behaviour.
937 macro control character, in GNU troff (and prior troffs) suppresses a
938 newline before macro output; in mandoc, it is an alias for the standard
948 reference was written by
949 .An Kristaps Dzonsons Aq kristaps@bsd.lv .
951 Do not use this language.