I'm using latex on a small netbook, and with average-sized files (~150 pages at the moment) compilation is already pretty slow. So I am looking for every way to speed up the compilation.
In this search, I found this page explaining how to "precompile a preamble", or, latexically-speaking, how to make a custom format file. That works fine enough.
But my preamble isn't as static as it should be, I keep adding or modifying definitions in there.
To mix the two solutions, at the moment, I use a Makefile together with latexmk, the makefile handling the regeneration of the .fmt file if needed, and latexmk taking good care of the rest.
But I have two problems with this :
- integration with
emacsto compile the whole document when working on a single file (makeneeds to be called in the proper directory) latexmkdoesn't recompile the file every time the preamble is modified, because it doesn't count as a dependency.
So I'd like to find a way to get rid of this Makefile, and get all the stuff done by latexmk.
I edited my .latexmkrc to include this :
pdflatex = 'pdflatex -fmt main %O %S';
add_input_ext('pdflatex','fmt');
add_cus_dep('tex', 'fmt', 1, 'compilepreamble');
sub compilepreamble {
print "Preamble compiling...\n";
$command = '&.pdflatex ./fmt/preamble.tex\dump';
system("pdflatex -ini -jobname='$_[0]' '$command'");
};
But with this, if the file main.fmt is not present or if fmt/preamble.tex is updated, the main.fmt file won't be regenerated.
Actually, in the first case, I get an error from pdflatex saying the it can't find main.fmt format file. So I understand latexmk doesn't even try to build main.fmt, it's probably not a problem in my custom dependency. However, I think I've added everything necessary for this to work.
So... Did I forget something? Is there a way round? Or is it a hopeless quest?