Skip to content

Instantly share code, notes, and snippets.

@btbytes
Forked from bertvv/pandoc.Makefile
Created November 27, 2020 15:34
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save btbytes/963348a56f66b9ed5004bc394af59e03 to your computer and use it in GitHub Desktop.
Makefile for Markdown -> PDF using pandoc
# Generate PDFs from the Markdown source files
#
# In order to use this makefile, you need some tools:
# - GNU make
# - Pandoc
# - LuaLaTeX
# - DejaVu Sans fonts
# Directory containing source (Markdown) files
source := src
# Directory containing pdf files
output := print
# All markdown files in src/ are considered sources
sources := $(wildcard $(source)/*.md)
# Convert the list of source files (Markdown files in directory src/)
# into a list of output files (PDFs in directory print/).
objects := $(patsubst %.md,%.pdf,$(subst $(source),$(output),$(sources)))
all: $(objects)
# Recipe for converting a Markdown file into PDF using Pandoc
$(output)/%.pdf: $(source)/%.md
pandoc \
--variable mainfont="DejaVu Sans" \
--variable monofont="DejaVu Sans Mono" \
--variable fontsize=11pt \
--variable geometry:"top=1.5cm, bottom=2.5cm, left=1.5cm, right=1.5cm" \
--variable geometry:a4paper \
--table-of-contents \
--number-sections \
-f markdown $< \
--latex-engine=lualatex \
-o $@
.PHONY : clean
clean:
rm -f $(output)/*.pdf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment