# inkscape2tikz: exact text positioning

Take the following screenshot from Inkscape:

where the "baseline" of strings Pa and pa are snapped to the black line.

This is the LaTeX output once the graphic is converted with inkscape2tikz:

As you can see, with the 2nd textbox, inkscape2tikz uses the lowest point of the letter 'p' to align the text box, instead of using the actual baseline (the lowest point of the letter 'a').

Is there anyway to correct this behaviour so that texts compiled with TikZ show up exactly where they appear in Inkscape?

Seems like this is a “bug” in inkscape2tikz. I doesn’t creates a node with the right anchor. See https://code.google.com/p/inkscape2tikz/issues/detail?id=22.

If you want to correct this manually, try to add the anchor=base west option to the node in the resulting TikZ code. I could have a closer look if you provide a minimal working example (MWE).

## some notes on nodes

TikZ uses nodes to add text to a picture (and do lot of more stuff which should be outside of this answer’s scope …). The shortes way to add a node is

\node {Text};


This will add “Text” at (0,0), the red point indicates the anchor of the node that is used to align it at a certain point. A node can be part of a path too (as it is in your case, I assume).

\draw (0,0) -- (10,0) node {Text};


will add “Text” at (5,0) aligned with the center of the node. A node can have several options, here above (to put the node above the line), pos (to shift the node somewhere between the startind and ending point of the line):

\draw (0,0) -- (10,0) node [above,pos=0.7] {Text};


will add “Text” above of (3.5,0). As you can see TikZ automatically changes the anchor from the center to the south of the node. The gap between the line and the text is caused by the inner sep of the node, which can be shown by add the draw option.

\draw (0,0) -- (5,0) node [above,pos=0.7,draw=blue] {Text};


You could use inner sep=0pt to make the border as narrow as possible, but the won’t help for texts with descender:

\draw (0,0) -- (5,0) node [above,pos=0.7,draw=blue,inner sep=0pt] {My Text};


In this case the descender defines the y value of the south anchor. To align a node at its baseline TikZ provides the base anchors, which can be used with the anchor option.

\draw (0,0) -- (5,0) node (n) [above,pos=0.7,draw=blue,anchor=base] {My Text};


Note that i omit the above and the inner sep options. There are two more baseline anchors: base west and base east.

\draw (0,0) -- (5,0) node (w) [pos=0.1,anchor=base west,inner sep=0pt] {west}
node (e) [pos=0.9,anchor=base east,inner sep=0pt] {east};


complete example

\documentclass{article}

\usepackage{tikz}

\begin{document}

• Your welcome! I never used such converters because I believe they output “dirty”/cluttered code – but never proofed this … I like building the code my self because I got the full control and in this case I can use all abilities PGF/TikZ provides. I guess Inkscape’s export doesn’t know how to use the pos options and prints the node separately or when it’s preferable to use polar coordinates or when tho use a \foreach or even the intersections library. What I want to say is that the export sure gives usable code but it’s not that flexible as hand written code. – Tobi Aug 11 '13 at 19:27