Somewhere in my document there is a theorem labelled theoremA
that has the number 2.21
. Later, I want to set another counter to that specific number 21
.
First, I tried \setcounterref{newcounter}{reference}
which does not work as I expected it to: theoremA
has the counter value 2.21
and \setcounterref
sets newcounter
to 2
instead of 21
.
To fix this, I tried \setcounter{theorem}{\StrBehind{\getrefnumber{orbitcomeagre}}{.}}
which yields the error Missing number, treated as zero
even though \StrBehind{\getrefnumber{orbitcomeagre}}{.}
has the correct value of 21
.
Does anyone have any suggestions how I can fix this?
Best Answer
Maybe I'm missing an important complication, but I think all you need to do is (a) define a "scratch" counter variable named, say,
scratchcounter
, in the preamble and (b) use an instruction such asimmediately after the theorem in question to store the number of the theorem (minus the "prefix") in the counter named
scratchcounter
. Its value may be accessed elsewhere in the document via\thescratchcounter
.