I did my diligent search for a combination of subfloatrow
, overpic
, and adding arrows for annotation of imported images using tikz
, but couldn't find one. These kind of images are typically found in the biology field, they could be for western blots or gel electrophoresis, etc…The idea is always the same; is to get multiple images annotated with text (courier fits well here), and frequently, with elegant, yet simple, arrows to point at a specific band or spot of interest in the image.
Recommended unless you report a better one!
overpic
: a very nice solution to these kind of text annotationsfloatrow
: AFIK is the best one when it comes to handling subfloats (figures and tables) as well as subcaptions and many other featuresmdframed
: a feature-rich package to control framestikz
: a no-comment-package for drawing arrows and figures (a tikz fan!)
Please AVOID these in your answer
subfig
: obsoletesubfigure
: supported not maintainedsubcaption
: fine, but its manual directs you to the better one, which is the subfloatrow environment offloatrow
for more complex subfloats
What is needed now?
-
adding arrows to at least one these subfigures in the Minimal Working Example (MWE), horizontal ones, left to right and in opposite direction as well. Please provide relative measurements to fine-tune the arrow positioning. Different, elegant arrows of tikz are welcomed, did I forget to mention elegant here?
-
Controlling the space between these images (in this case increasing it)
- Referring to the subfigures in the main figure caption
The code of MWE
\documentclass[12pt]{scrartcl} % KOMA script
\usepackage{courier} % courier font for text annotation
\usepackage[labelsep=period]{caption} % for appearance of captions not placings
\usepackage{subcaption} % incompatible with subfig, or subfigure (obsolete)
\usepackage[demo]{graphicx} % for graphcis, demo to provide image placeholders
\usepackage{xcolor} % colors
\usepackage[framemethod=tikz]{mdframed} % for frames, load xcolor before!
\usepackage{tikz} % drawing arrows and graphics
\usetikzlibrary{arrows} % arrow library for tikz
\usepackage{floatrow} % has the subfloatrow environment for subfloats
\usepackage[percent]{overpic} % for text annotation over imported pictures
\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, innerleftmargin=50pt,innerrightmargin=20pt, innerlinewidth=0pt, middlelinewidth=0pt,outerlinewidth=1pt] % change the innertopmargin for labels
\floatsetup[subfigure]{captionskip=10pt}
\ffigbox { %
\begin{subfloatrow}[3]% number of subfigures are 3, 2 by default
\ffigbox{
\begin{overpic}[grid,tics=15]{image1} % remove the grid, tics argument later on
\put (-30,0) {$ \beta $-actin}
\put(1,67){\rotatebox{90}{\texttt{Lane1: geneA}}}
\put(15,67){\rotatebox{90}{\texttt{Lane2: geneB}}}
\put(30,67){\rotatebox{90}{\texttt{Lane3: geneC}}}
\end{overpic}
}{\subcaption{subcap1}}
\ffigbox{\includegraphics{image2}}{\subcaption{subcap2}} % you can do the same as image 1 with overpic
\ffigbox{\includegraphics{image3}}{\subcaption{subcap3}} % you can do the same as image 1 with overpic
\end{subfloatrow}
}{\caption{A Minimal Working Example}}
\end{mdframed}
\end{figure}
Which gives
Best Answer
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:This produces:
Now, with the help of the grids, we can draw some arrows and place the labels:
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 themdframed
environment. To keep synchronicity, however, thefigure
counter will have to be manually stepped at the beginning (this is not necessary if the caption goes before the object):CTAN lion drawing by Duane Bibby.