An optimized set of tikz code?












6















I have a question, how can have the shortest set of tikz code for this pecture enter image description here



i am tring to optimize this code:



documentclass{article}
usepackage{amsmath}
usepackage{tikz}
begin{document}
La version de TikZ est : pgfversion

vfill

begin{center}
begin{tikzpicture}
%
draw (0,1) -- (1,0);
draw (1,0) -- (0,-1);
draw (0,-1) -- (-1,0);
draw (-1,0) -- (0,1);
draw (0,0) circle (1);
draw ((0,1) circle (1);
draw (0,-1) circle (1);
draw (-1,0) circle (1);
draw (1,0) circle (1);
%
draw (0,2) -- (2,0);
draw (2,0) -- (0,-2);
draw (0,-2) -- (-2,0);
draw (-2,0) -- (0,2);
draw (0,0) circle (2);
draw ((0,2) circle (2);
draw (0,-2) circle (2);
draw (-2,0) circle (2);
draw (2,0) circle (2);
end{tikzpicture}
end{center}
end{document}









share|improve this question









New contributor




mou-nadal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • Do you mean who has the shortest execution time in processor time? Who requires the least memory?

    – AndréC
    5 hours ago











  • Some think with a loop will be a great approach, but if we consider CPU and memory we must be more careful.

    – mou-nadal
    4 hours ago
















6















I have a question, how can have the shortest set of tikz code for this pecture enter image description here



i am tring to optimize this code:



documentclass{article}
usepackage{amsmath}
usepackage{tikz}
begin{document}
La version de TikZ est : pgfversion

vfill

begin{center}
begin{tikzpicture}
%
draw (0,1) -- (1,0);
draw (1,0) -- (0,-1);
draw (0,-1) -- (-1,0);
draw (-1,0) -- (0,1);
draw (0,0) circle (1);
draw ((0,1) circle (1);
draw (0,-1) circle (1);
draw (-1,0) circle (1);
draw (1,0) circle (1);
%
draw (0,2) -- (2,0);
draw (2,0) -- (0,-2);
draw (0,-2) -- (-2,0);
draw (-2,0) -- (0,2);
draw (0,0) circle (2);
draw ((0,2) circle (2);
draw (0,-2) circle (2);
draw (-2,0) circle (2);
draw (2,0) circle (2);
end{tikzpicture}
end{center}
end{document}









share|improve this question









New contributor




mou-nadal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • Do you mean who has the shortest execution time in processor time? Who requires the least memory?

    – AndréC
    5 hours ago











  • Some think with a loop will be a great approach, but if we consider CPU and memory we must be more careful.

    – mou-nadal
    4 hours ago














6












6








6








I have a question, how can have the shortest set of tikz code for this pecture enter image description here



i am tring to optimize this code:



documentclass{article}
usepackage{amsmath}
usepackage{tikz}
begin{document}
La version de TikZ est : pgfversion

vfill

begin{center}
begin{tikzpicture}
%
draw (0,1) -- (1,0);
draw (1,0) -- (0,-1);
draw (0,-1) -- (-1,0);
draw (-1,0) -- (0,1);
draw (0,0) circle (1);
draw ((0,1) circle (1);
draw (0,-1) circle (1);
draw (-1,0) circle (1);
draw (1,0) circle (1);
%
draw (0,2) -- (2,0);
draw (2,0) -- (0,-2);
draw (0,-2) -- (-2,0);
draw (-2,0) -- (0,2);
draw (0,0) circle (2);
draw ((0,2) circle (2);
draw (0,-2) circle (2);
draw (-2,0) circle (2);
draw (2,0) circle (2);
end{tikzpicture}
end{center}
end{document}









share|improve this question









New contributor




mou-nadal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I have a question, how can have the shortest set of tikz code for this pecture enter image description here



i am tring to optimize this code:



documentclass{article}
usepackage{amsmath}
usepackage{tikz}
begin{document}
La version de TikZ est : pgfversion

vfill

begin{center}
begin{tikzpicture}
%
draw (0,1) -- (1,0);
draw (1,0) -- (0,-1);
draw (0,-1) -- (-1,0);
draw (-1,0) -- (0,1);
draw (0,0) circle (1);
draw ((0,1) circle (1);
draw (0,-1) circle (1);
draw (-1,0) circle (1);
draw (1,0) circle (1);
%
draw (0,2) -- (2,0);
draw (2,0) -- (0,-2);
draw (0,-2) -- (-2,0);
draw (-2,0) -- (0,2);
draw (0,0) circle (2);
draw ((0,2) circle (2);
draw (0,-2) circle (2);
draw (-2,0) circle (2);
draw (2,0) circle (2);
end{tikzpicture}
end{center}
end{document}






tikz-pgf






share|improve this question









New contributor




mou-nadal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




mou-nadal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 2 hours ago









AndréC

8,86911447




8,86911447






New contributor




mou-nadal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 6 hours ago









mou-nadalmou-nadal

384




384




New contributor




mou-nadal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





mou-nadal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






mou-nadal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.













  • Do you mean who has the shortest execution time in processor time? Who requires the least memory?

    – AndréC
    5 hours ago











  • Some think with a loop will be a great approach, but if we consider CPU and memory we must be more careful.

    – mou-nadal
    4 hours ago



















  • Do you mean who has the shortest execution time in processor time? Who requires the least memory?

    – AndréC
    5 hours ago











  • Some think with a loop will be a great approach, but if we consider CPU and memory we must be more careful.

    – mou-nadal
    4 hours ago

















Do you mean who has the shortest execution time in processor time? Who requires the least memory?

– AndréC
5 hours ago





Do you mean who has the shortest execution time in processor time? Who requires the least memory?

– AndréC
5 hours ago













Some think with a loop will be a great approach, but if we consider CPU and memory we must be more careful.

– mou-nadal
4 hours ago





Some think with a loop will be a great approach, but if we consider CPU and memory we must be more careful.

– mou-nadal
4 hours ago










5 Answers
5






active

oldest

votes


















5














Here is a solution (not the shortest):



documentclass[tikz]{standalone}
begin{document}
begin{tikzpicture}
draw
circle (1) circle(2)
(0:1) --(90:1) -- (180:1) -- (270:1) -- cycle
(0:1) circle(1) (90:1) circle(1) (180:1) circle(1) (270:1) circle(1)
(0:2) --(90:2) -- (180:2) -- (270:2) -- cycle
(0:2) circle(2) (90:2) circle(2) (180:2) circle(2) (270:2) circle(2);
end{tikzpicture}
end{document}





share|improve this answer































    5














    Just for fun:



    documentclass[tikz,margin=5mm]{standalone}
    begin{document}
    begin{tikzpicture}

    draw (0,0) circle (1) circle (2);

    foreach t/n in {0/1,90/2,180/3,270/4}{
    draw (t:1)coordinate(n) circle (1) ;}

    foreach t/m in {0/5,90/6,180/7,270/8}{
    draw (t:2)coordinate(m) circle (2) ;}

    draw (1)--(2)--(3)--(4)--cycle;
    draw (5)--(6)--(7)--(8)--cycle;


    end{tikzpicture}
    end{document}





    share|improve this answer

































      5














      One path for everything. ;-)



      documentclass[tikz,border=3.14mm]{standalone}
      begin{document}
      begin{tikzpicture}
      draw[rotate=45] foreach Y in {1,2}
      {(0,0) circle[radius=Y]
      (45:Y) rectangle (225:Y)
      foreach X in {45,135,225,315}
      { (X:Y) circle[radius=Y]}};
      end{tikzpicture}
      end{document}


      enter image description here






      share|improve this answer

































        3














        Not as much as @marmot's nicely optimised answer but a try (gives more knobs for fun though):



        documentclass[tikz]{standalone}
        begin{document}
        begin{tikzpicture}[mystyle/.style={circle,draw,fill=none,minimum size=20, line width = 0.1pt}]
        foreach x/y/z in {0/0/2,0/1/2,0/-1/2,-1/0/2,1/0/2,0/0/4,0/1/4,0/-1/4,-1/0/4,1/0/4}
        node [mystyle, minimum size = z cm, color =black] (2) at (x, y) {};
        foreach x/y in {-0.7/0.7, -1.41/1.41}
        draw[rotate=45, line width = 0.1pt] (x , x ) rectangle (y, y);
        end{tikzpicture}
        end{document}


        which gives



        enter image description here






        share|improve this answer































          1














          I am participating in the celebration with two proposals, both of which have been made:



          Two loops:




          • the first one to make an enlargement (scale) by two

          • the second to build the 4 circles and the square using polar coordinates


          The code is indented so that it can be read:



          First proposal (easier to read):



          documentclass{article}
          usepackage{amsmath}
          usepackage{tikz}
          begin{document}
          La version de TikZ est : pgfversion

          vfill

          begin{center}
          begin{tikzpicture}
          foreach s in {1,2}{
          begin{scope}[scale=s]
          draw (0,0) circle (1);
          foreach r [remember= r as rr (initially 270)] in {0,90,180,270}{
          draw (r:1) circle (1);
          draw (rr:1)--(r:1);
          }
          end{scope}
          }
          end{tikzpicture}
          end{center}
          end{document}


          screenshot



          Second proposal (with one less scope environment):



          documentclass{article}
          usepackage{amsmath}
          usepackage{tikz}
          begin{document}
          La version de TikZ est : pgfversion

          vfill

          begin{center}
          begin{tikzpicture}
          foreach s in {1,2}{
          draw (0,0) circle (s);
          foreach r [remember= r as rr (initially 270)] in {0,90,180,270}{
          draw (r:s) circle (s);
          draw (rr:s)--(r:s);
          }
          }
          end{tikzpicture}
          end{center}
          end{document}





          share|improve this answer

























            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
            });


            }
            });






            mou-nadal is a new contributor. Be nice, and check out our Code of Conduct.










            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f473926%2fan-optimized-set-of-tikz-code%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            5 Answers
            5






            active

            oldest

            votes








            5 Answers
            5






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            5














            Here is a solution (not the shortest):



            documentclass[tikz]{standalone}
            begin{document}
            begin{tikzpicture}
            draw
            circle (1) circle(2)
            (0:1) --(90:1) -- (180:1) -- (270:1) -- cycle
            (0:1) circle(1) (90:1) circle(1) (180:1) circle(1) (270:1) circle(1)
            (0:2) --(90:2) -- (180:2) -- (270:2) -- cycle
            (0:2) circle(2) (90:2) circle(2) (180:2) circle(2) (270:2) circle(2);
            end{tikzpicture}
            end{document}





            share|improve this answer




























              5














              Here is a solution (not the shortest):



              documentclass[tikz]{standalone}
              begin{document}
              begin{tikzpicture}
              draw
              circle (1) circle(2)
              (0:1) --(90:1) -- (180:1) -- (270:1) -- cycle
              (0:1) circle(1) (90:1) circle(1) (180:1) circle(1) (270:1) circle(1)
              (0:2) --(90:2) -- (180:2) -- (270:2) -- cycle
              (0:2) circle(2) (90:2) circle(2) (180:2) circle(2) (270:2) circle(2);
              end{tikzpicture}
              end{document}





              share|improve this answer


























                5












                5








                5







                Here is a solution (not the shortest):



                documentclass[tikz]{standalone}
                begin{document}
                begin{tikzpicture}
                draw
                circle (1) circle(2)
                (0:1) --(90:1) -- (180:1) -- (270:1) -- cycle
                (0:1) circle(1) (90:1) circle(1) (180:1) circle(1) (270:1) circle(1)
                (0:2) --(90:2) -- (180:2) -- (270:2) -- cycle
                (0:2) circle(2) (90:2) circle(2) (180:2) circle(2) (270:2) circle(2);
                end{tikzpicture}
                end{document}





                share|improve this answer













                Here is a solution (not the shortest):



                documentclass[tikz]{standalone}
                begin{document}
                begin{tikzpicture}
                draw
                circle (1) circle(2)
                (0:1) --(90:1) -- (180:1) -- (270:1) -- cycle
                (0:1) circle(1) (90:1) circle(1) (180:1) circle(1) (270:1) circle(1)
                (0:2) --(90:2) -- (180:2) -- (270:2) -- cycle
                (0:2) circle(2) (90:2) circle(2) (180:2) circle(2) (270:2) circle(2);
                end{tikzpicture}
                end{document}






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 6 hours ago









                Paul GaboritPaul Gaborit

                55.3k7140226




                55.3k7140226























                    5














                    Just for fun:



                    documentclass[tikz,margin=5mm]{standalone}
                    begin{document}
                    begin{tikzpicture}

                    draw (0,0) circle (1) circle (2);

                    foreach t/n in {0/1,90/2,180/3,270/4}{
                    draw (t:1)coordinate(n) circle (1) ;}

                    foreach t/m in {0/5,90/6,180/7,270/8}{
                    draw (t:2)coordinate(m) circle (2) ;}

                    draw (1)--(2)--(3)--(4)--cycle;
                    draw (5)--(6)--(7)--(8)--cycle;


                    end{tikzpicture}
                    end{document}





                    share|improve this answer






























                      5














                      Just for fun:



                      documentclass[tikz,margin=5mm]{standalone}
                      begin{document}
                      begin{tikzpicture}

                      draw (0,0) circle (1) circle (2);

                      foreach t/n in {0/1,90/2,180/3,270/4}{
                      draw (t:1)coordinate(n) circle (1) ;}

                      foreach t/m in {0/5,90/6,180/7,270/8}{
                      draw (t:2)coordinate(m) circle (2) ;}

                      draw (1)--(2)--(3)--(4)--cycle;
                      draw (5)--(6)--(7)--(8)--cycle;


                      end{tikzpicture}
                      end{document}





                      share|improve this answer




























                        5












                        5








                        5







                        Just for fun:



                        documentclass[tikz,margin=5mm]{standalone}
                        begin{document}
                        begin{tikzpicture}

                        draw (0,0) circle (1) circle (2);

                        foreach t/n in {0/1,90/2,180/3,270/4}{
                        draw (t:1)coordinate(n) circle (1) ;}

                        foreach t/m in {0/5,90/6,180/7,270/8}{
                        draw (t:2)coordinate(m) circle (2) ;}

                        draw (1)--(2)--(3)--(4)--cycle;
                        draw (5)--(6)--(7)--(8)--cycle;


                        end{tikzpicture}
                        end{document}





                        share|improve this answer















                        Just for fun:



                        documentclass[tikz,margin=5mm]{standalone}
                        begin{document}
                        begin{tikzpicture}

                        draw (0,0) circle (1) circle (2);

                        foreach t/n in {0/1,90/2,180/3,270/4}{
                        draw (t:1)coordinate(n) circle (1) ;}

                        foreach t/m in {0/5,90/6,180/7,270/8}{
                        draw (t:2)coordinate(m) circle (2) ;}

                        draw (1)--(2)--(3)--(4)--cycle;
                        draw (5)--(6)--(7)--(8)--cycle;


                        end{tikzpicture}
                        end{document}






                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited 5 hours ago

























                        answered 5 hours ago









                        ferahfezaferahfeza

                        5,77911931




                        5,77911931























                            5














                            One path for everything. ;-)



                            documentclass[tikz,border=3.14mm]{standalone}
                            begin{document}
                            begin{tikzpicture}
                            draw[rotate=45] foreach Y in {1,2}
                            {(0,0) circle[radius=Y]
                            (45:Y) rectangle (225:Y)
                            foreach X in {45,135,225,315}
                            { (X:Y) circle[radius=Y]}};
                            end{tikzpicture}
                            end{document}


                            enter image description here






                            share|improve this answer






























                              5














                              One path for everything. ;-)



                              documentclass[tikz,border=3.14mm]{standalone}
                              begin{document}
                              begin{tikzpicture}
                              draw[rotate=45] foreach Y in {1,2}
                              {(0,0) circle[radius=Y]
                              (45:Y) rectangle (225:Y)
                              foreach X in {45,135,225,315}
                              { (X:Y) circle[radius=Y]}};
                              end{tikzpicture}
                              end{document}


                              enter image description here






                              share|improve this answer




























                                5












                                5








                                5







                                One path for everything. ;-)



                                documentclass[tikz,border=3.14mm]{standalone}
                                begin{document}
                                begin{tikzpicture}
                                draw[rotate=45] foreach Y in {1,2}
                                {(0,0) circle[radius=Y]
                                (45:Y) rectangle (225:Y)
                                foreach X in {45,135,225,315}
                                { (X:Y) circle[radius=Y]}};
                                end{tikzpicture}
                                end{document}


                                enter image description here






                                share|improve this answer















                                One path for everything. ;-)



                                documentclass[tikz,border=3.14mm]{standalone}
                                begin{document}
                                begin{tikzpicture}
                                draw[rotate=45] foreach Y in {1,2}
                                {(0,0) circle[radius=Y]
                                (45:Y) rectangle (225:Y)
                                foreach X in {45,135,225,315}
                                { (X:Y) circle[radius=Y]}};
                                end{tikzpicture}
                                end{document}


                                enter image description here







                                share|improve this answer














                                share|improve this answer



                                share|improve this answer








                                edited 2 hours ago

























                                answered 5 hours ago









                                marmotmarmot

                                98.3k4113218




                                98.3k4113218























                                    3














                                    Not as much as @marmot's nicely optimised answer but a try (gives more knobs for fun though):



                                    documentclass[tikz]{standalone}
                                    begin{document}
                                    begin{tikzpicture}[mystyle/.style={circle,draw,fill=none,minimum size=20, line width = 0.1pt}]
                                    foreach x/y/z in {0/0/2,0/1/2,0/-1/2,-1/0/2,1/0/2,0/0/4,0/1/4,0/-1/4,-1/0/4,1/0/4}
                                    node [mystyle, minimum size = z cm, color =black] (2) at (x, y) {};
                                    foreach x/y in {-0.7/0.7, -1.41/1.41}
                                    draw[rotate=45, line width = 0.1pt] (x , x ) rectangle (y, y);
                                    end{tikzpicture}
                                    end{document}


                                    which gives



                                    enter image description here






                                    share|improve this answer




























                                      3














                                      Not as much as @marmot's nicely optimised answer but a try (gives more knobs for fun though):



                                      documentclass[tikz]{standalone}
                                      begin{document}
                                      begin{tikzpicture}[mystyle/.style={circle,draw,fill=none,minimum size=20, line width = 0.1pt}]
                                      foreach x/y/z in {0/0/2,0/1/2,0/-1/2,-1/0/2,1/0/2,0/0/4,0/1/4,0/-1/4,-1/0/4,1/0/4}
                                      node [mystyle, minimum size = z cm, color =black] (2) at (x, y) {};
                                      foreach x/y in {-0.7/0.7, -1.41/1.41}
                                      draw[rotate=45, line width = 0.1pt] (x , x ) rectangle (y, y);
                                      end{tikzpicture}
                                      end{document}


                                      which gives



                                      enter image description here






                                      share|improve this answer


























                                        3












                                        3








                                        3







                                        Not as much as @marmot's nicely optimised answer but a try (gives more knobs for fun though):



                                        documentclass[tikz]{standalone}
                                        begin{document}
                                        begin{tikzpicture}[mystyle/.style={circle,draw,fill=none,minimum size=20, line width = 0.1pt}]
                                        foreach x/y/z in {0/0/2,0/1/2,0/-1/2,-1/0/2,1/0/2,0/0/4,0/1/4,0/-1/4,-1/0/4,1/0/4}
                                        node [mystyle, minimum size = z cm, color =black] (2) at (x, y) {};
                                        foreach x/y in {-0.7/0.7, -1.41/1.41}
                                        draw[rotate=45, line width = 0.1pt] (x , x ) rectangle (y, y);
                                        end{tikzpicture}
                                        end{document}


                                        which gives



                                        enter image description here






                                        share|improve this answer













                                        Not as much as @marmot's nicely optimised answer but a try (gives more knobs for fun though):



                                        documentclass[tikz]{standalone}
                                        begin{document}
                                        begin{tikzpicture}[mystyle/.style={circle,draw,fill=none,minimum size=20, line width = 0.1pt}]
                                        foreach x/y/z in {0/0/2,0/1/2,0/-1/2,-1/0/2,1/0/2,0/0/4,0/1/4,0/-1/4,-1/0/4,1/0/4}
                                        node [mystyle, minimum size = z cm, color =black] (2) at (x, y) {};
                                        foreach x/y in {-0.7/0.7, -1.41/1.41}
                                        draw[rotate=45, line width = 0.1pt] (x , x ) rectangle (y, y);
                                        end{tikzpicture}
                                        end{document}


                                        which gives



                                        enter image description here







                                        share|improve this answer












                                        share|improve this answer



                                        share|improve this answer










                                        answered 5 hours ago









                                        RaajaRaaja

                                        3,60521037




                                        3,60521037























                                            1














                                            I am participating in the celebration with two proposals, both of which have been made:



                                            Two loops:




                                            • the first one to make an enlargement (scale) by two

                                            • the second to build the 4 circles and the square using polar coordinates


                                            The code is indented so that it can be read:



                                            First proposal (easier to read):



                                            documentclass{article}
                                            usepackage{amsmath}
                                            usepackage{tikz}
                                            begin{document}
                                            La version de TikZ est : pgfversion

                                            vfill

                                            begin{center}
                                            begin{tikzpicture}
                                            foreach s in {1,2}{
                                            begin{scope}[scale=s]
                                            draw (0,0) circle (1);
                                            foreach r [remember= r as rr (initially 270)] in {0,90,180,270}{
                                            draw (r:1) circle (1);
                                            draw (rr:1)--(r:1);
                                            }
                                            end{scope}
                                            }
                                            end{tikzpicture}
                                            end{center}
                                            end{document}


                                            screenshot



                                            Second proposal (with one less scope environment):



                                            documentclass{article}
                                            usepackage{amsmath}
                                            usepackage{tikz}
                                            begin{document}
                                            La version de TikZ est : pgfversion

                                            vfill

                                            begin{center}
                                            begin{tikzpicture}
                                            foreach s in {1,2}{
                                            draw (0,0) circle (s);
                                            foreach r [remember= r as rr (initially 270)] in {0,90,180,270}{
                                            draw (r:s) circle (s);
                                            draw (rr:s)--(r:s);
                                            }
                                            }
                                            end{tikzpicture}
                                            end{center}
                                            end{document}





                                            share|improve this answer






























                                              1














                                              I am participating in the celebration with two proposals, both of which have been made:



                                              Two loops:




                                              • the first one to make an enlargement (scale) by two

                                              • the second to build the 4 circles and the square using polar coordinates


                                              The code is indented so that it can be read:



                                              First proposal (easier to read):



                                              documentclass{article}
                                              usepackage{amsmath}
                                              usepackage{tikz}
                                              begin{document}
                                              La version de TikZ est : pgfversion

                                              vfill

                                              begin{center}
                                              begin{tikzpicture}
                                              foreach s in {1,2}{
                                              begin{scope}[scale=s]
                                              draw (0,0) circle (1);
                                              foreach r [remember= r as rr (initially 270)] in {0,90,180,270}{
                                              draw (r:1) circle (1);
                                              draw (rr:1)--(r:1);
                                              }
                                              end{scope}
                                              }
                                              end{tikzpicture}
                                              end{center}
                                              end{document}


                                              screenshot



                                              Second proposal (with one less scope environment):



                                              documentclass{article}
                                              usepackage{amsmath}
                                              usepackage{tikz}
                                              begin{document}
                                              La version de TikZ est : pgfversion

                                              vfill

                                              begin{center}
                                              begin{tikzpicture}
                                              foreach s in {1,2}{
                                              draw (0,0) circle (s);
                                              foreach r [remember= r as rr (initially 270)] in {0,90,180,270}{
                                              draw (r:s) circle (s);
                                              draw (rr:s)--(r:s);
                                              }
                                              }
                                              end{tikzpicture}
                                              end{center}
                                              end{document}





                                              share|improve this answer




























                                                1












                                                1








                                                1







                                                I am participating in the celebration with two proposals, both of which have been made:



                                                Two loops:




                                                • the first one to make an enlargement (scale) by two

                                                • the second to build the 4 circles and the square using polar coordinates


                                                The code is indented so that it can be read:



                                                First proposal (easier to read):



                                                documentclass{article}
                                                usepackage{amsmath}
                                                usepackage{tikz}
                                                begin{document}
                                                La version de TikZ est : pgfversion

                                                vfill

                                                begin{center}
                                                begin{tikzpicture}
                                                foreach s in {1,2}{
                                                begin{scope}[scale=s]
                                                draw (0,0) circle (1);
                                                foreach r [remember= r as rr (initially 270)] in {0,90,180,270}{
                                                draw (r:1) circle (1);
                                                draw (rr:1)--(r:1);
                                                }
                                                end{scope}
                                                }
                                                end{tikzpicture}
                                                end{center}
                                                end{document}


                                                screenshot



                                                Second proposal (with one less scope environment):



                                                documentclass{article}
                                                usepackage{amsmath}
                                                usepackage{tikz}
                                                begin{document}
                                                La version de TikZ est : pgfversion

                                                vfill

                                                begin{center}
                                                begin{tikzpicture}
                                                foreach s in {1,2}{
                                                draw (0,0) circle (s);
                                                foreach r [remember= r as rr (initially 270)] in {0,90,180,270}{
                                                draw (r:s) circle (s);
                                                draw (rr:s)--(r:s);
                                                }
                                                }
                                                end{tikzpicture}
                                                end{center}
                                                end{document}





                                                share|improve this answer















                                                I am participating in the celebration with two proposals, both of which have been made:



                                                Two loops:




                                                • the first one to make an enlargement (scale) by two

                                                • the second to build the 4 circles and the square using polar coordinates


                                                The code is indented so that it can be read:



                                                First proposal (easier to read):



                                                documentclass{article}
                                                usepackage{amsmath}
                                                usepackage{tikz}
                                                begin{document}
                                                La version de TikZ est : pgfversion

                                                vfill

                                                begin{center}
                                                begin{tikzpicture}
                                                foreach s in {1,2}{
                                                begin{scope}[scale=s]
                                                draw (0,0) circle (1);
                                                foreach r [remember= r as rr (initially 270)] in {0,90,180,270}{
                                                draw (r:1) circle (1);
                                                draw (rr:1)--(r:1);
                                                }
                                                end{scope}
                                                }
                                                end{tikzpicture}
                                                end{center}
                                                end{document}


                                                screenshot



                                                Second proposal (with one less scope environment):



                                                documentclass{article}
                                                usepackage{amsmath}
                                                usepackage{tikz}
                                                begin{document}
                                                La version de TikZ est : pgfversion

                                                vfill

                                                begin{center}
                                                begin{tikzpicture}
                                                foreach s in {1,2}{
                                                draw (0,0) circle (s);
                                                foreach r [remember= r as rr (initially 270)] in {0,90,180,270}{
                                                draw (r:s) circle (s);
                                                draw (rr:s)--(r:s);
                                                }
                                                }
                                                end{tikzpicture}
                                                end{center}
                                                end{document}






                                                share|improve this answer














                                                share|improve this answer



                                                share|improve this answer








                                                edited 2 hours ago

























                                                answered 2 hours ago









                                                AndréCAndréC

                                                8,86911447




                                                8,86911447






















                                                    mou-nadal is a new contributor. Be nice, and check out our Code of Conduct.










                                                    draft saved

                                                    draft discarded


















                                                    mou-nadal is a new contributor. Be nice, and check out our Code of Conduct.













                                                    mou-nadal is a new contributor. Be nice, and check out our Code of Conduct.












                                                    mou-nadal is a new contributor. Be nice, and check out our Code of Conduct.
















                                                    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%2f473926%2fan-optimized-set-of-tikz-code%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

                                                    what is the purpose of having a “thru cal” on RF PCB?

                                                    What does Gandalf whisper to the Moth on the Orthanc in Isengard?

                                                    magento2 creating a lot of catalogrule_product_temp tables