實作適合兩列頁面結構並允許多行節點的樹

實作適合兩列頁面結構並允許多行節點的樹

我有一張格式如下的論文這個,即每頁兩列文字。

我一直在嘗試製作一個樹結構以適合一列的內部,但到目前為止我還無法使其工作。

有關如何使用 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}

樹

相關內容