# Macro assignment problem

\docuentclass[pdftex,a4paper,12pt,oneside]{book}%

\begin{document}

\newcommand{\tmpa}{}
\newcommand{\tmpb}{}
\newcommand{\tmpc}{}

\renewcommand{\tmpc}{tmpc1}
\renewcommand{\tmpa}{\tmpc}
\renewcommand{\tmpb}{\tmpc}
\noindent tmpa: \tmpa \\
tmpb: \tmpb \\
tmpc: \tmpc \\
\renewcommand{\tmpc}{tmpc2}
tmpa: \tmpa \\
tmpb: \tmpb \\
tmpc: \tmpc

\end{document}


Result:

tmpa: tmpc1

tmpb: tmpc1

tmpc: tmpc1

tmpa: tmpc2

tmpb: tmpc2

tmpc: tmpc2

Changing the value of tmpc changes the values of the other two variables. How can I assign only the value of tmpc without this pointer like effect?

-
It is difficult to understand why you use \tmpc in \tmpa and \tmpb if you do not want this pointer effect'. Just define another command ?! You should provide more context so that one can think of a workaround. Right now, your problem appears rather unclear to me. – Alfred M. Apr 16 '12 at 7:03

When TeX finds a macro it expands it to its current meaning; so with

\newcommand{\tmpa}{}
\newcommand{\tmpb}{}
\newcommand{\tmpc}{}

\renewcommand{\tmpc}{tmpc1}
\renewcommand{\tmpa}{\tmpc}
\renewcommand{\tmpb}{\tmpc}


when \tmpa is found, it's replaced first by \tmpc and then by tmpc1 (which is what \tmpc is defined to expand to).

If you want to freeze the meaning, then \let is the instruction to use:

\let\tmpa\tmpx


will assign to \tmpa the current meaning of \tmpx and subsequent changes to the latter command will not influence the meaning of \tmpa.

There's no "LaTeX interface" to \let`, because such commands are intended to be used by "programmers" rather than "users".

-