, , ,

I admire when somebody perfects their set-up of something they do regularly. When I was writing my thesis I needed to draw a few images and I didn't want to spend whole days of making it in TikZ by hand. For that reason I found out that I can use Inkscape with svg2tikz to draw the diagrams in Inkscape and convert the resulting SVG into a TikZ source. The caveat of this is that if I wanted to have LaTeX formulas in the Inkscape image and svg2tikz script would escape them, making them rendered incorrectly. As a simple fix, I just patched svg2tikz by changing what characters need escaping. All that was needed was to change the definitions

``````SPECIAL_TEX_CHARS = ['\$', '\\', '%', '_', '#', '{', r'}', '^', '&']
SPECIAL_TEX_CHARS_REPLACE = [r'\\$', r'\$\backslash\$', r'\%', r'\_', r'\#', r'\{', r'\}', r'\^{}', r'\&']
``````

to just

``````SPECIAL_TEX_CHARS = ['%', '#', '&']
SPECIAL_TEX_CHARS_REPLACE = [r'\%', r'\_', r'\#', r'\{', r'\}', r'\^{}', r'\&']
``````

This worked beautifully. I added a couple of simple bash scripts to automate the whole process but it wasn't anything fancy. I used this set-up a couple of times when making slides and also in my thesis where I only had 9 images, so why bother perfecting it further? :-)

Today I discovered this fantastic blog post by Gilles Castel, who takes a very similar approach to the next level. He doesn't use svg2tikz but instead uses the internal Inkscape tool that creates a TeX template to be included in the document. But then he creates a really smart collection of Vim, Inkscape and other scripts to make the process of creating SVG images, storing them at the right place, generating the required LaTeX code, and importing it where it's needed really seamless. It is really wonderful and if I ever find myself needing to create dozens of TikZ images, I'll definitely copy a lot from that approach.

I also highly recommend looking at Gilles's other blog posts, where he also explains how he streamlines his other LaTeX and research related tasks. Also, on the topic of TikZ, I also recommend quiver helps with making TikZ diagrams. For converting svg to TikZ there's also pictikz but I haven't tried that one before.

### Responses (?)

JavaScript needs to be enabled to show responses. (Although, it is not necessary for posting them.)