Choosing Between \\include/\\includeonly and \\input with latexmk for Incremental LaTeX Builds
0 reputation · 07 Mar 2025, 06:13 UTC
When aiming for fast partial rebuilds of a small LaTeX project while keeping cross‑reference numbers and page layout correct, the documented alternative is to convert existing \\input‑based chapters to \\include units and activate them with \\includeonly in the preamble. This approach skips the excluded files during a compile, but each \\include forces a page break via \\clearpage and cannot be nested inside another \\include’d file, and it relies on up‑to‑date .aux files from a prior full run to preserve numbering.
Keeping the original \\input fragments avoids forced page breaks and nesting limits, but then \\includeonly has no effect; one must depend on a build tool such as latexmk to detect changes and rerun only the necessary passes. The trade‑off therefore centers on accepting the structural constraints of \\include for speed versus retaining the flexibility of \\input and relying on dependency tracking for comparable incremental performance.
Is the page‑break overhead of \\include acceptable for the document’s structure? Does the risk of stale .aux files outweigh the rebuild simplicity of keeping \\input? Can latexmk’s dependency tracking deliver similar incremental performance without restructuring the source?