Skip to content

Instantly share code, notes, and snippets.

@mstrehler
Forked from hmaarrfk/latex_Makefile
Created March 3, 2016 11:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mstrehler/f0ab29169e9d90e0aacd to your computer and use it in GitHub Desktop.
Save mstrehler/f0ab29169e9d90e0aacd to your computer and use it in GitHub Desktop.
Latex makefile
doc=your_document_name
name=$(doc)
BUILD=build
FIGS_DIR=figs
TARGET=$(doc).pdf
TOPSOURCE=$(doc).tex
# The first one suppressed all the output messages. but doesn't show you the error .....
#OPTIONS=-interaction=batchmode --output-directory=$(BUILD) --shell-escape -file-line-error -halt-on-error -jobname $(name)
OPTIONS=--output-directory=$(BUILD) --shell-escape -file-line-error -halt-on-error -jobname $(name)
BIBFILES=$(doc).bib
STYLE_FILES=\
your_document_style_file.sty\
your_document_bibtex_file.bst
all: $(TARGET)
$(BUILD):
mkdir -p $@
ln -fsr $(STYLE_FILES) $(BUILD)/.
ln -fsr $(FIGS_DIR) $(BUILD)/.
# you can comment the first 3 lines if you do not have a bib file
$(TARGET): $(BUILD) $(PDF_FIGS)
pdflatex $(OPTIONS) $(TOPSOURCE)
cp $(BIBFILES) $(BUILD)/.
(cd $(BUILD) && bibtex $(doc))
pdflatex $(OPTIONS) $(TOPSOURCE)
pdflatex $(OPTIONS) $(TOPSOURCE)
cp $(BUILD)/$(TARGET) $(TARGET)
clean:
rm -rf $(BUILD)
cleanharder: clean
rm -f $(TARGET)
.PHONY: all clean cleanharder $(TARGET) $(BUILD) $(PDF_FIGS)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment