实现一棵适合两列页面结构并允许多行节点的树

实现一棵适合两列页面结构并允许多行节点的树

我有一篇格式如下的论文这个,即每页两列文本。

我一直试图制作一个树结构来适应一列,但到目前为止我还无法使它工作。

有关于如何使用 tikz 制作树结构的资源,这个例如,或者。但到目前为止,我还无法使这些解决方案适应我目前的情况。

我手写了我想要的树的外观。第一个节点能够扩展到两行很重要,我猜是使用///newline

到目前为止我有这个:

\begin{figure}[t]
\centering

\caption{An illustration of a simple delete operation. \label{fig:simple}}
{
    \begin{tikzpicture}[level/.style={sibling distance = 5cm/#1, level distance = 1.5cm}, scale=0.6,transform shape]
    \node {\footnotesize educated at( Bush, University of Texas at Austin)}
    child
    {
        %node [treenode] {$Y$ \\ 50} 
        child
        {
            %node [treenode] {$Z$ \\ 40} 
            child
            {
                node [treenode] {$S1$ \\ 30}
                child
                {
                    node {\\60} 
                }
                {
                    node {\\60} 
                }
            }
            child
            {
                {
                    node {\\60} 
                }
                {
                    node {\\60} 
                } 
            }
        }
        child[edge from parent path ={(\tikzparentnode.-50) -- (\tikzchildnode.north)}]
        {
            node [subtree,yshift=0.4cm] (a) {}   % delay the text till later
        }
    }
    child[edge from parent path ={(\tikzparentnode.-30) -- (\tikzchildnode.north)}]
    {
        node [subtree,yshift=0.4cm] (b) {}       % delay the text till later
    }
;
% ------------------------------------------------ put the text into subtree nodes
\node[align=center,yshift=0.1cm] at (a) {$Z$\\200};
\node[align=center,yshift=0.1cm] at (b) {$Z$\\200};
\end{tikzpicture}
}
\end{figure}

以及这些包:

\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usetikzlibrary{shapes.geometric,arrows,fit,matrix,positioning}

理想情况下应该是这样的:

在此处输入图片描述

答案1

forest这是生产特别紧凑的树木的一种方法。

\documentclass[twocolumn]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{forest,kantlipsum}
\forestset{% adapted from page 52
  nice empty nodes/.style={
    delay={
      where content={}{
        shape=coordinate,
        for parent={
          for children={
            anchor=north
          }
        }
      }{}
    }
  }
}
\begin{document}
  \kant[1-2]
\begin{figure}[t]
\centering
\caption{An illustration of a simple delete operation. \label{fig:simple}}

    \begin{forest}
      nice empty nodes,
      for tree={
        align=center,
        parent anchor=south,
        edge path={
          \noexpand\path [draw, fill, \forestoption{edge}] (!u.parent anchor) circle (1.5pt) -- (.child anchor)\forestoption{edge label};
        }
      }
      [\textsc{data representation}\\{\footnotesize educated at (Bush, University of Texas at Austin)}
        [
          [Something\\here
          ]
          [Something\\else
          ]
        ]
        [
          [, tier=tier 1
            [
              [Q value]
              [English]
            ]
            [
              [Q value]
              [English]
            ]
          ]
          [
            [P value, tier=tier 1]
            [English]
          ]
        ]
      ]
    \end{forest}

\end{figure}
\kant[3-4]

\end{document}

树

相关内容