# Is there a LaTeX/TeX preprocessor/inliner that replaces only selected macros with their definitions?

I have the following situation:

Like most LaTeX users that write much, I have my own header files where the packages I use normally are required and the macros I use often are defined.

So if I write some article, I will normally use my own macros and save a lot of time and redundancies.

Now I send in my article to some journal and they want to publish it! Of course they want me to send in my source code.

Naturally, the following problem arises: The publishers won't want to include my own headers. They want code that compiles on every regular TeX-distribution. How can I convert my source into a file that doesn't contain my own macros anymore?

I need something like a preprocessor, that "inlines"/expands all macros and definitions found in the headers I explicitly specify (my headers), but not those in the other, unmentioned packages (regular headers).

Does anything like this exist? Could it be implemented using TeX/LaTeX or would one have to reimplement the macro expansion mechanism?

-
I found a very related question: tex.stackexchange.com/questions/3174/latex-macro-expander –  Turion Jul 4 '11 at 14:52
Depending on how smart your macros are, some of them could just be find/replaced with sed or similar tool... –  Seamus Jul 4 '11 at 15:27
You don't need to expand your macros, you just need to include the style file(s) in the preamble. Take a look at: tex.stackexchange.com/questions/12554/… for some ideas on how to do this. –  Loop Space Jul 4 '11 at 16:09
@Turion: I can't see why it is really related, especially the accepted answer there doesn't work here at all. –  Martin Scharrer Jul 5 '11 at 14:05
Sorry to dredge up an old post, but this SO post should be linked: stackoverflow.com/questions/17793815/…. –  Sean Allred Aug 1 '13 at 14:52

Take a look at arlatex or bundledoc. They are both scripts that are contained in the TeXLive distribution. They could do the job you need.
@Turion : I got the TL2011 pretest on a linux machine, and arlatex IS included in the distribution. Please, try arlatexin a terminal, texdoc arlatex to read the documentation. –  Sam Qasbah Jul 5 '11 at 14:49