Even-length cycle laid out as a starTikZ: Use --cycle in circuitsProblem with fill and cycleTikZ path labels...

Rationale to prefer local variables over instance variables?

Are Wave equations equivalent to Maxwell equations in free space?

Where does the proton come in the reduction of NAD?

I've given my players a lot of magic items. Is it reasonable for me to give them harder encounters?

Are small insurances worth it

How do you make a gun that shoots melee weapons and/or swords?

Is divide-by-zero a security vulnerability?

How do we objectively assess if a dialogue sounds unnatural or cringy?

Are there other characters in the Star Wars universe who had damaged bodies and needed to wear an outfit like Darth Vader?

Learning to quickly identify valid fingering for piano?

Is this nominative case or accusative case?

Can a Mexican citizen living in US under DACA drive to Canada?

In the world of The Matrix, what is "popping"?

Practical reasons to have both a large police force and bounty hunting network?

Is there a way to find out the age of climbing ropes?

Can a Mimic (container form) actually hold loot?

Should I use HTTPS on a domain that will only be used for redirection?

What is the oldest European royal house?

Convert an array of objects to array of the objects' values

ESPP--any reason not to go all in?

Forcing Mathematica's Integrate to give more general answers

Did Amazon pay $0 in taxes last year?

Effect of "wrong" driver with slightly long RS-485 stubs

Quitting employee has privileged access to critical information



Even-length cycle laid out as a star


TikZ: Use --cycle in circuitsProblem with fill and cycleTikZ path labels and --cyclephases (stages) of economic cycleNode placement, cycle, and scalingHow to cut out a scope using “even odd rule”Creating large star graphTikz fill area enclosed by cycleReduce length of arrow from block diagramTikzing a circled star













3















For demonstration purposes, I want to obtain a graph of C10 shaped as a star. I have been working on this for much longer than I should have. I currently have this:



begin{figure}
centering
begin{tikzpicture}[nodes={circle, draw}]
foreach i in {1,...,10}
{
pgfmathisodd{i};
node (Ni) at (360/10*i:pgfmathresult?18mm:9mm) {i};
}
foreach i in {1,...,10}
{
pgfmathmod{i}{10}
pgfmathadd{pgfmathresult}{1};
path (Ni) edge (Npgfmathresult);
}
end{tikzpicture}
end{figure}


Which outputs the following abomination:



enter image description here



I don't know if the same ugliness would happen had I typed out the nodes myself.










share|improve this question























  • The "abomination" is simply all numbers aligned the same way. Try instead of defining the points recursively like you did and then in a second step add the lines and then the numbers. This should make it better :)

    – Superuser27
    5 hours ago











  • What I mean is: if you just look at how the numbers are positioned, they look fine. It's just the lines starting from weird places.

    – Superuser27
    5 hours ago











  • I have given up and written every node one by one. It works! The question is even more curious to me now.

    – ThoAppelsin
    5 hours ago
















3















For demonstration purposes, I want to obtain a graph of C10 shaped as a star. I have been working on this for much longer than I should have. I currently have this:



begin{figure}
centering
begin{tikzpicture}[nodes={circle, draw}]
foreach i in {1,...,10}
{
pgfmathisodd{i};
node (Ni) at (360/10*i:pgfmathresult?18mm:9mm) {i};
}
foreach i in {1,...,10}
{
pgfmathmod{i}{10}
pgfmathadd{pgfmathresult}{1};
path (Ni) edge (Npgfmathresult);
}
end{tikzpicture}
end{figure}


Which outputs the following abomination:



enter image description here



I don't know if the same ugliness would happen had I typed out the nodes myself.










share|improve this question























  • The "abomination" is simply all numbers aligned the same way. Try instead of defining the points recursively like you did and then in a second step add the lines and then the numbers. This should make it better :)

    – Superuser27
    5 hours ago











  • What I mean is: if you just look at how the numbers are positioned, they look fine. It's just the lines starting from weird places.

    – Superuser27
    5 hours ago











  • I have given up and written every node one by one. It works! The question is even more curious to me now.

    – ThoAppelsin
    5 hours ago














3












3








3








