TikZ Angles – Using the Angles Library in TikZ

tikz-anglestikz-pgf

I am trying to use the angles library, but I am not sure how to apply it when the nodes were specified from other methods.

In the examples, the drawing of the vectors and naming of the nodes happens on the same draw command that issue the angles command.

\documentclass[tikz]{standalone}%

\usetikzlibrary{calc}
\usetikzlibrary{intersections}
\usetikzlibrary{angles}

\begin{document}
\begin{tikzpicture}
  \coordinate (O) at (0, 0);

  \path[name path = para] (-1, -2.5) parabola bend (2, 2) (4, 0);

  \draw (O) -- (5, 0) coordinate (P1);

  \path[name path = circ] (O) circle[radius = .75bp];
  \path[name intersections = {of = para and circ}];

  \coordinate (A) at (intersection-1);
  \coordinate (B) at (intersection-2);

  \draw[-latex, red] (A) -- ($(B)!1cm!(A)$) coordinate (P2);

  \path (P1) -- (O) -- (P2)
  pic[''$\theta$'', draw, -latex, red, angle radius = .5cm,
  angle eccentricity = 1.2] {angle = P1--O--P2};
\end{tikzpicture}
\end{document}

It is telling me theta isn't a color.


Even if I load the quotes library and put double quotes around \theta as Harish Kumar has answered, I still receive the message:

! Missing \endcsname inserted.
<to be read again>
                   \theta
l.41   angle eccentricity = 1.2, font = \tiny]
                                               {angle = P1--O--P2};
! Missing \endcsname inserted.

 ...

l.41 ...y = 1.2, font = \tiny] {angle = P1--O--P2}
                                                  ;

! Package xcolor Error: Undefined color ```$\theta $'''.

For those who don't believe me that double quotes are causing the same problem, I narrated a video for you showing that this is the case.

https://www.dropbox.com/s/44zhedz2psg1vrk/2014-05-08%2018.08.46.mp4

Best Answer

You need to load quotes library to use quotes syntax. This enables the quotes syntax for labels, pins, edge nodes, and pic texts.

Also, it is double quotes like "$\theta$" (not ''$\theta$''). Some editors (such as Emacs) automatically convert " to `` or '' (depending on whether they are inserted at the start or end of a word) since that produces the right output after compiling the document. In this case, however, we want actual double quotes. To type these in Emacs, simply hit the double quote key twice in succession. The second one will convert the previously inserted two single quotes into a single double quote which is what is needed here.

\documentclass[tikz,varwidth]{standalone}%

\usetikzlibrary{calc}
\usetikzlibrary{intersections}
\usetikzlibrary{angles}
\usetikzlibrary{quotes}

\begin{document}
\begin{tikzpicture}
  \coordinate (O) at (0, 0);

  \path[name path = para] (-1, -2.5) parabola bend (2, 2) (4, 0);

  \draw (O) -- (5, 0) coordinate (P1);

  \path[name path = circ] (O) circle[radius = .75bp];
  \path[name intersections = {of = para and circ}];

  \coordinate (A) at (intersection-1);
  \coordinate (B) at (intersection-2);

  \draw[-latex, red] (A) -- ($(B)!1cm!(A)$) coordinate (P2);

  \path (P1) -- (O) -- (P2) pic["$\theta$", draw,-latex, red, angle radius = 0.5cm, angle eccentricity = 1.2] {angle = P1--O--P2};
\end{tikzpicture}
\end{document}

enter image description here