Thanks to everyone, I now have this working. Here is the final version. --8<---------------cut here---------------start------------->8--- #+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") (latex "tree.tikz") (t "tree.png")) #+header: :imagemagick yes :iminoptions -density 600 :imoutoptions -geometry 800 #+header: :results file raw #+header: :fit yes #+header: :headers '("\\usepackage{tikz}") #+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 org-export-current-backend ,@body)) #+end_src --8<---------------cut here---------------end--------------->8--- The header line that says to use the package tikz right before the source block is only necessary to generate the png when evaluating the block (“C-c C-c” on it), but as it does not prevent the export to work, I leave it there. I had to change my systems pgfsys-tex4ht.def as described in http://tex.stackexchange.com/questions/185349/error-using-pgfsysdriver-with-tex4ht-only-shows-up-with-texlive-2014-ok-with-t/232739#232739 (having a local copy and modifying it as suggested on the site did not work). Thanks again, Alan -- OpenPGP Key ID : 040D0A3B4ED2E5C7 Last week athmospheric CO₂ average (Updated August 31, 2015, Mauna Loa Obs.): 377.82 ppm