3

The following code gives No shape named S.corner 1 is known. error. What am I doing wrong?

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{angles}
\usetikzlibrary{shapes}
\usetikzlibrary{shapes.geometric}
\begin{document}
    \begin{tikzpicture}
        \node[name=S,regular polygon, regular polygon sides=9, draw, minimum width=6cm] at (0,0) {};
        \pic [draw, angle radius=.6cm] {angle = S.corner 1--S.corner 6--S.corner 5};
    \end{tikzpicture}
\end{document}
2
  • I don't know the \pic command, but \draw (S.corner 1) -- (S.corner 6); works fine with your example. Commented Mar 15, 2019 at 16:16
  • 1
    That's the standard problem that the angle construction adds point anchors center to the coordinates.
    – user121799
    Commented Mar 15, 2019 at 16:38

1 Answer 1

2

tikzlibraryangles.code.tex contains

\def\tikz@lib@rightangle@background#1--#2--#3\pgf@stop{%
  \path [name prefix ..] [pic actions, draw=none] (#2.center)
    -- ++(\tikz@start@angle@temp:\tikz@lib@angle@rad pt)
    -- ++(\tikz@end@angle@temp:\tikz@lib@angle@rad pt)
    -- ++(\tikz@start@angle@temp:-\tikz@lib@angle@rad pt)
    -- cycle;
}%

from which you see that it attaches .center to the second coordinate #2. This does not work if #2 is already an anchor. To work around this problem (rather than redefining \tikz@lib@rightangle@background and the other commands that attach .center), you may just define auxiliary coordinates.

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{angles}
\usetikzlibrary{shapes}
\usetikzlibrary{shapes.geometric}
\begin{document}
\begin{tikzpicture}
    \node[name=S,regular polygon, 
    regular polygon sides=9, draw, minimum width=6cm] at (0,0) {};
    \path foreach \X in {1,...,9} {(S.corner \X) coordinate (corner \X)};
    \pic [draw, angle radius=.6cm] {angle = corner 1--corner 6--corner 5};
\end{tikzpicture}
\end{document}

enter image description here

You must log in to answer this question.

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