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