eqn
Format mathematical equations for troff
TLDR
Process input with equations, saving the output for future typesetting with groff to PostScript
Typeset an input file with equations to PDF using the [me] macro package
SYNOPSIS
eqn [-d xy] [-f f] [-n] [-p n] [-s n] [-T name] [files]
PARAMETERS
-d xy
Specifies delimiters x and y for the start and end of equations, replacing the default .EQ and .EN. Either x or y can be omitted to avoid changing the corresponding delimiter.
-f f
Specifies a default font f for the equations. Overrides the font specified by gfont.
-n
Suppresses automatic newline after each equation.
-p n
Sets the subscript and superscript height to n points. Default is 12.
-s n
Sets the default size to n points. Overrides the size specified by gsize.
-T name
Prepare output for device name rather than troff. name can be psc, ps, tex, or dvi.
[files]
Specifies input files to process. If no files are given, eqn reads from standard input.
DESCRIPTION
The eqn command is a preprocessor that converts mathematical notation embedded within text into typesetting instructions suitable for use with troff or TeX. It reads the input, searches for lines starting with .EQ and ending with .EN. The text between these markers are interpreted as mathematical equations and translated into troff requests. Input lines not starting with .EQ are passed through unchanged. eqn is useful for creating documents containing complex mathematical formulas. The output from eqn is typically piped to troff (or TeX) for final formatting and printing. Modern systems often integrate equation processing directly into document preparation systems, making eqn less commonly used directly, but its legacy lives on in the syntax of mathematical expressions in many document processing tools. The program neqn can be used to display equations on terminals.
CAVEATS
eqn is designed to work with troff or TeX, and its output must be processed by one of these typesetting systems. The precise syntax and capabilities of eqn can vary slightly between different implementations.
EQUATION FORMATTING
Equations in eqn are specified using a language of keywords and operators. Common keywords include sqrt (square root), sum (summation), int (integral), frac (fraction), sup (superscript), and sub (subscript). Special characters and symbols can be accessed using keywords such as alpha, beta, gamma, etc.
Example:
.EQ
x = { -b +- sqrt {b sup 2 - 4ac} } over {2a}
.EN
MACROS
Macros may be defined using the define keyword to simplify the writing of repetitive equations. This allows complex or frequently used expressions to be written once and then referenced using the macro name. The syntax is define name replacement.
HISTORY
eqn was developed at Bell Laboratories in the 1970s by Brian Kernighan and Lorinda Cherry. It was designed to simplify the process of including mathematical formulas in documents typeset with troff. The command has been included as a standard utility in many Unix-like operating systems. It became a fundamental tool for scientific and technical writing. Its influence can be seen in the equation formatting syntax used in systems such as LaTeX. Variants and extensions of eqn have been developed over the years, but the core functionality remains largely consistent.