I would like to tag two parts of a huge equation using underbraces (and call them, say term A and term B). Later in the text, I want to talk about term A and term B. Is there a way to tag and label A and refer to it using ref later? Currently, I'm having to manually type in A, B, C, etc. and keep referring to
check if I'm referring to the right tag.
\documentclass{article}
\usepackage{amsmath}
\usepackage{mathtools}
\begin{document}
\begin{equation*}
\sum_{i=1}^n (i + i^2) = \underbrace{\sum_{i=1}^n i}_{A} + \underbrace{\sum_{i=1}^n i^2}_{B}
\end{equation*}
Later in the text, I want to talk about term A and term B. Is there a
way to tag and label A and refer to it using ref later? Currently,
I'm having to manually type in A, B, C, etc. and keep referring to
check if I'm referring to the right tag.
\end{document}
I want to replace _{A}
with something like _{\tag{A}\label{eq:term1}}
. And then, later in the text say Term~\ref{eq:term1} is blah blah blah
(where of course, blah blah blah is $n*(n+1)/2$
.)
Best Answer
You can use
\mytag{<tag>}{<label>}
as defined in the following MWE:You supply the
<tag>
you want to put down for the label, as well as the regular label<label>
.\mytag
prints<tag>
using\text{<tag>}
(fromamsmath
) and then performs the regular label-writing to the.aux
file (taken fromlatex.ltx
). That allows you to use\ref{<label>}
to retrieve<tag>
again.Note that this does not support usage with
hyperref
. Modifications are required in order for that, but it is doable. Wait for it......and now with
hyperref
support:As it stands, these two methods are exclusive. That is, if you want
hyperref
support, the second approach works. If you do not want support forhyperref
, then you should go with the former.