3

I want to use custom nodes in TikZ, with shapes loaded (or otherwise converted) from an SVG file because I don't have enough time to learn pgf to draw the shapes I want. How can I do that?

  • 1
    If you turn them into a suitable format, you can use \includegraphics{<file>} inside a \node e.g. \node {\includegraphics{<file>}};. If you just need them as content i.e. pictures. Probably best to convert them to PDF (unless you're using latex via DVI). Of course, the shapes won't be nodes in the sense of having shape-specific handling. If you put an octagon shape in a circular node, the borders of the node will be on the edges of the circle - not the octagon. But you can always place coordinates relative to the images, if necessary, and connect to those etc. – cfr Feb 2 '16 at 3:36
  • No good, because I also want to have text in these nodes (and I don't want to write the text inside the SVG). – JesseTG Feb 2 '16 at 4:21
  • Although very brief, have you had a look the svg.path library from the PGF/TikZ manual (ctan.unsw.edu.au/graphics/pgf/base/doc/pgfmanual.pdf#SVG-Path Library)? By using that, you may be able to declare new shapes (ctan.unsw.edu.au/graphics/pgf/base/doc/pgfmanual.pdf#declaring new shapes). PS: The urls in the parenthesis do contain spaces. This is not a mistake (though I can't seem to get markdown to accept that). – JP-Ellis Feb 2 '16 at 5:58
  • To me seems to more simple to look in manual for available shapes (you already use TikZ) and it from scratch than make all needed transformation from SVG. – Zarko Feb 2 '16 at 6:19
  • @JP-Ellis Who created the site was wrong about putting the spaces in. Anyway, add + or %20 where there's supposed to be a space. (Not sure which one is more indicated in this case.) – Alenanno Feb 2 '16 at 9:43
2

There is an svg2tikz extension for inkscape available from

https://github.com/kjellmf/svg2tikz

I haven't tried it personally so no example here. Jake has an example on site at

https://tex.stackexchange.com/a/245839/1090

  • This doesn't answer the question as far as I can tell because you can't create new node types this way, can you? Or have I misunderstood the question or the extension or both? – cfr Feb 2 '16 at 18:00
  • @cfr not sure really but anyway even if manual editing is required afterwards converting the svg to (any) tikz is perhaps a useful first step. It is currently the only suggested answer, if someone posts a better answer and this proves to be misleading, I'm happy to delete – David Carlisle Feb 2 '16 at 18:44
  • I think this is probably the best answer there is, because I don't think there is a way of doing what the OP wants. As I understand it, defining new kinds of nodes is a bit tricky (which is why pics are so much easier) and I don't think it can be automated in the way that reproducing the shape can be. [I think this may be why the OP says specifically they don't want to learn PGF as opposed to TikZ.] – cfr Feb 2 '16 at 19:38

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.