Arrow and label positing in a .pic using tikz












2















I am trying to draw a figure, which repeatedly contains a similar type of pictures. Hence I am using .pic provided by tikz in the following way:



documentclass[tikz, border=2px]{standalone}
usetikzlibrary{arrows.meta, bending, shapes.misc, shapes.geometric}

% define colors and other constants
colorlet{line color}{black!30}
defline thickness{1pt}

% define primitive shapes for the drawing
tikzset{
line/.style={
-, draw=line color, line width=line thickness},
z plus joint/.pic={
draw[black, line width=line thickness, fill=gray!50] (0,0)
circle (0.5);
draw[black, line width=line thickness, fill=white] (0,0) circle (0.3);
draw[line width=2pt, red, -{Triangle[bend, length=6pt, width=8pt]}]
(270:0.4) arc (270:150:0.4);
draw[latex-,blue, shorten <=2pt] (-0.5, 0.5) -- ++ (-0.5, 0.5)
node[above=2pt, black]{#1};
},
z minus joint/.pic={
pic[yscale=-1, rotate=180] {z plus joint=#1};},
}


begin{document}
begin{tikzpicture}[node distance=2cm]
path[line] (0, 0) pic {z plus joint=1} --
(2, 0) pic {z minus joint=3} --
(4, 0) pic {z minus joint=2} --
(4, 2) pic {z plus joint=4} --
(4, 4) pic {z minus joint=6};
end{tikzpicture}
end{document}


Please see below the generated figure:



enter image description here



I need the following two types of orientation for arrows:




  • Left side titled arrow

  • Right side titled arrow


I am looking for a way to provide an extra argument to the pic which can decide the orientation of the arrow. For example, see the following pseudo code:



begin{tikzpicture}[node distance=2cm]
path[line] (0, 0) pic {z plus joint={1}{right}} --
(2, 0) pic {z minus joint={3}{right}} --
(4, 0) pic {z minus joint={2}{left}} --
(4, 2) pic {z plus joint={4}{left}} --
(4, 4) pic {z minus joint={6}{left}};
end{tikzpicture}


PS: Since the orientation has only two possible values, i.e., left and right, we can have left as default









share



























    2















    I am trying to draw a figure, which repeatedly contains a similar type of pictures. Hence I am using .pic provided by tikz in the following way:



    documentclass[tikz, border=2px]{standalone}
    usetikzlibrary{arrows.meta, bending, shapes.misc, shapes.geometric}

    % define colors and other constants
    colorlet{line color}{black!30}
    defline thickness{1pt}

    % define primitive shapes for the drawing
    tikzset{
    line/.style={
    -, draw=line color, line width=line thickness},
    z plus joint/.pic={
    draw[black, line width=line thickness, fill=gray!50] (0,0)
    circle (0.5);
    draw[black, line width=line thickness, fill=white] (0,0) circle (0.3);
    draw[line width=2pt, red, -{Triangle[bend, length=6pt, width=8pt]}]
    (270:0.4) arc (270:150:0.4);
    draw[latex-,blue, shorten <=2pt] (-0.5, 0.5) -- ++ (-0.5, 0.5)
    node[above=2pt, black]{#1};
    },
    z minus joint/.pic={
    pic[yscale=-1, rotate=180] {z plus joint=#1};},
    }


    begin{document}
    begin{tikzpicture}[node distance=2cm]
    path[line] (0, 0) pic {z plus joint=1} --
    (2, 0) pic {z minus joint=3} --
    (4, 0) pic {z minus joint=2} --
    (4, 2) pic {z plus joint=4} --
    (4, 4) pic {z minus joint=6};
    end{tikzpicture}
    end{document}


    Please see below the generated figure:



    enter image description here



    I need the following two types of orientation for arrows:




    • Left side titled arrow

    • Right side titled arrow


    I am looking for a way to provide an extra argument to the pic which can decide the orientation of the arrow. For example, see the following pseudo code:



    begin{tikzpicture}[node distance=2cm]
    path[line] (0, 0) pic {z plus joint={1}{right}} --
    (2, 0) pic {z minus joint={3}{right}} --
    (4, 0) pic {z minus joint={2}{left}} --
    (4, 2) pic {z plus joint={4}{left}} --
    (4, 4) pic {z minus joint={6}{left}};
    end{tikzpicture}


    PS: Since the orientation has only two possible values, i.e., left and right, we can have left as default









    share

























      2












      2








      2


      1






      I am trying to draw a figure, which repeatedly contains a similar type of pictures. Hence I am using .pic provided by tikz in the following way:



      documentclass[tikz, border=2px]{standalone}
      usetikzlibrary{arrows.meta, bending, shapes.misc, shapes.geometric}

      % define colors and other constants
      colorlet{line color}{black!30}
      defline thickness{1pt}

      % define primitive shapes for the drawing
      tikzset{
      line/.style={
      -, draw=line color, line width=line thickness},
      z plus joint/.pic={
      draw[black, line width=line thickness, fill=gray!50] (0,0)
      circle (0.5);
      draw[black, line width=line thickness, fill=white] (0,0) circle (0.3);
      draw[line width=2pt, red, -{Triangle[bend, length=6pt, width=8pt]}]
      (270:0.4) arc (270:150:0.4);
      draw[latex-,blue, shorten <=2pt] (-0.5, 0.5) -- ++ (-0.5, 0.5)
      node[above=2pt, black]{#1};
      },
      z minus joint/.pic={
      pic[yscale=-1, rotate=180] {z plus joint=#1};},
      }


      begin{document}
      begin{tikzpicture}[node distance=2cm]
      path[line] (0, 0) pic {z plus joint=1} --
      (2, 0) pic {z minus joint=3} --
      (4, 0) pic {z minus joint=2} --
      (4, 2) pic {z plus joint=4} --
      (4, 4) pic {z minus joint=6};
      end{tikzpicture}
      end{document}


      Please see below the generated figure:



      enter image description here



      I need the following two types of orientation for arrows:




      • Left side titled arrow

      • Right side titled arrow


      I am looking for a way to provide an extra argument to the pic which can decide the orientation of the arrow. For example, see the following pseudo code:



      begin{tikzpicture}[node distance=2cm]
      path[line] (0, 0) pic {z plus joint={1}{right}} --
      (2, 0) pic {z minus joint={3}{right}} --
      (4, 0) pic {z minus joint={2}{left}} --
      (4, 2) pic {z plus joint={4}{left}} --
      (4, 4) pic {z minus joint={6}{left}};
      end{tikzpicture}


      PS: Since the orientation has only two possible values, i.e., left and right, we can have left as default









      share














      I am trying to draw a figure, which repeatedly contains a similar type of pictures. Hence I am using .pic provided by tikz in the following way:



      documentclass[tikz, border=2px]{standalone}
      usetikzlibrary{arrows.meta, bending, shapes.misc, shapes.geometric}

      % define colors and other constants
      colorlet{line color}{black!30}
      defline thickness{1pt}

      % define primitive shapes for the drawing
      tikzset{
      line/.style={
      -, draw=line color, line width=line thickness},
      z plus joint/.pic={
      draw[black, line width=line thickness, fill=gray!50] (0,0)
      circle (0.5);
      draw[black, line width=line thickness, fill=white] (0,0) circle (0.3);
      draw[line width=2pt, red, -{Triangle[bend, length=6pt, width=8pt]}]
      (270:0.4) arc (270:150:0.4);
      draw[latex-,blue, shorten <=2pt] (-0.5, 0.5) -- ++ (-0.5, 0.5)
      node[above=2pt, black]{#1};
      },
      z minus joint/.pic={
      pic[yscale=-1, rotate=180] {z plus joint=#1};},
      }


      begin{document}
      begin{tikzpicture}[node distance=2cm]
      path[line] (0, 0) pic {z plus joint=1} --
      (2, 0) pic {z minus joint=3} --
      (4, 0) pic {z minus joint=2} --
      (4, 2) pic {z plus joint=4} --
      (4, 4) pic {z minus joint=6};
      end{tikzpicture}
      end{document}


      Please see below the generated figure:



      enter image description here



      I need the following two types of orientation for arrows:




      • Left side titled arrow

      • Right side titled arrow


      I am looking for a way to provide an extra argument to the pic which can decide the orientation of the arrow. For example, see the following pseudo code:



      begin{tikzpicture}[node distance=2cm]
      path[line] (0, 0) pic {z plus joint={1}{right}} --
      (2, 0) pic {z minus joint={3}{right}} --
      (4, 0) pic {z minus joint={2}{left}} --
      (4, 2) pic {z plus joint={4}{left}} --
      (4, 4) pic {z minus joint={6}{left}};
      end{tikzpicture}


      PS: Since the orientation has only two possible values, i.e., left and right, we can have left as default







      tikz-pgf





      share












      share










      share



      share










      asked 9 mins ago









      Ravi JoshiRavi Joshi

      6821816




      6821816






















          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%2f478537%2farrow-and-label-positing-in-a-pic-using-tikz%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%2f478537%2farrow-and-label-positing-in-a-pic-using-tikz%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)