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
|
% This file is public domain.
%
% Test symbolic equation references.
%
\ifx\eplain\undefined \input eplain \fi
\loggingall
\leftdisplays
An equation with a number in its name:
$$ a+b=1\eqdef{line1}$$
\line{did we mess up plain's line in equation \eqref{line1}?\hfil}
\bye
The first equation:
$$x + y = 1 \eqdef{first}$$
In equation \eqref{first}, we said that $x+y=1$.
Now, in equation \eqref{second}, we say that $a+b=2$.
$$a + b = 2 \eqdef{second}$$
The next equation is unlabeled in the output, but we can still refer to
it.
$$c + d = 3 \eqdefn{*}$$
And here's an equation whose text references another equation, namely,
\eqref{first}:
$$c=3\eqdef[\eqrefn{first}*]{first-star}$$
And a reference to it: \eqref{first-star}.
Here is the first of a group of equations: \eqdefn{group}
$$a = 1\eqsubdef{group-1}$$
and the invisible second, then the third of the group \eqsubdefn{group-invis}:
$$b = 2\eqsubdef{group-2}$$
We refer to the group as \eqref{group}, to the first as
\eqref{group-1}, the third as \eqref{group-2}, and the invisible second
as \eqref{group-invis}.
Here's an equation labeled strangely:
$$a=1\eqdef[\rm strange*]{foo}$$
And let's refer to \eqref{foo}.
Let's do subequations off that:
$$b=2\eqsubdef{foo-1}$$
And refer to it: \eqref{foo-1}.
% We can't use \count255, since #1 might involve contortions which
% trample it.
\newcount\subrefcount
\def\eqsubreftext#1#2{%
\subrefcount = #2
\advance\subrefcount by 96
#1\char\subrefcount
}
Let's try another group, with a different labelling scheme. Here is the
first of this group2: \eqdefn{group2}
$$a = 1\eqsubdef{group2-1}$$
and the second of the group2 \eqsubdefn{group2-invis}:
$$b = 2\eqsubdef{group2-2}$$
We refer to the group2 as \eqref{group2}, to the first as
\eqref{group2-1}, the third as \eqref{group2-2}, and the invisible second
as \eqref{group2-invis}.
Here is one done with displaylines:
% The \hfill's and \llap make the equation numbers come out in the right
% place if we are not doing \leftdisplays. (See the TeXbook, p.194.)
%$$\displaylines{
% \hfill x=1\hfill\llap{\eqdef{displayline-1}}\cr
% \hfill y=2\hfill\llap{\eqdef{displayline-2}}\cr
%}$$
$$\displaylines{
x=1\eqdef{displayline-1}\cr
y=2\eqdef{displayline-2}\cr
}$$
Let's refer to each of the equations in the displaylines:
\eqref{displayline-1}, \eqref{displayline-2}.
And one with eqalignno:
$$
\eqalignno{
a+b&=c&\eqdef{eqalign-1}\cr
d+e&=f&\eqdef{eqalign-2}\cr
}
$$
And one with leqalignno, and indented more:
{\leftdisplayindent = 1in
$$\leqalignno{
a+b &=c&\eqdef{leqalign-1}\cr
dt+eg&=f&\eqdef{leqalign-2}\cr
}$$
}
And now let's refer to those: \eqref{eqalign-1}, \eqref{eqalign-2},
\eqref{leqalign-1}, \eqref{leqalign-2}.
\def\eqprint#1{[\rm A.#1]}
From now on, all equation labels should be in brackets and preceded
by `A.'. In \eqref{*}, we said that $c+d=3$. And in equation
\eqref{undefined}, we say that $1+1=2$.
\eqdefn{*x}
\eqdefn{*y}
We defined equation \eqref{*y}, although we didn't give an equation for
it.
This is a forward reference to equation \eqref{forward}.
$$e + f = 4 \eqdef{forward}$$
That equation above defines \eqref{forward}.
\newcount\sectionnum \sectionnum = 1
\def\eqconstruct#1{\the\sectionnum.#1}
And now equation numbers should have a section number (which we start at
one) preceding them.
$$a+b=1 \eqdef{s-ab}$$
That equation is \eqref{s-ab}. The one we'll define in the next section
is \eqref{s-cd}.
\advance\sectionnum by 1
The equation in the previous section was \eqref{s-ab}. Let's define one
in this section:
$$c+d=3 \eqdef{s-cd}$$
And refer to it: \eqref{s-cd}.
\bye
|