We will not try to describe the language precisely here; interested readers may refer to the appendix for more details. Throughout this section, we will write expressions exactly as they are handed to the typesetting program (hereinafter called ``EQN''), except that we won't show the delimiters that the user types to mark the beginning and end of the expression. The interface between EQN and TROFF is described at the end of this section.
As we said, typing x=y+z+1 should produce , and indeed it does. Variables are made italic, operators and digits become roman, and normal spacings between letters and operators are altered slightly to give a more pleasing appearance.
Input is free-form. Spaces and new lines in the input are used by EQN to separate pieces of the input; they are not used to create space in the output. Thus
Extra white space can be forced into the output by several characters of various sizes. A tilde ``~'' gives a space equal to the normal word spacing in text; a circumflex gives half this much, and a tab charcter spaces to the next tab stop.
Spaces (or tildes, etc.) also serve to delimit pieces of the input. For example, to get
we write
Fractions are specified with the keyword over:
Similarly, subscripts and superscripts are introduced by the keywords sub and sup:
is produced by
More complicated expressions can now be formed with these primitives:
is produced by
The braces convention is an example of the power of using a recursive grammar to define the language. It is part of the language that if a construct can appear in some context, then any expression in braces can also occur in that context.
There is a sqrt operator for making square roots of the appropriate size: ``sqrt a+b'' produces , and
Since large radicals look poor on our typesetter, sqrt is not useful for tall expressions.
Limits on summations, integrals and similar constructions are specified with the keywords from and to. To get
we need only type
Again, the braces indicate just what goes into the from part.
There is a facility for making braces, brackets, parentheses, and vertical bars of the right height, using the keywords left and right:
A left need not have a corresponding right, as we shall see in the next example. Any characters may follow left and right, but generally only various parentheses and bars are meaningful.
Big brackets, etc., are often used with another facility, called piles, which make vertical piles of objects. For example, to get
we can type
Although EQN makes a valiant attempt to use the right sizes and fonts, there are times when the default assumptions are simply not what is wanted. For instance the italic sign in the previous example would conventionally be in roman. Slides and transparencies often require larger characters than normal text. Thus we also provide size and font changing commands: ``size 12 bold {A~x~=~y}'' will produce . Size is followed by a number representing a character size in points. (One point is 1/72 inch; this paper is set in 9 point type.)
If necessary, an input string can be quoted in "...", which turns off grammatical significance, and any font or spacing changes that might otherwise be done on it. Thus we can say
Diacritical marks, long a problem in traditional typesetting, are straightforward:
is made by typing
There are also facilities for globally changing default sizes and fonts, for example for making viewgraphs or for setting chemical equations. The language allows for matrices, and for lining up equations at the same horizontal position.
Finally, there is a definition facility, so a user can say
The EQN preprocessor reads intermixed text and equations, and passes its output to TROFF. Since TROFF uses lines beginning with a period as control words (e.g., ``.ce'' means ``center the next output line''), EQN uses the sequence ``.EQ'' to mark the beginning of an equation and ``.EN'' to mark the end. The ``.EQ'' and ``.EN'' are passed through to TROFF untouched, so they can also be used by a knowledgeable user to center equations, number them automatically, etc. By default, however, ``.EQ'' and ``.EN'' are simply ignored by TROFF, so by default equations are printed in-line.
``.EQ'' and ``.EN'' can be supplemented by TROFF commands as desired; for example, a centered display equation can be produced with the input:
Since it is tedious to type ``.EQ'' and ``.EN'' around very short expressions (single letters, for instance), the user can also define two characters to serve as the left and right delimiters of expressions. These characters are recognized anywhere in subsequent text. For example if the left and right delimiters have both been set to ``#'', the input:
Running a preprocessor is strikingly easy on UNIX. To typeset text stored in file ``f'', one issues the command: