4

How can I control the background color of my LaTex fragments in Org-mode?

I am using the badwolf-theme package, and this is what I get:

enter image description here

I would like the background color of my formulas to match the background color of my org buffer.

Here are my current org-format-latex-options:

enter image description here

4
  • 2
    Have you tried tweaking org-format-latex-options?
    – JeanPierre
    May 28, 2016 at 20:03
  • @JeanPierre I updated the OP. Background seems to be set to default. Not sure if there is a different option to control this. May 29, 2016 at 0:04
  • 1
    Maybe try setting it to auto?
    – JeanPierre
    May 29, 2016 at 7:34
  • This works for me with the default value of org-format-latex-options, which are the same as yours. Maybe something in the badwolf-theme causes the problem?
    – Tyler
    Jun 1, 2016 at 13:09

4 Answers 4

1

I've had this problem before, sometimes deleting the ltximg folder helps reset things from the previous theme.

2
  • in case anyone doesn‘t know where to look, the ltximg files are in „~/.emacs.d/.local/cache/org-latex“
    – pfincent
    Oct 20, 2021 at 10:58
  • 1
    @pfincent be aware that the folder for the ltximg-files is configured by the variable org-latex-preview-ltxpng-directory; depending on the user's configuration, this variable might also point to some other place.
    – ben
    Oct 21, 2021 at 14:50
1

I had a similar issue (in my case it was the foreground-setting that I couldn't control appropriately). I was able to fix it by employing xcolor in the conversion process.

Put this in your init.el and execute it by pressing C-M-x or by restarting emacs:

;; fix color handling in org-preview-latex-fragment
(let ((dvipng--plist (alist-get 'dvipng org-preview-latex-process-alist)))
  (plist-put dvipng--plist :use-xcolor t)
  (plist-put dvipng--plist :image-converter '("dvipng -D %D -T tight -o %O %f")))

Then simply recreate your images (delete the folder ltximg).

2
  • I get the error: „void-variable org-preview-latex-process-alist“
    – pfincent
    Oct 20, 2021 at 11:07
  • Hi @pfincent, how did you execute the expression that I suggested - in init.el or manually with C-M-x? In init.el, please try to wrap my expression inside a (with-eval-after-load 'org <my-code-here>)-statement. Maybe org has not been loaded yet when the code in your init.el is executed. Or, simply execute my expression manually (C-M-x), after you've opened an org-document. Does this fix your issue?
    – ben
    Oct 21, 2021 at 12:40
1

There is now a solution to this in later versions of org-mode: https://www.mail-archive.com/[email protected]/msg130709.html

To get true transparent backgrounds in the generated fragments, set

(plist-put org-format-latex-options :background "Transparent")
0

I would try changing the :background from default to "Black"

Somehow my :foreground default got changed from white to black and it was really annoying. Note that it's expecting a stringp so quotes are needed. You might be able to put hex string in there. Haven't tried myself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.