Commit | Line | Data |
---|---|---|
8340f87c BJ |
1 | .NH |
2 | The Language | |
3 | .PP | |
4 | We will not try to describe the language precisely here; | |
5 | interested readers may refer to the appendix for more details. | |
6 | Throughout this section, we will write expressions | |
7 | exactly | |
8 | as they are handed to the typesetting program (hereinafter called | |
9 | .UC ``EQN'' ), | |
10 | except that we won't show the delimiters | |
11 | that the user types to mark the beginning and end of the expression. | |
12 | The interface between | |
13 | .UC EQN | |
14 | and | |
15 | .UC TROFF | |
16 | is described at the end of this section. | |
17 | .PP | |
18 | As we said, typing x=y+z+1 should produce $x=y+z+1$, | |
19 | and indeed it does. | |
20 | Variables are made italic, operators and digits become roman, | |
21 | and normal spacings between letters and operators are altered slightly | |
22 | to give a more pleasing appearance. | |
23 | .PP | |
24 | Input is free-form. | |
25 | Spaces and new lines in the input are used by | |
26 | .UC EQN | |
27 | to separate pieces of the input; | |
28 | they are not used to create space in the output. | |
29 | Thus | |
30 | .P1 | |
31 | x = y | |
32 | + z + 1 | |
33 | .P2 | |
34 | also gives $x=y+z+1$. | |
35 | Free-form input is easier to type initially; | |
36 | subsequent editing is also easier, | |
37 | for an expression may be typed as many short lines. | |
38 | .PP | |
39 | Extra white space can be forced into the output by several | |
40 | characters of various sizes. | |
41 | A tilde ``\|~\|'' gives a space equal | |
42 | to the normal word spacing in text; | |
43 | a circumflex gives half this much, | |
44 | and a tab charcter spaces to the next tab stop. | |
45 | .PP | |
46 | Spaces (or tildes, etc.) | |
47 | also serve to delimit pieces of the input. | |
48 | For example, to get | |
49 | .EQ | |
50 | f(t) = 2 pi int sin ( omega t )dt | |
51 | .EN | |
52 | we write | |
53 | .P1 | |
54 | f(t) = 2 pi int sin ( omega t )dt | |
55 | .P2 | |
56 | Here spaces are | |
57 | .ul | |
58 | necessary | |
59 | in the input | |
60 | to indicate that | |
61 | .ul | |
62 | sin, pi, int, | |
63 | and | |
64 | .ul | |
65 | omega | |
66 | are special, and potentially worth special treatment. | |
67 | .UC EQN | |
68 | looks up each such string of characters | |
69 | in a table, and if appropriate gives it a translation. | |
70 | In this case, | |
71 | .ul | |
72 | pi | |
73 | and | |
74 | .ul | |
75 | omega | |
76 | become their greek equivalents, | |
77 | .ul | |
78 | int | |
79 | becomes the integral sign | |
80 | (which must be moved down and enlarged so it looks ``right''), | |
81 | and | |
82 | .ul | |
83 | sin | |
84 | is made roman, following conventional mathematical practice. | |
85 | Parentheses, digits and operators are automatically made roman | |
86 | wherever found. | |
87 | .PP | |
88 | Fractions are specified with the keyword | |
89 | .ul | |
90 | over: | |
91 | .P1 | |
92 | a+b over c+d+e = 1 | |
93 | .P2 | |
94 | produces | |
95 | .EQ | |
96 | a+b over c+d+e = 1 | |
97 | .EN | |
98 | .PP | |
99 | Similarly, subscripts and superscripts are introduced by the keywords | |
100 | .ul | |
101 | sub | |
102 | and | |
103 | .ul | |
104 | sup: | |
105 | .EQ | |
106 | x sup 2 + y sup 2 = z sup 2 | |
107 | .EN | |
108 | is produced by | |
109 | .P1 | |
110 | x sup 2 + y sup 2 = z sup 2 | |
111 | .P2 | |
112 | The spaces after the 2's are necessary to mark the end of | |
113 | the superscripts; | |
114 | similarly the keyword | |
115 | .ul | |
116 | sup | |
117 | has to be marked off by spaces or | |
118 | some equivalent delimiter. | |
119 | The return to the proper baseline is automatic. | |
120 | Multiple levels of subscripts or superscripts | |
121 | are of course allowed: | |
122 | ``x\|\|sup\|\|y\|\|sup\|\|z'' is | |
123 | $x sup y sup z$. | |
124 | The construct | |
125 | ``something | |
126 | .ul | |
127 | sub | |
128 | something | |
129 | .ul | |
130 | sup | |
131 | something'' | |
132 | is recognized as a special case, | |
133 | so | |
134 | ``x sub i sup 2'' | |
135 | is | |
136 | $x sub i sup 2$ instead of ${x sub i} sup 2$. | |
137 | .PP | |
138 | More complicated expressions can now be formed with these | |
139 | primitives: | |
140 | .EQ | |
141 | {partial sup 2 f} over {partial x sup 2} = | |
142 | x sup 2 over a sup 2 + y sup 2 over b sup 2 | |
143 | .EN | |
144 | is produced by | |
145 | .P1 | |
146 | .ce 0 | |
147 | {partial sup 2 f} over {partial x sup 2} = | |
148 | x sup 2 over a sup 2 + y sup 2 over b sup 2 | |
149 | .P2 | |
150 | Braces {} are used to group objects together; | |
151 | in this case they indicate unambiguously what goes over what | |
152 | on the left-hand side of the expression. | |
153 | The language defines the precedence of | |
154 | .ul | |
155 | sup | |
156 | to be higher than that of | |
157 | .ul | |
158 | over, | |
159 | so | |
160 | no braces are needed to get the correct association on the right side. | |
161 | Braces can always be used when in doubt | |
162 | about precedence. | |
163 | .PP | |
164 | The braces convention is an example of the power | |
165 | of using a recursive grammar | |
166 | to define the language. | |
167 | It is part of the language that if a construct can appear | |
168 | in some context, | |
169 | then | |
170 | .ul | |
171 | any expression | |
172 | in braces | |
173 | can also occur in that context. | |
174 | .PP | |
175 | There is a | |
176 | .ul | |
177 | sqrt | |
178 | operator for making square roots of the appropriate size: | |
179 | ``sqrt a+b'' produces $sqrt a+b$, | |
180 | and | |
181 | .P1 | |
182 | x = {-b +- sqrt{b sup 2 -4ac}} over 2a | |
183 | .P2 | |
184 | is | |
185 | .EQ | |
186 | x={-b +- sqrt{b sup 2 -4ac}} over 2a | |
187 | .EN | |
188 | Since large radicals look poor on our typesetter, | |
189 | .ul | |
190 | sqrt | |
191 | is not useful for tall expressions. | |
192 | .PP | |
193 | Content-type: text/html