For demonstration purposes, I want to obtain a graph of C10 shaped as a star. I have been working on this for much longer than I should have. I currently have this:



begin{figure}
centering
begin{tikzpicture}[nodes={circle, draw}]
foreach i in {1,...,10}
{
pgfmathisodd{i};
node (Ni) at (360/10*i:pgfmathresult?18mm:9mm) {i};
}
foreach i in {1,...,10}
{
pgfmathmod{i}{10}
pgfmathadd{pgfmathresult}{1};
path (Ni) edge (Npgfmathresult);
}
end{tikzpicture}
end{figure}


Which outputs the following abomination:



enter image description here



I don't know if the same ugliness would happen had I typed out the nodes myself.










share|improve this question














For demonstration purposes, I want to obtain a graph of C10 shaped as a star. I have been working on this for much longer than I should have. I currently have this:



begin{figure}
centering
begin{tikzpicture}[nodes={circle, draw}]
foreach i in {1,...,10}
{
pgfmathisodd{i};
node (Ni) at (360/10*i:pgfmathresult?18mm:9mm) {i};
}
foreach i in {1,...,10}
{
pgfmathmod{i}{10}
pgfmathadd{pgfmathresult}{1};
path (Ni) edge (Npgfmathresult);
}
end{tikzpicture}
end{figure}


Which outputs the following abomination:



enter image description here



I don't know if the same ugliness would happen had I typed out the nodes myself.







tikz-pgf tikz-node tikz-path






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 5 hours ago









ThoAppelsinThoAppelsin

325111




325111













  • The "abomination" is simply all numbers aligned the same way. Try instead of defining the points recursively like you did and then in a second step add the lines and then the numbers. This should make it better :)

    – Superuser27
    5 hours ago











  • What I mean is: if you just look at how the numbers are positioned, they look fine. It's just the lines starting from weird places.

    – Superuser27
    5 hours ago











  • I have given up and written every node one by one. It works! The question is even more curious to me now.

    – ThoAppelsin
    5 hours ago



















  • The "abomination" is simply all numbers aligned the same way. Try instead of defining the points recursively like you did and then in a second step add the lines and then the numbers. This should make it better :)

    – Superuser27
    5 hours ago











  • What I mean is: if you just look at how the numbers are positioned, they look fine. It's just the lines starting from weird places.

    – Superuser27
    5 hours ago











  • I have given up and written every node one by one. It works! The question is even more curious to me now.

    – ThoAppelsin
    5 hours ago

















The "abomination" is simply all numbers aligned the same way. Try instead of defining the points recursively like you did and then in a second step add the lines and then the numbers. This should make it better :)

– Superuser27
5 hours ago





The "abomination" is simply all numbers aligned the same way. Try instead of defining the points recursively like you did and then in a second step add the lines and then the numbers. This should make it better :)

– Superuser27
5 hours ago













What I mean is: if you just look at how the numbers are positioned, they look fine. It's just the lines starting from weird places.

– Superuser27
5 hours ago





What I mean is: if you just look at how the numbers are positioned, they look fine. It's just the lines starting from weird places.

– Superuser27
5 hours ago













I have given up and written every node one by one. It works! The question is even more curious to me now.

– ThoAppelsin
5 hours ago





I have given up and written every node one by one. It works! The question is even more curious to me now.

– ThoAppelsin
5 hours ago










2 Answers
2






active

oldest

votes


















2














After the manipulations, the result won't be an integer any more. Rather, you'll get numbers like 1.0, where .0 is interpreted as an anchor. Therefore I suggest



documentclass[tikz,border=3.14mm]{standalone}
begin{document}
begin{tikzpicture}[nodes={circle, draw}]
foreach i in {1,...,10}
{
pgfmathisodd{i};
node (Ni) at (360/10*i:pgfmathresult?18mm:9mm) {i};
}
foreach i in {1,...,10}
{
pgfmathtruncatemacro{j}{mod(i,10)+1}
path (Ni) edge (Nj);
}
end{tikzpicture}
end{document}


enter image description here






