我用
\begin{tikzpicture}[
node distance=4ex and 0em,
block/.style={rectangle, draw, fill=white!20,
text width=7.5em, text centered, rounded corners, minimum height=4em},
line/.style={draw, -latex},
]
\node [block] (1) {A};
\node [block, below right= of 1] (2) {B};
\node [block, below left= of 2] (3) {C};
\node [block, above left= of 3] (4) {D};
\path [line] (1) -- (2);
\path [line] (2) -- (3);
\path [line] (3) -- (4);
\path [line] (4) -- (1);
\end{tikzpicture}
我现在想要用箭头 (1) 到 (2)、(2) 到 (3)、(4) 到 (4) 以及 (4) 到 (1) 来代替直线。请指教。
答案1
通过bend left
节点之间的边选项,经过一些手动调整(非常类似于@CarLaTeX 答案,+1)后,箭头几乎完美地位于穿过节点的圆圈上:
\documentclass[margin=3.141592]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
positioning}
\begin{document}
\begin{tikzpicture}[
node distance = 4ex and 0em,
block/.style = {rectangle, draw, fill=white!20,
text width=6em, text centered, rounded corners, minimum height=4em},
every edge/.style = {draw=gray, -{Latex[scale=0.8]}, ultra thick, bend angle=20},
]
\node [block] (1) {A};
\node [block, below right= of 1] (2) {B};
\node [block, below left= of 2] (3) {C};
\node [block, above left= of 3] (4) {D};
\path (1.east) edge [bend left] (2)
(2) edge [bend left] (3.east)
(3.west) edge [bend left] (4)
(4) edge [bend left] (1.west);
\end{tikzpicture}
\end{document}
给出
答案2
如果我的水晶球没问题的话,我想你会想要弯曲的箭而不是直线的箭。
您可以使用以下选项进行操作bend left
:
\documentclass[border=1cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[
node distance=4ex and 0em,
block/.style={rectangle, draw, fill=white!20,
text width=7.5em, text centered, rounded corners, minimum height=4em},
line/.style={draw, -latex},
]
\node [block] (1) {A};
\node [block, below right= of 1] (2) {B};
\node [block, below left= of 2] (3) {C};
\node [block, above left= of 3] (4) {D};
\path [line] (1) to[bend left] (2);
\path [line] (2) to[bend left] (3);
\path [line] (3) to[bend left] (4);
\path [line] (4) to[bend left] (1);
\end{tikzpicture}
\end{document}