newcommand inside a tikz node

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












In this example



documentclass[tikz,border=5pt]standalone
usetikzlibraryshapes.misc, positioning, calc
newcommandelement[1][draw, rectangle] #1
usepackagetikz
begindocument
begintikzpicture
node [align=center](a)
[draw, rectangle]a;
node [align=center, anchor = north](b) at ($(a.south) + (0, -0.3)$)
[draw, rectangle]b;
node [align=center, anchor = west](c) at ($(a.east) + (0.3, 0)$)
elementc;

endtikzpicture
enddocument


at node c I try to use newcommand element that should construct node c in the same way as nodes a and b are constructed.



Is such an approach possible? Assume I need to construct multiple nodes in a repetitive and nontrivial way.










share|improve this question

























    up vote
    1
    down vote

    favorite












    In this example



    documentclass[tikz,border=5pt]standalone
    usetikzlibraryshapes.misc, positioning, calc
    newcommandelement[1][draw, rectangle] #1
    usepackagetikz
    begindocument
    begintikzpicture
    node [align=center](a)
    [draw, rectangle]a;
    node [align=center, anchor = north](b) at ($(a.south) + (0, -0.3)$)
    [draw, rectangle]b;
    node [align=center, anchor = west](c) at ($(a.east) + (0.3, 0)$)
    elementc;

    endtikzpicture
    enddocument


    at node c I try to use newcommand element that should construct node c in the same way as nodes a and b are constructed.



    Is such an approach possible? Assume I need to construct multiple nodes in a repetitive and nontrivial way.










    share|improve this question























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      In this example



      documentclass[tikz,border=5pt]standalone
      usetikzlibraryshapes.misc, positioning, calc
      newcommandelement[1][draw, rectangle] #1
      usepackagetikz
      begindocument
      begintikzpicture
      node [align=center](a)
      [draw, rectangle]a;
      node [align=center, anchor = north](b) at ($(a.south) + (0, -0.3)$)
      [draw, rectangle]b;
      node [align=center, anchor = west](c) at ($(a.east) + (0.3, 0)$)
      elementc;

      endtikzpicture
      enddocument


      at node c I try to use newcommand element that should construct node c in the same way as nodes a and b are constructed.



      Is such an approach possible? Assume I need to construct multiple nodes in a repetitive and nontrivial way.










      share|improve this question













      In this example



      documentclass[tikz,border=5pt]standalone
      usetikzlibraryshapes.misc, positioning, calc
      newcommandelement[1][draw, rectangle] #1
      usepackagetikz
      begindocument
      begintikzpicture
      node [align=center](a)
      [draw, rectangle]a;
      node [align=center, anchor = north](b) at ($(a.south) + (0, -0.3)$)
      [draw, rectangle]b;
      node [align=center, anchor = west](c) at ($(a.east) + (0.3, 0)$)
      elementc;

      endtikzpicture
      enddocument


      at node c I try to use newcommand element that should construct node c in the same way as nodes a and b are constructed.



      Is such an approach possible? Assume I need to construct multiple nodes in a repetitive and nontrivial way.







      tikz-pgf macros nodes






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 3 hours ago









      Viesturs

      1,2452921




      1,2452921




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          4
          down vote













          Perhaps you should define a tikz style for nodes:



          for one argument



          documentclass[tikz,border=5pt]standalone

          usetikzlibraryshapes.misc, positioning, calc
          usepackagetikz
          tikzset
          element/.style=draw,rectangle,node contents=#1
          begindocument
          begintikzpicture
          node [align=center](a)
          [draw, rectangle]a;
          node [align=center, anchor = north](b) at ($(a.south) + (0, -0.3)$)
          [draw, rectangle]b;
          node [align=center, anchor = west,element=c,at=($(a.east) + (0.3, 0)$)] ;

          endtikzpicture

          enddocument


          for 3 arguments



          documentclass[tikz,border=5pt]standalone

          usetikzlibraryshapes.misc, positioning, calc
          usepackagetikz
          tikzset
          element/.style n args=3draw=#2,shape=#3,node contents=#1
          begindocument
          begintikzpicture
          node [align=center](a)
          [draw, rectangle]a;
          node [align=center, anchor = north](b) at ($(a.south) + (0, -0.3)$)
          [draw, rectangle]b;
          node [align=center, anchor = west,element=cbluerectangle,name=c,at=($(a.east) + (0.3, 0)$)] ;

          endtikzpicture
          enddocument





          share|improve this answer






















          • How to change element=c if I have more than 1 argument to element?
            – Viesturs
            2 hours ago










          • I will reedit my answer considering your new requirement soon
            – Hafid Boukhoulda
            1 hour ago










          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',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          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%2f453575%2fnewcommand-inside-a-tikz-node%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          4
          down vote













          Perhaps you should define a tikz style for nodes:



          for one argument



          documentclass[tikz,border=5pt]standalone

          usetikzlibraryshapes.misc, positioning, calc
          usepackagetikz
          tikzset
          element/.style=draw,rectangle,node contents=#1
          begindocument
          begintikzpicture
          node [align=center](a)
          [draw, rectangle]a;
          node [align=center, anchor = north](b) at ($(a.south) + (0, -0.3)$)
          [draw, rectangle]b;
          node [align=center, anchor = west,element=c,at=($(a.east) + (0.3, 0)$)] ;

          endtikzpicture

          enddocument


          for 3 arguments



          documentclass[tikz,border=5pt]standalone

          usetikzlibraryshapes.misc, positioning, calc
          usepackagetikz
          tikzset
          element/.style n args=3draw=#2,shape=#3,node contents=#1
          begindocument
          begintikzpicture
          node [align=center](a)
          [draw, rectangle]a;
          node [align=center, anchor = north](b) at ($(a.south) + (0, -0.3)$)
          [draw, rectangle]b;
          node [align=center, anchor = west,element=cbluerectangle,name=c,at=($(a.east) + (0.3, 0)$)] ;

          endtikzpicture
          enddocument





          share|improve this answer






















          • How to change element=c if I have more than 1 argument to element?
            – Viesturs
            2 hours ago










          • I will reedit my answer considering your new requirement soon
            – Hafid Boukhoulda
            1 hour ago














          up vote
          4
          down vote













          Perhaps you should define a tikz style for nodes:



          for one argument



          documentclass[tikz,border=5pt]standalone

          usetikzlibraryshapes.misc, positioning, calc
          usepackagetikz
          tikzset
          element/.style=draw,rectangle,node contents=#1
          begindocument
          begintikzpicture
          node [align=center](a)
          [draw, rectangle]a;
          node [align=center, anchor = north](b) at ($(a.south) + (0, -0.3)$)
          [draw, rectangle]b;
          node [align=center, anchor = west,element=c,at=($(a.east) + (0.3, 0)$)] ;

          endtikzpicture

          enddocument


          for 3 arguments



          documentclass[tikz,border=5pt]standalone

          usetikzlibraryshapes.misc, positioning, calc
          usepackagetikz
          tikzset
          element/.style n args=3draw=#2,shape=#3,node contents=#1
          begindocument
          begintikzpicture
          node [align=center](a)
          [draw, rectangle]a;
          node [align=center, anchor = north](b) at ($(a.south) + (0, -0.3)$)
          [draw, rectangle]b;
          node [align=center, anchor = west,element=cbluerectangle,name=c,at=($(a.east) + (0.3, 0)$)] ;

          endtikzpicture
          enddocument





          share|improve this answer






















          • How to change element=c if I have more than 1 argument to element?
            – Viesturs
            2 hours ago










          • I will reedit my answer considering your new requirement soon
            – Hafid Boukhoulda
            1 hour ago












          up vote
          4
          down vote










          up vote
          4
          down vote









          Perhaps you should define a tikz style for nodes:



          for one argument



          documentclass[tikz,border=5pt]standalone

          usetikzlibraryshapes.misc, positioning, calc
          usepackagetikz
          tikzset
          element/.style=draw,rectangle,node contents=#1
          begindocument
          begintikzpicture
          node [align=center](a)
          [draw, rectangle]a;
          node [align=center, anchor = north](b) at ($(a.south) + (0, -0.3)$)
          [draw, rectangle]b;
          node [align=center, anchor = west,element=c,at=($(a.east) + (0.3, 0)$)] ;

          endtikzpicture

          enddocument


          for 3 arguments



          documentclass[tikz,border=5pt]standalone

          usetikzlibraryshapes.misc, positioning, calc
          usepackagetikz
          tikzset
          element/.style n args=3draw=#2,shape=#3,node contents=#1
          begindocument
          begintikzpicture
          node [align=center](a)
          [draw, rectangle]a;
          node [align=center, anchor = north](b) at ($(a.south) + (0, -0.3)$)
          [draw, rectangle]b;
          node [align=center, anchor = west,element=cbluerectangle,name=c,at=($(a.east) + (0.3, 0)$)] ;

          endtikzpicture
          enddocument





          share|improve this answer














          Perhaps you should define a tikz style for nodes:



          for one argument



          documentclass[tikz,border=5pt]standalone

          usetikzlibraryshapes.misc, positioning, calc
          usepackagetikz
          tikzset
          element/.style=draw,rectangle,node contents=#1
          begindocument
          begintikzpicture
          node [align=center](a)
          [draw, rectangle]a;
          node [align=center, anchor = north](b) at ($(a.south) + (0, -0.3)$)
          [draw, rectangle]b;
          node [align=center, anchor = west,element=c,at=($(a.east) + (0.3, 0)$)] ;

          endtikzpicture

          enddocument


          for 3 arguments



          documentclass[tikz,border=5pt]standalone

          usetikzlibraryshapes.misc, positioning, calc
          usepackagetikz
          tikzset
          element/.style n args=3draw=#2,shape=#3,node contents=#1
          begindocument
          begintikzpicture
          node [align=center](a)
          [draw, rectangle]a;
          node [align=center, anchor = north](b) at ($(a.south) + (0, -0.3)$)
          [draw, rectangle]b;
          node [align=center, anchor = west,element=cbluerectangle,name=c,at=($(a.east) + (0.3, 0)$)] ;

          endtikzpicture
          enddocument






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 1 hour ago

























          answered 2 hours ago









          Hafid Boukhoulda

          714313




          714313











          • How to change element=c if I have more than 1 argument to element?
            – Viesturs
            2 hours ago










          • I will reedit my answer considering your new requirement soon
            – Hafid Boukhoulda
            1 hour ago
















          • How to change element=c if I have more than 1 argument to element?
            – Viesturs
            2 hours ago










          • I will reedit my answer considering your new requirement soon
            – Hafid Boukhoulda
            1 hour ago















          How to change element=c if I have more than 1 argument to element?
          – Viesturs
          2 hours ago




          How to change element=c if I have more than 1 argument to element?
          – Viesturs
          2 hours ago












          I will reedit my answer considering your new requirement soon
          – Hafid Boukhoulda
          1 hour ago




          I will reedit my answer considering your new requirement soon
          – Hafid Boukhoulda
          1 hour ago

















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f453575%2fnewcommand-inside-a-tikz-node%23new-answer', 'question_page');

          );

          Post as a guest













































































          Comments

          Popular posts from this blog

          What does second last employer means? [closed]

          List of Gilmore Girls characters

          One-line joke