-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
134 lines (100 loc) · 4.29 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
## ---- user config ----
# Set to anything non-empty to suppress most of latex's messaging. To diagnose LaTeX errors, you may want to do `make latex_quiet=""` to get verbose output
latex_quiet := true
# Set to anything non-empty to reprocess TeX files every time we make a PDF.
# Otherwise these files will be regenerated only when the source markdown
# changes; in that case, if you change other dependencies (e.g. a
# bibliography), you will have to use the -B option to make in order to force
# regeneration. If you have many talks it probably makes more to take this
# manual option.
# always_latexmk := true
always_latexmk :=
# Set to anything non-empty to use xelatex rather than pdflatex. I always do
# this in order to use system fonts and better Unicode support. pdflatex is
# faster, and there are some packages with which xelatex is incompatible.
xelatex := true
# directories for markdown sources: notes and scripts
NOTES := notes
# Set to anything non-empty to always use the "scuro" dark-on-light scheme
# on slides. Comment this out to turn this off (you can still turn it on
# in individual files with "scuro: true" in the YAML metadata)
SCURO := true
# Extra options to pandoc. Note that certain options set here are overridden.
PANDOC_OPTIONS :=
# pandoc slide level, for slides from notes only (generation from script
# requires slide level be set to 2).
NOTES_SLIDE_LEVEL := 2
## ---- special external files ----
# Normally these do not need to be changed
# works if overlay_filter python script is local or in PATH
OVERLAY_FILTER := overlay_filter
# these work if the two templates are local or in ~/.pandoc/templates
SLIDES_TMPL := elsmd-slides.latex
SCRIPT_TMPL := beamerarticle.latex
# temp file subdirectory (created in lectures, slides, handouts)
# change this if you're using */tmp for something else
temp_dir := tmp
## ---- commands ----
# Change these only to really change the behavior of the whole setup
PANDOC := pandoc -t beamer $(if $(xelatex),--latex-engine xelatex) \
--filter $(OVERLAY_FILTER) $(PANDOC_OPTIONS)
LATEXMK := latexmk $(if $(xelatex),-xelatex,-pdflatex="pdflatex %O %S") \
-pdf -dvi- -ps- $(if $(latex_quiet),-silent,-verbose) \
-outdir=$(temp_dir)
## ---- build rules ----
notes_md := $(wildcard $(NOTES)/*.md)
notes_tex := $(patsubst $(NOTES)/%.md,lectures/%.tex,$(notes_md))
notes_pdf := $(patsubst %.tex,%.pdf,$(notes_tex))
slides_notes_tex := $(patsubst $(NOTES)/%.md,slides/%.tex,$(notes_md))
slides_pdf := $(patsubst %.tex,%.pdf,$(slides_notes_tex))
handouts_notes_tex := $(patsubst $(NOTES)/%.md,handouts/%.tex,$(notes_md))
handouts_notes_pdf := $(patsubst %.tex,%.pdf,$(handouts_notes_tex))
# notes_pdf is handled separately
pdfs := $(slides_pdf) $(handouts_notes_pdf)
$(notes_tex): lectures/%.tex: $(NOTES)/%.md
mkdir -p lectures
$(PANDOC) --template $(SLIDES_TMPL) \
--slide-level $(NOTES_SLIDE_LEVEL) \
-V beamer-notes=true \
-V fontsize=10pt \
-V scuro="" \
-o $@ $<
$(slides_notes_tex): slides/%.tex: $(NOTES)/%.md
mkdir -p slides
$(PANDOC) --template $(SLIDES_TMPL) \
$(if $(SCURO),-V scuro=true) --slide-level=$(NOTES_SLIDE_LEVEL) \
-o $@ $<
$(handouts_notes_tex): handouts/%.tex: $(NOTES)/%.md
mkdir -p handouts
$(PANDOC) --template $(SLIDES_TMPL) \
--slide-level $(NOTES_SLIDE_LEVEL) \
-V beamer-handout=true \
-V classoption=handout \
-V scuro="" \
-o $@ $<
phony_pdfs := $(if $(always_latexmk),$(pdfs) $(notes_pdf))
# phony targets to make all three PDFS for a single source
pdfsets := $(notdir $(basename $(notes_md)))
$(pdfsets): %:lectures/%.pdf slides/%.pdf handouts/%.pdf
.PHONY: $(phony_pdfs) $(pdfsets) all clean reallyclean
$(pdfs): %.pdf: %.tex
rm -rf $(dir $@)$(temp_dir)
cd $(dir $<); $(LATEXMK) $(notdir $<)
mv $(dir $@)$(temp_dir)/$(notdir $@) $@
rm -r $(dir $@)$(temp_dir)
$(notes_pdf): %.pdf: %.tex
rm -rf $(dir $@)$(temp_dir)
cd $(dir $<); $(LATEXMK) $(notdir $<)
pdfjam --nup 2x2 --landscape $(dir $@)$(temp_dir)/$(notdir $@) -o $@
rm -r $(dir $@)$(temp_dir)
all: $(pdfs) $(notes_pdf)
# clean up everything except final pdfs
clean:
rm -rf lectures/$(temp_dir) slides/$(temp_dir) handouts/$(temp_dir)
rm -f $(notes_tex) \
$(slides_notes_tex) \
$(handouts_notes_tex)
# clean up everything including pdfs
reallyclean: clean
rm -f $(pdfs) $(notes_pdf)
.DEFAULT_GOAL := all