[Tex/LaTex] Concatenate two strings to make a new command

cross-referencingequationsmacros

I took some habits with my sciences reports so I developed some personalized commands.

First, I define in the preamble all the variables that I need like this:

\newcommand{\cvba}{Cv_{\beta/\alpha}}
\newcommand{\za}{z_{\alpha}}
...

Then I begin all my equation labels by "eq:" like in this example :

\begin{equation}
  \za = \frac{1000.-T}{34}
  \label{eq:za}
\end{equation}

And finally, I set a command which allows me to make a reference from a variable to its definition inside the environment equation :

\newcommand{\eref}[2]{\hyperref[eq:#1]{#2}}

In this example, za will point to the previous equation :

\begin{equation}
  \cvba = \eref{za}{\za}+12
  \label{eq:cvba}
\end{equation}

My problem is that I would like to make my new command eref a little bit easier and lighter to use such as it takes only one parameter.

I tried to define it like this :

\newcommand{\eref}[1]{\hyperref[eq:#1]{\#1}}

Obviously it doesn't work because the \# is understood as a specific character.

So my question is : "How could I concatenate two strings to make a new command?"

If it can helps, the names of my variables can change, for example they could be \var_varname such as he new command would looks like :

\newcommand{\eref}[1]{\hyperref[eq:#1]{\var_#1}}

Best Answer

instead of

\var_#1

you want

\csname var_#1\endcsname