1

I'm using Lualatex with a custom package and have org-mode configured to it using

(setq org-latex-compiler "lualatex")

I also put all the Latex-packages I usually need into a custom one and configured org-mode to use that when compiling. This works great, except when I want to send emails with mu4e that include Latex-equations, in which case I get an error message:

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

Inspecting the compilation logs shows that the compilation ends because Emacs tries to compile the file using Latex, not Lualatex. So I tried to change org-preview-latex-process-alist to use Lualatex. After some unsuccessful partial reconfiguration attempts, I replaced pretty much all latex-values lualatex:

(setq org-preview-latex-process-alist
      '((luamagick :programs
        ("lualatex" "convert")
        :description "pdf > png" :message "you need to install lualatex and imagemagick." :use-xcolor t :image-input-type "pdf" :image-output-type "png" :image-size-adjust
        (1.0 . 1.0)
        :latex-compiler
        ("lualatex -interaction nonstopmode -output-directory %o %f")
        :image-converter
        ("convert -density %D -trim -antialias %f -quality 100 %O"))
 (dvipng :programs
     ("lualatex" "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
     ("lualatex -interaction nonstopmode -output-directory %o %f")
     :image-converter
     ("dvipng -D %D -T tight -bg Transparent -o %O %f"))
 (dvisvgm :programs
      ("lualatex" "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
      ("lualatex -interaction nonstopmode -output-directory %o %f")
      :image-converter
      ("dvisvgm %f -n -b min -c %S -o %O"))
 (imagemagick :programs
          ("lualatex" "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")

Where the luamagick-part is from this answer. But the error message remains. So how can I tell org-msg to use Lualatex instead of normal Latex? Alternatively, how can I configure org-msg to not use my custom library while leaving it as a default for normal org-mode?

1 Answer 1

2

I think the message

Please adjust 'imagemagick' part of `org-preview-latex-process-alist'

means that in the imagemagick part of the list org-preview-latex-process-alist, you need to change "pdflatex -interaction nonstopmode -output-directory %o %f" to "lualatex -interaction nonstopmode -output-directory %o %f" . From what you've shown above, you haven't made that change yet. I don't think you need to even do (setq org-latex-compiler "lualatex"), because that controls LaTeX export (to .tex or .pdf files).

EDIT: As OP points out, :image-converter ("convert -density %D -trim -antialias %f -quality 100 %O") is needed for the imagemagick entry to work. So while the lua fragments need lualatex to be added, the resulting image won't be converted into a .png without the :image-converter command.

Alternatively, you may want to (1) revert everything back to the previous default settings, and (2) add the following:

(imagemagick-lua :programs
          ("lualatex" "convert")
          :description "pdf > png" :message "you need to install the programs: lualatex and imagemagick." :image-input-type "pdf" :image-output-type "png" :image-size-adjust
          (1.0 . 1.0)
          :latex-compiler
          ("lualatex -interaction nonstopmode -output-directory %o %f")
          :image-converter ("convert -density %D -trim -antialias %f -quality 100 %O")

(Edited to add the image-converter part, raised in the comments)

to the end of org-preview-latex-process-alist, and then do:

(setq org-preview-latex-default-process 'imagemagick-lua)

If you only need to use lualatex in some documents and prefer the regular method in other cases, after adding the above imagemagick-lua process, you could then add the following function to your config:

(defun my/lua-latex-previews ()
  "Function to set local org-preview-latex process to Imagemagick-lua"
  (interactive)
  (setq-local org-preview-latex-default-process 'image-magick-lua))

and just do M-x my/lua-latex-previews in the buffers where you need lualatex.

3
  • Thanks! I only now came to try it out. It now compiles but after Creating LaTeX Image it says org-compile-file: No valid command to process "/tmp/orgtexg9hBIc.pdf". Please adjust imagemagick-lua' part of org-preview-latex-process-alist'. What does it want now? Commented Sep 17, 2023 at 17:47
  • I figured it out: the image-converter portion was needed. I added ` :image-converter ("convert -density %D -trim -antialias %f -quality 100 %O")` from the imagemagick-entry and now it works! Commented Sep 17, 2023 at 18:07
  • 1
    @AlexanderPraehauser Woops, totally missed that part. I'll correct that so that other people won't get stuck if they follow this up. Yes, that should fix the imagemagick entry. But your luamagick entry should have worked from the start -- although you might have had to do (setq org-preview-latex-default-process 'luamagick) or use the my/lua-latex-previews function with 'image-magick-lua changed to luamagick. Commented Sep 18, 2023 at 7:38

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.