![箭头末端的节点](https://linux22.com/image/376492/%E7%AE%AD%E5%A4%B4%E6%9C%AB%E7%AB%AF%E7%9A%84%E8%8A%82%E7%82%B9.png)
我想在一些箭头的起点和终点处放置一些文字,如下图所示(但不那么丑):
有没有办法做到这一点,而无需对角度或类似内容进行硬编码?
答案1
这里有两种方法。最有可能的是问题和答案重复。
\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{decorations.markings}
\begin{document}
\begin{tikzpicture}
\node[circle,draw] at (0,0) (A){A};
\node[circle,draw] at (4,-1) (B){B};
\node[circle,draw] at (4,2) (C){C};
\draw (A) -- (B) node[pos=1]{X};
\draw[decoration={markings,
mark=at position 1cm with {
\node{Y};
}}, postaction={decorate}] (A) -- (C);
\end{tikzpicture}
\end{document}