Tikz picture using two “foreach” loops











up vote
4
down vote

favorite












I am making a picture using foreach. MWE is appended below



documentclass{article}

usepackage[svgnames]{xcolor}
usepackage{tikz}

begin{document}

begin{tikzpicture}

foreach x in {0,...,5}
draw [DodgerBlue](x,-1) circle (0.25);

foreach x in {0,...,5}
draw [-latex,red](x,-1) -- (x,-1.5);

foreach x in {0,...,5}
draw [-latex,DarkGreen](x,-1) -- (x,-0.5);

draw [ultra thin] (5,-0.5) -- (0,-1);

end{tikzpicture}

end{document}


The resulting picture is attached below



enter image description here



Now what I want is that the green arrows on the top should be limited by the black line diagonal line. That is for the first circle there should be no green arrow, and its length should increase until it becomes equal to the red arrow in the last circle. How can this be done using foreach using the variable y. Is there a way such that the intersection of the black diagonal line with the green arrows can be used to limit the length of the green arrows to the desired values? Or is there any other way to achieve this?










share|improve this question


























    up vote
    4
    down vote

    favorite












    I am making a picture using foreach. MWE is appended below



    documentclass{article}

    usepackage[svgnames]{xcolor}
    usepackage{tikz}

    begin{document}

    begin{tikzpicture}

    foreach x in {0,...,5}
    draw [DodgerBlue](x,-1) circle (0.25);

    foreach x in {0,...,5}
    draw [-latex,red](x,-1) -- (x,-1.5);

    foreach x in {0,...,5}
    draw [-latex,DarkGreen](x,-1) -- (x,-0.5);

    draw [ultra thin] (5,-0.5) -- (0,-1);

    end{tikzpicture}

    end{document}


    The resulting picture is attached below



    enter image description here



    Now what I want is that the green arrows on the top should be limited by the black line diagonal line. That is for the first circle there should be no green arrow, and its length should increase until it becomes equal to the red arrow in the last circle. How can this be done using foreach using the variable y. Is there a way such that the intersection of the black diagonal line with the green arrows can be used to limit the length of the green arrows to the desired values? Or is there any other way to achieve this?










    share|improve this question
























      up vote
      4
      down vote

      favorite









      up vote
      4
      down vote

      favorite











      I am making a picture using foreach. MWE is appended below



      documentclass{article}

      usepackage[svgnames]{xcolor}
      usepackage{tikz}

      begin{document}

      begin{tikzpicture}

      foreach x in {0,...,5}
      draw [DodgerBlue](x,-1) circle (0.25);

      foreach x in {0,...,5}
      draw [-latex,red](x,-1) -- (x,-1.5);

      foreach x in {0,...,5}
      draw [-latex,DarkGreen](x,-1) -- (x,-0.5);

      draw [ultra thin] (5,-0.5) -- (0,-1);

      end{tikzpicture}

      end{document}


      The resulting picture is attached below



      enter image description here



      Now what I want is that the green arrows on the top should be limited by the black line diagonal line. That is for the first circle there should be no green arrow, and its length should increase until it becomes equal to the red arrow in the last circle. How can this be done using foreach using the variable y. Is there a way such that the intersection of the black diagonal line with the green arrows can be used to limit the length of the green arrows to the desired values? Or is there any other way to achieve this?










      share|improve this question













      I am making a picture using foreach. MWE is appended below



      documentclass{article}

      usepackage[svgnames]{xcolor}
      usepackage{tikz}

      begin{document}

      begin{tikzpicture}

      foreach x in {0,...,5}
      draw [DodgerBlue](x,-1) circle (0.25);

      foreach x in {0,...,5}
      draw [-latex,red](x,-1) -- (x,-1.5);

      foreach x in {0,...,5}
      draw [-latex,DarkGreen](x,-1) -- (x,-0.5);

      draw [ultra thin] (5,-0.5) -- (0,-1);

      end{tikzpicture}

      end{document}


      The resulting picture is attached below



      enter image description here



      Now what I want is that the green arrows on the top should be limited by the black line diagonal line. That is for the first circle there should be no green arrow, and its length should increase until it becomes equal to the red arrow in the last circle. How can this be done using foreach using the variable y. Is there a way such that the intersection of the black diagonal line with the green arrows can be used to limit the length of the green arrows to the desired values? Or is there any other way to achieve this?







      tikz-pgf foreach






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 57 mins ago









      Damitr

      570312




      570312






















          4 Answers
          4






          active

          oldest

          votes

















          up vote
          4
          down vote













          You can use a simple linear function. Please note that your arrow heads are quite large in your scale. It might be a good idea to choose a larger scale or use another arrow tip to have a better representation of the second case.



          linear function



          documentclass{article}

          usepackage[svgnames]{xcolor}
          usepackage{tikz}

          begin{document}

          begin{tikzpicture}

          foreach x in {0,...,5}{
          draw [DodgerBlue](x,0) circle (0.25);
          draw [-latex,red](x,0) -- (x,-.5);
          }
          foreach x in {1,...,5}{
          draw [-latex,DarkGreen](x,0) -- (x,{0.1*x});
          }

          draw [ultra thin] (5,.5) -- (0,0);

          end{tikzpicture}

          end{document}





          share|improve this answer




























            up vote
            4
            down vote













            In case you do not want to do analytic computations (or if you do not have a simple parametrization for the line).



            documentclass{article}

            usepackage[svgnames]{xcolor}
            usepackage{tikz}
            usetikzlibrary{calc}
            begin{document}

            begin{tikzpicture}

            foreach x in {0,...,5}
            draw [DodgerBlue](x,-1) circle (0.25);

            foreach x in {0,...,5}
            draw [-latex,red](x,-1) -- (x,-1.5) ;

            draw [ultra thin] (5,-0.5) coordinate(aux0) -- (0,-1) coordinate(aux1);

            foreach x in {1,...,5}
            draw [-latex,DarkGreen] (x,-1) coordinate(aux2) (x,-0.5) coordinate(aux3)
            (aux2) -- (intersection cs:first line={(aux2)--(aux3)},
            second line={(aux0)--(aux1)});


            end{tikzpicture}

            end{document}


            enter image description here






            share|improve this answer























            • Using intersections is an interesting idea :)
              – TeXnician
              36 mins ago










            • @TeXnician These are actually those intersections that come with calc and do not require the intersections library. They are restricted to intersections of straight lines, though. (+1 to your analytic solution ;-)
              – marmot
              33 mins ago










            • I have used these "calc intersections" before, but I would not have thought of them in this case…
              – TeXnician
              25 mins ago


















            up vote
            3
            down vote













            Like this (please obeserve foreach x in {1,...,5}?



            documentclass{article}

            usepackage[svgnames]{xcolor}
            usepackage{tikz}

            begin{document}

            begin{tikzpicture}

            foreach x in {0,...,5}
            draw [DodgerBlue](x,-1) circle (0.25);

            foreach x in {0,...,5}
            draw [-latex,red](x,-1) -- (x,-1.5);

            %foreach x in {0,...,5}
            % draw [-latex,DarkGreen](x,-1) -- (x,-0.5);
            foreach x in {1,...,5}
            draw [-latex,DarkGreen](x,-1) -- (x,-1+0.1*x);

            draw [ultra thin] (5,-0.5) -- (0,-1);

            end{tikzpicture}

            end{document}


            enter image description here






            share|improve this answer






























              up vote
              0
              down vote













              one more with use of lines intersections, but defined with help of the package intersections:



              documentclass[tikz, svgnames, margin=3]{standalone}
              usetikzlibrary{intersections}

              begin{document}
              begin{tikzpicture}
              foreach x in {0,...,5}{
              draw [DodgerBlue](x,0) circle (0.25);
              draw [-latex,red](x,0) -- (x,-.5);
              }
              draw [ultra thin, name path=A] (5,.5) -- (0,0);
              foreach x in {1,...,5}
              {
              path[name path=Bx] (x,0) -- ++ (0,0.5);
              draw[-latex,DarkGreen,
              name intersections={of=A and Bx,by={Bx}}] (x,0) -- (Bx);
              }
              end{tikzpicture}
              end{document}


              enter image description here





              share





















                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%2f464497%2ftikz-picture-using-two-foreach-loops%23new-answer', 'question_page');
                }
                );

                Post as a guest















                Required, but never shown

























                4 Answers
                4






                active

                oldest

                votes








                4 Answers
                4






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes








                up vote
                4
                down vote













                You can use a simple linear function. Please note that your arrow heads are quite large in your scale. It might be a good idea to choose a larger scale or use another arrow tip to have a better representation of the second case.



                linear function



                documentclass{article}

                usepackage[svgnames]{xcolor}
                usepackage{tikz}

                begin{document}

                begin{tikzpicture}

                foreach x in {0,...,5}{
                draw [DodgerBlue](x,0) circle (0.25);
                draw [-latex,red](x,0) -- (x,-.5);
                }
                foreach x in {1,...,5}{
                draw [-latex,DarkGreen](x,0) -- (x,{0.1*x});
                }

                draw [ultra thin] (5,.5) -- (0,0);

                end{tikzpicture}

                end{document}





                share|improve this answer

























                  up vote
                  4
                  down vote













                  You can use a simple linear function. Please note that your arrow heads are quite large in your scale. It might be a good idea to choose a larger scale or use another arrow tip to have a better representation of the second case.



                  linear function



                  documentclass{article}

                  usepackage[svgnames]{xcolor}
                  usepackage{tikz}

                  begin{document}

                  begin{tikzpicture}

                  foreach x in {0,...,5}{
                  draw [DodgerBlue](x,0) circle (0.25);
                  draw [-latex,red](x,0) -- (x,-.5);
                  }
                  foreach x in {1,...,5}{
                  draw [-latex,DarkGreen](x,0) -- (x,{0.1*x});
                  }

                  draw [ultra thin] (5,.5) -- (0,0);

                  end{tikzpicture}

                  end{document}





                  share|improve this answer























                    up vote
                    4
                    down vote










                    up vote
                    4
                    down vote









                    You can use a simple linear function. Please note that your arrow heads are quite large in your scale. It might be a good idea to choose a larger scale or use another arrow tip to have a better representation of the second case.



                    linear function



                    documentclass{article}

                    usepackage[svgnames]{xcolor}
                    usepackage{tikz}

                    begin{document}

                    begin{tikzpicture}

                    foreach x in {0,...,5}{
                    draw [DodgerBlue](x,0) circle (0.25);
                    draw [-latex,red](x,0) -- (x,-.5);
                    }
                    foreach x in {1,...,5}{
                    draw [-latex,DarkGreen](x,0) -- (x,{0.1*x});
                    }

                    draw [ultra thin] (5,.5) -- (0,0);

                    end{tikzpicture}

                    end{document}





                    share|improve this answer












                    You can use a simple linear function. Please note that your arrow heads are quite large in your scale. It might be a good idea to choose a larger scale or use another arrow tip to have a better representation of the second case.



                    linear function



                    documentclass{article}

                    usepackage[svgnames]{xcolor}
                    usepackage{tikz}

                    begin{document}

                    begin{tikzpicture}

                    foreach x in {0,...,5}{
                    draw [DodgerBlue](x,0) circle (0.25);
                    draw [-latex,red](x,0) -- (x,-.5);
                    }
                    foreach x in {1,...,5}{
                    draw [-latex,DarkGreen](x,0) -- (x,{0.1*x});
                    }

                    draw [ultra thin] (5,.5) -- (0,0);

                    end{tikzpicture}

                    end{document}






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered 39 mins ago









                    TeXnician

                    23.9k62984




                    23.9k62984






















                        up vote
                        4
                        down vote













                        In case you do not want to do analytic computations (or if you do not have a simple parametrization for the line).



                        documentclass{article}

                        usepackage[svgnames]{xcolor}
                        usepackage{tikz}
                        usetikzlibrary{calc}
                        begin{document}

                        begin{tikzpicture}

                        foreach x in {0,...,5}
                        draw [DodgerBlue](x,-1) circle (0.25);

                        foreach x in {0,...,5}
                        draw [-latex,red](x,-1) -- (x,-1.5) ;

                        draw [ultra thin] (5,-0.5) coordinate(aux0) -- (0,-1) coordinate(aux1);

                        foreach x in {1,...,5}
                        draw [-latex,DarkGreen] (x,-1) coordinate(aux2) (x,-0.5) coordinate(aux3)
                        (aux2) -- (intersection cs:first line={(aux2)--(aux3)},
                        second line={(aux0)--(aux1)});


                        end{tikzpicture}

                        end{document}


                        enter image description here






                        share|improve this answer























                        • Using intersections is an interesting idea :)
                          – TeXnician
                          36 mins ago










                        • @TeXnician These are actually those intersections that come with calc and do not require the intersections library. They are restricted to intersections of straight lines, though. (+1 to your analytic solution ;-)
                          – marmot
                          33 mins ago










                        • I have used these "calc intersections" before, but I would not have thought of them in this case…
                          – TeXnician
                          25 mins ago















                        up vote
                        4
                        down vote













                        In case you do not want to do analytic computations (or if you do not have a simple parametrization for the line).



                        documentclass{article}

                        usepackage[svgnames]{xcolor}
                        usepackage{tikz}
                        usetikzlibrary{calc}
                        begin{document}

                        begin{tikzpicture}

                        foreach x in {0,...,5}
                        draw [DodgerBlue](x,-1) circle (0.25);

                        foreach x in {0,...,5}
                        draw [-latex,red](x,-1) -- (x,-1.5) ;

                        draw [ultra thin] (5,-0.5) coordinate(aux0) -- (0,-1) coordinate(aux1);

                        foreach x in {1,...,5}
                        draw [-latex,DarkGreen] (x,-1) coordinate(aux2) (x,-0.5) coordinate(aux3)
                        (aux2) -- (intersection cs:first line={(aux2)--(aux3)},
                        second line={(aux0)--(aux1)});


                        end{tikzpicture}

                        end{document}


                        enter image description here






                        share|improve this answer























                        • Using intersections is an interesting idea :)
                          – TeXnician
                          36 mins ago










                        • @TeXnician These are actually those intersections that come with calc and do not require the intersections library. They are restricted to intersections of straight lines, though. (+1 to your analytic solution ;-)
                          – marmot
                          33 mins ago










                        • I have used these "calc intersections" before, but I would not have thought of them in this case…
                          – TeXnician
                          25 mins ago













                        up vote
                        4
                        down vote










                        up vote
                        4
                        down vote









                        In case you do not want to do analytic computations (or if you do not have a simple parametrization for the line).



                        documentclass{article}

                        usepackage[svgnames]{xcolor}
                        usepackage{tikz}
                        usetikzlibrary{calc}
                        begin{document}

                        begin{tikzpicture}

                        foreach x in {0,...,5}
                        draw [DodgerBlue](x,-1) circle (0.25);

                        foreach x in {0,...,5}
                        draw [-latex,red](x,-1) -- (x,-1.5) ;

                        draw [ultra thin] (5,-0.5) coordinate(aux0) -- (0,-1) coordinate(aux1);

                        foreach x in {1,...,5}
                        draw [-latex,DarkGreen] (x,-1) coordinate(aux2) (x,-0.5) coordinate(aux3)
                        (aux2) -- (intersection cs:first line={(aux2)--(aux3)},
                        second line={(aux0)--(aux1)});


                        end{tikzpicture}

                        end{document}


                        enter image description here






                        share|improve this answer














                        In case you do not want to do analytic computations (or if you do not have a simple parametrization for the line).



                        documentclass{article}

                        usepackage[svgnames]{xcolor}
                        usepackage{tikz}
                        usetikzlibrary{calc}
                        begin{document}

                        begin{tikzpicture}

                        foreach x in {0,...,5}
                        draw [DodgerBlue](x,-1) circle (0.25);

                        foreach x in {0,...,5}
                        draw [-latex,red](x,-1) -- (x,-1.5) ;

                        draw [ultra thin] (5,-0.5) coordinate(aux0) -- (0,-1) coordinate(aux1);

                        foreach x in {1,...,5}
                        draw [-latex,DarkGreen] (x,-1) coordinate(aux2) (x,-0.5) coordinate(aux3)
                        (aux2) -- (intersection cs:first line={(aux2)--(aux3)},
                        second line={(aux0)--(aux1)});


                        end{tikzpicture}

                        end{document}


                        enter image description here







                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited 35 mins ago

























                        answered 38 mins ago









                        marmot

                        82.5k493176




                        82.5k493176












                        • Using intersections is an interesting idea :)
                          – TeXnician
                          36 mins ago










                        • @TeXnician These are actually those intersections that come with calc and do not require the intersections library. They are restricted to intersections of straight lines, though. (+1 to your analytic solution ;-)
                          – marmot
                          33 mins ago










                        • I have used these "calc intersections" before, but I would not have thought of them in this case…
                          – TeXnician
                          25 mins ago


















                        • Using intersections is an interesting idea :)
                          – TeXnician
                          36 mins ago










                        • @TeXnician These are actually those intersections that come with calc and do not require the intersections library. They are restricted to intersections of straight lines, though. (+1 to your analytic solution ;-)
                          – marmot
                          33 mins ago










                        • I have used these "calc intersections" before, but I would not have thought of them in this case…
                          – TeXnician
                          25 mins ago
















                        Using intersections is an interesting idea :)
                        – TeXnician
                        36 mins ago




                        Using intersections is an interesting idea :)
                        – TeXnician
                        36 mins ago












                        @TeXnician These are actually those intersections that come with calc and do not require the intersections library. They are restricted to intersections of straight lines, though. (+1 to your analytic solution ;-)
                        – marmot
                        33 mins ago




                        @TeXnician These are actually those intersections that come with calc and do not require the intersections library. They are restricted to intersections of straight lines, though. (+1 to your analytic solution ;-)
                        – marmot
                        33 mins ago












                        I have used these "calc intersections" before, but I would not have thought of them in this case…
                        – TeXnician
                        25 mins ago




                        I have used these "calc intersections" before, but I would not have thought of them in this case…
                        – TeXnician
                        25 mins ago










                        up vote
                        3
                        down vote













                        Like this (please obeserve foreach x in {1,...,5}?



                        documentclass{article}

                        usepackage[svgnames]{xcolor}
                        usepackage{tikz}

                        begin{document}

                        begin{tikzpicture}

                        foreach x in {0,...,5}
                        draw [DodgerBlue](x,-1) circle (0.25);

                        foreach x in {0,...,5}
                        draw [-latex,red](x,-1) -- (x,-1.5);

                        %foreach x in {0,...,5}
                        % draw [-latex,DarkGreen](x,-1) -- (x,-0.5);
                        foreach x in {1,...,5}
                        draw [-latex,DarkGreen](x,-1) -- (x,-1+0.1*x);

                        draw [ultra thin] (5,-0.5) -- (0,-1);

                        end{tikzpicture}

                        end{document}


                        enter image description here






                        share|improve this answer



























                          up vote
                          3
                          down vote













                          Like this (please obeserve foreach x in {1,...,5}?



                          documentclass{article}

                          usepackage[svgnames]{xcolor}
                          usepackage{tikz}

                          begin{document}

                          begin{tikzpicture}

                          foreach x in {0,...,5}
                          draw [DodgerBlue](x,-1) circle (0.25);

                          foreach x in {0,...,5}
                          draw [-latex,red](x,-1) -- (x,-1.5);

                          %foreach x in {0,...,5}
                          % draw [-latex,DarkGreen](x,-1) -- (x,-0.5);
                          foreach x in {1,...,5}
                          draw [-latex,DarkGreen](x,-1) -- (x,-1+0.1*x);

                          draw [ultra thin] (5,-0.5) -- (0,-1);

                          end{tikzpicture}

                          end{document}


                          enter image description here






                          share|improve this answer

























                            up vote
                            3
                            down vote










                            up vote
                            3
                            down vote









                            Like this (please obeserve foreach x in {1,...,5}?



                            documentclass{article}

                            usepackage[svgnames]{xcolor}
                            usepackage{tikz}

                            begin{document}

                            begin{tikzpicture}

                            foreach x in {0,...,5}
                            draw [DodgerBlue](x,-1) circle (0.25);

                            foreach x in {0,...,5}
                            draw [-latex,red](x,-1) -- (x,-1.5);

                            %foreach x in {0,...,5}
                            % draw [-latex,DarkGreen](x,-1) -- (x,-0.5);
                            foreach x in {1,...,5}
                            draw [-latex,DarkGreen](x,-1) -- (x,-1+0.1*x);

                            draw [ultra thin] (5,-0.5) -- (0,-1);

                            end{tikzpicture}

                            end{document}


                            enter image description here






                            share|improve this answer














                            Like this (please obeserve foreach x in {1,...,5}?



                            documentclass{article}

                            usepackage[svgnames]{xcolor}
                            usepackage{tikz}

                            begin{document}

                            begin{tikzpicture}

                            foreach x in {0,...,5}
                            draw [DodgerBlue](x,-1) circle (0.25);

                            foreach x in {0,...,5}
                            draw [-latex,red](x,-1) -- (x,-1.5);

                            %foreach x in {0,...,5}
                            % draw [-latex,DarkGreen](x,-1) -- (x,-0.5);
                            foreach x in {1,...,5}
                            draw [-latex,DarkGreen](x,-1) -- (x,-1+0.1*x);

                            draw [ultra thin] (5,-0.5) -- (0,-1);

                            end{tikzpicture}

                            end{document}


                            enter image description here







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited 25 mins ago

























                            answered 37 mins ago









                            Przemysław Scherwentke

                            29.6k54494




                            29.6k54494






















                                up vote
                                0
                                down vote













                                one more with use of lines intersections, but defined with help of the package intersections:



                                documentclass[tikz, svgnames, margin=3]{standalone}
                                usetikzlibrary{intersections}

                                begin{document}
                                begin{tikzpicture}
                                foreach x in {0,...,5}{
                                draw [DodgerBlue](x,0) circle (0.25);
                                draw [-latex,red](x,0) -- (x,-.5);
                                }
                                draw [ultra thin, name path=A] (5,.5) -- (0,0);
                                foreach x in {1,...,5}
                                {
                                path[name path=Bx] (x,0) -- ++ (0,0.5);
                                draw[-latex,DarkGreen,
                                name intersections={of=A and Bx,by={Bx}}] (x,0) -- (Bx);
                                }
                                end{tikzpicture}
                                end{document}


                                enter image description here





                                share

























                                  up vote
                                  0
                                  down vote













                                  one more with use of lines intersections, but defined with help of the package intersections:



                                  documentclass[tikz, svgnames, margin=3]{standalone}
                                  usetikzlibrary{intersections}

                                  begin{document}
                                  begin{tikzpicture}
                                  foreach x in {0,...,5}{
                                  draw [DodgerBlue](x,0) circle (0.25);
                                  draw [-latex,red](x,0) -- (x,-.5);
                                  }
                                  draw [ultra thin, name path=A] (5,.5) -- (0,0);
                                  foreach x in {1,...,5}
                                  {
                                  path[name path=Bx] (x,0) -- ++ (0,0.5);
                                  draw[-latex,DarkGreen,
                                  name intersections={of=A and Bx,by={Bx}}] (x,0) -- (Bx);
                                  }
                                  end{tikzpicture}
                                  end{document}


                                  enter image description here





                                  share























                                    up vote
                                    0
                                    down vote










                                    up vote
                                    0
                                    down vote









                                    one more with use of lines intersections, but defined with help of the package intersections:



                                    documentclass[tikz, svgnames, margin=3]{standalone}
                                    usetikzlibrary{intersections}

                                    begin{document}
                                    begin{tikzpicture}
                                    foreach x in {0,...,5}{
                                    draw [DodgerBlue](x,0) circle (0.25);
                                    draw [-latex,red](x,0) -- (x,-.5);
                                    }
                                    draw [ultra thin, name path=A] (5,.5) -- (0,0);
                                    foreach x in {1,...,5}
                                    {
                                    path[name path=Bx] (x,0) -- ++ (0,0.5);
                                    draw[-latex,DarkGreen,
                                    name intersections={of=A and Bx,by={Bx}}] (x,0) -- (Bx);
                                    }
                                    end{tikzpicture}
                                    end{document}


                                    enter image description here





                                    share












                                    one more with use of lines intersections, but defined with help of the package intersections:



                                    documentclass[tikz, svgnames, margin=3]{standalone}
                                    usetikzlibrary{intersections}

                                    begin{document}
                                    begin{tikzpicture}
                                    foreach x in {0,...,5}{
                                    draw [DodgerBlue](x,0) circle (0.25);
                                    draw [-latex,red](x,0) -- (x,-.5);
                                    }
                                    draw [ultra thin, name path=A] (5,.5) -- (0,0);
                                    foreach x in {1,...,5}
                                    {
                                    path[name path=Bx] (x,0) -- ++ (0,0.5);
                                    draw[-latex,DarkGreen,
                                    name intersections={of=A and Bx,by={Bx}}] (x,0) -- (Bx);
                                    }
                                    end{tikzpicture}
                                    end{document}


                                    enter image description here






                                    share











                                    share


                                    share










                                    answered 6 mins ago









                                    Zarko

                                    118k865155




                                    118k865155






























                                        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%2f464497%2ftikz-picture-using-two-foreach-loops%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

                                        Trompette piccolo

                                        Slow SSRS Report in dynamic grouping and multiple parameters

                                        Simon Yates (cyclisme)