绘制弯曲路径时如何避免双箭头

绘制弯曲路径时如何避免双箭头

我正在绘制一个图形,需要用弯曲的箭头线连接两个节点。

问题是,那条弯曲的线上不是只有一个箭头,而是有两个箭头。标有红色圆圈的箭头是我不想要的。如何删除它?

图形图像

\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
  • 如果您想使用,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}

相关内容