share|improve this answer



















  • 2





    I am aware of the fact that one can shorten the code. This answer is to explain what happens and to provide a way that works which is very close to the code of the question.

    – marmot
    4 hours ago











  • Probably a good idea to fix the circle size so the 10 node isn't bigger than the others.

    – Sandy G
    3 hours ago











  • Great answer, thank you for being to the point. And to @SandyG, I already have fixed the size inconsistency via putting all nodes in boxes with zero width, and giving any size I like to the nodes.

    – ThoAppelsin
    1 hour ago



















1














PGF's foreach has quite powerfull tools that you can use here:



begin{tikzpicture}[nodes={circle, draw}]
foreach[evaluate=i as j using isodd(i)] i in {1,...,10}
{
node (Ni) at (360/10*i:j?18mm:9mm) {i};
}
foreach[remember=i as j (initially 10)] i in {1,...,10}
{
draw (Ni) -- (Nj);
}
end{tikzpicture}


The optional [evaluate=i as j using isodd(i)] in the first loop computes isodd(i) and stores the result in macro j.



The optional [remember=i as j (initially 10)] in the second loop stores i's content in macro j at the end of the iteration, allowing for this content to be available for the next iteration.






share|improve this answer
























  • Thank you for your extended recommendations, but I think marmot's answer is more relevant to the issue/question, since it also explains the cause of the erroneous outcome in the question.

    – ThoAppelsin
    1 hour ago











  • @ThoAppelsin I agree, this answer is also aimed at those who will find your question later and offer them a simple and robust solution.

    – Christoph Frings
    54 mins ago













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


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f478207%2feven-length-cycle-laid-out-as-a-star%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














After the manipulations, the result won't be an integer any more. Rather, you'll get numbers like 1.0, where .0 is interpreted as an anchor. Therefore I suggest



documentclass[tikz,border=3.14mm]{standalone}
begin{document}
begin{tikzpicture}[nodes={circle, draw}]
foreach i in {1,...,10}
{
pgfmathisodd{i};
node (Ni) at (360/10*i:pgfmathresult?18mm:9mm) {i};
}
foreach i in {1,...,10}
{
pgfmathtruncatemacro{j}{mod(i,10)+1}
path (Ni) edge (Nj);
}
end{tikzpicture}
end{document}


enter image description here






share|improve this answer



















  • 2





    I am aware of the fact that one can shorten the code. This answer is to explain what happens and to provide a way that works which is very close to the code of the question.

    – marmot
    4 hours ago











  • Probably a good idea to fix the circle size so the 10 node isn't bigger than the others.

    – Sandy G
    3 hours ago











  • Great answer, thank you for being to the point. And to @SandyG, I already have fixed the size inconsistency via putting all nodes in boxes with zero width, and giving any size I like to the nodes.

    – ThoAppelsin
    1 hour ago
















2














After the manipulations, the result won't be an integer any more. Rather, you'll get numbers like 1.0, where .0 is interpreted as an anchor. Therefore I suggest



documentclass[tikz,border=3.14mm]{standalone}
begin{document}
begin{tikzpicture}[nodes={circle, draw}]
foreach i in {1,...,10}
{
pgfmathisodd{i};
node (Ni) at (360/10*i:pgfmathresult?18mm:9mm) {i};
}
foreach i in {1,...,10}
{
pgfmathtruncatemacro{j}{mod(i,10)+1}
path (Ni) edge (Nj);
}
end{tikzpicture}
end{document}


enter image description here






share|improve this answer



















  • 2





    I am aware of the fact that one can shorten the code. This answer is to explain what happens and to provide a way that works which is very close to the code of the question.

    – marmot
    4 hours ago











  • Probably a good idea to fix the circle size so the 10 node isn't bigger than the others.

    – Sandy G
    3 hours ago











  • Great answer, thank you for being to the point. And to @SandyG, I already have fixed the size inconsistency via putting all nodes in boxes with zero width, and giving any size I like to the nodes.

    – ThoAppelsin
    1 hour ago














2












2








2







After the manipulations, the result won't be an integer any more. Rather, you'll get numbers like 1.0, where .0 is interpreted as an anchor. Therefore I suggest



