Skip to content

Instantly share code, notes, and snippets.

@efraintorlo
Last active February 27, 2016 20:34
Show Gist options
  • Select an option

  • Save efraintorlo/67825dae97c3d628181a to your computer and use it in GitHub Desktop.

Select an option

Save efraintorlo/67825dae97c3d628181a to your computer and use it in GitHub Desktop.
Latex file rendering using Latexmk, pandoc and rst2html.py
SHELL := /bin/bash
# ====================
# Author: elchinot7
# Mail: elchinot7@mail.com
# Date: Today
# ====================
# Makefile for LaTeX file:
# ====================
FILE ?= my_Latex_doc
# ====================
# Documentation
README ?= Readme
# ====================
# css to be used in HTML docs
# this styles are defined under ./docs/css/
#CSS_STYLE = ./docs/css/rst2html.css
CSS_STYLE_README = ./docs/css/pandoc_2.css
CSS_STYLE = ./docs/css/pandoc_2.css
#CSS_STYLE = ./docs/css/github_pandoc.css
# ====================
.PHONY: clean show default compile auto docs
LATEXFILE = $(FILE).tex
OUTPUTFILE = $(FILE).pdf
# Apps needed are different for Linux/Mac
ifeq ($(shell uname -s),Darwin)
OPEN = mupdf-x11
LATEX = latexmk
PANDOC = pandoc
else
OPEN = /usr/bin/mupdf
LATEX = latexmk
PANDOC = pandoc
endif
default: compile show
compile: $(LATEXFILE)
$(LATEX) -pdf -f -pdflatex="pdflatex --shell-escape --synctex=1 %O %S" $(LATEXFILE)
auto: $(LATEXFILE)
$(LATEX) -pdf -pvc --silent -f -pdflatex="pdflatex --shell-escape --synctex=1 %O %S" $(LATEXFILE)
show: $(OUTPUTFILE)
$(OPEN) -r 95 $(OUTPUTFILE) &
docs: docs_fresh
@echo -e "\033[31m$(README).html Done!\033[0m"
open $(README).html
docs_fresh: clean_docs $(README).html
%.html: %.rst
rst2html.py --date --time --math-output="MathJax" --stylesheet=$(CSS_STYLE_README) $< $@
tex2rst: $(FILE).tex
$(PANDOC) -s -S --bibliography biblio.bib --filter pandoc-citeproc $(FILE).tex -o $(FILE).rst
tex2html: $(FILE).tex
$(PANDOC) -s -S --toc --bibliography biblio.bib --filter pandoc-citeproc -c $(CSS_STYLE) $(FILE).tex -o $(FILE).html
clean_docs:
@echo -e "\033[31mCleaning... \033[0m"
rm *.html
clean:
@rm *.aux *.log *.out *.pdfsync *.tdo *.end\
*.table *.gnuplot *.gz *.bbl *.dvi *.fls \
*.fdb_latexmk *Notes.bib *.blg
#latexmk -C $(FILE)
help:
@echo "*********************************************************"
@echo -e " \033[31m Makefile Menu\033[0m"
@echo " < Latexmk >"
@echo "*********************************************************"
@echo "Please use 'make <target>' where target is one of:"
@echo
@echo -e "\033[31mdefault\033[0m # to compile the LaTeX doc: "
@echo -e " > \033[32m$(LATEXFILE)\033[0m"
@echo -e "\033[31mauto\033[0m # To run Latexmk continously"
@echo -e "\033[31mshow\033[0m # To show \033[32m$(OUTPUTFILE)\033[0m"
@echo -e "\033[31mtex2html\033[0m # To produce a HTML version of \033[32m$(FILE)\033[0m"
@echo -e "\033[31mtex2rst\033[0m # To produce a rst version of \033[32m$(FILE)\033[0m"
@echo -e "\033[31mdocs\033[0m # To produce the \033[32m$(README).html \033[0m"
@echo -e "\033[31mclean\033[0m # to clean auxiliary latex files. "
@echo "*********************************************************"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment