Collaboration & change tracking

Because LaTeX is plain text, it fits version control and collaborative writing beautifully. This chapter builds a pattern for moving a manuscript forward without breaking it: keep only source files in Git, turn version differences into a PDF with latexdiff, and manage notes or review markup with todonotes / changes.

Manage it with Git

Since the source is text, Git’s line-level diffs, branches, merges, and history apply directly (a world apart from binary document files). Commit only the source (.tex, .bib, figures, .latexmkrc, …) and exclude anything regenerated by compilation via .gitignore. A collaboration tip: write one sentence per line — short lines keep diffs readable and merges conflict-free.

terminal
# .gitignore — 生成物を無視 / ignore generated files
*.aux
*.log
*.out
*.toc
*.fls
*.fdb_latexmk
*.synctex.gz
*.bbl
*.blg
*.bcf
*.run.xml
*.idx
*.ilg
*.ind

Whether to commit PDFs depends on how you distribute them. If you need to freeze a submitted or released copy, it is fine to keep it explicitly under something like releases/. But committing a regenerated main.pdf on every edit makes diffs unreadable and bloats history. A practical workflow is to ignore generated PDFs day to day, then attach milestone builds to tags or Releases.

In collaboration, branch by chapter or task, and keep each commit to one meaningful change. Mixing a large figure replacement, bibliography cleanup, and prose rewrite in one commit makes both diff PDFs and Git diffs harder to review. LaTeX’s advantage is that prose can be handled like code, so keep the history at code-like granularity too.

latexdiff — mark up the differences

latexdiff (by F. Tilmann) compares two versions and outputs a new .tex with the changes highlighted. Compiling it gives a PDF where added text is underlined (in color) and deleted text is struck through — like a word processor’s track-changes view. All the markup commands it inserts begin with \DIF.

terminal
latexdiff --flatten old.tex new.tex > diff.tex   # diff.tex をコンパイル / then compile diff.tex
latexdiff-vc --git -r HEAD~3 main.tex            # Git の版と比較 / compare against a Git revision

For documents split with \input/\include, add --flatten so they are merged before comparison. With latexdiff-vc and --git (or --svn, --hg), you can diff directly against a specific revision in version control.

todonotes — leave notes and TODOs

The todonotes package is for leaving working notes in the manuscript. \todo{...} puts a colored callout in the margin (\todo[inline]{...} places it in the text), \missingfigure{...} drops in a placeholder for a figure you have not drawn yet, and \listoftodos collects every TODO into one list. For the final version, \usepackage[disable]{todonotes} hides them all.

latex
\usepackage{todonotes}
...
\todo{ここは要出典}
\missingfigure{回路図を後で追加}
\listoftodos

changes — author-attributed edits

For reviewing and co-author markup, the changes package is handy. Use \added{...}, \deleted{...}, \replaced{new}{old}, and \comment{...} to mark edits explicitly, with a color per author. The draft option shows the markup, the final mode hides it, and \listofchanges summarizes every edit — like track-changes embedded right in the source.

latex
\usepackage[draft]{changes}
...
\added[id=AB]{新しく加えた一文。}
\replaced[id=AB]{改訂後}{改訂前}

Before switching to the final version

  • Set todonotes to disable and changes to final, then confirm no TODOs or markup remain in the PDF.
  • Keep the .tex generated by latexdiff under a separate name; do not merge it into the main manuscript source.
  • Before producing the submission PDF, clean generated files with something like latexmk -C and verify a clean rebuild.
  • When sending files to co-authors, separate the source bundle, the diff PDF, and the final PDF, and state which one needs review.

How they fit together

  • History, division of work, mergingGit (ignore generated files; one sentence per line).
  • Show what changed since the last versionlatexdiff (--flatten for split docs).
  • Your own TODOs and unfinished spotstodonotes (disable for the final).
  • Co-authors’ markup and accept/rejectchanges (draft vs final).