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:

enter image description here

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:

Some other resources:

  • 4
    In short: creating a format is closest you will get. Keeping this all in memory is not possible (because it's a file lookup each time). What you could try (never tested this myself) is to install a file watcher that copies the needed style files etc. into a ramdisk and adds this as local texmf tree. Maybe this could speed it up a bit, but probably it is not worth the effort. – TeXnician Aug 24 '18 at 9:49
  • @Hansimov But how much the gain would be is mainly subjective (IMO). So my concern is whether it is really necessary? But not to mention, in my limited experience with Tex, I suggest not to spend time doing this exercise. – Raaja Aug 24 '18 at 9:52
  • @TeXnician Thanks for your advice. I will have a try and test some benchmarks. – Hansimov Aug 24 '18 at 10:04
  • @Raaja Yes, you are right. I also considered this before. But I think 'it is better than never'. :P – Hansimov Aug 24 '18 at 10:07
  • @JohnKormylo This solution has been covered in my quesion descriptions as "Externalize graphics". – Hansimov Aug 25 '18 at 1:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.