-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathg2
545 lines (545 loc) · 9.43 KB
/
g2
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
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
.SC "Size and Font Changes"
.PP
By default, equations are set in 10-point type (the same size as this guide),
with standard mathematical conventions
to determine what characters are in roman and what in italic.
Although
.UC EQN
makes a valiant attempt to use
esthetically pleasing sizes and fonts,
it is not perfect.
To change sizes and fonts, use
.ul
size n
and
.ul
roman, italic,
.ul
bold
and
.ul
fat.
Like
.ul
sub
and
.ul
sup,
size
and font changes affect only the thing that follows
them, and revert to the normal situation
at the end of it. Thus
.P1
bold x y
.P2
is
.EQ
bold x y
.EN
and
.P1
size 14 bold x = y +
size 14 {alpha + beta}
.P2
gives
.EQ
size 14 bold x = y +
size 14 {alpha + beta}
.EN
As always, you can use braces if you want to affect something
more complicated than a single letter.
For example, you can change the size of an entire equation by
.P1
size 12 { ... }
.P2
.PP
Legal sizes which may follow
.ul
size
are
6, 7, 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 28, 36.
You can also change the size
.ul
by
a given amount;
for example, you can say
.ul
size~+2
to make the size two points bigger,
or
.ul
size~\(mi3
to make it three points smaller.
This has the advantage that you don't have
to know what the current size is.
.PP
If you are using fonts other than roman, italic and bold,
you can say
.ul
font X
where
.ul
X
is a one character
.UC TROFF
name or number for the font.
Since
.UC EQN
is tuned for roman, italic and bold,
other fonts may not give quite as good an appearance.
.PP
The
.ul
fat
operation takes the current font and widens it by overstriking:
.ul
fat\ grad
is
$fat grad$ and
.ul
fat {x sub i}
is
$fat {x sub i}$.
.PP
If an entire document is to be in a non-standard size
or font, it is a severe nuisance
to have to write out a size and font change for each
equation.
Accordingly, you can set a ``global'' size or font
which thereafter affects all equations.
At the beginning of any equation, you might say, for instance,
.P1
^EQ
gsize 16
gfont R
...
^EN
.P2
to set the size to 16 and the font to roman thereafter.
In place of R, you can use any of the
.UC TROFF
font names.
The size after
.ul
gsize
can be a relative change with + or \(mi.
.PP
Generally,
.ul
gsize
and
.ul
gfont
will appear at the beginning of a document
but they can also appear
thoughout a document: the global font and size
can be changed as often as needed.
For example, in a footnote\(dd
.FS
\(ddLike this one, in which we have a
$gsize -2$few random
expressions like $x sub i$ and $pi sup 2$.
The sizes for these were set by the command
.ul
gsize~\(mi2.
.FE $gsize +2$
you will typically want the size of equations to match
the size of the footnote text, which is two points smaller
than the main text.
Don't forget to reset the global size
at the end of the footnote.
.SC "Diacritical Marks"
.PP
To get funny marks on top of letters,
there are several words:
.P1
.tr ^^
.tr ~~
.ta 1i
x dot $x dot$
x dotdot $x dotdot$
x hat $x hat$
x tilde $x tilde$
x vec $x vec$
x dyad $x dyad$
x bar $x bar$
x under $x under$
.P2
The diacritical mark is placed at the right height.
The
.ul
bar
and
.ul
under
are made the right length for the entire construct,
as in $x+y+z bar$;
other marks are centered.
.SC "Quoted Text"
.PP
Any input entirely within quotes (\|"..."\|)
is not subject to any of the font changes and spacing
adjustments normally done by the equation setter.
This provides a way to do your own spacing and adjusting if needed:
.KS
.P1
italic "sin(x)" + sin (x)
.P2
.KE
is
.EQ
italic "sin(x)" + sin (x)
.EN
.PP
Quotes are also used to get braces and other
.UC EQN
keywords printed:
.P1
"{ size alpha }"
.P2
is
.EQ
"{ size alpha }"
.EN
and
.P1
roman "{ size alpha }"
.P2
is
.EQ
roman "{ size alpha }"
.EN
.PP
The construction "" is often used as a place-holder
when grammatically
.UC EQN
needs something, but you don't actually want anything in your output.
For example, to make
$"" sup 2 roman He$,
you can't just type
.ul
sup 2 roman He
because a
.ul
sup
has to be a superscript
.ul
on
something.
Thus you must say
.P1
"" sup 2 roman He
.P2
.PP
To get a literal quote
use ``\\"''.
.UC TROFF
characters like
.ul
\e(bs
can appear unquoted, but more complicated things like
horizontal and vertical motions with
.ul
\eh
and
.ul
\ev
should
always
be quoted.
(If you've never heard of
.ul
\\h
and
.ul
\\v,
ignore this section.)
.SC "Lining Up Equations"
.PP
Sometimes it's necessary to line up a series of equations
at some horizontal position, often at an equals sign.
This is done with two operations called
.ul
mark
and
.ul
lineup.
.PP
The word
.ul
mark
may appear once at any place in an equation.
It remembers the horizontal position where it appeared.
Successive equations can contain one occurrence of the word
.ul
lineup.
The place where
.ul
lineup
appears is made to line up
with the place marked by the previous
.ul
mark
if at all possible.
Thus, for example,
you can say
.KS
.P1
^EQ I
x+y mark = z
^EN
^EQ I
x lineup = 1
^EN
.P2
to produce
.EQ I
x+y mark = z
.EN
.EQ I
x lineup = 1
.EN
.KE
For reasons too complicated to talk about,
when you use
.UC EQN
and
`\(mims',
use either
.UC .EQ\ I
or
.UC .EQ\ L .
mark
and
.ul
lineup
don't work with centered equations.
Also bear in mind that
.ul
mark
doesn't look ahead;
.P1
x mark =1
...
x+y lineup =z
.P2
isn't going to work, because there isn't room
for the
.ul
x+y
part after the
.ul
mark
remembers where the
.ul
x
is.
.SC "Big Brackets, Etc."
.PP
.tr ~
To get big brackets [~],
braces {~}, parentheses (~), and bars |~|
around things, use the
.ul
left
and
.ul
right
commands:
.tr ~~
.P1
left { a over b + 1 right }
~=~ left ( c over d right )
+ left [ e right ]
.P2
is
.EQ
left { a over b + 1 right } ~=~ left ( c over d right ) + left [ e right ]
.EN
The resulting brackets are made big enough to cover whatever they enclose.
Other characters can be used besides these,
but the are not likely to look very good.
One exception is the
.ul
floor
and
.ul
ceiling
characters:
.P1
left floor x over y right floor
<= left ceiling a over b right ceiling
.P2
produces
.EQ
left floor x over y right floor
<= left ceiling a over b right ceiling
.EN
.PP
Several warnings about brackets are in order.
First, braces are typically bigger than brackets and parentheses,
because they are made up of three, five, seven, etc., pieces,
while brackets can be made up of two, three, etc.
Second, big left and right parentheses often look poor,
because the character set is poorly designed.
.PP
The
.ul
right
part may be omitted:
a ``left something'' need not have a
corresponding
``right
something''.
If the
.ul
right
part is omitted,
put braces around the thing you want the left bracket
to encompass.
Otherwise, the resulting brackets may be too large.
.PP
If you want to omit the
.ul
left
part, things are more complicated,
because technically you can't have a
.ul
right
without a corresponding
.ul
left.
Instead you have to say
.P1
left "" ..... right )
.P2
for example.
The
.ul
left ""
means a ``left nothing''.
This satisfies the rules without hurting your output.
.SC "Piles"
.PP
There is a general facility for making vertical piles
of things; it comes in several flavors.
For example:
.P1
.tr ~~
A ~=~ left [
pile { a above b above c }
~~ pile { x above y above z }
right ]
.P2
will make
.\" Cheat #1: AT&T eqn stacked piles more tightly than GNU eqn.
.EQ
set baseline_sep 1v
A ~=~ left [
pile { a above b above c } ~~ pile { x above y above z }
right ]
.EN
.\" Reset equation baseline separation to the default, which is not
.\" documented anywhere and has no syntactical access. :-/
.EQ
set baseline_sep 140
.EN
The elements of the pile (there can be as many as you want)
are centered one above another, at the right height for
most purposes.
The keyword
.ul
above
is used to separate the pieces;
braces are used around the entire list.
The elements of a pile can be as complicated as needed, even containing more piles.
.PP
Three other forms of pile exist:
.ul
lpile
makes a pile with the elements left-justified;
.ul
rpile
makes a right-justified pile;
and
.ul
cpile
makes a centered pile, just like
.ul
pile.
The vertical spacing between the pieces
is somewhat larger for
.ul
l-,
.ul
r-
and
.ul
cpiles
than it is for ordinary piles.
.\" Cheat #2: Shrink the display distance a bit to fit this display on
.\" the page.
.nr DD -0.25v
.P1 2
roman sign (x)~=~
left {
lpile {1 above 0 above -1}
~~ lpile
{if~x>0 above if~x=0 above if~x<0}
.P2
.nr DD +0.25v
makes
.EQ
roman sign (x)~=~
left {
lpile {1 above 0 above -1}
~~ lpile
{if~x>0 above if~x=0 above if~x<0}
.EN
Notice the left brace
without a matching right one.
.SC Matrices
.PP
It is also possible to make matrices.
For example, to make
a neat array like
.EQ
matrix {
ccol { x sub i above y sub i }
ccol { x sup 2 above y sup 2 }
}
.EN
you have to type
.P1
matrix {
ccol { x sub i above y sub i }
ccol { x sup 2 above y sup 2 }
}
.P2
This produces a matrix with
two centered columns.
The elements of the columns are then listed just as for a pile,
each element separated by the word
.ul
above.
You can also use
.ul
lcol
or
.ul
rcol
to left or right adjust columns.
Each column can be separately adjusted,
and there can be as many columns as you like.
.PP
The reason for using a matrix instead of two adjacent piles, by the way,
is that if the elements of the piles don't all have the same height,
they won't line up properly.
A matrix forces them to line up,
because it looks at the entire structure before deciding what
spacing to use.
.PP
A word of warning about matrices _
.ul
each column must have the same number of elements in it.
The world will end if you get this wrong.