[Tex/LaTex] How to draw arrow in figure from one subfloat to another

arrowsfloatssubfloatstikz-arrows

I have a figure that spans two columns in a two column document.

A minimal code example is given below.

\documentclass[twocolumn]{article}
\usepackage{lipsum}

\usepackage{graphicx}
\usepackage{stfloats}
\usepackage{subfig}

\begin{document}

\begin{figure*}[b!]
\centering
\subfloat[Box A]{\label{f_a}\includegraphics[height=3cm]{example-image-a.png}}
\hspace{1pt}
\subfloat[Box B]{\label{f_b}\includegraphics[height=3cm]{example-image-b.png}}
\hspace{1pt}
\subfloat[Box C]{\label{f_c}\includegraphics[height=3cm]{example-image-c.png}}
\label{myfig}
\caption{Three boxes}
\end{figure*}

\lipsum

\end{document}

This produces a figure like enter image description here

I want to draw an arrow from one image to another without affecting the figure numbering or captions.

Desired result. enter image description here

How to achieve the desired result ?

Best Answer

To combine tikz elements with an image, one has to overlay it with a coordinate system. Copied from "Drawing on an image with TikZ":

\begin{tikzpicture}
  \node[anchor=south west,inner sep=0] (image) {\includegraphics{... name of image ...}};
  \begin{scope}[x={(image.south west)},y={(image.north east)}]
    ... tikz code, with (0,0) = south west and (1,1) = north east ...
  \end{scope}
\end{tikzpicture}

To use positions across tikzpictures, one has to use the remember picture option. Moreover, the option overlay is necessary for those elements that connect the images; otherwise they would occupy space and influence the layout. Below is an example with two pictures and a connecting arrow (which I put into a separate picture).

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[remember picture]
  \node[anchor=south west,inner sep=0] (imageA) {\includegraphics[height=2cm]{example-image-a.png}};
  \begin{scope}[x={(imageA.south west)},y={(imageA.north east)}]
    \node[coordinate] (A) at (0.9,0.9) {};
  \end{scope}
\end{tikzpicture}
\begin{tikzpicture}[remember picture]
  \node[anchor=south west,inner sep=0] (imageB) {\includegraphics[height=2cm]{example-image-b.png}};
  \begin{scope}[x={(imageB.south west)},y={(imageB.north east)}]
    \node[coordinate] (B) at (0.3,0.3) {};
  \end{scope}
\end{tikzpicture}
\begin{tikzpicture}[remember picture,overlay]
  \draw[->] (A) -- (B);
\end{tikzpicture}
\end{document}

enter image description here