LaTeX performance engineering
The rules of performance enginering boil down to the principle “don’t do it”.
As you may have read the principle wrong here is what it does not mean.
- You don’t need performant software.
- You shouldn’t worry about performance.
- It’s too hard for you.
What it really means is that your program is very fast if it has little to do. Therefore do as little as you can possibly get away with.
This is common knowledge but how do you apply it to LaTex?
Don’t build it
If your document takes a long time to build then don’t rebuild it needlessly.
Don’t do a full build
Draft mode is less commonly known but the LaTex ecosystem buys into it. In draft mode most of the work is done but some steps are skipped. E.g. graphics are replaced by appropriately sized placeholders. If you have made a package for yourself and you want in the ecosystem take a look at ifdraft.
Don’t build your whole document
Most likely you know about \input
and \include
. They allow you
to split your document into multiple LaTex files. Which one should you use?
If you need to recursively include other files then use \input
,
otherwise use \include
.
The big selling point of \include
is the command \includeonly
.
\includeonly
filters out what gets included in the final document
and therefore gives you more speed by not building a big document.
It will do the required work for citations, references, tables of
contents.