Named paths inside a tikz/pic












0















I am trying to understand the naming behavior of paths inside a pic definition. Consider the following



documentclass{standalone}
usepackage{tikz}
usetikzlibrary{intersections}

tikzset{%
path1/.pic={%
coordinate (-p) at (-0.5,-0.5);
draw[red, name path=-horz-fails] (-1,0.5) to (1,0.5);
draw[black, name path=-vert] (0,-1) to (0,1);
};
}
tikzset{%
path2/.pic={%
draw[blue, name path=-horz] (-1,0) to (1,0);
};
}

begin{document}
begin{tikzpicture}
pic [name=p1] at (0, 0) {path1};
pic (p2) at (0, 0) {path2};
draw [name intersections={of=-vert and -horz}]
(intersection-1) circle (2pt) to (p1-p);
%draw [name intersections={of=-vert and -horz-fails}]
% (intersection-1) circle (2pt);
end{tikzpicture}
end{document}


In this example, all four lines are correctly drawn. Further, the uncommented intersection is correctly drawn; however, if I uncomment the second intersection, I get get the compiler error



! Package tikz Error: I do not know the path named `-horz-works'. Perhaps you 
misspelt it.


From my searches, I came across this question and the associated bug report from the answer. As with that answer, the last path named in the pic is available outside the definition. I thought this might be related, but I cloned the repository and tried compiling with the fix, but I still get the same result. I also tried to use name path .., but that did not make the path available in the main picture environment.



My question is: Is this a manifestation of the same bug? If not, what are the naming rules for paths inside a pic definition?



I notice that the coordinate (-p here) inherits the pic name outside scope of the pic as I expected and I would like to reference the path in the same manner.





Motivation



My ultimate goal is to draw a line to the intersection of two paths defined inside a generated pic. I have some Python code that generates the lines of latitude and longitude along a sphere. I would like to use the pic multiple times within a single picture; thus, I would like to refer to the paths with the parent pic name to compute only those intersections that will further what I am trying to show. Since I am computing the paths, I could define the coordinates of the intersections, but I would like to let TikZ do the job and that seems like overkill to me.










share|improve this question



























    0















    I am trying to understand the naming behavior of paths inside a pic definition. Consider the following



    documentclass{standalone}
    usepackage{tikz}
    usetikzlibrary{intersections}

    tikzset{%
    path1/.pic={%
    coordinate (-p) at (-0.5,-0.5);
    draw[red, name path=-horz-fails] (-1,0.5) to (1,0.5);
    draw[black, name path=-vert] (0,-1) to (0,1);
    };
    }
    tikzset{%
    path2/.pic={%
    draw[blue, name path=-horz] (-1,0) to (1,0);
    };
    }

    begin{document}
    begin{tikzpicture}
    pic [name=p1] at (0, 0) {path1};
    pic (p2) at (0, 0) {path2};
    draw [name intersections={of=-vert and -horz}]
    (intersection-1) circle (2pt) to (p1-p);
    %draw [name intersections={of=-vert and -horz-fails}]
    % (intersection-1) circle (2pt);
    end{tikzpicture}
    end{document}


    In this example, all four lines are correctly drawn. Further, the uncommented intersection is correctly drawn; however, if I uncomment the second intersection, I get get the compiler error



    ! Package tikz Error: I do not know the path named `-horz-works'. Perhaps you 
    misspelt it.


    From my searches, I came across this question and the associated bug report from the answer. As with that answer, the last path named in the pic is available outside the definition. I thought this might be related, but I cloned the repository and tried compiling with the fix, but I still get the same result. I also tried to use name path .., but that did not make the path available in the main picture environment.



    My question is: Is this a manifestation of the same bug? If not, what are the naming rules for paths inside a pic definition?



    I notice that the coordinate (-p here) inherits the pic name outside scope of the pic as I expected and I would like to reference the path in the same manner.





    Motivation



    My ultimate goal is to draw a line to the intersection of two paths defined inside a generated pic. I have some Python code that generates the lines of latitude and longitude along a sphere. I would like to use the pic multiple times within a single picture; thus, I would like to refer to the paths with the parent pic name to compute only those intersections that will further what I am trying to show. Since I am computing the paths, I could define the coordinates of the intersections, but I would like to let TikZ do the job and that seems like overkill to me.










    share|improve this question

























      0












      0








      0








      I am trying to understand the naming behavior of paths inside a pic definition. Consider the following



      documentclass{standalone}
      usepackage{tikz}
      usetikzlibrary{intersections}

      tikzset{%
      path1/.pic={%
      coordinate (-p) at (-0.5,-0.5);
      draw[red, name path=-horz-fails] (-1,0.5) to (1,0.5);
      draw[black, name path=-vert] (0,-1) to (0,1);
      };
      }
      tikzset{%
      path2/.pic={%
      draw[blue, name path=-horz] (-1,0) to (1,0);
      };
      }

      begin{document}
      begin{tikzpicture}
      pic [name=p1] at (0, 0) {path1};
      pic (p2) at (0, 0) {path2};
      draw [name intersections={of=-vert and -horz}]
      (intersection-1) circle (2pt) to (p1-p);
      %draw [name intersections={of=-vert and -horz-fails}]
      % (intersection-1) circle (2pt);
      end{tikzpicture}
      end{document}


      In this example, all four lines are correctly drawn. Further, the uncommented intersection is correctly drawn; however, if I uncomment the second intersection, I get get the compiler error



      ! Package tikz Error: I do not know the path named `-horz-works'. Perhaps you 
      misspelt it.


      From my searches, I came across this question and the associated bug report from the answer. As with that answer, the last path named in the pic is available outside the definition. I thought this might be related, but I cloned the repository and tried compiling with the fix, but I still get the same result. I also tried to use name path .., but that did not make the path available in the main picture environment.



      My question is: Is this a manifestation of the same bug? If not, what are the naming rules for paths inside a pic definition?



      I notice that the coordinate (-p here) inherits the pic name outside scope of the pic as I expected and I would like to reference the path in the same manner.





      Motivation



      My ultimate goal is to draw a line to the intersection of two paths defined inside a generated pic. I have some Python code that generates the lines of latitude and longitude along a sphere. I would like to use the pic multiple times within a single picture; thus, I would like to refer to the paths with the parent pic name to compute only those intersections that will further what I am trying to show. Since I am computing the paths, I could define the coordinates of the intersections, but I would like to let TikZ do the job and that seems like overkill to me.










      share|improve this question














      I am trying to understand the naming behavior of paths inside a pic definition. Consider the following



      documentclass{standalone}
      usepackage{tikz}
      usetikzlibrary{intersections}

      tikzset{%
      path1/.pic={%
      coordinate (-p) at (-0.5,-0.5);
      draw[red, name path=-horz-fails] (-1,0.5) to (1,0.5);
      draw[black, name path=-vert] (0,-1) to (0,1);
      };
      }
      tikzset{%
      path2/.pic={%
      draw[blue, name path=-horz] (-1,0) to (1,0);
      };
      }

      begin{document}
      begin{tikzpicture}
      pic [name=p1] at (0, 0) {path1};
      pic (p2) at (0, 0) {path2};
      draw [name intersections={of=-vert and -horz}]
      (intersection-1) circle (2pt) to (p1-p);
      %draw [name intersections={of=-vert and -horz-fails}]
      % (intersection-1) circle (2pt);
      end{tikzpicture}
      end{document}


      In this example, all four lines are correctly drawn. Further, the uncommented intersection is correctly drawn; however, if I uncomment the second intersection, I get get the compiler error



      ! Package tikz Error: I do not know the path named `-horz-works'. Perhaps you 
      misspelt it.


      From my searches, I came across this question and the associated bug report from the answer. As with that answer, the last path named in the pic is available outside the definition. I thought this might be related, but I cloned the repository and tried compiling with the fix, but I still get the same result. I also tried to use name path .., but that did not make the path available in the main picture environment.



      My question is: Is this a manifestation of the same bug? If not, what are the naming rules for paths inside a pic definition?



      I notice that the coordinate (-p here) inherits the pic name outside scope of the pic as I expected and I would like to reference the path in the same manner.





      Motivation



      My ultimate goal is to draw a line to the intersection of two paths defined inside a generated pic. I have some Python code that generates the lines of latitude and longitude along a sphere. I would like to use the pic multiple times within a single picture; thus, I would like to refer to the paths with the parent pic name to compute only those intersections that will further what I am trying to show. Since I am computing the paths, I could define the coordinates of the intersections, but I would like to let TikZ do the job and that seems like overkill to me.







      tikz-pgf intersections tikz-pic






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 14 mins ago









      Keith PrussingKeith Prussing

      13116




      13116






















          0






          active

          oldest

          votes











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "85"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f477963%2fnamed-paths-inside-a-tikz-pic%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f477963%2fnamed-paths-inside-a-tikz-pic%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

          Calculate evaluation metrics using cross_val_predict sklearn

          Insert data from modal to MySQL (multiple modal on website)