I often use LaTeX to write documents and use TikZ/PGF to draw multi-page pictures.
However, one common issue (which has been discovered hundreds of times) is that even small change will take some time to recompile. The time of recompilation is not too long, but still annoying.
I find that most of the time is wasted on loading packages and some other files, like .sty, .cfg, .def, .tex and so on. Just as the following picture shows:
So here comes my questions:
- Is this package-loading process the main cause of time consumption?
- If so, is it possible to keep these files (.sty, .cfg, .def, ...) in memory in order to speed up each compilation? Since we seldom change the preamble of the tex file, and even it is changed, it seems not hard to detect these changes and load the missing files.
I know there have been some similar questions, and I have read almost all of the answers, comments and related articles -- for a large number of times -- since this question keeps tormenting me again and again.
And I always say to myself: 'Well, if this could be solved, then someone would have solved this. Do not ask a new question.'
However, it seems few practical methods are provided to solve the problem of recompilation. While most of the answers claim that we cannot avoid recompilation, I wonder whether there are any more fundamental methods to speed up the recompilations.
Here are some fine solutions I have discovered (welcome to add more):
- Use
-draftmode - Externalize graphics
- Precompile the preamble (which is much close to my ideal solution, but not work in some cases)
Some related questions in TeX.SE I have read:
- Speeding up LaTeX compilation
- How to speed up LaTeX compilation with several TikZ pictures?
- Ultrafast PDFLaTeX with precompiling
- Externalizing tikz with precompiled preamble
- Precompile header with xelatex
- How to speed up pdflatex for a very large document on MacOS X?
- Speeding up compilation using precompiled preamble with LuaTeX
Some other resources:

initexis no longer maintained. – Hansimov Sep 17 '18 at 04:21