documentclass[tikz,border=3.14mm]{standalone}
begin{document}
begin{tikzpicture}[nodes={circle, draw}]
foreach i in {1,...,10}
{
pgfmathisodd{i};
node (Ni) at (360/10*i:pgfmathresult?18mm:9mm) {i};
}
foreach i in {1,...,10}
{
pgfmathtruncatemacro{j}{mod(i,10)+1}
path (Ni) edge (Nj);
}
end{tikzpicture}
end{document}


enter image description here






share|improve this answer













After the manipulations, the result won't be an integer any more. Rather, you'll get numbers like 1.0, where .0 is interpreted as an anchor. Therefore I suggest



documentclass[tikz,border=3.14mm]{standalone}
begin{document}
begin{tikzpicture}[nodes={circle, draw}]
foreach i in {1,...,10}
{
pgfmathisodd{i};
node (Ni) at (360/10*i:pgfmathresult?18mm:9mm) {i};
}
foreach i in {1,...,10}
{
pgfmathtruncatemacro{j}{mod(i,10)+1}
path (Ni) edge (Nj);
}
end{tikzpicture}
end{document}


enter image description here







share|improve this answer












share|improve this answer



share|improve this answer










answered 4 hours ago









marmotmarmot

106k5129242




106k5129242








  • 2





    I am aware of the fact that one can shorten the code. This answer is to explain what happens and to provide a way that works which is very close to the code of the question.

    – marmot
    4 hours ago











  • Probably a good idea to fix the circle size so the 10 node isn't bigger than the others.

    – Sandy G
    3 hours ago











  • Great answer, thank you for being to the point. And to @SandyG, I already have fixed the size inconsistency via putting all nodes in boxes with zero width, and giving any size I like to the nodes.

    – ThoAppelsin
    1 hour ago














  • 2





    I am aware of the fact that one can shorten the code. This answer is to explain what happens and to provide a way that works which is very close to the code of the question.

    – marmot
    4 hours ago











  • Probably a good idea to fix the circle size so the 10 node isn't bigger than the others.

    – Sandy G
    3 hours ago











  • Great answer, thank you for being to the point. And to @SandyG, I already have fixed the size inconsistency via putting all nodes in boxes with zero width, and giving any size I like to the nodes.

    – ThoAppelsin
    1 hour ago








2




2





I am aware of the fact that one can shorten the code. This answer is to explain what happens and to provide a way that works which is very close to the code of the question.

– marmot
4 hours ago





I am aware of the fact that one can shorten the code. This answer is to explain what happens and to provide a way that works which is very close to the code of the question.

– marmot
4 hours ago













Probably a good idea to fix the circle size so the 10 node isn't bigger than the others.

– Sandy G
3 hours ago





Probably a good idea to fix the circle size so the 10 node isn't bigger than the others.

– Sandy G
3 hours ago













Great answer, thank you for being to the point. And to @SandyG, I already have fixed the size inconsistency via putting all nodes in boxes with zero width, and giving any size I like to the nodes.

– ThoAppelsin
1 hour ago





Great answer, thank you for being to the point. And to @SandyG, I already have fixed the size inconsistency via putting all nodes in boxes with zero width, and giving any size I like to the nodes.

– ThoAppelsin
1 hour ago











1














PGF's foreach has quite powerfull tools that you can use here:



begin{tikzpicture}[nodes={circle, draw}]
foreach[evaluate=i as j using isodd(i)] i in {1,...,10}
{
node (Ni) at (360/10*i:j?18mm:9mm) {i};
}
foreach[remember=i as j (initially 10)] i in {1,...,10}
{
draw (Ni) -- (Nj);
}
end{tikzpicture}


The optional [evaluate=i as j using isodd(i)] in the first loop computes isodd(i) and stores the result in macro j.



The optional [remember=i as j (initially 10)] in the second loop stores i's content in macro j at the end of the iteration, allowing for this content to be available for the next iteration.






share|improve this answer
























  • Thank you for your extended recommendations, but I think marmot's answer is more relevant to the issue/question, since it also explains the cause of the erroneous outcome in the question.

    – ThoAppelsin
    1 hour ago











  • @ThoAppelsin I agree, this answer is also aimed at those who will find your question later and offer them a simple and robust solution.

    – Christoph Frings
    54 mins ago


















1














PGF's foreach has quite powerfull tools that you can use here:



