From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andreas Leha Subject: Re: Embedding diagrams in Org Date: Sat, 21 Mar 2015 21:41:30 +0000 Message-ID: References: <87bnkr8kkg.fsf@wmi.amu.edu.pl> <87d2579uah.fsf@ucl.ac.uk> <87egoioaql.fsf@wmi.amu.edu.pl> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:39673) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YZR9V-0003PD-Bg for emacs-orgmode@gnu.org; Sat, 21 Mar 2015 17:41:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YZR9S-0005t0-4I for emacs-orgmode@gnu.org; Sat, 21 Mar 2015 17:41:53 -0400 Received: from plane.gmane.org ([80.91.229.3]:57708) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YZR9R-0005sm-TJ for emacs-orgmode@gnu.org; Sat, 21 Mar 2015 17:41:50 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1YZR9K-0006VB-O5 for emacs-orgmode@gnu.org; Sat, 21 Mar 2015 22:41:42 +0100 Received: from cpc33-cmbg15-2-0-cust4.5-4.cable.virginm.net ([81.102.136.5]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 21 Mar 2015 22:41:42 +0100 Received: from andreas.leha by cpc33-cmbg15-2-0-cust4.5-4.cable.virginm.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 21 Mar 2015 22:41:42 +0100 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Hi Marcin, see some inline comments. Note, that I have not done much research on this and all my information may be outdated.... Marcin Borkowski writes: > On 2015-02-18, at 20:37, Andreas Leha wrote: > >> I also use tikz in my org files. I just include a slightly more >> involved version of Eric's example to show some of the beauty of org. > > OK, so I'm trying to understand it. (One of the reasons is that it > doesn't work for me; somehow I couldn't get the svg export for inclusion > in HTML. OTOH, conversion using pdf2svg does work for me (in LaTeX > files), so I want to learn how to utilize it for Org-mode.) > >> This includes a caption for the diagram, and different output formats >> for different export routes. >> >> Best, >> Andreas >> >> --8<---------------cut here---------------start------------->8--- >> #+LATEX_HEADER: \usepackage{tikz} >> >> * tikz example >> >> #+name: tikz_example >> #+header: :packages '(("" "tikz")) > > What does the above line do exactly? > This will ensure, that the produced latex file for the diagram loads tikz. I could not find that documented, so maybe that should be replaced by ':headers '("\\usepackage{tikz}")'. In my first tests it now seems unnecessary, maybe due to a change in the semantics of LATEX_HEADER when LATEX_HEADER_EXTRA was introduced. So, I guess you can omit that altogether. >> #+header: :file (by-backend (latex "example_diagram.tikz") (html "example_diagram.svg") (t "example_diagram.png")) > > The manual says that after :file I can have a string or a list of two > strings. Does the above mean that it is in fact macroexpanded? The argument of any header option can be replaced by an elisp form (which then in this case should return a string or a list of two strings). > Do > I get it correctly that the (t "example_diagram.png") refers to manual > evaluation and not the evaluation during the export? Yes. I use that to be able to see the diagram within the org document. > >> #+header: :imagemagick yes :iminoptions -density 600 :imoutoptions -geometry 800 >> #+header: :results file raw >> #+header: :fit yes >> #+begin_src latex >> \begin{tikzpicture} >> \node[red!50!black] (a) {A}; >> \node (b) [right of=a] {B}; >> \draw[->] (a) -- (b); >> \end{tikzpicture} >> #+end_src > > And, last but not least: how exactly the magic of tikz -> svg is > supposed to work here? Do I get it correctly that in you example, > Imagemagick handles both png and svg? Yes, imagemagick does both here. And there is a bug in imagemagick up to 6.9 producing corrupt svg [1]. I guess that is hitting you. Try upgrading your imagemagick. > What if I want to use pdf2svg > instead? I do not think that this is possible right now. BUT: You can use htlatex. If you look at worg [2], you'll find an example demonstrating that. It mainly requires setting '(setq org-babel-latex-htlatex "htlatex")'. I think that possibility might make pdf2svg unnecessary. BUT 2: This won't have an effect on the example in this thread. I consider it a bug that the example I gave in this thread tries to run imagemagick for the svg even if that variable is set to "htlatex". I'll file a bug report in a separate thread. > >> #+caption: A tikz example diagram with a caption >> #+results: tikz_example >> [[file:example_diagram.png]] >> --8<---------------cut here---------------end--------------->8--- > > TIA, HTH, Andreas Footnotes: [1] http://www.imagemagick.org/discourse-server/viewtopic.php?t=27009 [2] http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-LaTeX.html#sec-4-3