A Spiral of numbers











up vote
11
down vote

favorite
2












I am trying to produce a spiral of numbers from 1 through 101 with the following properties:



-- multiples of 5 are in a node shaped like pentagon



-- there is a special starburst node at numbers 3, 6, 11, 13, 17, 23, 29, 37, 43, 52, 56, 61, 63, 68, 69, 71, 72, 80, 91, 99.



(I think one could use the shapes.geometric library to achieve both of these if only I could figure out how to switch styles at specific values of x in the loop below.)



Here is where I am (with help from here):



documentclass[parskip]{scrartcl}
usepackage[margin=15mm]{geometry}
usepackage{stix}
usepackage{tikz}
usetikzlibrary{shapes.geometric}
usetikzlibrary{calc}
usepackage{pifont}
usepackage{wasysym}
usepackage{graphicx}

begin{document}
hspace{0pt} vfill
begin{center}
newcounter{cntRoot}
begin{tikzpicture}
coordinate (a) at (0,0);
coordinate (b) at (0:1);
foreach x in {1,...,100}{%
coordinate (c) at ($(b)!0.9cm!270:(a)$);
setcounter{cntRoot}{x}
addtocounter{cntRoot}{1}
node[fill=white,draw,circle,inner sep=1pt] at (c)
{$thecntRoot$};
coordinate (b) at (c);
};
end{tikzpicture}
end{center}
vfill
end{document}


I tried to implement ideas from this answer without much success. Any help would be much appreciated!










