我能够用
\begin{tikzpicture}[thick]
\draw (0,0) -- (4,0) node[midway,below]{$f$} -- (4,2) node[midway,right]{$\frac{x}{2}$}-- cycle;
\end{tikzpicture}
现在我想标记三角形的左角,但我不知道该怎么做。
答案1
我的答案显示了如何标记顶点和角度。宏tikzAngleOfLine
没有优化
\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\newcommand{\tikzAngleOfLine}{\tikz@AngleOfLine}
\def\tikz@AngleOfLine(#1)(#2)#3{%
\pgfmathanglebetweenpoints{%
\pgfpointanchor{#1}{center}}{%
\pgfpointanchor{#2}{center}}
\pgfmathsetmacro{#3}{\pgfmathresult}%
}
\begin{tikzpicture}
\coordinate (A) at (1,1);
\coordinate (B) at ($(A)+(25:3)$);
\coordinate (C) at ($(A)+(100:5)$);
\draw (A) node[left]{$A$} -- (B) node[right]{$B$}node[midway,below]{$c$} -- (C)node[above]{$C$}node[midway,above]{$a$} -- (A)node[midway,left]{$b$};
\tikzAngleOfLine(A)(B){\AngleStart}
\tikzAngleOfLine(A)(C){\AngleEnd}
\draw[red,<->] (A)+(\AngleStart:2cm) arc (\AngleStart:\AngleEnd:2 cm);
\node[circle,fill=green] at ($(A)+({(\AngleStart+\AngleEnd)/2}:1 cm)$) {$\alpha$};
\end{tikzpicture}
\end{document}
答案2
以下是使用 TikZ 3.0 的解决方案:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{quotes,angles}
\begin{document}
\begin{tikzpicture}
\draw
(3,-1) coordinate (a) node[right] {a}
-- (0,0) coordinate (b) node[left] {b}
-- (2,2) coordinate (c) node[above right] {c}
pic["$\alpha$",draw=orange,<->,angle eccentricity=1.2,angle radius=1cm] {angle=a--b--c};
\end{tikzpicture}
\end{document}
答案3
我基于上述 Alain Matthes 的出色回答,定义了一个更直接的宏。我还提供了其用例的示例。
\newcommand{\tikzAngleOfLine}{\tikz@AngleOfLine}
\def\tikz@AngleOfLine(#1)(#2)#3{%
\pgfmathanglebetweenpoints{%
\pgfpointanchor{#1}{center}}{%
\pgfpointanchor{#2}{center}}
\pgfmathsetmacro{#3}{\pgfmathresult}%
}
\newcommand{\tikzMarkAngle}[3]{
\tikzAngleOfLine#1#2{\AngleStart}
\tikzAngleOfLine#1#3{\AngleEnd}
\draw #1+(\AngleStart:0.15cm) arc (\AngleStart:\AngleEnd:0.15cm);
}
\begin{tikzpicture}[scale=4,line width=1pt]
\coordinate (B) at (0,0);
\coordinate (C) at (1,0);
\coordinate (A) at (0.5,1.5);
\draw (A) -- (B) -- (C) -- cycle;
\node [below left] at (B) {B};
\node [below right] at (C) {C};
\node [above] at (A) {A};
\coordinate (D) at (barycentric cs:A=0.5 ,C=0.5);
\node [above right] at (D) {D};
\draw (B) -- (D);
\tikzAngleOfLine(A)(C){\AngleStart}
\tikzAngleOfLine(A)(B){\AngleEnd}
\draw (A)+(\AngleStart:0.15cm) arc (\AngleStart:\AngleEnd:0.15cm);
\tikzMarkAngle{(C)}{(B)}{(A)}
\tikzMarkAngle{(D)}{(A)}{(B)}
\end{tikzpicture}
以下是使用示例宏。
我还在下面提供了一个稍微更复杂的例子。
\newcommand{\tikzAngleOfLine}{\tikz@AngleOfLine}
\def\tikz@AngleOfLine(#1)(#2)#3{%
\pgfmathanglebetweenpoints{%
\pgfpointanchor{#1}{center}}{%
\pgfpointanchor{#2}{center}}
\pgfmathsetmacro{#3}{\pgfmathresult}%
}
\newcommand{\tikzMarkAngle}[4][0.15cm]{
\tikzAngleOfLine#2#3{\AngleStart}
\tikzAngleOfLine#2#4{\AngleEnd}
\draw[<->] #2+(\AngleStart:#1) arc (\AngleStart:\AngleEnd:#1);
}
\begin{tikzpicture}[scale=4,line width=1pt]
\coordinate (B) at (0,0);
\coordinate (C) at (1,0);
\coordinate (A) at (0.5,1.5);
\draw (A) -- (B) -- (C) -- cycle;
\node [below left] at (B) {B};
\node [below right] at (C) {C};
\node [above] at (A) {A};
\coordinate (D) at (barycentric cs:A=0.5 ,C=0.5);
\coordinate (E) at (barycentric cs:A=0.40 ,B=0.60);
\node [above right] at (D) {D};
\node [above left] at (E) {E};
\draw (B) -- (D);
\draw (C) -- (E);
\draw (E) -- (D);
\tikzMarkAngle{(A)}{(B)}{(C)}
\node at ($(A)+(-90:0.23)$) {$20^\circ$};
\tikzMarkAngle{(B)}{(D)}{(C)}
\node at ($(B)+(25:0.23)$) {$60^\circ$};
\tikzMarkAngle{(C)}{(B)}{(E)}
\node at ($(C)+(155:0.23)$) {$50^\circ$};
\begin{scope}[color=orange]
\tikzMarkAngle{(D)}{(E)}{(B)}
\node at ($(D)+(-20:0.15)$) {?=$30^\circ$};
\end{scope}
\tikzMarkAngle{(B)}{(A)}{(D)}
\node at ($(B)+(55:0.23)$) {$20^\circ$};
\tikzMarkAngle{(C)}{(E)}{(D)}
\node at ($(C)+(120:0.23)$) {$30^\circ$};
\coordinate (F) at (barycentric cs:A=0.50 ,B=0.50);
\node [above left] at (F) {F};
\draw (F) -- (D);
\draw (C) -- (F);
\coordinate (G) at (intersection of D--B and C--F);
\node [above] at (G) {G};
\draw (E) -- (G);
\begin{scope}[color=blue]
\tikzMarkAngle{(G)}{(F)}{(E)}
\node at ($(G)+(145:0.20)$) {$40^\circ$};
\tikzMarkAngle[0.07cm]{(F)}{(E)}{(G)}
\node at ($(F)+(-175:0.10)$) {$40^\circ$};
\tikzMarkAngle{(D)}{(A)}{(F)}
\node at ($(D)+(135:0.22)$) {$80^\circ$};
\end{scope}
\end{tikzpicture}
答案4
您可以在三角形的起始处插入一个节点,即(0,0)
,并在其左侧放置一个标签node[left]{$A$}
。完整示例:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[thick]
\draw (0,0) node[left]{$A$} -- (4,0) node[midway,below]{$f$} -- (4,2) node[midway,right]{$\frac{x}{2}$}-- cycle;
\end{tikzpicture}
\end{document}