From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id iG0mDHQbJWRHSwEASxT56A (envelope-from ) for ; Thu, 30 Mar 2023 07:17:40 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id EOYqDHQbJWRTGgAA9RJhRA (envelope-from ) for ; Thu, 30 Mar 2023 07:17:40 +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 A005525F1 for ; Thu, 30 Mar 2023 07:17:39 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1phkeU-0004hJ-SK; Thu, 30 Mar 2023 01:16:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1phkeR-0004gk-MP for emacs-orgmode@gnu.org; Thu, 30 Mar 2023 01:16:44 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1phkeO-0005TO-QH for emacs-orgmode@gnu.org; Thu, 30 Mar 2023 01:16:43 -0400 Received: by mail-wm1-x32e.google.com with SMTP id d11-20020a05600c3acb00b003ef6e6754c5so7232712wms.5 for ; Wed, 29 Mar 2023 22:16:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680153398; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=HfStEyBycYo/j3Orog5cBOQTURc53nXI+ETPQXYEELY=; b=c7MnkkKrgXV8umjLNlFHBvo8b5qkw2eJqxrVToAqW1wc/xU5wFyJlvw8JZjJvBwe1V 0ctFi1iconRRqIK5BZwgh28wCV9i0DNkc4Gh2NCe8YGidHHBeUiixP09SeFQcnWMcYzz 8RMR6pOy4Y1QrOt6YS7Fc8OsDrp0w0jRbuCgwEr9tD91A2pdzkkTA8UKJmIYhbN56QuX kKblLqB8/m4ggZybgv7Dw7lWi42FrGZ3k7tog8zjIlF0gPOAP9u8dwpFjwqBmdCuFI1w Fn7d74PfNbPoeRP2vw6K14pFM8aCD1vL8J2E4S+iYuuyeWS2IY3kJoNlIQSDi7FPCs72 ozRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680153398; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HfStEyBycYo/j3Orog5cBOQTURc53nXI+ETPQXYEELY=; b=En5hibGLq1GntWhEZ3lQyu4UY3ENhiP9q2/zj7Tj7gtBhdTVYHH8YnQVsQ3CyfCBdp 6mhBQct707Uo52ivCozSABHSXVdSGGrFlzMnoLPEP/QnY55jVQRIrvbzjeONoaAu6+1A Pu12PHIAJTP56e8AAZoW4SGsbNk3k4Y2z1twwgNvQiy2dc+Ar38XlAtdYQeDcUcVD3Wb omjtDfeSaqB5D69kY1rfPwxjjBUI2fMdOlD2OrdSXQqcTZC3uly8Hix0Hn7EezSN+LNE hgMsc2MDzql6PCjIGPGdS+DSFF9vUXb1+kU5/xNvwmGWmwh8NeGRw5eiIc5oDQGvHkQe 8xPA== X-Gm-Message-State: AAQBX9dBxNsyNMg7bKDRVd7HAQHxKdd4d/4GjcFyqre6cWjttarvaZZU RvyYDedNO7GeV4Qd287D2J+gX/PkNc4= X-Google-Smtp-Source: AKy350aRbXo/eTZKWrhF8RK9yGfxDyKhsW3oZiN1CP6w6QAsR94vKF7M/2fh7qKb+ijoBMihMu/01Q== X-Received: by 2002:a7b:c8c5:0:b0:3ef:62cd:1ef with SMTP id f5-20020a7bc8c5000000b003ef62cd01efmr12690872wml.25.1680153398513; Wed, 29 Mar 2023 22:16:38 -0700 (PDT) Received: from pluto.localnet (aaubervilliers-157-1-6-252.w83-200.abo.wanadoo.fr. [83.200.45.252]) by smtp.gmail.com with ESMTPSA id x19-20020a1c7c13000000b003ed1f111fdesm4355706wmc.20.2023.03.29.22.16.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Mar 2023 22:16:37 -0700 (PDT) From: chris To: emacs-orgmode@gnu.org Subject: Re: File generation from LaTeX src fails due to temporary PDF in wrong directory Date: Thu, 30 Mar 2023 07:16:35 +0200 Message-ID: <45437000.fMDQidcC6G@pluto> In-Reply-To: <871ql7s1ig.fsf@christianmoe.com> References: <2409256.jE0xQCEvom@pluto> <871ql7s1ig.fsf@christianmoe.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=inkbottle007@gmail.com; helo=mail-wm1-x32e.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-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Seal: i=1; s=key1; d=yhetil.org; t=1680153459; a=rsa-sha256; cv=none; b=EminsFdhkV/eSle8JrIJJygnO3tamVChEbLNtTq1A/WzEIf+VnNBHcurcDRLbvIXH1477C rtaXbHOGyUGT6QDtvb7oEjmt6ZDJ1S9hUuMjZ3u2SmXRnnzSi0i2C2ExKOQ7f8Bj2Kv1OU Brpzql00LFC5k5B7Bb3gYnrfxDp2SuEI+yYgnHgL8wjoD5z5wza7OVgqkf4LsCPONeuszw 0qrLHEzdZUNRYOUShe6lJC5B9U4k+Pl2sztv4xiTFleK0Q6zoR5ylj7appl7v73X95oI/L cics0/7NA2FZ3AufenGnqO0QCtu8Eocb65+WB16knRbt7jc+zQinx/c/qVKeDQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=c7MnkkKr; 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" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1680153459; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=HfStEyBycYo/j3Orog5cBOQTURc53nXI+ETPQXYEELY=; b=lGU2naBZJ3vaUL+g65DoT//kZSkXTyRsvOo8FJ5xwuHBFr9ARIiU7oqdwF2PCq+z0Mozom wVirC25/5xgF/oaRKAzAULCl3ufFl7CSSrfFCjP/BZ9mPcQ+A4QY2oT0IQh5ZbY7zDBkt8 G23bBurz7Yi6zwQ+UhExvpvaZ5VFFs36Q0sXtViUgxDDv9QKVK/BheG9EtIcjF6CdW6Fl5 m30nTkKwrr+P5DpzTt/ghyRYbIU/x6p6vuLpBETsgdFVUi4QDFO5W4MLT+aaTvkec/Ov4J IaEepCcrWAxkC3a4r9oqhXJOAqtrsHQ7X+8PmoDQPhtZLbReDTI3tr+6n2qQqg== X-Migadu-Spam-Score: -5.85 X-Spam-Score: -5.85 X-Migadu-Queue-Id: A005525F1 X-Migadu-Scanner: scn0.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=c7MnkkKr; 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-TUID: m5p9QQCCksLx On Wednesday, 29 March 2023 23:15:03 CEST Christian Moe wrote: >=20 > Hi, >=20 > Pardon the noise: It turned out to be a pretty obvious problem with my > setup that has now been resolved. >=20 > I had modified org-latex-pdf-process to use xelatex, and for some reason > my setup lacked the =3D-output-directory %o=3D switch. I should probably > have thought of that first, but the omission has had no ill effects on > ordinary PDF export, so I didn't run into any problem before trying to > use Babel with LaTeX. >=20 > Ihor and Pedro, thanks for checking. >=20 > Chris, I don't know why your attempts fail, but I'll be trying similar > things over the next days, so maybe I'll come back to you. >=20 =46or one thing I don't understand 90% of the options, that can explain a l= ot. Another point, the gibberish output I was speaking about are "similar" thos= e=20 of [[https://emacs.stackexchange.com/questions/68823/minimal-working-example-o= f-tikz-to-svg-in-orgmode]] Actually the svg image they get is an image containing the `tikz` instructi= ons=20 transformed as image. What I get is the svg instructions that should genera= te=20 the image: an image showing a `svg` listing. Anyway You start from that: #+begin_src emacs-lisp (setq org-latex-compiler "lualatex") #+end_src #+name: circle #+header: :results file drawer #+header: :file circle.svg #+header: :dvisvgm yes #+header: :headers '("\\usepackage{tikz}") #+begin_src latex \begin{tikzpicture} \fill[yellow] (0,0) circle (3cm); \end{tikzpicture} #+end_src You do C-c C-c on both blocks. Looking at *Messages* you see there is a file ``` cat /tmp/babel-DQ59bY/latex-2whyWA.tex \documentclass[preview]{standalone}=20 \def\pgfsysdriver{pgfsys-tex4ht.def}=20 \usepackage{tikz}\begin{document}\begin{tikzpicture}=20 \fill[yellow] (0,0) circle (3cm);=20 \end{tikzpicture}\end{document} ``` Among `latex`, `pdflatex`, `lualatex`, `htlatex`, the latex file can only b= e=20 successfully processed by `htlatex`, which will produces several outputs: ``` ls *2whyWA*=20 latex-2whyWA-1.svg latex-2whyWA.4tc latex-2whyWA.css latex-2whyWA.html = =20 latex-2whyWA.lg latex-2whyWA.tmp=20 latex-2whyWA.4ct latex-2whyWA.aux latex-2whyWA.dvi latex-2whyWA.idv = =20 latex-2whyWA.log latex-2whyWA.xref ``` One of them is `svg` file and is correct. I've tried replacing `(setq org-latex-compiler "lualatex")` by every possib= le=20 latex compiler listed above. I've also tried replacing `#+header: :dvisvgm yes` by `htlatex` and=20 `inkscape`. In every case I get the gibberish output, specifically an image of the list= ing=20 of the svg output, or in any case something resembling to `XML`. Something else I can do "by hand": ``` lualatex -jobname=3Dfoo <(sed '/pgfsysdriver/d' /tmp/babel-DQ59bY/ latex-2whyWA.tex); dvisvgm --pdf --output=3Dfoo.svg foo.pdf ``` then: ``` $ cat foo.svg=20 =20 =20 =20 =20 =20 =20 =20 =20 =20 $ cat latex-2whyWA-1.svg =20 =20 =20 =20 =20 =20 =20 =20 =20 =20 =20 =20 =20 =20 =20 ``` I got that last trick from [[https://en.wikipedia.org/wiki/ Wikipedia:Graphics_Lab/Resources/PDF_conversion_to_SVG]] We can see both files have the exact same size, `foo.svg` is 548 bytes,=20 `latex-2whyWA-1.svg` is 855 bytes. `foo.svg` is superior in that it uses `utf-8` encoding, which is superior. bitmaps outputs for `tikz` are not nice. So two ways to do it by hand, and it would be nice to have it doing it=20 automatically. Wikipedia says `inkscape` method can yield heavy results, and indeed I had = to=20 install `potrace`. They say in the stackexchange page that `pdflatex+inkscape` is the default= =20 method, so even it didn't work at all, I followed the instruction it gave m= e=20 to first install `inkscape` and then install `potrace`. What I like best is: ``` lualatex -jobname=3Dfoo <(sed '/pgfsysdriver/d' /tmp/babel-DQ59bY/ latex-2whyWA.tex); dvisvgm --pdf --output=3Dfoo.svg foo.pdf ``` It would be easier if second line `\def\pgfsysdriver{pgfsys-tex4ht.def}` wa= s=20 not inserted in the first place. I think the way plain `org-latex-preview`, which work for me, are generated= is=20 through `latex + dvisvgm` and I think that in this case the above=20 `\def\pgfsysdriver{pgfsys-tex4ht.def}` isn't used neither. Using "old" `latex` can be troublesome in some cases though, namely everyti= me=20 somebody is trying to use some `utf-8`. Best, Chris > Yours, > Christian >=20 >=20 > chris writes: >=20 > > On Wednesday, 29 March 2023 10:00:35 CEST Pedro Andres Aranda Gutierrez= =20 wrote: > >> On Tue, 28 Mar 2023 10:04:24 +0200, Christian Moe =20 wrote > >> Hi, > >> > >> > I'm trying and failing to export images from TikZ code, apparently > >> > because the temporary PDF is misplaced. Here is a minimal example ju= st > >> > exporting the PDF: > >> > >> > #+LATEX_HEADER: \usepackage{tikz} > >> > > >> > #+header: :fit yes > >> > #+begin_src latex :exports results :file ./test-tikz-triangle.png > >> > \begin{tikzpicture} % > >> > \draw[draw=3Dblack, fill=3Dblue!10] (0,4) -- (3,0) -- (-3,0) -- cycl= e; > >> > \end{tikzpicture} > >> > #+end_src > >> > >> > Execution fails with an error message like this: > >> > > >> > org-compile-file: File "/tmp/babel-Tay2kl/latex-IJVI84.pdf" wasn=E2= =80=99t > >> > produced. See "*Org PDF LaTeX Output*" for details > >> > >> Hi Christian, > >> trying to reproduce this on a master (emacs30.0.50) on Ubuntu. To make= it=20 really > >> lightweight, I'm starting with > >> emacs -Q > >> but unfortunately, I'm not able to reproduce it here :( > > > > Hi, I've been trying to have a similar example working for hours,=20 specifically I was trying to follow https://orgmode.org/worg/org-contrib/ba= bel/ languages/ob-doc-LaTeX.html[1] > > > > Could you provide more context because if I run emacs -Q here, with the= =20 example provided by OP, and type C-c C-c, I just get "no org-babel execute= =20 function for latex!". > > So I guess it might have required a little more work than what I've jus= t=20 described. > > > > Here is the setting I've used: > > > > This in my dot-emacs.org file: > > #+begin_src emacs-lisp > > (with-eval-after-load 'org > > (add-to-list 'org-latex-packages-alist '("" "stmaryrd" t)) > > (add-to-list 'org-latex-packages-alist '("" "tikz-cd" t)) > > (add-to-list 'org-latex-packages-alist '("" "amscd" t)) > > (add-to-list 'org-latex-packages-alist '("" "mathtools" t)) > > (add-to-list 'org-latex-packages-alist '("" "unicode-math" t)) > > ;; (add-to-list 'org-latex-packages-alist '("" "breqn" t)) > > (add-to-list 'org-latex-packages-alist '("" "thisisastupidtestfil= e"=20 t)) > > (setq org-latex-create-formula-image-program 'dvisvgm) ;; probabl= y=20 only this line is relevant with the matter at hand > > (setq org-format-latex-options > > (plist-put org-format-latex-options :scale 0.80))) > > #+end_src > > > > With this, when I put the following in some org file and type C-c C-x C= =2Dl I=20 immediately get a org-latex-preview of the tikz snippet: > > \begin{tikzpicture} % > > \draw[->] (-3,0) -- (-2,0) arc[radius=3D0.5cm,start angle=3D-180,end= =20 angle=3D0] > > (-1,0) -- (1,0) arc[radius=3D0.5cm,start angle=3D180,end angle=3D0] (= 2,0) --=20 (3,0); > > \filldraw (-1.5,0) circle[radius=3D1mm]; > > \filldraw (1.5,0) circle[radius=3D1mm]; > > \end{tikzpicture} > > > > Now If I use the following and type C-c C-c, I never get anything in=20 multiple ways: > > Note that I've also tried with imagemagick... > > #+name: test_plot_png > > #+header: :exports results :file test.svg > > #+header: :dvisvgm yes > > #+header: :fit yes :noweb yes :headers '("\\usepackage{tikz}") > > #+begin_src latex :file test.svg > > \begin{tikzpicture} % > > \draw[->] (-3,0) -- (-2,0) arc[radius=3D0.5cm,start angle=3D-180,en= d=20 angle=3D0] > > (-1,0) -- (1,0) arc[radius=3D0.5cm,start angle=3D180,end angle=3D0]= (2,0) --=20 (3,0); > > \filldraw (-1.5,0) circle[radius=3D1mm]; > > \filldraw (1.5,0) circle[radius=3D1mm]; > > \end{tikzpicture} > > #+end_src > > > > Many times a pdf is generated in the /tmp/ directory but that pdf is=20 gibberish. When I go from the latex file to the pdf using pdflatex, only=20 gibberish pdf is generated, no relation with the image that should be=20 generated. > > If instead I use lualatex, the pdf is correctly generated. > > Anyway, I've been experimenting for hours, and I have no idea how to ha= ve=20 the thing working. > > > > I also used that code someone gave me: > > #+begin_src emacs-lisp > > (set-variable 'org-preview-latex-process-alist > > '((dvipng :programs ; Was here originally. > > ("latex" "dvipng") > > :description "dvi > png" :message "you ne= ed=20 to install the programs: latex and dvipng." :image-input-type "dvi" :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")) > > (dvisvgm :programs ; Was here originally. > > ("latex" "dvisvgm") > > :description "dvi > svg" :message "you n= eed=20 to install the programs: latex and dvisvgm." :image-input-type "dvi" :image- output-type "svg" :image-size-adjust > > (1.7 . 1.5) > > :latex-compiler > > ("latex -interaction nonstopmode -output- directory %o %f") > > :image-converter > > ("dvisvgm %f -n -b min -c %S -o %O")) > > (imagemagick :programs ; The recommended "new" wa= y. > > ("latex" "convert") > > :description "pdf > png" :message "y= ou=20 need to install the programs: latex and imagemagick." :image-input-type "pd= f"=20 :image-output-type "png" :image-size-adjust > > (1.0 . 1.0) > > :latex-compiler > > ("lualatex -interaction nonstopmode - output-directory %o %f") > > :image-converter > > ("convert -density %D -trim -antiali= as=20 %f -quality 100 %O")))) > > #+end_src > > > > No luck at all there neither. > > > > BTW, when I do C-c C-c on the OP example, after having evaluated > > #+begin_src emacs-lisp > > (org-babel-do-load-languages > > 'org-babel-load-languages > > '((latex . t))) > > #+end_src > > > > No pdf, no output, only an empty latex file generated in /tmp > > > > > > Bottom line, I'd really like to know how this hole thing is supposed to= =20 work. > > org-preview latex working perfectly fine though. > > > > Note: The reason I want to have this working is that I want to export t= o=20 html. Plain latex formula are displayed very very well using mathjax. But T= iKz=20 things are not working. > > So even though I've got a near wysiwyg in emacs, I can't have that=20 exported to html. > > What I'd like to have is plain latex formulas exported to mathjax and t= ikz=20 diagrams exported using the SVG image. > > Initially my setting wasn't even using imagemagick, only dvisvgm. > > > > Also it seems we have three ways to do the exact same thing: > > org-latex-preview which works perfectly with minimal effort on my box, > > the C-c C-c thing, > > and the org-html-export-to-html thing. > > Each using independent workflow. Though probably not completely indepen= dent=20 though. > > > > My emacs is master from a month ago. > > > > Cheers, > > Chris > > > > > > > >> > >> My emacs: > >> > >> GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, > >> cairo version 1.16.0) of 2023-03-26 > >> > >> Would you please try again, calling with emacs -Q and giving a couple > >> clues more of your process to confirm... It may be that I'm too modern > >> ;-) > >> > >> Thx, /Pedro A. > >> > >> > > > > > > > > -------- > > [1] https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-LaTeX.h= tml >=20