share|improve this question




























    up vote
    11
    down vote

    favorite
    2












    I am trying to produce a spiral of numbers from 1 through 101 with the following properties:



    -- multiples of 5 are in a node shaped like pentagon



    -- there is a special starburst node at numbers 3, 6, 11, 13, 17, 23, 29, 37, 43, 52, 56, 61, 63, 68, 69, 71, 72, 80, 91, 99.



    (I think one could use the shapes.geometric library to achieve both of these if only I could figure out how to switch styles at specific values of x in the loop below.)



    Here is where I am (with help from here):



    documentclass[parskip]{scrartcl}
    usepackage[margin=15mm]{geometry}
    usepackage{stix}
    usepackage{tikz}
    usetikzlibrary{shapes.geometric}
    usetikzlibrary{calc}
    usepackage{pifont}
    usepackage{wasysym}
    usepackage{graphicx}

    begin{document}
    hspace{0pt} vfill
    begin{center}
    newcounter{cntRoot}
    begin{tikzpicture}
    coordinate (a) at (0,0);
    coordinate (b) at (0:1);
    foreach x in {1,...,100}{%
    coordinate (c) at ($(b)!0.9cm!270:(a)$);
    setcounter{cntRoot}{x}
    addtocounter{cntRoot}{1}
    node[fill=white,draw,circle,inner sep=1pt] at (c)
    {$thecntRoot$};
    coordinate (b) at (c);
    };
    end{tikzpicture}
    end{center}
    vfill
    end{document}


    I tried to implement ideas from this answer without much success. Any help would be much appreciated!










    share|improve this question


























      up vote
      11
      down vote

      favorite
      2









      up vote
      11
      down vote

      favorite
      2






      2





      I am trying to produce a spiral of numbers from 1 through 101 with the following properties:



      -- multiples of 5 are in a node shaped like pentagon



      -- there is a special starburst node at numbers 3, 6, 11, 13, 17, 23, 29, 37, 43, 52, 56, 61, 63, 68, 69, 71, 72, 80, 91, 99.



      (I think one could use the shapes.geometric library to achieve both of these if only I could figure out how to switch styles at specific values of x in the loop below.)



      Here is where I am (with help from here):



      documentclass[parskip]{scrartcl}
      usepackage[margin=15mm]{geometry}
      usepackage{stix}
      usepackage{tikz}
      usetikzlibrary{shapes.geometric}
      usetikzlibrary{calc}
      usepackage{pifont}
      usepackage{wasysym}
      usepackage{graphicx}

      begin{document}
      hspace{0pt} vfill
      begin{center}
      newcounter{cntRoot}
      begin{tikzpicture}
      coordinate (a) at (0,0);
      coordinate (b) at (0:1);
      foreach x in {1,...,100}{%
      coordinate (c) at ($(b)!0.9cm!270:(a)$);
      setcounter{cntRoot}{x}
      addtocounter{cntRoot}{1}
      node[fill=white,draw,circle,inner sep=1pt] at (c)
      {$thecntRoot$};
      coordinate (b) at (c);
      };
      end{tikzpicture}
      end{center}
      vfill
      end{document}


      I tried to implement ideas from this answer without much success. Any help would be much appreciated!










      share|improve this question















      I am trying to produce a spiral of numbers from 1 through 101 with the following properties:



      -- multiples of 5 are in a node shaped like pentagon



      -- there is a special starburst node at numbers 3, 6, 11, 13, 17, 23, 29, 37, 43, 52, 56, 61, 63, 68, 69, 71, 72, 80, 91, 99.



      (I think one could use the shapes.geometric library to achieve both of these if only I could figure out how to switch styles at specific values of x in the loop below.)



      Here is where I am (with help from here):



      documentclass[parskip]{scrartcl}
      usepackage[margin=15mm]{geometry}
      usepackage{stix}
      usepackage{tikz}
      usetikzlibrary{shapes.geometric}
      usetikzlibrary{calc}
      usepackage{pifont}
      usepackage{wasysym}
      usepackage{graphicx}

      begin{document}
      hspace{0pt} vfill
      begin{center}
      newcounter{cntRoot}
      begin{tikzpicture}
      coordinate (a) at (0,0);
      coordinate (b) at (0:1);
      foreach x in {1,...,100}{%
      coordinate (c) at ($(b)!0.9cm!270:(a)$);
      setcounter{cntRoot}{x}
      addtocounter{cntRoot}{1}
      node[fill=white,draw,circle,inner sep=1pt] at (c)
      {$thecntRoot$};
      coordinate (b) at (c);
      };
      end{tikzpicture}
      end{center}
      vfill
      end{document}


      I tried to implement ideas from this answer without much success. Any help would be much appreciated!







      tikz-pgf tikz-styles






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 3 at 4:19

























      asked Dec 3 at 4:14









      kan

      3,19312155




      3,19312155






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          21
          down vote



          accepted










          I am sure that there is a more efficient way of dealing with your starbursts (for example, using LaTeX3), but the code below deals with them by first defining a comma separated list of special numbers and them looping through all of them to see if there is a match. The numbers mod 5 are easy to deal with using pgfmathparseresult.



          The end result is then:



          enter image description here



          Here is the code:



          documentclass[parskip]{scrartcl}
          usepackage[margin=15mm]{geometry}
          usepackage{stix}
          usepackage{tikz}
          usetikzlibrary{shapes,shapes.geometric,calc}
          usepackage{pifont}
          usepackage{wasysym}
          usepackage{graphicx}
          newififnotfound% to mark the stars as we print them
          newcommandstarbursts{3,6,11,13,17,23,29,37,43,52,56,61,63,68,69,71,72,80,91,99}
          begin{document}

          begin{tikzpicture}
          coordinate (a) at (0,0);
          coordinate (b) at (0:1);
          foreach x in {1,...,100}{%
          coordinate (c) at ($(b)!0.9cm!270:(a)$);
          pgfmathparse{int(mod(x,5))}
          ifnumpgfmathresult=0
          node[fill=white,draw,regular polygon, regular polygon sides=5,inner sep=1pt] at (c) {$x$};
          else
          notfoundtrue% this will mark any starbursts
          foreach y in starbursts {% check for stars
          ifnumx=y% a star is born!
          node[fill=white,draw,starburst,inner sep=1pt] at (c) {$x$};
          globalnotfoundfalse% need global as inside a loop
          fi
          }
          ifnotfound% we have not printed a node yet
          node[fill=white,draw,circle,inner sep=1pt] at (c) {$x$};
          fi
          fi
          coordinate (b) at (c);
          };
          end{tikzpicture}

          end{document}


          EDIT



          Here's a LaTeX3 version. The code is much neater but it is also slower in the sense that my laptop returns the following timings:




          tikz: real 2.436 user 2.136 sys 0.281 pcpu 99.18



          tikz: real 2.479 user 2.169 sys 0.294 pcpu 99.34



          expl: real 2.557 user 2.250 sys 0.293 pcpu 99.45



          expl: real 2.552 user 2.238 sys 0.301 pcpu 99.49




          The output is the same as above. Here's the revised code:



          documentclass[parskip]{scrartcl}
          usepackage[margin=15mm]{geometry}
          usepackage{stix}
          usepackage{tikz}
          usetikzlibrary{shapes,shapes.geometric,calc}
          usepackage{pifont}
          usepackage{wasysym}
          usepackage{graphicx}

          tikzset{
          mynode/.style = {fill=white,draw,inner sep=1pt}
          }
          usepackage{expl3}
          ExplSyntaxOn
          clist_new:N l_starbursts
          clist_set:Nn l_starbursts {3,6,11,13,17,23,29,37,43,52,56,61,63,68,69,71,72,80,91,99}
          newcommandSetNode[1]{
          int_compare:nTF { int_mod:nn { #1 } { 5 } = 0 }
          {tikzset{mynode/.append~style={regular~polygon, regular~polygon~sides=5}}}
          {
          clist_if_in:NoTF l_starbursts {#1}
          {tikzset{mynode/.append~style={starburst}}}
          {tikzset{mynode/.append~style={circle}}}
          }
          }
          cs_generate_variant:Nn clist_if_in:NnTF {noTF}
          ExplSyntaxOff

          newififnotfound% to mark the stars as we print them
          begin{document}

          begin{tikzpicture}
          coordinate (a) at (0,0);
          coordinate (b) at (0:1);
          foreach x in {1,...,100}{%
          coordinate (c) at ($(b)!0.9cm!270:(a)$);
          SetNode{x}
          node[mynode] at (c) {$x$};
          coordinate (b) at (c);
          };
          end{tikzpicture}

          end{document}


          EDIT II



          Here is a third "plain TeX" approach following jfbu's suggestion and where the stars take precedence over the hexagons (unlike above, as pointed out by sgmoye in the comments). I switched to plain TeX because, surprisingly, using LaTeX3 sequences in a similar fashion led to slower code. Perhaps clists would be better? It could also be that the first solution draws the nodes directly whereas solutions II and III use some tikzset{...} trickery. Anyway, here is the code:



          documentclass[parskip]{scrartcl}
          usepackage[margin=15mm]{geometry}
          usepackage{stix}
          usepackage{tikz}
          usetikzlibrary{shapes,shapes.geometric,calc}
          usepackage{pifont}
          usepackage{wasysym}
          usepackage{graphicx}

          tikzset{
          mynode/.style = {fill=white,draw,inner sep=1pt}
          }
          newcommandstarbursts{3,6,11,13,17,23,29,37,43,52,56,61,63,68,69,71,72,80,91,99}
          defsetnextstar#1,#2!{%
          ifrelaxdetokenize{#1}relaxgdefnextstar{200}elsegdefnextstar{#1}gdefstarbursts{#2}fi%
          }
          expandaftersetnextstarstarbursts,,!

          newcommandSetNode[1]{
          ifnum#1=nextstar
          tikzset{mynode/.append style={starburst}}
          expandaftersetnextstarstarbursts!
          else
          pgfmathparse{int(mod(x,5))}
          ifnumpgfmathresult=0
          tikzset{mynode/.append style={regular polygon, regular polygon sides=5}}
          else
          tikzset{mynode/.append style={circle}}
          fi
          fi
          }
          begin{document}

          begin{tikzpicture}
          coordinate (a) at (0,0);
          coordinate (b) at (0:1);
          foreach x in {1,...,100}{%
          coordinate (c) at ($(b)!0.9cm!270:(a)$);
          SetNode{x}
          node[mynode] at (c) {$x$};
          coordinate (b) at (c);
          };
          end{tikzpicture}

          end{document}


          The output is slightly different in that 80 now has a star.



          enter image description here






          share|improve this answer























          • Thank you so much for your help! Much appreciated!
            – kan
            Dec 3 at 5:40










          • (Also, the comment "a star is born" had me giggling! We stan the talent!)
            – kan
            Dec 3 at 7:05










          • @kan Glad to be helpful and to amuse:)
            – Andrew
            Dec 3 at 9:56










          • you could have an evolving list (comma separated or whatever) of starbursts: compare x with the first: if < do nothing, if equal do the "star is born" and suppress that (leading) entry from list, if > you made a coding error somewhere. There should also be a flag to signal the starburst list is now empty.
            – jfbu
            Dec 3 at 10:53










          • I wondered what would happen if a number divisible by 5 were in the starburst list. Sure enough, 80 is just such a one: it is in the starburst list but is enclosed in a pentagon. Is this intended?
            – sgmoye
            Dec 3 at 12:11











          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%2f462906%2fa-spiral-of-numbers%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          21
          down vote



          accepted










          I am sure that there is a more efficient way of dealing with your starbursts (for example, using LaTeX3), but the code below deals with them by first defining a comma separated list of special numbers and them looping through all of them to see if there is a match. The numbers mod 5 are easy to deal with using pgfmathparseresult.



          The end result is then:



          enter image description here



          Here is the code:



          documentclass[parskip]{scrartcl}
          usepackage[margin=15mm]{geometry}
          usepackage{stix}
          usepackage{tikz}
          usetikzlibrary{shapes,shapes.geometric,calc}
          usepackage{pifont}
          usepackage{wasysym}
          usepackage{graphicx}
          newififnotfound% to mark the stars as we print them
          newcommandstarbursts{3,6,11,13,17,23,29,37,43,52,56,61,63,68,69,71,72,80,91,99}
          begin{document}

          begin{tikzpicture}
          coordinate (a) at (0,0);
          coordinate (b) at (0:1);
          foreach x in {1,...,100}{%
          coordinate (c) at ($(b)!0.9cm!270:(a)$);
          pgfmathparse{int(mod(x,5))}
          ifnumpgfmathresult=0
          node[fill=white,draw,regular polygon, regular polygon sides=5,inner sep=1pt] at (c) {$x$};
          else
          notfoundtrue% this will mark any starbursts
          foreach y in starbursts {% check for stars
          ifnumx=y% a star is born!
          node[fill=white,draw,starburst,inner sep=1pt] at (c) {$x$};
          globalnotfoundfalse% need global as inside a loop
          fi
          }
          ifnotfound% we have not printed a node yet
          node[fill=white,draw,circle,inner sep=1pt] at (c) {$x$};
          fi
          fi
          coordinate (b) at (c);
          };
          end{tikzpicture}

          end{document}


          EDIT



          Here's a LaTeX3 version. The code is much neater but it is also slower in the sense that my laptop returns the following timings:




          tikz: real 2.436 user 2.136 sys 0.281 pcpu 99.18



          tikz: real 2.479 user 2.169 sys 0.294 pcpu 99.34



          expl: real 2.557 user 2.250 sys 0.293 pcpu 99.45



          expl: real 2.552 user 2.238 sys 0.301 pcpu 99.49




          The output is the same as above. Here's the revised code:



          documentclass[parskip]{scrartcl}
          usepackage[margin=15mm]{geometry}
          usepackage{stix}
          usepackage{tikz}
          usetikzlibrary{shapes,shapes.geometric,calc}
          usepackage{pifont}
          usepackage{wasysym}
          usepackage{graphicx}

          tikzset{
          mynode/.style = {fill=white,draw,inner sep=1pt}
          }
          usepackage{expl3}
          ExplSyntaxOn
          clist_new:N l_starbursts
          clist_set:Nn l_starbursts {3,6,11,13,17,23,29,37,43,52,56,61,63,68,69,71,72,80,91,99}
          newcommandSetNode[1]{
          int_compare:nTF { int_mod:nn { #1 } { 5 } = 0 }
          {tikzset{mynode/.append~style={regular~polygon, regular~polygon~sides=5}}}
          {
          clist_if_in:NoTF l_starbursts {#1}
          {tikzset{mynode/.append~style={starburst}}}
          {tikzset{mynode/.append~style={circle}}}
          }
          }
          cs_generate_variant:Nn clist_if_in:NnTF {noTF}
          ExplSyntaxOff

          newififnotfound% to mark the stars as we print them
          begin{document}

          begin{tikzpicture}
          coordinate (a) at (0,0);
          coordinate (b) at (0:1);
          foreach x in {1,...,100}{%
          coordinate (c) at ($(b)!0.9cm!270:(a)$);
          SetNode{x}
          node[mynode] at (c) {$x$};
          coordinate (b) at (c);
          };
          end{tikzpicture}

          end{document}


          EDIT II



          Here is a third "plain TeX" approach following jfbu's suggestion and where the stars take precedence over the hexagons (unlike above, as pointed out by sgmoye in the comments). I switched to plain TeX because, surprisingly, using LaTeX3 sequences in a similar fashion led to slower code. Perhaps clists would be better? It could also be that the first solution draws the nodes directly whereas solutions II and III use some tikzset{...} trickery. Anyway, here is the code:



          documentclass[parskip]{scrartcl}
          usepackage[margin=15mm]{geometry}
          usepackage{stix}
          usepackage{tikz}
          usetikzlibrary{shapes,shapes.geometric,calc}
          usepackage{pifont}
          usepackage{wasysym}
          usepackage{graphicx}

          tikzset{
          mynode/.style = {fill=white,draw,inner sep=1pt}
          }
          newcommandstarbursts{3,6,11,13,17,23,29,37,43,52,56,61,63,68,69,71,72,80,91,99}
          defsetnextstar#1,#2!{%
          ifrelaxdetokenize{#1}relaxgdefnextstar{200}elsegdefnextstar{#1}gdefstarbursts{#2}fi%
          }
          expandaftersetnextstarstarbursts,,!

          newcommandSetNode[1]{
          ifnum#1=nextstar
          tikzset{mynode/.append style={starburst}}
          expandaftersetnextstarstarbursts!
          else
          pgfmathparse{int(mod(x,5))}
          ifnumpgfmathresult=0
          tikzset{mynode/.append style={regular polygon, regular polygon sides=5}}
          else
          tikzset{mynode/.append style={circle}}
          fi
          fi
          }
          begin{document}

          begin{tikzpicture}
          coordinate (a) at (0,0);
          coordinate (b) at (0:1);
          foreach x in {1,...,100}{%
          coordinate (c) at ($(b)!0.9cm!270:(a)$);
          SetNode{x}
          node[mynode] at (c) {$x$};
          coordinate (b) at (c);
          };
          end{tikzpicture}

          end{document}


          The output is slightly different in that 80 now has a star.



          enter image description here






          share|improve this answer























          • Thank you so much for your help! Much appreciated!
            – kan
            Dec 3 at 5:40










          • (Also, the comment "a star is born" had me giggling! We stan the talent!)
            – kan
            Dec 3 at 7:05










          • @kan Glad to be helpful and to amuse:)
            – Andrew
            Dec 3 at 9:56










          • you could have an evolving list (comma separated or whatever) of starbursts: compare x with the first: if < do nothing, if equal do the "star is born" and suppress that (leading) entry from list, if > you made a coding error somewhere. There should also be a flag to signal the starburst list is now empty.
            – jfbu
            Dec 3 at 10:53










          • I wondered what would happen if a number divisible by 5 were in the starburst list. Sure enough, 80 is just such a one: it is in the starburst list but is enclosed in a pentagon. Is this intended?
            – sgmoye
            Dec 3 at 12:11















          up vote
          21
          down vote



          accepted










          I am sure that there is a more efficient way of dealing with your starbursts (for example, using LaTeX3), but the code below deals with them by first defining a comma separated list of special numbers and them looping through all of them to see if there is a match. The numbers mod 5 are easy to deal with using pgfmathparseresult.



          The end result is then:



          enter image description here



          Here is the code:



          documentclass[parskip]{scrartcl}
          usepackage[margin=15mm]{geometry}
          usepackage{stix}
          usepackage{tikz}
          usetikzlibrary{shapes,shapes.geometric,calc}
          usepackage{pifont}
          usepackage{wasysym}
          usepackage{graphicx}
          newififnotfound% to mark the stars as we print them
          newcommandstarbursts{3,6,11,13,17,23,29,37,43,52,56,61,63,68,69,71,72,80,91,99}
          begin{document}

          begin{tikzpicture}
          coordinate (a) at (0,0);
          coordinate (b) at (0:1);
          foreach x in {1,...,100}{%
          coordinate (c) at ($(b)!0.9cm!270:(a)$);
          pgfmathparse{int(mod(x,5))}
          ifnumpgfmathresult=0
          node[fill=white,draw,regular polygon, regular polygon sides=5,inner sep=1pt] at (c) {$x$};
          else
          notfoundtrue% this will mark any starbursts
          foreach y in starbursts {% check for stars
          ifnumx=y% a star is born!
          node[fill=white,draw,starburst,inner sep=1pt] at (c) {$x$};
          globalnotfoundfalse% need global as inside a loop
          fi
          }
          ifnotfound% we have not printed a node yet
          node[fill=white,draw,circle,inner sep=1pt] at (c) {$x$};
          fi
          fi
          coordinate (b) at (c);
          };
          end{tikzpicture}

          end{document}


          EDIT



          Here's a LaTeX3 version. The code is much neater but it is also slower in the sense that my laptop returns the following timings:




          tikz: real 2.436 user 2.136 sys 0.281 pcpu 99.18



          tikz: real 2.479 user 2.169 sys 0.294 pcpu 99.34



          expl: real 2.557 user 2.250 sys 0.293 pcpu 99.45



          expl: real 2.552 user 2.238 sys 0.301 pcpu 99.49




          The output is the same as above. Here's the revised code:



          documentclass[parskip]{scrartcl}
          usepackage[margin=15mm]{geometry}
          usepackage{stix}
          usepackage{tikz}
          usetikzlibrary{shapes,shapes.geometric,calc}
          usepackage{pifont}
          usepackage{wasysym}
          usepackage{graphicx}

          tikzset{
          mynode/.style = {fill=white,draw,inner sep=1pt}
          }
          usepackage{expl3}
          ExplSyntaxOn
          clist_new:N l_starbursts
          clist_set:Nn l_starbursts {3,6,11,13,17,23,29,37,43,52,56,61,63,68,69,71,72,80,91,99}
          newcommandSetNode[1]{
          int_compare:nTF { int_mod:nn { #1 } { 5 } = 0 }
          {tikzset{mynode/.append~style={regular~polygon, regular~polygon~sides=5}}}
          {
          clist_if_in:NoTF l_starbursts {#1}
          {tikzset{mynode/.append~style={starburst}}}
          {tikzset{mynode/.append~style={circle}}}
          }
          }
          cs_generate_variant:Nn clist_if_in:NnTF {noTF}
          ExplSyntaxOff

          newififnotfound% to mark the stars as we print them
          begin{document}

          begin{tikzpicture}
          coordinate (a) at (0,0);
          coordinate (b) at (0:1);
          foreach x in {1,...,100}{%
          coordinate (c) at ($(b)!0.9cm!270:(a)$);
          SetNode{x}
          node[mynode] at (c) {$x$};
          coordinate (b) at (c);
          };
          end{tikzpicture}

          end{document}


          EDIT II



          Here is a third "plain TeX" approach following jfbu's suggestion and where the stars take precedence over the hexagons (unlike above, as pointed out by sgmoye in the comments). I switched to plain TeX because, surprisingly, using LaTeX3 sequences in a similar fashion led to slower code. Perhaps clists would be better? It could also be that the first solution draws the nodes directly whereas solutions II and III use some tikzset{...} trickery. Anyway, here is the code:



          documentclass[parskip]{scrartcl}
          usepackage[margin=15mm]{geometry}
          usepackage{stix}
          usepackage{tikz}
          usetikzlibrary{shapes,shapes.geometric,calc}
          usepackage{pifont}
          usepackage{wasysym}
          usepackage{graphicx}

          tikzset{
          mynode/.style = {fill=white,draw,inner sep=1pt}
          }
          newcommandstarbursts{3,6,11,13,17,23,29,37,43,52,56,61,63,68,69,71,72,80,91,99}
          defsetnextstar#1,#2!{%
          ifrelaxdetokenize{#1}relaxgdefnextstar{200}elsegdefnextstar{#1}gdefstarbursts{#2}fi%
          }
          expandaftersetnextstarstarbursts,,!

          newcommandSetNode[1]{
          ifnum#1=nextstar
          tikzset{mynode/.append style={starburst}}
          expandaftersetnextstarstarbursts!
          else
          pgfmathparse{int(mod(x,5))}
          ifnumpgfmathresult=0
          tikzset{mynode/.append style={regular polygon, regular polygon sides=5}}
          else
          tikzset{mynode/.append style={circle}}
          fi
          fi
          }
          begin{document}

          begin{tikzpicture}
          coordinate (a) at (0,0);
          coordinate (b) at (0:1);
          foreach x in {1,...,100}{%
          coordinate (c) at ($(b)!0.9cm!270:(a)$);
          SetNode{x}
          node[mynode] at (c) {$x$};
          coordinate (b) at (c);
          };
          end{tikzpicture}

          end{document}


          The output is slightly different in that 80 now has a star.



          enter image description here






          share|improve this answer























          • Thank you so much for your help! Much appreciated!
            – kan
            Dec 3 at 5:40










          • (Also, the comment "a star is born" had me giggling! We stan the talent!)
            – kan
            Dec 3 at 7:05










          • @kan Glad to be helpful and to amuse:)
            – Andrew
            Dec 3 at 9:56










          • you could have an evolving list (comma separated or whatever) of starbursts: compare x with the first: if < do nothing, if equal do the "star is born" and suppress that (leading) entry from list, if > you made a coding error somewhere. There should also be a flag to signal the starburst list is now empty.
            – jfbu
            Dec 3 at 10:53










          • I wondered what would happen if a number divisible by 5 were in the starburst list. Sure enough, 80 is just such a one: it is in the starburst list but is enclosed in a pentagon. Is this intended?
            – sgmoye
            Dec 3 at 12:11













          up vote
          21
          down vote



          accepted







          up vote
          21
          down vote



          accepted






          I am sure that there is a more efficient way of dealing with your starbursts (for example, using LaTeX3), but the code below deals with them by first defining a comma separated list of special numbers and them looping through all of them to see if there is a match. The numbers mod 5 are easy to deal with using pgfmathparseresult.



          The end result is then:



          enter image description here



          Here is the code:



          documentclass[parskip]{scrartcl}
          usepackage[margin=15mm]{geometry}
          usepackage{stix}
          usepackage{tikz}
          usetikzlibrary{shapes,shapes.geometric,calc}
          usepackage{pifont}
          usepackage{wasysym}
          usepackage{graphicx}
          newififnotfound% to mark the stars as we print them
          newcommandstarbursts{3,6,11,13,17,23,29,37,43,52,56,61,63,68,69,71,72,80,91,99}
          begin{document}

          begin{tikzpicture}
          coordinate (a) at (0,0);
          coordinate (b) at (0:1);
          foreach x in {1,...,100}{%
          coordinate (c) at ($(b)!0.9cm!270:(a)$);
          pgfmathparse{int(mod(x,5))}
          ifnumpgfmathresult=0
          node[fill=white,draw,regular polygon, regular polygon sides=5,inner sep=1pt] at (c) {$x$};
          else
          notfoundtrue% this will mark any starbursts
          foreach y in starbursts {% check for stars
          ifnumx=y% a star is born!
          node[fill=white,draw,starburst,inner sep=1pt] at (c) {$x$};
          globalnotfoundfalse% need global as inside a loop
          fi
          }
          ifnotfound% we have not printed a node yet
          node[fill=white,draw,circle,inner sep=1pt] at (c) {$x$};
          fi
          fi
          coordinate (b) at (c);
          };
          end{tikzpicture}

          end{document}


          EDIT



          Here's a LaTeX3 version. The code is much neater but it is also slower in the sense that my laptop returns the following timings:




          tikz: real 2.436 user 2.136 sys 0.281 pcpu 99.18



          tikz: real 2.479 user 2.169 sys 0.294 pcpu 99.34



          expl: real 2.557 user 2.250 sys 0.293 pcpu 99.45



          expl: real 2.552 user 2.238 sys 0.301 pcpu 99.49




          The output is the same as above. Here's the revised code:



          documentclass[parskip]{scrartcl}
          usepackage[margin=15mm]{geometry}
          usepackage{stix}
          usepackage{tikz}
          usetikzlibrary{shapes,shapes.geometric,calc}
          usepackage{pifont}
          usepackage{wasysym}
          usepackage{graphicx}

          tikzset{
          mynode/.style = {fill=white,draw,inner sep=1pt}
          }
          usepackage{expl3}
          ExplSyntaxOn
          clist_new:N l_starbursts
          clist_set:Nn l_starbursts {3,6,11,13,17,23,29,37,43,52,56,61,63,68,69,71,72,80,91,99}
          newcommandSetNode[1]{
          int_compare:nTF { int_mod:nn { #1 } { 5 } = 0 }
          {tikzset{mynode/.append~style={regular~polygon, regular~polygon~sides=5}}}
          {
          clist_if_in:NoTF l_starbursts {#1}
          {tikzset{mynode/.append~style={starburst}}}
          {tikzset{mynode/.append~style={circle}}}
          }
          }
          cs_generate_variant:Nn clist_if_in:NnTF {noTF}
          ExplSyntaxOff

          newififnotfound% to mark the stars as we print them
          begin{document}

          begin{tikzpicture}
          coordinate (a) at (0,0);
          coordinate (b) at (0:1);
          foreach x in {1,...,100}{%
          coordinate (c) at ($(b)!0.9cm!270:(a)$);
          SetNode{x}
          node[mynode] at (c) {$x$};
          coordinate (b) at (c);
          };
          end{tikzpicture}

          end{document}


          EDIT II



          Here is a third "plain TeX" approach following jfbu's suggestion and where the stars take precedence over the hexagons (unlike above, as pointed out by sgmoye in the comments). I switched to plain TeX because, surprisingly, using LaTeX3 sequences in a similar fashion led to slower code. Perhaps clists would be better? It could also be that the first solution draws the nodes directly whereas solutions II and III use some tikzset{...} trickery. Anyway, here is the code:



          documentclass[parskip]{scrartcl}
          usepackage[margin=15mm]{geometry}
          usepackage{stix}
          usepackage{tikz}
          usetikzlibrary{shapes,shapes.geometric,calc}
          usepackage{pifont}
          usepackage{wasysym}
          usepackage{graphicx}

          tikzset{
          mynode/.style = {fill=white,draw,inner sep=1pt}
          }
          newcommandstarbursts{3,6,11,13,17,23,29,37,43,52,56,61,63,68,69,71,72,80,91,99}
          defsetnextstar#1,#2!{%
          ifrelaxdetokenize{#1}relaxgdefnextstar{200}elsegdefnextstar{#1}gdefstarbursts{#2}fi%
          }
          expandaftersetnextstarstarbursts,,!

          newcommandSetNode[1]{
          ifnum#1=nextstar
          tikzset{mynode/.append style={starburst}}
          expandaftersetnextstarstarbursts!
          else
          pgfmathparse{int(mod(x,5))}
          ifnumpgfmathresult=0
          tikzset{mynode/.append style={regular polygon, regular polygon sides=5}}
          else
          tikzset{mynode/.append style={circle}}
          fi
          fi
          }
          begin{document}

          begin{tikzpicture}
          coordinate (a) at (0,0);
          coordinate (b) at (0:1);
          foreach x in {1,...,100}{%
          coordinate (c) at ($(b)!0.9cm!270:(a)$);
          SetNode{x}
          node[mynode] at (c) {$x$};
          coordinate (b) at (c);
          };
          end{tikzpicture}

          end{document}


          The output is slightly different in that 80 now has a star.



          enter image description here






          share|improve this answer














          I am sure that there is a more efficient way of dealing with your starbursts (for example, using LaTeX3), but the code below deals with them by first defining a comma separated list of special numbers and them looping through all of them to see if there is a match. The numbers mod 5 are easy to deal with using pgfmathparseresult.



          The end result is then:



          enter image description here



          Here is the code:



          documentclass[parskip]{scrartcl}
          usepackage[margin=15mm]{geometry}
          usepackage{stix}
          usepackage{tikz}
          usetikzlibrary{shapes,shapes.geometric,calc}
          usepackage{pifont}
          usepackage{wasysym}
          usepackage{graphicx}
          newififnotfound% to mark the stars as we print them
          newcommandstarbursts{3,6,11,13,17,23,29,37,43,52,56,61,63,68,69,71,72,80,91,99}
          begin{document}

          begin{tikzpicture}
          coordinate (a) at (0,0);
          coordinate (b) at (0:1);
          foreach x in {1,...,100}{%
          coordinate (c) at ($(b)!0.9cm!270:(a)$);
          pgfmathparse{int(mod(x,5))}
          ifnumpgfmathresult=0
          node[fill=white,draw,regular polygon, regular polygon sides=5,inner sep=1pt] at (c) {$x$};
          else
          notfoundtrue% this will mark any starbursts
          foreach y in starbursts {% check for stars
          ifnumx=y% a star is born!
          node[fill=white,draw,starburst,inner sep=1pt] at (c) {$x$};
          globalnotfoundfalse% need global as inside a loop
          fi
          }
          ifnotfound% we have not printed a node yet
          node[fill=white,draw,circle,inner sep=1pt] at (c) {$x$};
          fi
          fi
          coordinate (b) at (c);
          };
          end{tikzpicture}

          end{document}


          EDIT



          Here's a LaTeX3 version. The code is much neater but it is also slower in the sense that my laptop returns the following timings:




          tikz: real 2.436 user 2.136 sys 0.281 pcpu 99.18



          tikz: real 2.479 user 2.169 sys 0.294 pcpu 99.34



          expl: real 2.557 user 2.250 sys 0.293 pcpu 99.45



          expl: real 2.552 user 2.238 sys 0.301 pcpu 99.49




          The output is the same as above. Here's the revised code:



          documentclass[parskip]{scrartcl}
          usepackage[margin=15mm]{geometry}
          usepackage{stix}
          usepackage{tikz}
          usetikzlibrary{shapes,shapes.geometric,calc}
          usepackage{pifont}
          usepackage{wasysym}
          usepackage{graphicx}

          tikzset{
          mynode/.style = {fill=white,draw,inner sep=1pt}
          }
          usepackage{expl3}
          ExplSyntaxOn
          clist_new:N l_starbursts
          clist_set:Nn l_starbursts {3,6,11,13,17,23,29,37,43,52,56,61,63,68,69,71,72,80,91,99}
          newcommandSetNode[1]{
          int_compare:nTF { int_mod:nn { #1 } { 5 } = 0 }
          {tikzset{mynode/.append~style={regular~polygon, regular~polygon~sides=5}}}
          {
          clist_if_in:NoTF l_starbursts {#1}
          {tikzset{mynode/.append~style={starburst}}}
          {tikzset{mynode/.append~style={circle}}}
          }
          }
          cs_generate_variant:Nn clist_if_in:NnTF {noTF}
          ExplSyntaxOff

          newififnotfound% to mark the stars as we print them
          begin{document}

          begin{tikzpicture}
          coordinate (a) at (0,0);
          coordinate (b) at (0:1);
          foreach x in {1,...,100}{%
          coordinate (c) at ($(b)!0.9cm!270:(a)$);
          SetNode{x}
          node[mynode] at (c) {$x$};
          coordinate (b) at (c);
          };
          end{tikzpicture}

          end{document}


          EDIT II



          Here is a third "plain TeX" approach following jfbu's suggestion and where the stars take precedence over the hexagons (unlike above, as pointed out by sgmoye in the comments). I switched to plain TeX because, surprisingly, using LaTeX3 sequences in a similar fashion led to slower code. Perhaps clists would be better? It could also be that the first solution draws the nodes directly whereas solutions II and III use some tikzset{...} trickery. Anyway, here is the code:



          documentclass[parskip]{scrartcl}
          usepackage[margin=15mm]{geometry}
          usepackage{stix}
          usepackage{tikz}
          usetikzlibrary{shapes,shapes.geometric,calc}
          usepackage{pifont}
          usepackage{wasysym}
          usepackage{graphicx}

          tikzset{
          mynode/.style = {fill=white,draw,inner sep=1pt}
          }
          newcommandstarbursts{3,6,11,13,17,23,29,37,43,52,56,61,63,68,69,71,72,80,91,99}
          defsetnextstar#1,#2!{%
          ifrelaxdetokenize{#1}relaxgdefnextstar{200}elsegdefnextstar{#1}gdefstarbursts{#2}fi%
          }
          expandaftersetnextstarstarbursts,,!

          newcommandSetNode[1]{
          ifnum#1=nextstar
          tikzset{mynode/.append style={starburst}}
          expandaftersetnextstarstarbursts!
          else
          pgfmathparse{int(mod(x,5))}
          ifnumpgfmathresult=0
          tikzset{mynode/.append style={regular polygon, regular polygon sides=5}}
          else
          tikzset{mynode/.append style={circle}}
          fi
          fi
          }
          begin{document}

          begin{tikzpicture}
          coordinate (a) at (0,0);
          coordinate (b) at (0:1);
          foreach x in {1,...,100}{%
          coordinate (c) at ($(b)!0.9cm!270:(a)$);
          SetNode{x}
          node[mynode] at (c) {$x$};
          coordinate (b) at (c);
          };
          end{tikzpicture}

          end{document}


          The output is slightly different in that 80 now has a star.



          enter image description here







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Dec 3 at 13:08

























          answered Dec 3 at 5:29









          Andrew

          30.2k34380




          30.2k34380












          • Thank you so much for your help! Much appreciated!
            – kan
            Dec 3 at 5:40










          • (Also, the comment "a star is born" had me giggling! We stan the talent!)
            – kan
            Dec 3 at 7:05










          • @kan Glad to be helpful and to amuse:)
            – Andrew
            Dec 3 at 9:56










          • you could have an evolving list (comma separated or whatever) of starbursts: compare x with the first: if < do nothing, if equal do the "star is born" and suppress that (leading) entry from list, if > you made a coding error somewhere. There should also be a flag to signal the starburst list is now empty.
            – jfbu
            Dec 3 at 10:53










          • I wondered what would happen if a number divisible by 5 were in the starburst list. Sure enough, 80 is just such a one: it is in the starburst list but is enclosed in a pentagon. Is this intended?
            – sgmoye
            Dec 3 at 12:11


















          • Thank you so much for your help! Much appreciated!
            – kan
            Dec 3 at 5:40










          • (Also, the comment "a star is born" had me giggling! We stan the talent!)
            – kan
            Dec 3 at 7:05










          • @kan Glad to be helpful and to amuse:)
            – Andrew
            Dec 3 at 9:56










          • you could have an evolving list (comma separated or whatever) of starbursts: compare x with the first: if < do nothing, if equal do the "star is born" and suppress that (leading) entry from list, if > you made a coding error somewhere. There should also be a flag to signal the starburst list is now empty.
            – jfbu
            Dec 3 at 10:53










          • I wondered what would happen if a number divisible by 5 were in the starburst list. Sure enough, 80 is just such a one: it is in the starburst list but is enclosed in a pentagon. Is this intended?
            – sgmoye
            Dec 3 at 12:11
















          Thank you so much for your help! Much appreciated!
          – kan
          Dec 3 at 5:40




          Thank you so much for your help! Much appreciated!
          – kan
          Dec 3 at 5:40












          (Also, the comment "a star is born" had me giggling! We stan the talent!)
          – kan
          Dec 3 at 7:05




          (Also, the comment "a star is born" had me giggling! We stan the talent!)
          – kan
          Dec 3 at 7:05












          @kan Glad to be helpful and to amuse:)
          – Andrew
          Dec 3 at 9:56




          @kan Glad to be helpful and to amuse:)
          – Andrew
          Dec 3 at 9:56












          you could have an evolving list (comma separated or whatever) of starbursts: compare x with the first: if < do nothing, if equal do the "star is born" and suppress that (leading) entry from list, if > you made a coding error somewhere. There should also be a flag to signal the starburst list is now empty.
          – jfbu
          Dec 3 at 10:53




          you could have an evolving list (comma separated or whatever) of starbursts: compare x with the first: if < do nothing, if equal do the "star is born" and suppress that (leading) entry from list, if > you made a coding error somewhere. There should also be a flag to signal the starburst list is now empty.
          – jfbu
          Dec 3 at 10:53












          I wondered what would happen if a number divisible by 5 were in the starburst list. Sure enough, 80 is just such a one: it is in the starburst list but is enclosed in a pentagon. Is this intended?
          – sgmoye
          Dec 3 at 12:11




          I wondered what would happen if a number divisible by 5 were in the starburst list. Sure enough, 80 is just such a one: it is in the starburst list but is enclosed in a pentagon. Is this intended?
          – sgmoye
          Dec 3 at 12:11


















          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%2f462906%2fa-spiral-of-numbers%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

          數位音樂下載

          When can things happen in Etherscan, such as the picture below?

          格利澤436b