xref: /freebsd/contrib/mandoc/man.7 (revision 8f7835acc6d6d39854a82173d4cf10695c6eea13)
1.\" $Id: man.7,v 1.150 2023/10/23 22:57:54 schwarze Exp $
2.\"
3.\" Copyright (c) 2009, 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
4.\" Copyright (c) 2011-2015,2017-2020,2023 Ingo Schwarze <schwarze@openbsd.org>
5.\" Copyright (c) 2017 Anthony Bentley <bentley@openbsd.org>
6.\" Copyright (c) 2010 Joerg Sonnenberger <joerg@netbsd.org>
7.\"
8.\" Permission to use, copy, modify, and distribute this software for any
9.\" purpose with or without fee is hereby granted, provided that the above
10.\" copyright notice and this permission notice appear in all copies.
11.\"
12.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19.\"
20.Dd $Mdocdate: October 23 2023 $
21.Dt MAN 7
22.Os
23.Sh NAME
24.Nm man
25.Nd legacy formatting language for manual pages
26.Sh DESCRIPTION
27The
28.Nm man
29language was the standard formatting language for
30.At
31manual pages from 1979 to 1989.
32Do not use it to write new manual pages: it is a purely presentational
33language and lacks support for semantic markup.
34Use the
35.Xr mdoc 7
36language, instead.
37.Pp
38In a
39.Nm
40document, lines beginning with the control character
41.Sq \&.
42are called
43.Dq macro lines .
44The first word is the macro name.
45It usually consists of two capital letters.
46For a list of portable macros, see
47.Sx MACRO OVERVIEW .
48The words following the macro name are arguments to the macro.
49.Pp
50Lines not beginning with the control character are called
51.Dq text lines .
52They provide free-form text to be printed; the formatting of the text
53depends on the respective processing context:
54.Bd -literal -offset indent
55\&.SH Macro lines change control state.
56Text lines are interpreted within the current state.
57.Ed
58.Pp
59Many aspects of the basic syntax of the
60.Nm
61language are based on the
62.Xr roff 7
63language; see the
64.Em LANGUAGE SYNTAX
65and
66.Em MACRO SYNTAX
67sections in the
68.Xr roff 7
69manual for details, in particular regarding
70comments, escape sequences, whitespace, and quoting.
71.Pp
72Each
73.Nm
74document starts with the
75.Ic TH
76macro specifying the document's name and section, followed by the
77.Sx NAME
78section formatted as follows:
79.Bd -literal -offset indent
80\&.TH PROGNAME 1 1979-01-10
81\&.SH NAME
82\efBprogname\efR \e(en one line about what it does
83.Ed
84.Sh MACRO OVERVIEW
85This overview is sorted such that macros of similar purpose are listed
86together.
87Deprecated and non-portable macros are not included in the overview,
88but can be found in the alphabetical reference below.
89.Ss Page header and footer meta-data
90.Bl -column "RS, RE" description
91.It Ic TH Ta set the title: Ar name section date Op Ar source Op Ar volume
92.It Ic AT Ta display AT&T UNIX version in the page footer (<= 1 argument)
93.It Ic UC Ta display BSD version in the page footer (<= 1 argument)
94.El
95.Ss Sections and paragraphs
96.Bl -column "RS, RE" description
97.It Ic SH Ta section header (one line)
98.It Ic SS Ta subsection header (one line)
99.It Ic PP Ta start an undecorated paragraph (no arguments)
100.It Ic IP Ta indented paragraph: Op Ar head Op Ar width
101.It Ic TP Ta tagged paragraph: Op Ar width
102.It Ic PD Ta set vertical paragraph distance: Op Ar height
103.It Ic EX , EE Ta display an example (no arguments)
104.It Ic RS , RE Ta reset the left margin: Op Ar width
105.It Ic in Ta additional indent: Op Ar width
106.El
107.Ss Physical markup
108.Bl -column "RS, RE" description
109.It Ic B Ta boldface font
110.It Ic I Ta italic font
111.It Ic SB Ta small boldface font
112.It Ic SM Ta small roman font
113.It Ic BI Ta alternate between boldface and italic fonts
114.It Ic BR Ta alternate between boldface and roman fonts
115.It Ic IB Ta alternate between italic and boldface fonts
116.It Ic IR Ta alternate between italic and roman fonts
117.It Ic RB Ta alternate between roman and boldface fonts
118.It Ic RI Ta alternate between roman and italic fonts
119.El
120.Sh MACRO REFERENCE
121This section is a canonical reference to all macros, arranged
122alphabetically.
123For the scoping of individual macros, see
124.Sx MACRO SYNTAX .
125.Bl -tag -width 3n
126.It Ic AT
127Sets the volume for the footer for compatibility with man pages from
128.At
129releases.
130The optional arguments specify which release it is from.
131This macro is an extension that first appeared in
132.Bx 4.3 .
133.It Ic B
134Text is rendered in bold face.
135.It Ic BI
136Text is rendered alternately in bold face and italic.
137Thus,
138.Sq .BI this word and that
139causes
140.Sq this
141and
142.Sq and
143to render in bold face, while
144.Sq word
145and
146.Sq that
147render in italics.
148Whitespace between arguments is omitted in output.
149.Pp
150Example:
151.Pp
152.Dl \&.BI bold italic bold italic
153.It Ic BR
154Text is rendered alternately in bold face and roman (the default font).
155Whitespace between arguments is omitted in output.
156See also
157.Ic BI .
158.It Ic DT
159Restore the default tabulator positions.
160They are at intervals of 0.5 inches.
161This has no effect unless the tabulator positions were changed with the
162.Xr roff 7
163.Ic ta
164request.
165.It Ic EE
166End an example block started with
167.Ic EX .
168This is a Version 9
169.At
170extension later adopted by GNU.
171In
172.Xr mandoc 1 ,
173it does the same as the
174.Xr roff 7
175.Ic fi
176request (switch to fill mode).
177.It Ic EX
178Begin a block to display an example.
179This is a Version 9
180.At
181extension later adopted by GNU.
182In
183.Xr mandoc 1 ,
184it does the same as the
185.Xr roff 7
186.Ic nf
187request (switch to no-fill mode).
188.It Ic HP
189Begin a paragraph whose initial output line is left-justified, but
190subsequent output lines are indented, with the following syntax:
191.Pp
192.D1 Pf . Ic HP Op Ar width
193.Pp
194The
195.Ar width
196argument is a
197.Xr roff 7
198scaling width.
199If specified, it's saved for later paragraph left margins;
200if unspecified, the saved or default width is used.
201.Pp
202This macro is portable, but deprecated
203because it has no good representation in HTML output,
204usually ending up indistinguishable from
205.Ic PP .
206.It Ic I
207Text is rendered in italics.
208.It Ic IB
209Text is rendered alternately in italics and bold face.
210Whitespace between arguments is omitted in output.
211See also
212.Ic BI .
213.It Ic IP
214Begin an indented paragraph with the following syntax:
215.Pp
216.D1 Pf . Ic IP Op Ar head Op Ar width
217.Pp
218The
219.Ar width
220argument is a
221.Xr roff 7
222scaling width defining the left margin.
223It's saved for later paragraph left-margins; if unspecified, the saved or
224default width is used.
225.Pp
226The
227.Ar head
228argument is used as a leading term, flushed to the left margin.
229This is useful for bulleted paragraphs and so on.
230.It Ic IR
231Text is rendered alternately in italics and roman (the default font).
232Whitespace between arguments is omitted in output.
233See also
234.Ic BI .
235.It Ic LP
236A synonym for
237.Ic PP .
238.It Ic ME
239End a mailto block started with
240.Ic MT .
241This is a GNU extension.
242.It Ic MT
243Begin a mailto block.
244This is a GNU extension.
245It has the following syntax:
246.Bd -unfilled -offset indent
247.Pf . Ic MT Ar address
248link description to be shown
249.Pf . Ic ME
250.Ed
251.It Ic OP
252Optional command-line argument.
253This is a rarely used DWB extension.
254It has the following syntax:
255.Pp
256.D1 Pf . Ic OP Ar key Op Ar value
257.Pp
258The
259.Ar key
260is usually a command-line flag and
261.Ar value
262its argument.
263.It Ic P
264This synonym for
265.Ic PP
266is an
267.At III
268extension later adopted by
269.Bx 4.3 .
270.It Ic PD
271Specify the vertical space to be inserted before each new paragraph.
272.br
273The syntax is as follows:
274.Pp
275.D1 Pf . Ic PD Op Ar height
276.Pp
277The
278.Ar height
279argument is a
280.Xr roff 7
281scaling width.
282It defaults to
283.Cm 1v .
284If the unit is omitted,
285.Cm v
286is assumed.
287.Pp
288This macro affects the spacing before any subsequent instances of
289.Ic HP ,
290.Ic IP ,
291.Ic LP ,
292.Ic P ,
293.Ic PP ,
294.Ic SH ,
295.Ic SS ,
296.Ic SY ,
297and
298.Ic TP .
299.It Ic PP
300Begin an undecorated paragraph.
301The scope of a paragraph is closed by a subsequent paragraph,
302sub-section, section, or end of file.
303The saved paragraph left-margin width is reset to the default.
304.It Ic RB
305Text is rendered alternately in roman (the default font) and bold face.
306Whitespace between arguments is omitted in output.
307See also
308.Ic BI .
309.It Ic RE
310Explicitly close out the scope of a prior
311.Ic RS .
312The default left margin is restored to the state before that
313.Ic RS
314invocation.
315.Pp
316The syntax is as follows:
317.Pp
318.D1 Pf . Ic RE Op Ar level
319.Pp
320Without an argument, the most recent
321.Ic RS
322block is closed out.
323If
324.Ar level
325is 1, all open
326.Ic RS
327blocks are closed out.
328Otherwise,
329.Ar level No \(mi 1
330nested
331.Ic RS
332blocks remain open.
333.It Ic RI
334Text is rendered alternately in roman (the default font) and italics.
335Whitespace between arguments is omitted in output.
336See also
337.Ic BI .
338.It Ic RS
339Temporarily reset the default left margin.
340This has the following syntax:
341.Pp
342.D1 Pf . Ic RS Op Ar width
343.Pp
344The
345.Ar width
346argument is a
347.Xr roff 7
348scaling width.
349If not specified, the saved or default width is used.
350.Pp
351See also
352.Ic RE .
353.It Ic SB
354Text is rendered in small size (one point smaller than the default font)
355bold face.
356This macro is an extension that probably first appeared in SunOS 4.0
357and was later adopted by GNU and by
358.Bx 4.4 .
359.It Ic SH
360Begin a section.
361The scope of a section is only closed by another section or the end of
362file.
363The paragraph left-margin width is reset to the default.
364.It Ic SM
365Text is rendered in small size (one point smaller than the default
366font).
367.It Ic SS
368Begin a sub-section.
369The scope of a sub-section is closed by a subsequent sub-section,
370section, or end of file.
371The paragraph left-margin width is reset to the default.
372.It Ic SY
373Begin a synopsis block with the following syntax:
374.Bd -unfilled -offset indent
375.Pf . Ic SY Ar command
376.Ar arguments
377.Pf . Ic YS
378.Ed
379.Pp
380This is a GNU extension and rarely used even in GNU manual pages.
381Formatting is similar to
382.Ic IP .
383.It Ic TH
384Set the name of the manual page for use in the page header
385and footer with the following syntax:
386.Pp
387.D1 Pf . Ic TH Ar name section date Op Ar source Op Ar volume
388.Pp
389Conventionally, the document
390.Ar name
391is given in all caps.
392The
393.Ar section
394is usually a single digit, in a few cases followed by a letter.
395The recommended
396.Ar date
397format is
398.Sy YYYY-MM-DD
399as specified in the ISO-8601 standard;
400if the argument does not conform, it is printed verbatim.
401If the
402.Ar date
403is empty or not specified, the current date is used.
404The optional
405.Ar source
406string specifies the organisation providing the utility.
407When unspecified,
408.Xr mandoc 1
409uses its
410.Fl Ios
411argument.
412The
413.Ar volume
414string replaces the default volume title of the
415.Ar section .
416.Pp
417Examples:
418.Pp
419.Dl \&.TH CVS 5 "1992-02-12" GNU
420.It Ic TP
421Begin a paragraph where the head, if exceeding the indentation width, is
422followed by a newline; if not, the body follows on the same line after
423advancing to the indentation width.
424Subsequent output lines are indented.
425The syntax is as follows:
426.Bd -unfilled -offset indent
427.Pf . Ic TP Op Ar width
428.Ar head No \e" one line
429.Ar body
430.Ed
431.Pp
432The
433.Ar width
434argument is a
435.Xr roff 7
436scaling width.
437If specified, it's saved for later paragraph left-margins; if
438unspecified, the saved or default width is used.
439.It Ic TQ
440Like
441.Ic TP ,
442except that no vertical spacing is inserted before the paragraph.
443This is a GNU extension.
444.It Ic UC
445Sets the volume for the footer for compatibility with man pages from
446.Bx
447releases.
448The optional first argument specifies which release it is from.
449This macro is an extension that first appeared in
450.Bx 3 .
451.It Ic UE
452End a uniform resource identifier block started with
453.Ic UR .
454This is a GNU extension.
455.It Ic UR
456Begin a uniform resource identifier block.
457This is a GNU extension.
458It has the following syntax:
459.Bd -unfilled -offset indent
460.Pf . Ic UR Ar uri
461link description to be shown
462.Pf . Ic UE
463.Ed
464.It Ic YS
465End a synopsis block started with
466.Ic SY .
467This is a GNU extension.
468.It Ic in
469Indent relative to the current indentation:
470.Pp
471.D1 Pf . Ic in Op Ar width
472.Pp
473If
474.Ar width
475is signed, the new offset is relative.
476Otherwise, it is absolute.
477This value is reset upon the next paragraph, section, or sub-section.
478.El
479.Sh MACRO SYNTAX
480The
481.Nm
482macros are classified by scope: line scope or block scope.
483Line macros are only scoped to the current line (and, in some
484situations, the subsequent line).
485Block macros are scoped to the current line and subsequent lines until
486closed by another block macro.
487.Ss Line Macros
488Line macros are generally scoped to the current line, with the body
489consisting of zero or more arguments.
490If a macro is scoped to the next line and the line arguments are empty,
491the next line, which must be text, is used instead.
492Thus:
493.Bd -literal -offset indent
494\&.I
495foo
496.Ed
497.Pp
498is equivalent to
499.Sq .I foo .
500If next-line macros are invoked consecutively, only the last is used.
501If a next-line macro is followed by a non-next-line macro, an error is
502raised.
503.Pp
504The syntax is as follows:
505.Bd -literal -offset indent
506\&.YO \(lBbody...\(rB
507\(lBbody...\(rB
508.Ed
509.Bl -column "MacroX" "ArgumentsX" "ScopeXXXXX" "CompatX" -offset indent
510.It Em Macro Ta Em Arguments Ta Em Scope     Ta Em Notes
511.It Ic AT  Ta    <=1       Ta    current   Ta    \&
512.It Ic B   Ta    n         Ta    next-line Ta    \&
513.It Ic BI  Ta    n         Ta    current   Ta    \&
514.It Ic BR  Ta    n         Ta    current   Ta    \&
515.It Ic DT  Ta    0         Ta    current   Ta    \&
516.It Ic EE  Ta    0         Ta    current   Ta    Version 9 At
517.It Ic EX  Ta    0         Ta    current   Ta    Version 9 At
518.It Ic I   Ta    n         Ta    next-line Ta    \&
519.It Ic IB  Ta    n         Ta    current   Ta    \&
520.It Ic IR  Ta    n         Ta    current   Ta    \&
521.It Ic OP  Ta    >=1       Ta    current   Ta    DWB
522.It Ic PD  Ta    1         Ta    current   Ta    \&
523.It Ic RB  Ta    n         Ta    current   Ta    \&
524.It Ic RI  Ta    n         Ta    current   Ta    \&
525.It Ic SB  Ta    n         Ta    next-line Ta    \&
526.It Ic SM  Ta    n         Ta    next-line Ta    \&
527.It Ic TH  Ta    >1, <6    Ta    current   Ta    \&
528.It Ic UC  Ta    <=1       Ta    current   Ta    \&
529.It Ic in  Ta    1         Ta    current   Ta    Xr roff 7
530.El
531.Ss Block Macros
532Block macros comprise a head and body.
533As with in-line macros, the head is scoped to the current line and, in
534one circumstance, the next line (the next-line stipulations as in
535.Sx Line Macros
536apply here as well).
537.Pp
538The syntax is as follows:
539.Bd -literal -offset indent
540\&.YO \(lBhead...\(rB
541\(lBhead...\(rB
542\(lBbody...\(rB
543.Ed
544.Pp
545The closure of body scope may be to the section, where a macro is closed
546by
547.Ic SH ;
548sub-section, closed by a section or
549.Ic SS ;
550or paragraph, closed by a section, sub-section,
551.Ic HP ,
552.Ic IP ,
553.Ic LP ,
554.Ic P ,
555.Ic PP ,
556.Ic RE ,
557.Ic SY ,
558or
559.Ic TP .
560No closure refers to an explicit block closing macro.
561.Pp
562As a rule, block macros may not be nested; thus, calling a block macro
563while another block macro scope is open, and the open scope is not
564implicitly closed, is syntactically incorrect.
565.Bl -column "MacroX" "ArgumentsX" "Head ScopeX" "sub-sectionX" "compatX" -offset indent
566.It Em Macro Ta Em Arguments Ta Em Head Scope Ta Em Body Scope  Ta Em Notes
567.It Ic HP  Ta    <2        Ta    current    Ta    paragraph   Ta    \&
568.It Ic IP  Ta    <3        Ta    current    Ta    paragraph   Ta    \&
569.It Ic LP  Ta    0         Ta    current    Ta    paragraph   Ta    \&
570.It Ic ME  Ta    0         Ta    none       Ta    none        Ta    GNU
571.It Ic MT  Ta    1         Ta    current    Ta    to \&ME     Ta    GNU
572.It Ic P   Ta    0         Ta    current    Ta    paragraph   Ta    \&
573.It Ic PP  Ta    0         Ta    current    Ta    paragraph   Ta    \&
574.It Ic RE  Ta    <=1       Ta    current    Ta    none        Ta    \&
575.It Ic RS  Ta    1         Ta    current    Ta    to \&RE     Ta    \&
576.It Ic SH  Ta    >0        Ta    next-line  Ta    section     Ta    \&
577.It Ic SS  Ta    >0        Ta    next-line  Ta    sub-section Ta    \&
578.It Ic SY  Ta    1         Ta    current    Ta    to \&YS     Ta    GNU
579.It Ic TP  Ta    n         Ta    next-line  Ta    paragraph   Ta    \&
580.It Ic TQ  Ta    n         Ta    next-line  Ta    paragraph   Ta    GNU
581.It Ic UE  Ta    0         Ta    current    Ta    none        Ta    GNU
582.It Ic UR  Ta    1         Ta    current    Ta    part        Ta    GNU
583.It Ic YS  Ta    0         Ta    none       Ta    none        Ta    GNU
584.El
585.Pp
586If a block macro is next-line scoped, it may only be followed by in-line
587macros for decorating text.
588.Ss Font handling
589In
590.Nm
591documents, both
592.Sx Physical markup
593macros and
594.Xr roff 7
595.Ql \ef
596font escape sequences can be used to choose fonts.
597In text lines, the effect of manual font selection by escape sequences
598only lasts until the next macro invocation; in macro lines, it only lasts
599until the end of the macro scope.
600Note that macros like
601.Ic BR
602open and close a font scope for each argument.
603.Sh SEE ALSO
604.Xr man 1 ,
605.Xr mandoc 1 ,
606.Xr eqn 7 ,
607.Xr mandoc_char 7 ,
608.Xr mdoc 7 ,
609.Xr roff 7 ,
610.Xr tbl 7
611.Sh HISTORY
612The
613.Nm
614language first appeared as a macro package for the roff typesetting
615system in
616.At v7 .
617.Pp
618The stand-alone implementation that is part of the
619.Xr mandoc 1
620utility first appeared in
621.Ox 4.6 .
622.Sh AUTHORS
623.An -nosplit
624.An Douglas McIlroy Aq Mt m.douglas.mcilroy@dartmouth.edu
625designed and implemented the original version of these macros,
626wrote the original version of this manual page,
627and was the first to use them when he edited volume 1 of the
628.At v7
629manual pages.
630.Pp
631.An James Clark
632later rewrote the macros for groff.
633.An Eric S. Raymond Aq Mt esr@thyrsus.com
634and
635.An Werner Lemberg Aq Mt wl@gnu.org
636added the extended
637.Nm
638macros to groff in 2007.
639.Pp
640The
641.Xr mandoc 1
642program and this
643.Nm
644reference were written by
645.An Kristaps Dzonsons Aq Mt kristaps@bsd.lv .
646