Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
\usetikzlibrary{shadows}

\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}
  \node[drop shadow={shadow xshift=.8ex,shadow yshift=-.8ex,opacity=0.5},
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

enter image description here

The files are available here: Picture tex file

share|improve this question

1 Answer 1

up vote 3 down vote accepted

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}
  \node[drop shadow={shadow xshift=.8ex,shadow yshift=-.8ex,opacity=0.5},
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.


enter image description here

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}%
share|improve this answer
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.