Skip to content

Instantly share code, notes, and snippets.

@plmi
Last active November 12, 2023 14:09
Show Gist options
  • Save plmi/d2cd5c96b8ae07361f5a77e2fd448d02 to your computer and use it in GitHub Desktop.
Save plmi/d2cd5c96b8ae07361f5a77e2fd448d02 to your computer and use it in GitHub Desktop.
Makefile to compile latex document with latexmk
PAPER=solution-1.tex
SHELL=/bin/zsh
# remove extension .tex from PAPER
# https://unix.stackexchange.com/a/460224
FILENAME := $(shell x='$(PAPER)'; echo "$${x%%.*}")
.PHONY: all clean watch
# use -shell-escape to use minted package
# use -bibtex for biblatex support
all:
latexmk -pdf -pdflatex="pdflatex -interaction=nonstopmode" -use-make $(PAPER) -shell-escape -bibtex
clean:
find . -type f -regex "./$(FILENAME)\.\(aux\|fls\|log\|out\|dvi\|fdb_latexmk\|bcf\|run.xml\|bbl\|blg\)" -delete
watch:
@while [ 1 ]; do; inotifywait $(PAPER); sleep 0.01; make all; done
# for bash:
# @while true; do; inotifywait $(PAPER); sleep 0.01; make all; done
#!/bin/bash
# fixes '*** missing separator' error
perl -pi -e 's/^ */\t/' Makefile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment