显示一系列树和箭头

显示一系列树和箭头

我应该将一系列图像按顺序排列并用箭头连接起来。这就是我设法做到的: 在此处输入图片描述

使用此代码:

\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}

这非常好,但我希望箭头居中对齐而不是向下。

我希望每行之间能有更多的空间。

像这样:

在此处输入图片描述

我怎样才能做到这一点?

我的序言部分内容:

\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})}

如果可能的话,我愿意继续使用该套餐子浮点型因为我的文档中有很多这样的数字,而且我不想改变所有内容。

多谢!

答案1

\subfloat为此,您不需要。所有树都可以封装在一个tabular环境中,该环境可保证相对于箭头所在的公式轴垂直居中。

我还补充说,\small这会使所有内容稍微小一些,并有助于控制尺寸。

\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}

在此处输入图片描述

相关内容