我正在为 Tikz 使用以下 LaTeX 代码:
\begin{tikzpicture}[ noeud/.style={draw, circle},
triangle/.style={isosceles triangle, anchor=apex,
draw, shape border rotate=90,
minimum size = 1cm},
scale=1]
\node (A) at (-1.5, -2) {};
\node (B) at (1.5, -2) {};
\node[noeud] (r) at (0, 0) {$r$};
\node[triangle] at (A) {$A$};
\node[triangle] at (B) {$B$};
\coordinate(Ar) at (intersection of r and r--A);
\draw (Ar)--(-1.5, -2);
\coordinate(Bd) at (intersection of r and r--B);
\draw (Bd)--(1.5, -2);
\end{tikzpicture}
我想在节点 r 和两个三角形的顶部之间画一条直线。但是,我无法以可读的方式完成我的 Tikz 代码。
有人知道我的问题是什么吗?
下面是我得到的和我想要得到的图片:
答案1
您可以轻松地使用库定位所有内容positioning
并使用apex
锚点来停止连接。
\documentclass[tikz]{standalone}
\usetikzlibrary{positioning, shapes.geometric}
\begin{document}
\begin{tikzpicture}[%
noeud/.style={draw, circle},
triangle/.style={isosceles triangle, anchor=apex,
draw, shape border rotate=90,
minimum size = 1cm},
scale=1]
% \node (A) at (-1.5, -2) {};
% \node (B) at (1.5, -2) {};
\node[noeud] (r) at (0, 0) {$r$};
\node[triangle, below left=2cm and 1cm of r] (A) {$A$};
\node[triangle, below right=2cm and 1cm of r] (B) {$B$};
% \coordinate(Ar) at (intersection of r and r--A);
\draw (r)--(A.apex) (r)--(B.apex);
% \coordinate(Bd) at (intersection of r and r--B);
% \draw (Bd)--(1.5, -2);
\end{tikzpicture}
\end{document}