答案1
TikZ
可以使用来支撑一条线decorations.pathreplacing
。如果节点是O
,AB
则命令
\draw[very thick, -stealth](O)--(AB);
\draw[decorate, decoration={brace}](O.center)--(AB.center);
将绘制线(带有隐形箭头),然后绘制支架。可以使用 将支架移离节点,raise=
并使用 控制支架的“高度” 。然后,您可以使用选项(并使用 进行移动)放置带有所需标签的 ,amplitude=
从而为支架添加标签,如以下代码所示。node
sloped
yshift=
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary {decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}
\node[draw, circle, inner sep=1pt, label={180:0}] at (0,0)(O){};
\node[fill, circle, inner sep=1pt, label={0:$AB$}] at (1,4)(AB){};
\node[fill, circle, inner sep=1pt, label={0:$B$}] at (1,2)(B){};
\node[fill, circle, inner sep=1pt, label={0:$A$}] at (4,1)(A){};
\draw[very thick, -stealth](O)--(AB);
\draw[decorate, decoration={brace, raise=3pt, amplitude=6pt}](O.center)--
node[sloped, yshift=15pt]{$(\mathrm{length}\,A)\cdot(\mathrm{length}\,B)$}(AB.center);
\draw[very thick, -stealth](O)--(B);
\draw[very thick, -stealth](O)--(A);
\draw[thick, dotted](O)--(4,0);
\end{tikzpicture}
\end{document}
可以使用库添加标记的角度angles
。示例中的箭头看起来像Triangle
style,这需要arrows.meta
,bending
库将使头部指向正确的方向。添加以下代码:
\usetikzlibrary {decorations.pathreplacing, angles, arrows.meta, bending} % in preamble
\draw pic [draw, angle radius=1.2cm, -Triangle] {angle=X--O--B};
\draw pic [draw, angle radius=1.2cm, -Triangle] {angle=X--O--AB};
\draw pic [draw, angle radius=1cm, -Triangle] {angle=X--O--A};
\draw pic [draw, angle radius=1cm, -Triangle] {angle=X--O--AB};
答案2
可以pstricks-add
使用相对较短的代码来完成:
\documentclass[border=12pt, svgnames]{standalone}%
\usepackage{pstricks-add, pst-eucl}
\begin{document}
\psset{arrowinset=0.12, linejoin=1, unit=2cm, braceWidth=0.4pt}
\begin{pspicture}(-0.5,-0.5)(2.5,2)
\pstGeonode(2; 20){A}(1; 50){B}(2; 70){AB}
\pstGeonode[PointSymbol=o, PosAngle=180](0,0){O}
\pnode(2.2,0){X}\ncline[linestyle=dotted, dotsep=2pt, nodesepA=2pt]{O}{X}
\psset{arrows=->, nodesepA=2pt, nodesepB=3pt}\ncline{O}{A}\ncline{O}{B}\ncline{O}{AB}
\psbrace[rot=70, nodesep=-1pt](AB)(O){\makebox[0pt]{(length A)$\cdot$(length B)}}
\end{pspicture}
\end{document}