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 gC8DAUbqT1+fYQAA0tVLHw (envelope-from ) for ; Wed, 02 Sep 2020 18:53:58 +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 iHoBOEXqT19SNQAA1q6Kng (envelope-from ) for ; Wed, 02 Sep 2020 18:53:57 +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 5FF23940704 for ; Wed, 2 Sep 2020 18:53:57 +0000 (UTC) Received: from localhost ([::1]:47142 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kDXtL-0001F0-AI for larch@yhetil.org; Wed, 02 Sep 2020 14:53:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43564) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kDXt0-0001Ec-Cj for emacs-orgmode@gnu.org; Wed, 02 Sep 2020 14:53:34 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:33070) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kDXsy-0006DX-Gn for emacs-orgmode@gnu.org; Wed, 02 Sep 2020 14:53:34 -0400 Received: by mail-pf1-x441.google.com with SMTP id u20so166829pfn.0 for ; Wed, 02 Sep 2020 11:53:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=SteG6DSAxGWWRjfoustqtSCObhi7b3nOqppZD57aey8=; b=cO2cAwxwNXWaytt+xEjTUdimtFmqiiLVeYP/QlxAx3hqq6opqMNCT/Abj40ITEfaiK uM1P3vaDdGo6KIVmYFGoke0qRHRiJyJEQ1r3GcTmH0HJTuN6zCDvfkZb17W28AjRVdmW LXh5eS6viVMbxgOekRH9lH8nMGVNQUriN4CqNLg1C6CBEEOIIFCfWKLmfDOziHoOTZaY iDLH//kbOTC+6IEedT8YGX6m1VmfSx2tCGJkDlPPq9VTDNjADYRMYi+hnAjojAvdnnhk hbrdNy1t4EPOSMcwKG1oEChEWjeOed+yPLF9YmvV9zj2+F/p5xO2I0WnJ6d+u98pRQ9i ZADg== 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:in-reply-to:references:date :message-id:mime-version; bh=SteG6DSAxGWWRjfoustqtSCObhi7b3nOqppZD57aey8=; b=Oo463Uyrs/XGZ4uVc4UgAowEwTyRtW7SkIJbrw8im2Xe21BDqTP1KD7er754U983M0 p53pHJtrELRLFjMk7OHHbHxYWzwyrjvdjXf+Ha78x9ad6fooTJldXlQgKmGvl+lJJ0I4 6R916fvG39hGysAf0OCDQC7imaqVefQyaQUYY4331ZWx2eowG8hgYSuv9r018qLu5Q5G vWjmQJA+alZYjq88Xo1OneE+gzPp5pJBd+5EHZjEbhg136D0nHlTnFK5DMKzlKXOEWon XnNQvhPYxpmoHbtlLSVI3OP4VLD7a2KzkttECkIuUy4ylZEHkGSVqJwpJ9IzydrzxGFX 6dag== X-Gm-Message-State: AOAM532ci2S0cI7GM7bQmIFfeRQnT358tcyz5Uytf2B9pTzEGBbxA5sp 5Hwa37Xnc3bFhf8zGVlI0NVP+v4wUEmj8w== X-Google-Smtp-Source: ABdhPJyo4HGkOBfienQL/J4qz2BfiOyQtaecfFMzqE20Q76EGv7Ea4mhC/OBLCEKJuhjiuDARP/OXA== X-Received: by 2002:a63:4e10:: with SMTP id c16mr2956595pgb.54.1599072810190; Wed, 02 Sep 2020 11:53:30 -0700 (PDT) Received: from ryzen3950 (c-73-71-89-135.hsd1.ca.comcast.net. [73.71.89.135]) by smtp.gmail.com with ESMTPSA id u138sm218579pfc.218.2020.09.02.11.53.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Sep 2020 11:53:28 -0700 (PDT) From: Matt Huszagh To: "emacs-orgmode@gnu.org" Cc: Subject: Re: [PATCH] babel latex headers and image generation commands In-Reply-To: <87zh685bl4.fsf@gmail.com> References: <874kw6ztr9.fsf@gmail.com> <871rrayrsc.fsf@gmail.com> <87y2thylcb.fsf@gmail.com> <87r1z29abl.fsf@gnu.org> <87y2lynft3.fsf@gmail.com> <87zh685bl4.fsf@gmail.com> Date: Wed, 02 Sep 2020 11:53:24 -0700 Message-ID: <87d034qacb.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::441; envelope-from=huszaghmatt@gmail.com; helo=mail-pf1-x441.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-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: , 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=cO2cAwxw; 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: -1.71 X-TUID: U9KPs0nt3G3C --=-=-= Content-Type: text/plain Matt Huszagh writes: > I've added a few changes to the patch that additionally allow custom the > begin and end document environments. The purpose here is to allow latex > code within the document environment that is ignored by the body > export. For instance, I can set the page color with > {\color{some-color}...} and this doesn't mess up latex exports. I've fixed a minor bug with the previous patch. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-ob-latex.el-Make-latex-to-svg-compilation-very-custo.patch >From 1bcd1d28dde6625d0c648c92243260b46433e1eb Mon Sep 17 00:00:00 2001 From: Matt Huszagh Date: Fri, 28 Aug 2020 22:26:05 -0700 Subject: [PATCH] ob-latex.el: Make latex to svg compilation very customizable * lisp/ob-latex.el (org-babel-latex-preamble): Add latex preamble customization. (org-babel-latex-begin-env): Add latex document environment begin customization. (org-babel-latex-end-env): Add latex document environment end customization. (org-babel-latex-pdf-svg-process): Add customization for converting a pdf to svg. (org-babel-execute:latex): Add specific case for svg generation from latex block. --- lisp/ob-latex.el | 57 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/lisp/ob-latex.el b/lisp/ob-latex.el index 4b343dd14..991873e2e 100644 --- a/lisp/ob-latex.el +++ b/lisp/ob-latex.el @@ -70,6 +70,45 @@ :group 'org-babel :type 'string) +(defcustom org-babel-latex-preamble + (lambda (_) + "\\documentclass[preview]{standalone} +\\def\\pgfsysdriver{pgfsys-tex4ht.def} +") + "Closure which evaluates at runtime to the latex preamble. It +takes 1 argument which is the parameters of the source block." + :group 'org-babel + :type 'function) + +(defcustom org-babel-latex-begin-env + (lambda (_) + "\\begin{document}") + "Closure which evaluates at runtime to the begin part of the +document environment. It takes 1 argument which is the +parameters of the source block. This allows adding additional +code that will be ignored when exporting the literal latex +source." + :group 'org-babel + :type 'function) + +(defcustom org-babel-latex-end-env + (lambda (_) + "\\end{document}") + "Closure which evaluates at runtime to the end part of the +document environment. It takes 1 argument which is the +parameters of the source block. This allows adding additional +code that will be ignored when exporting the literal latex +source." + :group 'org-babel + :type 'function) + +(defcustom org-babel-latex-pdf-svg-process + "inkscape --pdf-poppler %f -T -l -o %O" + "Command used to convert a PDF file to an SVG file when +executing a latex source block." + :group 'org-babel + :type 'string) + (defcustom org-babel-latex-htlatex-packages '("[usenames]{color}" "{tikz}" "{color}" "{listings}" "{amsmath}") "Packages to use for htlatex export." @@ -114,12 +153,26 @@ This function is called by `org-babel-execute-src-block'." (mapconcat #'identity headers "\n")))) (org-create-formula-image body out-file org-format-latex-options in-buffer))) + ((string= "svg" extension) + (with-temp-file tex-file + (insert (concat (funcall org-babel-latex-preamble params) + (mapconcat #'identity headers "\n") + (funcall org-babel-latex-begin-env params) + body + (funcall org-babel-latex-end-env params)))) + (let ((tmp-pdf (org-babel-latex-tex-to-pdf tex-file))) + (let* ((log-buf (get-buffer-create "*Org Babel LaTeX Output*")) + (err-msg "org babel latex failed") + (img-out (org-compile-file + tmp-pdf + (list org-babel-latex-pdf-svg-process) + extension err-msg log-buf))) + (shell-command (format "mv %s %s" img-out out-file))))) ((string-suffix-p ".tikz" out-file) (when (file-exists-p out-file) (delete-file out-file)) (with-temp-file out-file (insert body))) - ((and (or (string= "svg" extension) - (string= "html" extension)) + ((and (string= "html" extension) (executable-find org-babel-latex-htlatex)) ;; TODO: this is a very different way of generating the ;; frame latex document than in the pdf case. Ideally, both -- 2.28.0 --=-=-=--