我面臨一個小問題。我有一條線穿過根節點。
\tikzset{
basic/.style = {draw, text width=1.5cm, drop shadow, font=\sffamily, rectangle},
root/.style = {basic, rounded corners=6pt, thin, align=center,
fill=green!60, text width=13cm},
level 2/.style = {basic, rounded corners=4pt, thin,align=center, fill=green!60,
text width=8em},
level 3/.style = {basic, thin, align=left, fill=pink!60, text width=8em, align=center}
}
\hspace*{0cm}{
\begin{tikzpicture}[
level 1/.style={sibling distance=70mm},
edge from parent/.style={->,draw},
>=latex]
\begin{scope}[every node/.style={level 3}]
\node[root] (c1) {AAAAA};
\node [below of = c1, xshift=-4cm, yshift=0cm] (c11) {S};
\node [below of = c11] (c12) {D};
\node [below of = c12] (c13) {R};
\node [below of = c1, xshift=4cm, yshift=.15cm] (c14) {W};
\node [below of = c14, yshift=-0.5cm] (c15) {K};
\node [below of = c15, yshift=-0.5cm] (c16) {M};
\end{scope}
\foreach \value in {1,2,3}
\draw[->] (c1.120) |- (c1\value.east);
\foreach \value in {4,5,6}
\draw[->] (c1.270) |- (c1\value.west);
\end{tikzpicture}}
答案1
語法c1.120
表示c1
節點邊界與與節點中心成 120 度角的直線的交點。在您的情況下,該點位於頂部邊界並\draw[->] (c1.120) |- (c1\value.east);
穿過節點。如果您想遵守此語法,您只需選擇一個將起點置於底部邊框上的角度,例如c1.250
。
\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\node[draw, minimum width=2cm, minimum height=1cm] (c1) {};
\node[draw, minimum width=2cm, minimum height=1cm, below left= 0.5cm and 0.5cm of c1] (c2) {};
\draw (c1.center) -- (120:2cm);
\draw (c1.center) -- (0:2cm);
\draw (0:1.5cm) arc [start angle=0, end angle=120, radius=1.5cm] node[midway, above right] {$120^\circ$};
\draw[fill=red] (c1.120) circle (2pt);
\draw (c1.120) |- (c2);
\begin{scope}[xshift=5cm]
\node[draw, minimum width=2cm, minimum height=1cm] (c1) {};
\node[draw, minimum width=2cm, minimum height=1cm, below left= 0.5cm and 0.5cm of c1] (c2) {};
\draw (c1.center) -- (250:2cm);
\draw (c1.center) -- (0:2cm);
\draw (0:1.5cm) arc [start angle=0, end angle=250, radius=1.5cm] node[midway, above left] {$250^\circ$};
\draw[fill=red] (c1.250) circle (2pt);
\draw (c1.250) |- (c2);
\end{scope}
\end{tikzpicture}
\end{document}