Skip to content

Instantly share code, notes, and snippets.

@jerinphilip
Created May 10, 2020 21:34
Show Gist options
  • Save jerinphilip/c9360753ba498546df707b23fdfe3207 to your computer and use it in GitHub Desktop.
Save jerinphilip/c9360753ba498546df707b23fdfe3207 to your computer and use it in GitHub Desktop.
LatexMk Makefile
LATEX=xelatex
LATEXOPT=--shell-escape
NONSTOP=--interaction=nonstopmode
LATEXMK=latexmk
LATEXMKOPT=-pdf
CONTINUOUS=-pvc
MAIN=main
JOBNAME='-jobname=build/$(MAIN)'
SOURCES=$(MAIN).tex Makefile main.bib main.tex content/chapters/*.tex content/*.tex styles/*.sty
FIGURES := $(shell find figures/* -type f)
all: $(MAIN).pdf
.refresh:
touch .refresh
$(MAIN).pdf: $(MAIN).tex .refresh $(SOURCES) $(FIGURES)
$(LATEXMK) $(LATEXMKOPT) $(JOBNAME) $(CONTINUOUS) \
-pdflatex="$(LATEX) $(LATEXOPT) $(NONSTOP) %O %S" $(MAIN)
force:
touch .refresh
rm $(MAIN).pdf
$(LATEXMK) $(LATEXMKOPT) $(JOBNAME) $(CONTINUOUS) \
-pdflatex="$(LATEX) $(LATEXOPT) %O %S" $(MAIN)
clean:
$(LATEXMK) -C $(MAIN)
rm -f $(MAIN).pdfsync
rm -rf *~ *.tmp
rm -f *.bbl *.blg *.aux *.end *.fls *.log *.out *.fdb_latexmk
once:
$(LATEXMK) $(LATEXMKOPT) $(JOBNAME) -pdflatex="$(LATEX) $(LATEXOPT) %O %S" $(MAIN)
debug:
$(LATEX) $(LATEXOPT) $(MAIN)
sync:
git push overleaf master
git push origin master
.PHONY: clean force once all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment