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.


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)

 '((R . t)
   (latex . t)))

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.