我想让 TikZ 在笛卡尔平面上绘制一个三角形 - 一个顶点位于原点 O、A = (2,1) 和 B = (-3, 5) 的三角形。我还想绘制并标记两个角度 - 一个从正 x 轴到 OA,一个从正 x 轴到 OB。我希望角度在与 OA 和 OB 相切的地方有箭头。我还想在序言中保留“\documentclass{amsart}”。
答案1
使用两种简单的可能性TikZ
:
对于版本 3.0,使用
angles
和quotes
库:代码:
\documentclass{article} \usepackage{tikz} \usetikzlibrary{angles,quotes} \tikzset{ mydot/.style={ fill, circle, inner sep=1.5pt } } \begin{document} \begin{tikzpicture}[>=latex] % the coordinates of the vertices \coordinate (O) at (0,0); \coordinate (A) at (2,1); \coordinate (B) at (-3,5); \coordinate (E) at (2,0); % the axis \draw[help lines,->] (-3.5,0) -- (2.5,0); \draw[help lines,->] (0,-0.5) -- (0,5.5); % the edges of the triangle \draw (O) -- (A) -- (B) -- cycle; % labelling the vertices \node[mydot,label={right:$A$}] at (A) {}; \node[mydot,label={left:$B$}] at (B) {}; \node[mydot,label={below:$O$}] at (O) {}; % the arcs for the angles \path[gray] pic["$\alpha$" shift={(23pt,3pt)},draw,->,angle radius=1.5cm] {angle = E--O--A} pic["$\beta$" above=6pt,draw,->,angle radius=0.75cm] {angle = E--O--B}; \end{tikzpicture} \end{document}
对于版本 2.10,不带库并使用
arc
路径:代码:
\documentclass{amsart} \usepackage{tikz} \tikzset{ mydot/.style={ fill, circle, inner sep=1.5pt } } \begin{document} \begin{tikzpicture}[>=latex] % the coordinates of the vertices \coordinate (O) at (0,0); \coordinate (A) at (2,1); \coordinate (B) at (-3,5); % the axis \draw[help lines,->] (-3.5,0) -- (2.5,0); \draw[help lines,->] (0,-0.5) -- (0,5.5); % the edges of the triangle \draw (O) -- (A) -- (B) -- cycle; % labelling the vertices \node[mydot,label={right:$A$}] at (A) {}; \node[mydot,label={left:$B$}] at (B) {}; \node[mydot,label={below:$O$}] at (O) {}; % the arcs for the angles \begin{scope}[gray] \draw[->] (1,0) +(0:0.5cm) arc [radius=1cm,start angle=0,end angle=41] node[midway,right] {$\alpha$}; \draw[->] (0.5,0) +(0:0.25cm) arc [radius=0.75cm,start angle=0,end angle=122] node[midway,above] {$\beta$}; \end{scope} \end{tikzpicture} \end{document}