我画一个角:
\usetikzlibrary{angles,quotes}
\begin{tikzpicture}
\coordinate [label=above right:$A$] (A) at (1,1);
\coordinate [label=above left:$B$] (B) at (0,0);
\coordinate [label=below left:$C$] (C) at (1,0);
\draw (A) -- (B) -- (C) pic [draw] {angle};
\end{tikzpicture}
我得到:包 pgfkeys 错误:我不知道密钥“/tikz/pics/angle”,我将忽略它。也许你拼错了。...draw (A) -- (B) -- (C) pic [draw] {angle}。
如何解决?
答案1
如果我将您的代码片段插入到一个小的文档中,例如:
\documentclass[border=3.141592]{standalone}
\usepackage{tikz}
\usetikzlibrary{angles,
quotes}
\begin{document}
\begin{tikzpicture}
\coordinate [label=above right:$A$] (A) at (1,1);
\coordinate [label=above left:$B$] (B) at (0,0);
\coordinate [label=below left:$C$] (C) at (1,0);
\draw (A) -- (B) -- (C) pic [draw] {angle};
\end{tikzpicture}
\end{document}
我得到以下结果:
但我想你可能想要的是以下结果:
与您的代码片段不同,生成上述图像的 MWE (最小工作示例) 具有由 明确定义的角度坐标{angle=C--B--A}
。请注意,这些坐标的顺序决定角度标记是在绘制线内还是外:
\documentclass[border=3.141592]{standalone}
\usepackage{tikz}
\usetikzlibrary{angles,
quotes}
\begin{document}
\begin{tikzpicture}
\coordinate [label=above right:$A$] (A) at (1,1);
\coordinate [label= left:$B$] (B) at (0,0);
\coordinate [label=right:$C$] (C) at (1,0);
\draw (A) -- (B) -- (C) pic [draw] {angle=C--B--A}; % <---
\end{tikzpicture}
\end{document}
答案2
还有另一种(类似的)使用tkz-euclide
包的方法:
\documentclass{standalone}
\usepackage{tkz-euclide}
\tkzSetUpPoint[size=1,color=black,fill=black]
\begin{document}
\begin{tikzpicture}
\tkzDefPoints{1/1/A,0/0/B,1/0/C}
\tkzDrawPoints(A,B,C)
\tkzDrawSegments(A,B B,C)
\tkzLabelPoint[above](A){A}\tkzLabelPoint[left](B){B} \tkzLabelPoint[right](C){C}
\tkzMarkAngle[size=0.5](C,B,A)
\end{tikzpicture}
\end{document}