33

I want to create a simple figure where images are connected with arrows. Here is what I did:

\begin{tikzpicture}
\node[](A) {\includegraphics[width=0.2\textwidth]{a}};
\node[right=1mm of A](B) {\includegraphics[width=0.2\textwidth]{b}};
\draw[->] (A) to (B);
\end{tikzpicture}

example

But I want the arrow to start and end right at the images with no space between. How can I do that?

4
  • 9
    add every node/.style={inner sep=0,outer sep=0} to the picture options
    – percusse
    Oct 4, 2013 at 10:56
  • @percusse Would you like to write an answer, or is there a duplicate somewhere? Oct 6, 2013 at 15:10
  • @percusse / tauran: Would either of you like to write an answer? I thought I remembered a duplicate for this one but can't find it... Mar 2, 2014 at 4:53
  • And every node/.style={inner xsep=0pt,outer xsep=0pt} for no sep. See Claudio Fiandrino: tex.stackexchange.com/questions/95649/…
    – PatrickT
    Nov 29, 2018 at 19:36

1 Answer 1

51

The extra space is added according to the inner sep and outer sep amounts. If you zero them out the image is tightly packed inside the node thanks to inner sep=0 and moreover the arrows start right from the border thanks to outer sep=0

\documentclass[tikz]{standalone}
\usepackage{mwe} % For dummy images 
\usetikzlibrary{positioning}

\begin{document}

\begin{tikzpicture}[every node/.style={inner sep=0,outer sep=0}]
\node[](A) {\includegraphics[width=0.2\textwidth]{example-image-a}};
\node[right=1cm of A](B) {\includegraphics[width=0.2\textwidth]{example-image-b}};
\draw[->] (A) to (B);
\end{tikzpicture}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .