我试图使用交点作为关节将一条弯曲路径连接到另一条弯曲路径(两个弯曲边),但是当向第二条路径添加样式为“-latex”的箭头时,曲线略有位移,交点错误。
\begin{tikzpicture}
\draw
node (A) at (-2,-2) {A}
node (B) at ( 0,-3) {B}
node (C) at (-2,-4) {C}
;
\draw [name path=line] (-2,-3.5) -- (-1,-3.5);
\draw [-latex] (A) edge [bend left=45,name path=curve] (C);
\draw [name intersections={of=curve and line}] (B) edge [bend right] (intersection-1) ;
\end{tikzpicture}
下面是上述代码中含有和不含错误的图像。
是什么原因造成的?如何解决?
答案1
解决方法:\usetikzlibrary{bending}
。这样弯曲箭头的箭头就能更好地跟随曲线:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{bending}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}
\draw
node (A) at (-2,-2) {A}
node (B) at ( 0,-3) {B}
node (C) at (-2,-4) {C}
;
\draw [name path=line] (-2,-3.5) -- (-1,-3.5);
\draw [-latex] (A) edge [bend left=45,name path=curve] (C);
\draw [name intersections={of=curve and line}] (B) edge [bend right]
(intersection-1) ;
\end{tikzpicture}
\end{document}