TikZ 流程图子项

TikZ 流程图子项

是否可以将 C 块显示为单个块而不是 3 个块?

在此处输入图片描述

\documentclass[landscape]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage[margin=1in]{geometry}
\usepackage{tikz-qtree}
\usetikzlibrary{shadows,trees}
\begin{document}
\tikzset{font=\small,
edge from parent fork down,
level distance=1.75cm,
every node/.style=
    {top color=white,
    bottom color=blue!25,
    rectangle,rounded corners,
    minimum height=8mm,
    draw=blue!75,
    very thick,
    drop shadow,
    align=center,
    text depth = 0pt
    },
edge from parent/.style=
    {draw=blue!50,
    thick
    }}

\centering


\begin{tikzpicture}
\Tree [.A
        [.{B}
            [.{C} ]
] 
        [.{D}
            [.{C} ]            
 ] 
 [.{C}
]
        [.{E}
]
]
\end{tikzpicture}


\end{document}

答案1

由于所需对象不再是树(它有循环),因此最好不用 来绘制它tikz-qtree;以下代码显示了一些可能性:

\documentclass[landscape]{article}
\usepackage{tikz}
\usetikzlibrary{positioning,shadows}

\begin{document}

\tikzset{font=\small,
every node/.style=
    {top color=white,
    bottom color=blue!25,
    rectangle,rounded corners,
    minimum height=8mm,
    draw=blue!75,
    very thick,
    drop shadow,
    align=center,
    text depth = 0pt
    },
myedge/.style=
    {draw=blue!50,
    thick
    }}

\begin{tikzpicture}
\node (a) {A};
\node[below=of a] (d) {D};
\node[right=of d] (e) {E};
\node[left=of d] (b) {B};
\node[below=of b] (c) {C};
\foreach \pare/\chil in {a/b,a/d,a/e,b/c,d/c} 
  \draw[myedge] (\pare.south) -- (\chil.north);
\draw[myedge] (a.south) -- (c.north);
\begin{scope}[xshift=5.5cm]
\node (a) {A};
\node[below=of a] (d) {D};
\node[right=of d] (e) {E};
\node[left=of d] (b) {B};
\node[below=of b] (c) {C};
\foreach \pare/\chil in {a/b,a/d,a/e,b/c,d/c} 
  \draw[myedge] (\pare.south) -- (\chil.north);
\draw[myedge] (a.south) .. controls (-3.5cm,-1.5cm) .. (c.north);
\end{scope}
\begin{scope}[xshift=8cm]
\node (a) {A};
\coordinate[below=of a] (aux); 
\node[right=of aux] (b) {B};
\node[right=of b] (d) {D};
\node[right=of d] (e) {E};
\node[below=of aux] (c) {C};
\foreach \pare/\chil in {a/b,a/d,a/e,b/c,d/c} 
  \draw[myedge] (\pare.south) -- (\chil.north);
\draw[myedge] (a) -- (c);
\end{scope}
\end{tikzpicture}

\end{document}

在此处输入图片描述

如果您想保留tikz-qtree语法和样式,那么您可以执行以下操作:

\documentclass[landscape]{article}
\usepackage{tikz-qtree}
\usetikzlibrary{shadows,trees,calc}

\begin{document}
\tikzset{font=\small,
edge from parent fork down,
level distance=1.75cm,
every node/.style=
    {top color=white,
    bottom color=blue!25,
    rectangle,rounded corners,
    minimum height=8mm,
    draw=blue!75,
    very thick,
    drop shadow,
    align=center,
    text depth = 0pt
    },
edge from parent/.style=
    {draw=blue!50,
    thick
    }}

\begin{tikzpicture}
\Tree [.\node (a) {A};
        [.{B}
            [.\node (c) {C}; ]
] 
        [.\node (d) {D}; 
 ] 
        [.{E}
]
]
\draw[edge from parent] let \p1=(d.south), \p2=(c.north) in 
  (d.south) |- ( $ (d.south) + (0,0.5*\y2-0.5*\y1) $ ) -| (c.north);
\draw[edge from parent] let \p1=(a.south), \p2=(d.north) in 
  (a.south) -- ++(0,0.5*\y2-0.5*\y1) -- ++(-1.3,0) |- ( $ (c.north) - (0,0.5*\y2-0.5*\y1) $ ) -- (c.north);
\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容