Last active
December 7, 2017 19:29
-
-
Save lorepozo/cacb58c117f32a5c34f24d7a6d3f88a6 to your computer and use it in GitHub Desktop.
Makefile for LaTeX
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
THIS_FILE := $(lastword $(MAKEFILE_LIST)) | |
TEX := xelatex -shell-escape -interaction=nonstopmode -file-line-error | |
PRE := $(wildcard ./*.tex) | |
OBJ := $(PRE:%.tex=%.pdf) | |
BIB := $(wildcard ./*.bib) | |
BIB_OBJ := $(BIB:%.bib=%.bbl) | |
all: $(OBJ) | |
bib: $(BIB_OBJ) | |
%.bbl: %.bib | |
bibtex $(^:.bib=) | |
%.pdf: %.tex | |
$(TEX) $^ | |
if [ -e "$(^:.tex=.bib)" ] ; then $(MAKE) -f $(THIS_FILE) $(^:.tex=.bbl) && $(TEX) $^ && $(TEX) $^ ; fi | |
clean: | |
$(RM) *.aux *.log *.out *.bbl *.blg | |
cleanall: clean | |
$(RM) $(OBJ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just use
make
in any directory with a.tex
file.If you're using bibtex for citations, name the
.bib
file like the associated.tex
file (e.g.main.tex
andmain.bib
).make clean
gets rid of all auxiliary files, andmake cleanall
will also get rid of the produced PDFs.