Suppose I have a document with multiple include or input statements
\input{fileA}
\input{fileB}
etc.
Is there an easy way to generate a single .tex
file where \input{fileA}
is replaced by the actual content of fileA
etc. without copying it manually?
Best Answer
You can use the following tools to do this. All of them are on CTAN but not all of them are part of either TeXLive or MikTeX, so you may need to manually install them. They need either Perl or a C compiler installed. Both should not be a problem with Linux but might be one under Windows or Mac. However IIRC TeXLive installs its own Perl interpreter.
latexpand
Perl script:Installation:
Simply download it from http://mirrors.ctan.org/support/latexpand/latexpand and run it. You need Perl installed however.
Usage:
flatex
Installation:
Get the single C file and compile it, e.g. with
cc flatex.c -o flatex
.Usage:
flatten
Installation:
Get the ZIP file from CTAN, unpack it and run
make
followed bymake install
. You need a C compiler and maybeflex
for this. However it seems quite old and you might run in trouble because of it. I failed compiling it!Usage: