1 EQN(5) Standards, Environments, and Macros EQN(5)
2
3 NAME
4 eqn - eqn language reference for mandoc
5
6 DESCRIPTION
7 The eqn language is an equation-formatting language. It is used within
8 mdoc(5) and man(5) UNIX manual pages. It describes the structure of an
9 equation, not its mathematical meaning. This manual describes the eqn
10 language accepted by the mandoc(1) utility, which corresponds to the
11 Second Edition eqn specification (see SEE ALSO for references).
12
13 Equations within mdoc(5) or man(5) documents are enclosed by the
14 standalone `.EQ' and `.EN' tags. Equations are multi-line blocks
15 consisting of formulas and control statements.
16
17 EQUATION STRUCTURE
18 Each equation is bracketed by `.EQ' and `.EN' strings. Note: these are
19 not the same as mandoc_roff(5) macros, and may only be invoked as `.EQ'.
20
21 The equation grammar is as follows, where quoted strings are case-
22 sensitive literals in the input:
23
24 eqn : box | eqn box
25 box : text
26 | "{" eqn "}"
27 | "define" text text
28 | "ndefine" text text
29 | "tdefine" text text
30 | "gfont" text
31 | "gsize" text
32 | "set" text text
33 | "undef" text
34 | "sqrt" box
35 | box pos box
36 | box mark
37 | "matrix" "{" [col "{" list "}"]* "}"
38 | pile "{" list "}"
39 | font box
40 | "size" text box
41 | "left" text eqn ["right" text]
42 col : "lcol" | "rcol" | "ccol" | "col"
43 text : [^space\"]+ | \".*\"
44 pile : "lpile" | "cpile" | "rpile" | "pile"
45 pos : "over" | "sup" | "sub" | "to" | "from"
46 mark : "dot" | "dotdot" | "hat" | "tilde" | "vec"
47 | "dyad" | "bar" | "under"
48 font : "roman" | "italic" | "bold" | "fat"
49 list : eqn
50 | list "above" eqn
51 space : [\^~ \t]
52
53 White-space consists of the space, tab, circumflex, and tilde characters.
54 It is required to delimit tokens consisting of alphabetic characters and
55 it is ignored at other places. Braces and quotes also delimit tokens.
56 If within a quoted string, these space characters are retained. Quoted
57 strings are also not scanned for keywords, glyph names, and expansion of
58 definitions. To print a literal quote character, it can be prepended
59 with a backslash or expressed with the \(dq escape sequence.
60
61 Subequations can be enclosed in braces to pass them as arguments to
62 operation keywords, overriding standard operation precedence. Braces can
63 be nested. To set a brace verbatim, it needs to be enclosed in quotes.
64
65 The following text terms are translated into a rendered glyph, if
66 available: alpha, beta, chi, delta, epsilon, eta, gamma, iota, kappa,
67 lambda, mu, nu, omega, omicron, phi, pi, psi, rho, sigma, tau, theta,
68 upsilon, xi, zeta, DELTA, GAMMA, LAMBDA, OMEGA, PHI, PI, PSI, SIGMA,
69 THETA, UPSILON, XI, inter (intersection), union (union), prod (product),
70 int (integral), sum (summation), grad (gradient), del (vector
71 differential), times (multiply), cdot (center-dot), nothing (zero-width
72 space), approx (approximately equals), prime (prime), half (one-half),
73 partial (partial differential), inf (infinity), >> (much greater), <<
74 (much less), <- (left arrow), -> (right arrow), +- (plus-minus), != (not
75 equal), == (equivalence), <= (less-than-equal), and >= (more-than-equal).
76 The character escape sequences documented in mandoc_char(5) can be used,
77 too.
78
79 The following control statements are available:
80
81 define Replace all occurrences of a key with a value. Its syntax is as
82 follows:
83
84 define key cvalc
85
86 The first character of the value string, c, is used as the
87 delimiter for the value val. This allows for arbitrary enclosure
88 of terms (not just quotes), such as
89
90 define foo 'bar baz'
91 define foo cbar bazc
92
93 It is an error to have an empty key or val. Note that a quoted
94 key causes errors in some eqn implementations and should not be
95 considered portable. It is not expanded for replacements.
96 Definitions may refer to other definitions; these are evaluated
97 recursively when text replacement occurs and not when the
98 definition is created.
99
100 Definitions can create arbitrary strings, for example, the
101 following is a legal construction.
102
103 define foo 'define'
104 foo bar 'baz'
105
106 Self-referencing definitions will raise an error. The ndefine
107 statement is a synonym for define, while tdefine is discarded.
108
109 gfont Set the default font of subsequent output. Its syntax is as
110 follows:
111
112 gfont font
113
114 In mandoc, this value is discarded.
115
116 gsize Set the default size of subsequent output. Its syntax is as
117 follows:
118
119 gsize [+|-]size
120
121 The size value should be an integer. If prepended by a sign, the
122 font size is changed relative to the current size.
123
124 set Set an equation mode. In mandoc, both arguments are thrown away.
125 Its syntax is as follows:
126
127 set key val
128
129 The key and val are not expanded for replacements. This
130 statement is a GNU extension.
131
132 undef Unset a previously-defined key. Its syntax is as follows:
133
134 define key
135
136 Once invoked, the definition for key is discarded. The key is
137 not expanded for replacements. This statement is a GNU
138 extension.
139
140 Operation keywords have the following semantics:
141
142 above See pile.
143
144 bar Draw a line over the preceding box.
145
146 bold Set the following box using bold font.
147
148 ccol Like cpile, but for use in matrix.
149
150 cpile Like pile, but with slightly increased vertical spacing.
151
152 dot Set a single dot over the preceding box.
153
154 dotdot Set two dots (dieresis) over the preceding box.
155
156 dyad Set a dyad symbol (left-right arrow) over the preceding box.
157
158 fat A synonym for bold.
159
160 font Set the second argument using the font specified by the first
161 argument; currently not recognized by the mandoc(1) eqn parser.
162
163 from Set the following box below the preceding box, using a slightly
164 smaller font. Used for sums, integrals, limits, and the like.
165
166 hat Set a hat (circumflex) over the preceding box.
167
168 italic Set the following box using italic font.
169
170 lcol Like lpile, but for use in matrix.
171
172 left Set the first argument as a big left delimiter before the second
173 argument. As an optional third argument, right can follow. In
174 that case, the fourth argument is set as a big right delimiter
175 after the second argument.
176
177 lpile Like cpile, but subequations are left-justified.
178
179 matrix Followed by a list of columns enclosed in braces. All columns
180 need to have the same number of subequations. The columns are
181 set as a matrix. The difference compared to multiple subsequent
182 pile operators is that in a matrix, corresponding subequations in
183 all columns line up horizontally, while each pile does vertical
184 spacing independently.
185
186 over Set a fraction. The preceding box is the numerator, the
187 following box is the denominator.
188
189 pile Followed by a list of subequations enclosed in braces, the
190 subequations being separated by above keywords. Sets the
191 subequations one above the other, each of them centered.
192 Typically used to represent vectors in coordinate representation.
193
194 rcol Like rpile, but for use in matrix.
195
196 right See left; right cannot be used without left. To set a big right
197 delimiter without a big left delimiter, the following
198 construction can be used:
199
200 left "" box right delimiter
201
202 roman Set the following box using the default font.
203
204 rpile Like cpile, but subequations are right-justified.
205
206 size Set the second argument with the font size specified by the first
207 argument; currently ignored by mandoc(1). By prepending a plus
208 or minus sign to the first argument, the font size can be
209 selected relative to the current size.
210
211 sqrt Set the square root of the following box.
212
213 sub Set the following box as a subscript to the preceding box.
214
215 sup Set the following box as a superscript to the preceding box. As
216 a special case, if a sup clause immediately follows a sub clause
217 as in
218
219 mainbox sub subbox sup supbox
220
221 both are set with respect to the same mainbox, that is, supbox is
222 set above subbox.
223
224 tilde Set a tilde over the preceding box.
225
226 to Set the following box above the preceding box, using a slightly
227 smaller font. Used for sums and integrals and the like. As a
228 special case, if a to clause immediately follows a from clause as
229 in
230
231 mainbox from frombox to tobox
232
233 both are set below and above the same mainbox.
234
235 under Underline the preceding box.
236
237 vec Set a vector symbol (right arrow) over the preceding box.
238
239 The binary operations from, to, sub, and sup group to the right, that is,
240
241 mainbox sup supbox sub subbox
242
243 is the same as
244
245 mainbox sup {supbox sub subbox}
246
247 and different from
248
249 {mainbox sup supbox} sub subbox.
250
251 By contrast, over groups to the left.
252
253 In the following list, earlier operations bind more tightly than later
254 operations:
255
256 1. dyad, vec, under, bar, tilde, hat, dot, dotdot
257 2. fat, roman, italic, bold, size
258 3. sub, sup
259 4. sqrt
260 5. over
261 6. from, to
262
263 COMPATIBILITY
264 This section documents the compatibility of mandoc eqn and the troff eqn
265 implementation (including GNU troff).
266
267 - The text string `\"' is interpreted as a literal quote in troff. In
268 mandoc, this is interpreted as a comment.
269 - In troff, The circumflex and tilde white-space symbols map to fixed-
270 width spaces. In mandoc, these characters are synonyms for the space
271 character.
272 - The troff implementation of eqn allows for equation alignment with
273 the mark and lineup tokens. mandoc discards these tokens. The back
274 n, fwd n, up n, and down n commands are also ignored.
275
276 SEE ALSO
277 mandoc(1), man(5), mandoc_char(5), mandoc_roff(5), mdoc(5)
278
279 Brian W. Kernighan and Lorinda L. Cherry, "System for Typesetting
280 Mathematics", Communications of the ACM, 18, 151-157, March, 1975.
281
282 Brian W. Kernighan and Lorinda L. Cherry, Typesetting Mathematics, User's
283 Guide, 1976.
284
285 Brian W. Kernighan and Lorinda L. Cherry, Typesetting Mathematics, User's
286 Guide (Second Edition), 1978.
287
288 HISTORY
289 The eqn utility, a preprocessor for troff, was originally written by
290 Brian W. Kernighan and Lorinda L. Cherry in 1975. The GNU
291 reimplementation of eqn, part of the GNU troff package, was released in
292 1989 by James Clark. The eqn component of mandoc(1) was added in 2011.
293
294 AUTHORS
295 This eqn reference was written by Kristaps Dzonsons <kristaps@bsd.lv>.
296
297 illumos September 4, 2017 illumos