Debian Codegraph @

texmf-dist/source/latex/eqnarray/eqnarray.dtx

raw
1 \def\fileversion{1.3}
2 \def\filedate{December 1, 2010}
3 \def\docdate{December 1, 2010}
4 %
5 % \MakeShortVerb{\|}
6 %
7 % \iffalse
8 % Version 1.1: \def\filedate{jan 1993}, \def\docdate{9 jan 1995}
9 % Version 1.2: Piet van Oostrum <[email protected]> added the code which
10 % is necessary for the |fleqn| option.
11 % \def\filedate{17 May 1995} \def\docdate{17 May 1995}
12 % Version 1.2a: \def\filedate{17 July 1997}, \def\docdate{17 July 1997}
13 % Apart from a statement \RequirePackage{array} no
14 % modifications have been made in the style file itself.
15 % I improved the documentation and I packed
16 % everything into an easier-to-use dtx file
17 % Version 1.3: \def\filedate{December 1, 2010}
18 % \def\docdate{December 1, 2010}
19 % The new command \eqnnum gives customizable equation numbers.
20 % This package is published under the terms of the GPL
21 % \fi
22 %
23 % \title{The |equationarray| environment}
24 % \author{Roland Winkler\\ \normalsize
25 % |[email protected]|}
26 % \date{\filedate\quad v\fileversion}
27 % \maketitle
28 % \begin{abstract}\noindent
29 % This package provides the |equationarray| environment. It combines
30 % the line numbering of the |eqnarray| and the more flexible
31 % formatting features of the |array| environment. It requires the
32 % |array| package.
33 %
34 % This package is published under the terms of the GNU General
35 % Public License as published by the Free Software Foundation,
36 % either version 3 of the License, or (at your option) any later
37 % version.
38 % \end{abstract}
39 %
40 % \section{Introduction}
41 %
42 % Problem: The |eqnarray| environment is too restrictive because it is
43 % only prepared to accept three part equations. Some applications
44 % require more sophisticated mathematics, so three parts aren't
45 % enough. Simultaneously, we would like to have our equations
46 % numbered. If the equations aren't to be numbered, then the |array|
47 % environment suffices.\footnote{Nevertheless it is often easier to use the
48 % |equationarray*| environment than both an |equation| plus an |array|
49 % environment. Moreover a page break is possible between two lines of the
50 % |equationarray|.} If the equations aren't to be aligned with
51 % each other, then the |equation| environment is preferred.
52 %
53 % A first version of the |equationarray| environment was written by
54 % Tony Li, University of Southern California, |<[email protected]>|
55 % starting 6/15/1988. The current version has been completely
56 % rewritten in order to make it compatible with Frank Mittelbach's
57 % |array| environment, i.e., it should be possible to use all features
58 % of the |array| environment. If you find a bug (see below!) or if you
59 % make any improvements, I'd like to hear about them.
60 %
61 % \section{Example}
62 %
63 % We give a short example for the use of |equationarray|. The text is
64 % %
65 % \begin{verbatim}
66 % \newcolumntype{e}{@{\quad}}
67 % \arraycolsep 0.2em
68 % \begin{equationarray}{p{2.5em}erclecercl}
69 % now: & - i\partial_t \psi & = & H\,\psi & \Rightarrow
70 % & \psi (t) & = & \psi (0) \exp (iEt) \\[3ex]
71 % then: & - i\partial_t \psi & = & (H+E_0) \,\psi & \Rightarrow
72 % & \psi (t) & = & \psi (0) \exp [i(E+E_0)t]
73 % \end{equationarray}
74 % \end{verbatim}
75 % %
76 % \noindent and we obtain
77 % %
78 % \newcolumntype{e}{@{\quad}}
79 % \arraycolsep 0.2em
80 % \begin{equationarray}{p{2.5em}erclecercl}
81 % now: & - i\partial_t \psi & = & H\,\psi & \Rightarrow
82 % & \psi (t) & = & \psi (0) \exp (iEt) \\[3ex]
83 % then: & - i\partial_t \psi & = & (H+E_0) \,\psi & \Rightarrow
84 % & \psi (t) & = & \psi (0) \exp [i(E+E_0)t]
85 % \end{equationarray}
86 % %
87 % An |equationarray| behaves very much like an |array|. For example,
88 % |equationarray| accepts the same tokens for defining columns, and
89 % new column types can be defined with |\newcolumntype|. One can use
90 % |\multicolumn|, |\hline|, |\cline|, and |\vline|. Moreover,
91 % |equationarray| makes use of |\arraycolsep|, |\extracolsep|, and
92 % |\extrarowheight|.\footnote{Some people don't like the large spacing
93 % between the columns of the standard |eqnarray|. Don't be surprised
94 % that |equationarray| seems to have the same ``bug''. To decrease
95 % the spacing between two columns you just have to change the value
96 % of $\tt\backslash$|arraycolsep|, see the example above.} In an
97 % |equationarray| all these things have the same meaning like in an
98 % |array|. The main difference is that by default each entry of an
99 % |equationarray| is displayed with |\displaystyle| whereas |array|
100 % uses |\textstyle|. One can avoid page breaks between two lines by
101 % using the star version |\\*|. There is also the star version
102 % |equationarray*| which has usually no line numbers. But if for a
103 % particular line you still want a line number, you can use
104 % |\yesnumber|. (I find this more convenient than having many lines
105 % with |\nonumber|.) Inside the |equationarray| and |equationarray*|
106 % environments, there is also the macro |\eqnnum| available. It takes
107 % one argument that is used as the equation number for the current
108 % line. The normal line number is always suppressed in such a line.
109 %
110 % The default is that without the |fleqn| option the equations are
111 % centered. With the |fleqn| option they are left-justified, indented
112 % by |\mathindent|.\footnote{Thanks to Piet van Oostrum
113 % |<[email protected]>| who added the code which is necessary for the
114 % |fleqn| option.} With the optional argument |[l]| or |[r]| the
115 % |equationarray| will appear flushleft or flushright, with the option
116 % |[c]| the |equationarray| will be centered, e.g.\
117 % |\begin{equationarray}[l]{rclll}|.
118 %
119 % \section{Bugs}
120 %
121 % Compared with |array| the |equationarray| uses slightly extended
122 % versions of |\@classz| and |\multicolumn| because it must count the
123 % columns. Each time you insert a |&| the counter |\@eqcnt| is
124 % increased by one. |\multicolumn| increases |\@eqcnt| according to
125 % the number of |\span|ed columns. Thus if you have an |array| within
126 % the |equationarray| environment and in that line of the
127 % |equationarray| you have less |&|'s than columns defined in the
128 % preamble, then the line numbering will be not flushright but further
129 % to the left.
130 %
131 % In that case you can either fill up the end of the line with extra
132 % |&|'s (straightforward) or you can put the original definition of
133 % |\@classz| and |\multicolumn| within the definition of the |array|
134 % command.
135 %
136 % \section{License}
137 %
138 % This \LaTeX package is free software: you can redistribute it
139 % and/or modify it under the terms of the GNU General Public License
140 % as published by the Free Software Foundation, either version 3 of
141 % the License, or (at your option) any later version.
142 %
143 % This package is distributed in the hope that it will be useful,
144 % but WITHOUT ANY WARRANTY; without even the implied warranty of
145 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
146 % GNU General Public License for more details.
147 %
148 % The GNU General Public License is available at\\
149 % \texttt{http://www.gnu.org/licenses/gpl.html}
150 %
151 % \section{The code}
152 %
153 %\iffalse
154 %<*style>
155 %\fi
156 % \begin{macrocode}
157 \typeout{equationarray \fileversion\space<\filedate>}
158 % \typeout{English documentation\space\space<\docdate>}
159 \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{eqnarray}
160 % \end{macrocode}
161 % |equationarray| can't do anything if we don't have the |array| package.
162 % \begin{macrocode}
163 \RequirePackage{array}
164 % \end{macrocode}
165 % Process the |fleqn| option.
166 % \begin{macrocode}
167 \def\eqnarr@left{\@centering}
168 \let\eqnarr@opts\relax
169 \DeclareOption{fleqn}{
170 \def\eqnarr@left{\mathindent}
171 \def\eqnarr@opts{\displaywidth\linewidth
172 \advance\displaywidth-\mathindent} }
173 \ProcessOptions
174 % \end{macrocode}
175 %
176 % \begin{macro}{\equationarray}
177 % \begin{macrocode}
178 \def\equationarray{%
179 \col@sep\arraycolsep
180 \def\d@llarbegin{$\displaystyle}%
181 \def\d@llarend{$}%
182 \stepcounter{equation}%
183 \let\@currentlabel=\theequation
184 \set@eqnsw \global\@eqcnt\z@ \global\@eqargcnt\z@
185 \let\@classz\@eqnclassz
186 % \end{macrocode}
187 % We need an extended definition of |\multicolumn| which increases
188 % the counter |\@eqcnt| according to the number of columns covered
189 % by |\multicolumn|.
190 % \begin{macrocode}
191 \def\multicolumn##1##2##3{\@eqnmulticolumn{##1}{##2}{##3}%
192 \global\advance\@eqcnt##1
193 \global\advance\@eqcnt\m@ne}%
194 % \end{macrocode}
195 % The macro |\eqnnum| initializes |\@eqnarrnum| and suppresses
196 % ordinary equation numbering.
197 % \begin{macrocode}
198 \def\eqnnum##1{\global\@eqnswfalse\gdef\@eqnarrnum{##1}}
199 \def\@halignto{to\displaywidth}%
200 \@ifnextchar[{\@equationarray}{\@equationarray[.]}}
201 % \end{macrocode}
202 % \end{macro}
203 %
204 % \begin{macro}{\@eqnmulticolumn}
205 % |\@eqnmulticolumn| equals the original version of |\multicolumn|.
206 % \begin{macrocode}
207 \let\@eqnmulticolumn=\multicolumn
208 % \end{macrocode}
209 % \end{macro}
210 %
211 % \begin{macro}{\nonumber,\yesnumber}
212 % Note that |\nonumber| is already defined in standard latex.tex
213 % \begin{macrocode}
214 % \def\nonumber{\global\@eqnswfalse}
215 \def\yesnumber{\global\@eqnswtrue}
216 \let\set@eqnsw=\yesnumber
217 % \end{macrocode}
218 % \end{macro}
219 %
220 % \begin{macro}{\@amper}
221 % We need a macro for |&| that expands at the right time.
222 % \begin{macrocode}
223 \def\@amper{&}
224 % \end{macrocode}
225 % \end{macro}
226 %
227 % \begin{macro}{\@eqargcnt}
228 % The main idea about the |equationarray| is the following: The
229 % counter |\@eqargcnt| counts the number of columns defined in the
230 % preamble. In each line of the |equationarray|, the counter
231 % |\@eqcnt| counts the number of |&| which have been introduced
232 % explicitely by the user. By comparing these counters we can
233 % silently fill every line of the |equationarray| with exactly
234 % |\@eqargcnt| copies of |&| before we insert the equation
235 % number. See also the \TeX book, Exercise 22.9.
236 % \begin{macrocode}
237 \newcount\@eqargcnt % counts number of columns
238 % \end{macrocode}
239 % \end{macro}
240 %
241 % \begin{macro}{\@equationarray}
242 % \begin{macrocode}
243 \def\@equationarray[#1]#2{%
244 \eqnarr@opts
245 \@tempdima \ht \strutbox
246 \advance \@tempdima by\extrarowheight
247 \setbox\@arstrutbox=\hbox{\vrule
248 \@height\arraystretch \@tempdima
249 \@depth\arraystretch \dp \strutbox
250 \@width\z@}%
251 \gdef\advance@eqargcnt{\global\advance\@eqargcnt\@ne}%
252 \begingroup
253 \@mkpream{#2}%
254 \xdef\@preamble{%
255 \if #1l\tabskip\z@ \else\if #1r\tabskip\@centering
256 \else\if #1c\tabskip\@centering
257 \else\tabskip\eqnarr@left \fi\fi\fi
258 \halign \@halignto
259 \bgroup \tabskip\z@ \@arstrut \@preamble
260 \if #1l\tabskip\@centering \else\if #1r\tabskip\z@
261 \else\tabskip\@centering \fi\fi
262 % \end{macrocode}
263 %
264 % Here we need an extra column for the equation-number
265 %
266 % \begin{macrocode}
267 \@amper\llap{\@sharp}\tabskip\z@\cr}%
268 \endgroup
269 \gdef\advance@eqargcnt{}%
270 \bgroup
271 \let\@sharp## \let\protect\relax
272 \m@th \let\\=\@equationcr
273 \let\par\@empty
274 $$ % $$ BRACE MATCHING HACK
275 \lineskip \z@
276 \baselineskip \z@
277 \@preamble}
278 % \end{macrocode}
279 % \end{macro}
280 %
281 % \begin{macro}{\@eqnclassz}
282 % |\@eqnclassz| does the same thing as |\@classz| except that we add\\
283 % |\advance@eqargcnt|
284 % \begin{macrocode}
285 \def\@eqnclassz{\@classx
286 \@tempcnta \count@
287 \advance@eqargcnt
288 \prepnext@tok
289 \@addtopreamble{%
290 \global\advance\@eqcnt\@ne
291 \ifcase \@chnum
292 \hfil \d@llarbegin \insert@column \d@llarend\hfil \or
293 \d@llarbegin \insert@column \d@llarend \hfil \or
294 \hfil\kern\z@ \d@llarbegin \insert@column \d@llarend \or
295 $\vcenter
296 \@startpbox{\@nextchar}\insert@column \@endpbox $\or
297 \vtop \@startpbox{\@nextchar}\insert@column \@endpbox \or
298 \vbox \@startpbox{\@nextchar}\insert@column \@endpbox
299 \fi}\prepnext@tok}
300 % \end{macrocode}
301 % \end{macro}
302 %
303 % \begin{macro}{\endequationarray}
304 % \begin{macrocode}
305 \def\endequationarray{\@zequationcr
306 \egroup
307 \global\advance\c@equation\m@ne $$ % $$ BRACE MATCHING HACK
308 \egroup\global\@ignoretrue
309 \gdef\@preamble{}}
310 % \end{macrocode}
311 % \end{macro}
312 %
313 % \begin{macro}{\@equationcr}
314 % If we have |\\*| the command |\@equationcr| avoids page breaks
315 % \begin{macrocode}
316 \def\@equationcr{${\ifnum0=`}\fi\@ifstar{\global\@eqpen\@M
317 \@xequationcr}{\global\@eqpen\interdisplaylinepenalty
318 \@xequationcr}}
319 % \end{macrocode}
320 % \end{macro}
321 %
322 % \begin{macro}{\@xequationcr}
323 % \begin{macrocode}
324 \def\@xequationcr{%
325 \@ifnextchar[{\@argequationcr}{\ifnum0=`{\fi}${}%
326 \@zequationcr}}
327 % \end{macrocode}
328 % \end{macro}
329 %
330 % \begin{macro}{\@argequationcr}
331 % \begin{macrocode}
332 \def\@argequationcr[#1]{\ifnum0=`{\fi}${}\ifdim #1>\z@
333 \@xargequationcr{#1}\else
334 \@yargequationcr{#1}\fi}
335 % \end{macrocode}
336 % \end{macro}
337 %
338 % \begin{macro}{\@xargequationcr}
339 % \begin{macrocode}
340 \def\@xargequationcr#1{\unskip
341 \@tempdima #1\advance\@tempdima \dp \@arstrutbox
342 \vrule \@depth\@tempdima \@width\z@
343 \@zequationcr\noalign{\penalty\@eqpen}}
344 % \end{macrocode}
345 % \end{macro}
346 %
347 % \begin{macro}{\@yargequationcr}
348 % \begin{macrocode}
349 \def\@yargequationcr#1{%
350 \@zequationcr\noalign{\penalty\@eqpen\vskip #1}}
351 % \end{macrocode}
352 % \end{macro}
353 %
354 % \begin{macro}{\@eqnarrnum}
355 % The macro |\@eqnarrnum| holds a customized equation number.
356 % This macro is initialized via the macro |\eqnnum|.
357 % \begin{macrocode}
358 \let\@eqnarrnum\relax
359 % \end{macrocode}
360 % \end{macro}
361 %
362 % \begin{macro}{\@zequationcr}
363 % We add |&\omit| for those columns that will remain empty.
364 % Note that without |\omit| we already have |\advance\@eqcnt\@ne| in
365 % the preamble.
366 %
367 % \begin{macrocode}
368 \def\@zequationcr{\@whilenum\@eqcnt <\@eqargcnt
369 \do{\@amper\omit\global\advance\@eqcnt\@ne}%
370 % \end{macrocode}
371 % We add an extra alignment tab for the equationnumber
372 % \begin{macrocode}
373 \@amper
374 % \end{macrocode}
375 % Either we insert the regular equation number or the customized one.
376 % \begin{macrocode}
377 \if@eqnsw\@eqnnum\stepcounter{equation}\else
378 \@eqnarrnum\global\let\@eqnarrnum\relax\fi
379 \set@eqnsw\global\@eqcnt\z@\cr}
380 % \end{macrocode}
381 % \end{macro}
382 %
383 % \begin{macro}{\equationarray*}
384 % Finally we define the |equationarray*| environment. It does exactly
385 % the same thing as |\equationarray| except that we |\let| the command
386 % |\set@eqnsw| equal |\nonumber|
387 % \begin{macrocode}
388 \@namedef{equationarray*}{%
389 \let\set@eqnsw=\nonumber \equationarray}
390 \@namedef{endequationarray*}{\endequationarray}
391 % \end{macrocode}
392 % \end{macro}
393 %\iffalse
394 %</style>
395 %<+driver>\documentclass{article}
396 %<+driver>\usepackage{doc}
397 %<+driver>\usepackage{eqnarray}
398 %<+driver>\begin{document}
399 %<+driver> \DocInput{eqnarray.dtx}
400 %<+driver>\end{document}
401 %\fi
402 \endinput