# Why is latex preview and latex to html export via dvisvgm not working in org-mode?

I read this and this question along with the documentation of org-preview-latex-process-alist pulled up by C-h v org-preview-latex-process-alist RET. Alright, I have an idea about what to do. I put this in my init.el under (use-package org ... :init)

(setq org-latex-pdf-process
'("xelatex -shell-escape -interaction nonstopmode %f"
"xelatex -shell-escape -interaction nonstopmode %f"))
(setq xdvsvgm
'(xdvsvgm
:programs ("xelatex" "dvisvgm")
:description "xdv > svg"
:message "you need to install the programs: xelatex and dvisvgm."
:use-xcolor t
:image-input-type "xdv"
:image-output-type "svg"
:image-size-adjust (1.7 . 1.5)
:latex-compiler ("xelatex -no-pdf -interaction nonstopmode -output-directory %o %f")
:image-converter ("dvisvgm %f -n -b min -c %S -o %O")))
(with-eval-after-load 'org
(add-to-list 'org-preview-latex-process-alist xdvsvgm)
(setq org-preview-latex-default-process 'xdvsvgm))


Then I try C-c C-e h h to export to html but I get,

org-compile-file: File "/tmp/orgtexlUjxgz.xdv" wasn’t produced. Please adjust ‘xdvsvgm’ part of ‘org-preview-latex-process-alist’.

I don't understand why the xdv file is not produced. My hunch is that there is something wrong with the command xelatex -no-pdf -interaction nonstopmode -output-directory %o %f.

Could someone help?

Here is a minimal document to test it,

#+TITLE: Title Here
#+AUTHOR: Author Name
#+OPTIONS: tex:xdvsvgm

#+BEGIN_export latex
\begin{align*}
n &= \frac{n}{2} + \frac{n}{2} \\
&= \sum_{i=1}^{n} 1
\end{align*}
#+END_export

• The two links at the top are to the same question: can you fix that? – NickD Jun 19 '20 at 12:48
• The usual debugging technique for such problems is to execute the command on the command line and see if it works as you expect. If not, fix the command; if yes, fix the linkage between Org mode and the command. – NickD Jun 19 '20 at 13:20
• Do you mean C-c C-x C-l to get a LaTeX preview? Exporting will just skip the latex secttion altogether since it's not HTML. – NickD Jun 19 '20 at 18:55
• If you try to export the above to HTML, the #+BEGIN_EXPORT latex ... #+END_EXPORT block should not be processed at all: you are saying "This block should only be exported to LaTeX (or PDF since that goes through LaTeX) - any other export should omit it". Are you sure you are exporting it to HTML? – NickD Jun 19 '20 at 19:18
• Okay to be honest, I am not that fluent in org-mode ways. I am using that latex begin end code block because then I get better syntax highlighting (AucTex like). And, it exports to Latex code without actually exporting the begin and end wrap. I fixed the links. – scribe Jun 20 '20 at 0:30

## 1 Answer

Okay so I solved the issue with some insight that if the command was failing to produce /tmp/orgtexlUjxgz.xdv then there must be a /tmp/orgtexlUjxgz.log with detail about the issue. And, sure enough, looking at /tmp/orgtexlUjxgz.log I realised that I was missing a package and resolving that fixed the org-toggle-latex-fragment.