Re: Bug: [PATCH] Can't set background color of latex fragment

2021-08-29 Thread Sébastien Miquel

Sébastien Miquel writes:

Here's a patch that fixes this bug by calling `dvipng' with the `-bg
Transparent' argument only when no background color is set.


Setting X-Woof-Bug and X-Woof-Patch, as this doesn't show on 
https://updates.orgmode.org/


--
Sébastien Miquel




Re: Bug: [PATCH] Can't set background color of latex fragment

2021-05-23 Thread Sébastien Miquel

Hi,

Here's a patch that fixes this bug by calling `dvipng' with the `-bg
Transparent' argument only when no background color is set.

Regards,

--
Sébastien Miquel

>From 5872fc3143162fbda11cf2aa5a3798567664be99 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Miquel?= 
Date: Sun, 23 May 2021 22:07:25 +0200
Subject: [PATCH] org.el (org-create-formula-image): Fix ignored background
 color

* lisp/org.el (org-preview-latex-process-alist): add a `:transparent-image-converter'
property for `dvipng'.
(org-create-formula-image): If available, use
`:transparent-image-converter' when no background color is set.
---
 lisp/org.el | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 1bd9e02eb..d544e62fb 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -3319,7 +3319,9 @@ All available processes and theirs documents can be found in
  :image-output-type "png"
  :image-size-adjust (1.0 . 1.0)
  :latex-compiler ("latex -interaction nonstopmode -output-directory %o %f")
- :image-converter ("dvipng -D %D -T tight -bg Transparent -o %O %f"))
+ :image-converter ("dvipng -D %D -T tight -o %O %f")
+ :transparent-image-converter
+ ("dvipng -D %D -T tight -bg Transparent -o %O %f"))
 (dvisvgm
  :programs ("latex" "dvisvgm")
  :description "dvi > svg"
@@ -3374,6 +3376,9 @@ PROPERTIES accepts the following attributes:
   given to the shell and supports any of the following
   place-holders defined below.

+If set, :transparent-image-converter is used instead of :image-converter to
+convert an image when the background color is nil or \"Transparent\".
+
 Place-holders used by `:image-converter' and `:latex-compiler':

   %finput file name
@@ -16288,7 +16293,6 @@ a HTML file."
 	   org-format-latex-header
 	   'snippet)))
 	 (latex-compiler (plist-get processing-info :latex-compiler))
-	 (image-converter (plist-get processing-info :image-converter))
 	 (tmpdir temporary-file-directory)
 	 (texfilebase (make-temp-name
 		   (expand-file-name "orgtex" tmpdir)))
@@ -16302,7 +16306,11 @@ a HTML file."
 		 "Black"))
 	 (bg (or (plist-get options (if buffer :background :html-background))
 		 "Transparent"))
-	 (log-buf (get-buffer-create "*Org Preview LaTeX Output*"))
+	 (image-converter
+  (or (and (string= bg "Transparent")
+   (plist-get processing-info :transparent-image-converter))
+  (plist-get processing-info :image-converter)))
+ (log-buf (get-buffer-create "*Org Preview LaTeX Output*"))
 	 (resize-mini-windows nil)) ;Fix Emacs flicker when creating image.
 (dolist (program programs)
   (org-check-external-command program error-message))
-- 
2.31.1