Pictures from Inkscapes pdf+LaTeX export positioned wrong in nodes

Sometimes I use Inkscape to add some graphical elements and text to my pictures. Inkscape allows to export this as pdf+LaTeX, where the pdf contains the picture and all graphical elements and the LaTeX file contains the text.

One can then \input{latex-file-from-inkscape} and the picture appears with superimposed text in the document font.

Internally this uses a picture-environment.

I now tried to put the picture in a tikz node and added a drop shadow. The result is wrong as the picture appears to get indented somehow. I found out that this also happens if a simple \fbox is added.

\documentclass{scrartcl}
\usepackage{tikz}

\begin{document}

\def\svgwidth{.5\textwidth}
\input{drawing.pdf_tex}

\def\svgwidth{.5\textwidth}
\setlength{\fboxsep}{0pt}
\fbox{\input{drawing.pdf_tex}}

\begin{tikzpicture}
\def\svgwidth{.5\textwidth}
inner sep=0,
] at (0,0) {\input{drawing.pdf_tex}};
\end{tikzpicture}

\end{document}


the picture below shows the result 1) just input the file 2) with \fbox 3) with tikz drop shadow

The files are available here: Picture tex file

-

I'm not sure exactly what effect you want but the generated tex file has several missing % at ends of line which cause white space in the output in some circumstances.

This

\noindent\begin{tikzpicture}
\def\svgwidth{.5\textwidth}
inner sep=0,
] at (0,0) {{\let\zzz\begin\def\begin{\unskip\let\begin\zzz\begin}\input{drawing.pdf_tex}}};
\end{tikzpicture}


certainly shifts the picture within the shadow, hope it's closer to what you intend.

Actually there is additional white space you probably need more \unskip but rather than obscure the tex more it seems simpler just to fix the included file. If I restore your MWE to how it was but fix the _tex file I get the image as shown with a shadow just on the right and bottom.

the changes all involve putting % at ends of lines as shown by this diff < lines the original > lines the corrected version.

\$ diff  drawing.pdf_tex1 drawing.pdf_tex2
30c30
<     \errmessage{(Inkscape) Color is used for the text in Inkscape, but the package 'color.sty' is not loaded}
---
>     \errmessage{(Inkscape) Color is used for the text in Inkscape, but the package 'color.sty' is not loaded}%
32c32
<   }
---
>   }%
34c34
<     \errmessage{(Inkscape) Transparency is used (non-zero) for the text in Inkscape, but the package 'transparent.sty' is not loaded}
---
>     \errmessage{(Inkscape) Transparency is used (non-zero) for the text in Inkscape, but the package 'transparent.sty' is not loaded}%
36,37c36,37
<   }
<   \providecommand\rotatebox[2]{#2}
---
>   }%
>   \providecommand\rotatebox[2]{#2}%
39c39
<     \setlength{\unitlength}{360pt}
---
>     \setlength{\unitlength}{360pt}%
41c41
<     \setlength{\unitlength}{\svgwidth}
---
>     \setlength{\unitlength}{\svgwidth}%

-
I thought so too and I did add them manually in the file while experimenting but this does not solve the problem. You would expect to see the drop shadow at the bottom of the picture and to the right but even with your fix it appears to the left of the picture as well. It seems coordiantes get shifted somehow... –  Martin H Nov 9 '12 at 14:54
OK fix for the tex include file posted, and I show the image I now get. –  David Carlisle Nov 9 '12 at 15:18
This seems to be the solution! I only added % in the picture environment but not in the lenght calculation bits. Now it looks correct. I will have a look at the inkscape module or send the author of this modul a mail. –  Martin H Nov 9 '12 at 15:51
picture mode is the one place you don't need the % (although they do no harm) as the picture commands explicitly ignore white space before or after the command. –  David Carlisle Nov 9 '12 at 16:02