Introduction
Makefiles automate complex LaTeX builds, handling dependencies between files and ensuring proper compilation order.
This guide covers Make-based LaTeX automation.
Basic Makefile
Simple Build
TEX = pdflatex
BIB = bibtex
document.pdf: document.tex
$(TEX) document.tex
clean:
rm -f *.aux *.bbl *.log *.out *.toc
With Bibliography
TEX = pdflatex
BIB = biber
%.pdf: %.tex
$(TEX) -interaction=nonstopmode $<
$(BIB) $(<:.tex=)
$(TEX) -interaction=nonstopmode $<
$(TEX) -interaction=nonstopmode $<
clean:
rm -f *.aux *.bbl *.blg *.log *.out *.toc *.synctex.gz
Advanced Makefiles
Multi-file Projects
MAIN = main
CHAPTERS = chapter1 chapter2 chapter3
$(MAIN).pdf: $(MAIN).tex $(patsubst %,%.tex,$(CHAPTERS))
pdflatex $(MAIN).tex
biber $(MAIN)
pdflatex $(MAIN).tex
pdflatex $(MAIN).tex
Conclusion
Makefiles automate complex LaTeX builds efficiently.
Comments