#Custom defs of macros for LaTeX fragments in org

What happened?

TLTR: LaTeX fragments in org fail to compile after trying to incorporate custom LaTeX macros for fragments. I’ve added my stylesheet to the org-latex-packages-alist with the snippet flag t, as indicated in the org documentation. Trying to compile a fragment results in “File “/tmp/orgtex6SSiyz.dvi” wasn’t produced. Please adjust ‘dvipng’ part of ‘org-preview-latex-process-alist’”.

Further information:

• Compiling LaTeX fragments worked before I tried to add my custom defs.
• I’ve added my package to .texlive as a style file and when using LaTeX I can include it globally via \usepackage{packagename}.
• Googling resulted in adding it in the config via
``````(add-to-list 'org-latex-packages-alist '("" "packagename" t))
``````

where the snippet flag t is required for the package to be used for turning LaTeX snippets into images for non LaTeX outputs (which my org file appears to be… – setting it to nil doesn’t produce the error message, but the package is then not incorporated for the fragments, as the output misses the results of the macros)

• I’ve looked at the variable org-preview-latex-process-alist but I’m new to Emacs and wasn’t able to draw a meaningful conclusion. This means in particular that I haven’t altered it consciously.

What did you expect to happen?

I’ve expected the LaTeX fragments in org to compile and display the result of my LaTeX macros… I hope that someone can tell me how to incorporate my custom LaTeX macros so that they are also respected by LaTeX fragments in org. I would like to transition to Emacs for managing a huge LaTeX project and it would be fabulous, if the fragments were readable in my notes between the LaTeX code blocks meant for export.

Steps to reproduce

1. Write a LaTeX style file ‘thisisastupidtestfile.sty’, maybe one that only contains the line
``````\ProvidesPackage{thisisastupidtestfile}[2022/07/15 thisisastupidtestfile]
\newcommand{\Z}{success}
``````

put it in .textlive/style_files/

1. Check that it works with \usepackage{thisisastupidtestfile} for some random LaTeX file on your system.

``````(add-to-list 'org-latex-packages-alist '("" "thisisastupidtestfile" t))
``````

(I put it after! org and after! latex) to your config, open doom, press SPC h r r, open an org file and paste \$\Z = success?\$.

1. Hover this LaTeX fragment and hit enter, the error should occur.

System information

``````
```

Hi. Could you provde the full log of the LaTeX compilation buffer? Did you check the TeX file produced by Org Export?

Also maybe relevant: Ins’t it `./texlive`, and not `~/.textlive`?

Finally, what is the value of the `TeX-style-private` variable in Emacs? Does it include the folder with your style files?

1 Like

Hi Dominik!