When using themes with background color set to #000000, and org-preview-default-process is set to dvisvgm, the LaTeX fragments are displayed incorrectly.

To reduplicate:

1. Switch to a theme with background color set to #000000 (like Modus Vivendi) 2. Create an org-mode document. Write some LaTeX fragment and press C-c C-x C-l to preview LaTeX fragment.
3. The LaTeX preview is displayed as a white rectangle.

After debugging, I found that it is because dvisvgm omitts the default #000 color value when generating SVG file, and emacs has a unique way of displaying the SVG, which caused foreground color to be applied to it.

A solution is to change org-format-latex-options to use transparent background by default. I've attached this fix.

See also: https://emacs-china.org/t/emacs-30-1-svg/29217/
From ea138d5327829fe9e28cd2cea6181a9ac1f8d16f Mon Sep 17 00:00:00 2001
From: Leilei332 <leiyixi...@outlook.com>
Date: Mon, 14 Apr 2025 17:47:44 +0800
Subject: [PATCH] Make LaTeX preview images use transparent background as
 default

* lisp/org.el (org-format-latex-options): Make LaTeX preview images use 
transparent background as default to make them display properly in some dark 
theme.
---
 lisp/org.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/org.el b/lisp/org.el
index 78e8c0692..4145b2d6b 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -3275,7 +3275,7 @@ A nil value means to remove them, after a query, from the 
list."
   :group 'org)
 
 (defcustom org-format-latex-options
-  '(:foreground default :background default :scale 1.0
+  '(:foreground default :background "Transparent" :scale 1.0
                :html-foreground "Black" :html-background "Transparent"
                :html-scale 1.0 :matchers ("begin" "$1" "$" "$$" "\\(" "\\["))
   "Options for creating images from LaTeX fragments.
-- 
2.49.0.windows.1

Reply via email to