Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to compile multiple files in one latex run

1,527 views
Skip to first unread message

Sven Siegmund

unread,
Feb 6, 2012, 5:26:03 PM2/6/12
to
Hello,

I have dozens of *.tex files (generated by a python script) which I
need to compile very often. The files are all very small, look all
very similar, all have the same preamble, the same structure, no cross-
references, and all compile to a one-page pdf document.

Currenty, I am compiling them from a loop in a python script, roughly
like this (in a pseudo-code):
for filename in listOfTexFiles:
tell shell to run "pdflatex "+filename

It does what I need, but it takes a lot of time. Seeing each time
latex starting up, loading the packages, compiling one file, then
terminating. Then latex starting up again, loading all the same
packages again, compiling another file ... Loading latex and the
packages takes about 40% of the whole compiling time.

Can't I do it any faster? Couldn't I load latex and the necessary
packages only once, and then run a series of commands which would spit
out dozens of similar pdf files and only then quit the latex program
instance?

Who knows how?

Marc van Dongen

unread,
Feb 6, 2012, 6:45:24 PM2/6/12
to
Hi,

I'm not sure if I've an answer, but how many files do you have? How
large are they?

Regards,


Marc van Dongen

Sven Siegmund

unread,
Feb 6, 2012, 7:53:25 PM2/6/12
to
> I'm not sure if I've an answer, but how many files do you have? How
> large are they?

Each *.tex file is about 2,4 KiB in size. I am currently testing my
script for the latex code generation and letting compile them to *.pdf
with a reduced data sample, so I work with only 27 files now. It
already takes 70 seconds to compile them all one by one (i.e. loading
latex, fonts and packages each time anew). The final amount of the
files will be around 1000 which would take some 43 minutes to compile
them all at the current speed.

I've waited for my 27 sample files to compile for about the 20th time
today, so I really would not mind some TeX command line magic by which
I could keep the packages and fonts loaded and only churn out several
pdf's from one continuous TeX compiler instance.

Looking forward to more suggestions,

Sven.

as

unread,
Feb 7, 2012, 12:49:25 AM2/7/12
to
Le Mon, 6 Feb 2012 14:26:03 -0800 (PST),
Sven Siegmund <sven.s...@gmail.com> a écrit :

> Can't I do it any faster? Couldn't I load latex and the necessary
> packages only once, and then run a series of commands which would spit
> out dozens of similar pdf files and only then quit the latex program
> instance?

You could try to do your own pre-compiled format. Don't know if it can
heavily speed up your process.
Have a look at
http://www.ctan.org/pkg/mylatex

Or compile only one document in which all your files are included via
\include or \input and then split the final pdf with an external tool
like pdftk.
http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/

--
Arnaud

Christoph Brendes

unread,
Feb 7, 2012, 2:27:48 AM2/7/12
to
Am Mon, 6 Feb 2012 14:26:03 -0800 (PST)
schrieb Sven Siegmund <sven.s...@gmail.com>:
You could use a master file which contains the preamble and include all
the small tex files. You will get one PDF which you can split into
separate pages.

Christoph

--
C. Brendes, Dipl.-Math.
Netzwerktechnologien
Tel: +49 (0)89 32399-359 / Fax: +49 (0)89 32399-354
--------------------------------------------------------------------------
Institut für Rundfunktechnik GmbH
Forschungs- und Entwicklungsinstitut von ARD, ZDF, DRadio, ORF und
SRG/SSR Floriansmühlstraße 60, 80939 München, Germany
Registergericht München HRB 5191
Geschäftsführer: Dr. Klaus Illgner-Fehns

Peter Knaggs

unread,
Feb 7, 2012, 4:27:46 AM2/7/12
to
as <no...@m.invalid> wrote:
> Le Mon, 6 Feb 2012 14:26:03 -0800 (PST),
> Sven Siegmund <sven.s...@gmail.com> a écrit :
>
>> Can't I do it any faster? Couldn't I load latex and the necessary
>> packages only once, and then run a series of commands which would spit
>> out dozens of similar pdf files and only then quit the latex program
>> instance?
>
> Or compile only one document in which all your files are included via
> \include or \input and then split the final pdf with an external tool
> like pdftk.
> http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/

This is the approach I took to a similar problem.
Except my files where of indeterminate length, anywhere from two or three
lines of text to two or three pages.

At the start of each logical file I throw a new page and write an entry
into the log file, along the lines of:

tag: filename sheet-number

This way the build script was able to scan the log to identify the start
of each logical file and use the pdftk program to extract the appropriate
pages.


--
Peter Knaggs

veldo...@gmail.com

unread,
Apr 12, 2013, 2:50:08 PM4/12/13
to
Hey Naggy daddy.
0 new messages