1 .\" $Id: eqn.7,v 1.35 2015/03/30 16:06:14 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: March 30 2015 $
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
51 documents are enclosed by the standalone
56 Equations are multi-line blocks consisting of formulas and control
58 .Sh EQUATION STRUCTURE
59 Each equation is bracketed by
65 these are not the same as
67 macros, and may only be invoked as
70 The equation grammar is as follows, where quoted strings are
71 case-sensitive literals in the input:
72 .Bd -literal -offset indent
75 | \(dq{\(dq eqn \(dq}\(dq
76 | \(dqdefine\(dq text text
77 | \(dqndefine\(dq text text
78 | \(dqtdefine\(dq text text
81 | \(dqset\(dq text text
86 | \(dqmatrix\(dq \(dq{\(dq [col \(dq{\(dq list \(dq}\(dq ]*
87 | pile \(dq{\(dq list \(dq}\(dq
89 | \(dqsize\(dq text box
90 | \(dqleft\(dq text eqn [\(dqright\(dq text]
91 col : \(dqlcol\(dq | \(dqrcol\(dq | \(dqccol\(dq | \(dqcol\(dq
92 text : [^space\e\(dq]+ | \e\(dq.*\e\(dq
93 pile : \(dqlpile\(dq | \(dqcpile\(dq | \(dqrpile\(dq | \(dqpile\(dq
94 pos : \(dqover\(dq | \(dqsup\(dq | \(dqsub\(dq | \(dqto\(dq | \(dqfrom\(dq
95 mark : \(dqdot\(dq | \(dqdotdot\(dq | \(dqhat\(dq | \(dqtilde\(dq | \(dqvec\(dq
96 | \(dqdyad\(dq | \(dqbar\(dq | \(dqunder\(dq
97 font : \(dqroman\(dq | \(dqitalic\(dq | \(dqbold\(dq | \(dqfat\(dq
99 | list \(dqabove\(dq eqn
103 White-space consists of the space, tab, circumflex, and tilde
105 It is required to delimit tokens consisting of alphabetic characters
106 and it is ignored at other places.
107 Braces and quotes also delimit tokens.
108 If within a quoted string, these space characters are retained.
109 Quoted strings are also not scanned for keywords, glyph names,
110 and expansion of definitions.
111 To print a literal quote character, it can be prepended with a
112 backslash or expressed with the \e(dq escape sequence.
114 Subequations can be enclosed in braces to pass them as arguments
115 to operation keywords, overriding standard operation precedence.
116 Braces can be nested.
117 To set a brace verbatim, it needs to be enclosed in quotes.
119 The following text terms are translated into a rendered glyph, if
120 available: alpha, beta, chi, delta, epsilon, eta, gamma, iota, kappa,
121 lambda, mu, nu, omega, omicron, phi, pi, psi, rho, sigma, tau, theta,
122 upsilon, xi, zeta, DELTA, GAMMA, LAMBDA, OMEGA, PHI, PI, PSI, SIGMA,
123 THETA, UPSILON, XI, inter (intersection), union (union), prod (product),
124 int (integral), sum (summation), grad (gradient), del (vector
125 differential), times (multiply), cdot (center-dot), nothing (zero-width
126 space), approx (approximately equals), prime (prime), half (one-half),
127 partial (partial differential), inf (infinity), >> (much greater), <<
128 (much less), \-> (left arrow), <\- (right arrow), +\- (plus-minus), !=
129 (not equal), == (equivalence), <= (less-than-equal), and >=
131 The character escape sequences documented in
135 The following control statements are available:
138 Replace all occurrences of a key with a value.
139 Its syntax is as follows:
141 .D1 Cm define Ar key cvalc
143 The first character of the value string,
145 is used as the delimiter for the value
147 This allows for arbitrary enclosure of terms (not just quotes), such as
149 .D1 Cm define Ar foo \(aqbar baz\(aq
150 .D1 Cm define Ar foo cbar bazc
152 It is an error to have an empty
158 causes errors in some
160 implementations and should not be considered portable.
161 It is not expanded for replacements.
162 Definitions may refer to other definitions; these are evaluated
163 recursively when text replacement occurs and not when the definition is
166 Definitions can create arbitrary strings, for example, the following is
167 a legal construction.
168 .Bd -literal -offset indent
169 define foo \(aqdefine\(aq
173 Self-referencing definitions will raise an error.
176 statement is a synonym for
182 Set the default font of subsequent output.
183 Its syntax is as follows:
187 In mandoc, this value is discarded.
189 Set the default size of subsequent output.
190 Its syntax is as follows:
192 .D1 Cm gsize Oo +|\- Oc Ns Ar size
196 value should be an integer.
197 If prepended by a sign,
198 the font size is changed relative to the current size.
200 Set an equation mode.
201 In mandoc, both arguments are thrown away.
202 Its syntax is as follows:
204 .D1 Cm set Ar key val
210 are not expanded for replacements.
211 This statement is a GNU extension.
213 Unset a previously-defined key.
214 Its syntax is as follows:
218 Once invoked, the definition for
223 is not expanded for replacements.
224 This statement is a GNU extension.
227 Operation keywords have the following semantics:
233 Draw a line over the preceding box.
235 Set the following box using bold font.
244 but with slightly increased vertical spacing.
246 Set a single dot over the preceding box.
248 Set two dots (dieresis) over the preceding box.
250 Set a dyad symbol (left-right arrow) over the preceding box.
255 Set the second argument using the font specified by the first argument;
256 currently not recognized by the
261 Set the following box below the preceding box,
262 using a slightly smaller font.
263 Used for sums, integrals, limits, and the like.
265 Set a hat (circumflex) over the preceding box.
267 Set the following box using italic font.
274 Set the first argument as a big left delimiter before the second argument.
275 As an optional third argument,
278 In that case, the fourth argument is set as a big right delimiter after
283 but subequations are left-justified.
285 Followed by a list of columns enclosed in braces.
286 All columns need to have the same number of subequations.
287 The columns are set as a matrix.
288 The difference compared to multiple subsequent
290 operators is that in a
292 corresponding subequations in all columns line up horizontally,
295 does vertical spacing independently.
298 The preceding box is the numerator, the following box is the denominator.
300 Followed by a list of subequations enclosed in braces,
301 the subequations being separated by
304 Sets the subequations one above the other, each of them centered.
305 Typically used to represent vectors in coordinate representation.
315 cannot be used without
317 To set a big right delimiter without a big left delimiter, the following
318 construction can be used:
320 .D1 Cm left No \(dq\(dq Ar box Cm right Ar delimiter
322 Set the following box using the default font.
326 but subequations are right-justified.
328 Set the second argument with the font size specified by the first
329 argument; currently ignored by
331 By prepending a plus or minus sign to the first argument,
332 the font size can be selected relative to the current size.
334 Set the square root of the following box.
336 Set the following box as a subscript to the preceding box.
338 Set the following box as a superscript to the preceding box.
339 As a special case, if a
341 clause immediately follows a
345 .D1 Ar mainbox Cm sub Ar subbox Cm sup Ar supbox
347 both are set with respect to the same
354 Set a tilde over the preceding box.
356 Set the following box above the preceding box,
357 using a slightly smaller font.
358 Used for sums and integrals and the like.
359 As a special case, if a
361 clause immediately follows a
365 .D1 Ar mainbox Cm from Ar frombox Cm to Ar tobox
367 both are set below and above the same
370 Underline the preceding box.
372 Set a vector symbol (right arrow) over the preceding box.
375 The binary operations
381 group to the right, that is,
383 .D1 Ar mainbox Cm sup Ar supbox Cm sub Ar subbox
387 .D1 Ar mainbox Cm sup Brq Ar supbox Cm sub Ar subbox
391 .D1 Bro Ar mainbox Cm sup Ar supbox Brc Cm sub Ar subbox .
397 In the following list, earlier operations bind more tightly than
428 This section documents the compatibility of mandoc
432 implementation (including GNU troff).
438 is interpreted as a literal quote in troff.
439 In mandoc, this is interpreted as a comment.
441 In troff, The circumflex and tilde white-space symbols map to
443 In mandoc, these characters are synonyms for the space character.
445 The troff implementation of
447 allows for equation alignment with the
452 mandoc discards these tokens.
459 commands are also ignored.
468 .%A Brian W. Kernighan
469 .%A Lorinda L. Cherry
470 .%T System for Typesetting Mathematics
471 .%J Communications of the ACM
477 .%A Brian W. Kernighan
478 .%A Lorinda L. Cherry
479 .%T Typesetting Mathematics, User's Guide
483 .%A Brian W. Kernighan
484 .%A Lorinda L. Cherry
485 .%T Typesetting Mathematics, User's Guide (Second Edition)
489 The eqn utility, a preprocessor for troff, was originally written by
490 Brian W. Kernighan and Lorinda L. Cherry in 1975.
491 The GNU reimplementation of eqn, part of the GNU troff package, was
492 released in 1989 by James Clark.
499 reference was written by
500 .An Kristaps Dzonsons Aq Mt kristaps@bsd.lv .