If I have the following piece of code, everything compiles:
\documentclass{article}
\newcommand{\mycmd}{
\edef\tmpcmd{test} % No commands with arguments
\tmpcmd
}
\begin{document}
\mycmd
\end{document}
But if it looks like this:
\documentclass{article}
\newcommand{\mycmd}{
\edef\tmpcmd{\textit{test}} % Has a command with argument
\tmpcmd
}
\begin{document}
\mycmd
\end{document}
Then I get a weird error:
! Undefined control sequence.
\GenericError ...
#4 \errhelp \@err@ ...
l.9 \mycmd
Why is this?


\edef\tmpcmd{\textit{test}}outside of\mycmd, much less inside a macro. Some macros are just not expandable. – Steven B. Segletes Jun 25 '15 at 11:52