TransWikia.com

Multiple bugs when trying to display angle

TeX - LaTeX Asked by Melvin on August 15, 2020

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}

One Answer

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

Correct answer by Zarko on August 15, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP