\begin{tikzpicture}[->,shorten >=1pt,auto,node distance=3cm,
main node/.style={draw}]
\node[main node] (1) {A};
\node[main node] (2) [right of=1] {B};
\node[main node] (3) [right of=2] {C};
\node[main node] (4) [below left of=3,xshift=1cm] {D};
\path[every node/.style={font=\sffamily\small}]
(2) edge [bend right] node [left] {} (4)
(3) edge [bend left] node [left] {} (4)
\end{tikzpicture}
看到进入 D 的箭头不对称了吗?我怎样才能使它们对称并从侧面进入?
答案1
节点n2
和n4
, 和n3
之间的边只有在节点 位于节点和的水平中间n4
时才是对称的。如果不是,那么某些对称性只能近似,例如节点 处的连接点是对称的:n4
n2
n3
n4
\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{calc,
positioning}
\begin{document}
\begin{tikzpicture}[
node distance=22mm and 22mm,
every edge/.style = {draw, ->, shorten >=1pt},
box/.style = {draw, minimum size=8mm, font=\sffamily\small},
]
\node (n1) [box] {A};
\node (n2) [box, right=of n1] {B};
\node (n3) [box, right=of n2] {C};
\node (n4) [box, below=of $(n2.south)!0.5!(n3.south)$] {D};
%
\path (n2) edge [bend right] (n4)
(n3) edge [bend left] (n4);
\end{tikzpicture}
\begin{tikzpicture}[
node distance=22mm and 22mm,
every edge/.style = {draw, ->, shorten >=1pt},
box/.style = {draw, minimum size=8mm, font=\sffamily\small},
]
\node (n1) [box] {A};
\node (n2) [box, right=of n1] {B};
\node (n3) [box, right=of n2] {C};
\node (n4) [box, below right=22mm and 8 mm of n2.east] {D};
%
\path (n2) edge [bend right] (n4.west)
(n3) edge [bend left] (n4.east);
\end{tikzpicture}
\end{document}
第一个图像代码示例的结果:
第二个示例的结果:
在图像代码中,我将节点名称从 1、2、3 和 4 更改为 n1、n2、n3 和 n4。