Automating setting node positions in foreach

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











up vote
1
down vote

favorite












Is there a way to automate setting nodes at the intervals of the foreach marks so they can be referred to, for drawing the braces; instead of defining their locations manually.



documentclassbeamer
beamertemplatenavigationsymbolsempty
usepackageverbatim
usepackagetikz
usepackagepgfplots
begindocument
beginframe[t]
frametitleci
begintikzpicture[scale=.9, transform shape]
pgfmathsetmacroincx.88
draw [thick,-] (0,0) -- +(0:8.8) node [pos=.146](a)a node [ pos=.296](b)b node [pos=.44](c)c node [pos=.586](d)d node [pos=.876](e)e node [pos=.73](f)f;
foreach x [evaluate=x as aff using int(x*1)]in 1,...,6draw [black, very thick] (incx*1.46*x,.2) -- +(-90:.4);
draw [blue, thick, decorate, decoration=brace,amplitude=.16cm,mirror] (b.center|-0,-.4) -- (d.center|-0,-.4) node [blue!80!black, midway, xshift=0cm, yshift=-.5cm] middle;
draw [blue, thick, decorate, decoration=brace,amplitude=.16cm] (a.center|-0,.4) -- (b.center|-0,.4) node [blue!80!black, midway, xshift=0cm, yshift=.5cm] series;
draw [blue, thick, decorate, decoration=brace,amplitude=.16cm,mirror] (e.center|-0,.4) -- (f.center|-0,.4) node [blue!80!black, midway, xshift=0cm, yshift=.5cm] draw;
endtikzpicture
endframe
enddocument


enter image description here










