From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 4Aa3L9AIMGMZCAAAbAwnHQ (envelope-from ) for ; Sun, 25 Sep 2022 09:52:48 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id eJyTL9AIMGOdkAAAauVa8A (envelope-from ) for ; Sun, 25 Sep 2022 09:52:48 +0200 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 1281C232B2 for ; Sun, 25 Sep 2022 09:52:47 +0200 (CEST) Received: from localhost ([::1]:39684 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocMRS-00016W-U9 for larch@yhetil.org; Sun, 25 Sep 2022 03:52:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56218) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocMQH-00014g-0D for emacs-orgmode@gnu.org; Sun, 25 Sep 2022 03:51:34 -0400 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]:41836) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocMQE-0000o7-S8 for emacs-orgmode@gnu.org; Sun, 25 Sep 2022 03:51:32 -0400 Received: by mail-pl1-x629.google.com with SMTP id d11so3697569pll.8 for ; Sun, 25 Sep 2022 00:51:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date; bh=1XNFwfcRy/3/PlDahwF+PHuaLe37rIyndVLhZqaSlsI=; b=qyvlFDBMoDJn0R9N9CGQIlFuIkwJ3gOwhVD6ug+/hhWbX6EQZ9L7PWCP554Scnc9Qo sj7VIULMtB7NkxTXO7wFFgdZUSCCbx/V2rZhhvXOzrPl+7Zq8K3+gvZ64CEjFoCXN5zn NHhxbL5haEhvJKkd3ApPF8EZiwcvk53j+PclARQYrKwhWA4/EG1jDh/sG3jhzS64tqWH 3DMgPKG7hYDZSZPNqb9AlPVDltHQUF5ZhLurLh/9JU4IdTFK37u4JGcuptWzhLKjyniA S2vbg57o3MFcf4cqJYdAo46/Wx0OybZqsHihu6qi8AsPlRma3t8f43XDXeuw8sD2SZSe KAkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date; bh=1XNFwfcRy/3/PlDahwF+PHuaLe37rIyndVLhZqaSlsI=; b=1SDi1NPIwSXsLpGsFtfmrm7oTJz51glJ6w5qYlWPZ7CpuEEX+AOtUzmMFjB8b17cvw nmu8ifLiPDOdUOnD6KhFBqV4DsAkMDUxw+qHxWnaySzaa6CW5a5UaGlxVmVCx22TW3MB qG3XI0JbHvwXXPxPhMbXydTG/0fUbkqJXWzWbX8Ghob1WjYc4bLygd5LLVE1F0F9Etzn Tp/8CRABDyhOhue+X7opuYekEF14FlfD+4h4+Fz0qpEEScJF6bjDo75v+l9zEX+QRXcw JfbnvdcjfGFHzf2hVyUEOggdQXV1WpLrWrHk0jcSuPnNvok1kzPyaiLzTNPZO0E5sgd1 FPRg== X-Gm-Message-State: ACrzQf0iGFhSOWB4jG+eKga8Q0/HuPJ7cvKyAvSrnqIkfjhNnDmW/m+5 Ww7uFRxjdRp2tMBhPC3jLuY= X-Google-Smtp-Source: AMsMyM6uTpFo8/evGRGp3vIK3LnWDi8ble92u93nzNVBVB8ys//ZW/TSiL8P4sp35IH9W5Y0gkEa2g== X-Received: by 2002:a17:90b:4a0b:b0:202:8568:4163 with SMTP id kk11-20020a17090b4a0b00b0020285684163mr30467304pjb.217.1664092289190; Sun, 25 Sep 2022 00:51:29 -0700 (PDT) Received: from localhost ([2409:8970:a80:3a4:8ec6:81ff:fe70:339d]) by smtp.gmail.com with ESMTPSA id oa16-20020a17090b1bd000b001f30b100e04sm4325229pjb.15.2022.09.25.00.51.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 00:51:28 -0700 (PDT) From: Ihor Radchenko To: Akira Kyle Cc: emacs-orgmode@gnu.org, reza@housseini.me Subject: Re: svg file from tikz picture In-Reply-To: <87czbmg6xi.fsf@akirakyle.com> References: <87czbmg6xi.fsf@akirakyle.com> Date: Sun, 25 Sep 2022 15:52:20 +0800 Message-ID: <87o7v3sxfv.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::629; envelope-from=yantar92@gmail.com; helo=mail-pl1-x629.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, 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.29 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-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1664092368; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=1XNFwfcRy/3/PlDahwF+PHuaLe37rIyndVLhZqaSlsI=; b=IReSIZFoQ75Sci+yRuJg4BnFuzyqe7o6Qkio6PHz7eWRnV37ahq1DklhuDeufLcQ42WtPE r7bO6no+O3tnh3jNHSwcLn6BQmvr57Qafi8nyGVTn4oJuml2vc0NHfBdCVy678J5Mk29Qf iSLnZjmWssni2gZCuk2UfnXQHl2YJmq/3u8sFJc2kP8xbD2VEb5+9ABRPEdyVbBwhF93zR XJ69pxtevJ1EF/J/m4SRPwjDaCvO1JGcWt8JXvGHA/mNKcTedbV9YTdRjSRr6GuAvSYhbP werIO8wEXY0bWmYWWdGG8eZ5Ln79O1iIzXKaPMXx74AYrED4xDLximcnYAUfeg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1664092368; a=rsa-sha256; cv=none; b=Y+7ZTmvsyvjEg55ZRp1gnWGY46DsCuYVOcCdejXEHK7bqGGXU0pg2HAalP4QAGqnk/2zUx XPYuA5uRLQaQVQIpnEe5oSvvXvKiPzovro7px9zoXTRy7DE1z1DXcNo3feuAN8hYqN2SqI oo2HyBVEMI2JlrNe4fmYcl8Fi0jNJ33bqyG2pZfyIdBnAbIRs3sIj+t0eHy4ZJDsVKd1fi 82zZm6W2eXfVYU+NSJl4uTiN3BQwXHrnVt2J4alzXO4GljKFIKy8vWjMHvwDzSKTRU1ru8 VAjiSidvWIvf0vR94WYNYF3UCZP1hSB58lYueJBJ1JOORnpEFNUpQ5O6wlz+iA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=qyvlFDBM; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -1.85 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=qyvlFDBM; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 1281C232B2 X-Spam-Score: -1.85 X-Migadu-Scanner: scn1.migadu.com X-TUID: 8YQFONhSW7cH Akira Kyle writes: > I've been using the attached patch for the last few years and I've meaning to send it here/start a discussion about ob-latex.el since I used it pretty much daily to write tikz figures in org mode. So I'm glad to see this discussion has been started! > > I've found it to be incredibly productive to use babel to develop tikz diagrams as I can make come changes and quickly `org-ctrl-c-ctrl-c` to render them in the same buffer. > > I think when I made this patch I had been caught by some of the quirks of the svg export. For example, sometimes I would have some latex equation which I use ~org-latex-preview~ on as I was writing it, but then it would fail to render as mathjax upon html export since I would use some latex package that isn't available under mathjax. So by using ob-latex I could easily fix this by using the ~:file .svg~ header and get a nice html export. However due to the different way of assembling the ~.tex~ file sometimes ~org-latex-preview~ would work but ob-latex wouldn't. I think my use case may be fairly common and so I think ob-latex really should be updated so svg uses the ~org-latex-preview~ code. o Thanks a lot for the patch! I am not very familiar with the code here, but I will try to cross-check things as much as possible as an initial feedback. > Also I think the ~.tikz~ extension doesn't really make any sense since one really can but arbitrary tex code in such a block, and I think that's why I renamed it in my patch. However I'm now realizing that this evaluation method probably doesn't make much since `:tangle` will already do this, with the added benefit of handling noweb references correctly. So perhaps this should be removed and document using tangling in lieu of ~:file *.tikz~? This sounds reasonable, but we must not remove it just yet. Instead, we need to support .tex extension _and_ .tikz extension as backwards compatibility. For .tikz extension we may also display a warning that it is obsolete. > -(defcustom org-babel-latex-htlatex-packages > - '("[usenames]{color}" "{tikz}" "{color}" "{listings}" "{amsmath}") > - "Packages to use for htlatex export." > - :group 'org-babel > - :type '(repeat (string))) Removing this defcustom will be a regression. Maybe we can instead append it to org-latex-packages-alist? Note that {color} and {tikz} are not loaded by default in `org-format-latex-header'. > + (org-format-latex-header > + (concat org-format-latex-header > + (mapconcat #'identity (cdr (assq :headers params)) "\n") > + (if fit "\n\\usepackage[active, tightpage]{preview}\n" "") (concat "a" nil "b") is perfectly acceptable. There is no need to supply empty strings as `concat' arguments. Can simply use (when fit ...) > +(defun org-babel-latex-format-tex (tex-file body) > + "Generate a temporary tex file from execute params." > + (with-temp-file tex-file > + (insert > + (org-latex-make-preamble > + (org-export-get-environment (org-export-get-backend 'latex)) > + org-format-latex-header) > + (concat "\n\\begin{document}\n" body "\n\\end{document}\n")))) I note that `org-export-get-environment' will be ran inside a temporary file. It means that Org buffer LaTeX export settings for the source buffer will not affect the return value. I assume that it is intentional. If so, it is worth adding a comment about it into the code. > > -(defun org-babel-latex-tex-to-pdf (file) > - "Generate a pdf file according to the contents FILE." > - (require 'ox-latex) > - (org-latex-compile file)) > - This is removing a non-private function. Even though this function is nothing but trivial, we still cannot remove it without notice. The function should be moved to org-compat.el and marked obsolete. Finally, please note that we follow certain commit message standards in Org mode. See https://orgmode.org/worg/org-contribute.html#commit-messages -- Ihor Radchenko, Org mode contributor, Learn more about Org mode at https://orgmode.org/. Support Org development at https://liberapay.com/org-mode, or support my work at https://liberapay.com/yantar92