0

In my .org file I embedded a simple Latex segment:

$f(x) = x^2$    

Then I use the following command to generate a preview for that segment:

org-toggle-latex-fragment

But I get an error:

org-compile-file: File "/var/folders/x2/zp6vz8z97xv48g97pht5_mrc0000gn/T/orgtexu9KnIy.dvi" wasn’t produced.  
Please adjust ‘dvipng’ part of ‘org-preview-latex-process-alist’.

I tried to debug the issue:

  • The file /var/folders/x2/zp6vz8z97xv48g97pht5_mrc0000gn/T/orgtexu9KnIy.tex exists
  • I can use pdflatex to create a file from the above .tex without any issue.
  • I can also create a dvi from the above by just running latex orgtexu9KnIy.tex. No error happens.
  • When I run dvipng orgtexu9KnIy I get the following output:

    This is /usr/local/texlive/2017/bin/x86_64-darwin/dvipng (dvipng (TeX Live)) 
    1.15 Copyright 2002-2015 Jan-Ake Larsson
    [1]
    

And I have a file orgtexu9KnIy1.png in the current folder. I'm suspicious bit wondering about the additional 1 in the file name.

Org expects the file name to be orgtexu9KnIy.png and not orgtexu9KnIy1.png.


The value of the variable org-preview-latex-process-alist:

((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 -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 "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 -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)
           :latex-compiler
           ("pdflatex -interaction nonstopmode -output-directory %o %f")
           :image-converter
           ("convert -density %D -trim -antialias %f -quality 100 %O")))
3
  • Looks like an incomplete TeX setup. Maybe, pdflatex is setup but not dvipng. Does AucTeX Preview work with the generated LaTeX file? If that works (with png-previews) you could give texfrag a try. – Tobias Apr 19 '20 at 7:59
  • Can you run a fourth step: dvipng orgtexu9KnIy.dvi, and see if that succeeds too? Also,please add the value of org-preview-latex-process-alist to your question. – NickD Apr 19 '20 at 19:15
  • @NickD updated my question, dvipng seems to work, but it generates a file orgtexu9KnIy1.png which has an additional 1 in the filename, which is a bit strange. There are no other pngs in the same folder. – Max Apr 20 '20 at 4:46
1

NickD's comment helped me to debug the issue. In the end everything was setup correctly, but I needed to create symlinks in /usr/local/bin to latex and to dvipng. It was not enough to have these utilities in my PATH.

The tools were installed in /usr/local/texlive/2017/bin/x86_64-darwin/ by brew.

I found that out because in the messages buffer there was a zsh: latex command not found, which I also initially overlooked.

4
  • It should be enough to have them in your PATH: check the value of ~PATH` inside emacs using (getenv "PATH") - it may be that something changes it or it is not set correctly somehow. – NickD Apr 20 '20 at 21:37
  • Hm it didn't work, I added the dir to the PATH in my .zshrc, but looks like by default emacs won't read that. I didn't bother to fix that, but other people looked into that: stackoverflow.com/questions/9435019/… – Max Apr 21 '20 at 9:46
  • Are you using terminal emacs or GUI emacs? From the terminal, emacs should inherit the PATH setting from the shell, so that should work. From the GUI, you have to put the PATH setting in some place (perhaps $HOME/.profile) which is sourced by whatever GUI you use and then emacs will inherit from that. – NickD Apr 21 '20 at 12:28
  • Yes you are right, I use the GUI version. Thanks for the tip, I will try to make that work! – Max Apr 21 '20 at 14:10

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.