3

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

  • 1
    Don't you need the quotes library for that syntax for the pic? – Loop Space May 8 '14 at 4:59
  • @AndrewStacey the example in the manual didn't say to load it. – dustin May 8 '14 at 5:00
  • @dustin With double quotes (" instead of ''), you can't receive the same message! – Paul Gaborit May 8 '14 at 9:20
  • 1
    Without the quotes library, you can try to use pic text=$\theta$ instead of "$theta". – Paul Gaborit May 8 '14 at 9:27
  • 2
    @dustin I've just looked at your video. The double quotes look like doubled quotes to me. It looks as though you are using Emacs (bonus points for that!). Emacs tries to be clever and when you type " on your keyboard then it translates it to two single quotes (either opening or closing) as that is what LaTeX wants. Try typing " twice. The second time, Emacs will replace the doubled single quotes with a single double quote. – Loop Space May 8 '14 at 18:31
4

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

  • I receive the same message even with the quotes library and the double quotes around \theta. – dustin May 8 '14 at 5:13
  • @dustin Works for me with latest miktex. – user11232 May 8 '14 at 5:56
2

If including the quotes library still didn't do the trick, I suggest loading the babel library as it is proposed here. I had the exact same problem and it did the trick for me.

\usetikzlibrary{angles,quotes}
\usetikzlibrary{babel}
  • This is not an answer: (i) the user11232 work as expected (ii) babel library is helpfull if your document language is not English (most of non English babel redefine ", so library quotes can not recognize them). Please consider rewrote your answer. – Zarko Feb 7 '17 at 15:50
1

Using quote library in documents with some not English languages has problem with their babels redefinition of ''. For example (slightly modified user11232 answer):

\documentclass[tikz, margin=3mm]{standalone}%
\usetikzlibrary{angles,
%                babel, % <-- example works if you enable this library
                calc,
                intersections,
                quotes}
\usepackage[slovene]{babel}
\begin{document}
    \begin{tikzpicture}[
              > = stealth,
   angle radius = 5mm,
my angle/.style = {draw, -latex,
                   angle eccentricity=1.3,
                   font=\large} % angle label position!
                        ]
\draw   (0,0) coordinate (O) -- 
        (4,0) coordinate (P1);
\draw[very thin, dashed, name path = para] (-1,-2.5) parabola bend (2,2) (4,0);
\draw[very thin, name path = circ] (O) circle[radius = .75bp];
%
\path[name intersections = {of = para and circ, by={A,B}}];
%
\draw[-latex, red] (A) -- ($(B)!1cm!(A)$) coordinate (P2);
%
\path (P1) -- (O) -- (P2) 
    pic[my angle,"$\theta$"] {angle = P1--O--P2};
\end{tikzpicture}
\end{document}

gives error:

! Argument of \language@active@arg" has an extra }.
<inserted text> 
                \par 
l.26     pic[my angle,"$\theta$"]
                                  {angle = P1--O--P2};
? x

which in case, if I enable babel library in preamble of above MWE, disappear and gives the following result:

enter image description here

Let me noted, that this problem has been discussed in many questions/answers here. Also, the OP MWE is calculation very demanding it it take a while to give result. For its problem exist better approaches (but this is not a question here).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.