emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: chris <inkbottle007@gmail.com>
To: Org Mode List <emacs-orgmode@gnu.org>
Subject: Re: File generation from LaTeX src fails due to temporary PDF in wrong directory
Date: Wed, 29 Mar 2023 19:31:52 +0200	[thread overview]
Message-ID: <2409256.jE0xQCEvom@pluto> (raw)
In-Reply-To: <CAO48Bk_XynFrk_SNAScXxUrS9FFw+sCBEpq40STN0ad8biVrGg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 7403 bytes --]

On Wednesday, 29 March 2023 10:00:35 CEST Pedro Andres Aranda Gutierrez wrote:
> On Tue, 28 Mar 2023 10:04:24 +0200, Christian Moe <mail@christianmoe.com> 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 just
> > exporting the PDF:
> 
> > #+LATEX_HEADER: \usepackage{tikz}
> >
> > #+header: :fit yes
> > #+begin_src latex :exports results :file ./test-tikz-triangle.png
> > \begin{tikzpicture}             %
> > \draw[draw=black, fill=blue!10] (0,4) -- (3,0) -- (-3,0) -- cycle;
> > \end{tikzpicture}
> > #+end_src
> 
> > Execution fails with an error message like this:
> >
> > org-compile-file: File "/tmp/babel-Tay2kl/latex-IJVI84.pdf" wasn’t
> > 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 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, specifically I was trying to follow https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-LaTeX.html[1]

Could you provide more context because if I run emacs -Q here, with the example provided by OP, and type C-c C-c, I just get "no org-babel execute function for latex!".
So I guess it might have required a little more work than what I've just 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 '("" "thisisastupidtestfile" t))
      (setq org-latex-create-formula-image-program 'dvisvgm) ;; probably 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-l I immediately get a org-latex-preview of the tikz snippet:
\begin{tikzpicture}             %
  \draw[->] (-3,0) -- (-2,0) arc[radius=0.5cm,start angle=-180,end angle=0]   
  (-1,0) -- (1,0) arc[radius=0.5cm,start angle=180,end angle=0] (2,0) -- (3,0);
  \filldraw (-1.5,0) circle[radius=1mm];
  \filldraw (1.5,0) circle[radius=1mm];
\end{tikzpicture}

Now If I use the following and type C-c C-c, I never get anything in 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=0.5cm,start angle=-180,end angle=0]   
    (-1,0) -- (1,0) arc[radius=0.5cm,start angle=180,end angle=0] (2,0) -- (3,0);
    \filldraw (-1.5,0) circle[radius=1mm];
    \filldraw (1.5,0) circle[radius=1mm];
  \end{tikzpicture}
#+end_src

Many times a pdf is generated in the /tmp/ directory but that pdf is gibberish. When I go from the latex file to the pdf using pdflatex, only gibberish pdf is generated, no relation with the image that should be 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 have 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 need 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 need 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" way.
                                   ("latex" "convert")
                                   :description "pdf > png" :message "you need to install the programs: latex and imagemagick." :image-input-type "pdf" :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 -antialias %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 work.
org-preview latex working perfectly fine though.

Note: The reason I want to have this working is that I want to export to html. Plain latex formula are displayed very very well using mathjax. But TiKz things are not working.
So even though I've got a near wysiwyg in emacs, I can't have that exported to html.
What I'd like to have is plain latex formulas exported to mathjax and tikz 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 independent 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.html

[-- Attachment #2: Type: text/html, Size: 22157 bytes --]

  reply	other threads:[~2023-03-29 17:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-29  8:00 File generation from LaTeX src fails due to temporary PDF in wrong directory Pedro Andres Aranda Gutierrez
2023-03-29 17:31 ` chris [this message]
2023-03-29 21:15   ` Christian Moe
2023-03-30  5:16     ` chris
2023-03-30 11:15       ` Christian Moe
2023-03-31  5:25         ` chris
2023-03-31  7:36           ` Christian Moe
  -- strict thread matches above, loose matches on Subject: below --
2023-03-28  8:04 Christian Moe
2023-03-28 10:14 ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2409256.jE0xQCEvom@pluto \
    --to=inkbottle007@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).