Faster way to compile a document
I highly recommend recompiling often. Here are some thoughts which were too long for a comment:
- You can see whether your code corresponds to what you wanted to achieve.
- You get compiler errors quite early and thus you can detect and resolve them more early and easily. When I code some more complex math formulas, I even compile while writing the formulas to check whether what I wrote this far is correct.
- Some people (not me) like WYSIWYG editors like Lyx (LaTeX Editors/IDEs), so you might want to try or read about it. And some people use Lyx and apply some fine-tuning with another editor afterwards.
You might want to compare What are good learning resources for a LaTeX beginner?.
In the end you can choose your workflow freely, so just see this as my opinion. The problem is of course the runtime. You cannot always get what you want. These might "speed up" the runtime:
- Upgrade your engines (this helped me a couple of times). New distributions have just arrived.
- If you have a small document, compile time usually is not an issue. If you have a larger document like a book, consider to divide your project with
\input
or\include
and comment the temporarily uninteresting sections/chapters out or use\includeonly
or thesubfile
-package (as mentioned by TeXnician and samcarter). - Get a faster computer. Not an easy one.
- As others has have pointed out: Use
draft
modes. - If you use Tikz and plots, you might want to generate the plots using
gnuplot
. - Tikz is not build to be fast. Tikz-pictures can be externalized as pointed out by mickep correctly. You also might also consider
inkscape
as an alternative. - The use of
savebox
es might be appropriate. - I am not sure whether a different engine like
LuaTeX
might speed up the compile time. This also might depend on your use of the Lua language, e.g. I once gained several minutes by writing a script in Lua instead of using\foreach
directly. - Compiling a document on a terminal and not in a IDE might be faster.
- See Speeding up LaTeX compilation.
In a similar situation I decided, that when writing on a text passage I seldom need to see the whole document, but that compiling the current chapter/section/whatever is enough. For this task I use the subfiles
package. With this package I can both compile the main file to get the complete output and the individual chapters alone to save time. Compiling the individual will still have the packages from the main file available and the look and feel of the document will be the same.
My file look like this:
main.tex
:
\documentclass{book}
\usepackage{subfiles}
\usepackage{xcolor}% Just an example for all packages you want to use
\begin{document}
text
\subfile{chapter1}
\end{document}
and chapter1.tex
% !TeX root = chapter1.tex % not necessary, but some editors think they are smart
\documentclass[main]{subfiles}
\begin{document}
the content of chapter 1, \textcolor{blue}{using packages from the main file}
\end{document}
Most of the time I use this together with
\usepackage{xr-hyper}% or \usepackage{xr} if you don't use hyperref
\externaldocument{Chapter2}
which can be used to access labels etc. from for example other subfiles
or with
\usepackage{zref-xr}
\zxrsetup{toltxlabel}
\zexternaldocument*[main-]{main}
to access things like pagenumbers or chapter numbers from the main file.