# How can I embed an external image within a tikzpicture environment?

I want to embed an image within a tikzpicture environment. I tried the following,

\begin{tikzpicture}[]
\pgftext{\includegraphics[width=150pt]{pic1.png}} at (0pt,0pt);
\pgftext{\includegraphics[width=150pt]{pic2.png}} at (100pt,0);
\end{tikzpicture}


but both pictures are placed at upper-left corner of image, at the same position. I tried including them inside nodes as well, to no avail.

What am I doing wrong?

-
Try \node (myfirstpic) at (0,0) {\includegraphics{pic1.png}}; – Jubobs May 19 '13 at 15:02
@Jubobs - that worked! Thanks. Seems that in my earlier attempt I tried to nest \includegraphics inside \pgftext. – Rogach May 19 '13 at 15:06
Closely related: tex.stackexchange.com/questions/9559/… – juliohm May 19 '13 at 19:27
– texenthusiast May 19 '13 at 22:03
– Jubobs Aug 17 '13 at 12:29

The prefered way to embed external pictures in a tikzpicture environment is to insert an \includegraphics{...} inside a \node. See the code below for an example.

\documentclass{article}

\usepackage{graphicx}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\node[inner sep=0pt] (russell) at (0,0)
{\includegraphics[width=.25\textwidth]{bertrand_russell.jpg}};

What's the use of the inner sep=0pt option? – nemarona Feb 7 '15 at 15:13
@nemarona Try to use inner sep=10pt (for example) and recompile. inner sep=0pt tells TikZ to make the node's bounding box as tight as possible around the image. – Jubobs Feb 7 '15 at 15:38