A simple pandoc setup to compile a book from markdown sources into html pages and pdf.
Features:
- Tufte-inspired layout with sidenotes
- Latex formulas via katex plugin
- Custom Environments
- Cross references
- HTML pages, individual PDF chapters, PDF book
- Install pandoc v2.14 (exact version requirement)
- Make sure you have python 3.5+ installed with pandocfilters package
- Clone the repository
- Customize your book by setting up variables in
Makefile. - Type
maketo build both pdf and html files.
- To build html only, type
make html. - To build pdf only, type
make pdf.
Find the compiled results in publish/ directory.
pandoc2.14 (strict: must be version 2.14)python3.5 or higher withpandocfiltersinstalled
Note: Every new release of pandoc since version 2.10 has broken the compile process due to changes in the way that pandoc handles citations. Getting things to run with a different version of pandoc is certainly possible, but may require changes, primarily to the latex template located at templates/book.tex. The issue is typically with the latex environments related to cslreferences. Copy and paste from the latex template corresponding to your pandoc version as is necessary.
assets-- Put all files linked to from the sources herecss-- All css files. NO NEED TO EDIT.filters-- Custom pandoc filters. NO NEED TO EDIT.sources-- This is where the source markdown files live. Go here to edit.templates-- Pandoc template files. NO NEED TO EDIT.publish-- Contains compiled pages and pdfs ready for publishing. DO NOT EDIT.
The setup is based on:
See Issues tab for current issues and ways of contributing to the project.
Thank you.
Scroll through the markdown files in sources/ to get a sense for how this
works. Below is additional documentation.
- Edit one of the source markdown files in
sources/ - Type
maketo produce all output inpublish/
-
maketo compile all sources intopublish/directory. This will compile all chapters as html and pdf, as well as the whole book as pdf. -
make -j8to compile in parallel. -
make publish/pdf/chaptername.pdfto compile individual pdf chapter -
make publish/chaptername.htmlto compile individual html name
Example usage in markdown:
This is a first paragraph.[^note1]
[^note1]:
{-} This is an unnumbered margin note.
This is a second paragraph.[^note2]
[^note2]:
This is a numbered sidenote.
Numbered theorem environment example:
begin-Theorem
$2+2=4$
end-Theorem
The environment Theorem must be defined in latex macros at templates/macros.sty.
Unnumered environment:
begin+Example
This.
end+Example
The begin and end statements must be at the beginning of a new paragraph each.
Create a reference by writing !{kind:name}, e.g., !{theorem:main},
anywhere outside math or code environments.
Use reference with the same syntax, e.g., Theorem !{theorem:main}.
Another reference of the form !{theorem:second} will increment theorem
counter.
Example:
Next we're going to see a deep theorem.
!{thm:deep}
begin+Theorem
$1 + 1 = 2$
end+Theorem
We saw in Theorem !{thm:deep} that $1+1=2$.
NOTE: This way of doing references is NOT equivalent to the way pdflatex does it. In particular, references don't automatically match to the correct number of the Theorem environment. Instead every numbered theorem has to be prefixed with an !{thm:name} expression for this to work.
Math macros can be defined in templates/shared-macros.tex. When compiling from markdown to html, these will be inserted at the top of the markdown file and interpreted by pandoc for use with katex. When compiling to pdf, these will be interpreted by pdflatex.
Ideally, create images in both SVG and PDF format. Place two files image.pdf and image.svg in the assets/ directory. Include the image by its .svg extension.

At compile time, the custom filter filter/svgimagext.py will subsitute the pdf extension for the pdf compilation. You don't need to worry about it.
If vector graphics are not available use JPG or PNG. Those are the only other two formats that are supported.