diff options
author | Roshan Shariff <roshan.shariff@gmail.com> | 2020-09-16 18:28:39 -0600 |
---|---|---|
committer | Bastien <bzg@gnu.org> | 2020-09-23 10:59:19 +0200 |
commit | 2f9e1569f05f3553519d2fd59406b5788499b44e (patch) | |
tree | a8116feea1ad554946f3782a1620f9bc9d10a52e | |
parent | d06aa486d6c3163b6ef6e9ab665117bd93dff34a (diff) | |
download | org-mode-2f9e1569f05f3553519d2fd59406b5788499b44e.tar.gz |
org.el: Allow transparent background in latex images
* 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
-rw-r--r-- | lisp/org.el | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/lisp/org.el b/lisp/org.el index a9fdc7b..d45a789 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" |