Commit | Line | Data |
---|---|---|
755c0b0d TL |
1 | .SC "Shorthand for In-line Equations" |
2 | .PP | |
3 | In a mathematical document, | |
4 | it is necessary to follow mathematical conventions | |
5 | not just in display equations, | |
6 | but also in the body of the text, | |
7 | for example by making variable names like $x$ italic. | |
8 | Although this could be done by surrounding the appropriate parts | |
9 | with | |
10 | .UC .EQ | |
11 | and | |
12 | .UC .EN , | |
13 | the continual repetition of | |
14 | .UC .EQ | |
15 | and | |
16 | .UC .EN | |
17 | is a nuisance. | |
18 | Furthermore, with `\(mims', | |
19 | .UC .EQ | |
20 | and | |
21 | .UC .EN | |
22 | imply a displayed equation. | |
23 | .PP | |
24 | .UC EQN | |
25 | provides a shorthand for short in-line expressions. | |
26 | You can define two characters to mark the left and right ends | |
27 | of an in-line equation, and then type expressions right in the middle of text | |
28 | lines. | |
29 | To set both the left and right characters to dollar signs, for example, | |
30 | add to the beginning of your document the three lines | |
31 | .P1 | |
32 | .EQ | |
33 | delim %% | |
34 | .EN | |
35 | .P2 | |
36 | Having done this, you can then say things like | |
37 | .P1 | |
38 | .fi | |
39 | Let %alpha sub i% be the primary variable, | |
40 | and let %beta% be zero. | |
41 | Then we can show that %x sub 1% is %>=0%. | |
42 | .P2 | |
43 | This works as | |
44 | you might expect _ | |
45 | spaces, newlines, and so on are significant | |
46 | in the text, but not in the equation part itself. | |
47 | Multiple equations can occur in a single input line. | |
48 | .PP | |
49 | Enough room is left before and after a line that contains | |
50 | in-line expressions | |
51 | that something like | |
52 | $sum from i=1 to n x sub i$ | |
53 | does not interfere with the lines surrounding it. | |
54 | .PP | |
55 | To turn off the delimiters, | |
56 | .P1 | |
57 | .EQ | |
58 | delim off | |
59 | .EN | |
60 | .P2 | |
61 | Warning: don't use braces, tildes, circumflexes, or double quotes as delimiters _ | |
62 | chaos will result. | |
63 | .SC "Definitions" | |
64 | .PP | |
65 | .UC EQN | |
66 | provides a facility so you can give | |
67 | a frequently-used string of characters a name, | |
68 | and thereafter just type the name instead of the | |
69 | whole string. | |
70 | For example, if the sequence | |
71 | .P1 | |
72 | x sub i sub 1 + y sub i sub 1 | |
73 | .P2 | |
74 | appears repeatedly throughout a paper, | |
75 | you can save re-typing it each time by defining it like this: | |
76 | .P1 2 | |
77 | define xy 'x sub i sub 1 + y sub i sub 1' | |
78 | .P2 | |
79 | This makes | |
80 | .ul | |
81 | xy | |
82 | a shorthand for whatever characters occur between the single quotes | |
83 | in the definition. | |
84 | You can use any character instead of quote to mark the ends of the definition, | |
85 | so long as it doesn't appear inside the definition. | |
86 | .PP | |
87 | Now you can use | |
88 | .ul | |
89 | xy | |
90 | like this: | |
91 | .P1 | |
92 | ^EQ | |
93 | f(x) = xy ... | |
94 | ^EN | |
95 | .P2 | |
96 | and so on. | |
97 | Each occurrence of | |
98 | .ul | |
99 | xy | |
100 | will expand into what it was defined as. | |
101 | Be careful to leave spaces or their equivalent | |
102 | around the name | |
103 | when you actually use it, so | |
104 | .UC EQN | |
105 | will be able to identify it as special. | |
106 | .PP | |
107 | There are several things to watch out for. | |
108 | First, although definitions can use previous definitions, | |
109 | as in | |
110 | .P1 | |
111 | .EQ | |
112 | define xi ' x sub i ' | |
113 | define xi1 ' xi sub 1 ' | |
114 | .EN | |
115 | .P2 | |
116 | .ul | |
117 | don't define something in terms of itself' | |
118 | A favorite error is to say | |
119 | .P1 | |
120 | define X ' roman X ' | |
121 | .P2 | |
122 | This is a guaranteed disaster, | |
123 | since X | |
124 | .ul | |
125 | is | |
126 | now defined in terms of itself. | |
127 | If you say | |
128 | .P1 | |
129 | define X ' roman "X" ' | |
130 | .P2 | |
131 | however, the quotes | |
132 | protect the second X, | |
133 | and everything works fine. | |
134 | .PP | |
135 | .UC EQN | |
136 | keywords can be redefined. | |
137 | You can make | |
138 | / mean | |
139 | .ul | |
140 | over | |
141 | by saying | |
142 | .P1 | |
143 | define / ' over ' | |
144 | .P2 | |
145 | or redefine | |
146 | .ul | |
147 | over | |
148 | as / | |
149 | with | |
150 | .P1 | |
151 | define over ' / ' | |
152 | .P2 | |
153 | .PP | |
154 | If you need different things | |
155 | to print on a terminal and on the typesetter, it is sometimes worth | |
156 | defining a symbol differently in | |
157 | .UC NEQN | |
158 | and | |
159 | .UC EQN . | |
160 | This can be done with | |
161 | .ul | |
162 | ndefine | |
163 | and | |
164 | .ul | |
165 | tdefine. | |
166 | A definition made with | |
167 | .ul | |
168 | ndefine | |
169 | only takes effect if you are running | |
170 | .UC NEQN ; | |
171 | if you use | |
172 | .ul | |
173 | tdefine, | |
174 | the definition only applies for | |
175 | .UC EQN . | |
176 | Names defined with plain | |
177 | .ul | |
178 | define | |
179 | apply to both | |
180 | .UC EQN | |
181 | and | |
182 | .UC NEQN . | |
183 | .SC "Local Motions" | |
184 | .PP | |
185 | Although | |
186 | .UC EQN | |
187 | tries to get most things at the right place on the paper, | |
188 | it isn't perfect, and occasionally you will need to tune | |
189 | the output to make it just right. | |
190 | Small extra horizontal spaces can be obtained with | |
191 | tilde and circumflex. | |
192 | You can also say | |
193 | .ul | |
194 | back n | |
195 | and | |
196 | .ul | |
197 | fwd n | |
198 | to move small amounts horizontally. | |
199 | .ul | |
200 | n | |
201 | is how far to move in 1/100's of an em (an em is about the width | |
202 | of the letter | |
203 | `m'.) | |
204 | Thus | |
205 | .ul | |
206 | back 50 | |
207 | moves back about half the width of an m. | |
208 | Similarly you can move things up or down with | |
209 | .ul | |
210 | up n | |
211 | and | |
212 | .ul | |
213 | down n. | |
214 | As with | |
215 | .ul | |
216 | sub | |
217 | or | |
218 | .ul | |
219 | sup, | |
220 | the local motions affect the next thing in the input, | |
221 | and this can be something arbitrarily complicated if it is enclosed | |
222 | in braces. |