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:

  • Convert .pdf files to .png using GIMP (after transporting the .pdf files to my linux system); the resulting image quality is poor, very blurry, but otherwise intact, and all fonts were rendered properly

  • Convert .pdf files to .svg using Inkscape; this is a disaster, as the resulting .svg file has the graph labels mashed together, and some of the labels are pushed on top of axes or graph traces

  • Convert .dvi files to .svg using dvisvgm; this is also a disaster, as the resulting .svg file contains an unrecognizable mess

  • Convert .pdf files to .svg using pdf2svg; this was better, as the graphics were very sharp, but the fonts did not convert well (mathematical symbols were not in italics, square-root symbols were mangled)

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:


\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)$};


Browse other questions tagged or ask your own question.