10

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?

Turion
  • 4,622
  • 2
    I found a very related question: http://tex.stackexchange.com/questions/3174/latex-macro-expander – Turion Jul 04 '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 04 '11 at 15:27
  • 3
    You don't need to expand your macros, you just need to include the style file(s) in the preamble. Take a look at: http://tex.stackexchange.com/questions/12554/submitting-a-journal-article-as-a-single-tex-file for some ideas on how to do this. – Andrew Stacey Jul 04 '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 05 '11 at 14:05
  • Writing a reasonable good Perl script which reads standard macro definitions from a given files and replaces these macros with the macro definitions would be reasonable simple. To support the full tricky TeX syntax however would be more or less impossible. Telling TeX to expand only a certain set of macros would be difficult. You could place the whole thing in an \edef environment while previously \let all other macros to `\relax. – Martin Scharrer Jul 05 '11 at 14:13
  • @Andrew: This was also my first idea. However publishers also seem to often forbid custom macros, so specific expansion would be preferable. – Martin Scharrer Jul 05 '11 at 14:15
  • @Martin: I've yet to encounter one that actually forbids them - I've gotten a few disapproving looks but never an actual forbidding. Nonetheless, this is quite close to some stuff I've done/am doing. I have written a Perl-script that understands TeX, and I am writing a TeX package that sort of knows when to stop expanding. The trick is really to provide a whitelist of macros that should not be expanded and then to expand everything else (rather than providing a blacklist of those that should be expanded). – Andrew Stacey Jul 05 '11 at 15:23
  • @Martin: The question I called related certainly is related if one follows Andrews advice to copy the style files in the preamble or uses Sam's arlatex/bundledoc.

    As so many "kinda related" questions showed up maybe someone can mark some of these as duplicates?

    – Turion Jul 05 '11 at 16:04
  • 2
    Sorry to dredge up an old post, but this SO post should be linked: http://stackoverflow.com/questions/17793815/using-sed-in-bash-script-to-replace-latex-aliases. – Sean Allred Aug 01 '13 at 14:52

1 Answers1

6

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.

Martin Scharrer
  • 262,582
  • 1
    Thanks for your contribution. I added the usual hyperlinks to CTAN. However, these packages seem to bundle all required files together, which might be an alternative solution to the problem, but isn't exactly what was asked. – Martin Scharrer Jul 05 '11 at 13:57
  • @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 05 '11 at 14:49
  • 1
    @Martin Sharrer : Yes, it's a working workaround to the problem; mainly arlatex is an alternative very close to the solution. – Sam Qasbah Jul 05 '11 at 14:52
  • While bundledoc automatically detects dependencies, it doesn't bundle everything up in one tex file. Arlatex does this, making it very convenient when you have to upload a single tex file to an automated tex document server (arxiv or similar), but you have to determine the dependencies yourself. Still, great hint! – Turion Aug 02 '13 at 11:19