程序包 pgf 错误:没有已知的形状名称

程序包 pgf 错误:没有已知的形状名称

我遇到了一个问题

程序包 pgf 错误:没有已知的形状名称

但我不知道它出了什么问题,如何修复它?有人能帮助我吗?

我的代码如下:

\documentclass{minimal}
\usepackage{tikz}
\usepackage{verbatim}
\usepackage{CJKutf8}
\usetikzlibrary{shapes}
\usepackage{amsmath}
\usepackage{xspace}
\newcommand{\A}{\ensuremath{\mathcal{A}}\xspace}
\newcommand{\B}{\ensuremath{\mathcal{B}}\xspace}
\newcommand\pa[1]{\ensuremath{\left(#1\right)}}
\begin{document}
\begin{CJK}{UTF8}{gbsn}
\begin{tikzpicture}[
grow=right,
level 1/.style={sibling distance=.5cm,level distance=5.2cm},
level 2/.style={sibling distance=3.5cm, level distance=3.7cm},
edge from parent/.style={very thick,draw=blue!40!black!60,
    shorten >=5pt, shorten <=5pt},
edge from parent path={(\tikzparentnode.east) -- (\tikzchildnode.west)},
kant/.style={text width=2cm, text centered, sloped},
every node/.style={text ragged, inner sep=2mm},
punkt/.style={rectangle, rounded corners, shade, top color=white,
bottom color=blue!50!black!20, draw=blue!40!black!60, very
thick }
]

\node[punkt, text width=4.5em] {未知相关\\估计信息}
%Lower part lv1
child {
    node[punkt, text width=4em]
       {完全未知}                 
%----------------------------------------------
             child {
        node [punkt,rectangle split, rectangle split,
        rectangle split parts=2] {
            \textbf{非随机意义下:}
            \nodepart{second}
            相关估计信息未知但有界                            }
        edge from parent
            node[below, kant,  pos=.6] {}
    }
    child {
        node [punkt, rectangle split, rectangle split parts=2]{
            \textbf{随机意义下:}
            \nodepart{second}
            互协方差信息未知但有界
        }
        edge from parent
            node[kant, above] {}}
        edge from parent{
            node[kant, below] {}}
    }

%Upper part, lv1

child {
    node[punkt, text width=4em] {部分未知}
    %child 1
    child {
        node [punkt,rectangle split, rectangle split,
        rectangle split parts=2] {
            \textbf{非随机意义下:}
            \nodepart{second}
            相关估计信息未知但有界                            }  
        edge from parent
            node[below, kant,  pos=.6] {}
    }
    %child 2
    child {
        node [punkt, rectangle split, rectangle split parts=2]{
            \textbf{随机意义下:}
            \nodepart{second}
            互协方差信息未知但有界
        }
        edge from parent
            node[kant, above] {}}
        edge from parent{
            node[kant, above] {}}
}

\end{tikzpicture}
\end{CJK}
\end{document}

答案1

树木厌恶真空。您不能在树的中间留下这样的空行。

另外,您需要一个分号来完成路径,并且需要改变兄弟距离以防止上下分支相互重叠。

我还删除了你的 MWE 中不需要的包(但显然你会希望它们出现在你的文档中)并更改了类。minimal不是适合在示例中使用。standalone或者article是推荐的替代方案。

\documentclass[tikz,border=5pt]{standalone}
\usepackage{CJKutf8}
\usetikzlibrary{shapes}
\begin{document}
\begin{CJK}{UTF8}{gbsn}
\begin{tikzpicture}
  [
    grow=right,
    level 1/.style={sibling distance=5.5cm,level distance=5.2cm},
    level 2/.style={sibling distance=3.5cm, level distance=3.7cm},
    edge from parent/.style={very thick,draw=blue!40!black!60, shorten >=5pt, shorten <=5pt},
    edge from parent path={(\tikzparentnode.east) -- (\tikzchildnode.west)},
    kant/.style={text width=2cm, text centered, sloped},
    every node/.style={text ragged, inner sep=2mm},
    punkt/.style={rectangle, rounded corners, shade, top color=white, bottom color=blue!50!black!20, draw=blue!40!black!60, very thick }
  ]

  \node[punkt, text width=4.5em] {未知相关\\估计信息}
  %Lower part lv1
  child {
    node[punkt, text width=4em]
    {完全未知}
    %----------------------------------------------
    child {
      node [punkt,rectangle split, rectangle split, rectangle split parts=2] {
        \textbf{非随机意义下:}
        \nodepart{second}
        相关估计信息未知但有界}
      edge from parent
      node[below, kant,  pos=.6] {}
    }
    child {
      node [punkt, rectangle split, rectangle split parts=2]{
        \textbf{随机意义下:}
        \nodepart{second}
        互协方差信息未知但有界
      }
      edge from parent
      node[kant, above] {}}
    edge from parent{
      node[kant, below] {}}
  }
  %Upper part, lv1
  child {
    node[punkt, text width=4em] {部分未知}
    %child 1
    child {
      node [punkt,rectangle split, rectangle split,
      rectangle split parts=2] {
        \textbf{非随机意义下:}
        \nodepart{second}
        相关估计信息未知但有界}
      edge from parent
      node[below, kant,  pos=.6] {}
    }
    %child 2
    child {
      node [punkt, rectangle split, rectangle split parts=2]{
        \textbf{随机意义下:}
        \nodepart{second}
        互协方差信息未知但有界
      }
      edge from parent
      node[kant, above] {}}
    edge from parent{
      node[kant, above] {}}
  }
  ;

\end{tikzpicture}
\end{CJK}
\end{document}

树

相关内容