I try to improve the time pdflatex needs to compile my book.
Really working example
book.tex
%&preamble
\begin{document}
Hi
\end{document}
and
preamble.tex
\documentclass{article}
I run the following commands on bash console:
$ pdflatex -ini -jobname="preamble" "&pdflatex preamble.tex\dump"
$ latexmk -pdf -pvc -e '$latex=q/latex %O -shell-escape %S/' book.tex
A window opens with a (nearly) live preview that will be updated after each change in the book.tex file. The PDF Viewer evince reloads automatic when the .pdf changed.
Open Questions
I had no success to compile with the preamble of my book in the preamble.tex file.
- How can I find out what I can precompile?
- Can I precompile
\newcommand's,\usepackage's? - Can I precompile a pure chapter without header?
Other aproaches for speed up
(I do not understand how to combine this ideas for best result)
pdflatexknows a-draftmodeI measured 20% faster compilation withtime pdflatex -draftmode 50pagetest.tex
\includemany chapters you can use\includeonlyin your master file (book.tex) to compile just the chapters you are editing at the moment. – Ethan Bolker Oct 29 '12 at 0:56\includeand\includeonlyworks only with separating the file's content on different pages. But for your final compilation you can change those\includeonlyback to\inputs. • Also related:mylatexformat– Qrrbrbirlbel Oct 29 '12 at 1:22\newcommand. Withmylatexformatyou can compile files with the same preamble, the files must have a\begin{document}and\end{document}– Guido Oct 29 '12 at 3:11bookdocument intopreamble.texandbook.tex? Also, what is the exact wording of the error message? – krlmlr Oct 29 '12 at 19:51