![不使用 xparse 包,使用两个可选参数作为角度标签](https://linux22.com/image/358707/%E4%B8%8D%E4%BD%BF%E7%94%A8%20xparse%20%E5%8C%85%EF%BC%8C%E4%BD%BF%E7%94%A8%E4%B8%A4%E4%B8%AA%E5%8F%AF%E9%80%89%E5%8F%82%E6%95%B0%E4%BD%9C%E4%B8%BA%E8%A7%92%E5%BA%A6%E6%A0%87%E7%AD%BE.png)
我想使用我的宏 \angs 来绘制角度标签。我首先尝试了以下代码,但存在一些问题。
\usetikzlibrary{quotes,angles}
\tikzset{
ar/.style={angle radius=#1},
ar/.default=0.65cm,
ae/.style={angle eccentricity=#1},
ae/.default=0.75,
}
\def\angs[#1,#2]#3#4{%
\draw pic[draw,angle radius=#1,"{\scriptsize $#4$}",angle eccentricity=#2] {angle = #3}
}
\begin{tikzpicture}
\coordinate[label=below:{\scriptsize $A$}] (A) at (0,0);
\coordinate[label=below:{\scriptsize $B$}] (B) at (2,0);
\coordinate[label=above:{\scriptsize $C$}] (C) at (3,2);
\draw (A) -- (B) -- (C);
%\draw pic[draw,angle radius=0.65cm,"{\scriptsize $120^{\circ}$}",angle eccentricity=0.5] {angle = C--B--A};
\angs[ar,ae]{A--B--C}{120^{\circ}};
\end{tikzpicture}
答案1
也许你想要类似
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{quotes,angles}
\tikzset{
ar/.style={angle radius=#1},
ar/.default=0.65cm,
ae/.style={angle eccentricity=#1},
ae/.default=0.75,
}
\newcommand{\angs}[3][]{%
\draw pic[ar,ae,#1,draw,"{\scriptsize $#3$}"] {angle = #2}
}
\begin{document}
\begin{tikzpicture}
\coordinate[label=below:{\scriptsize $A$}] (A) at (0,0);
\coordinate[label=below:{\scriptsize $B$}] (B) at (2,0);
\coordinate[label=above:{\scriptsize $C$}] (C) at (3,2);
\draw (A) -- (B) -- (C);
\angs[ar,ae]{A--B--C}{240^{\circ}};
\end{tikzpicture}
\begin{tikzpicture}
\coordinate[label=below:{\scriptsize $A$}] (A) at (0,0);
\coordinate[label=below:{\scriptsize $B$}] (B) at (2,0);
\coordinate[label=above:{\scriptsize $C$}] (C) at (3,2);
\draw (A) -- (B) -- (C);
\angs[ar=1cm,ae=.3]{A--B--C}{240^{\circ}};
\end{tikzpicture}
\end{document}