# label \theequation inside math

Code:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\begin{document}
\begin{align*}
J
&= J_0 + 2 m r^2
& \label{eq:asdf}\refstepcounter{equation}(\theequation)
&& \tilde{J}
&= J_0 + 2 m \tilde{r}^2 & \refstepcounter{equation}(\theequation)
\end{align*}
\eqref{eq:asdf}
\end{document}


Output:

I want to reference (1).

• You need to put \label after \refstepcounter (although using align* and then using \refstepcounter by hand is pretty odd:-) – David Carlisle Oct 3 '14 at 14:51
• Try running it twice. The first run writes the aux file, the second reads it. – John Kormylo Oct 3 '14 at 14:53
• May be of interest: http://tex.stackexchange.com/a/42728/2417 – Ian Thompson Oct 3 '14 at 14:58
• @DavidCarlisle: equation counter is set to 0 before I call \label. That means that there has to appear a (0). If that were true, I would be happy. – Michael Banucu Oct 3 '14 at 14:58
• \refstepcounter sets the current label (which is why you need to do that first, as for undoing amsmath definition John beat me by a few seconds:-) – David Carlisle Oct 3 '14 at 15:32

Amsmath sets \let\label=\@gobble in align*.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\begin{document}
\let\goodlabel=\label
\begin{align*}
J
&= J_0 + 2 m r^2
& \refstepcounter{equation}\goodlabel{eq:asdf}(\theequation)
&& \tilde{J}
&= J_0 + 2 m \tilde{r}^2 & \refstepcounter{equation}(\theequation)
\end{align*}
\eqref{eq:asdf}
\end{document}


• Ohh you beat me by 10 sec:-) – David Carlisle Oct 3 '14 at 15:31
• @David Carlisle - If it makes you feel any better, it took longer than that to crop the image. – John Kormylo Oct 3 '14 at 15:36
• @JohnKormylo: what is \@gobble? – Michael Banucu Oct 3 '14 at 15:45
• @Michael Banucu - I've seen it before but never seen the \def. I've always assumed from context that it eats arguments, but otherwise does nothing (like \relax). – John Kormylo Oct 4 '14 at 4:00