Skip to content

Instantly share code, notes, and snippets.

@relekang
Created January 13, 2015 15:04
Show Gist options
  • Save relekang/46e6650660e663eb09d8 to your computer and use it in GitHub Desktop.
Save relekang/46e6650660e663eb09d8 to your computer and use it in GitHub Desktop.
Latex project makefile
ifeq ($(shell uname -s), Darwin)
OPEN='open'
else
OPEN='see'
endif
ifeq ($(USE_BIB), false)
COMPILE = pdflatex -halt-on-error report.tex >> logs/compile \
&& echo "Compiled report" || (cat logs/compile && fail)
else
COMPILE = pdflatex -halt-on-error report.tex >> logs/compile && \
bibtex report >> logs/compile && \
pdflatex -halt-on-error report.tex >> logs/compile && \
pdflatex -halt-on-error report.tex >> logs/compile \
&& echo "Compiled report" || (cat logs/compile && fail)
endif
all: open
test: compile
compile:
@ test -d logs || mkdir logs
@ $(COMPILE)
bibliography: compile
bibtex report
pdflatex report.tex
pdflatex report.tex
open: compile
$(OPEN) report.pdf
clean:
rm -f *.log *.aux *.lof *.pdf *.toc *.lot
spell:
find . -name "*.tex" -exec aspell --no-backup --lang=en --mode=tex check "{}" \;
fixme:
@find . -name "*.tex" | xargs cat | grep "FIXME"
stats: pdfinfo count fixme_count cite_count
pdfinfo: compile
@pdfinfo report.pdf | grep --color=never "Pages"
count:
@find . -name "*.tex" | xargs ./texcount.pl -sum -v0 -total | \
grep --color=never -P "^(Sum|Number)"
fixme_count:
@echo "FIXME: `find . -name "*.tex" | xargs cat | grep "FIXME" -c`"
cite_count:
@echo "Citations: `find . -name "*.tex" | xargs cat | grep "\\cite" -c`"
.PHONY: compile open clean bibliography pdfinfo count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment