Org-Babel PDF Export

These are my notes on exporting a PDF from an org-babel file.

First Try

The key sequence to export a PDF from an org file is C-c C-e l p (c as in… c, e as in export, l as in LaTex, and p as in PDF). My first try produced this error:

! LaTeX Error: File `ulem.sty` not found.

The actual output had `ulem.sty` ending with an apostrophe (which I can't show here because org either renders the apostrophe as an accent or if I put it in an inline verbatim block it disables the verbatim markup - seems like a bug) but either nikola or org or something else marked the single apostrophe as an error with a red box around it in the output so I changed it to a backtick (`) to get rid of the box.

Past experience told me that the error indicated I was likely missing a (debian) package.

apt-cache search ulem
texlive-generic-recommended - TeX Live: Generic recommended packages
libextutils-modulemaker-perl - Perl extension to build module from scratch

Since I'm doing something with LaTex, not perl I decided that installing the texlive-generic-recommended package was probably what I should do.

sudo apt-get install texlive-generic-recommended

Second try

I hit C-c C-e l p again and this time it did output a PDF, but there was no syntax-highlighting of the code. Followng this blog post I added this to my init.el file:

;; export to latex/pdf
(require 'ox-latex)

;; syntax-highlighting for pdf's
(add-to-list 'org-latex-packages-alist '("" "minted"))
(setq org-latex-listings 'minted)
(setq org-latex-pdf-process '("pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"))

Once I re-loaded the init.el file, the PDF's came out with the syntax highlighting working.

The original post used xelatex instead of pdflatex but I don't use xelatex. Also minted can be found in the texlive-latex-extras package if it isn't already installed. The post also mentions needing pygments but I didn't need it, possibly because it's a dependency for other python libraries that I've already installed.