Bloerg
       

Pandoc and LaTeX

In a previous post, I described some basic ideas how to make the PDF output of LaTeX a little bit prettier. Unfortunately, the text needs to be written in plain TeX which is cumbersome at best. But why not write Markdown and use yours truly’s favorite converter Pandoc to do the dirty job of generating TeX? The best thing with this setup: Pandoc does not process raw TeX commands and environments such as \newpage or $$ but outputs them verbatim into the final file. Thus, for most tasks you can write Markdown but if it’s necessary, you can simply add high-quality TikZ figures or plots made with PGFPlots.

To integrate the stylistic changes, I prepared a TeX template for Pandoc’s simple template engine and a Makefile. You can check out both in the current (empty) directory with

$ git clone git://gist.github.com/4194445.git .
$ rm -rf .git

Now place any Markdown files in here and make a nicely laid out PDF document.

You might have noticed the title and author variables in the template which will result in correspond \title{} and \author{} calls in the TeX document. To enter this data in your Markdown file, you have to use Pandoc’s title block extension and put it on top of your Markdown file like this:

% Multi line
  titles must begin with a leading space
% Brian Griffin
  Glenn Quagmire

Unfortunately, there are also some caveats with Pandoc:

For me, these are only minor problems and for smaller documents such as reports I now write Markdown and convert that rather than typing the document in a word processor or as raw LaTeX.

Discussion

This post might also have some comments at Google+.