A Spiral of numbers
up vote
2
down vote
favorite
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
add a comment |
up vote
2
down vote
favorite
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
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
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
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
tikz-pgf tikz-styles
edited 1 hour ago
asked 1 hour ago
kan
3,14612154
3,14612154
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
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:
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}
Thank you so much for your help! Much appreciated!
– kan
1 min ago
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
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:
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}
Thank you so much for your help! Much appreciated!
– kan
1 min ago
add a comment |
up vote
2
down vote
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:
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}
Thank you so much for your help! Much appreciated!
– kan
1 min ago
add a comment |
up vote
2
down vote
up vote
2
down vote
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:
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}
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:
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}
answered 12 mins ago
Andrew
29.7k34279
29.7k34279
Thank you so much for your help! Much appreciated!
– kan
1 min ago
add a comment |
Thank you so much for your help! Much appreciated!
– kan
1 min ago
Thank you so much for your help! Much appreciated!
– kan
1 min ago
Thank you so much for your help! Much appreciated!
– kan
1 min ago
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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