Is there a way/an existing tool to process a LaTeX source document such that for a given list of macro definitions (using \newcommand), calls to those macros are replaced by their expanded version?
Imagined work-flow:
<program> source.tex macros.tex > output.tex
where
source.tex:
\documentclass{article}
\newcommand\Rbb{\mathbb{R}}
\newcommand\Cbb{\mathbb{C}}
\newcommand\jb[1]{\langle #1\rangle}
\begin{document}
On $\Rbb$ we define $\jb{x} = \sqrt{1 + x^2}$, while on $\Cbb$ we
define $\jb{x} = \sqrt{1 + |x|^2}$ where the square root is taken
for the real numbers.
\end{document}
macros.tex:
\newcommand\Rbb{\mathbb{R}}
\newcommand\Cbb{\mathbb{C}}
\newcommand\jb[1]{\langle #1\rangle}
And the desired output is:
output.tex:
\documentclass{article}
\newcommand\Rbb{\mathbb{R}}
\newcommand\Cbb{\mathbb{C}}
\newcommand\jb[1]{\langle #1\rangle}
\begin{document}
On $\mathbb{R}$ we define $\langle x\rangle = \sqrt{1 + x^2}$, while on $\mathbb{C}$ we
define $\langle x\rangle = \sqrt{1 + |x|^2}$ where the square root is taken
for the real numbers.
\end{document}
Motivation Sometimes my collaborators and I have conflicting items in the personal list of macros that we usually use. To make life easier on myself I would like to prepare my edits using my personal macros to make typing faster. But before merging I would like to flatten out all such macros so that they don't conflict with the ones used by my coauthors.
de-macroin that linked question. The documentation for that package on the CTAN website is very brief. Would you saying a few more words about it? (I've just tested it and the result doesn't look too promising: it introduced an extra brace to the preamble causing a syntax error, and made zero changes to the body. It is likely that I am using it wrong.) – Willie Wong Jan 06 '14 at 11:24.styfile; all I did was change the filename to reflect the requirement (I assume, based on the documentation) that it ends in-private.sty. – Willie Wong Jan 07 '14 at 08:19