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