我正在绘制一个图形,需要用弯曲的箭头线连接两个节点。
问题是,那条弯曲的线上不是只有一个箭头,而是有两个箭头。标有红色圆圈的箭头是我不想要的。如何删除它?
\documentclass[a4paper,10pt]{article}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\begin{document}
\tikzstyle{node}=[
circle,
inner sep=2.4mm,
draw=black,
line width=0.2mm,
]
\tikzstyle{linea}=[
draw=black,
line width=0.34mm,
-triangle 60
]
\begin{tikzpicture}[y=-1cm]
\node (n1) at (1, 0.5) {};
\node (n2) [node] at (1, 2) {A};
\node (n3) [node] at (1, 4) {x};
\path [linea] (n1) -- (n2);
\path [linea] (n2) -- (n3);
\path [linea, bend left] (n3.west) edge (n2.west);
\end{tikzpicture}
\end{document}
答案1
改编
- 使用
\tikzset
而不是\tikzstyle
(见应该使用 \tikzset 还是 \tikzstyle 来定义 TikZ 样式?) - 添加
\usetikzlibrary{automata}
并使用state
节点选项 - 添加
\usetikzlibrary{positioning}
相对定位 - 最小化示例
edge
增加了和之间的比较to
- 也可以看看tikz 手册“17.12 连接节点:使用边缘操作”
- “
edge
暂时停止现有道路的建设和一条新道路的建设页已建成”(红色) to
将内容添加到路径(蓝色)
- 如果您想使用,
egde
则不应使用draw
(见下图)。 - 如果您想使用,
to
您应该使用draw
(见上图)。 - 如果你只需要连接二节点,通常的方法是使用:
\draw[linea] (a) to[bend right] (b); % with bend \draw[linea] (a) -- (b); % without bend
结果
代码
\documentclass[a4paper,10pt]{article}
\usepackage{tikz}
\usetikzlibrary{shapes, arrows, automata, positioning}
\begin{document}
\begin{tikzpicture}[
linea/.style={
draw,
-triangle 60
},
]
\node [state] (a) {a};
\node [state, right=of a] (b) {b};
\node [state, right=of b] (c) {c};
\path [linea, bend left, red] (a.north) edge (b.north) edge node[above]{\texttt{edge}} (c.north);
\path [linea, blue, bend right] (a.south) to (b.south) to node[below]{\texttt{to}} (c.south);
\end{tikzpicture}
\verb|draw| and \verb|\path ...| = \verb|\draw ...|
\begin{tikzpicture}[
linea/.style={
-triangle 60
},
]
\node [state] (a) {a};
\node [state, right=of a] (b) {b};
\node [state, right=of b] (c) {c};
\path [linea, bend left, red] (a.north) edge (b.north) edge node[above]{\texttt{edge}} (c.north);
\path [linea, blue, bend right] (a.south) to (b.south) to node[below]{\texttt{to}} (c.south);
\end{tikzpicture}
no \verb|draw| and \verb|\path|
\end{document}