1 .\" $Id: man.7,v 1.104 2011/08/17 22:20:14 kristaps Exp $
3 .\" Copyright (c) 2009, 2010 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: August 17 2011 $
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 tab character.
56 The back-space character
58 indicates the start of an escape sequence for
60 .Sx Predefined Strings ,
62 .Sx Special Characters .
64 Text following an escaped double-quote
66 whether in a macro or text line, is ignored to the end of
68 A macro line beginning with a control character and comment escape
72 macro lines with only a control character and optional trailing
77 .Bd -literal -offset indent -compact
78 \&.\e\*q This is a comment line.
79 \&.\e\*q The next line is ignored:
81 \&.Em Emphasis \e\*q This is also a comment.
83 .Ss Special Characters
84 Special characters are used to encode special glyphs and are rendered
85 differently across output media.
86 They may occur in both macro and text lines.
87 Sequences begin with the escape character
89 followed by either an open-parenthesis
91 for two-character sequences; an open-bracket
93 for n-character sequences (terminated at a close-bracket
95 or a single one character sequence.
98 .Bl -tag -width Ds -offset indent -compact
109 Terms may be text-decorated using the
111 escape followed by an indicator: B (bold), I (italic), R (regular), or P
112 (revert to previous mode):
113 A numerical representation 3, 2, or 1 (bold, italic, and regular,
114 respectively) may be used instead.
115 A text decoration is only valid, if specified in free-form text, until
116 the next macro invocation; if specified within a macro, it's only valid
117 until the macro closes scope.
118 Note that macros like
120 open and close a font scope with each argument.
124 attribute is forgotten when entering or exiting a macro block.
127 .Bl -tag -width Ds -offset indent -compact
129 write in bold, then switch to regular
131 write in italic, then return to previous
133 .Ss Predefined Strings
134 Predefined strings, like
135 .Sx Special Characters ,
136 mark special output glyphs.
137 Predefined strings are escaped with the slash-asterisk,
147 .Bl -tag -width Ds -offset indent -compact
154 These strings are set using
158 consists of several pre-set escapes listed in
161 Whitespace consists of the space character.
162 In text lines, whitespace is preserved within a line.
163 In macro lines, whitespace delimits arguments and is discarded.
165 Unescaped trailing spaces are stripped from text line input unless in a
167 In general, trailing whitespace on any input line is discouraged for
168 reasons of portability.
169 In the rare case that a blank character is needed at the end of an
170 input line, it may be forced by
173 If the first character of a text line is a space, that line is printed
174 with a leading newline.
176 Macro arguments may be quoted with double-quotes; in this case,
177 whitespace within the quotes is retained as part of the argument.
179 A quoted argument begins with a double-quote preceded by whitespace.
180 The next double-quote not pairwise adjacent to another double-quote
181 terminates the literal, regardless of surrounding whitespace.
183 In unquoted arguments, space characters can alternatively be included
184 by preceding them with a backslash
186 but quoting is usually better for clarity.
188 Note that any quoted text, even if it would cause a macro invocation
189 when unquoted, is considered literal text.
191 In text lines, quotes are regarded as opaque text.
193 Many macros support scaled widths for their arguments.
194 The syntax for a scaled width is
195 .Sq Li [+-]?[0-9]*.[0-9]*[:unit:] ,
196 where a decimal must be preceded or proceeded by at least one digit.
197 Negative numbers, while accepted, are truncated to zero.
199 The following scaling units are accepted:
201 .Bl -tag -width Ds -offset indent -compact
214 default vertical span
226 default horizontal span
231 Using anything other than
237 is necessarily non-portable across output media.
241 If a scaling unit is not provided, the numerical value is interpreted
242 under the default rules of
244 for vertical spaces and
249 .Bl -tag -width Ds -offset indent -compact
251 two-inch tagged list indentation
258 Sentences should terminate at the end of an input line.
259 By doing this, a formatter will be able to apply the proper amount of
260 spacing after the end of sentence (unescaped) period, exclamation mark,
261 or question mark followed by zero or more non-sentence closing
271 .Bd -literal -offset indent -compact
272 Do not end sentences mid-line like this. Instead,
273 end a sentence like this.
274 A new sentence gets a new line.
279 document must contain the
281 macro describing the document's section and title.
282 It may occur anywhere in the document, although conventionally it
283 appears as the first macro.
287 at least one macro or text node must appear in the document.
289 The following is a well-formed skeleton
293 .Bd -literal -offset indent
294 \&.TH PROGNAME 1 2009-10-10
296 \efBprogname\efR \e(en a description goes here
298 \&.\e\*q For sections 2 & 3 only.
299 \&.\e\*q Not used in OpenBSD.
301 \efBprogname\efR [\efB\e-options\efR] arguments...
303 The \efBfoo\efR utility processes files...
304 \&.\e\*q .SH IMPLEMENTATION NOTES
305 \&.\e\*q Not used in OpenBSD.
306 \&.\e\*q .SH RETURN VALUES
307 \&.\e\*q For sections 2, 3, & 9 only.
308 \&.\e\*q .SH ENVIRONMENT
309 \&.\e\*q For sections 1, 6, 7, & 8 only.
311 \&.\e\*q .SH EXIT STATUS
312 \&.\e\*q For sections 1, 6, & 8 only.
313 \&.\e\*q .SH EXAMPLES
314 \&.\e\*q .SH DIAGNOSTICS
315 \&.\e\*q For sections 1, 4, 6, 7, & 8 only.
317 \&.\e\*q For sections 2, 3, & 9 only.
318 \&.\e\*q .SH SEE ALSO
319 \&.\e\*q .BR foo ( 1 )
320 \&.\e\*q .SH STANDARDS
325 \&.\e\*q .SH SECURITY CONSIDERATIONS
326 \&.\e\*q Not used in OpenBSD.
331 document are conventionally ordered as they appear above.
332 Sections should be composed as follows:
333 .Bl -ohang -offset indent
335 The name(s) and a short description of the documented material.
336 The syntax for this is generally as follows:
338 .D1 \efBname\efR \e(en description
340 The name of the library containing the documented material, which is
341 assumed to be a function in a section 2 or 3 manual.
342 For functions in the C library, this may be as follows:
344 .D1 Standard C Library (libc, -lc)
346 Documents the utility invocation syntax, function call syntax, or device
349 For the first, utilities (sections 1, 6, and 8), this is
350 generally structured as follows:
352 .D1 \efBname\efR [-\efBab\efR] [-\efBc\efR\efIarg\efR] \efBpath\efR...
354 For the second, function calls (sections 2, 3, 9):
356 .D1 \&.B char *name(char *\efIarg\efR);
358 And for the third, configurations (section 4):
360 .D1 \&.B name* at cardbus ? function ?
362 Manuals not in these sections generally don't need a
365 This expands upon the brief, one-line description in
367 It usually contains a break-down of the options (if documenting a
369 .It Em IMPLEMENTATION NOTES
370 Implementation-specific notes should be kept here.
371 This is useful when implementing standard functions that may have side
372 effects or notable algorithmic implications.
374 This section documents the return values of functions in sections 2, 3, and 9.
376 Documents any usages of environment variables, e.g.,
379 Documents files used.
380 It's helpful to document both the file name and a short description of how
381 the file is used (created, modified, etc.).
383 This section documents the command exit status for
384 section 1, 6, and 8 utilities.
385 Historically, this information was described in
387 a practise that is now discouraged.
390 This often contains snippets of well-formed,
391 well-tested invocations.
392 Make sure that examples work properly!
394 Documents error conditions.
395 This is most useful in section 4 manuals.
396 Historically, this section was used in place of
398 for manuals in sections 1, 6, and 8; however, this practise is
401 Documents error handling in sections 2, 3, and 9.
403 References other manuals with related topics.
404 This section should exist for most manuals.
406 .D1 \&.BR bar \&( 1 \&),
408 Cross-references should conventionally be ordered
409 first by section, then alphabetically.
411 References any standards implemented or used, such as
413 .D1 IEEE Std 1003.2 (\e(lqPOSIX.2\e(rq)
415 If not adhering to any standards, the
417 section should be used.
419 A brief history of the subject, including where support first appeared.
421 Credits to the person or persons who wrote the code and/or documentation.
422 Authors should generally be noted by both name and email address.
424 Common misuses and misunderstandings should be explained
427 Known bugs, limitations, and work-arounds should be described
429 .It Em SECURITY CONSIDERATIONS
430 Documents any security precautions that operators should consider.
433 Macros are one to three characters in length and begin with a
436 at the beginning of the line.
439 macro control character is also accepted.
440 An arbitrary amount of whitespace (spaces or tabs) may sit between the
441 control character and the macro name.
442 Thus, the following are equivalent:
443 .Bd -literal -offset indent
448 To include space characters in macro arguments, arguments may be quoted;
457 macros are classified by scope: line scope or block scope.
458 Line macros are only scoped to the current line (and, in some
459 situations, the subsequent line).
460 Block macros are scoped to the current line and subsequent lines until
461 closed by another block macro.
463 Line macros are generally scoped to the current line, with the body
464 consisting of zero or more arguments.
465 If a macro is scoped to the next line and the line arguments are empty,
466 the next line, which must be text, is used instead.
468 .Bd -literal -offset indent
475 If next-line macros are invoked consecutively, only the last is used.
476 If a next-line macro is followed by a non-next-line macro, an error is
483 The syntax is as follows:
484 .Bd -literal -offset indent
485 \&.YO \(lBbody...\(rB
489 .Bl -column -compact -offset indent "MacroX" "ArgumentsX" "ScopeXXXXX" "CompatX"
490 .It Em Macro Ta Em Arguments Ta Em Scope Ta Em Notes
491 .It Sx \&AT Ta <=1 Ta current Ta \&
492 .It Sx \&B Ta n Ta next-line Ta \&
493 .It Sx \&BI Ta n Ta current Ta \&
494 .It Sx \&BR Ta n Ta current Ta \&
495 .It Sx \&DT Ta 0 Ta current Ta \&
496 .It Sx \&I Ta n Ta next-line Ta \&
497 .It Sx \&IB Ta n Ta current Ta \&
498 .It Sx \&IR Ta n Ta current Ta \&
499 .It Sx \&R Ta n Ta next-line Ta \&
500 .It Sx \&RB Ta n Ta current Ta \&
501 .It Sx \&RI Ta n Ta current Ta \&
502 .It Sx \&SB Ta n Ta next-line Ta \&
503 .It Sx \&SM Ta n Ta next-line Ta \&
504 .It Sx \&TH Ta >1, <6 Ta current Ta \&
505 .It Sx \&UC Ta <=1 Ta current Ta \&
506 .It Sx \&br Ta 0 Ta current Ta compat
507 .It Sx \&fi Ta 0 Ta current Ta compat
508 .It Sx \&ft Ta 1 Ta current Ta compat
509 .It Sx \&in Ta 1 Ta current Ta compat
510 .It Sx \&na Ta 0 Ta current Ta compat
511 .It Sx \&nf Ta 0 Ta current Ta compat
512 .It Sx \&sp Ta 1 Ta current Ta compat
517 are included for compatibility with the significant corpus of existing
518 manuals that mix dialects of roff.
519 These macros should not be used for portable
523 Block macros comprise a head and body.
524 As with in-line macros, the head is scoped to the current line and, in
525 one circumstance, the next line (the next-line stipulations as in
529 The syntax is as follows:
530 .Bd -literal -offset indent
531 \&.YO \(lBhead...\(rB
536 The closure of body scope may be to the section, where a macro is closed
539 sub-section, closed by a section or
541 part, closed by a section, sub-section, or
543 or paragraph, closed by a section, sub-section, part,
551 No closure refers to an explicit block closing macro.
553 As a rule, block macros may not be nested; thus, calling a block macro
554 while another block macro scope is open, and the open scope is not
555 implicitly closed, is syntactically incorrect.
557 .Bl -column -compact -offset indent "MacroX" "ArgumentsX" "Head ScopeX" "sub-sectionX" "compatX"
558 .It Em Macro Ta Em Arguments Ta Em Head Scope Ta Em Body Scope Ta Em Notes
559 .It Sx \&HP Ta <2 Ta current Ta paragraph Ta \&
560 .It Sx \&IP Ta <3 Ta current Ta paragraph Ta \&
561 .It Sx \&LP Ta 0 Ta current Ta paragraph Ta \&
562 .It Sx \&P Ta 0 Ta current Ta paragraph Ta \&
563 .It Sx \&PP Ta 0 Ta current Ta paragraph Ta \&
564 .It Sx \&RE Ta 0 Ta current Ta none Ta compat
565 .It Sx \&RS Ta 1 Ta current Ta part Ta compat
566 .It Sx \&SH Ta >0 Ta next-line Ta section Ta \&
567 .It Sx \&SS Ta >0 Ta next-line Ta sub-section Ta \&
568 .It Sx \&TP Ta n Ta next-line Ta paragraph Ta \&
576 If a block macro is next-line scoped, it may only be followed by in-line
577 macros for decorating text.
579 This section is a canonical reference to all macros, arranged
581 For the scoping of individual macros, see
584 Sets the volume for the footer for compatibility with man pages from
587 The optional arguments specify which release it is from.
589 Text is rendered in bold face.
596 Text is rendered alternately in bold face and italic.
598 .Sq .BI this word and that
603 to render in bold face, while
608 Whitespace between arguments is omitted in output.
612 .Dl \&.BI bold italic bold italic
614 The output of this example will be emboldened
618 with spaces stripped between arguments.
628 Text is rendered alternately in bold face and roman (the default font).
629 Whitespace between arguments is omitted in output.
633 for an equivalent example.
644 Included for compatibility.
646 Begin a paragraph whose initial output line is left-justified, but
647 subsequent output lines are indented, with the following syntax:
648 .Bd -filled -offset indent
655 argument must conform to
657 If specified, it's saved for later paragraph left-margins; if unspecified, the
658 saved or default width is used.
668 Text is rendered in italics.
675 Text is rendered alternately in italics and bold face.
676 Whitespace between arguments is omitted in output.
680 for an equivalent example.
690 Begin an indented paragraph with the following syntax:
691 .Bd -filled -offset indent
693 .Op Cm head Op Cm width
698 argument defines the width of the left margin and is defined by
700 It's saved for later paragraph left-margins; if unspecified, the saved or
701 default width is used.
705 argument is used as a leading term, flushed to the left margin.
706 This is useful for bulleted paragraphs and so on.
716 Text is rendered alternately in italics and roman (the default font).
717 Whitespace between arguments is omitted in output.
721 for an equivalent example.
731 Begin an undecorated paragraph.
732 The scope of a paragraph is closed by a subsequent paragraph,
733 sub-section, section, or end of file.
734 The saved paragraph left-margin width is reset to the default.
766 Text is rendered in roman (the default font).
773 Text is rendered alternately in roman (the default font) and bold face.
774 Whitespace between arguments is omitted in output.
778 for an equivalent example.
788 Explicitly close out the scope of a prior
790 The default left margin is restored to the state of the original
794 Text is rendered alternately in roman (the default font) and italics.
795 Whitespace between arguments is omitted in output.
799 for an equivalent example.
809 Temporarily reset the default left margin.
810 This has the following syntax:
811 .Bd -filled -offset indent
818 argument must conform to
820 If not specified, the saved or default width is used.
825 Text is rendered in small size (one point smaller than the default font)
829 The scope of a section is only closed by another section or the end of
831 The paragraph left-margin width is reset to the default.
833 Text is rendered in small size (one point smaller than the default
837 The scope of a sub-section is closed by a subsequent sub-section,
838 section, or end of file.
839 The paragraph left-margin width is reset to the default.
841 Sets the title of the manual page with the following syntax:
842 .Bd -filled -offset indent
844 .Ar title section date
845 .Op Ar source Op Ar volume
848 Conventionally, the document
850 is given in all caps.
855 as specified in the ISO-8601 standard;
856 if the argument does not conform, it is printed verbatim.
859 is empty or not specified, the current date is used.
862 string specifies the organisation providing the utility.
865 string replaces the default rendered volume, which is dictated by the
870 .Dl \&.TH CVS 5 "1992-02-12" GNU
872 Begin a paragraph where the head, if exceeding the indentation width, is
873 followed by a newline; if not, the body follows on the same line after a
874 buffer to the indentation width.
875 Subsequent output lines are indented.
876 The syntax is as follows:
877 .Bd -filled -offset indent
884 argument must conform to
886 If specified, it's saved for later paragraph left-margins; if
887 unspecified, the saved or default width is used.
897 Sets the volume for the footer for compatibility with man pages from
899 The optional first argument specifies which release it is from.
901 Breaks the current line.
902 Consecutive invocations have no further effect.
907 End literal mode begun by
910 Change the current font mode.
913 for a listing of available font modes.
915 Indent relative to the current indentation:
917 .D1 Pf \. Sx \&in Op Cm width
921 is signed, the new offset is relative.
922 Otherwise, it is absolute.
923 This value is reset upon the next paragraph, section, or sub-section.
925 Don't align to the right margin.
927 Begin literal mode: all subsequent free-form lines have their end of
928 line boundaries preserved.
931 Literal mode is implicitly ended by
936 Insert vertical spaces into output with the following syntax:
937 .Bd -filled -offset indent
944 spaces, which must conform to
946 If 0, this is equivalent to the
949 Defaults to 1, if unspecified.
954 This section documents areas of questionable portability between
955 implementations of the
961 In quoted literals, GNU troff allowed pair-wise double-quotes to produce
962 a standalone double-quote in formatted output.
963 It is not known whether this behaviour is exhibited by other formatters.
965 troff suppresses a newline before
967 macro output; in mandoc, it is an alias for the standard
973 .Pq horizontal position ,
975 .Pq vertical position ,
979 .Pq text filling colour ,
981 .Pq zero-length character ,
985 .Pq horizontal position marker ,
987 .Pq text overstrike ,
991 escape sequences are all discarded in mandoc.
995 scaling unit is accepted by mandoc, but rendered as the default unit.
999 macro does not accept negative values in mandoc.
1000 In GNU troff, this would result in strange behaviour.
1013 language first appeared as a macro package for the roff typesetting
1016 It was later rewritten by James Clark as a macro package for groff.
1017 The stand-alone implementation that is part of the
1019 utility written by Kristaps Dzonsons appeared in
1024 reference was written by
1025 .An Kristaps Dzonsons Aq kristaps@bsd.lv .
1027 Do not use this language.