1

I need to implement some diagrams arrows, like the ones used with the tikz package in a subfigure template (I used subfigure because subfloats give me problems).

So the subfigure template is like the one in this older post subfigure template and the arrows that I would like to insert are just the ones in this other post arrows.

Assuming I would like that for each couple of subfigures there's an arrow in between that link each caption.

EDIT: This is a sample of the code, I do not include the begin document because I had multiple tex files. So where I insert the $\longrightarrow$, instead, I would like an arrow like the one in the post I cited before.

...
\begin{figure}[H]
\begin{center}
    \subfigure[\footnotesize{Mela Golden Delicious}]{
        \label{fig:mela1}
        \includegraphics[width=0.2\textwidth]{example-image}
    }
    \subfigure[\footnotesize{Lime}]{
        \label{fig:lime}
        \includegraphics[width=0.2\textwidth]{example-image}
    }
    \subfigure[\footnotesize{Mango}]{
        \label{fig:mango}
        \includegraphics[width=0.2\textwidth]{example-image}
    }
    $\longrightarrow$
    \subfigure[\footnotesize{Mela Granny Smith}]{
        \label{fig:mela2}
        \includegraphics[width=0.2\textwidth]{example-image}
    }\\
    \subfigure[\footnotesize{Mandarino}]{
        \label{fig:manda}
        \includegraphics[width=0.2\textwidth]{example-image}
    }
    \subfigure[\footnotesize{Pompelmo}]{
        \label{fig:pom}
        \includegraphics[width=0.2\textwidth]{example-image}
    }
    $\longrightarrow$
    \subfigure[\footnotesize{Arancia}]{
        \label{fig:aranc}
        \includegraphics[width=0.2\textwidth]{example-image}
    }\\
    \subfigure[\footnotesize{Succo all'arancia}]{
        \label{fig:succo1}
        \includegraphics[width=0.2\textwidth]{example-image}
    }
    $\longrightarrow$
    \subfigure[\footnotesize{Succo al pompelmo}]{
        \label{fig:succo2}
        \includegraphics[width=0.2\textwidth]{example-image}
    }\\
    \subfigure[\footnotesize{Cetriolo}]{
        \label{fig:cet}
        \includegraphics[width=0.2\textwidth]{example-image}
    }
    $\longrightarrow$
    \subfigure[\footnotesize{Zucchina}]{
        \label{fig:zuc}
        \includegraphics[width=0.2\textwidth]{example-image}
    }
\end{center}
\caption{Example}
\label{fig:subfigures6}
\end{figure}
Simo
  • 41

1 Answers1

1

A solution which first places the \subfloat (using the subfig package, you really shouldn't use subfigure anymore) and places some marks using the tikzmark library. Afterwards it draws the arrows as an overlayed tikzpicture. Everywhere we want to have some white spaces, which is later filled by the arrows, we have to manually introduce that space (using \hspace{1cm} in this example). Additionally I use \adjustimage and its valign=c option to easily place the \tikzmarks approximately on the vertical centre of the pictures.

Also I removed all the white space around the contents of your \subfloats (by placing % at the end of the lines, which removes the space added by a new line in TeX), and spaced them out more evenly by placing a few \hfils.

The \footnotesize isn't necessary for subfig as it by default sets the fontsize of the subfloat captions to \footnotesize.

To get the arrows at the correct position you have to compile at least twice.

\documentclass[]{article}

\usepackage{subfig}
\usepackage{adjustbox}

\usepackage{tikz}
\usetikzlibrary{tikzmark}

\begin{document}
\begin{figure}
  \centering
    \subfloat[Mela Golden Delicious]{%
        \label{fig:mela1}%
        \adjustimage{width=0.2\textwidth,valign=c}{example-image}%
    }\hfil
    \subfloat[Lime]{%
        \label{fig:lime}%
        \adjustimage{width=0.2\textwidth,valign=c}{example-image}%
    }\hfil
    \subfloat[Mango]{%
        \label{fig:mango}%
        \adjustimage{width=0.2\textwidth,valign=c}{example-image}%
        \tikzmark{mangoR}%
    }\hfil\hspace{1cm}%
    \subfloat[Mela Granny Smith]{%
        \label{fig:mela2}%
        \tikzmark{melaL}%
        \adjustimage{width=0.2\textwidth,valign=c}{example-image}%
    }\\
    \subfloat[Mandarino]{%
        \label{fig:manda}%
        \adjustimage{width=0.2\textwidth,valign=c}{example-image}%
    }\hfil
    \subfloat[Pompelmo]{%
        \label{fig:pom}%
        \adjustimage{width=0.2\textwidth,valign=c}{example-image}%
        \tikzmark{pompelmoR}%
    }\hfil\hspace{1cm}%
    \subfloat[Arancia]{%
        \label{fig:aranc}%
        \tikzmark{aranciaL}%
        \adjustimage{width=0.2\textwidth,valign=c}{example-image}%
    }\\
    \subfloat[Succo all'arancia]{%
        \label{fig:succo1}%
        \adjustimage{width=0.2\textwidth,valign=c}{example-image}%
        \tikzmark{succoarR}%
    }\hspace{1cm}%
    \subfloat[Succo al pompelmo]{%
        \label{fig:succo2}%
        \tikzmark{succopoL}%
        \adjustimage{width=0.2\textwidth,valign=c}{example-image}%
    }\\
    \subfloat[Cetriolo]{%
        \label{fig:cet}%
        \adjustimage{width=0.2\textwidth,valign=c}{example-image}%
        \tikzmark{cetrioloR}%
    }\hspace{1cm}%
    \subfloat[Zucchina]{%
        \label{fig:zuc}%
        \tikzmark{zuccinaL}%
        \adjustimage{width=0.2\textwidth,valign=c}{example-image}%
    }
  \begin{tikzpicture}[remember picture, overlay, >=latex]
    \foreach\x/\y in
      {mangoR/melaL, pompelmoR/aranciaL, succoarR/succopoL, cetrioloR/zuccinaL}
      \draw[->] (pic cs:\x) -- (pic cs:\y);
  \end{tikzpicture}
\caption{Example}
\label{fig:subfloats6}
\end{figure}
\end{document}

enter image description here

Skillmon
  • 60,462