begin{tikzpicture}[nodes={circle, draw}]
foreach[evaluate=i as j using isodd(i)] i in {1,...,10}
{
node (Ni) at (360/10*i:j?18mm:9mm) {i};
}
foreach[remember=i as j (initially 10)] i in {1,...,10}
{
draw (Ni) -- (Nj);
}
end{tikzpicture}


The optional [evaluate=i as j using isodd(i)] in the first loop computes isodd(i) and stores the result in macro j.



The optional [remember=i as j (initially 10)] in the second loop stores i's content in macro j at the end of the iteration, allowing for this content to be available for the next iteration.






share|improve this answer
























  • Thank you for your extended recommendations, but I think marmot's answer is more relevant to the issue/question, since it also explains the cause of the erroneous outcome in the question.

    – ThoAppelsin
    1 hour ago











  • @ThoAppelsin I agree, this answer is also aimed at those who will find your question later and offer them a simple and robust solution.

    – Christoph Frings
    54 mins ago
















1












1








1







PGF's foreach has quite powerfull tools that you can use here:



begin{tikzpicture}[nodes={circle, draw}]
foreach[evaluate=i as j using isodd(i)] i in {1,...,10}
{
node (Ni) at (360/10*i:j?18mm:9mm) {i};
}
foreach[remember=i as j (initially 10)] i in {1,...,10}
{
draw (Ni) -- (Nj);
}
end{tikzpicture}


The optional [evaluate=i as j using isodd(i)] in the first loop computes isodd(i) and stores the result in macro j.



The optional [remember=i as j (initially 10)] in the second loop stores i's content in macro j at the end of the iteration, allowing for this content to be available for the next iteration.






share|improve this answer













PGF's foreach has quite powerfull tools that you can use here:



begin{tikzpicture}[nodes={circle, draw}]
foreach[evaluate=i as j using isodd(i)] i in {1,...,10}
{
node (Ni) at (360/10*i:j?18mm:9mm) {i};
}
foreach[remember=i as j (initially 10)] i in {1,...,10}
{
draw (Ni) -- (Nj);
}
end{tikzpicture}


The optional [evaluate=i as j using isodd(i)] in the first loop computes isodd(i) and stores the result in macro j.



The optional [remember=i as j (initially 10)] in the second loop stores i's content in macro j at the end of the iteration, allowing for this content to be available for the next iteration.







share|improve this answer












share|improve this answer



share|improve this answer










answered 3 hours ago









Christoph FringsChristoph Frings

901211




901211













  • Thank you for your extended recommendations, but I think marmot's answer is more relevant to the issue/question, since it also explains the cause of the erroneous outcome in the question.

    – ThoAppelsin
    1 hour ago











  • @ThoAppelsin I agree, this answer is also aimed at those who will find your question later and offer them a simple and robust solution.

    – Christoph Frings
    54 mins ago





















  • Thank you for your extended recommendations, but I think marmot's answer is more relevant to the issue/question, since it also explains the cause of the erroneous outcome in the question.

    – ThoAppelsin
    1 hour ago











  • @ThoAppelsin I agree, this answer is also aimed at those who will find your question later and offer them a simple and robust solution.

    – Christoph Frings
    54 mins ago



















Thank you for your extended recommendations, but I think marmot's answer is more relevant to the issue/question, since it also explains the cause of the erroneous outcome in the question.

– ThoAppelsin
1 hour ago





Thank you for your extended recommendations, but I think marmot's answer is more relevant to the issue/question, since it also explains the cause of the erroneous outcome in the question.

– ThoAppelsin
1 hour ago













@ThoAppelsin I agree, this answer is also aimed at those who will find your question later and offer them a simple and robust solution.

– Christoph Frings
54 mins ago







@ThoAppelsin I agree, this answer is also aimed at those who will find your question later and offer them a simple and robust solution.

– Christoph Frings
54 mins ago




















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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f478207%2feven-length-cycle-laid-out-as-a-star%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

El tren de la libertad Índice Antecedentes "Porque yo decido" Desarrollo de la...

Castillo d'Acher Características Menú de navegación

Connecting two nodes from the same mother node horizontallyTikZ: What EXACTLY does the the |- notation for...