TikZ externalization vs. inline rendering for figure-heavy documents without shell escape
0 reputation · 03 Dec 2023, 13:38 UTC
0 reputation · 03 Dec 2023, 13:38 UTC
When maintaining a figure-heavy LaTeX document in a build environment where -shell-escape is disabled, the choice between TikZ's external library and inline rendering becomes a trade-off between compilation speed and build simplicity. The external library can pre-compile each picture to a separate PDF, but without shell escape it relies on the mode=list and make fallback, which generates a Makefile and assumes a Unix-like environment with GNU make plus a separate manual build step. Inline rendering avoids special flags entirely, yet re-executes all figure code on every run, making iterative edits slow.
An unresolved concern is how externalization interacts with TikZ features that depend on global document state, such as remember picture and overlay. Because each picture is compiled in isolation, these features can produce stale or blank images unless the external step is repeated, and the behavior varies across PGF releases. The question is which approach to adopt when the build pipeline cannot invoke the TeX engine as a subprocess and the document mixes many standalone figures with overlay-dependent ones.
Should the document use externalization via mode=list and make despite the added build complexity, or fall back to inline rendering to preserve overlay correctness? How can a figure-heavy document balance recompilation speed against reliable remember picture support in a no-shell-escape environment? Is the external library's isolation behavior stable across current TeX Live versions, or does it require per-version adjustments?
31775 reputation · 03 Dec 2023, 15:02 UTC
shell-escape is disabled, the choice between TikZ externalization and inline rendering depends on whether you prioritize build speed or visual correctness for complex layouts.For documents heavily utilizing remember picture and overlay, inline rendering is the recommended fallback. While externalization via mode=list can offer speed benefits by pre-compiling figures, its isolation nature often breaks features that rely on the global document state to calculate coordinates.
When shell-escape is restricted, the TikZ external library cannot automatically trigger the TeX engine to process figures. To bypass this, you must use externalize [mode=list], which generates a Makefile. This introduces several complexities:
remember picture require the engine to know the final page layout to position elements correctly. In an isolated compilation, these coordinates are often zeroed out or incorrect.Inline rendering is the most stable approach for no-shell-escape environments because it processes the TikZ code as part of the main compilation pass. This ensures:
overlay and remember picture have full access to the global document state.If inline rendering is too slow but you cannot use shell-escape externalization, consider these hybrid strategies:
standalone LaTeX files. Compile them once manually and use \include in the main document. This gives you the speed of external PDFs without the TikZ library's automation logic.\if toggle to comment out heavy TikZ code during iterative text editing, and uncomment it only for the final production build.Diagnostic Question: Does your document rely on remember picture to position figures relative to specific text nodes nodes, or are the figures mostly self-contained diagrams?
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.