From 13d3aae6adc02cf9716af66df7cee8b1f7d2e4e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois-Xavier=20Wicht?= Date: Tue, 13 Oct 2026 14:06:10 +0200 Subject: [PATCH] Add make and latexmk build --- .gitignore | 37 +++++++++++++++++++++++++++++++++++++ .latexmkrc | 4 ++++ Makefile | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+) create mode 100644 .gitignore create mode 100644 .latexmkrc create mode 100644 Makefile diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..114e680 --- /dev/null +++ b/.gitignore @@ -0,0 +1,37 @@ +# LaTeX build artifacts +*.aux +*.bbl +*.bcf +*.blg +*.fdb_latexmk +*.fls +*.log +*.out +*.run.xml +*.synctex.gz +*.synctex(busy) +*.toc +*.lof +*.lot +*.dvi +*.xdv +figures/src/*.pdf + +# Build output +build/ +figures/build/ +main.pdf +main.pdf.tmp + +# Downloads waiting to be moved to context/related-papers/ +ingest/* +!ingest/.gitkeep + +# Scratch output +scratch/**/build/ +scratch/**/*.pdf + +# OS files +.DS_Store +Thumbs.db +desktop.ini diff --git a/.latexmkrc b/.latexmkrc new file mode 100644 index 0000000..7b447bb --- /dev/null +++ b/.latexmkrc @@ -0,0 +1,4 @@ +# Settings shared by vimtex, make watch and make. vimtex and make watch write into build/; make passes -outdir=build/make, so a make run never writes the files of a running watch. +$pdf_mode = 1; +$out_dir = 'build'; +ensure_path('TEXINPUTS', './venue//'); diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..208750c --- /dev/null +++ b/Makefile @@ -0,0 +1,49 @@ +# vimtex and make watch write into build/ (set in .latexmkrc); make writes into build/make/, so it can run while a watch is compiling. + +LATEXMK := latexmk +FLAGS := -interaction=nonstopmode -halt-on-error -file-line-error +BUILD := build/make +ARXIV := build/arxiv + +FIG_SRC := $(wildcard figures/src/*.tex) +FIG_PDF := $(FIG_SRC:figures/src/%.tex=figures/build/%.pdf) +FIG_DATA := $(wildcard figures/data/*) + +.PHONY: all figures watch clean arxiv wordcount + +all: figures + $(LATEXMK) $(FLAGS) -outdir=$(BUILD) main.tex + cp $(BUILD)/main.pdf main.pdf.tmp && mv main.pdf.tmp main.pdf + +figures: $(FIG_PDF) + +# Each figure is compiled from figures/src/ into a temporary folder and moved into place, so a running watch never reads a half-written PDF. +figures/build/%.pdf: figures/src/%.tex $(FIG_DATA) | figures/build + @tmp=$$(mktemp -d figures/build/.tmp.XXXXXX); \ + if (cd figures/src && pdflatex $(FLAGS) -output-directory=$(CURDIR)/$$tmp $*.tex > /dev/null); then \ + mv $$tmp/$*.pdf $@ && rm -rf $$tmp && echo "Built $@"; \ + else \ + cat $$tmp/$*.log; rm -rf $$tmp; exit 1; \ + fi + +figures/build: + mkdir -p $@ + +watch: figures + $(LATEXMK) -pvc -view=none -synctex=1 -interaction=nonstopmode -file-line-error main.tex + +clean: + rm -rf build figures/build + +# The tarball takes main.tex, sections/, appendix/, macros/, bib/, the compiled figures, the .bbl and the files of venue/; context/, scratch/, ingest/, .claude/, CLAUDE.md, writing-style-guide.md, claudese.md and .mcp.json stay out. +arxiv: all + rm -rf $(ARXIV) && mkdir -p $(ARXIV)/figures/build + cp -r main.tex sections appendix macros bib $(ARXIV)/ + cp figures/build/*.pdf $(ARXIV)/figures/build/ + cp $(BUILD)/main.bbl $(ARXIV)/ + find venue -type f ! -name .gitkeep -exec cp {} $(ARXIV)/ \; + tar -czf build/arxiv.tar.gz -C $(ARXIV) . + @echo "Wrote build/arxiv.tar.gz" + +wordcount: + texcount -sum sections/*.tex appendix/*.tex