xref: /openbsd-src/share/man/man7/roff.7 (revision 50b7afb2c2c0993b0894d4e34bf857cb13ed9c80)
1.\"	$OpenBSD: roff.7,v 1.34 2014/07/07 11:34:41 schwarze Exp $
2.\"
3.\" Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
4.\" Copyright (c) 2010, 2011, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
5.\"
6.\" Permission to use, copy, modify, and distribute this software for any
7.\" purpose with or without fee is hereby granted, provided that the above
8.\" copyright notice and this permission notice appear in all copies.
9.\"
10.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17.\"
18.Dd $Mdocdate: July 7 2014 $
19.Dt ROFF 7
20.Os
21.Sh NAME
22.Nm roff
23.Nd roff language reference for mandoc
24.Sh DESCRIPTION
25The
26.Nm roff
27language is a general purpose text formatting language.
28Since traditional implementations of the
29.Xr mdoc 7
30and
31.Xr man 7
32manual formatting languages are based on it,
33many real-world manuals use small numbers of
34.Nm
35requests and escape sequences intermixed with their
36.Xr mdoc 7
37or
38.Xr man 7
39code.
40To properly format such manuals, the
41.Xr mandoc 1
42utility supports a tiny subset of
43.Nm
44requests and escapes.
45Only these requests and escapes supported by
46.Xr mandoc 1
47are documented in the present manual,
48together with the basic language syntax shared by
49.Nm ,
50.Xr mdoc 7 ,
51and
52.Xr man 7 .
53For complete
54.Nm
55manuals, consult the
56.Sx SEE ALSO
57section.
58.Pp
59Input lines beginning with the control character
60.Sq \&.
61are parsed for requests and macros.
62Such lines are called
63.Dq request lines
64or
65.Dq macro lines ,
66respectively.
67Requests change the processing state and manipulate the formatting;
68some macros also define the document structure and produce formatted
69output.
70The single quote
71.Pq Qq \(aq
72is accepted as an alternative control character,
73treated by
74.Xr mandoc 1
75just like
76.Ql \&.
77.Pp
78Lines not beginning with control characters are called
79.Dq text lines .
80They provide free-form text to be printed; the formatting of the text
81depends on the respective processing context.
82.Sh LANGUAGE SYNTAX
83.Nm
84documents may contain only graphable 7-bit ASCII characters, the space
85character, and, in certain circumstances, the tab character.
86The backslash character
87.Sq \e
88indicates the start of an escape sequence, used for example for
89.Sx Comments ,
90.Sx Special Characters ,
91.Sx Predefined Strings ,
92and
93user-defined strings defined using the
94.Sx ds
95request.
96For a listing of escape sequences, consult the
97.Sx ESCAPE SEQUENCE REFERENCE
98below.
99.Ss Comments
100Text following an escaped double-quote
101.Sq \e\(dq ,
102whether in a request, macro, or text line, is ignored to the end of the line.
103A request line beginning with a control character and comment escape
104.Sq \&.\e\(dq
105is also ignored.
106Furthermore, request lines with only a control character and optional
107trailing whitespace are stripped from input.
108.Pp
109Examples:
110.Bd -literal -offset indent -compact
111\&.\e\(dq This is a comment line.
112\&.\e\(dq The next line is ignored:
113\&.
114\&.Sh EXAMPLES \e\(dq This is a comment, too.
115\&example text \e\(dq And so is this.
116.Ed
117.Ss Special Characters
118Special characters are used to encode special glyphs and are rendered
119differently across output media.
120They may occur in request, macro, and text lines.
121Sequences begin with the escape character
122.Sq \e
123followed by either an open-parenthesis
124.Sq \&(
125for two-character sequences; an open-bracket
126.Sq \&[
127for n-character sequences (terminated at a close-bracket
128.Sq \&] ) ;
129or a single one character sequence.
130.Pp
131Examples:
132.Bl -tag -width Ds -offset indent -compact
133.It Li \e(em
134Two-letter em dash escape.
135.It Li \ee
136One-letter backslash escape.
137.El
138.Pp
139See
140.Xr mandoc_char 7
141for a complete list.
142.Ss Text Decoration
143Terms may be text-decorated using the
144.Sq \ef
145escape followed by an indicator: B (bold), I (italic), R (regular), or P
146(revert to previous mode).
147A numerical representation 3, 2, or 1 (bold, italic, and regular,
148respectively) may be used instead.
149.Pp
150The two-character indicator
151.Sq BI
152requests a font that is both bold and italic.
153It may not be portable to old roff implementations.
154.Pp
155Examples:
156.Bl -tag -width Ds -offset indent -compact
157.It Li \efBbold\efR
158Write in \fBbold\fP, then switch to regular font mode.
159.It Li \efIitalic\efP
160Write in \fIitalic\fP, then return to previous font mode.
161.It Li \ef(BIbold italic\efP
162Write in \f(BIbold italic\fP, then return to previous font mode.
163.El
164.Pp
165Text decoration is
166.Em not
167recommended for
168.Xr mdoc 7 ,
169which encourages semantic annotation.
170.Ss Predefined Strings
171Predefined strings, like
172.Sx Special Characters ,
173mark special output glyphs.
174Predefined strings are escaped with the slash-asterisk,
175.Sq \e* :
176single-character
177.Sq \e*X ,
178two-character
179.Sq \e*(XX ,
180and N-character
181.Sq \e*[N] .
182.Pp
183Examples:
184.Bl -tag -width Ds -offset indent -compact
185.It Li \e*(Am
186Two-letter ampersand predefined string.
187.It Li \e*q
188One-letter double-quote predefined string.
189.El
190.Pp
191Predefined strings are not recommended for use,
192as they differ across implementations.
193Those supported by
194.Xr mandoc 1
195are listed in
196.Xr mandoc_char 7 .
197Manuals using these predefined strings are almost certainly not portable.
198.Ss Whitespace
199Whitespace consists of the space character.
200In text lines, whitespace is preserved within a line.
201In request and macro lines, whitespace delimits arguments and is discarded.
202.Pp
203Unescaped trailing spaces are stripped from text line input unless in a
204literal context.
205In general, trailing whitespace on any input line is discouraged for
206reasons of portability.
207In the rare case that a blank character is needed at the end of an
208input line, it may be forced by
209.Sq \e\ \e& .
210.Pp
211Literal space characters can be produced in the output
212using escape sequences.
213In macro lines, they can also be included in arguments using quotation; see
214.Sx MACRO SYNTAX
215for details.
216.Pp
217Blank text lines, which may include whitespace, are only permitted
218within literal contexts.
219If the first character of a text line is a space, that line is printed
220with a leading newline.
221.Ss Scaling Widths
222Many requests and macros support scaled widths for their arguments.
223The syntax for a scaled width is
224.Sq Li [+-]?[0-9]*.[0-9]*[:unit:] ,
225where a decimal must be preceded or followed by at least one digit.
226Negative numbers, while accepted, are truncated to zero.
227.Pp
228The following scaling units are accepted:
229.Pp
230.Bl -tag -width Ds -offset indent -compact
231.It c
232centimetre
233.It i
234inch
235.It P
236pica (~1/6 inch)
237.It p
238point (~1/72 inch)
239.It f
240synonym for
241.Sq u
242.It v
243default vertical span
244.It m
245width of rendered
246.Sq m
247.Pq em
248character
249.It n
250width of rendered
251.Sq n
252.Pq en
253character
254.It u
255default horizontal span
256.It M
257mini-em (~1/100 em)
258.El
259.Pp
260Using anything other than
261.Sq m ,
262.Sq n ,
263.Sq u ,
264or
265.Sq v
266is necessarily non-portable across output media.
267See
268.Sx COMPATIBILITY .
269.Pp
270If a scaling unit is not provided, the numerical value is interpreted
271under the default rules of
272.Sq v
273for vertical spaces and
274.Sq u
275for horizontal ones.
276.Pp
277Examples:
278.Bl -tag -width ".Bl -tag -width 2i" -offset indent -compact
279.It Li \&.Bl -tag -width 2i
280two-inch tagged list indentation in
281.Xr mdoc 7
282.It Li \&.HP 2i
283two-inch tagged list indentation in
284.Xr man 7
285.It Li \&.sp 2v
286two vertical spaces
287.El
288.Ss Sentence Spacing
289Each sentence should terminate at the end of an input line.
290By doing this, a formatter will be able to apply the proper amount of
291spacing after the end of sentence (unescaped) period, exclamation mark,
292or question mark followed by zero or more non-sentence closing
293delimiters
294.Po
295.Sq \&) ,
296.Sq \&] ,
297.Sq \&' ,
298.Sq \&"
299.Pc .
300.Pp
301The proper spacing is also intelligently preserved if a sentence ends at
302the boundary of a macro line.
303.Pp
304Examples:
305.Bd -literal -offset indent -compact
306Do not end sentences mid-line like this.  Instead,
307end a sentence like this.
308A macro would end like this:
309\&.Xr mandoc 1 \&.
310.Ed
311.Sh REQUEST SYNTAX
312A request or macro line consists of:
313.Pp
314.Bl -enum -compact
315.It
316the control character
317.Sq \&.
318or
319.Sq \(aq
320at the beginning of the line,
321.It
322optionally an arbitrary amount of whitespace,
323.It
324the name of the request or the macro, which is one word of arbitrary
325length, terminated by whitespace,
326.It
327and zero or more arguments delimited by whitespace.
328.El
329.Pp
330Thus, the following request lines are all equivalent:
331.Bd -literal -offset indent
332\&.ig end
333\&.ig    end
334\&.   ig end
335.Ed
336.Sh MACRO SYNTAX
337Macros are provided by the
338.Xr mdoc 7
339and
340.Xr man 7
341languages and can be defined by the
342.Sx \&de
343request.
344When called, they follow the same syntax as requests, except that
345macro arguments may optionally be quoted by enclosing them
346in double quote characters
347.Pq Sq \(dq .
348Quoted text, even if it contains whitespace or would cause
349a macro invocation when unquoted, is always considered literal text.
350Inside quoted text, pairs of double quote characters
351.Pq Sq Qq
352resolve to single double quote characters.
353.Pp
354To be recognised as the beginning of a quoted argument, the opening
355quote character must be preceded by a space character.
356A quoted argument extends to the next double quote character that is not
357part of a pair, or to the end of the input line, whichever comes earlier.
358Leaving out the terminating double quote character at the end of the line
359is discouraged.
360For clarity, if more arguments follow on the same input line,
361it is recommended to follow the terminating double quote character
362by a space character; in case the next character after the terminating
363double quote character is anything else, it is regarded as the beginning
364of the next, unquoted argument.
365.Pp
366Both in quoted and unquoted arguments, pairs of backslashes
367.Pq Sq \e\e
368resolve to single backslashes.
369In unquoted arguments, space characters can alternatively be included
370by preceding them with a backslash
371.Pq Sq \e\~ ,
372but quoting is usually better for clarity.
373.Pp
374Examples:
375.Bl -tag -width Ds -offset indent -compact
376.It Li .Fn strlen \(dqconst char *s\(dq
377Group arguments
378.Qq const char *s
379into one function argument.
380If unspecified,
381.Qq const ,
382.Qq char ,
383and
384.Qq *s
385would be considered separate arguments.
386.It Li .Op \(dqFl a\(dq
387Consider
388.Qq \&Fl a
389as literal text instead of a flag macro.
390.El
391.Sh REQUEST REFERENCE
392The
393.Xr mandoc 1
394.Nm
395parser recognises the following requests.
396Note that the
397.Nm
398language defines many more requests not implemented in
399.Xr mandoc 1 .
400.Ss \&ad
401Set line adjustment mode.
402This line-scoped request is intended to have one argument to select
403normal, left, right, or centre adjustment for subsequent text.
404Currently, it is ignored including its arguments,
405and the number of arguments is not checked.
406.Ss \&am
407Append to a macro definition.
408The syntax of this request is the same as that of
409.Sx \&de .
410.Ss \&ami
411Append to a macro definition, specifying the macro name indirectly.
412The syntax of this request is the same as that of
413.Sx \&dei .
414.Ss \&am1
415Append to a macro definition, switching roff compatibility mode off
416during macro execution.
417The syntax of this request is the same as that of
418.Sx \&de1 .
419Since
420.Xr mandoc 1
421does not implement
422.Nm
423compatibility mode at all, it handles this request as an alias for
424.Sx \&am .
425.Ss \&as
426Append to a user-defined string.
427The syntax of this request is the same as that of
428.Sx \&ds .
429If a user-defined string with the specified name does not yet exist,
430it is set to the empty string before appending.
431.Ss \&cc
432Changes the control character.
433Its syntax is as follows:
434.Bd -literal -offset indent
435.Pf . Cm \&cc Op Ar c
436.Ed
437.Pp
438If
439.Ar c
440is not specified, the control character is reset to
441.Sq \&. .
442Trailing characters are ignored.
443.Ss \&ce
444Center some lines.
445This line-scoped request is intended to take one integer argument,
446specifying how many lines to center.
447Currently, it is ignored including its arguments, and the number
448of arguments is not checked.
449.Ss \&de
450Define a
451.Nm
452macro.
453Its syntax can be either
454.Bd -literal -offset indent
455.Pf . Cm \&de Ar name
456.Ar macro definition
457\&..
458.Ed
459.Pp
460or
461.Bd -literal -offset indent
462.Pf . Cm \&de Ar name Ar end
463.Ar macro definition
464.Pf . Ar end
465.Ed
466.Pp
467Both forms define or redefine the macro
468.Ar name
469to represent the
470.Ar macro definition ,
471which may consist of one or more input lines, including the newline
472characters terminating each line, optionally containing calls to
473.Nm
474requests,
475.Nm
476macros or high-level macros like
477.Xr man 7
478or
479.Xr mdoc 7
480macros, whichever applies to the document in question.
481.Pp
482Specifying a custom
483.Ar end
484macro works in the same way as for
485.Sx \&ig ;
486namely, the call to
487.Sq Pf . Ar end
488first ends the
489.Ar macro definition ,
490and after that, it is also evaluated as a
491.Nm
492request or
493.Nm
494macro, but not as a high-level macro.
495.Pp
496The macro can be invoked later using the syntax
497.Pp
498.D1 Pf . Ar name Op Ar argument Op Ar argument ...
499.Pp
500Regarding argument parsing, see
501.Sx MACRO SYNTAX
502above.
503.Pp
504The line invoking the macro will be replaced
505in the input stream by the
506.Ar macro definition ,
507replacing all occurrences of
508.No \e\e$ Ns Ar N ,
509where
510.Ar N
511is a digit, by the
512.Ar N Ns th Ar argument .
513For example,
514.Bd -literal -offset indent
515\&.de ZN
516\efI\e^\e\e$1\e^\efP\e\e$2
517\&..
518\&.ZN XtFree .
519.Ed
520.Pp
521produces
522.Pp
523.D1 \efI\e^XtFree\e^\efP.
524.Pp
525in the input stream, and thus in the output: \fI\^XtFree\^\fP.
526.Pp
527Since macros and user-defined strings share a common string table,
528defining a macro
529.Ar name
530clobbers the user-defined string
531.Ar name ,
532and the
533.Ar macro definition
534can also be printed using the
535.Sq \e*
536string interpolation syntax described below
537.Sx ds ,
538but this is rarely useful because every macro definition contains at least
539one explicit newline character.
540.Pp
541In order to prevent endless recursion, both groff and
542.Xr mandoc 1
543limit the stack depth for expanding macros and strings
544to a large, but finite number.
545Do not rely on the exact value of this limit.
546.Ss \&dei
547Define a
548.Nm
549macro, specifying the macro name indirectly.
550The syntax of this request is the same as that of
551.Sx \&de .
552The request
553.Pp
554.D1 Pf . Cm \&dei Ar name Op Ar end
555.Pp
556has the same effect as:
557.Pp
558.D1 Pf . Cm \&de No \e* Ns Bo Ar name Bc Op \e* Ns Bq Ar end
559.Ss \&de1
560Define a
561.Nm
562macro that will be executed with
563.Nm
564compatibility mode switched off during macro execution.
565This is a GNU extension not available in traditional
566.Nm
567implementations and not even in older versions of groff.
568Since
569.Xr mandoc 1
570does not implement
571.Nm
572compatibility mode at all, it handles this request as an alias for
573.Sx \&de .
574.Ss \&ds
575Define a user-defined string.
576Its syntax is as follows:
577.Pp
578.D1 Pf . Cm \&ds Ar name Oo \(dq Oc Ns Ar string
579.Pp
580The
581.Ar name
582and
583.Ar string
584arguments are space-separated.
585If the
586.Ar string
587begins with a double-quote character, that character will not be part
588of the string.
589All remaining characters on the input line form the
590.Ar string ,
591including whitespace and double-quote characters, even trailing ones.
592.Pp
593The
594.Ar string
595can be interpolated into subsequent text by using
596.No \e* Ns Bq Ar name
597for a
598.Ar name
599of arbitrary length, or \e*(NN or \e*N if the length of
600.Ar name
601is two or one characters, respectively.
602Interpolation can be prevented by escaping the leading backslash;
603that is, an asterisk preceded by an even number of backslashes
604does not trigger string interpolation.
605.Pp
606Since user-defined strings and macros share a common string table,
607defining a string
608.Ar name
609clobbers the macro
610.Ar name ,
611and the
612.Ar name
613used for defining a string can also be invoked as a macro,
614in which case the following input line will be appended to the
615.Ar string ,
616forming a new input line passed to the
617.Nm
618parser.
619For example,
620.Bd -literal -offset indent
621\&.ds badidea .S
622\&.badidea
623H SYNOPSIS
624.Ed
625.Pp
626invokes the
627.Cm SH
628macro when used in a
629.Xr man 7
630document.
631Such abuse is of course strongly discouraged.
632.Ss \&el
633The
634.Qq else
635half of an if/else conditional.
636Pops a result off the stack of conditional evaluations pushed by
637.Sx \&ie
638and uses it as its conditional.
639If no stack entries are present (e.g., due to no prior
640.Sx \&ie
641calls)
642then false is assumed.
643The syntax of this request is similar to
644.Sx \&if
645except that the conditional is missing.
646.Ss \&EN
647End an equation block.
648See
649.Sx \&EQ .
650.Ss \&EQ
651Begin an equation block.
652See
653.Xr eqn 7
654for a description of the equation language.
655.Ss \&fam
656Change the font family.
657This line-scoped request is intended to have one argument specifying
658the font family to be selected.
659It is a groff extension, and currently, it is ignored including its
660arguments, and the number of arguments is not checked.
661.Ss \&ft
662Change the font.
663Its syntax is as follows:
664.Pp
665.D1 Pf . Cm \&ft Op Ar font
666.Pp
667The following
668.Ar font
669arguments are supported:
670.Bl -tag -width 4n -offset indent
671.It Cm B , BI , 3 , 4
672switches to
673.Sy bold
674font
675.It Cm I , 2
676switches to
677.Em underlined
678font
679.It Cm R , CW , 1
680switches to normal font
681.It Cm P No "or no argument"
682switches back to the previous font
683.El
684.Pp
685This request takes effect only locally, may be overridden by macros
686and escape sequences, and is only supported in
687.Xr man 7
688for now.
689.Ss \&hw
690Specify hyphenation points in words.
691This line-scoped request is currently ignored.
692.Ss \&hy
693Set automatic hyphenation mode.
694This line-scoped request is currently ignored.
695.Ss \&ie
696The
697.Qq if
698half of an if/else conditional.
699The result of the conditional is pushed into a stack used by subsequent
700invocations of
701.Sx \&el ,
702which may be separated by any intervening input (or not exist at all).
703Its syntax is equivalent to
704.Sx \&if .
705.Ss \&if
706Begins a conditional.
707This request has the following syntax:
708.Bd -literal -offset indent
709\&.if COND BODY
710.Ed
711.Bd -literal -offset indent
712\&.if COND \e{BODY
713BODY...\e}
714.Ed
715.Bd -literal -offset indent
716\&.if COND \e{\e
717BODY...
718\&.\e}
719.Ed
720.Pp
721COND is a conditional statement.
722Currently,
723.Xr mandoc 1
724supports the following subset of roff conditionals:
725.Bl -bullet
726.It
727If
728.Sq \&!
729is prefixed to COND, the condition is logically inverted.
730.It
731If the first character of COND is
732.Sq n
733.Pq nroff mode
734or
735.Sq o
736.Pq odd page ,
737COND evaluates to true.
738.It
739If the first character of COND is
740.Sq c
741.Pq character available ,
742.Sq d
743.Pq string defined ,
744.Sq e
745.Pq even page ,
746.Sq r
747.Pq register accessed ,
748or
749.Sq t
750.Pq troff mode ,
751COND evaluates to false.
752.It
753If COND starts with a parenthesis or with an optionally signed
754integer number, it is evaluated according to the rules of
755.Sx Numerical expressions
756explained below.
757It evaluates to true if the the result is positive,
758or to false if the result is zero or negative.
759.It
760Otherwise, the first character of COND is regarded as a delimiter
761and COND evaluates to true if the string extending from its first
762to its second occurrence is equal to the string extending from its
763second to its third occurrence.
764.It
765If COND cannot be parsed, it evaluates to false.
766.El
767.Pp
768If a conditional is false, its children are not processed, but are
769syntactically interpreted to preserve the integrity of the input
770document.
771Thus,
772.Pp
773.D1 \&.if t .ig
774.Pp
775will discard the
776.Sq \&.ig ,
777which may lead to interesting results, but
778.Pp
779.D1 \&.if t .if t \e{\e
780.Pp
781will continue to syntactically interpret to the block close of the final
782conditional.
783Sub-conditionals, in this case, obviously inherit the truth value of
784the parent.
785.Pp
786If the BODY section is begun by an escaped brace
787.Sq \e{ ,
788scope continues until the end of the input line containing the
789matching closing-brace escape sequence
790.Sq \e} .
791If the BODY is not enclosed in braces, scope continues until
792the end of the line.
793If the COND is followed by a BODY on the same line, whether after a
794brace or not, then requests and macros
795.Em must
796begin with a control character.
797It is generally more intuitive, in this case, to write
798.Bd -literal -offset indent
799\&.if COND \e{\e
800\&.foo
801bar
802\&.\e}
803.Ed
804.Pp
805than having the request or macro follow as
806.Pp
807.D1 \&.if COND \e{ .foo
808.Pp
809The scope of a conditional is always parsed, but only executed if the
810conditional evaluates to true.
811.Pp
812Note that the
813.Sq \e}
814is converted into a zero-width escape sequence if not passed as a
815standalone macro
816.Sq \&.\e} .
817For example,
818.Pp
819.D1 \&.Fl a \e} b
820.Pp
821will result in
822.Sq \e}
823being considered an argument of the
824.Sq \&Fl
825macro.
826.Ss \&ig
827Ignore input.
828Its syntax can be either
829.Bd -literal -offset indent
830.Pf . Cm \&ig
831.Ar ignored text
832\&..
833.Ed
834.Pp
835or
836.Bd -literal -offset indent
837.Pf . Cm \&ig Ar end
838.Ar ignored text
839.Pf . Ar end
840.Ed
841.Pp
842In the first case, input is ignored until a
843.Sq \&..
844request is encountered on its own line.
845In the second case, input is ignored until the specified
846.Sq Pf . Ar end
847macro is encountered.
848Do not use the escape character
849.Sq \e
850anywhere in the definition of
851.Ar end ;
852it would cause very strange behaviour.
853.Pp
854When the
855.Ar end
856macro is a roff request or a roff macro, like in
857.Pp
858.D1 \&.ig if
859.Pp
860the subsequent invocation of
861.Sx \&if
862will first terminate the
863.Ar ignored text ,
864then be invoked as usual.
865Otherwise, it only terminates the
866.Ar ignored text ,
867and arguments following it or the
868.Sq \&..
869request are discarded.
870.Ss \&ll
871Change the output line length.
872Its syntax is as follows:
873.Pp
874.D1 Pf . Cm \&ll Op Oo +|- Oc Ns Ar width
875.Pp
876If the
877.Ar width
878argument is omitted, the line length is reset to its previous value.
879The default setting for terminal output is 78n.
880If a sign is given, the line length is added to or subtracted from;
881otherwise, it is set to the provided value.
882Using this request in new manuals is discouraged for several reasons,
883among others because it overrides the
884.Xr mandoc 1
885.Fl O Cm width
886command line option.
887.Ss \&ne
888Declare the need for the specified minimum vertical space
889before the next trap or the bottom of the page.
890This line-scoped request is currently ignored.
891.Ss \&nh
892Turn off automatic hyphenation mode.
893This line-scoped request is currently ignored.
894.Ss \&nr
895Define or change a register.
896A register is an arbitrary string value that defines some sort of state,
897which influences parsing and/or formatting.
898Its syntax is as follows:
899.Pp
900.D1 Pf \. Cm \&nr Ar name Oo +|- Oc Ns Ar expression
901.Pp
902For the syntax of
903.Ar expression ,
904see
905.Sx Numerical expressions
906below.
907If it is prefixed by a sign, the register will be
908incremented or decremented instead of assigned to.
909.Pp
910The following register
911.Ar name
912is handled specially:
913.Bl -tag -width Ds
914.It Cm nS
915If set to a positive integer value, certain
916.Xr mdoc 7
917macros will behave in the same way as in the
918.Em SYNOPSIS
919section.
920If set to 0, these macros will behave in the same way as outside the
921.Em SYNOPSIS
922section, even when called within the
923.Em SYNOPSIS
924section itself.
925Note that starting a new
926.Xr mdoc 7
927section with the
928.Cm \&Sh
929macro will reset this register.
930.El
931.Ss \&ns
932Turn on no-space mode.
933This line-scoped request is intended to take no arguments.
934Currently, it is ignored including its arguments,
935and the number of arguments is not checked.
936.Ss \&ps
937Change point size.
938This line-scoped request is intended to take one numerical argument.
939Currently, it is ignored including its arguments,
940and the number of arguments is not checked.
941.Ss \&rm
942Remove a request, macro or string.
943Its syntax is as follows:
944.Pp
945.D1 Pf \. Cm \&rm Ar name
946.Ss \&rr
947Remove a register.
948Its syntax is as follows:
949.Pp
950.D1 Pf \. Cm \&rr Ar name
951.Ss \&so
952Include a source file.
953Its syntax is as follows:
954.Pp
955.D1 Pf \. Cm \&so Ar file
956.Pp
957The
958.Ar file
959will be read and its contents processed as input in place of the
960.Sq \&.so
961request line.
962To avoid inadvertent inclusion of unrelated files,
963.Xr mandoc 1
964only accepts relative paths not containing the strings
965.Qq ../
966and
967.Qq /.. .
968.Pp
969This request requires
970.Xr man 1
971to change to the right directory before calling
972.Xr mandoc 1 ,
973per convention to the root of the manual tree.
974Typical usage looks like:
975.Pp
976.Dl \&.so man3/Xcursor.3
977.Pp
978As the whole concept is rather fragile, the use of
979.Sx \&so
980is discouraged.
981Use
982.Xr ln 1
983instead.
984.Ss \&ta
985Set tab stops.
986This line-scoped request can take an arbitrary number of arguments.
987Currently, it is ignored including its arguments.
988.Ss \&tr
989Output character translation.
990Its syntax is as follows:
991.Pp
992.D1 Pf \. Cm \&tr Ar [ab]+
993.Pp
994Pairs of
995.Ar ab
996characters are replaced
997.Ar ( a
998for
999.Ar b ) .
1000Replacement (or origin) characters may also be character escapes; thus,
1001.Pp
1002.Dl tr \e(xx\e(yy
1003.Pp
1004replaces all invocations of \e(xx with \e(yy.
1005.Ss \&T&
1006Re-start a table layout, retaining the options of the prior table
1007invocation.
1008See
1009.Sx \&TS .
1010.Ss \&TE
1011End a table context.
1012See
1013.Sx \&TS .
1014.Ss \&TS
1015Begin a table, which formats input in aligned rows and columns.
1016See
1017.Xr tbl 7
1018for a description of the tbl language.
1019.Ss Numerical expressions
1020The
1021.Sx \&nr ,
1022.Sx \&if ,
1023and
1024.Sx \&ie
1025requests accept integer numerical expressions as arguments.
1026These are always evaluated using the C
1027.Vt int
1028type; integer overflow works the same way as in the C language.
1029Numbers consist of an arbitrary number of digits
1030.Sq 0
1031to
1032.Sq 9
1033prefixed by an optional sign
1034.Sq +
1035or
1036.Sq - .
1037.Pp
1038The following binary operators are implemented.
1039Unless otherwise stated, they behave as in the C language:
1040.Pp
1041.Bl -tag -width 2n -compact
1042.It Ic +
1043addition
1044.It Ic -
1045subtraction
1046.It Ic *
1047multiplication
1048.It Ic /
1049division
1050.It Ic %
1051remainder of division
1052.It Ic <
1053less than
1054.It Ic >
1055greater than
1056.It Ic ==
1057equal to
1058.It Ic =
1059equal to, same effect as
1060.Ic ==
1061(this differs from C)
1062.It Ic <=
1063less than or equal to
1064.It Ic >=
1065greater than or equal to
1066.It Ic <>
1067not equal to (corresponds to C
1068.Ic != ;
1069this one is of limited portability, it is supported by Heirloom roff,
1070but not by groff)
1071.It Ic &
1072logical and (corresponds to C
1073.Ic && )
1074.It Ic \&:
1075logical or (corresponds to C
1076.Ic \&|| )
1077.It Ic <?
1078minimum (not available in C)
1079.It Ic >?
1080maximum (not available in C)
1081.El
1082.Pp
1083There is no concept of precendence; evaluation proceeds from left to right,
1084except when subexpressions are enclosed in parantheses.
1085Inside parentheses, whitespace is ignored.
1086.Sh ESCAPE SEQUENCE REFERENCE
1087The
1088.Xr mandoc 1
1089.Nm
1090parser recognises the following escape sequences.
1091Note that the
1092.Nm
1093language defines more escape sequences not implemented in
1094.Xr mandoc 1 .
1095In
1096.Xr mdoc 7
1097and
1098.Xr man 7
1099documents, using escape sequences is discouraged except for those
1100described in the
1101.Sx LANGUAGE SYNTAX
1102section above.
1103.Pp
1104A backslash followed by any character not listed here
1105simply prints that character itself.
1106.Ss \e<newline>
1107A backslash at the end of an input line can be used to continue the
1108logical input line on the next physical input line, joining the text
1109on both lines together as if it were on a single input line.
1110.Ss \e<space>
1111The escape sequence backslash-space
1112.Pq Sq \e\ \&
1113is an unpaddable space-sized non-breaking space character; see
1114.Sx Whitespace .
1115.Ss \e\(dq
1116The rest of the input line is treated as
1117.Sx Comments .
1118.Ss \e%
1119Hyphenation allowed at this point of the word; ignored by
1120.Xr mandoc 1 .
1121.Ss \e&
1122Non-printing zero-width character; see
1123.Sx Whitespace .
1124.Ss \e\(aq
1125Acute accent special character; use
1126.Sq \e(aa
1127instead.
1128.Ss \e( Ns Ar cc
1129.Sx Special Characters
1130with two-letter names, see
1131.Xr mandoc_char 7 .
1132.Ss \e*[ Ns Ar name ]
1133Interpolate the string with the
1134.Ar name ;
1135see
1136.Sx Predefined Strings
1137and
1138.Sx ds .
1139For short names, there are variants
1140.No \e* Ns Ar c
1141and
1142.No \e*( Ns Ar cc .
1143.Ss \e-
1144Special character
1145.Dq mathematical minus sign .
1146.Ss \e[ Ns Ar name ]
1147.Sx Special Characters
1148with names of arbitrary length, see
1149.Xr mandoc_char 7 .
1150.Ss \e^
1151One-twelfth em half-narrow space character, effectively zero-width in
1152.Xr mandoc 1 .
1153.Ss \e`
1154Grave accent special character; use
1155.Sq \e(ga
1156instead.
1157.Ss \e{
1158Begin conditional input; see
1159.Sx if .
1160.Ss \e\(ba
1161One-sixth em narrow space character, effectively zero-width in
1162.Xr mandoc 1 .
1163.Ss \e}
1164End conditional input; see
1165.Sx if .
1166.Ss \e~
1167Paddable non-breaking space character.
1168.Ss \e0
1169Digit width space character.
1170.Ss \eA\(aq Ns Ar string Ns \(aq
1171Anchor definition; ignored by
1172.Xr mandoc 1 .
1173.Ss \eB\(aq Ns Ar string Ns \(aq
1174Interpolate
1175.Sq 1
1176if
1177.Ar string
1178conforms to the syntax of
1179.Sx Numerical expressions
1180explained above and
1181.Sq 0
1182otherwise.
1183.Ss \eb\(aq Ns Ar string Ns \(aq
1184Bracket building function; ignored by
1185.Xr mandoc 1 .
1186.Ss \eC\(aq Ns Ar name Ns \(aq
1187.Sx Special Characters
1188with names of arbitrary length.
1189.Ss \ec
1190Interrupt text processing to insert requests or macros; ignored by
1191.Xr mandoc 1 .
1192.Ss \eD\(aq Ns Ar string Ns \(aq
1193Draw graphics function; ignored by
1194.Xr mandoc 1 .
1195.Ss \ed
1196Move down by half a line; ignored by
1197.Xr mandoc 1 .
1198.Ss \ee
1199Backslash special character.
1200.Ss \eF[ Ns Ar name ]
1201Switch font family (groff extension); ignored by
1202.Xr mandoc 1 .
1203For short names, there are variants
1204.No \eF Ns Ar c
1205and
1206.No \eF( Ns Ar cc .
1207.Ss \ef[ Ns Ar name ]
1208Switch to the font
1209.Ar name ,
1210see
1211.Sx Text Decoration .
1212For short names, there are variants
1213.No \ef Ns Ar c
1214and
1215.No \ef( Ns Ar cc .
1216.Ss \eg[ Ns Ar name ]
1217Interpolate the format of a number register; ignored by
1218.Xr mandoc 1 .
1219For short names, there are variants
1220.No \eg Ns Ar c
1221and
1222.No \eg( Ns Ar cc .
1223.Ss \eH\(aq Ns Oo +|- Oc Ns Ar number Ns \(aq
1224Set the height of the current font; ignored by
1225.Xr mandoc 1 .
1226.Ss \eh\(aq Ns Ar number Ns \(aq
1227Horizontal motion; ignored by
1228.Xr mandoc 1 .
1229.Ss \ek[ Ns Ar name ]
1230Mark horizontal input place in register; ignored by
1231.Xr mandoc 1 .
1232For short names, there are variants
1233.No \ek Ns Ar c
1234and
1235.No \ek( Ns Ar cc .
1236.Ss \eL\(aq Ns Ar number Ns Oo Ar c Oc Ns \(aq
1237Vertical line drawing function; ignored by
1238.Xr mandoc 1 .
1239.Ss \el\(aq Ns Ar number Ns Oo Ar c Oc Ns \(aq
1240Horizontal line drawing function; ignored by
1241.Xr mandoc 1 .
1242.Ss \eM[ Ns Ar name ]
1243Set fill (background) color (groff extension); ignored by
1244.Xr mandoc 1 .
1245For short names, there are variants
1246.No \eM Ns Ar c
1247and
1248.No \eM( Ns Ar cc .
1249.Ss \em[ Ns Ar name ]
1250Set glyph drawing color (groff extension); ignored by
1251.Xr mandoc 1 .
1252For short names, there are variants
1253.No \em Ns Ar c
1254and
1255.No \em( Ns Ar cc .
1256.Ss \eN\(aq Ns Ar number Ns \(aq
1257Character
1258.Ar number
1259on the current font.
1260.Ss \en[ Ns Ar name ]
1261Interpolate the number register
1262.Ar name .
1263For short names, there are variants
1264.No \en Ns Ar c
1265and
1266.No \en( Ns Ar cc .
1267.Ss \eo\(aq Ns Ar string Ns \(aq
1268Overstrike
1269.Ar string ;
1270ignored by
1271.Xr mandoc 1 .
1272.Ss \eR\(aq Ns Ar name Oo +|- Oc Ns Ar number Ns \(aq
1273Set number register; ignored by
1274.Xr mandoc 1 .
1275.Ss \eS\(aq Ns Ar number Ns \(aq
1276Slant output; ignored by
1277.Xr mandoc 1 .
1278.Ss \es\(aq Ns Oo +|- Oc Ns Ar number Ns \(aq
1279Change point size; ignored by
1280.Xr mandoc 1 .
1281Alternative forms
1282.No \es Ns Oo +|- Oc Ns Ar n ,
1283.No \es Ns Oo +|- Oc Ns \(aq Ns Ar number Ns \(aq ,
1284.No \es Ns [ Oo +|- Oc Ns Ar number ] ,
1285and
1286.No \es Ns Oo +|- Oc Ns [ Ar number Ns ]
1287are also parsed and ignored.
1288.Ss \et
1289Horizontal tab; ignored by
1290.Xr mandoc 1 .
1291.Ss \eu
1292Move up by half a line; ignored by
1293.Xr mandoc 1 .
1294.Ss \eV[ Ns Ar name ]
1295Interpolate an environment variable; ignored by
1296.Xr mandoc 1 .
1297For short names, there are variants
1298.No \eV Ns Ar c
1299and
1300.No \eV( Ns Ar cc .
1301.Ss \ev\(aq Ns Ar number Ns \(aq
1302Vertical motion; ignored by
1303.Xr mandoc 1 .
1304.Ss \ew\(aq Ns Ar string Ns \(aq
1305Interpolate the width of the
1306.Ar string .
1307The
1308.Xr mandoc 1
1309implementation assumes that after expansion of user-defined strings, the
1310.Ar string
1311only contains normal characters, no escape sequences, and that each
1312character has a width of 24 basic units.
1313.Ss \eX\(aq Ns Ar string Ns \(aq
1314Output
1315.Ar string
1316as device control function; ignored in nroff mode and by
1317.Xr mandoc 1 .
1318.Ss \ex\(aq Ns Ar number Ns \(aq
1319Extra line space function; ignored by
1320.Xr mandoc 1 .
1321.Ss \eY[ Ns Ar name ]
1322Output a string as a device control function; ignored in nroff mode and by
1323.Xr mandoc 1 .
1324For short names, there are variants
1325.No \eY Ns Ar c
1326and
1327.No \eY( Ns Ar cc .
1328.Ss \eZ\(aq Ns Ar string Ns \(aq
1329Print
1330.Ar string
1331with zero width and height; ignored by
1332.Xr mandoc 1 .
1333.Ss \ez
1334Output the next character without advancing the cursor position;
1335approximated in
1336.Xr mandoc 1
1337by simply skipping the next character.
1338.Sh COMPATIBILITY
1339This section documents compatibility between mandoc and other
1340.Nm
1341implementations, at this time limited to GNU troff
1342.Pq Qq groff .
1343The term
1344.Qq historic groff
1345refers to groff version 1.15.
1346.Pp
1347.Bl -dash -compact
1348.It
1349In mandoc, the
1350.Sx \&EQ ,
1351.Sx \&TE ,
1352.Sx \&TS ,
1353and
1354.Sx \&T& ,
1355macros are considered regular macros.
1356In all other
1357.Nm
1358implementations, these are special macros that must be specified without
1359spacing between the control character (which must be a period) and the
1360macro name.
1361.It
1362The
1363.Cm nS
1364register is only compatible with OpenBSD's groff-1.15.
1365.It
1366Historic groff did not accept white-space before a custom
1367.Ar end
1368macro for the
1369.Sx \&ig
1370request.
1371.It
1372The
1373.Sx \&if
1374and family would print funny white-spaces with historic groff when
1375using the next-line syntax.
1376.El
1377.Sh SEE ALSO
1378.Xr mandoc 1 ,
1379.Xr eqn 7 ,
1380.Xr man 7 ,
1381.Xr mandoc_char 7 ,
1382.Xr mdoc 7 ,
1383.Xr tbl 7
1384.Rs
1385.%A Joseph F. Ossanna
1386.%A Brian W. Kernighan
1387.%I AT&T Bell Laboratories
1388.%T Troff User's Manual
1389.%R Computing Science Technical Report
1390.%N 54
1391.%C Murray Hill, New Jersey
1392.%D 1976 and 1992
1393.%U http://www.kohala.com/start/troff/cstr54.ps
1394.Re
1395.Rs
1396.%A Joseph F. Ossanna
1397.%A Brian W. Kernighan
1398.%A Gunnar Ritter
1399.%T Heirloom Documentation Tools Nroff/Troff User's Manual
1400.%D September 17, 2007
1401.%U http://heirloom.sourceforge.net/doctools/troff.pdf
1402.Re
1403.Sh HISTORY
1404The RUNOFF typesetting system, whose input forms the basis for
1405.Nm ,
1406was written in MAD and FAP for the CTSS operating system by Jerome E.
1407Saltzer in 1964.
1408Doug McIlroy rewrote it in BCPL in 1969, renaming it
1409.Nm .
1410Dennis M. Ritchie rewrote McIlroy's
1411.Nm
1412in PDP-11 assembly for
1413.At v1 ,
1414Joseph F. Ossanna improved roff and renamed it nroff
1415for
1416.At v2 ,
1417then ported nroff to C as troff, which Brian W. Kernighan released with
1418.At v7 .
1419In 1989, James Clarke re-implemented troff in C++, naming it groff.
1420.Sh AUTHORS
1421.An -nosplit
1422This
1423.Nm
1424reference was written by
1425.An Kristaps Dzonsons Aq Mt kristaps@bsd.lv
1426and
1427.An Ingo Schwarze Aq Mt schwarze@openbsd.org .
1428