1 .\" $Id: roff.7,v 1.27 2011/02/09 10:03:02 kristaps Exp $
3 .\" Copyright (c) 2010 Kristaps Dzonsons <kristaps@bsd.lv>
4 .\" Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
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.
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.
18 .Dd $Mdocdate: February 9 2011 $
23 .Nd roff language reference for mandoc
27 language is a general purpose text formatting language.
28 In particular, it serves as the basis for the
32 manual formatting macro languages.
33 This manual describes the subset of the
35 language accepted by the
39 Input lines beginning with the control characters
43 are parsed for requests and macros.
44 These define the document structure, change the processing state
45 and manipulate the formatting.
46 Some requests and macros also produce formatted output,
49 All other input lines provide free-form text to be printed;
50 the formatting of free-form text depends on the respective
54 documents may contain only graphable 7-bit ASCII characters, the space
55 character, and, in certain circumstances, the tab character.
56 To produce other characters in the output, use the escape sequences
61 A request or macro line consists of:
69 at the beginning of the line,
71 optionally an arbitrary amount of whitespace,
73 the name of the request or the macro, which is one word of arbitrary
74 length, terminated by whitespace,
76 and zero or more arguments delimited by whitespace.
79 Thus, the following request lines are all equivalent:
80 .Bd -literal -offset indent
86 Macros can be defined by the
89 When called, they follow the same syntax as requests, except that
90 macro arguments may optionally be quoted by enclosing them
91 in double quote characters
93 To be recognized as the beginning of a quoted argument, the opening
94 quote character must be preceded by a space character.
96 A quoted argument may contain whitespace, and pairs of double quote
99 resolve to single double quote characters.
100 A quoted argument extends to the next double quote character that is not
101 part of a pair, or to the end of the input line, whichever comes earlier.
102 Leaving out the terminating double quote character at the end of the line
104 For clarity, if more arguments follow on the same input line,
105 it is recommended to follow the terminating double quote character
106 by a space character; in case the next character after the terminating
107 double quote character is anything else, it is regarded as the beginning
108 of the next, unquoted argument.
110 Both in quoted and unquoted arguments, pairs of backslashes
112 resolve to single backslashes.
113 In unquoted arguments, space characters can alternatively be included
114 by preceding them with a backslash
116 but quoting is usually better for clarity.
117 .Sh REQUEST REFERENCE
121 parser recognizes the following requests.
124 language defines many more requests not implemented in
127 Set line adjustment mode.
128 This line-scoped request is intended to have one argument to select
129 normal, left, right, or center adjustment for subsequent text.
130 Currently, it is ignored including its arguments,
131 and the number of arguments is not checked.
133 Append to a macro definition.
134 The syntax of this request is the same as that of
136 It is currently ignored by
140 Append to a macro definition, specifying the macro name indirectly.
141 The syntax of this request is the same as that of
143 It is currently ignored by
147 Append to a macro definition, switching roff compatibility mode off
148 during macro execution.
149 The syntax of this request is the same as that of
151 It is currently ignored by
158 Its syntax can be either
159 .Bd -literal -offset indent
160 .Pf . Cm \&de Ar name
166 .Bd -literal -offset indent
167 .Pf . Cm \&de Ar name Ar end
172 Both forms define or redefine the macro
175 .Ar macro definition ,
176 which may consist of one or more input lines, including the newline
177 characters terminating each line, optionally containing calls to
181 macros or high-level macros like
185 macros, whichever applies to the document in question.
189 macro works in the same way as for
194 .Ar macro definition ,
195 and after that, it is also evaluated as a
199 macro, but not as a high-level macro.
201 The macro can be invoked later using the syntax
203 .D1 Pf . Ar name Op Ar argument Op Ar argument ...
205 Regarding argument parsing, see
209 The line invoking the macro will be replaced
210 in the input stream by the
211 .Ar macro definition ,
212 replacing all occurrences of
217 .Ar N Ns th Ar argument .
219 .Bd -literal -offset indent
221 \efI\e^\e\e$1\e^\efP\e\e$2
228 .D1 \efI\e^XtFree\e^\efP.
230 in the input stream, and thus in the output: \fI\^XtFree\^\fP.
232 Since macros and user-defined strings share a common string table,
235 clobbers the user-defined string
239 can also be printed using the
241 string interpolation syntax described below
243 but this is rarely useful because every macro definition contains at least
244 one explicit newline character.
246 In order to prevent endless recursion, both groff and
248 limit the stack depth for expanding macros and strings
249 to a large, but finite number.
250 Do not rely on the exact value of this limit.
254 macro, specifying the macro name indirectly.
255 The syntax of this request is the same as that of
257 It is currently ignored by
263 macro that will be executed with
265 compatibility mode switched off during macro execution.
266 This is a GNU extension not available in traditional
268 implementations and not even in older versions of groff.
273 compatibility mode at all, it handles this request as an alias for
276 Define a user-defined string.
277 Its syntax is as follows:
279 .D1 Pf . Cm \&ds Ar name Oo \(dq Oc Ns Ar string
285 arguments are space-separated.
288 begins with a double-quote character, that character will not be part
290 All remaining characters on the input line form the
292 including whitespace and double-quote characters, even trailing ones.
296 can be interpolated into subsequent text by using
297 .No \e* Ns Bq Ar name
300 of arbitrary length, or \e*(NN or \e*N if the length of
302 is two or one characters, respectively.
303 Interpolation can be prevented by escaping the leading backslash;
304 that is, an asterisk preceded by an even number of backslashes
305 does not trigger string interpolation.
307 Since user-defined strings and macros share a common string table,
314 used for defining a string can also be invoked as a macro,
315 in which case the following input line will be appended to the
317 forming a new input line passed to the
321 .Bd -literal -offset indent
332 Such abuse is of course strongly discouraged.
336 half of an if/else conditional.
337 Pops a result off the stack of conditional evaluations pushed by
339 and uses it as its conditional.
340 If no stack entries are present (e.g., due to no prior
343 then false is assumed.
344 The syntax of this request is similar to
346 except that the conditional is missing.
348 End an equation block.
352 Begin an equation block.
355 for a description of the equation language.
357 Set automatic hyphenation mode.
358 This line-scoped request is currently ignored.
362 half of an if/else conditional.
363 The result of the conditional is pushed into a stack used by subsequent
366 which may be separated by any intervening input (or not exist at all).
367 Its syntax is equivalent to
370 Begins a conditional.
371 Right now, the conditional evaluates to true
372 if and only if it starts with the letter
374 indicating processing in nroff style as opposed to troff style.
375 If a conditional is false, its children are not processed, but are
376 syntactically interpreted to preserve the integrity of the input
384 which may lead to interesting results, but
386 .D1 \&.if t .if t \e{\e
388 will continue to syntactically interpret to the block close of the final
390 Sub-conditionals, in this case, obviously inherit the truth value of
392 This request has the following syntax:
393 .Bd -literal -offset indent
398 .Bd -literal -offset indent
402 .Bd -literal -offset indent
407 .Bd -literal -offset indent
412 COND is a conditional statement.
413 roff allows for complicated conditionals; mandoc is much simpler.
414 At this time, mandoc supports only
423 All other invocations are read up to the next end of line or space and
426 If the BODY section is begun by an escaped brace
428 scope continues until a closing-brace escape sequence
430 If the BODY is not enclosed in braces, scope continues until
432 If the COND is followed by a BODY on the same line, whether after a
433 brace or not, then requests and macros
435 begin with a control character.
436 It is generally more intuitive, in this case, to write
437 .Bd -literal -offset indent
444 than having the request or macro follow as
446 .D1 \&.if COND \e{ .foo
448 The scope of a conditional is always parsed, but only executed if the
449 conditional evaluates to true.
451 Note that text following an
453 escape sequence is discarded.
454 Furthermore, if an explicit closing sequence
456 is specified in a free-form line, the entire line is accepted within the
457 scope of the prior request, not only the text preceding the close, with the
459 collapsing into a zero-width space.
462 Its syntax can be either
463 .Bd -literal -offset indent
470 .Bd -literal -offset indent
476 In the first case, input is ignored until a
478 request is encountered on its own line.
479 In the second case, input is ignored until the specified
481 macro is encountered.
482 Do not use the escape character
484 anywhere in the definition of
486 it would cause very strange behaviour.
490 macro is a roff request or a roff macro, like in
494 the subsequent invocation of
496 will first terminate the
498 then be invoked as usual.
499 Otherwise, it only terminates the
501 and arguments following it or the
503 request are discarded.
505 Declare the need for the specified minimum vertical space
506 before the next trap or the bottom of the page.
507 This line-scoped request is currently ignored.
509 Turn off automatic hyphenation mode.
510 This line-scoped request is currently ignored.
512 Remove a request, macro or string.
513 This request is intended to have one argument,
514 the name of the request, macro or string to be undefined.
515 Currently, it is ignored including its arguments,
516 and the number of arguments is not checked.
519 A register is an arbitrary string value that defines some sort of state,
520 which influences parsing and/or formatting.
521 Its syntax is as follows:
523 .D1 Pf \. Cm \&nr Ar name Ar value
527 may, at the moment, only be an integer.
528 So far, only the following register
533 If set to a positive integer value, certain
535 macros will behave in the same way as in the
538 If set to 0, these macros will behave in the same way as outside the
540 section, even when called within the
543 Note that starting a new
547 macro will reset this register.
550 Turn on no-space mode.
551 This line-scoped request is intended to take no arguments.
552 Currently, it is ignored including its arguments,
553 and the number of arguments is not checked.
556 This line-scoped request is intended to take one numerical argument.
557 Currently, it is ignored including its arguments,
558 and the number of arguments is not checked.
560 Include a source file.
561 Its syntax is as follows:
563 .D1 Pf \. Cm \&so Ar file
567 will be read and its contents processed as input in place of the
570 To avoid inadvertant inclusion of unrelated files,
572 only accepts relative paths not containing the strings
578 This line-scoped request can take an arbitrary number of arguments.
579 Currently, it is ignored including its arguments.
581 Output character translation.
582 This request is intended to have one argument,
583 consisting of an even number of characters.
584 Currently, it is ignored including its arguments,
585 and the number of arguments is not checked.
587 Re-start a table layout, retaining the options of the prior table
596 Begin a table, which formats input in aligned rows and columns.
599 for a description of the tbl language.
601 This section documents compatibility between mandoc and other other
603 implementations, at this time limited to GNU troff
607 refers to groff version 1.15.
617 macros are considered regular macros.
620 implementations, these are special macros that must be specified without
621 spacing between the control character (which must be a period) and the
626 register is only compatible with OpenBSD's groff-1.15.
628 Historic groff did not accept white-space before a custom
636 and family would print funny white-spaces with historic groff when
637 using the next-line syntax.
647 .%A Joseph F. Ossanna
648 .%A Brian W. Kernighan
649 .%I AT&T Bell Laboratories
650 .%T Troff User's Manual
651 .%R Computing Science Technical Report
653 .%C Murray Hill, New Jersey
655 .%U http://www.kohala.com/start/troff/cstr54.ps
658 .%A Joseph F. Ossanna
659 .%A Brian W. Kernighan
661 .%T Heirloom Documentation Tools Nroff/Troff User's Manual
662 .%D September 17, 2007
663 .%U http://heirloom.sourceforge.net/doctools/troff.pdf
666 The RUNOFF typesetting system was written in PL/1 for the CTSS
667 operating system by Jerome ("Jerry") E. Saltzer in 1961.
668 It was first used as the main documentation tool by Multics since 1963.
669 Robert ("Bob") H. Morris ported it to the GE-635 and called it
671 Doug McIlroy rewrote it in BCPL in 1969,
672 Joseph F. Ossanna rewrote it in PDP-11 assembly in 1973,
673 and Brian W. Kernighan rewrote it in C in 1975.
678 reference was written by
679 .An Kristaps Dzonsons Aq kristaps@bsd.lv
681 .An Ingo Schwarze Aq schwarze@openbsd.org .