Provided by: groff-base_1.23.0-2_amd64

**Name**

eqn - format mathematics (equations) forgroffor MathML

**Synopsis**

eqn[-CNrR] [-dxy] [-fF] [-mn] [-Mdir] [-pn] [-sn] [-Tdev] [file...]eqn--helpeqn-veqn--version

**Description**

The GNU implementation ofeqnis part of thegroff(7) document formatting system.eqnis atroff(1) preprocessor that translates expressions in its own language, embedded inroff(7) input files, into mathematical notation typeset bytroff(1). It copies eachfile's contents to the standard output stream, translating eachequationbetween lines starting with.EQand.EN, or within a pair of user-specified delimiters. Normally,eqnis not executed directly by the user, but invoked by specifying the-eoption togroff(1). While GNUeqn's input syntax is highly compatible with AT&Teqn, the outputeqnproduces cannot be processed by AT&Ttroff; GNUtroff(or atroffimplementing relevant GNU extensions) must be used. If nofileoperands are given on the command line, or iffileis “-”,eqnreads the standard input stream. Unless the-Roption is used,eqnsearches for the fileeqnrcin the directories given with the-Moption first, then in/usr/share/groff/site-tmac, and finally in the standard macro directory/usr/share/groff/1.23.0/tmac. If it exists and is readable,eqnprocesses it before any input files. This man page primarily discusses the differences between GNUeqnand AT&Teqn. Most of the new features of the GNUeqninput language are based on TeX. There are some references to the differences between TeX and GNUeqnbelow; these may safely be ignored if you do not know TeX. Three points are worth special note. • GNUeqnemits Presentation MathML output when invoked with the “-TMathML” option. • GNUeqndoes not support terminal devices well, though it may suffice for simple inputs. • GNUeqnsets the input token “...” as an ellipsis on the text baseline, not the three centered dots of AT&Teqn. Set an ellipsis on the math axis with the GNU extension macrocdots.Anatomyofanequationeqninput consists of tokens. Consider a form of Newton's second law of motion. The input .EQ F = m a .EN becomesF=ma. Each ofF,=,m, andais a token. Spaces and newlines are interchangeable; they separate tokens but do not break lines or produce space in the output. The following input characters not only separate tokens, but manage their grouping and spacing as well.{}Braces perform grouping. Whereas “esupab” expresses “(eto thea) timesb”, “esup{ab}” means “eto the (atimesb)”. When immediately preceded by a “left” or “right” primitive, a brace loses its special meaning.^~are thehalfspaceandfullspace,respectively. Use them to tune the appearance of the output. Tab and leader characters separate tokens as well as advancing the drawing position to the next tab stop, but are seldom used ineqninput. When they occur, they must appear at the outermost lexical scope. This roughly means that they can't appear within braces that are necessary to disambiguate the input;eqnwill diagnose an error in this event. (See subsection “Macros” below for additional token separation rules.) Other tokens are primitives, macros, an argument to either of the foregoing, or components of an equation.Primitivesare fundamental keywords of theeqnlanguage. They can configure an aspect of the preprocessor's state, as when setting a “global” font selection or type size (gfontandgsize), or declaring or deleting macros (“define” andundef); these are termedcommands.Other primitives perform formatting operations on the tokens after them (as withfat,over,sqrt, orup). Equationcomponentsinclude mathematical variables, constants, numeric literals, and operators.eqnremaps some input character sequences togroffspecial character escape sequences for economy in equation entry and to ensure that glyphs from an unstyled font are used; seegroff_char(7). + \[pl] ' \[fm] - \[mi] <= \[<=] = \[eq] >= \[>=]Macrospermit primitives, components, and other macros to be collected and referred to by a single token. Predefined macros make convenient the preparation ofeqninput in a form resembling its spoken expression; for example, considercos,hat,inf, andlim.SpacingandtypefaceGNUeqnimputes types to the components of an equation, adjusting the spacing between them accordingly. Recognized types are as follows; most affect spacing only, whereas the “letter” subtype of “ordinary” also assigns a style. ordinary character such as “1”, “a”, or “!” letter character to be italicized by default digitn/aoperator large operator such as “Σ” binary binary operator such as “+” relation relational operator such as “=” opening opening bracket such as “(” closing closing bracket such as “)” punctuation punctuation character such as “,” inner sub-formula contained within brackets suppress component to which automatic spacing is not applied Two primitives apply types to equation components.typeteApply typetto expressione.chartypettextAssign each character in (unquoted)texttypet, persistently.eqnsets up spacings and styles as if by the following commands. chartype "letter" abcdefghiklmnopqrstuvwxyz chartype "letter" ABCDEFGHIKLMNOPQRSTUVWXYZ chartype "letter" \[*a]\[*b]\[*g]\[*d]\[*e]\[*z] chartype "letter" \[*y]\[*h]\[*i]\[*k]\[*l]\[*m] chartype "letter" \[*n]\[*c]\[*o]\[*p]\[*r]\[*s] chartype "letter" \[*t]\[*u]\[*f]\[*x]\[*q]\[*w] chartype "binary" *\[pl]\[mi] chartype "relation" <>\[eq]\[<=]\[>=] chartype "opening" {([ chartype "closing" })] chartype "punctuation" ,;:. chartype "suppress" ^~eqnassigns all other ordinary and specialroffcharacters, including numerals 0–9, the “ordinary” type. (The “digit” type is not used, but is available for customization.) In keeping with common practice in mathematical typesetting, lowercase, but not uppercase, Greek letters are assigned the “letter” type to style them in italics. The macros for producing ellipses, “...”,cdots, andldots, use the “inner” type.Primitiveseqnsupports without alteration the AT&Teqnprimitivesabove,back,bar,bold,define,down,fat,font,from,fwd,gfont,gsize,italic,left,lineup,mark,matrix,ndefine,over,right,roman,size,sqrt,sub,sup,tdefine,to,under, andup.NewprimitivesThe GNU extension primitives “type” andchartypeare discussed in subsection “Spacing and typeface” above; “set” in subsection “Customization” below; andgrfontandgbfontin subsection “Fonts” below. In the following synopses,Xcan be any character not appearing in the parameter thus bracketed.e1accente2Sete2as an accent overe1.e2is assumed to be at the appropriate height for a lowercase letter without an ascender;eqnvertically shifts it depending one1's height. For example,hatis defined as follows. accent { "^" }dotdot,dot,tilde,vec, anddyadare also defined using theaccentprimitive.bigeEnlarge the expressione; semantics like those of CSS “large” are intended. Introffoutput, the type size is increased by 5 scaled points. MathML output emits the following. <mstyle mathsize='big'>copyfileincludefileInterpolate the contents offile, omitting lines beginning with.EQor.EN. If a relative path name,fileis sought relative to the current working directory.ifdefnameXanythingXIfnameis defined as a primitive or macro, interpretanything.nosplittextAs "text", but sincetextis not quoted it is subject to macro expansion; it is not split up and the spacing between characters not adjusted per subsection “Spacing and typeface” above.eopprimeAsprime, but set the prime symbol as an operator one. In the input “Aopprimesub1”, the “1” is tucked under the prime as a subscript to the “A” (as is conventional in mathematical typesetting), whereas whenprimeis used, the “1” is a subscript to the prime character. The precedence ofopprimeis the same as that ofbarand “under”, and higher than that of other primitives exceptaccentanduaccent. In unquoted text, a neutral apostrophe (') that is not the first character on the input line is treated likeopprime.sdefinenameXanythingXAs “define”, butnameis not recognized as a macro if called with arguments.e1smallovere2Asover, but reduces the type size ofe1ande2, and puts less vertical space betweene1ande2and the fraction bar. Theoverprimitive corresponds to the TeX\overprimitive in displayed equation styles;smallovercorresponds to\overin non-display (“inline”) styles.spacenSet extra vertical spacing around the equation, replacing the default values, wherenis an integer in hundredths of an em. If positive,nincreases vertical spacing before the equation; if negative, it does so after the equation. This primitive provides an interface togroff's\xescape sequence, but with the opposite sign convention. It has no effect if the equation is part of apic(1) picture.specialtroff-macroeConstruct an object by callingtroff-macroone. Thetroffstring0scontains theeqnoutput fore, and the registers0w,0h,0d,0skern, and0skewthe width, height, depth, subscript kern, and skew ofe, respectively. (Thesubscriptkernof an object indicates how much a subscript on that object should be “tucked in”, or placed to the left relative to a non-subscripted glyph of the same size. Theskewof an object is how far to the right of the center of the object an accent over it should be placed.) The macro must modify0sso that it outputs the desired result, returns the drawing position to the text baseline at the beginning ofe, and updates the foregoing registers to correspond to the new dimensions of the result. Suppose you want a construct that “cancels” an expression by drawing a diagonal line through it. .de Ca . ds 0s \ \Z'\\*(0s'\ \v'\\n(0du'\ \D'l \\n(0wu -\\n(0hu-\\n(0du'\ \v'\\n(0hu' .. .EQ special Ca "x \[mi] 3 \[pl] x" ~ 3 .EN We use the\[mi]and\[pl]special characters instead of + and - because they are part of the argument to atroffmacro, soeqndoes not transform them to mathematical glyphs for us. Here's a more complicated construct that draws a box around an expression; the bottom of the box rests on the text baseline. We define theeqnmacroboxto wrap the call of thetroffmacroBx. .de Bx .ds 0s \ \Z'\\h'1n'\\*[0s]'\ \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 .. .EQ define box ' special Bx $1 ' box(foo) ~ "bar" .ENsplit"text"Astext, but sincetextis quoted, it is not subject to macro expansion; it is split up and the spacing between characters adjusted per subsection “Spacing and typeface” above.e1uaccente2Sete2as an accent undere1.e2is assumed to be at the appropriate height for a letter without a descender;eqnvertically shifts it depending on whethere1has a descender.utildeis predefined usinguaccentas a tilde accent below the baseline.undefnameRemove definition of macro or primitivename, making it undefined.vcentereVertically centereabout themathaxis, a horizontal line upon which fraction bars and characters such as “+” and “−” are aligned. MathML already behaves this way, soeqnignores this primitive when producing that output format. The built-insummacro is defined as if by the following. define sum ! { type "operator" vcenter size +5 \(*S } !ExtendedprimitivesGNUeqnextends the syntax of some AT&Teqnprimitives, introducing one deliberate incompatibility.delimoneqnrecognizes an “on” argument to thedelimprimitive specially, restoring any delimiters previously disabled with “delimoff”. If delimiters haven't been specified, neither command has effect. Feweqndocuments are expected to use “o” and “n” as left and right delimiters, respectively. If yours does, consider swapping them, or select others.coln{...}ccoln{...}lcoln{...}rcoln{...}pilen{...}cpilen{...}lpilen{...}rpilen{...}The integer valuen(in hundredths of an em) increases the vertical spacing between rows, usinggroff's\xescape sequence (the value has no effect in MathML mode). Negative values are accepted but have no effect. If more than onenoccurs in a matrix or pile, the largest is used.CustomizationWheneqngeneratestroffinput, the appearance of equations is controlled by a large number of parameters. They have no effect when generating MathML, which delegates typesetting to a MathML rendering engine. Configure these parameters with thesetprimitive.setpnassigns parameterpthe integer valuen;nis interpreted in units of hundredths of an em unless otherwise stated. For example, set x_height 45 says thateqnshould assume that the font's x-height is 0.45 ems. Available parameters are as follows; defaults are shown in parentheses. We intend these descriptions to be expository rather than rigorous.minimum_sizesets a floor for the type size (in scaled points) at which equations are set (5).fat_offsetThefatprimitive emboldens an equation by overprinting two copies of the equation horizontally offset by this amount (4). In MathML mode, components to whichfat_offsetapplies instead use the following. <mstyle mathvariant='double-struck'>over_hangA fraction bar is longer by twice this amount than the maximum of the widths of the numerator and denominator; in other words, it overhangs the numerator and denominator by at least this amount (0).accent_widthWhenbarorunderis applied to a single character, the line is this long (31). Normally,barorunderproduces a line whose length is the width of the object to which it applies; in the case of a single character, this tends to produce a line that looks too long.delimiter_factorExtensible delimiters produced with theleftandrightprimitives have a combined height and depth of at least this many thousandths of twice the maximum amount by which the sub-equation that the delimiters enclose extends away from the axis (900).delimiter_shortfallExtensible delimiters produced with theleftandrightprimitives have a combined height and depth not less than the difference of twice the maximum amount by which the sub-equation that the delimiters enclose extends away from the axis and this amount (50).null_delimiter_spaceThis much horizontal space is inserted on each side of a fraction (12).script_spaceThe width of subscripts and superscripts is increased by this amount (5).thin_spaceThis amount of space is automatically inserted after punctuation characters. It also configures the width of the space produced by the^token (17).medium_spaceThis amount of space is automatically inserted on either side of binary operators (22).thick_spaceThis amount of space is automatically inserted on either side of relations. It also configures the width of the space produced by the~token (28).x_heightThe height of lowercase letters without ascenders such as “x” (45).axis_heightThe height above the baseline of the center of characters such as “+” and “−” (26). It is important that this value is correct for the font you are using.default_rule_thicknessThis should be set to the thickness of the\[ru]character, or the thickness of horizontal lines produced with the\Descape sequence (4).num1Theoverprimitive shifts up the numerator by at least this amount (70).num2Thesmalloverprimitive shifts up the numerator by at least this amount (36).denom1Theoverprimitive shifts down the denominator by at least this amount (70).denom2Thesmalloverprimitive shifts down the denominator by at least this amount (36).sup1Normally superscripts are shifted up by at least this amount (42).sup2Superscripts within superscripts or upper limits or numerators ofsmalloverfractions are shifted up by at least this amount (37). Conventionally, this is less thansup1.sup3Superscripts within denominators or square roots or subscripts or lower limits are shifted up by at least this amount (28). Conventionally, this is less thansup2.sub1Subscripts are normally shifted down by at least this amount (20).sub2When there is both a subscript and a superscript, the subscript is shifted down by at least this amount (23).sup_dropThe baseline of a superscript is no more than this much below the top of the object on which the superscript is set (38).sub_dropThe baseline of a subscript is at least this much below the bottom of the object on which the subscript is set (5).big_op_spacing1The baseline of an upper limit is at least this much above the top of the object on which the limit is set (11).big_op_spacing2The baseline of a lower limit is at least this much below the bottom of the object on which the limit is set (17).big_op_spacing3The bottom of an upper limit is at least this much above the top of the object on which the limit is set (20).big_op_spacing4The top of a lower limit is at least this much below the bottom of the object on which the limit is set (60).big_op_spacing5This much vertical space is added above and below limits (10).baseline_sepThe baselines of the rows in a pile or matrix are normally this far apart (140). Usually equal to the sum ofnum1anddenom1.shift_downThe midpoint between the top baseline and the bottom baseline in a matrix or pile is shifted down by this much from the axis (26). Usually equal toaxis_height.column_sepThis much space is added between columns in a matrix (100).matrix_side_sepThis much space is added at each side of a matrix (17).draw_linesIf non-zero,eqndraws lines using thetroff\Descape sequence, rather than the\lescape sequence and the\[ru]special character. Theeqnrcfile sets the default:1onps,html, and the X11 devices, otherwise0.body_heightis the presumed height of an equation above the text baseline;eqnadds any excess as extra pre-vertical line spacing withtroff's\xescape sequence (85).body_depthis the presumed depth of an equation below the text baseline;eqnadds any excess as extra post-vertical line spacing withtroff's\xescape sequence (35).nroffIf non-zero, thenndefinebehaves likedefineandtdefineis ignored, otherwisetdefinebehaves likedefineandndefineis ignored. Theeqnrcfile sets the default:1onascii,latin1,utf8, andcp1047devices, otherwise0.MacrosIn GNUeqn, macros can take arguments. A word defined by any of thedefine,ndefine, ortdefineprimitives followed immediately by a left parenthesis is treated as aparameterizedmacrocall:subsequent tokens up to a matching right parenthesis are treated as comma-separated arguments. In this context only, commas and parentheses also serve as token separators. A macro argument is not terminated by a comma inside parentheses nested within it. In a macro definition,$n, wherenis between 1 and 9 inclusive, is replaced by thenth argument; if there are fewer thannarguments, it is replaced by nothing.PredefinedmacrosGNUeqnsupports the predefined macros offered by AT&Teqn:and,approx,arc,cos,cosh,del,det,dot,dotdot,dyad,exp,for,grad,half,hat,if,inter,Im,inf,int,lim,ln,log,max,min,nothing,partial,prime,prod,Re,sin,sinh,sum,tan,tanh,tilde,times,union,vec,==,!=,+=,->,<-,<<,>>, and “...”. The lowercase classical Greek letters are available asalpha,beta,chi,delta,epsilon,eta,gamma,iota,kappa,lambda,mu,nu,omega,omicron,phi,pi,psi,rho,sigma,tau,theta,upsilon,xi, andzeta. Spell them with an initial capital letter (Alpha) or in full capitals (ALPHA) to obtain uppercase forms. GNUeqnfurther defines the macroscdot,cdots, andutilde(all discussed above),dollar, which sets a dollar sign, andldots, which sets an ellipsis on the text baseline.Fontseqnuses up to three typefaces to set an equation: italic (oblique), roman (upright), and bold. Assign each agrofftypeface with the primitivesgfont,grfont, andgbfont.The defaults are the stylesI,R, andB(applied to the current font family). Thechartypeprimitive (see above) sets a character's type, which determines the face used to set it. The “letter” type is set in italics; others are set in roman. Use theboldprimitive to select an (upright) bold style.gbfontfSelectfas the bold font. This is a GNU extension.gfontfSelectfas the italic font.grfontfSelectfas the roman font. This is a GNU extension.

**Options**

--helpdisplays a usage message, while-vand--versionshow version information; all exit afterward.-CRecognize.EQand.ENeven when followed by a character other than space or newline.-dxySpecify delimitersxfor left andyfor right ends of equations not bracketed by.EQ/.EN.xandyneed not be distinct. Any “delimxy” statements in the source file override this option.-fFis equivalent to “gfontF”.-mnis equivalent to “setminimum_sizen”.-MdirSearchdirforeqnrcbefore those listed in section “Description” above.-NProhibit newlines within delimiters. This option allowseqnto recover better from missing closing delimiters.-pnSet sub- and superscriptsnpoints smaller than the surrounding text. This option is deprecated.eqnnormally sets sub- and superscripts at 70% of the type size of the surrounding text.-rReduce the type size of subscripts at most once relative to the base type size for the equation.-RDon't loadeqnrc.-snis equivalent to “gsizen”. This option is deprecated.-TdevPrepare output for the devicedev. In most cases, the effect of this is to define a macrodevwith a value of1;eqnrcuses this to provide definitions appropriate for the device. However, if the specified driver is “MathML”, the output is MathML markup rather thantroffinput, andeqnrcis not loaded at all. The default output device isps.

**Files**

/usr/share/groff/1.23.0/tmac/eqnrcInitialization file.

**MathML** **mode** **limitations**

MathML is designed on the assumption that it cannot know the exact physical characteristics of the media and devices on which it will be rendered. It does not support control of motions and sizes to the same degreetroffdoes. •eqncustomization parameters have no effect on generated MathML. • Thespecial,up,down,fwd, andbackprimitives cannot be implemented, and yield a MathML “<merror>” message instead. • Thevcenterprimitive is silently ignored, as centering on the math axis is the MathML default. • Characters thateqnsets extra large introffmode—notably the integral sign—may appear too small and need to have their “<mstyle>” wrappers adjusted by hand. As in itstroffmode,eqnin MathML mode leaves the.EQand.ENtokens in place, but emits nothing corresponding todelimdelimiters. They can, however, be recognized as character sequences that begin with “<math>”, end with “</math>”, and do not cross line boundaries.

**Caveats**

Tokens must be double-quoted ineqninput if they are not to be recognized as names of macros or primitives, or if they are to be interpreted bytroff. In particular, short ones, like “pi” and “PI”, can collide withtroffidentifiers. For instance, theeqncommand “gfontPI” does not selectgroff's Palatino italic font for the global italic face; you must use “gfont"PI"” instead. Delimited equations are set at the type size current at the beginning of the input line, not necessarily that immediately preceding the opening delimiter. Unlike TeX,eqndoes not inherently distinguish displayed and inline equation styles; see thesmalloverprimitive above. However, macro packages frequently defineEQandENmacros such that the equation within is displayed. These macros may accept arguments permitting the equation to be labeled or captioned; see the package's documentation.

**Bugs**

eqnabuses terminology—its “equations” can be inequalities, bare expressions, or unintelligible gibberish. But there's no changing it now. Innroffmode, lowercase Greek letters are rendered in roman instead of italic style. In MathML mode, themarkandlineupfeatures don't work. These could, in theory, be implemented with “<maligngroup>” elements. In MathML mode, each digit of a numeric literal gets a separate “<mn></mn>” pair, and decimal points are tagged with “<mo></mo>”. This is allowed by the specification, but inefficient.

**Examples**

We first illustrateeqnusage with a trigonometric identity. .EQ sin ( alpha + beta ) = sin alpha cos beta + cos alpha sin beta .EN It can be convenient to set up delimiters if mathematical content will appear frequently in running text. .EQ delim $$ .EN Having cached a table of logarithms, the property $ln ( x y ) = ln x + ln y$ sped calculations. The quadratic formula illustrates use of fractions and radicals, and affords an opportunity to use the full space token~. .EQ x = { - b ~ \[+-] ~ sqrt { b sup 2 - 4 a c } } over { 2 a } .EN Alternatively, we could define the plus-minus sign as a binary operator. Automatic spacing puts 0.06 em less space on either side of the plus-minus than ~ does, this being the difference between the widths of themedium_spaceparameter used by binary operators and that of the full space. Independently, we can define a macro “frac” for setting fractions. .EQ chartype "binary" \[+-] define frac ! { $1 } over { $2 } ! x = frac(- b \[+-] sqrt { b sup 2 - 4 a c }, 2 a) .EN

**See** **also**

“Typesetting Mathematics—User's Guide” (2nd edition), by Brian W. Kernighan and Lorinda L. Cherry, 1978, AT&T Bell Laboratories Computing Science Technical Report No. 17.TheTeXbook, by Donald E. Knuth, 1984, Addison-Wesley Professional. Appendix G discusses many of the parameters from section “Customization” above in greater detail.groff_char(7), particularly subsections “Logical symbols”, “Mathematical symbols”, and “Greek glyphs”, documents a variety of special character escape sequences useful in mathematical typesetting.groff(1),troff(1),pic(1),groff_font(5)