-
Notifications
You must be signed in to change notification settings - Fork 11
/
Makefile
67 lines (49 loc) · 2.75 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
### From Rmd to PDF or html via md
## A Makefile in for your Rmarkdown-based paper project.
## Assuming you are using the rest of my templates and toolchain,
## (see http://kieranhealy.org/resources) you can use it
### to create .html, .tex, and .pdf output files (complete with
### bibliography, if present) from your Rmarkdown file.
## - Install the `pandoc-citeproc` and `pandoc-citeproc-preamble`
## filters for `pandoc`.
## - Change the paths at the top of the file as needed.
## - Using `make` without arguments will generate html, tex, and pdf
## output files from all of the `.Rmd` files in the folder.
## The `.md` files are created from `.Rmd` sources via R and `knitr`.
## - You can specify an output format with `make tex`, `make pdf` or
## - `make html`.
## - Doing `make clean` will remove all the .md .tex, .html, and .pdf files
## in your working directory. Make sure you do not have files in these
## formats that you want to keep!
## All Rmarkdown files in the working directory
SRC = $(wildcard *.Rmd)
## Location of Pandoc support files.
PREFIX = /Users/kjhealy/.pandoc
## Location of your working bibliography file
BIB = /Users/kjhealy/Documents/bibs/socbib-pandoc.bib
## CSL stylesheet (located in the csl folder of the PREFIX directory).
CSL = apsa
MD=$(SRC:.Rmd=.md)
PDFS=$(SRC:.Rmd=.pdf)
HTML=$(SRC:.Rmd=.html)
TEX=$(SRC:.Rmd=.tex)
DOCX=$(SRC:.md=.docx)
all: $(MD) $(PDFS) $(HTML) $(TEX) $(DOCX)
pdf: clean $(PDFS)
html: clean $(HTML)
tex: clean $(TEX)
md: clean $(MD)
docx: clean $(DOCX)
%.md: %.Rmd
R --no-echo -e "set.seed(100);knitr::knit('$<')"
%.html: %.md
pandoc -r markdown+simple_tables+table_captions+yaml_metadata_block -w html -S --template=$(PREFIX)/templates/html.template --css=$(PREFIX)/marked/kultiad-serif.css --filter pandoc-crossref --filter pandoc-citeproc --csl=$(PREFIX)/csl/$(CSL).csl --bibliography=$(BIB) --filter pandoc-citeproc-preamble -o $@ $<
%.tex: %.md
pandoc -r markdown+simple_tables+table_captions+yaml_metadata_block -w latex -s -S --latex-engine=pdflatex --template=$(PREFIX)/templates/latex.template --filter pandoc-crossref --filter pandoc-citeproc --csl=$(PREFIX)/csl/ajps.csl --bibliography=$(BIB) --filter pandoc-citeproc-preamble -o $@ $<
%.pdf: %.md
pandoc -r markdown+simple_tables+table_captions+yaml_metadata_block -w latex -s -S --latex-engine=pdflatex --template=$(PREFIX)/templates/latex.template --filter pandoc-crossref --filter pandoc-citeproc --csl=$(PREFIX)/csl/ajps.csl --bibliography=$(BIB) --filter pandoc-citeproc-preamble -o $@ $<
%.docx: %.md
pandoc -r markdown+simple_tables+table_captions+yaml_metadata_block -s -S --filter pandoc-crossref --filter pandoc-citeproc --csl=$(PREFIX)/csl/$(CSL).csl --bibliography=$(BIB) -o $@ $<
clean:
rm -f *.md *.html *.pdf *.tex *.docx
.PHONY: clean