| EQN(7) | Miscellaneous Information Manual | EQN(7) |
NAME
eqn — equations in
manual pages
DESCRIPTION
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.
WORDS
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:
alpha |
α | DELTA |
Δ |
beta |
β | GAMMA |
Γ |
gamma |
γ | LAMBDA |
Λ |
delta |
δ | OMEGA |
Ω |
epsilon |
ε | PHI |
Φ |
zeta |
ζ | PI |
Π |
eta |
η | PSI |
Ψ |
theta |
θ | SIGMA |
Σ |
iota |
ι | THETA |
Θ |
kappa |
κ | UPSILON |
Υ |
lambda |
λ | XI |
Ξ |
mu |
μ | sum |
∑ |
nu |
ν | prod |
∏ |
xi |
ξ | int |
∫ |
omicron |
ο | union |
∪ |
pi |
π | inter |
∩ |
rho |
ρ | grad, del |
∇ |
sigma |
σ | partial |
∂ |
tau |
τ | inf |
∞ |
upsilon |
υ | times |
× |
phi |
ϕ | cdot |
· |
chi |
χ | approx |
≈ |
psi |
ψ | prime |
′ |
omega |
ω | 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.
BOXES
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
overb - A fraction, a over b.
- a
supb - b as a superscript of a.
- a
subb - b as a subscript of a.
a
subbsupc sets both on a. - a
fromb - b under a, as the limits of a sum or an integral are set.
- a
tob - b over a.
a
frombtoc sets both on a. sqrta- The square root of a.
leftc ...rightd- The boxes between, enclosed in the delimiters c and
d, which may be empty
(‘
""’). Withoutright, the equation ends with a closing parenthesis. pile{aabovebabove...}- The boxes one above the other, centred;
lpileandrpilealign them left and right,cpilecentres them. matrix{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.
roman,italic,bold,fata- a in that font;
fatis bold. Words inside a are not split. sizen 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.
STATEMENTS
These words change how the rest of the page's equations are read; they set no box.
definename 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.ndefineis the same;tdefineis read and discarded. undefname- Forgets a definition.
delimxy- Makes x and y the delimiters
of equations inside text lines. ‘
delim off’ turns them off, and ‘delim on’ back on. gfontfont,gsizesize- Set the default font and size; they are read and ignored.
back,fwd,up,downn- Move the next box; they are read and ignored.
mark,lineup- Align equations with each other; they are ignored.
IN-LINE EQUATIONS
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.
OUTPUT
On a terminal, an equation is set on one line, with parentheses where its structure would otherwise be lost:
| Input | Output |
a+b over
c+d |
a + b/(c + d) |
{a+b} over
{c+d} |
(a + b)/(c + d) |
x sub i sup
2 |
x_i^2 |
sqrt
{x+1} |
√(x + 1) |
x bar |
x‾ |
In HTML, an equation is MathML.
EXAMPLES
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
DIAGNOSTICS
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.
SEE ALSO
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.
HISTORY
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.
CAVEATS
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.
BUGS
Positions, sizes and the mark and
lineup alignment are ignored. Equations inside
tables are not supported.
| September 28, 2026 | OxideBSD |