7

I am working on a document (using the scrbook class, if it is relevant) which will end up consisting of lots of text and a large number of tikz figures. Even when writing the very first chapter, I notice that running pdflatex, bibtex and makeindex takes a considerable amount of time. I expect this to become worse (i.e., even longer) when the amount of text and figures increases.

I already structured my document into a number of files, since, during writing, I often make changes to only one part of the whole document (e.g., one chapter or one part of the appendix). Is there any way to reuse the files generated by pdflatex during the last run to get a preview of the updated document (without having to wait for the document to be rebuilt completely)?

I would be fine with things like the TOC not being updated. My current toolchain and editor are set up on both, Windows (MiKTeX) and Linux (TeX Live), but I could live with being limited to one of the two platforms. My highest priority is to reduce the build times required for previewing.

6
  • 6
    use \include for each chapter and then use \includeonly{chapter4} tp preview chapter 4. This is exactly why \include is there. Oct 20, 2015 at 12:33
  • is it the case that you want the entire document to be available in the pdf file when you reprocess only one part of it, or would you be satisfied to have only the reprocessed segment in the new pdf file? (the latter is what you get with \include and \includeonly.) Oct 20, 2015 at 14:16
  • \nofiles in the preamble prevents update of the ToC like files
    – user31729
    Oct 20, 2015 at 14:43
  • @DavidCarlisle: Thanks, I did not know about \includeonly until now. Is there any LaTeX editor or tool which allows automating this (or at least semi-automatically generating some of the necessary commands)? Oct 20, 2015 at 16:01
  • 1
    not sure how you could automate \includeonly, hard to know what you need to include. emacs (of course) has other possibilities for example you can mark a region (eg just one equation) and it will in the background construct a temporary document using your document preamble but just that equation and open up a previewer, I assume other editors can do something similar (but I've only used emacs since 1987 so I wouldn't know:-) Oct 20, 2015 at 16:11

1 Answer 1

2

I am not aware that pdflatex or other latex programs can do incremental compilation, tikz can cache the created images by using tikzexternal, from the manual:

50.4 Externalizing Graphics

\documentclass{article}
% main document, called main.tex
\usepackage{tikz}
\usetikzlibrary{external}
\tikzexternalize % activate!
\begin{document}
\begin{tikzpicture}
\node {root}
child {node {left}}
child {node {right}
child {node {child}}
child {node {child}}
};
\end{tikzpicture}
A simple image is \tikz \fill (0,0) circle(5pt);.
\end{document}

The method works as follows: if the document is typeset normally, the library searches for replacement images for every picture. Filenames are generated automatically in the default configuration. In our case, the two file names will be main-figure0 and main-figure1. If they exist, those images are simply included and the pictures as such are not processed. If graphics files do not exist, steps are taken to generate the missing ones.

4
  • 1
    There is also the draft option for including graphics in general, this way graphics are not included and only a placeholder is put in the document.
    – gdkrmr
    Jun 14, 2018 at 11:28
  • Thanks for pointing this out. For my use case, however, this is not practical since I rely heavily on visualizations. Jun 14, 2018 at 17:03
  • I am sure that there is a way to turn use draft in parts of the document only, this way you build only the visualizations that you are currently working on.
    – gdkrmr
    Jun 15, 2018 at 7:14
  • You can also have your chapters in separate files and use \include{...} and \includeonly, see here: tex.stackexchange.com/questions/87010/…
    – gdkrmr
    Jun 15, 2018 at 7:16

You must log in to answer this question.

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