Skip to content

Instantly share code, notes, and snippets.

@akafael
Last active February 11, 2016 12:02
Show Gist options
  • Save akafael/87f7be49f850ff090a93 to your computer and use it in GitHub Desktop.
Save akafael/87f7be49f850ff090a93 to your computer and use it in GitHub Desktop.
Makefile to combine LaTeX and Python using PythonTeX
##
# Makefile for Latex + Pythontex
# Pythontex Reference: https://github.com/gpoore/pythontex
# @author Rafael Lima
##
# Compiler Options
TEX = pdflatex
TEXFLAGS = --enable-write18 --shell-escape
NAME = magicReport
##
# Recipes:
##
.PHONY = ALL
ALL: $(NAME).pdf
# Compile and open pdf
$(NAME).pdf: $(NAME).tex $(NAME).pytxcode
$(TEX) $(TEXFLAGS) $(NAME).tex &&\
$(TEX) $(NAME).tex &&\
xdg-open $(@)&
$(NAME).pytxcode: $(NAME).tex
$(TEX) $(TEXFLAGS) $<
pythontex $<
# Generate Python free latex code
.PHONY = pythonfree
pythonfree: $(NAME).tex
depythontex $<
# Remove generated files
.PHONY = clean
clean-tex:
rm -f $(NAME).aux $(NAME).bbl $(NAME).blg $(NAME).log $(NAME).idx $(NAME).out\
$(NAME).nav $(NAME).snm $(NAME).toc $(NAME).vrb
clean-py:
rm -f $(NAME).py*
rm -fr pythontex-files-*
.PHONY = clean-all
clean-all: clean-tex clean-py
rm -f $(NAME).pdf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment