4

I have to draw an angle like this picture. I would like to know how can i add a color inside the angle, like the second one picture enter image description here

enter image description here

My code is:

\noindent\begin{tikzpicture}[> = stealth]
\draw[gray,step=1cm] (0,0) grid +(9cm,6cm);
    \draw[ultra thick,red, ->]  (1,4) -- node[above] {\Large $\vec{c}$} +(2,1);
    \draw[ultra thick,blue,->]  (1,4) -- node[below left] {\Large $\vec{d}$} +(4,0);

    \draw[ultra thick,black,|-|] (3,1) -- node[below] {\Large $u$} +(1,0);
\end{tikzpicture}

1 Answer 1

11

You can use the angle pic defined by the angles library, along with the quotes syntax.

enter image description here

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{angles,quotes}
\begin{document}
\begin{tikzpicture}[> = stealth]
\coordinate (a) at (1,4);
\coordinate (b) at (3,5);
\coordinate (c) at (5,4);

\draw[gray,step=1cm] (0,0) grid +(9cm,6cm);
\draw pic[draw,fill=green!30,angle radius=1cm,"$\alpha$" shift={(6mm,1mm)}] {angle=c--a--b};
\draw pic[draw,fill=blue!30,angle radius=0.7cm,"$\epsilon$" shift={(-3mm,5mm)}] {angle=b--a--c};

\draw[ultra thick,red, ->]  (a) -- node[above] {\Large $\vec{c}$} (b);
\draw[ultra thick,blue,->]  (a) -- node[below left] {\Large $\vec{d}$} (c);
\end{tikzpicture}
\end{document}

Here's a version without said libraries. I can't really remember if this works properly in PGF 2.10, but you can try. I would recommend upgrading though.

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[> = stealth]
\coordinate (a) at (1,4);
\coordinate (b) at (3,5);
\coordinate (c) at (5,4);

\draw[gray,step=1cm] (0,0) grid +(9cm,6cm);

\draw [fill=green!30] (a) -- ++(1cm,0) arc(0:{atan(1/2)}:1cm) node[midway,right] {$\alpha$} -- cycle;
\draw [fill=blue!30] (a) -- ++(0.6cm,0) arc(0:{-360+atan(1/2)}:0.6cm) node[pos=0.6,left]{$\epsilon$} -- cycle;

\draw[ultra thick,red, ->]  (a) -- node[above] {\Large $\vec{c}$} (b);
\draw[ultra thick,blue,->]  (a) -- node[below left] {\Large $\vec{d}$} (c);
\end{tikzpicture}
\end{document}
3
  • 1
    sorry but there is an error "I can't find file `tikzlibraryangles.code.tex' \usetikzlibrary{angles,quotes} Emergency stop \usetikzlibrary{angles,quotes}"
    – ryuk
    Nov 14, 2015 at 21:03
  • @ryuk Right, perhaps you have version 2.1 of pgf/TikZ, those libraries were introduced in version 3. I can add a version not using those libraries. Nov 14, 2015 at 21:09
  • @ryuk Try the new one. As I say, upgrading is recommended. Nov 14, 2015 at 21:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .