Last active
February 7, 2024 10:30
-
-
Save ivanperez-keera/570ffae3c1155572cc44d03cabc95b99 to your computer and use it in GitHub Desktop.
Clean LaTeX Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.PHONY: default | |
# Use texfot if available. Produces less output. | |
TEXFOT_ARGS=--no-interactive --ignore 'Underfull.*' --ignore 'Package polytable Warning: Redefining column' --ignore 'Package hyperref Warning: Token not allowed in a PDF string' --ignore 'LaTeX Warning: .h. float specifier changed to .ht..' | |
TEXFOT=$(shell which texfot >/dev/null && echo texfot "${TEXFOT_ARGS}" || echo "") | |
# TEXFOT= | |
# Use chronic if available. Removes output on zero exitcode. | |
CHRONIC=$(shell which chronic || echo "") | |
# CHRONIC= | |
default: thesis.pdf | |
thesis.tex: thesis.lhs \ | |
c-0-abstract.lhs \ | |
c-0-acknow.lhs \ | |
c-0-background.lhs \ | |
c-0-introduction.lhs \ | |
frptime.lhs \ | |
macros.tex \ | |
robust.tex \ | |
title.tex \ | |
toc.tex \ | |
c-1-msfs.lhs \ | |
c-1-msfs-frp.lhs \ | |
c-1-msfs-usecase.lhs \ | |
c-1-reactivevalues.lhs \ | |
c-1-reactivevalues-experience.lhs \ | |
c-9-relatedwork.lhs \ | |
c-9-futurework.lhs \ | |
c-9-appendix.lhs \ | |
c-9-msfs-arrowlaws.lhs | |
lhs2TeX -o $*.tex $*.lhs | |
# INFO: If the file repeatedly fails to compile, use: | |
# pdflatex -interaction nonstopmode -file-line-error paper.tex | |
%.pdf: %.tex | |
@${CHRONIC} ${TEXFOT} pdflatex $< | |
@${TEXFOT} bibtex $(basename $<) | |
@${CHRONIC} ${TEXFOT} pdflatex $< | |
@${TEXFOT} pdflatex $< | |
# latexmk -g -pdf -pdflatex="${CHRONIC} ${TEXFOT} pdflatex" $< | |
# ${CHRONIC} ${TEXFOT} bibtex | |
# ${TEXFOT} pdflatex $< | |
# ${TEXFOT} pdflatex $< | |
clean: | |
rm -f *.pdf *.out *aux *bbl *blg *log *toc *.ptb *.tod *.fls *.fdb_latexmk *.lof | |
watch: | |
while true; do \ | |
make -B $(WATCHMAKE); \ | |
inotifywait --exclude '.*swx' --exclude '.*swp' --exclude '.*~' -qre close_write .; \ | |
done | |
# Explanation for the following rule. | |
# We manually select files. You can do with *.lhs or something similar. | |
# cat is used to pipe the file. This makes aspell (the spell checker) run in non-interactive mode. | |
# aspell: use local dictionary, run in non-interactive mode (-a), check the file (-c), source is latex (-t), language variant. | |
# grep: eliminate aspell crap, empty lines, aspell suggested corrections. | |
# grep: eliminate line with Ispell version number. | |
# sed: turn lines of the form <word> <line> <column> into <file>:<line>:<column>:error:<word>. This integrates with | |
# editors better. | |
spellcheck: | |
for i in c-0-abstract.lhs c-0-introduction.lhs ; do \ | |
cat $$i | \ | |
aspell --extra-dicts=$$PWD/.aspell.en.pws -a -c -t --lang=en_GB | \ | |
grep -ve '^*' | grep -ve '^\s*$$' | sed -e 's/:.*//g' | \ | |
grep -ve 'Ispell' | \ | |
sed -e "s/\& \(.*\) \([0-9]\+\) \([0-9]\+\)$$/$$i: \2: \3: error: \1/g" | sort -g -t ':' -k 2 ; \ | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment