修改 TiKZ 树方案

修改 TiKZ 树方案

我正在尝试修改我在一个示例中发现的树形方案,但是我无法实现我想要的效果。

在此处输入图片描述

我想在图中最后一个矩形下方添加两个矩形。从节点$A_{prv}\Delta P$应该出现“Q=”这样的行,这为另外两个选项让路。

代码:

\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{trees}
\begin{document}
\tikzstyle{every node}=[draw=black,thick,anchor=west]
\tikzstyle{selected}=[draw=red,fill=red!30]
\tikzstyle{optional}=[dashed,fill=gray!50]
\begin{tikzpicture}[%
  grow via three points={one child at (0.5,-0.7) and
  two children at (0.5,-0.7) and (0.5,-1.4)},
  edge from parent path={(\tikzparentnode.south) |- (\tikzchildnode.west)}]
  \node {$(\zeta,\Omega)\rightarrow (y,v_y)$}
    child { node {$\dot{\zeta} = \Omega$}}      
    child { node {$\dot{\Omega} = $}}
    child { node {$\dot{P_1} = (B/V)(Q-A\lambda d)$}}
    child { node {$\dot{P_2} = (B/V)(Q-A\lambda d)$}}
    child { node  {Q =}
      child { node {$0$ \hspace{14mm} if: \hspace{3mm} $P_1A_1-P_2A_2 < F_{pc}$}}
      child { node  {$A_{prv}\Delta P$ \hspace{3mm} if: \hspace{3mm} $P_1A_1-P_2A_2 \geq F_{pc}$}}};

\end{tikzpicture}
\end{document}

答案1

版本 1:最后一个节点的两个子节点。

代替

  child { node  {$A_{prv}\Delta P$ \hspace{3mm} if: \hspace{3mm} $P_1A_1-P_2A_2 \geq F_{pc}$}}};

经过

  child { node  {$A_{prv}\Delta P$ \hspace{3mm} if: \hspace{3mm} $P_1A_1-P_2A_2 \geq F_{pc}$}
           child { node {Child 1 of $A_{prv}\Delta P$}}
           child { node {Child 2 of $A_{prv}\Delta P$}}
        }
      };

在此处输入图片描述

\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{trees}
\begin{document}
\tikzstyle{every node}=[draw=black,thick,anchor=west]
\tikzstyle{selected}=[draw=red,fill=red!30]
\tikzstyle{optional}=[dashed,fill=gray!50]
\begin{tikzpicture}[%
  grow via three points={one child at (0.5,-0.7) and
  two children at (0.5,-0.7) and (0.5,-1.4)},
  edge from parent path={(\tikzparentnode.south) |- (\tikzchildnode.west)}]
  \node {$(\zeta,\Omega)\rightarrow (y,v_y)$}
    child { node {$\dot{\zeta} = \Omega$}}      
    child { node {$\dot{\Omega} = $}}
    child { node {$\dot{P_1} = (B/V)(Q-A\lambda d)$}}
    child { node {$\dot{P_2} = (B/V)(Q-A\lambda d)$}}
    child { node  {Q =}
      child { node {$0$ \hspace{14mm} if: \hspace{3mm} $P_1A_1-P_2A_2 < F_{pc}$}}
      child { node  {$A_{prv}\Delta P$ \hspace{3mm} if: \hspace{3mm} $P_1A_1-P_2A_2 \geq F_{pc}$}
               child { node {Child 1 of $A_{prv}\Delta P$}}
               child { node {Child 2 of $A_{prv}\Delta P$}}
            }
          };
\end{tikzpicture}
\end{document}

版本 2:的另外两个子节点Q =

代替

  child { node  {$A_{prv}\Delta P$ \hspace{3mm} if: \hspace{3mm} $P_1A_1-P_2A_2 \geq F_{pc}$}}};

经过

  child { node  {$A_{prv}\Delta P$ \hspace{3mm} if: \hspace{3mm} $P_1A_1-P_2A_2 \geq F_{pc}$}}
  child { node {Child 1 of $A_{prv}\Delta P$}}
  child { node {Child 2 of $A_{prv}\Delta P$}}
      };

在此处输入图片描述

\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{trees}
\begin{document}
\tikzstyle{every node}=[draw=black,thick,anchor=west]
\tikzstyle{selected}=[draw=red,fill=red!30]
\tikzstyle{optional}=[dashed,fill=gray!50]
\begin{tikzpicture}[%
  grow via three points={one child at (0.5,-0.7) and
  two children at (0.5,-0.7) and (0.5,-1.4)},
  edge from parent path={(\tikzparentnode.south) |- (\tikzchildnode.west)}]
  \node {$(\zeta,\Omega)\rightarrow (y,v_y)$}
    child { node {$\dot{\zeta} = \Omega$}}      
    child { node {$\dot{\Omega} = $}}
    child { node {$\dot{P_1} = (B/V)(Q-A\lambda d)$}}
    child { node {$\dot{P_2} = (B/V)(Q-A\lambda d)$}}
    child { node  {Q =}
      child { node {$0$ \hspace{14mm} if: \hspace{3mm} $P_1A_1-P_2A_2 < F_{pc}$}}
      child { node  {$A_{prv}\Delta P$ \hspace{3mm} if: \hspace{3mm} $P_1A_1-P_2A_2 \geq F_{pc}$}}
      child { node {Child 1 of $A_{prv}\Delta P$}}
      child { node {Child 2 of $A_{prv}\Delta P$}}
          };
\end{tikzpicture}
\end{document}

相关内容