# Differences

This shows you the differences between two versions of the page.

 — latex:tikz:svg [2013/07/04 08:45] (current) Line 1: Line 1: + ====== Converting images from TikZ to SVG ====== + The route from TikZ to SVG helps to programmatically draw images which can then be given to the boss for further perusal. + ===== the easy way ===== + * generate an image, an small example (balls.tex) is shown below + ​ + \documentclass{minimal} + \usepackage{tikz} + \begin{document} + \centering + \begin{tikzpicture} + \foreach \x/​\y/​\color in {1/​2/​red,​3/​4/​green,​5/​6/​blue} + \shade [ball color=\color] (\x,\y) circle (\x/\y); + \end{tikzpicture} + \end{document} + ​ + + * compile this document to {{:​latex:​tikz:​balls.pdf|balls.pdf}} + * import said pdf into [[http://​www.inkscape.org/​|inkscape]] + * save as {{:​latex:​tikz:​balls.svg|balls.svg}} + * import document.svg into [[http://​www.corel.com/​|CorelDraw]] + * save as {{:​latex:​tikz:​balls.cdr|balls.cdr}},​ send to boss + + ===== the hard way ===== + The hard way actually looks much easier, but in my experience doesn'​t always work, expecially for complicated figures. One advantage is that the resulting .svg-files are much nicer (e.g. shading fully works...) + + * use a special pgfsysdriver in the preamble of the document((taken from [[http://​en.wikipedia.org/​wiki/​File:​Circle_graph.svg|here]],​ which was linked from the PGF-mailing list [if I remember correctly...])) ({{:​latex:​tikz:​balls-htlatex.tex|balls-htlatex.tex}}) + + \documentclass{minimal} + \def\pgfsysdriver{pgfsys-tex4ht.def} + \usepackage{tikz} + \begin{document} + \centering + \begin{tikzpicture} + \foreach \x/​\y/​\color in {1/​2/​red,​3/​4/​green,​5/​6/​blue} + \shade [ball color=\color] (\x,\y) circle (\x/\y); + \end{tikzpicture} + \end{document} + + * if you're using graphics with TikZ (for example for [[scalebar|scale bars]], then also declare the graphics-extension. + + \usepackage{graphicx} + \DeclareGraphicsExtensions{.png} % I prefer .png to .eps... + + * use [[http://​blog.antiblau.de/​2008/​02/​15/​ausgabeprofil-latex-html-fuer-texniccenter/​|htlatex]] to compile this document to html. this generates .svg-files from all included tikz-pictures. + * open resulting {{:​latex:​tikz:​balls-htlatex.svg|}} with coreldraw (which sadly does not always work...) + ​ +