2

Let's say I have have the file asdf.tex which contains the code:

\documentclass{article}
\newcommand{\asdf}{blabla}
\begin{document}
    \asdf is very cool!
\end{document}

How can I compile my latex to a version asdf_standard.tex where only the standard latex is used, i.e.:

\documentclass{article}
\begin{document}
    blabla is very cool!
\end{document}

I'm sure the compiler does this kind of procedure at some point anyway, so how can I get this as a file?

Thanks for your replies!

4
  • 1
    In general you can not do this, and no latex at no point generates an expanded document of that form. Feb 22 '15 at 21:00
  • 3
    There is de-macro. It won't be a general solution - I assume it handles things like macros used as abbreviations (i.e. simple cases). Also, note that I've no personal experience with the package. I only wish somebody would accept any kind of .tex file from me!
    – cfr
    Feb 22 '15 at 21:10
  • 2
    Welcome to TeX.SX! Your question looks very much like a duplicate of Is there a script that reads a TeX file and replaces every instance of a \newcommand? Feb 22 '15 at 21:10
  • "I'm sure the compiler does this kind of procedure at some point anyway" To my understanding, this is only part of the picture. The actual process is simpler and more powerful, but makes this kind of 'search and replace' impossible. In fact, your best bet would be a regular expression search and replace – this is likely what 'de-macro' does. Feb 22 '15 at 21:36

Browse other questions tagged or ask your own question.