OxideBSD
EQN(7) Miscellaneous Information Manual EQN(7)

eqn — equations in manual pages

The eqn language describes mathematical notation inside a manual page written in mdoc(7) or man(7). It describes how an equation is laid out, not what it means. Like tbl(7), it began as a preprocessor that turned its input into roff(7) requests; oxdoc(1) reads it directly, as part of the page.

An equation starts with a EQ line and ends with an EN line; the lines between them are the equation. It takes its place in the text around it, as a word would:

The sum
.EQ
sum from i=1 to n i sup 2
.EN
grows as the cube of n.

An equation can also be written inside a text line, between the delimiters the delim statement sets.

An equation is a sequence of words separated by white space: spaces, tabs, line ends, and the characters ‘^’ and ‘~’, which are only separators here. Braces (‘{ and ‘}’’) are words by themselves, and a string in double quotes is one word, spaces and all; inside quotes, ‘\"’ stands for a quote. Anything else runs up to the next separator, brace or quote, so ‘x+1’ is one word.

A word that is not a keyword is set as text. An unquoted word is split where its characters change kind: letters, digits (with a decimal point), and anything else. Letters are set in italic, the rest in roman, and the pieces are spaced as mathematics usually is: a space around an operator such as ‘+’, none before a comma or a closing parenthesis, none after an opening one.

Some words are set as a symbol instead:

α DELTA Δ
β GAMMA Γ
γ LAMBDA Λ
δ OMEGA Ω
ε PHI Φ
ζ PI Π
η PSI Ψ
θ SIGMA Σ
ι THETA Θ
κ UPSILON Υ
λ XI Ξ
μ sum ∑
ν prod ∏
ξ int ∫
ο union ∪
π inter ∩
ρ grad, del ∇
σ partial ∂
τ inf ∞
υ times ×
ϕ cdot ·
χ approx ≈
ψ prime ′
ω half ½

The operators ‘<=’, ‘>=’, ‘!=’, ‘==’, ‘+-’, ‘->’, ‘<-’, ‘<<’ and ‘>>’, as words of their own, are set as the symbols ‘≤’, ‘≥’, ‘≠’, ‘≡’, ‘±’, ‘→’, ‘←’, ‘≪’ and ‘≫’; nothing is an empty word. The names of common functions, sin, cos, tan, sinh, cosh, tanh, coth, sec, csc, atan, arc, exp, log, ln, lim, max, min, det, Re, Im, and the words and, if and for, are set in roman. Escape sequences, such as the special characters of roff(7), work in any word.

An equation is built of boxes. A word is a box, and braces make a sequence of boxes into one. The keywords combine boxes:

a over b
A fraction, a over b.
a sup b
b as a superscript of a.
a sub b
b as a subscript of a. a sub b sup c sets both on a.
a from b
b under a, as the limits of a sum or an integral are set.
a to b
b over a. a from b to c sets both on a.
a
The square root of a.
c ... right d
The boxes between, enclosed in the delimiters c and d, which may be empty (‘""’). Without right, the equation ends with a closing parenthesis.
{a above b above ...}
The boxes one above the other, centred; lpile and rpile align them left and right, cpile centres them.
{lcol {... ccol {... rcol {...}}}}
A matrix of columns, each a pile of the same number of boxes, aligned left, centred or right.
a bar, under
A line over or under a.
a dot, dotdot, hat, tilde, vec, dyad
A dot, two dots, a circumflex, a tilde, an arrow or a double arrow over a.
, italic, bold, fat a
a in that font; fat is bold. Words inside a are not split.
n a
a in point size n; the size is ignored.

Marks bind tightest: a mark belongs to the box just before it. Then come the fonts, size and sqrt, each taking the one box after it. sub and sup come next and group to the right, so ‘x sup a sup b’ is ‘x sup { a sup b }’; over is looser and groups to the left. from and to group to the right, and apply to what the other operations have made of the boxes before them. Braces override all of this.

These words change how the rest of the page's equations are read; they set no box.

name value
From here on, the word name stands for value. The first character of value is its delimiter: it runs up to the next occurrence of that character, so ‘define half '1 over 2'’ defines ‘half’. A definition may use others; they are expanded when it is used. ndefine is the same; tdefine is read and discarded.
name
Forgets a definition.
xy
Makes x and y the delimiters of equations inside text lines. ‘delim off’ turns them off, and ‘delim on’ back on.
font, gsize size
Set the default font and size; they are read and ignored.
, fwd, up, down n
Move the next box; they are read and ignored.
, lineup
Align equations with each other; they are ignored.

Once delim has set delimiters, an equation can be written in the middle of a text or macro line:

.EQ
delim $$
.EN
The area is $pi r sup 2$.

The line is cut around the equation. The text before it stays as it was; the equation follows it, without a space unless the line has one there; and the rest of the line is text, even after a macro's arguments, joined to the equation the same way.

On a terminal, an equation is set on one line, with parentheses where its structure would otherwise be lost:

a + b/(c + d)
(a + b)/(c + d)
x_i^2
√(x + 1)
x‾

In HTML, an equation is MathML.

The quadratic formula,

.EQ
x = {-b +- sqrt {b sup 2 - 4ac}} over 2a
.EN

is shown as

A sum with limits, using a definition:

.EQ
define sq 'i sup 2'
sum from i=1 to n sq = {n(n+1)(2n+1)} over 6
.EN

is shown as

In lint mode, oxdoc(1) reports problems in equations at the levels mandoc(1) uses: a closing brace, right or above with nothing open for it to close, an operation missing its first box, a statement missing its argument, an unterminated quoted word or definition, and a definition that uses itself.

man(1), oxdoc(1), man(7), mdoc(7), roff(7), tbl(7)

Brian W. Kernighan and Lorinda L. Cherry, A System for Typesetting Mathematics, Communications of the ACM, 3, 18, 151–157, March 1975.

Brian W. Kernighan and Lorinda L. Cherry, Typesetting Mathematics — User's Guide (Second Edition), Bell Laboratories, 1978.

The eqn preprocessor was written by Brian W. Kernighan and Lorinda L. Cherry at Bell Laboratories and first appeared in Version 5 AT&T UNIX. This manual was written for OxideBSD.

Where the eqn of mandoc(1) differs from the language's original description, oxdoc(1) follows mandoc(1), the formatter the BSDs share: sqrt takes a single box, not an expression; from and to bind as tightly as over; and a from or to inside braces that are the operand of sub, sup, over or sqrt applies to that operation, leaving the braces.

Positions, sizes and the mark and lineup alignment are ignored. Equations inside tables are not supported.

September 28, 2026 OxideBSD