I am trying to create the following, but haven't been able to find anything here or elsewhere online...
I want to create an equation with a custom counter and then call the value of the counter when it was used in that equation. For example consider this.
\newcounter{opt}
\[
ax + b = c
\refstepcounter{opt}
\label{eq:1}
\]
\ref{eq:1}
This final \ref
call produces the value 1
, as I desire. However, I'd like to tag the equation with a non-standard tag, eg \tag*{$(P_1)$}
. I can do this as follows.
\newcounter{opt}
\[
ax + b = c
\refstepcounter{opt}
\label{eq:1}
\tag*{$(P_\theopt)$}
\]
\ref{eq:1}
This gives the correct tag, however now the \ref
call produces (P_1)
, instead of just 1
.
How can I adapts this so that I get the desired tag and I can reference the equation and get the value of the counter?
This, "Referring to label and value of counter at that point", is a highly related post. It's doing something a bit more in-depth than I am trying to do, and I can't understand what's going on well enough to adapt it...
If it helps, the context is the following. I have an optimisation problem, and I want to label two equations (P_1)
and (C_1)
using the same counter opt
. I then want to call this as (P,C)_1
; I was going to do this by writing (P,C)_\ref{eq:1}
.
I suppose, all I actually want to be able to do is to write a different thing in the brackets ()
on the equation line to what I \ref
produces.
If there's a better way of doing this, I'm all ears!
(P_1)
, as you say. However, I want to be able to call from the label just the value1
. This is what I can't work out how to do. \\ Hopefully the context I've added makes it clear! :)