share|improve this question

























    up vote
    1
    down vote

    favorite












    Is there a way to automate setting nodes at the intervals of the foreach marks so they can be referred to, for drawing the braces; instead of defining their locations manually.



    documentclassbeamer
    beamertemplatenavigationsymbolsempty
    usepackageverbatim
    usepackagetikz
    usepackagepgfplots
    begindocument
    beginframe[t]
    frametitleci
    begintikzpicture[scale=.9, transform shape]
    pgfmathsetmacroincx.88
    draw [thick,-] (0,0) -- +(0:8.8) node [pos=.146](a)a node [ pos=.296](b)b node [pos=.44](c)c node [pos=.586](d)d node [pos=.876](e)e node [pos=.73](f)f;
    foreach x [evaluate=x as aff using int(x*1)]in 1,...,6draw [black, very thick] (incx*1.46*x,.2) -- +(-90:.4);
    draw [blue, thick, decorate, decoration=brace,amplitude=.16cm,mirror] (b.center|-0,-.4) -- (d.center|-0,-.4) node [blue!80!black, midway, xshift=0cm, yshift=-.5cm] middle;
    draw [blue, thick, decorate, decoration=brace,amplitude=.16cm] (a.center|-0,.4) -- (b.center|-0,.4) node [blue!80!black, midway, xshift=0cm, yshift=.5cm] series;
    draw [blue, thick, decorate, decoration=brace,amplitude=.16cm,mirror] (e.center|-0,.4) -- (f.center|-0,.4) node [blue!80!black, midway, xshift=0cm, yshift=.5cm] draw;
    endtikzpicture
    endframe
    enddocument


    enter image description here










    share|improve this question























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      Is there a way to automate setting nodes at the intervals of the foreach marks so they can be referred to, for drawing the braces; instead of defining their locations manually.



      documentclassbeamer
      beamertemplatenavigationsymbolsempty
      usepackageverbatim
      usepackagetikz
      usepackagepgfplots
      begindocument
      beginframe[t]
      frametitleci
      begintikzpicture[scale=.9, transform shape]
      pgfmathsetmacroincx.88
      draw [thick,-] (0,0) -- +(0:8.8) node [pos=.146](a)a node [ pos=.296](b)b node [pos=.44](c)c node [pos=.586](d)d node [pos=.876](e)e node [pos=.73](f)f;
      foreach x [evaluate=x as aff using int(x*1)]in 1,...,6draw [black, very thick] (incx*1.46*x,.2) -- +(-90:.4);
      draw [blue, thick, decorate, decoration=brace,amplitude=.16cm,mirror] (b.center|-0,-.4) -- (d.center|-0,-.4) node [blue!80!black, midway, xshift=0cm, yshift=-.5cm] middle;
      draw [blue, thick, decorate, decoration=brace,amplitude=.16cm] (a.center|-0,.4) -- (b.center|-0,.4) node [blue!80!black, midway, xshift=0cm, yshift=.5cm] series;
      draw [blue, thick, decorate, decoration=brace,amplitude=.16cm,mirror] (e.center|-0,.4) -- (f.center|-0,.4) node [blue!80!black, midway, xshift=0cm, yshift=.5cm] draw;
      endtikzpicture
      endframe
      enddocument


      enter image description here










      share|improve this question













      Is there a way to automate setting nodes at the intervals of the foreach marks so they can be referred to, for drawing the braces; instead of defining their locations manually.



      documentclassbeamer
      beamertemplatenavigationsymbolsempty
      usepackageverbatim
      usepackagetikz
      usepackagepgfplots
      begindocument
      beginframe[t]
      frametitleci
      begintikzpicture[scale=.9, transform shape]
      pgfmathsetmacroincx.88
      draw [thick,-] (0,0) -- +(0:8.8) node [pos=.146](a)a node [ pos=.296](b)b node [pos=.44](c)c node [pos=.586](d)d node [pos=.876](e)e node [pos=.73](f)f;
      foreach x [evaluate=x as aff using int(x*1)]in 1,...,6draw [black, very thick] (incx*1.46*x,.2) -- +(-90:.4);
      draw [blue, thick, decorate, decoration=brace,amplitude=.16cm,mirror] (b.center|-0,-.4) -- (d.center|-0,-.4) node [blue!80!black, midway, xshift=0cm, yshift=-.5cm] middle;
      draw [blue, thick, decorate, decoration=brace,amplitude=.16cm] (a.center|-0,.4) -- (b.center|-0,.4) node [blue!80!black, midway, xshift=0cm, yshift=.5cm] series;
      draw [blue, thick, decorate, decoration=brace,amplitude=.16cm,mirror] (e.center|-0,.4) -- (f.center|-0,.4) node [blue!80!black, midway, xshift=0cm, yshift=.5cm] draw;
      endtikzpicture
      endframe
      enddocument


      enter image description here







      tikz-pgf






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Dec 8 at 7:03









      Hany

      1,075415




      1,075415




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          3
          down vote



          accepted










          You can try something like this:



          foreach[count=j] i in a,b,...,f
          draw[-|] (j,0) -- ++(1,0)node[below]icoordinate(i);


          to draw lines and name the nodes using foreach.



          enter image description here



          MWE



          documentclass[border=3mm]standalone
          usepackagepgfplots
          tikzsetbrce/.style=blue, thick, decorate, decoration=brace,amplitude=.16cm,
          tikzsetbrcetxt/.style=blue!80!black, midway, xshift=0cm,
          begindocument
          begintikzpicture
          foreach[count=j] i in a,b,...,f
          draw[-|] (j,0) -- ++(1,0)node[below]icoordinate(i);
          draw (f)--++(1,0);

          draw [brce,decoration=mirror] (b|-0,-.4) -- (d|-0,-.4) node [brcetxt,yshift=-.5cm] middle;
          draw [brce] (a|-0,.2) -- (b|-0,.2) node [brcetxt, yshift=.5cm] series;
          draw [brce] (e|-0,.2) -- (f|-0,.2) node [brcetxt, yshift=.5cm] draw;
          endtikzpicture
          enddocument





          share|improve this answer






















          • Thank you for your answer. I need the tickmarks, with possible node naming (not necessarily a b c d); and the braces.
            – Hany
            Dec 8 at 8:22






          • 1




            @Hany see the updated answer.
            – nidhin
            Dec 8 at 8:56










          • Thank you very much for your time.
            – Hany
            Dec 8 at 9:22










          • Just one more request please. Can the increments between the nodes be controlled, for example making them 1.4cm or so.
            – Hany
            Dec 8 at 9:43






          • 1




            @Hany my bad. change ` draw (j,0) -- ++(1,0); ` to ` draw (j*1.4,0) -- ++(1.4,0);`
            – nidhin
            Dec 8 at 10:00










          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: 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%2f463773%2fautomating-setting-node-positions-in-foreach%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          3
          down vote



          accepted










          You can try something like this:



          foreach[count=j] i in a,b,...,f
          draw[-|] (j,0) -- ++(1,0)node[below]icoordinate(i);


          to draw lines and name the nodes using foreach.



          enter image description here



          MWE



          documentclass[border=3mm]standalone
          usepackagepgfplots
          tikzsetbrce/.style=blue, thick, decorate, decoration=brace,amplitude=.16cm,
          tikzsetbrcetxt/.style=blue!80!black, midway, xshift=0cm,
          begindocument
          begintikzpicture
          foreach[count=j] i in a,b,...,f
          draw[-|] (j,0) -- ++(1,0)node[below]icoordinate(i);
          draw (f)--++(1,0);

          draw [brce,decoration=mirror] (b|-0,-.4) -- (d|-0,-.4) node [brcetxt,yshift=-.5cm] middle;
          draw [brce] (a|-0,.2) -- (b|-0,.2) node [brcetxt, yshift=.5cm] series;
          draw [brce] (e|-0,.2) -- (f|-0,.2) node [brcetxt, yshift=.5cm] draw;
          endtikzpicture
          enddocument





          share|improve this answer






















          • Thank you for your answer. I need the tickmarks, with possible node naming (not necessarily a b c d); and the braces.
            – Hany
            Dec 8 at 8:22






          • 1




            @Hany see the updated answer.
            – nidhin
            Dec 8 at 8:56










          • Thank you very much for your time.
            – Hany
            Dec 8 at 9:22










          • Just one more request please. Can the increments between the nodes be controlled, for example making them 1.4cm or so.
            – Hany
            Dec 8 at 9:43






          • 1




            @Hany my bad. change ` draw (j,0) -- ++(1,0); ` to ` draw (j*1.4,0) -- ++(1.4,0);`
            – nidhin
            Dec 8 at 10:00














          up vote
          3
          down vote



          accepted










          You can try something like this:



          foreach[count=j] i in a,b,...,f
          draw[-|] (j,0) -- ++(1,0)node[below]icoordinate(i);


          to draw lines and name the nodes using foreach.



          enter image description here



          MWE



          documentclass[border=3mm]standalone
          usepackagepgfplots
          tikzsetbrce/.style=blue, thick, decorate, decoration=brace,amplitude=.16cm,
          tikzsetbrcetxt/.style=blue!80!black, midway, xshift=0cm,
          begindocument
          begintikzpicture
          foreach[count=j] i in a,b,...,f
          draw[-|] (j,0) -- ++(1,0)node[below]icoordinate(i);
          draw (f)--++(1,0);

          draw [brce,decoration=mirror] (b|-0,-.4) -- (d|-0,-.4) node [brcetxt,yshift=-.5cm] middle;
          draw [brce] (a|-0,.2) -- (b|-0,.2) node [brcetxt, yshift=.5cm] series;
          draw [brce] (e|-0,.2) -- (f|-0,.2) node [brcetxt, yshift=.5cm] draw;
          endtikzpicture
          enddocument





          share|improve this answer






















          • Thank you for your answer. I need the tickmarks, with possible node naming (not necessarily a b c d); and the braces.
            – Hany
            Dec 8 at 8:22






          • 1




            @Hany see the updated answer.
            – nidhin
            Dec 8 at 8:56










          • Thank you very much for your time.
            – Hany
            Dec 8 at 9:22










          • Just one more request please. Can the increments between the nodes be controlled, for example making them 1.4cm or so.
            – Hany
            Dec 8 at 9:43






          • 1




            @Hany my bad. change ` draw (j,0) -- ++(1,0); ` to ` draw (j*1.4,0) -- ++(1.4,0);`
            – nidhin
            Dec 8 at 10:00












          up vote
          3
          down vote



          accepted







          up vote
          3
          down vote



          accepted






          You can try something like this:



          foreach[count=j] i in a,b,...,f
          draw[-|] (j,0) -- ++(1,0)node[below]icoordinate(i);


          to draw lines and name the nodes using foreach.



          enter image description here



          MWE



          documentclass[border=3mm]standalone
          usepackagepgfplots
          tikzsetbrce/.style=blue, thick, decorate, decoration=brace,amplitude=.16cm,
          tikzsetbrcetxt/.style=blue!80!black, midway, xshift=0cm,
          begindocument
          begintikzpicture
          foreach[count=j] i in a,b,...,f
          draw[-|] (j,0) -- ++(1,0)node[below]icoordinate(i);
          draw (f)--++(1,0);

          draw [brce,decoration=mirror] (b|-0,-.4) -- (d|-0,-.4) node [brcetxt,yshift=-.5cm] middle;
          draw [brce] (a|-0,.2) -- (b|-0,.2) node [brcetxt, yshift=.5cm] series;
          draw [brce] (e|-0,.2) -- (f|-0,.2) node [brcetxt, yshift=.5cm] draw;
          endtikzpicture
          enddocument





          share|improve this answer














          You can try something like this:



          foreach[count=j] i in a,b,...,f
          draw[-|] (j,0) -- ++(1,0)node[below]icoordinate(i);


          to draw lines and name the nodes using foreach.



          enter image description here



          MWE



          documentclass[border=3mm]standalone
          usepackagepgfplots
          tikzsetbrce/.style=blue, thick, decorate, decoration=brace,amplitude=.16cm,
          tikzsetbrcetxt/.style=blue!80!black, midway, xshift=0cm,
          begindocument
          begintikzpicture
          foreach[count=j] i in a,b,...,f
          draw[-|] (j,0) -- ++(1,0)node[below]icoordinate(i);
          draw (f)--++(1,0);

          draw [brce,decoration=mirror] (b|-0,-.4) -- (d|-0,-.4) node [brcetxt,yshift=-.5cm] middle;
          draw [brce] (a|-0,.2) -- (b|-0,.2) node [brcetxt, yshift=.5cm] series;
          draw [brce] (e|-0,.2) -- (f|-0,.2) node [brcetxt, yshift=.5cm] draw;
          endtikzpicture
          enddocument






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Dec 8 at 8:55

























          answered Dec 8 at 7:46









          nidhin

          3,324927




          3,324927











          • Thank you for your answer. I need the tickmarks, with possible node naming (not necessarily a b c d); and the braces.
            – Hany
            Dec 8 at 8:22






          • 1




            @Hany see the updated answer.
            – nidhin
            Dec 8 at 8:56










          • Thank you very much for your time.
            – Hany
            Dec 8 at 9:22










          • Just one more request please. Can the increments between the nodes be controlled, for example making them 1.4cm or so.
            – Hany
            Dec 8 at 9:43






          • 1




            @Hany my bad. change ` draw (j,0) -- ++(1,0); ` to ` draw (j*1.4,0) -- ++(1.4,0);`
            – nidhin
            Dec 8 at 10:00
















          • Thank you for your answer. I need the tickmarks, with possible node naming (not necessarily a b c d); and the braces.
            – Hany
            Dec 8 at 8:22






          • 1




            @Hany see the updated answer.
            – nidhin
            Dec 8 at 8:56










          • Thank you very much for your time.
            – Hany
            Dec 8 at 9:22










          • Just one more request please. Can the increments between the nodes be controlled, for example making them 1.4cm or so.
            – Hany
            Dec 8 at 9:43






          • 1




            @Hany my bad. change ` draw (j,0) -- ++(1,0); ` to ` draw (j*1.4,0) -- ++(1.4,0);`
            – nidhin
            Dec 8 at 10:00















          Thank you for your answer. I need the tickmarks, with possible node naming (not necessarily a b c d); and the braces.
          – Hany
          Dec 8 at 8:22




          Thank you for your answer. I need the tickmarks, with possible node naming (not necessarily a b c d); and the braces.
          – Hany
          Dec 8 at 8:22




          1




          1




          @Hany see the updated answer.
          – nidhin
          Dec 8 at 8:56




          @Hany see the updated answer.
          – nidhin
          Dec 8 at 8:56












          Thank you very much for your time.
          – Hany
          Dec 8 at 9:22




          Thank you very much for your time.
          – Hany
          Dec 8 at 9:22












          Just one more request please. Can the increments between the nodes be controlled, for example making them 1.4cm or so.
          – Hany
          Dec 8 at 9:43




          Just one more request please. Can the increments between the nodes be controlled, for example making them 1.4cm or so.
          – Hany
          Dec 8 at 9:43




          1




          1




          @Hany my bad. change ` draw (j,0) -- ++(1,0); ` to ` draw (j*1.4,0) -- ++(1.4,0);`
          – nidhin
          Dec 8 at 10:00




          @Hany my bad. change ` draw (j,0) -- ++(1,0); ` to ` draw (j*1.4,0) -- ++(1.4,0);`
          – nidhin
          Dec 8 at 10:00

















          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.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • 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%2f463773%2fautomating-setting-node-positions-in-foreach%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

          How to check contact read email or not when send email to Individual?

          Displaying single band from multi-band raster using QGIS

          How many registers does an x86_64 CPU actually have?