From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id kNyVEWzxYl+LcQAA0tVLHw (envelope-from ) for ; Thu, 17 Sep 2020 05:17:32 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id uGucDWzxYl8+IAAA1q6Kng (envelope-from ) for ; Thu, 17 Sep 2020 05:17:32 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 73FD79400D3 for ; Thu, 17 Sep 2020 05:17:31 +0000 (UTC) Received: from localhost ([::1]:55430 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kImIT-0005pJ-V9 for larch@yhetil.org; Thu, 17 Sep 2020 01:17:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47528) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kIho1-0003f6-0y for emacs-orgmode@gnu.org; Wed, 16 Sep 2020 20:29:45 -0400 Received: from mail-pj1-x1043.google.com ([2607:f8b0:4864:20::1043]:51076) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kIhnz-0004yp-DV for emacs-orgmode@gnu.org; Wed, 16 Sep 2020 20:29:44 -0400 Received: by mail-pj1-x1043.google.com with SMTP id fa1so341913pjb.0 for ; Wed, 16 Sep 2020 17:29:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=RmZtNMa1dKZ7HjUhhDmfGuvv5P2LzJURZrfmpb43gZ4=; b=WfdPm/KktiqnzaKEop2BAfIjCmejsCeWfIY6+H0H9zLteuqJcuZVx0/HFvwn1gYy+v A+rUuLWpuWstMmcxOnwyBjZs/+lfifR3RhbspnvAzhrbao0CBEDBX5qK5QfYOdRneT7O 1nSzR66o9IpSKeNomO8EpbPQn0i1b8jfW4uPAjmvcaqhP1euOL5119ouZnhn2dXxJH0+ bJ+Bcla4jiQ8qKx69nV+0uCLuEhmp3YFwkC0QuqWhi1V/AStNQnmSOkM7vMyQDGhjop6 JoCOjMkWkbexio3SHgRzF5gB4dwu9L0mWcT5tnkSNRhBYZTCRjTxHsExZxIdFBb6D692 elvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=RmZtNMa1dKZ7HjUhhDmfGuvv5P2LzJURZrfmpb43gZ4=; b=RYoirpgX8QANtgg1w82l8ZNs/FiHhnFp0l2h9RjvhGt+iY0ZzLuOQUTiEjokjLa6J7 QmBmt6Ta7jsfRsDG6X2VmQowYDXUtbHQaA9j4GECFXK/N/WQSNYIuMfLyAUEtVb9CMGJ t+Vf8ePBIZ8f9J9hN3BufmgjClaGldwy3lW2mjia+gv2QKd0F07L/YY2DD0sM1aam2H6 A7NfxdPlzCfPc1YPWIQ0oFCCo/KBmAeirnQYXzWETScnuzP52t6a+ybHTg34ctMnRkxT WVrmGKjdT/cfBneR5/+VzgBy9wuTdiZq0TZ3ju/a8ILgoqPKWHZynNeDhWIvfvx870BP OgUA== X-Gm-Message-State: AOAM532srzRD+mHK16Sk9evsQBuotE6NsJG9ar898Ra6Rpp6UlmhqSXL Izz5a/6dgg6t0jK2lR1C/bAaDxY1eTudaQ== X-Google-Smtp-Source: ABdhPJwifZ1EhmTA+wZWyuT1ooD8TvJ1U/g3pWlHHaHh3UE+WR40XaE9ExfOO5RkV4cpklos0Dhxmg== X-Received: by 2002:a17:90a:380a:: with SMTP id w10mr6020573pjb.23.1600302581285; Wed, 16 Sep 2020 17:29:41 -0700 (PDT) Received: from localhost (S01069050ca65e863.ed.shawcable.net. [174.3.244.184]) by smtp.gmail.com with ESMTPSA id e16sm3413833pgv.81.2020.09.16.17.29.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 16 Sep 2020 17:29:40 -0700 (PDT) From: Roshan Shariff To: emacs-orgmode@gnu.org Subject: [PATCH] org.el: Allow transparent background in latex images Date: Wed, 16 Sep 2020 18:28:39 -0600 Message-Id: <20200917002838.1037700-1-roshan.shariff@gmail.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::1043; envelope-from=roshan.shariff@gmail.com; helo=mail-pj1-x1043.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Thu, 17 Sep 2020 01:17:10 -0400 X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roshan Shariff Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=WfdPm/Kk; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: 2.29 X-TUID: ZJLPdGIInUrH * 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