First, apologies for my lack of knowledge in this matter. I am trying the following code without really understanding every bit and piece of it.
Anyway, can anyone help me find what is wrong with the following code?
\def\pm #1#2{\@bsphack
\newcommand{\currentValue}{\ref{#1}}
\protected@write\@auxout{}%
{\string\newlabel{test\currentValue}{{#2}{\thepage}}}%
\@esphack}
My intentions? To define a \pm command that takes two arguments.
The first argument needs to be used as a reference itself in order to obtain another variable: \currentValue.
Then, this variable (\currentValue) is appended to some other text ('test') in order to create a new label.
Things look good, but for some reason, when the final label is created, an \hbox {} is appended to the end of the test\currentValue label.
Any idea what the problem is? Or how can I achieve my goal, if not in this manner?
\ref{key}is a command to print something. If can contain boxes or font commands. It is normally not suitable as part of the key of a label. You could try thezrefpackage. With it you can define reference commands which gives back "pure" values. – Ulrike Fischer Jun 19 '12 at 13:23