From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: tikz for multiple targets Date: Thu, 11 Jul 2013 10:07:15 -0600 Message-ID: <87ehb55bcn.fsf@gmail.com> References: <87k3kztlam.fsf@ucl.ac.uk> <87wqoyagmh.fsf@gmx.us> <87obaa65uu.fsf@ucl.ac.uk> <87ehb62lhe.fsf@med.uni-goettingen.de> <878v1d7his.fsf@gmail.com> <878v1ds73o.fsf@med.uni-goettingen.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53658) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UxJR9-0006VJ-1W for emacs-orgmode@gnu.org; Thu, 11 Jul 2013 12:09:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UxJR7-000772-K1 for emacs-orgmode@gnu.org; Thu, 11 Jul 2013 12:09:42 -0400 Received: from mail-pd0-x22c.google.com ([2607:f8b0:400e:c02::22c]:33762) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UxJR7-00076t-Ef for emacs-orgmode@gnu.org; Thu, 11 Jul 2013 12:09:41 -0400 Received: by mail-pd0-f172.google.com with SMTP id z10so7620552pdj.31 for ; Thu, 11 Jul 2013 09:09:40 -0700 (PDT) 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: Andreas Leha Cc: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain > > This is very nice and works well for me. I would very much like to see > that in orgmode. Thanks a lot! > Great, I've just committed this patch. Thanks for your original example which this simply extends. > > How do I extend your example to output latex for latex, svg for html and > png in all other cases? > The attached does this. The catch is that the :imagemagick header argument is required for png (and other) image types to be used. --=-=-= Content-Type: text/x-org Content-Disposition: inline; filename=tikz-pdf-svg.org #+LATEX_HEADER: \usepackage{tikz} First execute the second code block, to define the convenience macro and to set the required new variables in ob-latex.el. Then export to HTML and to pdf to see the tree exported as an SVG image and as embedded tikz respectively. * Tikz test Here's a tree, exported to both html and pdf. #+header: :file (by-backend (html "tree.svg") (pdf 'nil) (t "tree.png")) #+header: :imagemagick #+header: :results (by-backend (pdf "latex") (t "raw")) #+begin_src latex \usetikzlibrary{trees} \begin{tikzpicture} \node [circle, draw, fill=red!20] at (0,0) {1} child { node [circle, draw, fill=blue!30] {2} child { node [circle, draw, fill=green!30] {3} } child { node [circle, draw, fill=yellow!30] {4} }}; \end{tikzpicture} #+end_src #+RESULTS: [[file:tree.png]] * COMMENT setup #+begin_src emacs-lisp :results silent (setq org-babel-latex-htlatex "htlatex") (defmacro by-backend (&rest body) `(case (if (boundp 'backend) (org-export-backend-name backend) nil) ,@body)) #+end_src --=-=-= Content-Type: text/plain Cheers, -- Eric Schulte http://cs.unm.edu/~eschulte --=-=-=--