-
Notifications
You must be signed in to change notification settings - Fork 1
/
e4
437 lines (437 loc) · 9.03 KB
/
e4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
.NH
The Language
.PP
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
.UC ``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
.UC EQN
and
.UC TROFF
is described at the end of this section.
.PP
As we said, typing x=y+z+1 should produce $x=y+z+1$,
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.
.PP
Input is free-form.
Spaces and new lines in the input are used by
.UC EQN
to separate pieces of the input;
they are not used to create space in the output.
Thus
.P1
x = y
+ z + 1
.P2
also gives $x=y+z+1$.
Free-form input is easier to type initially;
subsequent editing is also easier,
for an expression may be typed as many short lines.
.PP
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.
.PP
Spaces (or tildes, etc.)
also serve to delimit pieces of the input.
For example, to get
.EQ
f(t) = 2 pi int sin ( omega t )dt
.EN
we write
.P1
f(t) = 2 pi int sin ( omega t )dt
.P2
Here spaces are
.ul
necessary
in the input
to indicate that
.ul
sin, pi, int,
and
.ul
omega
are special, and potentially worth special treatment.
.UC EQN
looks up each such string of characters
in a table, and if appropriate gives it a translation.
In this case,
.ul
pi
and
.ul
omega
become their greek equivalents,
.ul
int
becomes the integral sign
(which must be moved down and enlarged so it looks ``right''),
and
.ul
sin
is made roman, following conventional mathematical practice.
Parentheses, digits and operators are automatically made roman
wherever found.
.PP
Fractions are specified with the keyword
.ul
over:
.P1
a+b over c+d+e = 1
.P2
produces
.EQ
a+b over c+d+e = 1
.EN
.PP
Similarly, subscripts and superscripts are introduced by the keywords
.ul
sub
and
.ul
sup:
.EQ
x sup 2 + y sup 2 = z sup 2
.EN
is produced by
.P1
x sup 2 + y sup 2 = z sup 2
.P2
The spaces after the 2's are necessary to mark the end of
the superscripts;
similarly the keyword
.ul
sup
has to be marked off by spaces or
some equivalent delimiter.
The return to the proper baseline is automatic.
Multiple levels of subscripts or superscripts
are of course allowed:
``x\|\|sup\|\|y\|\|sup\|\|z'' is
$x sup y sup z$.
The construct
``something
.ul
sub
something
.ul
sup
something''
is recognized as a special case,
so
``x sub i sup 2''
is
$x sub i sup 2$ instead of ${x sub i} sup 2$.
.PP
More complicated expressions can now be formed with these
primitives:
.EQ
{partial sup 2 f} over {partial x sup 2} =
x sup 2 over a sup 2 + y sup 2 over b sup 2
.EN
is produced by
.P1
.ce 0
{partial sup 2 f} over {partial x sup 2} =
x sup 2 over a sup 2 + y sup 2 over b sup 2
.P2
Braces {} are used to group objects together;
in this case they indicate unambiguously what goes over what
on the left-hand side of the expression.
The language defines the precedence of
.ul
sup
to be higher than that of
.ul
over,
so
no braces are needed to get the correct association on the right side.
Braces can always be used when in doubt
about precedence.
.PP
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
.ul
any expression
in braces
can also occur in that context.
.PP
There is a
.ul
sqrt
operator for making square roots of the appropriate size:
``sqrt a+b'' produces $sqrt a+b$,
and
.P1
x = {-b +- sqrt{b sup 2 -4ac}} over 2a
.P2
is
.EQ
x={-b +- sqrt{b sup 2 -4ac}} over 2a
.EN
Since large radicals look poor on our typesetter,
.ul
sqrt
is not useful for tall expressions.
.PP
Limits on summations, integrals and similar
constructions are specified with
the keywords
.ul
from
and
.ul
to.
To get
.EQ
sum from i=0 to inf x sub i -> 0
.EN
we need only type
.P1
sum from i=0 to inf x sub i -> 0
.P2
Centering and making the $SIGMA$ big enough and the limits smaller
are all automatic.
The
.ul
from
and
.ul
to
parts are both optional,
and the central part (e.g., the $SIGMA$)
can in fact be anything:
.P1
lim from {x -> pi /2} ( tan~x) = inf
.P2
is
.EQ
lim from {x -> pi /2} ( tan~x) = inf
.EN
Again,
the braces indicate just what goes into the
.ul
from
part.
.PP
There is a facility for making braces, brackets, parentheses, and vertical bars
of the right height, using the keywords
.ul
left
and
.ul
right:
.P1
left [ x+y over 2a right ]~=~1
.P2
makes
.EQ
left [ x+y over 2a right ]~=~1
.EN
A
.ul
left
need not have a corresponding
.ul
right,
as we shall see in the next example.
Any characters may follow
.ul
left
and
.ul
right,
but generally only various parentheses and bars are meaningful.
.PP
Big brackets, etc.,
are often used with another facility,
called
.ul
piles,
which make vertical piles of objects.
For example,
to get
.EQ
sign (x) ~==~ left {
rpile {1 above 0 above -1}
~~lpile {if above if above if}
~~lpile {x>0 above x=0 above x<0}
.EN
we can type
.P1
sign (x) ~==~ left {
rpile {1 above 0 above -1}
~~lpile {if above if above if}
~~lpile {x>0 above x=0 above x<0}
.P2
The construction ``left {''
makes a left brace big enough
to enclose the
``rpile {...}'',
which is a right-justified pile of
``above ... above ...''.
``lpile'' makes a left-justified pile.
There are also centered piles.
Because of the recursive language definition,
a
pile
can contain any number of elements;
any element of a pile can of course
contain piles.
.PP
Although
.UC 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
.ul
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 12 bold{ A~x~=~y}$.
.ul
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.)
.PP
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
.P1
lim~ roman "sup" ~x sub n = 0
.P2
to ensure that the supremum doesn't become a superscript:
.EQ
lim~ roman "sup" ~x sub n = 0
.EN
.PP
Diacritical marks, long a problem in traditional typesetting,
are straightforward:
.EQ
x dot under + x hat + y tilde + X hat + Y dotdot = z+Z bar
.EN
is made by typing
.P1
x dot under + x hat + y tilde
+ X hat + Y dotdot = z+Z bar
.P2
.PP
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.
.PP
Finally, there is a definition facility,
so a user can say
.P1
define name "..."
.P2
at any time in the document;
henceforth, any occurrence of the token ``name''
in an expression
will be expanded into whatever was inside
the double quotes in its definition.
This lets users tailor
the language to their own specifications,
for it is quite possible to redefine
keywords
like
.ul
sup
or
.ul
over.
Section 6 shows an example of definitions.
.PP
The
.UC EQN
preprocessor reads intermixed text and equations,
and passes its output to
.UC TROFF.
Since
.UC TROFF
uses lines beginning with a period as control words
(e.g., ``.ce'' means ``center the next output line''),
.UC 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
.UC 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
.UC TROFF ,
so by default equations are printed in-line.
.PP
``.EQ'' and ``.EN'' can be supplemented by
.UC TROFF
commands as desired;
for example, a centered display equation
can be produced with the input:
.P1
.ce 0
.in 5
.ce
.EQ
x sub i = y sub i ...
.EN
.in 0
.P2
.PP
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:
.P1
Let #x sub i#, #y# and #alpha# be positive
.P2
produces:
.P1
Let $x sub i$, $y$ and $alpha$ be positive
.P2
.PP
Running a preprocessor is strikingly easy on
.UC UNIX.
To typeset
text stored in file
``f\|'',
one issues the command:
.P1
eqn f | troff
.P2
The vertical bar connects the output
of one process
.UC (EQN)
to the input of another
.UC (TROFF) .