Include the local definition in braces ({}).
\newcommand\foo{FOO!}
\foo
{\renewcommand\foo{BAR?}\foo\foo}
\foo
This will create something like:
FOO!BAR?BAR? FOO!
This can also be done inside macro definitions - just make sure you add extra curly braces:
\newcommand\newfoo{{\renewcommand\foo{BAR?}\foo}}
Hope this helps.
source
share