In this previous question, we defined a new command \owntag
to combine the equation number with a user-defined tag:
\documentclass{article}
\usepackage{amsmath}
\newcommand{\owntag}[1]{\stepcounter{equation}\tag{\theequation, #2}}
\begin{document}
\begin{align}
F=ma \owntag[eq:newton]{Newton}
\end{align}
My equation is \eqref{eq:newton}.
\end{document}
As you can see, we can reference the equation getting the format "1, Newton" as a reference. I would like to extend this command such that I can
- reference to the equation using only the number (i.e. "eq. (1)")
- reference to the equation using only the text (i.e. "eq. (Newton)")
To implement the first goal, I tried to add an additional counter, set it to the value of the equation counter, do \refstepcounter
and put the \label
right after it, but still get "(1, Newton)" as a reference:
\documentclass{article}
\usepackage{amsmath}
\usepackage{xifthen}
\newcounter{equationwotag}
\newcommand{\owntag}[2][]{\ifthenelse{\equal{#1}{}}{
\stepcounter{equation}\tag{\theequation, #2}
}{
\setcounter{equationwotag}{\value{equation}}\label{#1}\stepcounter{equation}\stepcounter{equation}\tag{\theequation, #2}
}}
\begin{document}
\begin{align}
F=ma \owntag[eq:newton]{Newton}
\end{align}
My equation is \eqref{eq:newton}.
\end{document}
How can I achieve these two methods of referencing?