The basic idea is to use TikZ to place the images inside nodes with names; this will give you control over the positioning and will also allow the placement of arrows.
The requirement about cross-referencing can be fulfilled simply by using the \label
, \ref
mechanism.
Some explanations
I decided not to use overpic
at all. The grid and placement of labels can be done entirely through TikZ; in the following example I used Caramdir's and Jake's answers to Drawing on an image with TikZ and defined a \mygrid
command to place a labelled grid on each image; the mandatory argument of \mygrid
is the name of the node used to hold the image:
\documentclass[12pt]{scrartcl}
\usepackage{courier}
\usepackage[labelsep=period]{caption}
\usepackage{subcaption}
\usepackage{graphicx}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning}
\usepackage{floatrow}
\newcommand\mygrid[1]{%
\begin{scope}[x={(#1.south east)},y={(#1.north west)}]
\draw[help lines,xstep=.1,ystep=.1] (0,0) grid (1,1);
\foreach \x in {0,1,...,10} { \node [anchor=north,font=\tiny] at (\x/10,0) {\x}; }
\foreach \y in {0,1,...,10} { \node [anchor=east,font=\tiny] at (0,\y/10) {\y}; }
\end{scope}%
}
\begin{document}
\begin{figure}
\begin{mdframed}[
align=center,
linecolor=black,
fontcolor=black,
backgroundcolor=white,
%userdefinedwidth=0.9\textwidth,
roundcorner=5pt,
skipabove=10pt,
skipbelow=10pt,
leftmargin=0pt,
innertopmargin=100pt,
innerbottommargin=0pt,
innerlinewidth=0pt,
middlelinewidth=0pt,
outerlinewidth=1pt
]
\floatsetup[subfigure]{captionskip=10pt}
\ffigbox{%
\begin{subfloatrow}[3]
\ffigbox{%
\begin{tikzpicture}[remember picture]
\node[anchor=south west,inner sep=0] (image1)
{\includegraphics[width=3.8cm]{ctanlion}};
\mygrid{image1}
\end{tikzpicture}
}%
{\subcaption{subcap1}\label{sfig:a}}%
\ffigbox{%
\begin{tikzpicture}[remember picture]
\node[anchor=south west,inner sep=0] (image2)
{\includegraphics[width=3.8cm]{ctanlion}};
\mygrid{image2}
\end{tikzpicture}
}%
{\subcaption{subcap2}\label{sfig:b}}
\ffigbox{%
\begin{tikzpicture}[remember picture]
\node[anchor=south west,inner sep=0] (image3)
{\includegraphics[width=3.8cm,height=2cm]{ctanlion}};
\mygrid{image3}
\end{tikzpicture}
}%
{\subcaption{subcap3}\label{sfig:c}}
\end{subfloatrow}
}{\caption{A Minimal Working Example with three subfigures:~\ref{sfig:a}, \ref{sfig:b} and~\ref{sfig:c}}}
\end{mdframed}
\end{figure}
\end{document}
This produces:

Now, with the help of the grids, we can draw some arrows and place the labels:
\documentclass[12pt]{scrartcl}
\usepackage{courier}
\usepackage[labelsep=period]{caption}
\usepackage{subcaption}
\usepackage{graphicx}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning}
\usepackage{floatrow}
\newcommand\mygrid[1]{%
\begin{scope}[x={(#1.south east)},y={(#1.north west)}]
\draw[help lines,xstep=.1,ystep=.1] (0,0) grid (1,1);
\foreach \x in {0,1,...,10} { \node [anchor=north,font=\tiny] at (\x/10,0) {\x}; }
\foreach \y in {0,1,...,10} { \node [anchor=east,font=\tiny] at (0,\y/10) {\y}; }
\end{scope}%
}
\begin{document}
\begin{figure}
\begin{mdframed}[
align=center,
linecolor=black,
fontcolor=black,
backgroundcolor=white,
%userdefinedwidth=0.9\textwidth,
roundcorner=5pt,
skipabove=10pt,
skipbelow=10pt,
leftmargin=0pt,
innertopmargin=100pt,
innerbottommargin=0pt,
innerlinewidth=0pt,
middlelinewidth=0pt,
outerlinewidth=1pt
]
\floatsetup[subfigure]{captionskip=10pt}
\ffigbox{%
\begin{subfloatrow}[3]
\ffigbox{%
\begin{tikzpicture}[remember picture]
\node[anchor=south west,inner sep=0] (image1)
{\includegraphics[width=3.8cm]{ctanlion}};
\mygrid{image1}
\end{tikzpicture}
}%
{\subcaption{subcap1}\label{sfig:a}}%
\ffigbox{%
\begin{tikzpicture}[remember picture]
\node[anchor=south west,inner sep=0] (image2)
{\includegraphics[width=3.8cm]{ctanlion}};
\mygrid{image2}
\end{tikzpicture}
}%
{\subcaption{subcap2}\label{sfig:b}}
\ffigbox{%
\begin{tikzpicture}[remember picture]
\node[anchor=south west,inner sep=0] (image3)
{\includegraphics[width=3.8cm,height=2cm]{ctanlion}};
\mygrid{image3}
\end{tikzpicture}
}%
{\subcaption{subcap3}\label{sfig:c}}
\end{subfloatrow}
}{\caption{A Minimal Working Example with three subfigures:~\ref{sfig:a}, \ref{sfig:b} and~\ref{sfig:c}}}
\end{mdframed}
\end{figure}
\begin{tikzpicture}[remember picture,overlay]
% Some arrows
\draw[->,line width=1.5pt,cyan!80!black,dashed]
([yshift=-40pt,xshift=20pt]image2.north) |- +(0,80pt) -|
([yshift=-40pt,xshift=20pt]image3.north);
\draw[->,line width=1.5pt,orange!80!black]
([yshift=-10pt,xshift=20pt]image2.west) |-
([yshift=-10pt,xshift=20pt]image3.west);
\draw[->,line width=1.5pt,red!80!black]
([xshift=20pt]image1.west) |- +(0,70pt) -|
([yshift=20pt,xshift=30pt]image3.west);
\draw[->,line width=1.5pt,green!80!black,dashed]
([yshift=20pt,xshift=-43pt]image1.east) |- +(0,-73pt) -|
([yshift=-15pt,xshift=-15pt]image3.east);
% Some labels
\node[anchor=north west,rotate=90,font=\ttfamily]
at (image1.north west) {Lane1: geneA};
\node[anchor=north west,rotate=90,font=\ttfamily,yshift=-15pt]
at (image1.north west) {Lane2: geneB};
\node[anchor=north west,rotate=90,font=\ttfamily,yshift=-30pt]
at (image1.north west) {Lane3: geneC};\end{tikzpicture}
\end{document}

After commenting out the three \mygrid{...}
lines, one gets:

If the general caption must appear outside the frame, one can leave empty the corresponding argument (in this case, the second argument of the outer \ffigbox
), and then use \RawCaption
outside the mdframed
environment. To keep synchronicity, however, the figure
counter will have to be manually stepped at the beginning (this is not necessary if the caption goes before the object):
\documentclass[12pt]{scrartcl}
\usepackage{courier}
\usepackage[labelsep=period]{caption}
\usepackage{subcaption}
\usepackage{graphicx}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning}
\usepackage{floatrow}
\newcommand\mygrid[1]{%
\begin{scope}[x={(#1.south east)},y={(#1.north west)}]
\draw[help lines,xstep=.1,ystep=.1] (0,0) grid (1,1);
\foreach \x in {0,1,...,10} { \node [inner ysep=0pt,anchor=north,font=\tiny] at (\x/10,0) {\x}; }
\foreach \y in {0,1,...,10} { \node [inner ysep=0pt,anchor=east,font=\tiny] at (0,\y/10) {\y}; }
\end{scope}%
}
\begin{document}
\floatsetup[figure]{style=plain,capposition=bottom}
\begin{figure}
\begin{mdframed}[
align=center,
linecolor=black,
fontcolor=black,
backgroundcolor=white,
%userdefinedwidth=0.9\textwidth,
roundcorner=5pt,
skipabove=10pt,
skipbelow=10pt,
leftmargin=0pt,
innertopmargin=100pt,
innerbottommargin=0pt,
innerlinewidth=0pt,
middlelinewidth=0pt,
outerlinewidth=1pt
]
\floatsetup[subfigure]{captionskip=10pt}
\ffigbox{%
\stepcounter{figure}
\begin{subfloatrow}[3]
\ffigbox{%
\begin{tikzpicture}[remember picture]
\node[anchor=south west,inner sep=0] (image1)
{\includegraphics[width=3.8cm]{ctanlion}};
%\mygrid{image1}
\end{tikzpicture}
}%
{\subcaption{subcap1}\label{sfig:a}}%
\ffigbox{%
\begin{tikzpicture}[remember picture]
\node[anchor=south west,inner sep=0] (image2)
{\includegraphics[width=3.8cm]{ctanlion}};
%\mygrid{image2}
\end{tikzpicture}
}%
{\subcaption{subcap2}\label{sfig:b}}
\ffigbox{%
\begin{tikzpicture}[remember picture]
\node[anchor=south west,inner sep=0] (image3)
{\includegraphics[width=3.8cm,height=2cm]{ctanlion}};
%\mygrid{image3}
\end{tikzpicture}
}%
{\subcaption{subcap3}\label{sfig:c}}
\end{subfloatrow}
}{}% empty second argument; the caption goes outside the frame
\end{mdframed}
\RawCaption{\caption{A Minimal Working Example with three subfigures:~\ref{sfig:a}, \ref{sfig:b} and~\ref{sfig:c}}\label{test}}
\end{figure}
\begin{tikzpicture}[remember picture,overlay]
% Some arrows
\draw[->,line width=1.5pt,cyan!80!black,dashed]
([yshift=-40pt,xshift=20pt]image2.north) |- +(0,80pt) -|
([yshift=-40pt,xshift=20pt]image3.north);
\draw[->,line width=1.5pt,orange!80!black]
([yshift=-10pt,xshift=20pt]image2.west) |-
([yshift=-10pt,xshift=20pt]image3.west);
\draw[->,line width=1.5pt,red!80!black]
([xshift=20pt]image1.west) |- +(0,70pt) -|
([yshift=20pt,xshift=30pt]image3.west);
\draw[->,line width=1.5pt,green!80!black,dashed]
([yshift=20pt,xshift=-43pt]image1.east) |- +(0,-73pt) -|
([yshift=-15pt,xshift=-15pt]image3.east);
% Some labels
\node[anchor=north west,rotate=90,font=\ttfamily]
at (image1.north west) {Lane1: geneA};
\node[anchor=north west,rotate=90,font=\ttfamily,yshift=-15pt]
at (image1.north west) {Lane2: geneB};
\node[anchor=north west,rotate=90,font=\ttfamily,yshift=-30pt]
at (image1.north west) {Lane3: geneC};
\end{tikzpicture}
\end{document}

CTAN lion drawing by Duane Bibby.