Is it possible to dump the expanded form of a command as text?
E.g. when I write a macro
\newcommand{\mytest}[1]{\texttt{#1}}
I would want to define a macro \mydump such that
\mydump{\mytest{Hello World}}
creates a literal text \mytest{Hello World} in the output file.
When experimenting with custom macros, I sometimes run into rather unhelpful error messages. It would help a lot to be able to view level by level, how the problematic command is expanded.
I know that there are commands like \show, but those are command line oriented. Usually however I will be working in a LaTeX editor, that by default doesn't even show the log file, e.g. TeXStudio or Emacs with AUCTeX. So a more practical solution would be to put similar information into the output pdf file.
I tried to produce the needed output with something along the lines of combining \verb and \expandafter, but this gives no viable results (due to how LaTeX parses text into tokens and expands tokens as macros).
