The slowest part is a dozen of diagrams in TikZ.
|
|
Read section 63, "Externalizing Graphics", of the PGF Manual. |
|||||||||||||
|
|
You can try creating a Precompiled Preamble or "format" for your document. This technique basically caches all the computations that LaTeX does when processing the preamble which is the stuff before UpdateJust noticed the reference to TikZ- in this case Scott's suggestion is the most pertinent. Update 2:The mylatexformat package can aid in creating and using format files. |
||||
|
|
|
Another way to speed-up compilation is to figure out what it is that is making each picture slow and then do something about it. As a case study, it just took nearly 18s to compile the source for this seminar. That's a bit long for a compulsive recompiler like me! Watching the page numbers go by, I could see that the picture that takes the longest is on page 51. The source of this diagram is available and it's fairly clear that it's the torus that takes the time (there are two foreach loops, nested). If you look carefully at the start of the foreach loops, you'll see:
Even without looking at how the various commands are defined, it's clear that by changing them, I can change how many times these loops loop. Thus when I'm working on the diagram itself then I can use values that I'll use in the final document, but when I'm working elsewhere in the document, I can set them to something a little more user-friendly. Indeed, near the top of the document, I have:
which sets a global option (of course, I can override it for a particular picture when I'm actually working on it). (Note: One more tip: when working on a document with lots of diagrams, I often have a "diagram-only" file for working on a specific diagram at a time. This has the same preamble as my main document but only one diagram in it (the one I'm currently working on). It's like a scrap piece of paper. To save my working, when starting to a new picture then I just put a |
|||
|
|
Make is Your Friend!This problem was solved ages ago, so let's take advantage of all the nice tools Unix gave us! The best solution I can think of for a large document is to simply not have any To this end, I made a makefile (for GNU Make) that looks (and I do mean looks. Makefiles are old technology - so old that tabs are actually significant syntax...) sort of like this for a project of mine (ignore the syntax highlighting. tex.SE thinks this is TeX and it's obviously not):
How do I use that?!Whenever you'd use a You'll also notice that there is a rule for files matching |
|||
|
|
I use plain XeTeX†, so the externalization described in the TikZ manual doesn't work for me. But I've found a neat way to speed up my compilations. Like Andrew shows in his answer, I split the figures to their own
which will make a single page of the content I feed it with, having the contents dimensions (more or less). There would be some extra space though which needs to be removed by
Now after I do Then on the
Now every time I want a figure I can just write Of course, if I make changes to the † I realize the question title asks specifically about LaTeX, but in the question body the slowdown is attributed to using TikZ, so I hope I can share my experiences even though not with LaTeX. |
|||
|
|
|
If it's your TikZ graphics that are taking a long time, use the As for more general hints, if you are compiling a big document, but you only really need part of it to compile (e.g. if you're compiling a book, but only chapter 3 has changed) split the file into several files and use |
|||||
|
|
I don't use TikZ, so I've no idea if this will help with TikZ-related slowness. But, the question asks how to speed up compilation (in general). Using the |
||||
|
|
|
I would suggest using the regional compilation feature in AucTex. Of course you have to be using Emacs. The process is really easy:
A full compilation only happens when you want to get the whole document. If there's anything that I think help most I learned during making slides, it's the regional compilation in AucTex. |
||||
|
|
|
I am unsure for TikZ, but for XY-pic the command \CompileMatrices doesn't recompile your arrays, greatly speeding up the compilation time. |
|||
|
|
|
A more crude version of Andrew's suggestion would be:
This inserts the text "Picture" instead of any |
|||
|
|
