1 .\" $Id: eqn.7,v 1.39 2020/01/10 11:55:04 schwarze Exp $
3 .\" Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
4 .\" Copyright (c) 2014 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 10 2020 $
23 .Nd eqn language reference for mandoc
27 language is an equation-formatting language.
36 of an equation, not its mathematical meaning.
37 This manual describes the
39 language accepted by the
41 utility, which corresponds to the Second Edition
47 An equation starts with an input line containing exactly the characters
49 may contain multiple input lines, and ends with an input line
50 containing exactly the characters
52 Equivalently, an equation can be given in the middle of a single
53 text input line by surrounding it with the equation delimiters
58 The equation grammar is as follows, where quoted strings are
59 case-sensitive literals in the input:
60 .Bd -literal -offset indent
63 | \(dq{\(dq eqn \(dq}\(dq
64 | \(dqdefine\(dq text text
65 | \(dqndefine\(dq text text
66 | \(dqtdefine\(dq text text
69 | \(dqset\(dq text text
74 | \(dqmatrix\(dq \(dq{\(dq [col \(dq{\(dq list \(dq}\(dq]* \(dq}\(dq
75 | pile \(dq{\(dq list \(dq}\(dq
77 | \(dqsize\(dq text box
78 | \(dqleft\(dq text eqn [\(dqright\(dq text]
79 col : \(dqlcol\(dq | \(dqrcol\(dq | \(dqccol\(dq | \(dqcol\(dq
80 text : [^space\e\(dq]+ | \e\(dq.*\e\(dq
81 pile : \(dqlpile\(dq | \(dqcpile\(dq | \(dqrpile\(dq | \(dqpile\(dq
82 pos : \(dqover\(dq | \(dqsup\(dq | \(dqsub\(dq | \(dqto\(dq | \(dqfrom\(dq
83 mark : \(dqdot\(dq | \(dqdotdot\(dq | \(dqhat\(dq | \(dqtilde\(dq | \(dqvec\(dq
84 | \(dqdyad\(dq | \(dqbar\(dq | \(dqunder\(dq
85 font : \(dqroman\(dq | \(dqitalic\(dq | \(dqbold\(dq | \(dqfat\(dq
87 | list \(dqabove\(dq eqn
91 White-space consists of the space, tab, circumflex, and tilde
93 It is required to delimit tokens consisting of alphabetic characters
94 and it is ignored at other places.
95 Braces and quotes also delimit tokens.
96 If within a quoted string, these space characters are retained.
97 Quoted strings are also not scanned for keywords, glyph names,
98 and expansion of definitions.
99 To print a literal quote character, it can be prepended with a
100 backslash or expressed with the \e(dq escape sequence.
102 Subequations can be enclosed in braces to pass them as arguments
103 to operation keywords, overriding standard operation precedence.
104 Braces can be nested.
105 To set a brace verbatim, it needs to be enclosed in quotes.
107 The following text terms are translated into a rendered glyph, if
108 available: alpha, beta, chi, delta, epsilon, eta, gamma, iota, kappa,
109 lambda, mu, nu, omega, omicron, phi, pi, psi, rho, sigma, tau, theta,
110 upsilon, xi, zeta, DELTA, GAMMA, LAMBDA, OMEGA, PHI, PI, PSI, SIGMA,
111 THETA, UPSILON, XI, inter (intersection), union (union), prod (product),
112 int (integral), sum (summation), grad (gradient), del (vector
113 differential), times (multiply), cdot (center-dot), nothing (zero-width
114 space), approx (approximately equals), prime (prime), half (one-half),
115 partial (partial differential), inf (infinity), >> (much greater), <<
116 (much less), <\- (left arrow), \-> (right arrow), +\- (plus-minus), !=
117 (not equal), == (equivalence), <= (less-than-equal), and >=
119 The character escape sequences documented in
123 The following control statements are available:
126 Replace all occurrences of a key with a value.
127 Its syntax is as follows:
129 .D1 Cm define Ar key cvalc
131 The first character of the value string,
133 is used as the delimiter for the value
135 This allows for arbitrary enclosure of terms (not just quotes), such as
137 .D1 Cm define Ar foo \(aqbar baz\(aq
138 .D1 Cm define Ar foo cbar bazc
140 It is an error to have an empty
146 causes errors in some
148 implementations and should not be considered portable.
149 It is not expanded for replacements.
150 Definitions may refer to other definitions; these are evaluated
151 recursively when text replacement occurs and not when the definition is
154 Definitions can create arbitrary strings, for example, the following is
155 a legal construction.
156 .Bd -literal -offset indent
157 define foo \(aqdefine\(aq
161 Self-referencing definitions will raise an error.
164 statement is a synonym for
170 This statement takes a string argument consisting of two bytes,
171 to be used as the opening and closing delimiters for equations
172 in the middle of text input lines.
173 Conventionally, the dollar sign is used for both delimiters,
175 .Bd -literal -offset indent
179 An equation like $sin pi = 0$ can now be entered
180 in the middle of a text input line.
183 The special statement
185 temporarily disables previously declared delimiters and
189 Set the default font of subsequent output.
190 Its syntax is as follows:
194 In mandoc, this value is discarded.
196 Set the default size of subsequent output.
197 Its syntax is as follows:
199 .D1 Cm gsize Oo +|\- Oc Ns Ar size
203 value should be an integer.
204 If prepended by a sign,
205 the font size is changed relative to the current size.
207 Set an equation mode.
208 In mandoc, both arguments are thrown away.
209 Its syntax is as follows:
211 .D1 Cm set Ar key val
217 are not expanded for replacements.
218 This statement is a GNU extension.
220 Unset a previously-defined key.
221 Its syntax is as follows:
225 Once invoked, the definition for
230 is not expanded for replacements.
231 This statement is a GNU extension.
234 Operation keywords have the following semantics:
240 Draw a line over the preceding box.
242 Set the following box using bold font.
251 but with slightly increased vertical spacing.
253 Set a single dot over the preceding box.
255 Set two dots (dieresis) over the preceding box.
257 Set a dyad symbol (left-right arrow) over the preceding box.
262 Set the second argument using the font specified by the first argument;
263 currently not recognized by the
268 Set the following box below the preceding box,
269 using a slightly smaller font.
270 Used for sums, integrals, limits, and the like.
272 Set a hat (circumflex) over the preceding box.
274 Set the following box using italic font.
281 Set the first argument as a big left delimiter before the second argument.
282 As an optional third argument,
285 In that case, the fourth argument is set as a big right delimiter after
290 but subequations are left-justified.
292 Followed by a list of columns enclosed in braces.
293 All columns need to have the same number of subequations.
294 The columns are set as a matrix.
295 The difference compared to multiple subsequent
297 operators is that in a
299 corresponding subequations in all columns line up horizontally,
302 does vertical spacing independently.
305 The preceding box is the numerator, the following box is the denominator.
307 Followed by a list of subequations enclosed in braces,
308 the subequations being separated by
311 Sets the subequations one above the other, each of them centered.
312 Typically used to represent vectors in coordinate representation.
322 cannot be used without
324 To set a big right delimiter without a big left delimiter, the following
325 construction can be used:
327 .D1 Cm left No \(dq\(dq Ar box Cm right Ar delimiter
329 Set the following box using the default font.
333 but subequations are right-justified.
335 Set the second argument with the font size specified by the first
336 argument; currently ignored by
338 By prepending a plus or minus sign to the first argument,
339 the font size can be selected relative to the current size.
341 Set the square root of the following box.
343 Set the following box as a subscript to the preceding box.
345 Set the following box as a superscript to the preceding box.
346 As a special case, if a
348 clause immediately follows a
352 .D1 Ar mainbox Cm sub Ar subbox Cm sup Ar supbox
354 both are set with respect to the same
361 Set a tilde over the preceding box.
363 Set the following box above the preceding box,
364 using a slightly smaller font.
365 Used for sums and integrals and the like.
366 As a special case, if a
368 clause immediately follows a
372 .D1 Ar mainbox Cm from Ar frombox Cm to Ar tobox
374 both are set below and above the same
377 Underline the preceding box.
379 Set a vector symbol (right arrow) over the preceding box.
382 The binary operations
388 group to the right, that is,
390 .D1 Ar mainbox Cm sup Ar supbox Cm sub Ar subbox
394 .D1 Ar mainbox Cm sup Brq Ar supbox Cm sub Ar subbox
398 .D1 Bro Ar mainbox Cm sup Ar supbox Brc Cm sub Ar subbox .
404 In the following list, earlier operations bind more tightly than
435 This section documents the compatibility of mandoc
439 implementation (including GNU troff).
445 is interpreted as a literal quote in troff.
446 In mandoc, this is interpreted as a comment.
448 In troff, The circumflex and tilde white-space symbols map to
450 In mandoc, these characters are synonyms for the space character.
452 The troff implementation of
454 allows for equation alignment with the
459 mandoc discards these tokens.
466 commands are also ignored.
475 .%A Brian W. Kernighan
476 .%A Lorinda L. Cherry
477 .%T System for Typesetting Mathematics
478 .%J Communications of the ACM
484 .%A Brian W. Kernighan
485 .%A Lorinda L. Cherry
486 .%T Typesetting Mathematics, User's Guide
490 .%A Brian W. Kernighan
491 .%A Lorinda L. Cherry
492 .%T Typesetting Mathematics, User's Guide (Second Edition)
496 The eqn utility, a preprocessor for troff, was originally written by
497 Brian W. Kernighan and Lorinda L. Cherry in 1975.
498 The GNU reimplementation of eqn, part of the GNU troff package, was
499 released in 1989 by James Clark.
506 reference was written by
507 .An Kristaps Dzonsons Aq Mt kristaps@bsd.lv .