0

I have used live latex previews in org mode for some time. Without changing my setup, the following error has started appearing in *Org Preview LaTeX Output*:

ERROR: can't open file '../private/var/folders/16/481dkh1n503585qtsvjh00dw0000gr/T/orgtexwD0MHj.dvi' for reading

For specific directories on my iMac, this error always occurs; for other directories everything still works as normal. When I go to the file orgtexwD0MHj.dvi, it seems fine, and it has read permissions. If I use dvisvgm orgtexwD0MHj.dvi --no-fonts --exact-bbox --output=orgtexwD0MHj.svg from a command-line, it works.

Does anyone have any idea what could be causing this?

On my machine, I can reproduce the error with

emacs -Q

(setq org-preview-latex-default-process 'dvisvgm)
(setq org-preview-latex-process-alist
      '((dvisvgm
    :programs ("latex" "dvisvgm")
    :description "dvi > svg"
    :message "install programs: latex and dvisvgm."
    :image-input-type "dvi"
    :image-output-type "svg"
    :image-size-adjust (1.7 . 1.5)
    :latex-compiler ("pdflatex -output-format=dvi -interaction nonstopmode -output-directory %o %f")
    :image-converter ("dvisvgm %f --no-fonts --exact-bbox --scale=%S --output=%O"))))

Previewing a latex fragment in /tmp/t.org, I get the error.

NB: some folders in ~/ are also experiencing this error, so it is not specific to /tmp.

1

1 Answer 1

0

The issue has something to do with relative vs absolute filepaths.

Make the following setting, try to preview a latex fragment, and then inspect /tmp/t:

(setq org-preview-latex-process-alist
  '((dvisvgm
    :image-input-type "dvi"
    :image-output-type "svg"
    :image-size-adjust (1.7 . 1.5)
    :latex-compiler ("echo \"%o\n%b\n%O\n%f\" >> /tmp/t")
    :image-converter ("..."))))

In my case, it becomes apparent that %f expands to a relative filepath (relative to /tmp/), whereas the others expand to absolute filepaths. This also holds true when I perform a similar test on the way %f expands when used in the :image-converter.

I can force it to use an absolute path by making the following change, and things seem to be working okay having done that

(setq org-preview-latex-process-alist
  '((dvisvgm
    :image-input-type "dvi"
    :image-output-type "svg"
    :image-size-adjust (1.7 . 1.5)
    :latex-compiler ("pdflatex -interaction nonstopmode -output-format=dvi -output-directory=%o %f")
    :image-converter ("dvisvgm %o%b.dvi --no-fonts --exact-bbox --scale=%S --output=%O"))))
;; NB: %o%b.dvi instead of %f forces use of absolute path

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.