% Creating PDFs with Pandoc % Yoav Ram % 2012-12-16 11:36:00 +2
This post will show how to convert a Markdown document to PDF, mobile-PDF and EPUB documents using Pandoc.
The guide is not exhastive but rather a walkthrough of my own experiments. The mobile-PDF especially is lacking - it is based on somewhat advanced
The source Markdown file use for this post, creating-pdfs-with-pandoc.md, is available as a gist.
> pandoc creating-pdfs-with-pandoc.md -o creating-pdfs-with-pandoc.pdf
> pandoc creating-pdfs-with-pandoc.md -o creating-pdfs-with-pandoc.pdf --bibliography=<path to bibtex file> [--csl=<path to csl file>] [--toc]
The CSL file is optional, if ommited Pandoc uses Chicago-style citations. You can find more information on citation styles at http://citationstyles.org/. If you add the --toc
option Pandoc will add a table of contents.
> pandoc creating-pdfs-with-pandoc.md -o creating-pdfs-with-pandoc.epub --bibliography=<path to bibtex file> [--csl=<path to csl file>] [--toc]
On Windows 7 you can open EPUB files with Calibre.
This is following the discussion on tex.stackexchange, and using a Pandoc latex template which merges the default template with this one. Here is the template as a gist. Remember to put the template in Pandoc's template folder (on Windows 7, C:\Program Files (x86)\Pandoc\templates).
> pandoc creating-pdfs-with-pandoc.md -o creating-pdfs-with-pandoc.iphone.pdf -s --template=iphone-pandoc-template.latex --bibliography=<path to bibtex file> [--csl=<path to csl file>] [--toc]
This rendering is not so good - pages are split strangely and code segements are cropped. If anyone wants to play around with the template, I'll be happy to post the results.
Here is a reference [@Kimura1966], and also a link to my blog Mutation-Selection Blog. Here's a footnote1 that you can see on the bottom.
One of my favorite mathematical expressions is the triangle ineuqality:
And a piece of Python code:
for x in [p for p in posts if p['author'] == 'yoavram']:
print x['date']
print 'done'
Footnotes
-
Footnotes are great. ↩