Take the following screenshot from Inkscape: enter image description here

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: enter image description here

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};

node on path

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};

node midway on path

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};

node with border

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};

node with descender

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};

node with base anchor

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};

nodes at east and west base

complete example



    \draw (0,0) -- (5,0) node (n) [pos=0.7,draw=blue,anchor=base] {My Text};
    \fill [anch] (n.base) circle;
    \draw (0,-2) -- (5,-2) node (w) [pos=0.1,anchor=base west,inner sep=0pt] {west}
        node (e) [pos=0.9,anchor=base east,inner sep=0pt] {east};
    \fill [anch] (w.base west) circle;
    \fill [anch] (e.base east) circle;
| improve this answer | |
  • Thanks Topi that's very helpful. I decided to use inkscape's built in svg to pdf+tex converter for this project (deadline coming) but your instructions will be helpful once I start learning TikZ. – lyxicon Aug 11 '13 at 18:20
  • 1
    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
  • 1
    PS: The tutorials in the TikZ manual are great to step in … – Tobi Aug 11 '13 at 19:28

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.