#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]

put it in .textlive/style_files/

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

  2. add

(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

Loading data dump...

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!

thanks a lot for your fast reply!

  1. I am sorry that I’ve ++++ed the placement of the style file up :confused: My testfile had a local copy of the style file in the same folder, so that it has worked anyway. I’ve now placed it properly in /usr/share/texmf-dist/tex/latex/local/ and now I can use this package system wide when compiling with pdflatex (I’ve done that in the terminal, not emacs). After clearing org-latex-package-alist and readding the correct package, latex fragments work (nearly) as expected!

  2. I still have some issues but these might be tex(/order of dependencies loading) related, so I will dig into that, first!

Before closing this post I have one final question: How to proceed with this post, properly? As you can see, my issue was not doom related, but TeX related. Shall I delete this thread or shall I transform it into a post for others on how to import custom LaTeX packages to doom (properly – this might require polishing of an expert)? Technically this can be inferred from different sources (STACK exchange and GNU emacs org documentation along the doom documentation), so I am not sure about that.

Thanks a lot for your time!

Hi. Great that it works now! I do not think you have to do anything with the post yourself, but maybe administrators have a different opinion on that.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.