From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id KLluEZxmXWK8ggAAbAwnHQ (envelope-from ) for ; Mon, 18 Apr 2022 15:24:44 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id 2HYtEJxmXWIZPQEAauVa8A (envelope-from ) for ; Mon, 18 Apr 2022 15:24:44 +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 A44154019D for ; Mon, 18 Apr 2022 15:24:43 +0200 (CEST) Received: from localhost ([::1]:49712 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ngRMw-0005kI-DT for larch@yhetil.org; Mon, 18 Apr 2022 09:24:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59390) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ngRMJ-0005k4-6d for emacs-orgmode@gnu.org; Mon, 18 Apr 2022 09:24:03 -0400 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]:46845) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ngRMH-0002yg-Fs for emacs-orgmode@gnu.org; Mon, 18 Apr 2022 09:24:02 -0400 Received: by mail-pj1-x1032.google.com with SMTP id h15-20020a17090a054f00b001cb7cd2b11dso14028219pjf.5 for ; Mon, 18 Apr 2022 06:24:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=sfOU1ZPLw0yyJL1xoSMubJX46Xt1IuvB4/7k+f4+1J4=; b=KqZSo9ZKjqyKcIzqrAnKKlRj3yQM/Pwh6Gk/vbDhjDPAiC8+heuDX+ikUhPn7J7ukj tMa5Y32w4IYu496ipY9ieEsvUB8qFtrMGRe0WT3R9P88u1QumK9mnmzCS7WrGZPUlptZ cjCScv4j8+HO7IoHnUFq62lkWi/nWUF/nHfG8n/bPDrxvOEeAbRsp46hMWZGVosGCdzo 2sssLWqERZ2gvbN0ItCtHCmDswcoSBwFMIbhQZ54cCjE9FIg4rPq9//FYlfRazUg7hnA 1glp/4Vv7r4pHGTGqW77hj8hyaCYNRz/lEh3w2eW49T5xxvRoEnYVQyB0WdvSVfcLVgB oocw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=sfOU1ZPLw0yyJL1xoSMubJX46Xt1IuvB4/7k+f4+1J4=; b=ZaNyGzOPQgfAIV5gJIs20D4b+TZXJHsx5lTZcXQQR2yYFC3jIHxV2QQiJiaT3DTh2u O2ykUn+UtMhX/EDYweKw3a80KDZHp3Q7WKB2IU48KeewczBru50DlhsaOyj2vjD4bCkF MZ7YiSzOJZVnCfQd68xhNCaA2l/74wIBzz/QrfkiaNGimJwYOM1UrnPlr+RKfzbSRJXw tHyFNrLKS6g+YNTcCBQ/DxQioJzKQ2K4R/6sqLqZ9R18KVXvY2FBB5W6EkuNWPva4mq/ +9z8BIceA3R8KXEsqYUzzPYifcqOBW2465HwP4xYMB+QYt5qen35gSvDxMj/bOakGet6 /lOA== X-Gm-Message-State: AOAM531nfZzbmaRYHP4qzzwyCNEn/56JDKW7+U08PKlXwC7eHM65TkTG KNfRQ0xre0NnL6BOhfIUkebyBsxJUoQ= X-Google-Smtp-Source: ABdhPJxCC/r5tJImC0ny4HC/TZ2CbwuBOQvagmX0wwyr1XcMVaxsuVgUZfzoLmLVKiEqiGrRvXNfNA== X-Received: by 2002:a17:90b:4ac9:b0:1d2:c13c:7988 with SMTP id mh9-20020a17090b4ac900b001d2c13c7988mr283062pjb.133.1650288239419; Mon, 18 Apr 2022 06:23:59 -0700 (PDT) Received: from paquerette ([2001:861:4284:db70:cd5c:45f2:f190:1f88]) by smtp.gmail.com with ESMTPSA id c18-20020a056a000ad200b004f0f9696578sm14219908pfl.141.2022.04.18.06.23.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Apr 2022 06:23:58 -0700 (PDT) From: Edouard Debry To: Juan Manuel =?utf-8?Q?Mac=C3=ADas?= Subject: Re: latex block tikz to svg References: <86r196motz.fsf@gmail.com> <871r164aia.fsf@posteo.net> Date: Mon, 18 Apr 2022 15:23:51 +0200 In-Reply-To: <871r164aia.fsf@posteo.net> ("Juan Manuel =?utf-8?Q?Mac=C3=AD?= =?utf-8?Q?as=22's?= message of "Mon, 17 Jan 2022 16:01:17 +0000") Message-ID: <86v8v65xug.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (windows-nt) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=edouard.debry@gmail.com; helo=mail-pj1-x1032.google.com 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, T_SCC_BODY_TEXT_LINE=-0.01 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: , Cc: orgmode 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=1650288283; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=sfOU1ZPLw0yyJL1xoSMubJX46Xt1IuvB4/7k+f4+1J4=; b=Kwsncm3kG3TAFyMEKmxouV4OL0DZxI2QETi3hhsr+Ix72D4zW7FYTW3ciVGN+ITbT5P5va 5fOfBvqJlUrB7oCRNP6IhBOPwWO77mRvyF+NKMVJsxlXLRJZ/sk+YNpBaWPkXeUxA6UHS7 B4gmlfvMKACWb+fOvzXGUCOwKQomifOnAr6bB52ePLQrGvFL59MwWpEN9yeFe1w/GWO5Xq /HiW320jUmLd64bPjlXbVaYys+R0zwEtLaHwnGA3E3MYwWkYEmPiYY43f+Gayi/L3jmn/z +Y8J4JuhV/TJHeKJiNhPTbQmDulPzGEkJ5KdEtMl4f9DeEq/YG+evhBAYaJE4w== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1650288283; a=rsa-sha256; cv=none; b=RV782Q78he6xZxvQulXGTLEgsutqazJ5+7gJ5NOcyROchGtcnrQ6bZ9sZu7hGuq3IOkYVN 7kr0mxFbZBAPyr/+bUOhvAlt99Aomgsulg46W8yJnjSyiDbTR1Ph4wvtDzXWdBQ7FgHJ5k k33P1nJn5XFLEm6RKEyY3AKCsiaowwLMj8W1bzB2sxft2ICge0foNdUx1t6xRA7vFAI9H9 azC3S0R32yaR3E6UxnolBmGxorntUP1coT2UG1kv+YZOV4nazjs87cv9lEPW7K/uHLiSKu dYi9p5jnXiLB98xg8mOrskMC5ZFvkba6otzZRQXGzPMRSDSV6ytiOvhvULA5CA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=KqZSo9ZK; 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: -4.04 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=KqZSo9ZK; 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: A44154019D X-Spam-Score: -4.04 X-Migadu-Scanner: scn1.migadu.com X-TUID: Nchtf5kMCoXK Hi, I finally found a way to make the following example work <=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D> #+HEADER: :file test1.svg #+HEADER: :exports results #+HEADER: :results output silent graphics file #+HEADER: :headers '("\\usepackage{tikz}") #+begin_src latex \begin{tikzpicture} \draw[->] (-3,0) -- (-2,0) arc[radius=3D0.5cm,start angle=3D-180,end angle= =3D0] (-1,0) -- (1,0) arc[radius=3D0.5cm,start angle=3D180,end angle=3D0] (= 2,0) -- (3,0); \filldraw (-1.5,0) circle[radius=3D1mm]; \filldraw (1.5,0) circle[radius=3D3mm]; \end{tikzpicture} #+end_src <=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D> In file ob-latex.el, I commented out the lines beginning with ((string=3D "svg" extension) : ;; ((string=3D "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))))) This part is responsible for the previous example to fail. What actually breaks the svg production is the latex preamble. "pdflatex" fails itself to produce a valid pdf file. After that, I changed ((and (string=3D "html" extension) (executable-find org-babel-latex-htlatex)) into ((and (or (string=3D "html" extension) (string=3D "svg" extension)) (executable-find org-babel-latex-htlatex)) Then, previous example, is compiled no more by "pdflatex" but by "htlatex", this latter is able to produce svg directly. I hope I do not introduce any side effects in doing so. There are several w= ays to produce svg : - pdflatex + inkscape (default with current org implementation) - latex + dvisvgm - pdflatex + pdf2svg - htlatex (my choice above) Ideally, all ways could be implemented and orgmode's user should choose which way to use through a header parameter. As far as I could understand, "htlatex" is the faster (direct) and cleaner way to produce svg, but it may lack some advanced features, which is probably why, at the= =20 moment, the default way is through pdf generation. Regards =20=20 Juan Manuel Mac=C3=ADas writes: > Hi Edouard, > > Edouard Debry writes: > >> I would like to find a way to generate svg images from latex src blocks >> (using tikz) which works and is compatible with default orgmode settings >> for latex export (at least does not break it) >> >> Did you experience such issues ? do you have some workings settings and >> examples ? I googled several times "org latex block tikz svg", but it is >> difficult to guess how relevant are the elements found, some of them >> seems quiet outdated. Hence my question on this mailing list > > I've done some quick tests with your example block. I don't know if I'm > wrong, but I think the problem is on line 27 of `org-babel-execute:latex': > > ((string=3D "svg" extension) > > I don't know if this should be considered an Org bug, but it's clear > that if the svg extension is detected in :file, the ':imagemagick yes' > option is ignored, and a type of preamble is generated that fails in > pgfsysdriver when compiling the temp tex document: > > \documentclass[preview]{standalone} > \def\pgfsysdriver{pgfsys-tex4ht.def} > > If I replace the above line with this conditional: > > ((and (string=3D "svg" extension) (not imagemagick)) > > then the imagemagick option is taken into account: it creates correctly > the pdf and then converts it to svg with 'convert' imagemagick program. > I did have to remove this line though: > > #+HEADER: :imoutoptions -geometry 400 :iminoptions -density 600 > > otherwise, the conversion produced a dark image. > > Best regards, > > Juan Manuel=20