Last active
May 31, 2016 12:36
-
-
Save tomravalde/64b590381c46f81942c7357e1f9e3ab4 to your computer and use it in GitHub Desktop.
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
## Makefile to build PhD thesis | |
###-------------------------------------------------- | |
### T. Ravalde ([email protected]) | |
### Last edited: 2016/05/31 | |
### Adapted from Keiran Healy (https://github.com/kjhealy/workflow-paper/blob/master/Makefile) | |
###-------------------------------------------------- | |
## Put this Makefile in your project directory | |
## - Change/add the paths to at the top of the file as needed (e.g. line 37) | |
## - Change the hostname (line 40) to the name of the machine most commonly used to build the thesis | |
## Usage | |
## - `make thesis` will build the entire thesis (based on the contents of main.tex) | |
## - `make chapter` will build a preview version of the most recently edited chapter | |
## - `make clean` will remove all the .pdf files and other filetypes in your working directory. Make sure you do not have files in these formats that you want to keep! | |
## TODO | |
## - Haven't yet tested the wordcount (`count`) feature | |
## - Haven't fully tested `make chapter` (e.g. with nomenclature dependencies etc.) | |
###-------------------------------------------------- | |
### Setup | |
###-------------------------------------------------- | |
## Extensions for files in working directory | |
RMDEXT = Rmd # for all Rmarkdown files | |
MEXT = md # (e.g. md, markdown, mdown) for all markdown files | |
TEXEXT = tex # for all tex files | |
## Variables for files in working directory | |
SRC_RMD = $(wildcard *.$(RMDEXT)) # for all Rmarkdown files | |
SRC_MD = $(wildcard *.$(MEXT)) # for all markdown files | |
SRC_TEX = $(wildcard *.$(TEXEXT)) # for all tex files | |
## Working bibliography file | |
BIB=my-refs.bib | |
## Machine most commonly used to build the thesis | |
HOST="cv-tr608-01" | |
###-------------------------------------------------- | |
### Dependencies | |
###-------------------------------------------------- | |
MDS=$(SRC_RMD:.Rmd=.md) | |
TEXS=$(SRC_RMD:.Rmd=.tex) | |
COUNTS=$(SRC_RMD:.Rmd=.count) | |
###-------------------------------------------------- | |
### Rules | |
###-------------------------------------------------- | |
md: update clean $(MDS) | |
tex: update clean $(MDS) $(TEXS) | |
chapter: update clean $(MDS) $(TEXS) chapter-xelatex | |
count: $(COUNTS) | |
thesis: update clean $(MDS) $(TEXS) combo | |
###-------------------------------------------------- | |
### Commands | |
###-------------------------------------------------- | |
## Build thesis | |
combo: *.tex | |
latexmk -xelatex "-interaction=nonstopmode" main.tex | |
## Whenever running on Tom's machine, update to latest dependencies for paper and toolchain | |
update: | |
if [ `hostname` = $(HOST) ] ; \ | |
then \ | |
cp /home/tr608/ImpCol/PhD/my-refs.bib . ; \ | |
fi | |
# inkscape -D -z --file=metab.svg --export-pdf=metab.pdf --export-latex ; \ | |
# cp /home/tr608/.pandoc/templates/chapter.xelatex . ; \ | |
## Knit Rmarkdown to markdown | |
%.md: %.Rmd | |
./knit.R $< | |
## Convert to tex using pandoc and build a standalone preview version of edited chapter | |
%.tex: %.md | |
./vc | |
pandoc --chapters --natbib -o $@ $< | |
cat chapter.prepend $@ chapter.append > preview.tex | |
## Complile the preview chapter | |
chapter-xelatex: | |
xelatex preview.tex | |
## Run texcount on tex files | |
%.count: %.tex | |
texcount -sub=section $< > $@ | |
clean: | |
rm -f *.aux *.log *.out *.spl *.bbl *.blg *.fls *fdb_latexmk |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment