An optimized set of tikz code?












5















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.





















  • +1 for the MWE!!

    – Raaja
    3 hours ago











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

    – AndréC
    2 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
    2 hours ago
















5















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.





















  • +1 for the MWE!!

    – Raaja
    3 hours ago











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

    – AndréC
    2 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
    2 hours ago














5












5








5








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 17 mins ago









AndréC

8,85911447




8,85911447






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 4 hours ago









mou-nadalmou-nadal

334




334




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.













  • +1 for the MWE!!

    – Raaja
    3 hours ago











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

    – AndréC
    2 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
    2 hours ago



















  • +1 for the MWE!!

    – Raaja
    3 hours ago











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

    – AndréC
    2 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
    2 hours ago

















+1 for the MWE!!

– Raaja
3 hours ago





+1 for the MWE!!

– Raaja
3 hours ago













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

– AndréC
2 hours ago





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

– AndréC
2 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
2 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
2 hours ago










4 Answers
4






active

oldest

votes


















4














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































    4














    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

































      4














      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]
      ({-Y/sqrt(2)},{-Y/sqrt(2)}) rectangle ({Y/sqrt(2)},{Y/sqrt(2)})
      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























          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

























          4 Answers
          4






          active

          oldest

          votes








          4 Answers
          4






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          4














          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




























            4














            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


























              4












              4








              4







              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 3 hours ago









              Paul GaboritPaul Gaborit

              55.2k7140226




              55.2k7140226























                  4














                  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






























                    4














                    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




























                      4












                      4








                      4







                      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 2 hours ago

























                      answered 3 hours ago









                      ferahfezaferahfeza

                      5,76911931




                      5,76911931























                          4














                          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]
                          ({-Y/sqrt(2)},{-Y/sqrt(2)}) rectangle ({Y/sqrt(2)},{Y/sqrt(2)})
                          foreach X in {45,135,225,315}
                          { (X:Y) circle[radius=Y]}};
                          end{tikzpicture}
                          end{document}


                          enter image description here






                          share|improve this answer




























                            4














                            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]
                            ({-Y/sqrt(2)},{-Y/sqrt(2)}) rectangle ({Y/sqrt(2)},{Y/sqrt(2)})
                            foreach X in {45,135,225,315}
                            { (X:Y) circle[radius=Y]}};
                            end{tikzpicture}
                            end{document}


                            enter image description here






                            share|improve this answer


























                              4












                              4








                              4







                              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]
                              ({-Y/sqrt(2)},{-Y/sqrt(2)}) rectangle ({Y/sqrt(2)},{Y/sqrt(2)})
                              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]
                              ({-Y/sqrt(2)},{-Y/sqrt(2)}) rectangle ({Y/sqrt(2)},{Y/sqrt(2)})
                              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










                              answered 2 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 2 hours ago









                                      RaajaRaaja

                                      3,60521037




                                      3,60521037






















                                          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

                                          Callistus I

                                          Tabula Rosettana

                                          How to label and detect the document text images