From d3e2dc749fc82681ce9a32801b78131d68e21484 Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Thu, 7 Sep 2017 19:44:59 +0200 Subject: [PATCH] add pdf version --- makefile | 20 +++++++++++++++++--- pandoc/options.tex | 15 +++++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 pandoc/options.tex diff --git a/makefile b/makefile index bdde046..788808e 100644 --- a/makefile +++ b/makefile @@ -1,12 +1,26 @@ -title = 'category-theory-for-programmers' +title = category-theory-for-programmers root = $(shell pwd) src = $(root)/src chapters = $(shell find $(src)/part-* -name '*.html' | sort -V) -book: - cd $(src)/init; \ +all: $(title).epub $(title).pdf + +$(title).pdf: + @ cd $(src)/init; \ + pandoc \ + $(src)/init/preface.html \ + $(chapters) \ + --smart \ + --toc \ + --number-section \ + --latex-engine=xelatex \ + -H $(root)/pandoc/options.tex \ + -o $(root)/$(title).pdf + +$(title).epub: + @ cd $(src)/init; \ pandoc \ $(src)/init/preface.html \ $(chapters) \ diff --git a/pandoc/options.tex b/pandoc/options.tex new file mode 100644 index 0000000..688d219 --- /dev/null +++ b/pandoc/options.tex @@ -0,0 +1,15 @@ +% center images +\usepackage[export]{adjustbox} +\LetLtxMacro{\OldIncludegraphics}{\includegraphics} +\renewcommand{\includegraphics}[2][]{ + \begin{center} + \OldIncludegraphics[max width=8cm,max height=4cm,#1]{#2} + \end{center} +} + +% avoid that figures get a whole page +\renewcommand{\floatpagefraction}{.8}% + +% start new page with each section +\usepackage{etoolbox} +\pretocmd{\section}{\clearpage}{}{}