From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andreas Leha Subject: Re: Embedding diagrams in Org Date: Sat, 21 Feb 2015 11:06:47 +0000 Message-ID: References: <87bnkr8kkg.fsf@wmi.amu.edu.pl> <87d2579uah.fsf@ucl.ac.uk> <86pp96jngi.fsf@example.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:60388) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YP7td-0007GZ-Em for emacs-orgmode@gnu.org; Sat, 21 Feb 2015 06:06:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YP7tY-0005Yy-ET for emacs-orgmode@gnu.org; Sat, 21 Feb 2015 06:06:53 -0500 Received: from plane.gmane.org ([80.91.229.3]:56473) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YP7tY-0005Yn-6x for emacs-orgmode@gnu.org; Sat, 21 Feb 2015 06:06:48 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1YP7tX-0002dB-6s for emacs-orgmode@gnu.org; Sat, 21 Feb 2015 12:06:47 +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 Feb 2015 12:06:47 +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 Feb 2015 12:06:47 +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, Sebastien Vauban writes: > Hello Andreas, > > 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. >> >> This includes a caption for the diagram, and different output formats >> for different export routes. >> >> #+LATEX_HEADER: \usepackage{tikz} >> >> * tikz example >> >> #+name: tikz_example >> #+header: :packages '(("" "tikz")) >> #+header: :file (by-backend (latex "example_diagram.tikz") (html "example_diagram.svg") (t "example_diagram.png")) > > Where is the `by-backend' function defined? > Sorry, I thought the by-backend function was 'common wisdom' by now. It's been proposed by Eric Schulte and there has been a short discussion about including it in org proper. Here it is: --8<---------------cut here---------------start------------->8--- (defmacro by-backend (&rest body) `(case (if (boundp 'backend) (org-export-backend-name backend) nil) ,@body)) --8<---------------cut here---------------end--------------->8--- And I forgot to add: For the SVG export in html you might need to set --8<---------------cut here---------------start------------->8--- (setq org-babel-latex-htlatex "htlatex") --8<---------------cut here---------------end--------------->8--- >> #+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 >> >> #+caption: A tikz example diagram with a caption >> #+results: tikz_example >> [[file:example_diagram.png]] > > What'd be nice is that you could say (in a *file* property) that the > extension for LaTeX always has to be .tikz, for HTML .svg and .png in > all the other cases. I agree. Especially if that setup should be applied to every figure in the document, the header repetitions are tedious. I do not have a solution, I am afraid. > > Then, you could simply give the base name of the figure where > appropriate, in a "DRY" configuration. I'd love to see that, too. Best, Andreas