share
TeX - LaTeXHow can I produce a .svg file from a TikZ diagram?
[+19] [0] Santo D'Agostino
[2012-09-15 01:01:46]
[ tikz-pgf svg ]
[ https://tex.stackexchange.com/questions/71616/how-can-i-produce-a-svg-file-from-a-tikz-diagram ]

I would like to produce separate .svg files for each of the TikZ diagrams in my LaTeX document. Each of the .svg files will then be used in a WordPress web page. I have tried a number of things, none of which have produced good results:

Is there a way to get .svg files directly from LaTeX/TikZ without having to first produce .pdf files? I am guessing that this will work better than having to produce .pdf files first and then have to convert them.

I compile my LaTeX document using MikTeX via WinEdt (pdflatex) on a Windows XP system.

Update: In response to Speravir, here is one of the examples I've been working with:

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}[domain=-2:2,samples=100,scale=1.0,>=latex]
\tikzset{bgrid/.style={help lines,color=blue!10,very thin}}

\draw[bgrid] (-1.5,-3.5) grid (7.5,3.5);

\draw[<->, color=black] (-1.5,0) -- (7.5,0) node[right] {$x$};
\draw[<->, color=black] (0,-3.5) -- (0,3.5) node[above] {$y$};

\foreach \x/\xtext in {-1,1,2,3,4,5,6,7}
\draw (\x cm,1pt) -- (\x cm,-1pt) node[anchor=north] {$\xtext$};

\foreach \y/\ytext in {-3,-2,-1,1,2,3}
\draw (1pt,\y cm) -- (-1pt,\y cm) node[anchor=east] {$\ytext$};

\draw[thick,color=black,domain=0:7.5] plot (\x,{sqrt(\x)}) node[anchor=south] {$y = \sqrt{x}$};
\draw[dashed,color=black,domain=0:7.5] plot (\x,{(-1)*(sqrt(\x))}) node[anchor=north] {$y = -\sqrt{x}$};
\draw[thick,color=black,domain=-1.5:5.5] plot (\x,{(\x)-2}) node[anchor=south] {$y = x - 2$};

\filldraw[black] (4,2) circle(2pt) node[anchor=south east] {$(4, 2)$};
\filldraw[red] (1,-1) circle(2pt);
\draw[red] (1.5,-1) node[anchor=west] {$(1, -1)$};

\end{tikzpicture}
\end{document}
Possible Duplicate: LaTeX: outputting a “tight” svg. Please let us know if this answers your question in which case we can close this as a duplicate. Another very related question: Exporting all equations from a document as individual svg files. - Peter Grill
(3) Possible duplicate: tex.stackexchange.com/q/35145/86 Using tex4ht it is possible to generate SVG directly from TikZ. - Andrew Stacey