summaryrefslogtreecommitdiff
path: root/macros/latex209/contrib/misc/deleq.sty
blob: 1b3df7c671966f20f431d81ad42fd33cadba1a70 (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
355
356
357
358
359
%  The style option file "deleq.sty" is found after these instructions,
%  right before the .sty-file is a line with 30 percentage-signs.
%
% 
%                   LaTeX Macro for Partial Numbering of Equations
%                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
% 
%                   by Mats Dahlgren, <matsd@physchem.kth.se> 
%                      or <mats@fenk.wau.nl>,  June 1994
% 
%                       Version 3.0, June 22, 1994
%                       Version 3.02, Sept. 8, 1994
% 
% NOTICE:  This version of deleq.sty (3.02) is the last which runs
%          under LaTeX 2.09.  It is not maintained any longer.  All
%          improvements and changes are done to the file for LaTeX2e,
%          which have a version number of 4.0 (or higher).  Useres
%          are urged to change to LaTeX2e and a newer version of deleq.sty.
%
% CHANGES: A few font-testings have been included, which - hopefully - 
%          makes deleq.sty v.3.02 compatible with also other font
%          selection schemen than NFSS2.
%
% deleq.sty is a LaTeX macro makes partial numbering of equations
% possible.  It is meant to be used when numbering such as 3a, 3b, etc.
% is desired.  The default is to give an equation number like '3a'
% without period and with the 'a' typeset in roman font.  It can be used
% in 'article' as well as 'book' and 'report' document styles.  The
% examples given below are valid for 'article' styled documents.
% Both right aligned and left aligned equation numbers are avaliable.
% Equations can be numbered either 3, 3a, 3b, ..., or 2, 3a, 3b, ....
% Also, if equation numbers within eqnarray-like environments can be
% numbered 3, 3a, 3b,... or starting at 3a, which can follow both after
% equation 2b or 3.  An array environment can have its first equation
% numbered 3b if the nearest previous equation is 3a.  Within the
% array environment, equations can be numbered 3a, 3b, 4, 4a, 4b, 5a, 5b,
% etc., and also not numbered lines are possible ('\nonumber' works).
% Furthermore, equation numbers can be "recycled".  If equation 3 is repeated
% after equation 8, it can still have the numbering set to 3, and be
% followed by (a new) equation 9.  "Recycled" equation numbers can 
% receive partial numbers (3a, 3b, ...); partially numbered equations
% can also be "recycled" (but at this stage, the latter can not receive
% new partial numbers neatly, it will come out like '3ba' if eqution 3b
% is the "recycled" equation).  A command for using references in mathmode
% which avoids the eroor message "Don't use \bf in mathmode" when processed
% is also included. 
% 
% deleq.sty version 3.0 has been tested with LaTeX 2.09 under UNIX.  Please
% send bug reports, corrections, additions, suggestions, etc to me at
% <matsd@physchem.kth.se>.  Use the file at your own pleasure and risk.
% (Command names are a mixture of LaTeX, Swedish and a bit of the author's 
% fantasy...)
% 
% Enjoy your LaTeX!
%                   mats d.
% 
% 
% Requirements:     The file 'deleq.sty' must be available in the user's
%                  'TEXINPUTS' directories.
% 
% Usage:            The macro is included by stating 'deleq' as one of the 
%                   options with the '\documentstyle' command.
% 
% Environments:     The macro defines the following eight environments:
%                   deqn           environment for automatic numbering of the
%                                  first equation of type 3a
%                   dleqn          'deqn' for left-aligned numbers
%                   ddeqn          used for automatic numbering of the 
%                                  equations following the one in 'deqn';
%                                  see also details below 
%                   ddleqn         'ddeqn' for left-aligned numbers
%                   deqarr         environment for automatic partial equation
%                                  numbering used in 'eqnarray' environment
%                   dleqarr        'deqarr' for left-aligned numbers
%                   ddeqar         similar to 'deqarr' environment, but more 
%                                  flexible, see details below
%                   ddleqar        'ddeqar' for left-aligned numbers
% 
% Commands:         The macro defines the following thirteen commands:
%                   \nydeqno
%                   \heqno
%                   \nydeleqno
%                   \nydelleqno
%                   \deleqno
%                   \delleqno
%                   \reqno{FOO}
%                   \rleqno{FOO}
%                   \rndeqno{FOO}
%                   \rndleqno{FOO}
%                   \rdeqno{FOO}
%                   \rdleqno{FOO}
%                   \mthref{FOO}
% 
% Notice:       1.  If you use '\nydeleqno', '\nydelleqno', '\deleqno', 
%                   '\delleqno', \nydeqno', '\heqno', '\reqno', '\rleqno'
%                   '\rndeqno', '\rndleqno', '\rdeqno', or '\rdleqno' in 
%                   combination with '\label{FOO}', '\label{FOO}' should
%                   appear after the 'deleq'-command;
%               2.  If you change the appearance of equation numbers (e.g. use
%                   '[2]' instead of '(2)'),  deleq':s commands may not typeset
%                   the partial equation numbers like your ordinary ones.
% 
% Syntax:           Here follows a more detailed description of the different
%                   environments and commands.
% 
%   \begin{deqn}    typesets an equation just like \begin{equation} .. 
%   ..\end{deqn}    \end{equation} does, but gives it a number such as
%                   '3a' instead of '3' (always 'a').
% 
%   \begin{dleqn}   typesets an equation just like \begin{deqn} .. \end{deqn}
%   ..\end{dleqn}   does, but with the equation number left-aligned.
% 
%   \begin{ddeqn}   typesets an equation just like \begin{equation} .. 
%   ..\end{ddeqn}   \end{equation} does, but gives it a number such as
%                   '3b', '3c'... instead of '3', '4'... when following after
%                   another partially numbered equation.  When following 
%                   after an ordinarily numbered equation ('3') it gives
%                   a partial equation number with the last used ordinary
%                   equation number, e.g. '3a'.  Can be made to produce the
%                   result of 'deqn' environment by the use of '\nydeqno'.
% 
%   \begin{ddleqn}  typesets an equation just like \begin{ddeqn} .. \end{ddeqn}
%   ..\end{ddleqn   does, but with the equation number left-aligned.
% 
%   \begin{deqarr}  typesets an equation array just like \begin{eqnarray} .. 
%   ..\end{deqarr}  \end{eqnarray} does, but gives the first numbered 
%                   equation a number like '3a' instead of '3' (always 'a'),
%                   and the following '3b', '3c' etc.  The '\nonumber' command
%                   works just like in the 'equationarray' environment.
% 
%   \begin{dleqarr} typesets an equation array just like \begin{dleqarr} .. 
%   ..\end{dleqarr} \end{dleqarr} does, but with the equation numbers
%                   left-aligned.
% 
%   \begin{ddeqar}  typesets an equation array just like \begin{eqnarray} .. 
%   ..\end{ddeqar}  \end{eqnarray} does, but gives the equation numbers such
%                   as '3a' if following after an equation numbered '3' 
%                   (ordinary equation number) and numbers such as '3c' if
%                   following after a partially numbered equation '3b'. 
%                   Can be made to produce the result of 'deqarr' environment 
%                   by the use of '\nydeqno'.  The '\nonumber' command
%                   works just like in the 'equationarray' environment.
% 
%   \begin{ddleqar} typesets an equation array just like \begin{ddleqar} .. 
%   ..\end{ddleqar} \end{ddleqar} does, but with the equation numbers
%                   left-aligned.
% 
%   \nydeqno        Used within 'deqarr', 'dleqarr', 'ddeqar', or 'ddleqar' 
%                   environments to step the main equation number by one 
%                   and reset the partial equation number to 'a'; thus,   
%                   '\nydeqno' gives equation number '4a' when following 
%                   equation '3c'.
% 
%   \heqno          Used within 'deqarr', 'dleqarr', 'ddeqar', or 'ddleqar' 
%                   environments to step the main equation number by one and  
%                   to produce an ordinary equation number; thus, gives 
%                   equation number '4' when following equation '3c'. 
%                   Equations following the '\heqno'-ed will be partially  
%                   numbered with the '\heqno'-ed equation's number as the
%                   main number, e.g. '4a' (unless it has a '\nydeqno' 
%                   command, which in this case would produce the equation 
%                   number '5a').
% 
%   \nydeleqno      gives a new partial equation number when used in $$ ... $$.
%                   Thus, writing '$$ ... \nydeleqno $$' is equivalent to 
%                   writing '\begin{deqn} ... \end{deqn}'.
% 
%   \nydelleqno     gives a new partial left-aligned equation number when 
%                   used in $$ ... $$. Thus, writing '$$ ... \nydelleqno $$'  
%                   is equivalent to writing '\begin{dleqn} ... \end{dleqn}'.
% 
%   \deleqno        gives a partial equation number when used in $$ ... $$.
%                   Thus, writing '$$ ... \deleqno $$' is equivalent to 
%                   writing '\begin{ddeqn} ... \end{ddeqn}'.
% 
%   \delleqno       gives a partial left-aligned equation number when 
%                   used in $$ ... $$. Thus, writing '$$ ... \delleqno $$'  
%                   is equivalent to writing '\begin{ddleqn} ... \end{ddleqn}'.
% 
%   \reqno{FOO}     is used when repeating equations with its original number.
%                   '\reqno' takes the argument 'FOO', which has to be defined
%                   by a '\label{FOO}' in the original equation.  It can
%                   only be used within $$ ... $$.  It does not affect the 
%                   equation number counter, nor the partial equation number 
%                   counter.  However, it resets the partial equation number
%                   counter for the '\rndeqno', '\rndleqno', '\rdeqno', and 
%                   '\rdleqno' commands.  If used with a '\label{FOOO}' 
%                   command, the .aux-file will only contain the page number 
%                   of label {FOOO}.
% 
%   \rleqno{FOO}    same as '\reqno{FOO}' but left-aligns the equation number.
% 
%   \rndeqno{FOO}   adds a partial equation number to an old equation number,
%                   specified by the FOO label.  If FOO refers to equation 
%                   '4', '\rdeqno{FOO}' will result in equation number '4a'
%                   (always 'a').  It can only be used within 
%                   $$ ... $$.  It does not affect the equation number counter,
%                   nor the partial equation number counter.  However, it
%                   resets the partial equation number counter for the 
%                   '\rndeqno', '\rndleqno', '\rdeqno', and '\rdleqno' commands.
%                   The argument of '\rndeqno' follows the same rules as that of
%                   '\reqno'.  When used with the '\label{FOOO}' command, a
%                   reference to FOOO will only return the partial equation
%                   number.  To make a complete reference to an equation
%                   which has a '\rndeqno' command, say '\ref{FOO}\ref{FOOO}'. 
% 
%   \rndleqno{FOO}  same as '\rndeqno{FOO}' but left-aligns the equation number.
% 
%   \rdeqno{FOO}    same as '\rndeqno{FOO}' but without resetting any 
%                   equation number counter and giving consecutive partial
%                   equation numbers ('4b', '4c', etc.).
%                   NOTE:  There is nothing preventing the repeated use of
%                   '\rndeqno{FOO}' and '\rdeqno{FOO}' for the same label
%                   FOO.  This will result in numbering such as '3a' (if 
%                   FOO refers to equation '3') occuring several times.
% 
%   \rdleqno{FOO}   same as '\rdeqno{FOO}' but left-aligns the equation number.
% 
%   \mthref{FOO}    same as ordinary '\ref{FOO}' but does not type-set the
%                   '??' in '\bf' font if occurring within mathmode.
%                   'deleq.sty' makes use of this to avoid interruptions when
%                   LaTeX-ing documents containing '\reqno', '\rleqno', 
%                   '\rndeqno', '\rndleqno', '\rdeqno', or '\rdleqno'.  It 
%                   can be used also outside mathmode, and behaves then
%                   just like '\ref{FOO}'.  Warnings are the same as 
%                   when using '\ref{FOO}'.
% 
%
%  The file itself begins here 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  deleq.sty    Version 3.02, Sept. 8, 1994
%  (c) 1994 by Mats Dahlgren  (matsd@physchem.kth.se or mats@fenk.wau.nl)
%  
\typeout{deleq.sty included, version 3.02 (Sept. 8, 1994).  (c) 1994 by Mats Dahlgren}
%% Part 0:  Compatibility with older TeX/LaTeX versions than 3.141/2.09
\@ifundefined{mathrm}{\def\mathrm{\rm}}{\def\rm{\mathrm}}
\@ifundefined{mathcal}{\def\mathcal{\cal}}{}
\@ifundefined{reset@font}{\def\reset@font{\hspace*{0pt}}}{}
\def\deleqver{{\tt deleq.sty} version 3.02 (Sept.~8, 1994)}
%% Part 1: Counters etc.
\newcounter{deleq}[equation]
\newcounter{Deleq}
\newcount\@deqpen
\newcount\@deqcnt
\def\aLph#1{\@aLph{\@nameuse{c@#1}}}
\def\@aLph#1{\ifcase#1\or a\or b\or c\or d\or e\or f\or g\or h\or i\or j\or
   k\or l\or m\or n\or o\or p\or q\or r\or s\or t\or u\or v\or w\or x\or y\or
   z\else\@ctrerr\fi}
\def\thedeleq  {\theequation\mathrm{\aLph{deleq}}}
\def\theDeleq  {\mathrm{\aLph{Deleq}}}
\def\@deleqnnum{{\reset@font\rm (\thedeleq)}}
\def\@delleqnnum{\hbox to .01\p@{}\rlap{\reset@font\rm
        \hskip -\displaywidth(\thedeleq)}}
\def\mthref#1{\@ifundefined{r@#1}{\ifmmode \mathrm{??} \else 
  {\reset@font\bf ??} \fi\@warning {Reference `#1' on page \thepage \space
  undefined}}{\edef\@tempa{\@nameuse{r@#1}}\expandafter 
  \@car\@tempa \@nil\null}}
%% Part 2:  \nydeleqno and \deleqno, with leftists
\def\nydeleqno{\refstepcounter{equation}\refstepcounter{deleq}
  \let\@currentlabel\thedeleq \eqno (\thedeleq)}
\def\deleqno{\refstepcounter{deleq} \let\@currentlabel\thedeleq 
  \eqno (\thedeleq)}
\def\nydelleqno{\refstepcounter{equation}\refstepcounter{deleq}
  \let\@currentlabel\thedeleq \leqno (\thedeleq)}
\def\delleqno{\refstepcounter{deleq} \let\@currentlabel\thedeleq 
  \leqno (\thedeleq)}
%% Part 3:  \reqno, \rndeqno, and \rdeqno, with leftists
\newcommand{\reqno}[1]{\setcounter{Deleq}{-1}\refstepcounter{Deleq}
   \eqno (\mthref{#1}) }
\newcommand{\rdeqno}[1]{\refstepcounter{Deleq}
   \eqno (\mthref{#1}\theDeleq)}
\newcommand{\rndeqno}[1]{\setcounter{Deleq}{0}\refstepcounter{Deleq}
   \eqno (\mthref{#1}\theDeleq)}
\newcommand{\rleqno}[1]{\setcounter{Deleq}{-1}\refstepcounter{Deleq}
   \leqno (\mthref{#1}) }
\newcommand{\rdleqno}[1]{\refstepcounter{Deleq}
   \leqno (\mthref{#1}\theDeleq)}
\newcommand{\rndleqno}[1]{\setcounter{Deleq}{0}\refstepcounter{Deleq}
   \leqno (\mthref{#1}\theDeleq)}
%% Part 4:  'deqarr' environment 
\def\@deqncr{{\ifnum0=`}\fi\@ifstar{\global\@deqpen\@M
    \@ydeqncr}{\global\@deqpen\interdisplaylinepenalty \@ydeqncr}} 
