2

I should put in sequence a series of images and connect with arrows. This is what I managed to do: enter image description here

using this code:

\begin{figure}[!htbp]
\centering
\subfloat{
\begin{forest}
    [\textbf{\(\textbf{P}\sb{id1}\)}
        [\(\textbf{\#text}\sb{id2}\)]
        [\(\textbf{B}\sb{id3}\) [\(\textbf{\#text}\sb{id4}\)]]
        [\(\textbf{\#text}\sb{id5}\)]
    ]
\end{forest}
}
\subfloat{
    $\xrightarrow{R(id1, id6)}$
}
\subfloat{
\begin{forest}
    [\textbf{\(\textbf{P}\sb{id6}\)}
        [\(\textbf{\#text}\sb{id2}\)]
        [\(\textbf{B}\sb{id3}\) [\(\textbf{\#text}\sb{id4}\)]]
        [\(\textbf{\#text}\sb{id5}\)]
    ]
\end{forest}
}

\subfloat{
    $\xrightarrow{R(id2, id7)}$
}
\subfloat{
\begin{forest}
    [\textbf{\(\textbf{P}\sb{id6}\)}
        [\(\textbf{\#text}\sb{id7}\)]
        [\(\textbf{B}\sb{id3}\) [\(\textbf{\#text}\sb{id4}\)]]
        [\(\textbf{\#text}\sb{id5}\)]
    ]
\end{forest}
}
\subfloat{
    $\xrightarrow{R(id3, id8)}$
}

\subfloat{
\begin{forest}
    [\textbf{\(\textbf{P}\sb{id6}\)}
        [\(\textbf{\#text}\sb{id7}\)]
        [\(\textbf{EM}\sb{id8}\) [\(\textbf{\#text}\sb{id4}\)]]
        [\(\textbf{\#text}\sb{id5}\)]
    ]
\end{forest}
}
\subfloat{
    $\xrightarrow{R(id4, id9)}$
}
\subfloat{
\begin{forest}
    [\textbf{\(\textbf{P}\sb{id6}\)}
        [\(\textbf{\#text}\sb{id7}\)]
        [\(\textbf{EM}\sb{id8}\) [\(\textbf{STRONG}\sb{id9}\)]]
        [\(\textbf{\#text}\sb{id5}\)]
    ]
\end{forest}
}

\subfloat{
    $\xrightarrow{  I(id10)  }$
}
\subfloat{
\begin{forest}
    [\textbf{\(\textbf{P}\sb{id6}\)}
        [\(\textbf{\#text}\sb{id7}\)]
        [\(\textbf{EM}\sb{id8}\) [\(\textbf{STRONG}\sb{id9}\) [\(\textbf{\#text}\sb{id10}\)]]]
        [\(\textbf{\#text}\sb{id5}\)]
    ]
\end{forest}
}
\subfloat{
    $\xrightarrow{R(id5, id11)}$
}

\subfloat{
\begin{forest}
    [\textbf{\(\textbf{P}\sb{id6}\)}
        [\(\textbf{\#text}\sb{id7}\)]
        [\(\textbf{EM}\sb{id8}\) [\(\textbf{STRONG}\sb{id9}\) [\(\textbf{\#text}\sb{id10}\)]]]
        [\(\textbf{U}\sb{id11}\)]
    ]
\end{forest}
}
\subfloat{
    $\xrightarrow{  I(id12)  }$
}
\subfloat{
\begin{forest}
    [\textbf{\(\textbf{P}\sb{id6}\)}
        [\(\textbf{\#text}\sb{id7}\)]
        [\(\textbf{EM}\sb{id8}\) [\(\textbf{STRONG}\sb{id9}\) [\(\textbf{\#text}\sb{id10}\)]]]
        [\(\textbf{U}\sb{id11}\) [\(\textbf{\#text}\sb{id12}\)]]
    ]
\end{forest}
}
\caption{Applicazione delle operazioni di \textit{diff} sull'albero \textit{oTree}.}
\label{fig:sekowsolsenzaspanseqoperazioni}
\end{figure}

This is pretty good but I would like that the arrows were aligned centrally and not down.

And I wish there was more space between each line and the other.

Something like this:

enter image description here

How can I do this?

A piece of my preamble:

\documentclass[a4paper, 11pt, titlepage]{book}

\usepackage[italian]{babel}
\usepackage{courier}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{forest, adjustbox}
\usepackage{mathtools}

\usepackage{graphicx}
\usepackage{subfig}
\captionsetup[subfigure]{subrefformat=simple,labelformat=simple,listofformat=subsimple}
\renewcommand\thesubfigure{(\alph{subfigure})}

If it were possible I would like to continue using the package subfloat because I have a lot of figure this in my document and I'd rather not have to change everything.

Thanks a lot!

1 Answer 1

4

You need no \subfloat, for this. All trees can be encapsulated in a tabular environment that guarantees vertical centering with respect to the formula axis where the arrows sit.

I also added \small that makes everything a tad smaller and helps in keeping the size under control.

\documentclass[a4paper, 11pt, titlepage]{book}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}
\usepackage{courier}

\usepackage{forest, adjustbox}
\usepackage{mathtools}

\usepackage{graphicx}

% centered forest
\newenvironment{cforest}
 {\tabular{@{}c@{}}\forest}
 {\endforest\endtabular}

\begin{document}

\begin{figure}[!htbp]
\centering\small

%% first row
\begin{cforest}
    [\textbf{\(\textbf{P}\sb{id1}\)}
        [\(\textbf{\#text}\sb{id2}\)]
        [\(\textbf{B}\sb{id3}\) [\(\textbf{\#text}\sb{id4}\)]]
        [\(\textbf{\#text}\sb{id5}\)]
    ]
\end{cforest}
$\xrightarrow{R(id1, id6)}$
\begin{cforest}
    [\textbf{\(\textbf{P}\sb{id6}\)}
        [\(\textbf{\#text}\sb{id2}\)]
        [\(\textbf{B}\sb{id3}\) [\(\textbf{\#text}\sb{id4}\)]]
        [\(\textbf{\#text}\sb{id5}\)]
    ]
\end{cforest}

%% second row
$\xrightarrow{R(id2, id7)}$
\begin{cforest}
    [\textbf{\(\textbf{P}\sb{id6}\)}
        [\(\textbf{\#text}\sb{id7}\)]
        [\(\textbf{B}\sb{id3}\) [\(\textbf{\#text}\sb{id4}\)]]
        [\(\textbf{\#text}\sb{id5}\)]
    ]
\end{cforest}
$\xrightarrow{R(id3, id8)}$

%% third row
\begin{cforest}
    [\textbf{\(\textbf{P}\sb{id6}\)}
        [\(\textbf{\#text}\sb{id7}\)]
        [\(\textbf{EM}\sb{id8}\) [\(\textbf{\#text}\sb{id4}\)]]
        [\(\textbf{\#text}\sb{id5}\)]
    ]
\end{cforest}
$\xrightarrow{R(id4, id9)}$
\begin{cforest}
    [\textbf{\(\textbf{P}\sb{id6}\)}
        [\(\textbf{\#text}\sb{id7}\)]
        [\(\textbf{EM}\sb{id8}\) [\(\textbf{STRONG}\sb{id9}\)]]
        [\(\textbf{\#text}\sb{id5}\)]
    ]
\end{cforest}

%% fourth row
$\xrightarrow{  I(id10)  }$
\begin{cforest}
    [\textbf{\(\textbf{P}\sb{id6}\)}
        [\(\textbf{\#text}\sb{id7}\)]
        [\(\textbf{EM}\sb{id8}\) [\(\textbf{STRONG}\sb{id9}\) [\(\textbf{\#text}\sb{id10}\)]]]
        [\(\textbf{\#text}\sb{id5}\)]
    ]
\end{cforest}
$\xrightarrow{R(id5, id11)}$

%% fifth row
\begin{cforest}
    [\textbf{\(\textbf{P}\sb{id6}\)}
        [\(\textbf{\#text}\sb{id7}\)]
        [\(\textbf{EM}\sb{id8}\) [\(\textbf{STRONG}\sb{id9}\) [\(\textbf{\#text}\sb{id10}\)]]]
        [\(\textbf{U}\sb{id11}\)]
    ]
\end{cforest}
$\xrightarrow{  I(id12)  }$
\begin{cforest}
    [\textbf{\(\textbf{P}\sb{id6}\)}
        [\(\textbf{\#text}\sb{id7}\)]
        [\(\textbf{EM}\sb{id8}\) [\(\textbf{STRONG}\sb{id9}\) [\(\textbf{\#text}\sb{id10}\)]]]
        [\(\textbf{U}\sb{id11}\) [\(\textbf{\#text}\sb{id12}\)]]
    ]
\end{cforest}

\caption{Applicazione delle operazioni di \textit{diff} sull'albero \textit{oTree}.}
\label{fig:sekowsolsenzaspanseqoperazioni}
\end{figure}

\end{document}

enter image description here

0

You must log in to answer this question.

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