summaryrefslogtreecommitdiff
path: root/macros/latex-dev/required/amsmath/subeqn.tex
blob: 7e07f61d017cb81f8f48ff91d6684b06b096ed8e (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
%%% ====================================================================
%%%  @LaTeX-file{
%%%     filename  = "subeqn.tex",
%%%     version   = "1.2c",
%%%     date      = "1999/11/29",
%%%     time      = "14:49:29 EST",
%%%     checksum  = "29866 202 668 6426",
%%%     author    = "American Mathematical Society",
%%%     copyright = "Copyright 1999 American Mathematical Society,
%%%                  all rights reserved.  Copying of this file is
%%%                  authorized only if either:
%%%                  (1) you make absolutely no changes to your copy,
%%%                  including name; OR
%%%                  (2) if you do make changes, you first rename it
%%%                  to some other name.",
%%%     address   = "American Mathematical Society,
%%%                  Technical Support,
%%%                  Electronic Products and Services,
%%%                  P. O. Box 6248,
%%%                  Providence, RI 02940,
%%%                  USA",
%%%     telephone = "401-455-4080 or (in the USA and Canada)
%%%                  800-321-4AMS (321-4267)",
%%%     FAX       = "401-331-3842",
%%%     email     = "tech-support@ams.org (Internet)",
%%%     supported = "yes",
%%%     keywords  = "latex, amslatex, ams-latex, amstex",
%%%     abstract  = "This is part of the AMS-\LaTeX{} distribution.
%%%                  It is a sample document illustrating the use of
%%%                  the subequations environment and the effect of
%%%                  the fleqn option.",
%%%     docstring = "The checksum field above contains a CRC-16
%%%                  checksum as the first value, followed by the
%%%                  equivalent of the standard UNIX wc (word
%%%                  count) utility output of lines, words, and
%%%                  characters.  This is produced by Robert
%%%                  Solovay's checksum utility.",
%%%  }
%%% ====================================================================
\documentclass[fleqn]{article}

\title{Test of subequations environment}
\author{mjd}

\usepackage{amsmath}
\numberwithin{equation}{section}

\newcommand{\env}[1]{{\normalfont\texttt{#1}}}

\AtEndDocument{\multipasswarning}
\newcommand{\multipasswarning}{%
  \clearpage
  \typeout{%
  **********************************************************************}
  \typeout{%
  Note: This document needs to run through LaTeX three times, instead of}
  \typeout{%
  the usual two, to resolve indirect cross-references.}
  \typeout{%
  **********************************************************************}
}

\makeatletter
%    Omit the warning message if three passes have been completed (on
%    first pass \ref{check} is undefined and it is set to 0; on second
%    pass \ref{check} is 0 and set to 1; on third pass it is 1).
\def\checkref{\begingroup
  \@ifundefined{r@check}{\let\r@check\relax\def\@currentlabel{0}}{\def\@currentlabel{1}}%
  \ifnum1=0\expandafter\@firstoftwo\r@check\relax
    \global\let\multipasswarning\relax
  \fi
  \label{check}%
  \endgroup}
\makeatother

\begin{document}
\section{Prime equation numbers}

First an equation.
\begin{equation}\label{e:previous}
A=B
\end{equation}
That was equation \eqref{e:previous}.

Then the same, with a prime on the number.\checkref
\begin{equation}
\tag{\ref{e:previous}$'$}\label{e:prevprime}
C=D
\end{equation}
And that was equation \eqref{e:prevprime}.

Notice, by the way, that when a \verb"\ref" occurs inside a \verb"\tag",
and that \verb"\tag" is then \verb"\label"'d, a \verb"\ref" for the
second \verb"\label" requires \emph{three} runs of \LaTeX{} in order to
get the proper value. (If you run through the logic of \LaTeX{}'s
cross-referencing mechanisms as they apply in this case, you will see
that this is necessary.)

\section{Subnumbered equations}

Here is a,b,c sub-numbering.
\begin{subequations}
\begin{eqnarray}
A&=&B\\
D&=&C \label{e:middle}\\
E&=&F
\end{eqnarray}
\end{subequations}
That was produced with the \env{eqnarray} environment; the middle line
was labeled as \eqref{e:middle}.

An equation following the end of the \verb"subequations" environment
should revert to normal numbering:
\begin{equation}\label{e:check}
H<K
\end{equation}
A check on the labeling: that was equation~\eqref{e:check}.

The sub-numbered equations can be spread out through the text, like
this:
\begin{subequations}
\begin{equation}
A=B
\end{equation}
The \verb"subequations" environment can span arbitrary text between
subsidiary equations. The only restriction is that if there are any
numbered equations inside the \verb"subequations" environment that break
out of the subequation numbering sequence, they would have to be handled
specially.
\begin{equation}
D=C \label{e:newmiddle}
\end{equation}
More arbitrary text.
\begin{equation}
E=F
\end{equation}
\end{subequations}
Label check: the middle one was \eqref{e:newmiddle}

A final equation for a numbering check.
\begin{equation}\label{e:final}
G=H
\end{equation}
That equation was labeled as \eqref{e:final}.

\section{Tests of \env{align}, \env{gather}, and other
AMS-\protect\LaTeX{} environments}

The \env{align} environment:
\begin{subequations}
\begin{align}
\label{align:a}A+B&=B+A\\
\label{align:b}C&=D+E\\
\label{align:c}E&=F
\end{align}
\end{subequations}
Label check: that was \eqref{align:a}, \eqref{align:b}, and
\eqref{align:c}.

The \env{align} environment again:
\begin{subequations}
\begin{align}
\label{xalign:a}A+B&=B&     B&=B+A\\
\label{xalign:b}C&=D+E&     C\oplus D&=E\\
\label{xalign:c}E&=F&       E'&=F'
\end{align}
\end{subequations}
Label check: that was \eqref{xalign:a}, \eqref{xalign:b}, and
\eqref{xalign:c}.

The \env{gather} environment. For the third line we refer to one of the
numbers in the first \env{align} structure.
\begin{subequations}
\begin{gather}
\label{gather:a}A+B=B\\
\label{gather:b}C=D+E\\
\tag{\ref{align:c}$'$}\label{gather:c}E=F
\end{gather}
\end{subequations}
Label check: that was \eqref{gather:a},
\eqref{gather:b}, and
\eqref{gather:c}.

The next \env{subequations} environment encompasses two separate
equations. A \env{split} environment:
\begin{subequations}
\begin{equation}
\label{split:x}
\begin{split}
A&=B+C+F\\
&=G
\end{split}
\end{equation}
and a \env{multline} environment:
\begin{multline}\label{multline:x}
A[B]C[D]E[F]G[[H[I]J[K]L[M]N]]=\\
H[I]J[K]L[M]N[O]P[Q]R[S]T[U]V[W]X[Y]Z
\end{multline}
\end{subequations}
Label check: That was \eqref{split:x} and \eqref{multline:x}.

\end{document}