0

I am a brand new emacs user and I want to be able to view snippets of LaTeX in my .org file.

My OS is Ubuntu 16.04, I have installed texlive-full, and I have installed AucTex and org using the Emacs package manager.

I have been trying to follow the first example in this guide:

latex preview example

I have put in my .emacs file the single line

(setq org-latex-create-formula-image-program 'imagemagick)

I have the imagemagick package installed in Ubuntu.

Yet when I try to see the first example by pressing C-c C-x C-l, I get this error message:

org-compile-file: File "/tmp/orgtex32228nYH.pdf" wasn't produced.  Please adjust 'imagemagick' part of `org-preview-latex-process-alist'.

When I press C-h v I can inspect the variable, but I have no idea what to change...

Looking in /tmp there is no corresponding .log file, only a .tex file, which doesn't reveal any error.

Can anybody please help me?

2
  • The guide you point to predates the current version of org by many years, but looking over it I don't see too much that needs changing (other than the name of the variable: org-latex-create-formula-image-program is an alias to org-preview-latex-default-process, so it's going to work either way, but the new name is preferred, since it has a better chance of being valid in the future). If you forget about org for a moment and just cut and paste the example TeX program from the guide into a file on your system, and then try to process it as described in the guide, do you get any errors?
    – NickD
    Commented Mar 13, 2017 at 6:10
  • As an inspection of org-create-formula-image and org-compile-file shows the log-text of the programs for processing the preview images goes to the buffer *Org Preview LaTeX Output*. Pityingly the used function shell-command erases the output buffer before it prints the new output of the shell command. That means that you will only see the output of the last command. You could collect the output of all commands in a new buffer using an after-advice of org-compile-file.
    – Tobias
    Commented Dec 26, 2017 at 12:02

5 Answers 5

2

I recently struggled with this same problem, after installing texlive-full on Linux Mint. I followed advice starting from this post and indeed found I needed to install an additional package: ulem.sty. Unfortunately you say you cannot find the .log file, but if you can find where the .log file is, I suspect you will find you need additional packages which were not included in texlive-full.

1

I solved the problem that way :

  1. Edit /etc/ImageMagick-6/policy.xml
  2. Change the line <policy domain="coder" rights="none" pattern="PDF" /> to: <policy domain="coder" rights="read|write" pattern="PDF" />
1
  • 1
    Can you please enlarge your answer and explain what that line does and why commenting it out solved your problem?
    – NickD
    Commented Mar 5, 2019 at 19:39
0

I also faced the same problem. In my case, it was caused by the wrong setting of :latex-compiler in imagemagick part of org-preview-latex-process-alist: the original value was

("pdflatex -interaction nonstopmode -output-directory %o %f")

but I would like use

("lualatex -interaction nonstopmode -output-directory %o %f")

instead.

As I do not know much about lisp, I simply followed https://stackoverflow.com/questions/41568410/configure-org-mode-to-use-lualatex

Although this patch is for lualatex users like me (and not the best or reasonable way), your problem could be solved in a similar manner. You might define new function (e.g. new-imagemagick) with proper :latex-compiler command, add it to org-preview-latex-process-alist and call it rather than imagemagick. You can change directly the part of "pdf latex -interation ....") according to your prefer latex command.

1
  • In the case of luaLaTeX, a new entry was necessary because there was no entry before. But in the the case of imagemagick, there is an entry already present. If it does not work, it is better to fix it, than to introduce a new one.
    – NickD
    Commented Mar 5, 2019 at 19:37
0

I found the logs for this in my /tmp/ directory, but the way I was able to debug this was by running the convert command found in org-preview-latex-process-alist myself.

I got an error saying

convert: attempt to perform an operation not allowed by the security policy 
 `gs' @ error/delegate.c/ExternalDelegateCommand/378.

If this is the case for you, you can edit the policy found in /etc/ImageMagick-<version>/policy.xml. Change the rights for the gs pattern from none to all.

You can check the version of ImageMagick that Emacs uses by running

convert --version
0

I am on a Windows machine and the error was caused by the fact that the proper command in imagemagick to convert is not only convert anymore, but it is now magick convert. Changing that in the org-preview-latex-process-alist variable solved the problem for me.

That means the imagemagicksection of the var should be as follows

(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-compilerpiler
             ("pdflatex -interaction=nonstopmode -output-directory %o %f")
             :image-converter ;;on windows we need "magick" command prefix
             ("magick convert -density %D -trim -antialias %f -quality 100 %O"))

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.