4

I am trying to access a node defined inside a pic definition outside its scope. I found this example in the PGF manual v3.0.1a on page 254. The example given is as follows.

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
    \tikzset{
        seagull/.pic={
            % Code for a "seagull". Do you see it?...
            \coordinate (-left wing) at (-3mm,0);
            \coordinate (-head) at (0,0);
            \coordinate (-right wing) at (3mm,0);
            \draw (-left wing) to [bend left] (0,0) (-head) to [bend left] (-right wing);
        }
    }
    \tikz {
        \pic (Emma) {seagull};
        \pic (Alexandra) at (0,1) {seagull};
        \draw (Emma-left wing) -- (Alexandra-right wing);
    }
\end{document}

But I get an error on compiling: No shape named EmmaEmma-leftwing is known. Does anyone know what's wrong in this code and how one can access nodes defined inside a pic outside their scope.

  • The bug was also reported at https://sourceforge.net/p/pgf/bugs/398/ – Torbjørn T. Jun 18 '17 at 11:00
  • Another possible workaround is to do drawing and coordinate definition in the same path, i.e. \draw (-3mm,0) coordinate (-left wing) to [bend left] (0,0) coordinate (-head) to [bend left] (3mm,0) coordinate (-right wing); – Torbjørn T. Jun 18 '17 at 11:05
  • I totally missed that someone had already asked the exact same question. It seems there isn't a comprehensive solution yet. I took your suggestion to draw the paths and define coordinates outside of the pic environment. – scorpionwars Jun 19 '17 at 21:15
  • If you're referring to my comment, that wasn't what I meant. I meant that if you put that code in a pic, it works. Edit: In other words: seagull/.pic={ \draw (-3mm,0) coordinate (-left wing) to [bend left] (0,0) coordinate (-head) to [bend left] (3mm,0) coordinate (-right wing); } – Torbjørn T. Jun 19 '17 at 21:27
  • Ah! I missed that part and yeah, it does work if you combine the coordinate and path definitions together in one statement. I am still not entirely sure why but I will take the workaround. Thanks! – scorpionwars Jun 20 '17 at 18:49

0 Answers0