\def\@ydeqncr{\@ifnextchar [{\@xdeqncr}{\@xdeqncr[\z@]}} 
\def\@xdeqncr[#1]{\ifnum0=`{\fi}\@@deqncr
   \noalign{\penalty\@deqpen\vskip\jot\vskip #1\relax}}
\def\@@deqncr{\let\@tempa\relax
    \ifcase\@deqcnt \def\@tempa{& & &}\or \def\@tempa{& &}%
      \else \def\@tempa{&}\fi
     \@tempa \if@eqnsw\@deleqnnum\stepcounter{deleq}\fi
     \global\@eqnswtrue\global\@deqcnt\z@\cr}  
\def\deqarr{\stepcounter{equation}\stepcounter{deleq}
  \let\@currentlabel\thedeleq
  \global\@eqnswtrue\m@th
  \global\@deqcnt\z@\tabskip\@centering\let\\\@deqncr
  $$\halign to\displaywidth\bgroup\@eqnsel\hskip\@centering
  $\displaystyle\tabskip\z@{##}$&\global\@deqcnt\@ne
  \hskip 2\arraycolsep \hfil${##}$\hfil
  &\global\@deqcnt\tw@ \hskip 2\arraycolsep $\displaystyle\tabskip\z@{##}$\hfil
   \tabskip\@centering&\llap{##}\tabskip\z@\cr}
\def\enddeqarr{\@@deqncr\egroup
      \global\advance\c@deleq\m@ne$$\global\@ignoretrue}
%% Part 4b:  'dleqarr' environment 
\def\@dleqncr{{\ifnum0=`}\fi\@ifstar{\global\@deqpen\@M
    \@ydleqncr}{\global\@deqpen\interdisplaylinepenalty \@ydleqncr}} 
\def\@ydleqncr{\@ifnextchar [{\@xdleqncr}{\@xdleqncr[\z@]}} 
\def\@xdleqncr[#1]{\ifnum0=`{\fi}\@@dleqncr
   \noalign{\penalty\@deqpen\vskip\jot\vskip #1\relax}}
\def\@@dleqncr{\let\@tempa\relax
    \ifcase\@deqcnt \def\@tempa{& & &}\or \def\@tempa{& &}%
      \else \def\@tempa{&}\fi
     \@tempa \if@eqnsw\@delleqnnum\stepcounter{deleq}\fi
     \global\@eqnswtrue\global\@deqcnt\z@\cr}  
\def\dleqarr{\stepcounter{equation}\stepcounter{deleq}
  \let\@currentlabel\thedeleq
  \global\@eqnswtrue\m@th
  \global\@deqcnt\z@\tabskip\@centering\let\\\@dleqncr
  $$\halign to\displaywidth\bgroup\@eqnsel\hskip\@centering
  $\displaystyle\tabskip\z@{##}$&\global\@deqcnt\@ne
  \hskip 2\arraycolsep \hfil${##}$\hfil
  &\global\@deqcnt\tw@ \hskip 2\arraycolsep $\displaystyle\tabskip\z@{##}$\hfil
   \tabskip\@centering&\llap{##}\tabskip\z@\cr}
\def\enddleqarr{\@@dleqncr\egroup
      \global\advance\c@deleq\m@ne$$\global\@ignoretrue}
%% Part 5:  'ddeqar' environment 
\def\ddeqar{\stepcounter{deleq}
  \let\@currentlabel\thedeleq
  \global\@eqnswtrue\m@th
  \global\@deqcnt\z@\tabskip\@centering\let\\\@deqncr
  $$\halign to\displaywidth\bgroup\@eqnsel\hskip\@centering
  $\displaystyle\tabskip\z@{##}$&\global\@deqcnt\@ne
  \hskip 2\arraycolsep \hfil${##}$\hfil
  &\global\@deqcnt\tw@ \hskip 2\arraycolsep $\displaystyle\tabskip\z@{##}$\hfil
   \tabskip\@centering&\llap{##}\tabskip\z@\cr} 
\def\endddeqar{\enddeqarr}
%% Part 5b:  'ddleqar' environment 
\def\ddleqar{\stepcounter{deleq}
  \let\@currentlabel\thedeleq
  \global\@eqnswtrue\m@th
  \global\@deqcnt\z@\tabskip\@centering\let\\\@dleqncr
  $$\halign to\displaywidth\bgroup\@eqnsel\hskip\@centering
  $\displaystyle\tabskip\z@{##}$&\global\@deqcnt\@ne
  \hskip 2\arraycolsep \hfil${##}$\hfil
  &\global\@deqcnt\tw@ \hskip 2\arraycolsep $\displaystyle\tabskip\z@{##}$\hfil
   \tabskip\@centering&\llap{##}\tabskip\z@\cr} 
\def\endddleqar{\enddleqarr}
%% Part 6:  'deqn' and 'ddeqn' environments, with leftists
\def\deqn{$$\refstepcounter{equation}\stepcounter{deleq} 
  \let\@currentlabel\thedeleq}
\def\enddeqn{\eqno \hbox{\@deleqnnum} $$\global\@ignoretrue}
\def\ddeqn{$$\refstepcounter{deleq} \let\@currentlabel\thedeleq}
\def\endddeqn{\eqno \hbox{\@deleqnnum} $$\global\@ignoretrue}
\def\dleqn{\deqn}
\def\enddleqn{\leqno \hbox{\@deleqnnum} $$\global\@ignoretrue}
\def\ddleqn{\ddeqn}
\def\endddleqn{\leqno \hbox{\@deleqnnum} $$\global\@ignoretrue}
%% Part 7:  \nydeqno and \heqno
\def\nydeqno{\stepcounter{equation}\stepcounter{deleq}}
\def\heqno{\stepcounter{equation}}
%% END of it all!