On Unix-like operating systems, the eqn and neqn commands are language processors to assist in describing equations. eqn is a preprocessor for troff and is intended for devices that print troff’s output. neqn is a preprocessor for nroff and is intended for use with terminals.

Description

eqn compiles descriptions of equations embedded within troff input files into commands that are understood by troff. If no files are given on the command line, the standard input is read. A file name of - causes the standard input to be read.

  • Description
  • Syntax
  • Examples
  • Related commands
  • Linux commands help

eqn searches for the file eqnrc in the directories given with the -M option first, then in /usr/lib/groff/site-tmac, /usr/share/groff/site-tmac, and finally in the standard macro directory /usr/share/groff/1.22.1/tmac. If it exists, eqn processes it before the other input files. The -R option prevents this.

Syntax

eqn [-rvCNR] [-d xy] [-T name] [-M dir] [-f F] [-s n] [-p n] [-m n] [files…]

neqn [file]

checkeq [file]

Options

Using newer versions of GNU eqn

Most of the new features of GNU eqn are based on TeX. There are some references to the differences between TeX and GNU eqn below.

Automatic spacing

eqn gives each component of an equation a type, and adjusts the spacing between components using that type. Possible types are:

Components of an equation get a type in one of two ways:

New primitives

Extended primitives

Customization

The appearance of equations is controlled by a large number of parameters. These can be set using the set command.

type “binary” (mu

chartype “punctuation” .,;:

{ type “operator” vcenter size +5 (*S }

accent { “^” }

text

“text”

.EQdefine cancel ‘special Ca’.EN.de Ca. ds 0s \Z’\*(0s’\v’\n(0du’\D’l \n(0wu -\n(0hu-\n(0du’\v’\n(0hu’..

.EQdefine box ‘special Bx’.EN.de Bx. ds 0s \Z’\h'1n’\*(0s’\Z’\v’\n(0du+1n’\D’l \n(0wu+2n 0’\D’l 0 -\n(0hu-\n(0du-2n’\D’l -\n(0wu-2n 0’\D’l 0 \n(0hu+\n(0du+2n’'\h’\n(0wu+2n’. nr 0w +2n. nr 0d +1n. nr 0h +1n..

ccol n { … }

lcol n { … }

rcol n { … }

pile n { … }

cpile n { … }

lpile n { … }

rpile n { … }

Possible parameters are as follows. Values are in units of hundredths of an em unless otherwise stated. These descriptions are intended to be expository rather than definitive.

says that eqn should assume an x height of 0.45 ems.

Macros

Macros can take arguments. In a macro body, $n where n is between 1 and 9, is replaced by the n-th argument if the macro is called with arguments; if there are fewer than n arguments, it is replaced by nothing. A word containing a left parenthesis where the part of the word before the left parenthesis is defined using the define command is recognized as a macro call with arguments; characters following the left parenthesis up to a matching right parenthesis are treated as comma-separated arguments; commas inside nested parentheses do not terminate an argument.

Besides the macros mentioned above, the following definitions are available: Alpha, Beta, …, Omega (this is the same as ALPHA, BETA, …, OMEGA), ldots (three dots on the base line), and dollar.

copy “file”

Fonts

eqn normally uses at least two fonts to set an equation: an italic font for letters, and a roman font for everything else. The existing gfont command changes the font that is used as the italic font. By default, this is I. The font that is used as the roman font can be changed using the new grfont command.

The italic primitive uses the current italic font set by gfont; the roman primitive uses the current roman font set by grfont. There is also a new gbfont command, which changes the font used by the bold primitive. If you only use the roman, italic and bold primitives to changes fonts within an equation, you can change all the fonts used by your equations using only gfont, grfont and gbfont commands.

You can control which characters are treated as letters (and therefore set in italics) using the chartype command described above. A type of letter causes a character to be set in italic type. A type of digit causes a character to be set in roman type.

Files

Examples

eqn myfile.txt

Process a troff file.

nroff — Format documents for terminal display or line-printer.tbl — Preprocessor which formats tables for nroff or troff.troff — Typeset or format documents for terminal display or line-printer.