Take a look this description. It's a description of how to format the preamble yourself. Assuming your source file is main.tex, it all comes down to these steps (which were copied from the link and modified by me for my own use):
Rearrange your preamble so that its static part precedes any dynamic part. What in the preamble can be “dynamic”? For example, if you use \includeonly, you probably want to change its argument rather frequently and so it is not static. Finally, some packages read and write auxiliary files when you issue a command that you should put in the preamble (eg, nomencl uses \makenomenclature). Clearly, you have to run these
commands in every run.
Extract the static part of the preamble into, say, preamble.tex. At this point, main.tex no longer contains the static part. It should start with the dynamic part, or simply `\begin{document} if you have nothing dynamic.
Execute:
pdflatex -ini -jobname="preamble" "&pdflatex preamble.tex\dump"
in the command line. You will notice that a new file `preamble.fmt has
been generated in the same directory, along with other auxiliary files.
Edit the first line of main.tex so that it starts with %&preamble.
Execute latex main.tex as usual:
pdflatex -shell-escape main.tex
You may get an error about the class file immediately, or you may notice that latex finishes as usual. But if you have paid attention to the output, or if you inspect the the log file, then you will see that the preamble gets processed in “no time” at all. At this point, cheers!
To make things slightly fancier, here is an modification. First, add this to the end of preamble.tex:
\def\preambleloaded{Precompiled preamble loaded.}
Then, before the dynamic preamble (or \begin{document} if there is none) of
`main.tex, add:
\def\ifundefined#1{\expandafter\ifx\csname#1\endcsname\relax} \ifundefined{preambleloaded}
\typeout{PRECOMILED PREAMBLE NOT LOADED}\input{preamble} \else
\typeout{\preambleloaded}
\fi
The idea is to define a macro in the precompiled preamble and use it to detect if the precompiled preamble has been loaded or not. If not, \input{preamble} will be used to pull the static preamble back in and you will not see any error at all.
Also, if you are using tikz to make figures, have a look at the external library. Check the Tikz and Pgf manual, section 32 describes how to use it.
preambleandmainto get the standard compilation time. Als, I don't uselatexmkand therefore do not know what it does exactly, my guess is that it only compilespreamble.texonce. You could check this by constructing a very bulky preamble and running that several times, looking for speed changes. As for dynamic commands, I just meant the commands that you might alter a lot when working inmain.tex(eg. a macro that might change). Macro's that edit auxiliary files should also be considered dynamic (as mentioned above). – romeovs Jun 12 '11 at 15:15draftmode, ... :-( The problem with the dynamic commands is: I'm not sure which of them might modify .aux files and before I spend much time for finding out, it might be the better choice to just go on writing my thesis. :-( – MostlyHarmless Jun 12 '11 at 15:24\tikzexternalizein my dynamic preamble, because I might change it's options from time to time, that's all. – romeovs Jun 12 '11 at 18:16\begin{document} \end{document}, does it also take 8s to compile this file withpdflatex? – MostlyHarmless Jun 12 '11 at 18:55"&latex preamble.tex\dump"width"&pdflatex preamble.tex\dump"because I have JPG-images. May you’d like to add a nota abut this to your answer. – Tobi Jan 11 '12 at 16:09