11

I'm trying to export some python code with syntax highlighted to a pdf, from org-mode. Even though I can export to html without any issues I could not find a way to export it to pdf.

n.b. I'm using spacemacs but also tried without success with vanilla emacs.

Kadir Gunel
  • 233
  • 1
  • 10
user13328
  • 111
  • 1
  • 3

1 Answers1

11

Hey this answer solved my similar problem. A bit late but I had the same issue today.

As mentioned, I add the following code snipped to my .spacemacs/.emacs config:

(require 'org)
(require 'ox-latex)
(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"
        "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
        "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"))

(setq org-src-fontify-natively t)

(org-babel-do-load-languages
 'org-babel-load-languages
 '((R . t)
   (latex . t)))

To use Minted, you need to install the companion program pygments. You can do this with pip install pygments.

Oyren
  • 221
  • 2
  • 8