All I could find to configure was org-latex-to-pdf-process and org-latex-create-formulat-image-program. The first one only controls the process, when I want to export the entire document, the second one only controls the process that gets executed after the latex command. But how do I customize the latex command that gets used for the fragments?

My use case:

I got minted finally working to export my org file with code samples in colors. But since then, the preview is broken, because the latex snippets have now the minted package imported, too. Then the pdflatex process for the snippets fails, because it needs the -shell-escape flag passed. But I do not know how I can pass that flag to that process.

second use case:

I would like to use the unicodemath package for xelatex. But that package is only available in xelatex, and therefor the process for the latex fragments needs to be xelatex, too.

1 Answer 1


The variable is org-preview-latex-process-alist.

Note that there are some xelatex org-preview-process-alist settings floating around on the web that are not correct. Xelatex outputs an enhanced dvi file that ends in .xdv, not dvi. dvipng cannot process these. This is why I experimented with luatex (didn't get it to work), and finally used xelatex and svg (which should give better rendering anyway).

       ((dvipng :programs
         ("lualatex" "dvipng")
         :description "dvi > png" :message "you need to install the programs: latex and dvipng." :image-input-type "dvi" :image-output-type "png" :image-size-adjust
         (1.0 . 1.0)
         ("lualatex -output-format dvi -interaction nonstopmode -output-directory %o %f")
         ("dvipng -fg %F -bg %B -D %D -T tight -o %O %f"))
 (dvisvgm :programs
          ("latex" "dvisvgm")
          :description "dvi > svg" :message "you need to install the programs: latex and dvisvgm." :use-xcolor t :image-input-type "xdv" :image-output-type "svg" :image-size-adjust
          (1.7 . 1.5)
          ("xelatex -no-pdf -interaction nonstopmode -output-directory %o %f")
          ("dvisvgm %f -n -b min -c %S -o %O"))
 (imagemagick :programs
              ("latex" "convert")
              :description "pdf > png" :message "you need to install the programs: latex and imagemagick." :use-xcolor t :image-input-type "pdf" :image-output-type "png" :image-size-adjust
              (1.0 . 1.0)
              ("xelatex -no-pdf -interaction nonstopmode -output-directory %o %f")
              ("convert -density %D -trim -antialias %f -quality 100 %O")))))

To set the converter, use (setq org-preview-latex-default-process 'dvisvgm) ;; same as org-latex-create-formula-image-program, which is obsolete

To get unicode (I use it for Greek math characters) to work, you'll have to set (setq org-latex-inputenc-alist '(("utf8" . "utf8x"))) and (add-to-list 'org-latex-packages-alist '("" "unicode-math"))

If you don't change dvi to xdv in the snippet above, the process hangs with a message "Creating image".

Here is a minimal org example that works for me

#+Title: Test of Unicode Operation 
#+STARTUP: latexpreview
* unicode in latex fragments
Both unicode and latex-style Greek symbols work
\[ \alpha β \gamma δ\] 

I also installed a fallback font for unicode symbols

 (set-fontset-font "fontset-default" nil
                  (font-spec :size 40 :name "Symbola"))
  • 1
    I tried to replicate this suggestion. I installed lualatex and xetex and tried ptpb.pw/_0lI/elisp rendering \[ \gamma \] and \[ γ \], but they both produce basically empty output files ptpb.pw/04Pv. Any idea what I'm doing wrong?
    – Hatshepsut
    Commented Jun 28, 2018 at 18:45
  • I get the following error message when using these settings: link.
    – George
    Commented Aug 26, 2018 at 21:46
  • This worked perfectly for me, thank you!
    – slondr
    Commented Dec 11, 2020 at 18:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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