Working with large documents

Books, theses, and long reports make the edit-compile loop heavy — builds get slow, one giant file is awkward, and keeping numbering and references consistent across hundreds of pages is hard. This chapter breaks a long document into a shape you can keep writing every day: split by chapter, build only the part you are editing, and switch between draft mode and clean full builds deliberately.

What gets hard at scale

As a document grows you hit: (1) slow full compiles, (2) a single file too long to navigate, (3) the chore of keeping cross-references, numbering, and the table of contents consistent across chapters, and (4) errors that are hard to localize. All of these ease a lot once you split the document and process only the part you need.

Split it into files

The basic shape is one file per chapter, with a thin main file tying them together. It is easier to find your place, easier to divide work with co-authors, and your diffs stay small. The inclusion mechanics (\input / \include / subfiles) are covered on “Multi-file projects”; for chapter-level pieces, \include is the right tool (it page-breaks around each piece and gives each its own .aux).

Compile only the chapter you’re editing — \includeonly

If you split with \include, putting \includeonly{the-chapter-you-are-editing} in the preamble processes just that chapter. Because each chapter’s .aux retains the values from the last full build, the page numbers and cross-references of the skipped chapters stay correct. A multi-minute full build becomes a few-second partial one. The important habit is to do one full build first. If you skip chapters before their .aux files exist, references stay as ?? or page numbers remain stale. Combine this with latexmk’s incremental builds or -pvc and the waiting shrinks to almost nothing.

latex
% プリアンブルで編集中の章だけに絞る / restrict to the chapter you’re editing
\includeonly{chapters/ch3}

\includeonly is not a finishing mechanism. It depends on previously written .aux files for page numbers and references, so before submission you remove it and build every chapter. In a document with an index, bibliography, and contents, the partial-build PDF is a working approximation, not the final document.

Iterate fast with draft mode

The document class’s draft option helps when test-building a large document. (1) It marks overfull boxes (lines that run into the margin) with a black rule, so layout problems are easy to spot. (2) It replaces images with a framed placeholder showing the filename instead of rendering them, which skips image processing and speeds up compilation. To scope it to images only, use \usepackage[draft]{graphicx}. Switch back to final for the real output. If you want overfull rules but keep images visible, \overfullrule=5pt does that.

latex
\documentclass[draft]{report}   % 画像を省き overfull を表示 / skip images, show overfull rules
% 画像だけ draft にする場合 / scope it to images only:
\usepackage[draft]{graphicx}

Create a rhythm for a long project

For large documents, avoid the false choice between “always build everything perfectly” and “only ever build a fragment.” Day to day, use \includeonly and latexmk -pvc to iterate on the current chapter. At milestones, remove draft and build the whole document. Before weekends or submission, delete generated files and clean-build. This rhythm keeps the loop fast while still catching final-PDF failures early.

Other tactics

  • Minimize waiting with latexmk’s incremental builds or -pvc (see Automated builds).
  • For heavy figures, externalize TikZ or pre-render to PDF so rebuilds stay light.
  • Temporarily drop huge sections from \includeonly, or comment them out.
  • Just before finishing, build with final in full to settle numbering, the TOC, the index, and the bibliography.
  • Before submission, remove draft and \includeonly, rebuild the PDF, and read warnings in the log.