aboutsummaryrefslogtreecommitdiffstats
path: root/doc/user/equ_symb
blob: f56eca2a16c4178741812fdfdb1ba3b3b9ca41bc (plain) (blame)
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
@Section
   @Title { Symbols }
   @Tag { symbols }
@Begin
@PP
@Code "@Eq" prints characters in the fonts appropriate for mathematics:
@ID {
@Code "x - 2"
|7ct
@Eq { x-2 }
}
Here @Eq { x } is in Italic, @Eq { 2 } is in Roman, and @Eq { minus } is
from the Symbol font.  The character @Code "-" is a @I symbol which
stands for @Eq {minus}, and @Code "2" is also a symbol, standing for
@Eq { 2 }.  @Code "@Eq" includes a vast number of symbols:
@ID {
@Code "Omega delta int partial club"
|7ct
@Eq { Omega delta int partial club }
}
The summary at the end of this chapter has the complete list.
@PP
Symbols whose names are made from letters should be separated from each
other by at least one space or end of line, as was done above, or else
@Code "@Eq" will become confused:
@ID {
@Code "Omegadelta"
|7ct
@Eq { Omegadelta }
}
Symbols whose names are made from digits and punctuation characters can,
however, be run together with each other and with symbols made from
letters:
@ID {
@Code "Omega-delta<=2"
|7ct
@Eq { Omega-delta<=2 }
}
This rule applies throughout Lout (Section {@NumberOf spaces}).
@PP
Some symbols join objects together in mathematical ways:
@ID {
@Code "x sub 2"
|7ct
@Eq { x sub 2 }
}
Here the @Code "sub" symbol has taken the object just to its left, and
sub. @Index { @Code "sub" in equations }
the object just to its right, and joined them into one object in the
form of a subscript.  The two objects are called the left and right
parameters of {@Code "sub"}, and they may be arbitrary Lout objects.
@PP
Other symbols of a similar kind include {@Code "sup"} for
sup. @Index { @Code "sup" in equations }
superscripting, @Code "over" for built-up fractions, and @Code "from"
over.eq. @Index { @Code "over" in equations }
from. @Index { @Code "from" in equations }
to. @Index { @Code "to" in equations }
and @Code "to" for the lower and upper limits of sums, products,
etc.  These symbols may be used together to produce complicated
equations very easily:
@ID {
@Code {
"big sum from i=0 to n r sup i"
"= {r sup n+1 - 1} over r-1"
}
||7ct
@Eq { big sum from i=0 to n r sup i
= {r sup n+1 - 1} over r-1
}
}
Here @Code "sum" is just the @Eq { summation } symbol; @Code "from" and
@Code "to" do all the work of placing the limits.  They are quite
independent, so either or both may be omitted.  To get a superscript
directly over a subscript, use the @Code "supp" and @Code "on" symbols:
supp. @Index { @Code "supp" in equations }
on. @Index { @Code "on" in equations }
@ID {
@Code "A supp b on a"
|7ct
@Eq { A supp b on a }
}
These two symbols should always be used together as shown.
@PP
Sometimes a subscript appears to be too far to the right, owing to
the slope of italic letters: in @Eq { W sub n }, for example.  You
can fix this by using `tucked' subscripts, like this:
@IndentedList
@LI {
@Code "W tsub n"
|7ct
@Eq { W tsub n }
}
@LI {
@Code "W supp b ton a"
|7ct
@Eq { W supp b ton a }
}
@EndList
The @Code "tsub" and @Code "ton" symbols are exactly like @Code "sub"
and @Code "on" except for this tucking-in effect.  However, the
@Code "sub" symbol itself does a certain amount of tucking in; the
amount is determined by kerning information in the font files and
so is sensitive to the shape of the letters.
@PP
As usual in Lout, braces are used to group something into an indivisible
object.  Leaving them out creates ambiguities:
@ID @Code "a  sup  b  over  c"
There are two possible interpretations for this:
@IndentedList
@LI {
@Code "{a  sup  b}  over  c"
|7ct
@Eq {  {a  sup  b}  over  c }
}
@LI {
@Code "a  sup  {b  over  c}"
|7ct
@Eq {  a  sup  {b  over  c} }
}
@EndList
@Code "@Eq" chooses between them in the following way.  Every symbol that
takes a parameter also has a {@I precedence}, which is a number.  For
example, @Code "sup" has precedence 60 and @Code "over" has precedence
54.  The symbol with the highest precedence wins the object lying between
them, so in the above case the first interpretation is chosen.  If two
symbols of equal precedence compete for an object, the association is
towards the left:
@ID {
@Code "a sup b sub 2"
|7ct
@Eq { a sup b sub 2 }
}
In this case it is more probable that the following right association
was actually wanted:
@ID {
@Code "a sup { b sub 2 }"
|7ct
@Eq { a sup { b sub 2 } }
}
When in doubt, use braces to make the grouping clear.
@PP
White space between two objects is considered to be a symbol with
precedence 7, which is lower than the precedence of any @Code "@Eq"
symbol; but if the two objects are immediately adjacent and neither is
enclosed in braces the precedence is 102, which is higher than the
precedence of any @Code "@Eq" symbol.  Compare these three examples:
@IL
@LI {
@Code "big sum from i=0 to n"
|7ct
@Eq {  big sum from i=0 to n }
}
@LI {
@Code "big sum from {i = 0} to n"
|7ct
@Eq {  big sum from {i = 0} to n }
}
@LI {
@Code "big sum from i = 0 to n"
|7ct
@Eq {  big sum from i = 0 to n }
}
@EL
and you will see that some care is needed on this point.  Braces can
always be used to override precedence and associativity, and when in
doubt the easiest course is to insert them.  Although Lout allows
symbols to associate towards the left or right, @Code "@Eq" chooses
to have only left associative symbols.  The summary at the end of this
chapter gives the precedence of every symbol.
@PP
The @Code matrix symbol {@PageMark matrix} builds an array of objects:
matrix. @Index { @Code "matrix" in equations }
@ID {
@Code {
"matrix"
"   atleft { blpar }"
"   atright { brpar }"
"{"
"  row col x sup 2 col y sup 2 col z sup 2"
"  row col x col y col z"
"  row col 1 col 1 col 1"
"}"
}
||9ct
@Eq {
matrix
   atleft { blpar }
   atright { brpar }
{
  row col x sup 2 col y sup 2 col z sup 2
  row col x col y col z
  row col 1 col 1 col 1
}
}
}
The @Code atleft and @Code atright options place vertically scaled
versions of their values at each side; if either is omitted the value
is taken to be an empty object of zero width by default.  Although
we have used @Code blpar and @Code brpar here, since the options are
vertically scaled to the correct size some people prefer simply
@ID @OneRow @Code {
"matrix"
"   atleft { ( }"
"   atright { ) }"
}
The right parameter of @Code matrix is the array itself.  It must be
enclosed in braces, and it is a sequence of rows introduced by
@Code row symbols; each row is a sequence of objects introduced by
@Code col symbols.
@FootNote {
Older versions of Lout use different symbols, {@Code "above"} and
{@Code "nextcol"}, at this point.  For backward compatibility these
symbols are still available, but they are obsolete and no longer documented.
}
The @Code row and @Code col symbols have low precedence, but not
as low as white space between two objects.  Therefore, unless the
entries in the array are very simple, it is safest to enclose each of
them in braces.
@PP
Entries built with the @Code col symbol have their objects centred in
the column.  Also available are @Code lcol for left-justified entries,
@Code ccol meaning the same as {@Code col}, @Code rcol for
right-justified entries, and @Code mcol for alignment along column
marks.  Each column may contain entries of different kinds, except
that @Code mcol does not work well with any other sort.
@PP
When several matrices appear side by side, slight differences in height
can cause an unsightly appearance:
@ID @Eq {
matrix
   atleft { ( }
   atright { ) }
{
   row col a sub 11 col a sub 12
   row col a sub 21 col a sub 22
}
matrix
   atleft { ( }
   atright { ) }
{
   row col b sub 11 col b sub 12
   row col b sub 21 col b sub 22
}
=
matrix
   atleft { ( }
   atright { ) }
{
   row col c sub 11 col c sub 12
   row col c sub 21 col c sub 22
}
}
To assist in resolving this problem, the @Code "matrix" symbol has
a @Code "strut" option, which causes a strut to be inserted into
every row, guaranteeing that every row has height at least equal
to the height of the strut.  By using
@ID @Code {
"matrix"
"    strut { Yes }"
"..."
}
in each of the three matrices above, the result is improved to
@ID @Eq {
matrix
   atleft { ( }
   atright { ) }
   strut { Yes }
{
   row col a sub 11 col a sub 12
   row col a sub 21 col a sub 22
}
matrix
   atleft { ( }
   atright { ) }
   strut { Yes }
{
   row col b sub 11 col b sub 12
   row col b sub 21 col b sub 22
}
=
matrix
   atleft { ( }
   atright { ) }
   strut { Yes }
{
   row col c sub 11 col c sub 12
   row col c sub 21 col c sub 22
}
}
By default, the strut has height @Code "0.5f" (half the current font
size) both above and below the axis of the row.  This can be changed
by giving any length as the value of the @Code "strut" option:
@Code "strut { 2.0c }" for two centimetres above and below
the axis, and so on.
@PP
Some symbols have been added which produce `matrices' with commonly needed
@Code atleft and @Code atright options already set for you.  Here are
these symbols, on the left, with the equivalent @Code matrix symbol
and, on the right, the result produced:
@ID @Tab
    @Fmta { @Col @Code A ! @Col ! @Col @Code B ! @Col ! @Col C }
{
@Rowa
    A { "pmatrix" }
    B { "matrix atleft { ( } atright { ) } { M }" }
    C { @Eq { pmatrix { M } } }
@Rowa
    A { "bmatrix" }
    B { "matrix atleft { blbrack } atright { brbrack } { M }" }
    C { @Eq { bmatrix { M } } }
@Rowa
    A { "brmatrix" }
    B { "matrix atleft { blbrace } atright { brbrace } { M }" }
    C { @Eq { brmatrix { M } } }
@Rowa
    A { "fmatrix" }
    B { "matrix atleft { blfloor } atright { brfloor } { M }" }
    C { @Eq { fmatrix { M } } }
@Rowa
    A { "cmatrix" }
    B { "matrix atleft { blceil } atright { brceil } { M }" }
    C { @Eq { cmatrix { M } } }
@Rowa
    A { "amatrix" }
    B { "matrix atleft { blangle } atright { brangle } { M }" }
    C { @Eq { amatrix { M } } }
}
For example:
@ID {
@Code {
"fmatrix { (n+1) over 2 }"
}
|7ct
@Eq {
fmatrix { (n+1) over 2 }
}
}
As this example shows, these symbols are very useful for getting large
scaled delimiters around things that aren't necessarily matrices at all.
@PP
Each of the @Code "@Eq" symbols that takes parameters also has a @Code gap
option, which controls the amount of space inserted by the symbol:
@IL
@LI {
@Code "x over y"
|7ct
@Eq { x over y }
}
@LI {
6c @Wide @Code "x over gap { 3p } y"
|7ct
@Eq { x over gap { 3p } y }
}
@EL
@Code "@Eq" usually gets the spacing right without help.
@End @Section