0

To write in different language, I'm exploring different LaTeX engine mainly XeLaTex.

#+LATEX_COMPILER: xelatex
#+LATEX_HEADER: \usepackage{fontspec}
#+LATEX_HEADER: \setmainfont{CMU Serif}

* This is a test, (энэ бол тест)
\begin{equation}
a + b + c +d + e + f + g + h
\end{equation}
  • Above org-file, M-x org-latex-export-to-pdf produces pdf file without any issue.
  • But, (when I try to preview each equation) M-x org-latex-preview gives following error.
org-compile-file: File "/tmp/orgtexRzIPhL.dvi" wasn’t produced.  Please adjust ‘dvipng’ part of ‘org-preview-latex-process-alist’.

Question: What am I doing wrong?, How can I fix this?


Additional info: I played around little bit, and found that M-x org-latex-preview fails only when \usepackage{fontspec} exist.

The value of org-preview-latex-process-alist (As NickD suggested to include):

Value:
((dvipng :programs
         ("latex" "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)
         :latex-compiler
         ("latex -interaction nonstopmode -output-directory %o %f")
         :image-converter
         ("dvipng -D %D -T tight -o %O %f")
         :transparent-image-converter
         ("dvipng -D %D -T tight -bg Transparent -o %O %f"))
 (dvisvgm :programs
          ("latex" "dvisvgm")
          :description "dvi > svg" :message "you need to install the programs: latex and dvisvgm." :image-input-type "dvi" :image-output-type "svg" :image-size-adjust
          (1.7 . 1.5)
          :latex-compiler
          ("latex -interaction nonstopmode -output-directory %o %f")
          :image-converter
          ("dvisvgm %f --no-fonts --exact-bbox --scale=%S --output=%O"))
 (imagemagick :programs
              ("latex" "convert")
              :description "pdf > png" :message "you need to install the programs: latex and imagemagick." :image-input-type "pdf" :image-output-type "png" :image-size-adjust
              (1.0 . 1.0)
              :latex-compiler
              ("pdflatex -interaction nonstopmode -output-directory %o %f")
              :image-converter
              ("convert -density %D -trim -antialias %f -quality 100 %O")))
6
  • 1
    I deleted the preview-latex tag: preview-latex is part of auctex and has nothing to do with org-latex-preview (although it probably should, but that's fodder for another conversation...)
    – NickD
    Oct 16, 2023 at 16:41
  • @NickD, Thanks, I'll try to remember next time.
    – Garid
    Oct 17, 2023 at 2:03
  • What is the value of org-preview-latex-process-alist? Please add it to the question. You probably need to adjust the dvipng part of it to use xelatex instead of whatever it is using currently. Although dvipng would then be a misnomer...
    – NickD
    Oct 17, 2023 at 13:59
  • I don't know if xelatex can produce dvi output. You might be better off modifying the imagemagick method which goes through pdf rather than dvi and do (setq org-preview-latex-default-process 'imagemagick) to use that method instead of dvipng.
    – NickD
    Oct 17, 2023 at 14:10
  • @NickD, Thanks for the tip. After (setq org-preview-latex-default-process 'imagemagick), it outputs: org-compile-file: File "/tmp/orgtexJpyLfC.pdf" wasn’t produced. Please adjust ‘imagemagick’ part of ‘org-preview-latex-process-alist’.. I'm not sure how to debug further
    – Garid
    Oct 17, 2023 at 14:38

1 Answer 1

1

Here are the modifications to add to your init file:

(with-eval-after-load 'org
  (setq org-preview-latex-default-process 'imagemagick)
  (setf (plist-get (cdr (assq 'imagemagick org-preview-latex-process-alist)) :latex-compiler)
        '("xelatex -interaction nonstopmode -output-directory %o %f")))

When org is loaded, then the org-preview-latex-default-process will be set to imagemagick, which takes the fragment, compiles it with LaTeX to produce a PDF and then calls convert to convert the PDF to a PNG. The assumption is that you have installed imagemagick of course, otherwise the convert step will fail.

It also changes the LaTeX compiler of the imagemagick section from the default pdflatex to xelatex.

You could also use customize on these two variables: it would probably be easier, particularly for changing the LaTeX compiler entry.

Try it and see if it works.

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.