2

I've been trying for a while to get the angle working, but it's not displaying correctly. I get this instead:

enter image description here

The angle is not correctly labeled. I get the following error messages (all on that line):

Missing \endcsname inserted.

Package xcolor Error: Undefined color "$\theta $"'.

Missing \endcsname inserted. (again)

Runaway argument?

Package xcolor Error: Undefined color "$\theta $"'. (again)

Package xcolor Error: Undefined color "$\theta $"'. (again)

I have no idea how to solve this, the other page I looked at had this work, so I don't know what to do. Any help would be appreciated.

\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage[swedish]{babel}
\usepackage{amssymb}
\usepackage{tikz}
\usetikzlibrary{angles, quotes}

\begin{document}

\begin{figure}
    \caption{Enhetscirkeln}
    \label{Enhetscirkeln}
    \begin{center}
        \begin{tikzpicture}
            \coordinate (origo) at (0, 0);
            \draw[gray, thick] (origo) circle (50pt);
            \draw[black, thick] (origo) -- node[above, black, rotate = 30] {$r = 1$} (43.3pt, 25pt) node (r) {};
            \draw[gray, thin, ->] (origo) -- (75pt, 0)  node (x) {} node[below]  {$x$};
            \draw[gray, thin, ->] (origo) -- (-75pt, 0);
            \draw[gray, thin, ->] (origo) -- (0, -75pt);
            \draw[gray, thin, ->] (origo) -- (0, 75pt) node[right] {$y$};
            \pic [draw, ->, \dq$\theta$\dq, angle eccentricity=1.5] {angle = x--origo--r};
        \end{tikzpicture}
    \end{center}
\end{figure}


\end{document}
1
  • I do not know what \dq is - it is not working. quotes needs to be in quotes like this: \pic [draw, ->, "$\theta$", angle eccentricity=1.5] {angle = x--origo--r}; Aug 14, 2020 at 21:16

1 Answer 1

4

Try

\documentclass{book}
%\usepackage[utf8]{inputenc}
\usepackage[swedish]{babel}
\usepackage{amssymb}
\usepackage{tikz}
\usetikzlibrary{angles, quotes,
                babel} % <---

\begin{document}
\begin{figure}
    \caption{Enhetscirkeln}
    \label{Enhetscirkeln}
    \begin{center}
        \begin{tikzpicture}
            \coordinate (origo) at (0, 0);
            \draw[gray, thick] (origo) circle (50pt);
            \draw[black, thick] (origo) -- node[above, black, rotate = 30] {$r = 1$} (43.3pt, 25pt) node (r) {};
            \draw[gray, thin, ->] (origo) -- (75pt, 0)  node (x) {} node[below]  {$x$};
            \draw[gray, thin, ->] (origo) -- (-75pt, 0);
            \draw[gray, thin, ->] (origo) -- (0, -75pt);
            \draw[gray, thin, ->] (origo) -- (0, 75pt) node[right] {$y$};
            \pic [draw, ->, 
                  "$\theta$", % <---
                  angle eccentricity=1.5] {angle = x--origo--r};
        \end{tikzpicture}
    \end{center}
\end{figure}
\end{document}

Changes in comparison to your MWE (Minimal Working example) are marked by % <---.

Note:

  • package babel overwrite meaning of some code in tikz. This can be corrected by adding babel library to used TikZ libraries.
  • command \dq is not defined. In above MWE is replaced with " as is defined in quotes library.

enter image description here

1
  • Yes, this worked. Thank you very much.
    – Melvin
    Aug 14, 2020 at 21:46

You must log in to answer this question.

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