| EQN(7) | Miscellaneous Information Manual | EQN(7) | 
eqn —
eqn language is an equation-formatting language. It
  is used within mdoc(7) and
  man(7) UNIX
  manual pages. It describes the structure of an equation, not
  its mathematical meaning. This manual describes the
  eqn language accepted by the
  mandoc(1) utility, which
  corresponds to the Second Edition eqn specification
  (see SEE ALSO for references).
Equations within mdoc(7) or man(7) documents are enclosed by the standalone ‘.EQ’ and ‘.EN’ tags. Equations are multi-line blocks consisting of formulas and control statements.
The equation grammar is as follows, where quoted strings are case-sensitive literals in the input:
eqn     : box | eqn box
box     : text
        | "{" eqn "}"
        | "define" text text
        | "ndefine" text text
        | "tdefine" text text
        | "gfont" text
        | "gsize" text
        | "set" text text
        | "undef" text
        | "sqrt" box
        | box pos box
        | box mark
        | "matrix" "{" [col "{" list "}"]* "}"
        | pile "{" list "}"
        | font box
        | "size" text box
        | "left" text eqn ["right" text]
col     : "lcol" | "rcol" | "ccol" | "col"
text    : [^space\"]+ | \".*\"
pile    : "lpile" | "cpile" | "rpile" | "pile"
pos     : "over" | "sup" | "sub" | "to" | "from"
mark	: "dot" | "dotdot" | "hat" | "tilde" | "vec"
        | "dyad" | "bar" | "under"
font    : "roman" | "italic" | "bold" | "fat"
list    : eqn
        | list "above" eqn
space   : [\^~ \t]
White-space consists of the space, tab, circumflex, and tilde characters. It is required to delimit tokens consisting of alphabetic characters and it is ignored at other places. Braces and quotes also delimit tokens. If within a quoted string, these space characters are retained. Quoted strings are also not scanned for keywords, glyph names, and expansion of definitions. To print a literal quote character, it can be prepended with a backslash or expressed with the \(dq escape sequence.
Subequations can be enclosed in braces to pass them as arguments to operation keywords, overriding standard operation precedence. Braces can be nested. To set a brace verbatim, it needs to be enclosed in quotes.
The following text terms are translated into a rendered glyph, if available: alpha, beta, chi, delta, epsilon, eta, gamma, iota, kappa, lambda, mu, nu, omega, omicron, phi, pi, psi, rho, sigma, tau, theta, upsilon, xi, zeta, DELTA, GAMMA, LAMBDA, OMEGA, PHI, PI, PSI, SIGMA, THETA, UPSILON, XI, inter (intersection), union (union), prod (product), int (integral), sum (summation), grad (gradient), del (vector differential), times (multiply), cdot (center-dot), nothing (zero-width space), approx (approximately equals), prime (prime), half (one-half), partial (partial differential), inf (infinity), >> (much greater), << (much less), <- (left arrow), -> (right arrow), +- (plus-minus), != (not equal), == (equivalence), <= (less-than-equal), and >= (more-than-equal). The character escape sequences documented in mandoc_char(7) can be used, too.
The following control statements are available:
definedefine key
      cvalcThe first character of the value string, c, is used as the delimiter for the value val. This allows for arbitrary enclosure of terms (not just quotes), such as
define foo
      'bar baz'define foo
      cbar bazcIt is an error to have an empty key or
        val. Note that a quoted key
        causes errors in some eqn implementations and
        should not be considered portable. It is not expanded for replacements.
        Definitions may refer to other definitions; these are evaluated
        recursively when text replacement occurs and not when the definition is
        created.
Definitions can create arbitrary strings, for example, the following is a legal construction.
define foo 'define'
foo bar 'baz'
    
    Self-referencing definitions will raise an error. The
        ndefine statement is a synonym for
        define, while tdefine is
        discarded.
gfontgfont
      fontIn mandoc, this value is discarded.
gsizegsize
      [+|-]sizeThe size value should be an integer. If prepended by a sign, the font size is changed relative to the current size.
setset key
      valThe key and val are not expanded for replacements. This statement is a GNU extension.
undefdefine
      keyOnce invoked, the definition for key is discarded. The key is not expanded for replacements. This statement is a GNU extension.
Operation keywords have the following semantics:
abovepile.barboldccolcpile, but for use in
      matrix.cpilepile, but with slightly increased vertical
      spacing.dotdotdotdyadfatbold.fonteqn parser.fromhatitaliclcollpile, but for use in
      matrix.leftright can follow.
      In that case, the fourth argument is set as a big right delimiter after
      the second argument.lpilecpile, but subequations are
    left-justified.matrixpile
      operators is that in a matrix, corresponding
      subequations in all columns line up horizontally, while each
      pile does vertical spacing independently.overpileabove keywords. Sets the
      subequations one above the other, each of them centered. Typically used to
      represent vectors in coordinate representation.rcolrpile, but for use in
      matrix.rightleft; right cannot be
      used without left. To set a big right delimiter
      without a big left delimiter, the following construction can be used:
    
    left
      "" box
      right delimiterromanrpilecpile, but subequations are
    right-justified.sizesqrtsubsupsup clause immediately follows a
      sub clause as in
    
    sub subbox
      sup supboxboth are set with respect to the same mainbox, that is, supbox is set above subbox.
tildetoto clause immediately follows a
      from clause as in
    
    from frombox
      to toboxboth are set below and above the same mainbox.
undervecThe binary operations from,
    to, sub, and
    sup group to the right, that is,
sup supbox
  sub subboxis the same as
sup {supbox
  sub subbox}and different from
sup supbox}
  sub subbox.By contrast, over groups to the left.
In the following list, earlier operations bind more tightly than later operations:
eqn
  and the troff eqn implementation (including GNU
  troff).
eqn allows for
      equation alignment with the mark and
      lineup tokens. mandoc discards these tokens. The
      back n,
      fwd n,
      up n, and
      down n commands are also
      ignored.Brian W. Kernighan and Lorinda L. Cherry, System for Typesetting Mathematics, Communications of the ACM, 18, 151–157, March, 1975.
Brian W. Kernighan and Lorinda L. Cherry, Typesetting Mathematics, User's Guide, 1976.
Brian W. Kernighan and Lorinda L. Cherry, Typesetting Mathematics, User's Guide (Second Edition), 1978.
eqn reference was written by
  Kristaps Dzonsons
  <kristaps@bsd.lv>.
| September 4, 2017 | NetBSD 10.0 |