Tagging and grouping
8.5 Tagging and grouping
You can attach a name to an equation using the \tag command. In the equation or equation* environments,
\tag{name } attaches the tag name to the equation—name is typeset as text. The tag replaces the
number. Recall that the numbering of an equation is relative, that is, the number assigned to an equation is relative to the placement of the equation with respect to other equations in the document. An equation tag, on the other hand, is absolute—the tag remains the same even if the equation is moved.
202 Chapter 8 More math
If you want to reference the number generated by L A TEX for an equation, then you have to attach a \label{name } command. You reference the number with the \ref{name } or \eqref{name } command.
Note that an equation may contain both a tag and a label. The tag is typeset and the label can be used for page referencing with the \pageref command (see Sec- tion 10.4.2).
If there is a tag, the equation and the equation* environments are equivalent. For example,
may be typed as \begin{equation*}
\int_{-\infty}^{\infty} e^{-x^{2}} \, dx = \sqrt{\pi}\tag{Int}
\end{equation*} or \begin{equation}
\int_{-\infty}^{\infty} e^{-x^{2}} \, dx = \sqrt{\pi}\tag{Int}
\end{equation} or
\[ \int_{-\infty}^{\infty} e^{-x^{2}} \, dx = \sqrt{\pi}\tag{Int}
\] Note that \label works in a starred display math environment if a tag is present.
The \tag* command is the same as \tag except that it does not automatically enclose the tag in parentheses. To get
type \begin{equation}
\int_{-\infty}^{\infty} e^{-x^{2}} \, dx = \sqrt{\pi}
\tag*{A--B} \end{equation}
8.5 Tagging and grouping 203
Tagging allows numbered variants of equations. For instance, the equation ( 1)
may need a variant: ( 1 ′ )
If the label of the first equation is E:first, then the second equation may be typed as follows:
\begin{equation}\tag{\ref{E:first}$’$} A^{\langle 2 \rangle} \diamond B^{\langle 2\rangle} \equiv (A \diamond B)^{\langle 2 \rangle}
\end{equation} Such a tag is absolute in the sense that it does not change if the equation is moved. But
if it references a label and the number generated by L A TEX for the label changes, the tag changes. In contrast, grouping applies to a group of adjacent equations. Suppose the last equation was numbered (1) and the next group of equations is to be referred to as (2), with individual equations numbered as (2a), (2b), and so on. Enclosing these equations in a subequations environment accomplishes this goal. For instance,
and its variant (1b)
are typed as \begin{subequations}\label{E:joint}
\begin{equation}\label{E:original} A^{[2]} \diamond B^{[2]} \cong (A \diamond B)^{[2]} \end{equation}
\begin{equation}\label{E:modified} A^{\langle 2 \rangle} \diamond B^{\langle 2\rangle} \equiv (A \diamond B)^{\langle 2\rangle}
\end{equation} \end{subequations}
Referring to these equations, you find that \eqref{E:joint} resolves to (1)
\eqref{E:original} resolves to (1a)
204 Chapter 8 More math
\eqref{E:modified} resolves to (1b) Note that in this example, references to the second and third labels produce numbers,
(1a) and (1b), that also appear in the typeset version. The group label, E:joint, refer- ences the entire group, but (1) does not appear in the typeset version unless referenced.
A subequations environment can contain the multiline math constructs dis- cussed in Chapter 9 (see Section 9.4.4).