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