# Tikz changes included graphics

I'm including PDF images into my tikzpicture environment, and the line widths in the included images are different than in the original PDF (some are thick as they should be, some are thin).

A minimal example would be:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=2.7]
\node (A) at (0,0) {\includegraphics{example1}};
\end{tikzpicture}
\end{document}


How do I make tikzpicture keep the line widths in example1(.pdf)?

-
Did you make sure that it's not just a display-issue of the PDF-reader? Some behave pretty badly with line-width. Try zooming in or printing the file to verify this. Otherwise, it's pretty hard to figure out without the actual file. I don't get different results with a random .pdf. –  dhst Jul 2 '12 at 13:08
That's weird! I've added an image to your question. Is this the same you get? –  Hendrik Vogt Jul 2 '12 at 16:25
@HendrikVogt: I get the same result. Strange indeed! –  Jake Jul 2 '12 at 16:33
your linewidth in the pdf file is not correct. It can be seen when converting the pdf into an uncompressed one, e.g. with pdftk –  Herbert Jul 2 '12 at 16:58
@Herbert: you are perfectly right! In this PDF file, first lines use current linewidth (regardless of its value), then other lines use explicitly 1 unit or 0.5 unit. Add 1 w at the beginning of the stream corrects this error. –  Paul Gaborit Jul 4 '12 at 0:29

As I already wrote in the comment, the pdf has a wrong linewidth setting. You can repair it by setting explicitly the linewidth:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=2.7]
\node (A) at (0,0) {\pdfliteral{ 1 w}\includegraphics{example1}};
\end{tikzpicture}
\end{document}


yields the output:

-

This is not a complete answer but solves the issue:

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}[scale=2.7]
\node (A) at (0,0) [line width=1pt]{\includegraphics{example1.pdf}};
\end{tikzpicture}
\includegraphics{example1}
\end{document}


It seems that tikz regards the badly drawn line as its own and applies the default drawing options on it. So its definitely under the tikz regime while it should not be. I could imagine, that your pdf isnt quite valid (some missing boxes maybe, remember pdf creator on Mac isnt perfect at all) or its just a bug.

-
Your code proves that the first curves of this PDF file use the current value of linewidth instead of choosing their own value. –  Paul Gaborit Jul 4 '12 at 0:35

Finally it seems that it's difficult to use Adobe Illustrator correctly (you need to fix the line width to avoid to use the current line width). So I propose to draw the picture only with TikZ.

Remark : I use a tikzpicture inside a tikzpicture intentionally. If you fix line width =1pt in the first tikzpicture, the current line width in the second one is 0.4pt.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows}
\begin{document}

\newcommand{\midarrow}{\tikz \draw[-stealth'] (0,0) -- +(.1,0);}
\newcommand{\revmidarrow}{\tikz \draw[-stealth' reversed] (0,0) -- +(.1,0);}

\begin{tikzpicture}
\node (A) at (0,0) {%
\begin{tikzpicture}
\begin{scope}[line width = 1pt]
\draw (-120:2) .. controls (-150:0.25) .. (-180:2) node[pos=.8,sloped,scale=2] {\revmidarrow};
\draw (0:2)    .. controls (-30:0.25) ..  (-60:2)  node[pos=.8,sloped,scale=2] {\midarrow};
\draw (120:2)  .. controls (160:.75) and (180:.5) .. (0:0)
.. controls  (0:.5) and (20:.75)  .. (60:2)
node [pos=.8,sloped,scale=2] {\midarrow};
\end{scope}
\end{tikzpicture}
};
\end{tikzpicture}
\end{document}


-

Try this:

First convert image file

pdftoeps -level3 -eps example1.pdf example_1.eps


Second reconvert image file

epstopdf example_1.eps


And try (and compare)

\documentclass{article}
\usepackage{graphicx}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node (A) at (0,0) {\includegraphics[scale=1]{example_1.pdf}};
\end{tikzpicture}
\includegraphics[scale=1]{example1.pdf}
\includegraphics[scale=1]{example_1.pdf}
\end{document}


EDIT: Compare result, works for me TexLive 2012/Fedora 17/Acroread 9.5.1 EDIT2: Now works ...

-
I get the same results as reported above. Not sure what is different here. –  Peter Grill Jul 3 '12 at 5:47
The answer doesn't work. –  Bostjan Jul 3 '12 at 8:27
Opss, I se the problem now, your image (from Mac) it`s the problem (i think) –  Pablo González Jul 3 '12 at 11:19