My main TeX template has a whole bunch of commented out packages and options (so that when I need a package, I can just skim my preamble and comment out the right thing, rather than try and remember the exact name of the package).

I also have quite a few packages that I load by default, and I'm not sure which of them I really need in any given file. I could go through one by one, commenting them out and seeing what breaks stuff, I suppose, but if it's not slowing stuff down, I might as well not bother...

Does having a lot of extra commented out lines slow compilation of tex documents? Does loading packages that aren't used at all slow down compilation?

  • What about to try having template.tex with all known packages and their short descriptions and basic commands. When writing new document, copypaste this source and delete everything You don't need.
    – Crowley
    Aug 9, 2010 at 1:47
  • I do this, but I don't delete the commented out stuff I don't need.
    – Seamus
    Aug 9, 2010 at 10:58
  • 1
    When a 16MHz 286 was the new shiny, I used to worry about this. ;)
    – msw
    Aug 10, 2010 at 2:36

2 Answers 2


Commented out lines will slow compilation, but by such a minuscule amount that it is not worth worrying about it.

Unnecessary packages will slow down compilation by a meaningful amount and if you are concerned about compilation time it is worth stripping things down to a minimal set of required packages. (This is also a good idea anyway, due to the multiple obscure interactions between packages, there are fewer chances for unpleasant surprises if you only load the ones you need.)

  • 6
    Perhaps worth noting is that the only way in which compilation is slowed down by commented out options is the extra amount of time it takes to scan the bytes (starting from '%') to the end of line and discard those. So, yes it slows compilation down, but only by nano-seconds (micro-seconds at the most).
    – Giel
    Aug 8, 2010 at 15:03
  • Just to nit-pick: loading extra stuff you don't need also slows down compilation because the extra control sequences and pool strings reduce the efficiency of the overall program execution (but just by nanoseconds, not by a measurable amount). Aug 8, 2010 at 18:25

It's worth avoiding loading packages you don't need, not because it'll slow things down (though I suppose it might, a little bit), but because you want to avoid nasty interactions between packages.

It's one of the standard problems of the LaTeX kernel that packages have no real way of isolating themselves from each other (the LaTeX 3 team are addressing this). Quite often, packages work by overloading some part of the LaTeX internals, but no matter how carefully they do that, the end result is more fragile than you'd want. It also means that packages can work, or not work, depending on the order in which they're loaded: the hyperref package, for example, has to be loaded last, but before the packages that have to be loaded after it (confused yet?). Then you have to worry about different versions of packages in different distributions.

Also, if you have some problem in your document, possibly as a result of two packages clashing, then the more packages you've loaded, the longer is the process of working out which two packages are squabbling.

Myself, I try to limit myself to only those packages which must be present in a document. That saves trouble for me, in the future, but also for any co-authors who might have slightly different installations.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .