9

I am to convert an SVG image to TikZ code. I have never done that before thus I have a few questions.
First of all do I need Inkscape or any other program like this? Maybe there is a method using just Python?
Have you ever done that before? Are there any typical errors or problems?

  • Inkscape 0.48 offers export to LaTeX as pstricks code. It works okay-ish. If you want to use it in tikz, you have to fiddle a little bit. (I'm using it as an export path for maps; make all lines between points non-curved, export, remove the pstricks line to clutter, plot using \draw plot file{}. pgf manual section 22.4 helps a bit, but not much: ctan.org/pkg/pgf – Huang_d May 21 '17 at 8:33
  • Thanks! So that means that the only thing that I need is Inkscape 0.48? I think that pstricks will be good too. – Hendrra May 21 '17 at 9:09
  • The newest Inkscape will do, I just know that the functionality is implemented from v0.48 onwards. – Huang_d May 21 '17 at 9:15
  • 1
    You might need a plugin. There is also a command line programme svg2tikz, at least for Unix-ish systems. – cfr May 21 '17 at 19:04
  • 1
    I voted to reopen this because the linked question turned out to concern conversion of a bitmap image. This means that, for example, an answer I was thinking of adding which would address this question, would not address that one .... – cfr May 21 '17 at 19:08
7

Although How to export svg to tikz turned out to involve conversion of a bitmap image, rather than an SVG, parts of the answers there address the question here. In particular, the second stages of those answers, which involve conversion of the traced SVG to TikZ are relevant. That is, you can use Inkscape with the TikZ extension to export .tikz code. The code will not be very good and will be of little use for further editing, but it will work. It will also not be very efficient, but that is not always a pressing concern.

However, installing Inkscape just for this may be overkill. If you already have SVG - that is, your situation is not like that of the OP in How to export svg to tikz, who is starting with a PNG rather than an SVG - then you might prefer other options.

svg2tikz is a command line programme for Unix-ish systems which can convert SVG images to TikZ code, as the the name suggests.

The project is hosted at https://github.com/kjellmf/svg2tikz and based on Python.

If Inkscape is installed, svg2tikz can cooperate with it by using some Inkscape extensions. However, Inkscape is an optional dependency and not a requirement for basic functionality.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.