Automated builds

Building a LaTeX document by hand means repeating “compile → bibliography → compile → compile” and remembering when to rerun what. An automated build hands that judgment to a tool: it tracks dependencies, runs only the steps that are needed, and — in watch mode — rebuilds the moment you save. This page is about that workflow (for the tools themselves, see “Build tools”).

Current TeX64 app behavior: TeX64 0.1.14 does not expose an Auto-build setting in the Build menu. In the app, use the toolbar Build button for manual builds. This page explains the general LaTeX command-line workflow for watch builds such as latexmk -pvc.

What an automated build is

With cross-references, a table of contents, a bibliography, or an index, compilation needs several passes, with biber or makeindex slotted in between. An automated build tool works out that order and count itself, calls the auxiliary tools at the right moments, and keeps going until the output stabilizes. You effectively type one command. The standard is latexmk; the declarative alternative is llmk.

Automate with latexmk

A single latexmk -pdf document.tex runs as many compiles as needed, invokes bibtex/biber and makeindex, and repeats until things settle. Project-specific settings go in .latexmkrc (swapping the engine, the Japanese uplatex + dvipdfmx setup, and so on). In collaboration, commit that file and make it the project contract: “this document is built with this command.” That makes the same PDF easier to reproduce across editors and operating systems. For the individual options, see “Build tools.”

terminal
latexmk -pdf document.tex   # 必要な手順を自動で回す / runs all the needed steps

The first decision is the engine path that produces the PDF. A short English-only document is often fine with pdflatex; Japanese text or OpenType fonts usually point to upLaTeX + dvipdfmx or LuaLaTeX. Put that decision in .latexmkrc so editor buttons, the terminal, and CI all use the same route. The longer the document gets, the more this fixed build path pays off.

terminal
# .latexmkrc — upLaTeX + dvipdfmx の例 / example route
$latex = 'uplatex -interaction=nonstopmode -halt-on-error %O %S';
$dvipdf = 'dvipdfmx %O -o %D %S';
$pdf_mode = 3;

Rebuild on every save — latexmk -pvc

The most useful mode while writing is -pvc (preview continuously). latexmk watches all of the source files it depends on — the main file plus any .tex brought in with \input/\include and graphics files — and, whenever one is saved, rebuilds automatically and refreshes the viewer. It feels like a “dev server” for your document: save, and you see the result at once.

terminal
latexmk -pdf -pvc document.tex   # 監視して保存ごとに自動更新 / watch and auto-rebuild on save

Process only what changed — incremental builds

latexmk avoids redundant reruns because it records the dependencies. After each run it saves the state of every source file in a database, .fdb_latexmk, and it uses the .fls file produced by -recorder (a list of what that run read and wrote) to know precisely which inputs and outputs are involved. On the next invocation a step is rerun only if its inputs changed — nothing happens if you changed nothing, and a small edit triggers just the necessary passes. That is why rebuilds are fast.

llmk likewise automates the build. Because you write its settings declaratively in llmk.toml (or magic comments in the document), the steps are the same for anyone on any machine — excellent for reproducibility, and a good fit for collaboration and distribution. Think of latexmk as the tool that infers reruns from logs and dependencies, and llmk as the tool that states the processing workflow in the document project itself.

Fitting it into your workflow

-pvc is for writing, a normal latexmk run is for pre-submission checking, and latexmk -C is the cleanup that proves you are not depending on stale generated files. In collaboration, a document that cannot clean-build is likely to break for someone else. Do not rely only on instant on-save previews; periodically clean and rebuild so the final PDF submission is uneventful.

  • While writinglatexmk -pdf -pvc: auto-updates on every save.
  • Ship the config with the project → keep .latexmkrc / llmk.toml in the repo for reproducibility.
  • Final pass before distributionlatexmk -C to wipe outputs, then a clean build.
  • Building on a server or in CI → see the “CI” page.