Part of the
troff
troff (), short for "typesetter roff", is the major component of a document processing system developed by Bell Labs for the Unix operating system. troff and the related nroff were both developed from the original roff (software), roff.
Whil ...
suite of
Unix document layout tools, eqn is a
preprocessor
In computer science, a preprocessor (or precompiler) is a Computer program, program that processes its input data to produce output that is used as input in another program. The output is said to be a preprocessed form of the input data, which i ...
that formats equations for printing. A similar program, neqn, accepted the same input as eqn, but produced output tuned to look better in
nroff. The eqn program was created in 1974 by
Brian Kernighan and
Lorinda Cherry.
It was implemented using
yacc compiler-compiler.
The input language used by eqn allows the user to write mathematical expressions in much the same way as they would be spoken aloud. The language is defined by a
context-free grammar, together with
operator precedence and
operator associativity rules.
The eqn language is similar to the mathematical component of
TeX
Tex, TeX, TEX, may refer to:
People and fictional characters
* Tex (nickname), a list of people and fictional characters with the nickname
* Tex Earnhardt (1930–2020), U.S. businessman
* Joe Tex (1933–1982), stage name of American soul singer ...
, which appeared several years later, but is simpler and less complete.
An independent compatible implementation of the eqn preprocessor has been developed by
GNU as part of
groff, the GNU version of troff. The GNU implementation extends the original language by adding a number of new
keywords such as ''smallover'' and ''accent''.
mandoc, a specialised compiler for UNIX
man pages, also contains a standalone eqn parser/formatter.
History
Eqn was written using the
yacc parser generator.
Syntax examples
Here is how some examples would be written in eqn
(with equivalents in TeX for comparison):
Spaces are important in eqn;
tokens are delimited only by
whitespace characters, tildes ~, braces and double-quotes "". Thus
f(pi r sup 2)
results in
, whereas
f( pi r sup 2 )
is needed to give the intended
.
References
External links
Typesetting Mathematics, User's Guide (Second Edition)*
*
eqn
Plan 9 commands
{{Unix-stub