1 .\" $Id: roff.7,v 1.23 2011/01/04 23:32:21 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: January 4 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
65 A request or macro line consists of:
73 at the beginning of the line,
75 optionally an arbitrary amount of whitespace,
77 the name of the request or the macro, which is one word of arbitrary
78 length, terminated by whitespace,
80 and zero or more arguments delimited by whitespace.
83 Thus, the following request lines are all equivalent:
84 .Bd -literal -offset indent
93 parser recognizes the following requests.
96 language defines many more requests not implemented in
99 Set line adjustment mode.
100 This line-scoped request is intended to have one argument to select
101 normal, left, right, or center adjustment for subsequent text.
102 Currently, it is ignored including its arguments,
103 and the number of arguments is not checked.
105 Append to a macro definition.
106 The syntax of this request is the same as that of
108 It is currently ignored by
112 Append to a macro definition, specifying the macro name indirectly.
113 The syntax of this request is the same as that of
115 It is currently ignored by
119 Append to a macro definition, switching roff compatibility mode off
120 during macro execution.
121 The syntax of this request is the same as that of
123 It is currently ignored by
130 Its syntax can be either
131 .Bd -literal -offset indent
132 .Pf . Cm \&de Ar name
138 .Bd -literal -offset indent
139 .Pf . Cm \&de Ar name Ar end
144 Both forms define or redefine the macro
147 .Ar macro definition ,
148 which may consist of one or more input lines, including the newline
149 characters terminating each line, optionally containing calls to
153 macros or high-level macros like
157 macros, whichever applies to the document in question.
161 macro works in the same way as for
166 .Ar macro definition ,
167 and after that, it is also evaluated as a
171 macro, but not as a high-level macro.
173 The macro can be invoked later using the syntax
175 .D1 Pf . Ar name Op Ar argument Op Ar argument ...
177 Arguments are separated by blank characters and can be quoted
180 to allow inclusion of blank characters into arguments.
181 To include the double-quote character into a quoted argument,
182 escape it from ending the argument by doubling it.
184 The line invoking the macro will be replaced
185 in the input stream by the
186 .Ar macro definition ,
187 replacing all occurrences of
192 .Ar N Ns th Ar argument .
194 .Bd -literal -offset indent
196 \efI\e^\e\e$1\e^\efP\e\e$2
203 .D1 \efI\e^XtFree\e^\efP.
205 in the input stream, and thus in the output: \fI\^XtFree\^\fP.
207 Since macros and user-defined strings share a common string table,
210 clobbers the user-defined string
214 can also be printed using the
216 string interpolation syntax described below
218 but this is rarely useful because every macro definition contains at least
219 one explicit newline character.
221 In order to prevent endless recursion, both groff and
223 limit the stack depth for expanding macros and strings
224 to a large, but finite number.
225 Do not rely on the exact value of this limit.
229 macro, specifying the macro name indirectly.
230 The syntax of this request is the same as that of
232 It is currently ignored by
238 macro that will be executed with
240 compatibility mode switched off during macro execution.
241 This is a GNU extension not available in traditional
243 implementations and not even in older versions of groff.
248 compatibility mode at all, it handles this request as an alias for
251 Define a user-defined string.
252 Its syntax is as follows:
254 .D1 Pf . Cm \&ds Ar name Oo \(dq Oc Ns Ar string
260 arguments are space-separated.
263 begins with a double-quote character, that character will not be part
265 All remaining characters on the input line form the
267 including whitespace and double-quote characters, even trailing ones.
271 can be interpolated into subsequent text by using
272 .No \e* Ns Bq Ar name
275 of arbitrary length, or \e*(NN or \e*N if the length of
277 is two or one characters, respectively.
278 Interpolation can be prevented by escaping the leading backslash;
279 that is, an asterisk preceded by an even number of backslashes
280 does not trigger string interpolation.
282 Since user-defined strings and macros share a common string table,
289 used for defining a string can also be invoked as a macro,
290 in which case the following input line will be appended to the
292 forming a new input line passed to the
296 .Bd -literal -offset indent
307 Such abuse is of course strongly discouraged.
311 half of an if/else conditional.
312 Pops a result off the stack of conditional evaluations pushed by
314 and uses it as its conditional.
315 If no stack entries are present (e.g., due to no prior
318 then false is assumed.
319 The syntax of this request is similar to
321 except that the conditional is missing.
323 Set automatic hyphenation mode.
324 This line-scoped request is currently ignored.
328 half of an if/else conditional.
329 The result of the conditional is pushed into a stack used by subsequent
332 which may be separated by any intervening input (or not exist at all).
333 Its syntax is equivalent to
336 Begins a conditional.
337 Right now, the conditional evaluates to true
338 if and only if it starts with the letter
340 indicating processing in nroff style as opposed to troff style.
341 If a conditional is false, its children are not processed, but are
342 syntactically interpreted to preserve the integrity of the input
350 which may lead to interesting results, but
352 .D1 \&.if t .if t \e{\e
354 will continue to syntactically interpret to the block close of the final
356 Sub-conditionals, in this case, obviously inherit the truth value of
358 This request has the following syntax:
359 .Bd -literal -offset indent
364 .Bd -literal -offset indent
368 .Bd -literal -offset indent
373 .Bd -literal -offset indent
378 COND is a conditional statement.
379 roff allows for complicated conditionals; mandoc is much simpler.
380 At this time, mandoc supports only
389 All other invocations are read up to the next end of line or space and
392 If the BODY section is begun by an escaped brace
394 scope continues until a closing-brace escape sequence
396 If the BODY is not enclosed in braces, scope continues until
398 If the COND is followed by a BODY on the same line, whether after a
399 brace or not, then requests and macros
401 begin with a control character.
402 It is generally more intuitive, in this case, to write
403 .Bd -literal -offset indent
410 than having the request or macro follow as
412 .D1 \&.if COND \e{ .foo
414 The scope of a conditional is always parsed, but only executed if the
415 conditional evaluates to true.
417 Note that text following an
419 escape sequence is discarded.
420 Furthermore, if an explicit closing sequence
422 is specified in a free-form line, the entire line is accepted within the
423 scope of the prior request, not only the text preceding the close, with the
425 collapsing into a zero-width space.
428 Its syntax can be either
429 .Bd -literal -offset indent
436 .Bd -literal -offset indent
442 In the first case, input is ignored until a
444 request is encountered on its own line.
445 In the second case, input is ignored until the specified
447 macro is encountered.
448 Do not use the escape character
450 anywhere in the definition of
452 it would cause very strange behaviour.
456 macro is a roff request or a roff macro, like in
460 the subsequent invocation of
462 will first terminate the
464 then be invoked as usual.
465 Otherwise, it only terminates the
467 and arguments following it or the
469 request are discarded.
471 Declare the need for the specified minimum vertical space
472 before the next trap or the bottom of the page.
473 This line-scoped request is currently ignored.
475 Turn off automatic hyphenation mode.
476 This line-scoped request is currently ignored.
478 Remove a request, macro or string.
479 This request is intended to have one argument,
480 the name of the request, macro or string to be undefined.
481 Currently, it is ignored including its arguments,
482 and the number of arguments is not checked.
485 A register is an arbitrary string value that defines some sort of state,
486 which influences parsing and/or formatting.
487 Its syntax is as follows:
489 .D1 Pf \. Cm \&nr Ar name Ar value
493 may, at the moment, only be an integer.
494 So far, only the following register
499 If set to a positive integer value, certain
501 macros will behave in the same way as in the
504 If set to 0, these macros will behave in the same way as outside the
506 section, even when called within the
509 Note that starting a new
513 macro will reset this register.
516 Include a source file.
517 Its syntax is as follows:
519 .D1 Pf \. Cm \&so Ar file
523 will be read and its contents processed as input in place of the
526 To avoid inadvertant inclusion of unrelated files,
528 only accepts relative paths not containing the strings
533 Output character translation.
534 This request is intended to have one argument,
535 consisting of an even number of characters.
536 Currently, it is ignored including its arguments,
537 and the number of arguments is not checked.
539 Re-start a table layout, retaining the options of the prior table
548 Begin a table, which formats input in aligned rows and columns.
551 for a description of the tbl language.
553 This section documents compatibility between mandoc and other other
555 implementations, at this time limited to GNU troff
559 refers to groff version 1.15.
565 register is only compatible with OpenBSD's groff-1.15.
567 Historic groff did not accept white-space before a custom
575 and family would print funny white-spaces with historic groff when
576 using the next-line syntax.
585 .%A Joseph F. Ossanna
586 .%A Brian W. Kernighan
587 .%I AT&T Bell Laboratories
588 .%T Troff User's Manual
589 .%R Computing Science Technical Report
591 .%C Murray Hill, New Jersey
593 .%U http://www.kohala.com/start/troff/cstr54.ps
596 .%A Joseph F. Ossanna
597 .%A Brian W. Kernighan
599 .%T Heirloom Documentation Tools Nroff/Troff User's Manual
600 .%D September 17, 2007
601 .%U http://heirloom.sourceforge.net/doctools/troff.pdf
604 The RUNOFF typesetting system was written in PL/1 for the CTSS
605 operating system by Jerome ("Jerry") E. Saltzer in 1961.
606 It was first used as the main documentation tool by Multics since 1963.
607 Robert ("Bob") H. Morris ported it to the GE-635 and called it
609 Doug McIlroy rewrote it in BCPL in 1969,
610 Joseph F. Ossanna rewrote it in PDP-11 assembly in 1973,
611 and Brian W. Kernighan rewrote it in C in 1975.
616 reference was written by
617 .An Kristaps Dzonsons Aq kristaps@bsd.lv
619 .An Ingo Schwarze Aq schwarze@openbsd.org .