0

Is it possible to print the exact definition of a macro?

For example, the code

\def\foo#1{\bar\baz}
\printdef\foo

should result with \bar\baz.

If we define (as suggested in a similar question)

\def\printdef#1{\texttt{\meaning#1}}

then the result is macro:->\bar \baz, which is slightly different.

Skeeve
  • 153
  • 4
  • 3
    def\foo#1{\bar\baz} and \def\foo#1{\bar \baz } are identical definitions, the space characters are never tokenised or part of the definition, so you can not tell which was used – David Carlisle Dec 22 '22 at 20:02
  • 1
    When you ask TeX to show a definition, with \show or \meaning, it will always add a space after every control word. The token itself is stored in an internal (and not accessible) way (with a pointer to the name, stored elsewhere), so there's not much you can do. But \bar \baz is the exact definition. – egreg Dec 22 '22 at 21:25

0 Answers0