LinuxCommandLibrary

eqn

Format mathematical equations for troff

TLDR

Process input with equations, saving the output for future typesetting with groff to PostScript

$ eqn [path/to/input.eqn] > [path/to/output.roff]
copy

Typeset an input file with equations to PDF using the [me] macro package
$ eqn -T [pdf] [path/to/input.eqn] | groff -[me] -T [pdf] > [path/to/output.pdf]
copy

SYNOPSIS

eqn [-CNRrvw] [-dXY] [-sn] [-fn f] [-T name] [files...]

PARAMETERS

-C
    Enable compatibility mode with original eqn from 1979

-N
    Do not assume special math fonts available; use roman approximations

-R
    Omit positioning info from output

-r
    Ignore characters outside roman set

-v
    Print version information

-w
    Suppress output if no equations found

-dXY
    Set inline equation delimiters to X (left) and Y (right); default '"

-sn
    Set point size of equations to n

-fn f
    Set font n (1-4) to typeface f (e.g., times)

-Tname
    Prepare output for device name (e.g., latin1, utf8)

DESCRIPTION

eqn is a preprocessor for the troff and nroff typesetting systems that converts mathematical equations from a simple descriptive input format into low-level troff formatting commands.

It processes input files or standard input, recognizing equations delimited by .EQ and .EN macros (for display math) or single quotes/single double-quotes (for inline math). The syntax supports fractions (a/b), sub/superscripts (x2), sums/integrals (sum from i=0 to n of xi), matrices, and more, using intuitive notation like sqrt(x) or over {a b c} {d e f} for fractions.

Output is troff-compatible code that positions glyphs precisely. Typically piped into troff after preprocessors like tbl and pic. Modern usage is via groff, which emulates traditional Unix tools. Ideal for technical documents but superseded by LaTeX for new work.

CAVEATS

Archaic tool; requires troff/groff pipeline for rendering. Sensitive to exact syntax; errors halt processing. No Unicode support in base form; use groff extensions. Not suitable for interactive use or modern web output.

EQUATION DELIMITERS

Display: .EQ ... .EN
Inline: 'equation' or "equation"

BASIC SYNTAX EXAMPLES

a/b + c~d (fraction, spacing)
xi = sumj=0n j2
integral (dx)/sqrt(1 + x2)

HISTORY

Developed in 1975 by Lorinda Cherry and Jon Osier at Bell Labs for Version 7 Unix. Enhanced in subsequent AT&T releases. Ported to GNU as part of groff project in 1990s by James Clark, maintaining backward compatibility while adding features like better internationalization.

SEE ALSO

neqn(1), troff(1), nroff(1), groff(1), tbl(1), pic(1), refer(1)

Copied to clipboard