Forest
Reference
3.20 Externalization¶
Externalized tree pictures are compiled only once. The result of the compilation is saved into a separate .pdf file and reused on subsequent compilations of the document. If the code of the tree (or the context, see below) is changed, the tree is automatically recompiled.
Externalization is enabled by:
\usepackage[~external~]{forest}
~\tikzexternalize~
Both lines are necessary. TikZ’s externalization library is automatically loaded if necessary.
external/optimize¶
Parallels /tikz/external/optimize: if true (the default), the processing of non-current trees is skipped during the embedded compilation.
external/context¶
If the expansion of the macro stored in this option changes, the tree is recompiled.
external/depends on macro=⟨cs⟩¶
Adds the definition of macro ⟨cs⟩ to external/context. Thus, if the definition of ⟨cs⟩ is changed, the tree will be recompiled.
Forest respects or is compatible with several (not all) keys and commands of TikZ’s externalization library. In particular, the following keys and commands might be useful; see [Tantau 2007, §32].
/tikz/external/remake next
/tikz/external/prefix
/tikz/external/system call
\tikzexternalize
\tikzexternalenable
\tikzexternaldisable
Forest does not disturbe the externalization of non-Forest pictures. (At least it shouldn’t …)
The main auxiliary file for externalization has suffix .for. The externalized pictures have suffices -forest-\(n\) (their prefix can be set by /tikz/external/prefix, e.g. to a subdirectory). Information on all trees that were ever externalized in the document (even if they were changed or deleted) is kept. If you need a “clean” .for file, delete it and recompile. Deleting -forest-\(n\).pdf will result in recompilation of a specific tree.
Using draw tree and draw tree’ multiple times is compatible with externalization, as is drawing the tree in the box (see draw tree box). If you are trying to externalize a forest environment which utilizes TeX to produce a visible effect, you will probably need to use TeX’ and/or TeX”.