emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Sébastien Miquel" <sebastien.miquel@posteo.eu>
To: emacs-orgmode <emacs-orgmode@gnu.org>
Cc: Roshan Shariff <roshan.shariff@gmail.com>
Subject: Re: Bug: [PATCH] Can't set background color of latex fragment
Date: Sun, 23 May 2021 21:01:27 +0000	[thread overview]
Message-ID: <644826ea-9421-4e61-6bb8-1ad42156bcf7@posteo.eu> (raw)
In-Reply-To: <CAG8iPGxE--LSFrDOe0+5We9LWrQcCVg+6q5chFCWtM3jnJpZSA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 168 bytes --]

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


[-- Attachment #2: 0001-org.el-org-create-formula-image-Fix-ignored-backgrou.patch --]
[-- Type: text/x-patch, Size: 2648 bytes --]

From 5872fc3143162fbda11cf2aa5a3798567664be99 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Miquel?= <sebastien.miquel@posteo.eu>
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':

   %f    input 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

  reply	other threads:[~2021-05-23 21:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-07 19:38 Bug: " Sébastien Miquel
2021-04-10 22:27 ` Roshan Shariff
2021-05-19  6:30   ` Sébastien Miquel
2021-05-20  0:30     ` Roshan Shariff
2021-05-23 21:01       ` Sébastien Miquel [this message]
2021-08-29  7:22         ` Bug: [PATCH] " Sébastien Miquel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=644826ea-9421-4e61-6bb8-1ad42156bcf7@posteo.eu \
    --to=sebastien.miquel@posteo.eu \
    --cc=emacs-orgmode@gnu.org \
    --cc=roshan.shariff@gmail.com \
    --subject='Re: Bug: [PATCH] Can'\''t set background color of latex fragment' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Code repositories for project(s) associated with this inbox:

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).