From: Roshan Shariff <roshan.shariff@gmail.com>
To: emacs-orgmode@gnu.org
Cc: Roshan Shariff <roshan.shariff@gmail.com>
Subject: [PATCH] org.el: Allow transparent background in latex images
Date: Wed, 16 Sep 2020 18:28:39 -0600 [thread overview]
Message-ID: <20200917002838.1037700-1-roshan.shariff@gmail.com> (raw)
* lisp/org.el (org-create-formula-image): When `:background' is set to
"Transparent" in `org-format-latex-options', do not output a
`\pagecolor{...}' command in the generated LaTeX file. This will
cause dvisvgm, convert, or dvipng (with the `-bg Transparent' option)
to produce png or svg images with a transparent background.
* lisp/org.el (org-preview-latex-process-alist): Add the `-bg
Transparent' command-line option to dvipng, which causes it to produce
a PNG with an alpha channel when the dvi file has no `\background'
special.
TINYCHANGE
---
lisp/org.el | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/lisp/org.el b/lisp/org.el
index 053635c85..108dc6b5b 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -3282,7 +3282,7 @@ 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 -o %O %f"))
+ :image-converter ("dvipng -D %D -T tight -bg Transparent -o %O %f"))
(dvisvgm
:programs ("latex" "dvisvgm")
:description "dvi > svg"
@@ -16146,10 +16146,10 @@ a HTML file."
(if (eq fg 'default)
(setq fg (org-latex-color :foreground))
(setq fg (org-latex-color-format fg)))
- (if (eq bg 'default)
- (setq bg (org-latex-color :background))
- (setq bg (org-latex-color-format
- (if (string= bg "Transparent") "white" bg))))
+ (setq bg (cond
+ ((eq bg 'default) (org-latex-color :background))
+ ((string= bg "Transparent") nil)
+ (t (org-latex-color-format bg))))
;; Remove TeX \par at end of snippet to avoid trailing space.
(if (string-suffix-p string "\n")
(aset string (1- (length string)) ?%)
@@ -16158,8 +16158,10 @@ a HTML file."
(insert latex-header)
(insert "\n\\begin{document}\n"
"\\definecolor{fg}{rgb}{" fg "}%\n"
- "\\definecolor{bg}{rgb}{" bg "}%\n"
- "\n\\pagecolor{bg}%\n"
+ (if bg
+ (concat "\\definecolor{bg}{rgb}{" bg "}%\n"
+ "\n\\pagecolor{bg}%\n")
+ "")
"\n{\\color{fg}\n"
string
"\n}\n"
--
2.26.2
next reply other threads:[~2020-09-17 5:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-17 0:28 Roshan Shariff [this message]
2020-09-23 8:59 ` [PATCH] org.el: Allow transparent background in latex images Bastien
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=20200917002838.1037700-1-roshan.shariff@gmail.com \
--to=roshan.shariff@gmail.com \
--cc=emacs-orgmode@gnu.org \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public 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).