Portable LaTeX?

This isn't explicitly a question on TeX syntax, but is there a program available (or a flag for latex itself) that will create a complete standalone LaTeX file from one that has multiple dependencies?

-
There is a very trivial solution. For example, if your top-level file is called a.tex you could create a file that has one line: \input{a.tex}. This is probably not what you mean. Besides that I don't know any solutions. Why do you need this? –  Marc van Dongen Oct 10 '12 at 4:32
Sorry for getting back you so late, @MarcvanDongen, but my ideal solution would resolve all \inputs (even those hidden by \usepackage, using makeatletter and friend as necessary) to produce a single file to be processed by latex with a minimal TeX distribution. Alternatively, something that compiles LaTeX to plain TeX would be pretty cool, too. –  Sean Allred Apr 21 '13 at 13:19

There are bundledoc and arlatex.

The bundledoc package builds an archive which contains all needed LaTeX files (tex, cls,...).

arlatex is a Perl-script based on bundledoc which generates a single tex file, which in return produces the other files by using filecontents.

-

I am going to assume a few things:

• You are not doing something funny (with \write18, for example)
• The latex base format is ok for you (meaning you do not have to include it)
• The fonts do not have to be included

First of all, use the \listfiles command in the preamble. The include all the latex files listed by this command into your file using the filecontents package. Pray that my assumptions are ok to whatever non-god you have (the Leslie Lamport Lion?). Send the file.

-