Debian Codegraph @

texmf-dist/doc/otherformats/texsis/base/TXSeqns.doc

raw
1 %% file: TXSeqns.doc - Equations - TeXsis version 2.18
2 %% @(#) $Id: TXSeqns.doc,v 18.2 2000/05/17 00:19:46 myers Exp $
3 %======================================================================*
4 % (C) Copyright 1989, 1992 by Eric Myers and Frank E. Paige
5 % This file is a part of TeXsis. Distribution and/or modifications
6 % are allowed under the terms of the LaTeX Project Public License (LPPL).
7 % See the file COPYING or ftp://ftp.texsis.org/texsis/LPPL
8 %======================================================================*
9 \ifx\undefined\meta\texsis\input TXSdocM.doc\draft\fi
10
11 \section{Equations \label{sect.eqns}}
12
13 Plain \TeX\ was designed to make it easy to typeset equations
14 and mathematical formulae. \TeXsis\ provides additional features
15 that make the job even easier. Among these are the automatic
16 numbering of equations (with the ability to refer to numbered equations
17 by symbolic labels), automatic sizing of parentheses, and a
18 collection of special symbols which are often used by physicists.
19
20 \subsection{Equation Numbering \label{sect.eqno}}%
21 In Plain \TeX\ equation numbers are added to displayed
22 equations with the \cs{eqno} command, as described in Chapter~19 of
23 \TeXbook. For example, typing
24 \index{equations!numbering}
25 \TeXexample
26 $$ E=mc^2. \eqno (47) $$
27 |endTeXexample
28 will produce
29 \offparens
30 $$
31 E = mc^2 \eqno (47)
32 $$
33 With \TeXsis\ the procedure for getting
34 automatically numbered equations is similar, except that you use
35 \CS{EQN} instead of \cs{eqno}, and what follows this (up to the
36 ``|$$|'') is not used as the number of the equation, but as an
37 internal {\it label}\, for the equation. For example, if you had
38 already used |\EQN| to create three numbered equations, then
39 typing
40 \eqnum=3
41 \TeXexample
42 $$ \vec F = -{G_N Mm \over r^2} \, \hat r
43 \EQN Newton $$
44 |endTeXexample
45 would produce
46 $$
47 \vec F = -{G_N Mm \over r^2} \, \hat r
48 \EQN Newton
49 $$
50 \TeXsis\ automatically assigns the next available equation number to
51 the equation and prints this number on the right, in parentheses.
52 The equations that follow the one above would be numbered 4.5,
53 4.6, and so on.
54
55 The purpose of the "label" after the |\EQN| is to let you
56 refer to the equation in the text without knowing the equation
57 number that has been assigned to it. For example, to refer to
58 \Eq{Newton} above, which has the label ``Newton'', you might type
59 \index{equations!labeling}
60 \TeXexample
61 The dependence of the force on the inverse square of the distance
62 can be seen in \Eq{Newton}.
63 |endTeXexample
64 This would be printed as:
65 \example
66 The dependence of the force on the inverse square of the distance
67 can be seen in \Eq{Newton}.
68 \endexample
69 The control sequence \CS{Eq}\arg{label} gives the same result
70 as typing "|Eq.~(|$nn$|)|", where $nn$ is the appropriate
71 equation number for the given label. Two similar control
72 words allow you to refer to a range of equations, or to refer to
73 an equation simply by number, without the preceding "|Eq.~|."
74 Typing \CS{Eqs}\arg{label} produces "Eqs.~($nn$)", while
75 \CS{Ep}\arg{label} gives just the equation number associated
76 with the label, enclosed in parentheses. Thus typing
77 \TeXexample
78 The class of metrics defined by \Eqs{cond-1} through
79 \Ep{cond-5} can all be shown to satisfy inequality
80 \Ep{triangle}, as well as the condition in \Eq{Killing}.
81 |endTeXexample
82 would produce output something like
83 \example
84 The class of metrics defined by Eqs.~(14) through
85 (19) can all be shown to satisfy inequality
86 (23), as well as the condition in Eq.~(7).
87 \endexample
88
89 Almost any sequence of characters can be used as a "label" for
90 an equation. This includes letters, numbers, and punctuation
91 marks, but it is best to avoid \TeX's special characters, such as
92 |\|, |&|, |}|, |{|, |$|, |_|, and |^|. Spaces may be included
93 but will be ignored, and there {\sl is} a difference between
94 uppercase and lowercase letters. Also, the semicolon (|;|) is
95 reserved for a special purpose, which is described below.
96
97 You may want to give equations "names," as in the example
98 called "Newton" above, or you can give the equations labels that
99 are numbers. This is the best thing to do if the equations in
100 the original manuscript already have numbers, but if you do this
101 then you should be sure to remember that the internal label and
102 the number which is printed (the ``external'' number) are not
103 necessarily the same. If the equation {\it labeled} ``15'' is
104 the fifteenth equation in the document then it will also be
105 equation number 15, but if you move the equation around in the
106 file so that it is the sixth equation in the document it will be
107 printed as equation 6, even though it has the label ``15''.
108
109 If you have a heavily edited document and the arrangement of
110 the numbers and labels gets confusing there is a useful aid to
111 help straighten things out. If you say
112 \example
113 \CS{eqnotracetrue}
114 \endexample
115 then the equation numbers will be printed as usual, but with the label
116 appearing next to it in the right margin in square brackets.
117 For example, the equation
118 \TeXexample
119 $$
120 (i\gamma^\mu \partial_\mu - m)\psi (x) = 0
121 \EQN Dirac $$
122 |endTeXexample
123 when printed with |\eqnotracetrue| would appear as:
124 \begingroup\eqnotracetrue
125 $$
126 (i\gamma^\mu \partial_\mu - m)\psi (x) = 0
127 \EQN Dirac$$
128 \endgroup
129 Since the label appears in the margin the spacing of your document
130 remains exactly the same.
131 Obviously you would not print the final copy of the document this way,
132 but it can be very useful for editing. You can turn off this
133 equation tracing feature anytime by saying \cs{eqnotracefalse}. If you
134 say \cs{draft} at the beginning of your document then the equation
135 tracing will be turned on automatically (along with some other useful
136 features).
137 \index{equations!labeling}
138
139 \bigskip
140
141 Sometimes when several equations are closely related you will
142 want to give the whole set the same equation number. To distinguish
143 separate formulae in such a group you then generally add a letter to
144 the number. You might, for example, have the equation
145 \index{equations!multiple}
146 $$
147 J^2\ket{j,m} = j(j+1) \ket{j,m} \EQN eigen;a
148 $$
149 and then a short while later you might have the related equation
150 $$
151 J_z\ket{j,m} = m \ket{j,m} \EQN eigen;b
152 $$
153 These may be referred to together as \Eqs{eigen} or may be
154 referred to separately as \Eqs{eigen;a} and \Ep{eigen;b}. To get
155 an equation number with a letter in it you still use \CS{EQN}, but
156 you add the appropriate letter to the end of the label, separated
157 {from} the label by a semicolon. The equations above were created
158 by typing:
159 \TeXexample
160 $$
161 J^2\ket{j,m} = j(j+1) \ket{j,m} \EQN eigen;a
162 $$
163 |endTeXexample
164 and
165 \TeXexample
166 $$
167 J_z\ket{j,m} = m \ket{j,m} \EQN eigen;b
168 $$
169 |endTeXexample
170 The semicolon is not printed --- it is just used to separate the
171 letter from the label. If the letter is ``a'' then the next
172 available equation number is used, as usual, but if the letter is
173 anything else then the equation number is not incremented and
174 instead the number from the previous equation is used. You can
175 use any sequence of letters you like, although it is usually best
176 to use ``a,b,c$\ldots$'' for consecutive equations.
177
178 To refer to equations that have both numbers and letters you
179 can either use the letter to pick out a specific equation, or
180 simply leave out the letter and use the label to refer to the
181 whole set together. You can use either \CS{Eq} or \CS{Eqs} to do
182 this. For example, the sentence after \Eq{eigen;b} above was
183 created by typing
184 \TeXexample
185 These may be referred to together as \Eqs{eigen}
186 or may be referred to separately as
187 \Eqs{eigen;a} and \Ep{eigen;b}.
188 |endTeXexample
189 \index{equations!multiple}
190
191 \bigskip
192
193 You will eventually encounter an equation that is so long that
194 it has to be broken up into several lines, or you will want to
195 print several equations together, lined up by their "$=$" signs.
196 In plain \TeX\ you would use |\eqalign| to display these kinds of
197 equations, or |\eqalignno| to display them with equation numbers.
198 With \TeXsis\ you should use \CS{EQNalign} in place of
199 \cs{eqalign} or \cs{eqalignno}
200 to get automatically assigned equation numbers in aligned
201 equations. As in plain \TeX, the alignment of the
202 equations is controlled by |&| and |\cr|. An equation number is
203 assigned to a particular line by putting |\EQN| followed by a
204 label on that line, before the |\cr|. The label is everything
205 {from} the |\EQN| up to the |\cr|. For example,
206 \index{equations!alignment}
207 \TeXexample
208 |smalltt$$
209 \EQNalign{
210 {dp \over dt} &= - {\partial H \over \partial q}
211 \EQN Hamilton-1 \cr
212 {dq \over dt} &= {\partial H \over \partial p}
213 \EQN Hamilton-2 \cr}
214 $$
215 |endTeXexample
216 produces the two aligned and numbered equations
217 $$
218 \EQNalign{
219 {dp \over dt} &= - {\partial H \over \partial q} \EQN Hamilton-1 \cr
220 {dq \over dt} &= {\partial H \over \partial p} \EQN Hamilton-2 \cr}
221 $$
222
223 \cs{EQNalign} can be used both for typing multi-part equations or for
224 splitting an equation which is too long to fit on a single line.
225 However, when splitting a single long equation into several lines it may
226 actually be better to use |$$\eqalign{|\meta{formula}|}| followed by
227 |\EQN| \meta{label}|$$|. For example, in
228 $$
229 \eqalign{
230 {\cal L}_{NC} &= {-g \over 2\cos\theta_W} \sum_i
231 \bar\psi_i [ (t_{3,i}-2Q_i\sin^2\theta_W) \gamma_\mu
232 - t_{3,i}\gamma_\mu\gamma_5 ]\psi_i Z^\mu \cr
233 &\quad - e \sum_i Q_i \bar\psi_i \gamma_\mu \psi_i A^\mu \cr}
234 \EQN{NC}
235 $$
236 the equation number is centered between the two lines of the equation,
237 which looks better.
238 This equation was produced using \cs{eqalign} by typing:
239 \TeXexample
240 |smalltt$$
241 \eqalign{
242 {\cal L}_{NC} &= {-g \over 2\cos\theta_W} \sum_i
243 \bar\psi_i [ (t_{3,i}-2Q_i\sin^2\theta_W) \gamma_\mu
244 - t_{3,i}\gamma_\mu\gamma_5 ]\psi_i Z^\mu \cr
245 &\quad - e \sum_i Q_i \bar\psi_i \gamma_\mu \psi_i A^\mu \cr}
246 \EQN{NC}
247 $$
248 |endTeXexample
249
250 Closely related equations can be displayed together with the
251 same equation number by following the label with a semicolon and
252 a letter, as already described above. For example, the set of
253 equations,
254 $$
255 \EQNalign{
256 \nabla \cdot \vec D &= 4 \pi \rho \EQN EM;a \cr
257 \nabla \times \vec E &=
258 - {1 \over c} {\partial \vec B \over \partial t}
259 \EQN EM;b \cr
260 \nabla \cdot \vec B &= 0 \EQN EM;c \cr
261 \nabla \times \vec H &= {4 \pi \over c} \vec J
262 + {1 \over c} {\partial \vec D \over \partial t}
263 \EQN EM;d \cr}
264 $$
265 is produced by typing:
266 \TeXexample
267 |smalltt$$
268 \EQNalign{
269 \nabla \cdot \vec D &= 4 \pi \rho \EQN EM;a \cr
270 \nabla \times \vec E &=
271 - {1 \over c} {\partial \vec B \over \partial t}
272 \EQN EM;b \cr
273 \nabla \cdot \vec B &= 0 \EQN EM;c \cr
274 \nabla \times \vec H &= {4 \pi \over c} \vec J
275 + {1 \over c} {\partial \vec D \over \partial t}
276 \EQN EM;d \cr}
277 $$
278 |endTeXexample
279 Note that the alignment of the equations is controlled by |&| and
280 |\cr|, not by the arrangement used when the equation was typed
281 into the manuscript file. Still, it is recommended that you
282 arrange long sets of equations like these in some sort of clear
283 pattern when you type them. This will both reduce errors when
284 the equation is typed and make it easier for you to read the file
285 when you are looking at it later. Remember, \TeX\ ignores all
286 spaces and tabs when it reads material for equations or displayed
287 equations.
288 \index{equations!alignment}
289
290 \CS{EQNdoublealign} is similar to \cs{EQNalign} but makes
291 equations with two alignment tabs. For example,
292 \TeXexample
293 |smalltt$$
294 \EQNdoublealign{
295 \sigma_i^2 &= 1 & \EQN Pauli;a \cr
296 \sigma_i\sigma_j + \sigma_j\sigma_i &= 0 \qquad & (i \ne j)
297 \EQN Pauli;b \cr
298 \sigma_i\sigma_j &= i\sigma_k \qquad & (i,j,k\ {\rm cyclic})
299 \EQN Pauli;c \cr}
300 $$
301 |endTeXexample
302 produces
303 $$
304 \EQNdoublealign{
305 \sigma_i^2 &= 1 & \EQN Pauli;a \cr
306 \sigma_i\sigma_j + \sigma_j\sigma_i &= 0 \qquad & (i \ne j)
307 \EQN Pauli;b \cr
308 \sigma_i\sigma_j &= i\sigma_k \qquad & (i,j,k\ {\rm cyclic})
309 \EQN Pauli;c \cr}
310 $$
311 with both the equal signs and the parentheses aligned. The second
312 |&| is required in the first line, because without it the |\EQN| would
313 have aligned the equation number with the parentheses enclosing $i\ne j$.
314
315 Plain \TeX\ also lets you display formulae on several lines
316 without any alignment by using \cs{displaylines}. With \TeXsis\ you
317 can use the similar control sequence \CS{EQNdisplaylines} to get an
318 automatically assigned equation number for any line in such a
319 display. The pattern is the same as in |\displaylines|, but you
320 simply insert \cs{EQN}\meta{label} in front of the \cs{cr} on the
321 line you want numbered. \CS{EQNdisplaylines} produces less space
322 between the equations than would result from typing them
323 separately, and generally looks better for closely related equations.
324
325 All of the equation alignment macros are special cases of the plain
326 \TeX\ macro \cs{halign}. Therefore, if necessary, the vertical spacing can
327 be adjusted by inserting
328 \example
329 \cs{noalign}\cs{vskip}\meta{dimen}
330 \endexample
331 where \meta{dimen} can be either a positive or a negative dimension.
332 \bigskip
333
334 In a long document there are several different ways to number
335 the equations. You could just start at ``1'' and count up for
336 each new equation, but sometimes it is better to number the
337 equations consecutively within each chapter or section of a
338 document. In \TeXsis\ the default form for an equation number is
339 $cc.ss.nn$ where $cc$ stands for the chapter number, $ss$ is the
340 section number, and $nn$ is the equation number within that
341 section. Whenever you move to a new section or chapter (using
342 \cs{section} or \cs{chapter}, as described in
343 Section~\use{sect.sects}) the number $ss$ or $cc$ is incremented
344 by one and the number $nn$ is reset to one. If you are not using
345 chapter divisions in your document then the chapter number $cc$
346 is not made a part of the equation number, and the number $nn$ is
347 reset only at the beginning of a section. If you are not using
348 section divisions in your document then the section number $ss$
349 is not made a part of the equation number, and the number $nn$ is
350 reset to one only at the beginning of a chapter. If you use
351 neither chapter nor section divisions in your document then
352 neither the chapter number $cc$ nor the section number $ss$ will
353 be made a part of the equation number, and the equations will
354 simply be numbered consecutively, 1, 2, 3\dots.
355 \index{equations!numbering}
356
357 Although the system just described for forming equation
358 numbers gives a result that is usually what you will want for
359 your equation numbering, you can change the method by setting
360 either of two switches. If you say |\showchaptIDfalse| then the
361 chapter number $cc$ will not be made a part of the equation
362 number even though you may be using chapter level divisions in
363 your document. Similarly, saying |\showsectIDfalse| prevents the
364 section number $ss$ from being used in the equation number. The
365 opposites of these two switches are \cs{showchaptIDtrue} and
366 \cs{showsectIDtrue}. The equation number $nn$ is reset to one only
367 when a section or chapter number that is supposed to be visible
368 is incremented, as you might expect.
369
370 %>>> EOF TXSeqns.doc <<<