The following MWE displays the problem.
\documentclass{beamer}
\begin{document}
\begin{frame}{Frame 1}
\def\test{hello}
\test % prints hello
\end{frame}
\begin{frame}{Frame 2}
\test % should print hello, but doesn't
\end{frame}
\begin{frame}{Frame 3}
\def\test{something new}
\test % prints something new
\end{frame}
\begin{frame}{Frame 4}
\test % should print something new
\end{frame}
\end{document}
I am using \def simply because it came as part of an answer I found elsewhere on this site. It seems that the macro \test is only defined within the scope of the environment (in this case frame so perhaps the problem isn't beamer dependent). How can I have the command \test defined globally (from this point on)?
\def\test{hello}in the preamble. It is safe to use\newcommandthough. – Feb 01 '15 at 13:54\gdefwas unknown to me and now that it is known it does the trick! Many thanks. – Geoff Feb 01 '15 at 14:05\defs embedded within a macro. Sometimes I need to make one change and keep all the rest the same.\gdefdoes indeed work. – Geoff Feb 01 '15 at 14:13