How to make all circles in this example have the same radii?
The nodes with less than 4 digits appear smaller. I'd like to have them all of the same size and I can't seem to understand enough of the documentation to get it right. Feel free to suggest me a better way to do this. I'd love to be able to define a function $f(x) = x^2 + 8 mod 3127$ with $x_0 = 2$ which is where these numbers come from.
documentclass{article}
usepackage{tikz}
begin{document}
begin{tikzpicture}
def n {11}
def radius {3.5cm}
def margin {10}
def s {1}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$456$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {2}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$1562$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {3}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$792$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {4}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$1872$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {5}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$2152$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {6}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$25$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {7}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$441$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {8}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$615$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {9}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$2993$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {10}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$2329$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {11}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$2031$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
end{tikzpicture}
end{document}
tikz-pgf
add a comment |
The nodes with less than 4 digits appear smaller. I'd like to have them all of the same size and I can't seem to understand enough of the documentation to get it right. Feel free to suggest me a better way to do this. I'd love to be able to define a function $f(x) = x^2 + 8 mod 3127$ with $x_0 = 2$ which is where these numbers come from.
documentclass{article}
usepackage{tikz}
begin{document}
begin{tikzpicture}
def n {11}
def radius {3.5cm}
def margin {10}
def s {1}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$456$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {2}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$1562$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {3}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$792$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {4}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$1872$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {5}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$2152$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {6}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$25$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {7}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$441$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {8}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$615$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {9}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$2993$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {10}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$2329$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {11}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$2031$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
end{tikzpicture}
end{document}
tikz-pgf
What you want is to control the node size.
– Sigur
Jan 8 at 13:36
Your modulus function should produce labels as shown in my last edit.
– God Must Be Crazy
Jan 8 at 23:06
add a comment |
The nodes with less than 4 digits appear smaller. I'd like to have them all of the same size and I can't seem to understand enough of the documentation to get it right. Feel free to suggest me a better way to do this. I'd love to be able to define a function $f(x) = x^2 + 8 mod 3127$ with $x_0 = 2$ which is where these numbers come from.
documentclass{article}
usepackage{tikz}
begin{document}
begin{tikzpicture}
def n {11}
def radius {3.5cm}
def margin {10}
def s {1}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$456$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {2}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$1562$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {3}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$792$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {4}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$1872$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {5}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$2152$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {6}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$25$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {7}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$441$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {8}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$615$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {9}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$2993$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {10}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$2329$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {11}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$2031$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
end{tikzpicture}
end{document}
tikz-pgf
The nodes with less than 4 digits appear smaller. I'd like to have them all of the same size and I can't seem to understand enough of the documentation to get it right. Feel free to suggest me a better way to do this. I'd love to be able to define a function $f(x) = x^2 + 8 mod 3127$ with $x_0 = 2$ which is where these numbers come from.
documentclass{article}
usepackage{tikz}
begin{document}
begin{tikzpicture}
def n {11}
def radius {3.5cm}
def margin {10}
def s {1}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$456$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {2}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$1562$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {3}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$792$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {4}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$1872$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {5}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$2152$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {6}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$25$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {7}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$441$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {8}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$615$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {9}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$2993$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {10}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$2329$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {11}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$2031$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
end{tikzpicture}
end{document}
tikz-pgf
tikz-pgf
edited Jan 8 at 13:36
Joep Awinita
asked Jan 8 at 13:34
Joep AwinitaJoep Awinita
574
574
What you want is to control the node size.
– Sigur
Jan 8 at 13:36
Your modulus function should produce labels as shown in my last edit.
– God Must Be Crazy
Jan 8 at 23:06
add a comment |
What you want is to control the node size.
– Sigur
Jan 8 at 13:36
Your modulus function should produce labels as shown in my last edit.
– God Must Be Crazy
Jan 8 at 23:06
What you want is to control the node size.
– Sigur
Jan 8 at 13:36
What you want is to control the node size.
– Sigur
Jan 8 at 13:36
Your modulus function should produce labels as shown in my last edit.
– God Must Be Crazy
Jan 8 at 23:06
Your modulus function should produce labels as shown in my last edit.
– God Must Be Crazy
Jan 8 at 23:06
add a comment |
2 Answers
2
active
oldest
votes
What you wish is to control the node size. So, you can use minimum width
. For example:
In this case, you don't need to write [draw, circle]
all the time.
(Also, consider using foreach
.)
MWE
documentclass{article}
usepackage{tikz}
begin{document}
begin{tikzpicture}[every node/.style={circle,draw,minimum width=1.2cm}]
def n {11}
def radius {3.5cm}
def margin {10}
def s {1}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$456$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {2}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$1562$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {3}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$792$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {4}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$1872$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {5}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$2152$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {6}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$25$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {7}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$441$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {8}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$615$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {9}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$2993$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {10}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$2329$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {11}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$2031$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
end{tikzpicture}
end{document}
How can I use a foreach and still automatically place the text inside the circles?
– Joep Awinita
Jan 8 at 15:50
add a comment |
A PSTricks solution just for saving more keystrokes.
documentclass[pstricks,12pt]{standalone}
usepackage{pst-node}
degrees[11]
begin{document}
begin{pspicture}[radius=16pt,arrows=->,nodesep=2pt,arrowinset=0](-5,-5)(5,5)
foreach l [count=i from 0] in {456,1562,792,1872,2152,25,441,615,2993,2329,2031}
{Cnodeput(!4 ispace PtoCrel){Ai}{l}}
foreach i [count=j from 1] in {0,...,10}
{
ifnumi=10
ncarc{A0}{A10}
else
ncarc{Aj}{Ai}
fi
}
end{pspicture}
end{document}
Using f(x) = x*x + 8 (mod 3127)
documentclass[pstricks,12pt]{standalone}
usepackage{pst-node,pst-calculate}
makeatletter
deff#1{pst@mod{pscalculate{(#1+2)**2+8}}{3127}xx}
degrees[11]
begin{document}
begin{pspicture}[radius=16pt,arrows=->,nodesep=2pt,arrowinset=0](-5,-5)(5,5)
foreach i in {0,1,...,10}{Cnodeput(!4 ispace PtoCrel){Ai}{f{i}}}
foreach i [count=j from 1] in {0,...,10}
{
ifnumi=10
ncarc{A0}{A10}
else
ncarc{Aj}{Ai}
fi
}
end{pspicture}
end{document}
add a comment |
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
});
}
});
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%2f469160%2fhow-to-make-all-circles-in-this-example-have-the-same-radii%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
What you wish is to control the node size. So, you can use minimum width
. For example:
In this case, you don't need to write [draw, circle]
all the time.
(Also, consider using foreach
.)
MWE
documentclass{article}
usepackage{tikz}
begin{document}
begin{tikzpicture}[every node/.style={circle,draw,minimum width=1.2cm}]
def n {11}
def radius {3.5cm}
def margin {10}
def s {1}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$456$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {2}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$1562$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {3}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$792$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {4}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$1872$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {5}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$2152$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {6}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$25$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {7}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$441$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {8}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$615$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {9}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$2993$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {10}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$2329$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {11}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$2031$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
end{tikzpicture}
end{document}
How can I use a foreach and still automatically place the text inside the circles?
– Joep Awinita
Jan 8 at 15:50
add a comment |
What you wish is to control the node size. So, you can use minimum width
. For example:
In this case, you don't need to write [draw, circle]
all the time.
(Also, consider using foreach
.)
MWE
documentclass{article}
usepackage{tikz}
begin{document}
begin{tikzpicture}[every node/.style={circle,draw,minimum width=1.2cm}]
def n {11}
def radius {3.5cm}
def margin {10}
def s {1}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$456$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {2}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$1562$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {3}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$792$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {4}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$1872$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {5}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$2152$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {6}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$25$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {7}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$441$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {8}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$615$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {9}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$2993$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {10}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$2329$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {11}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$2031$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
end{tikzpicture}
end{document}
How can I use a foreach and still automatically place the text inside the circles?
– Joep Awinita
Jan 8 at 15:50
add a comment |
What you wish is to control the node size. So, you can use minimum width
. For example:
In this case, you don't need to write [draw, circle]
all the time.
(Also, consider using foreach
.)
MWE
documentclass{article}
usepackage{tikz}
begin{document}
begin{tikzpicture}[every node/.style={circle,draw,minimum width=1.2cm}]
def n {11}
def radius {3.5cm}
def margin {10}
def s {1}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$456$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {2}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$1562$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {3}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$792$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {4}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$1872$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {5}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$2152$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {6}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$25$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {7}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$441$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {8}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$615$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {9}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$2993$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {10}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$2329$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {11}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$2031$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
end{tikzpicture}
end{document}
What you wish is to control the node size. So, you can use minimum width
. For example:
In this case, you don't need to write [draw, circle]
all the time.
(Also, consider using foreach
.)
MWE
documentclass{article}
usepackage{tikz}
begin{document}
begin{tikzpicture}[every node/.style={circle,draw,minimum width=1.2cm}]
def n {11}
def radius {3.5cm}
def margin {10}
def s {1}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$456$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {2}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$1562$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {3}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$792$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {4}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$1872$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {5}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$2152$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {6}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$25$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {7}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$441$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {8}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$615$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {9}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$2993$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {10}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$2329$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
def s {11}
node[draw, circle] at ({360/n * (s - 1)}:radius) {$2031$};
draw[<-, >=latex] ({360/n * (s - 1)+margin}:radius)
arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
end{tikzpicture}
end{document}
answered Jan 8 at 13:38
SigurSigur
24.4k355138
24.4k355138
How can I use a foreach and still automatically place the text inside the circles?
– Joep Awinita
Jan 8 at 15:50
add a comment |
How can I use a foreach and still automatically place the text inside the circles?
– Joep Awinita
Jan 8 at 15:50
How can I use a foreach and still automatically place the text inside the circles?
– Joep Awinita
Jan 8 at 15:50
How can I use a foreach and still automatically place the text inside the circles?
– Joep Awinita
Jan 8 at 15:50
add a comment |
A PSTricks solution just for saving more keystrokes.
documentclass[pstricks,12pt]{standalone}
usepackage{pst-node}
degrees[11]
begin{document}
begin{pspicture}[radius=16pt,arrows=->,nodesep=2pt,arrowinset=0](-5,-5)(5,5)
foreach l [count=i from 0] in {456,1562,792,1872,2152,25,441,615,2993,2329,2031}
{Cnodeput(!4 ispace PtoCrel){Ai}{l}}
foreach i [count=j from 1] in {0,...,10}
{
ifnumi=10
ncarc{A0}{A10}
else
ncarc{Aj}{Ai}
fi
}
end{pspicture}
end{document}
Using f(x) = x*x + 8 (mod 3127)
documentclass[pstricks,12pt]{standalone}
usepackage{pst-node,pst-calculate}
makeatletter
deff#1{pst@mod{pscalculate{(#1+2)**2+8}}{3127}xx}
degrees[11]
begin{document}
begin{pspicture}[radius=16pt,arrows=->,nodesep=2pt,arrowinset=0](-5,-5)(5,5)
foreach i in {0,1,...,10}{Cnodeput(!4 ispace PtoCrel){Ai}{f{i}}}
foreach i [count=j from 1] in {0,...,10}
{
ifnumi=10
ncarc{A0}{A10}
else
ncarc{Aj}{Ai}
fi
}
end{pspicture}
end{document}
add a comment |
A PSTricks solution just for saving more keystrokes.
documentclass[pstricks,12pt]{standalone}
usepackage{pst-node}
degrees[11]
begin{document}
begin{pspicture}[radius=16pt,arrows=->,nodesep=2pt,arrowinset=0](-5,-5)(5,5)
foreach l [count=i from 0] in {456,1562,792,1872,2152,25,441,615,2993,2329,2031}
{Cnodeput(!4 ispace PtoCrel){Ai}{l}}
foreach i [count=j from 1] in {0,...,10}
{
ifnumi=10
ncarc{A0}{A10}
else
ncarc{Aj}{Ai}
fi
}
end{pspicture}
end{document}
Using f(x) = x*x + 8 (mod 3127)
documentclass[pstricks,12pt]{standalone}
usepackage{pst-node,pst-calculate}
makeatletter
deff#1{pst@mod{pscalculate{(#1+2)**2+8}}{3127}xx}
degrees[11]
begin{document}
begin{pspicture}[radius=16pt,arrows=->,nodesep=2pt,arrowinset=0](-5,-5)(5,5)
foreach i in {0,1,...,10}{Cnodeput(!4 ispace PtoCrel){Ai}{f{i}}}
foreach i [count=j from 1] in {0,...,10}
{
ifnumi=10
ncarc{A0}{A10}
else
ncarc{Aj}{Ai}
fi
}
end{pspicture}
end{document}
add a comment |
A PSTricks solution just for saving more keystrokes.
documentclass[pstricks,12pt]{standalone}
usepackage{pst-node}
degrees[11]
begin{document}
begin{pspicture}[radius=16pt,arrows=->,nodesep=2pt,arrowinset=0](-5,-5)(5,5)
foreach l [count=i from 0] in {456,1562,792,1872,2152,25,441,615,2993,2329,2031}
{Cnodeput(!4 ispace PtoCrel){Ai}{l}}
foreach i [count=j from 1] in {0,...,10}
{
ifnumi=10
ncarc{A0}{A10}
else
ncarc{Aj}{Ai}
fi
}
end{pspicture}
end{document}
Using f(x) = x*x + 8 (mod 3127)
documentclass[pstricks,12pt]{standalone}
usepackage{pst-node,pst-calculate}
makeatletter
deff#1{pst@mod{pscalculate{(#1+2)**2+8}}{3127}xx}
degrees[11]
begin{document}
begin{pspicture}[radius=16pt,arrows=->,nodesep=2pt,arrowinset=0](-5,-5)(5,5)
foreach i in {0,1,...,10}{Cnodeput(!4 ispace PtoCrel){Ai}{f{i}}}
foreach i [count=j from 1] in {0,...,10}
{
ifnumi=10
ncarc{A0}{A10}
else
ncarc{Aj}{Ai}
fi
}
end{pspicture}
end{document}
A PSTricks solution just for saving more keystrokes.
documentclass[pstricks,12pt]{standalone}
usepackage{pst-node}
degrees[11]
begin{document}
begin{pspicture}[radius=16pt,arrows=->,nodesep=2pt,arrowinset=0](-5,-5)(5,5)
foreach l [count=i from 0] in {456,1562,792,1872,2152,25,441,615,2993,2329,2031}
{Cnodeput(!4 ispace PtoCrel){Ai}{l}}
foreach i [count=j from 1] in {0,...,10}
{
ifnumi=10
ncarc{A0}{A10}
else
ncarc{Aj}{Ai}
fi
}
end{pspicture}
end{document}
Using f(x) = x*x + 8 (mod 3127)
documentclass[pstricks,12pt]{standalone}
usepackage{pst-node,pst-calculate}
makeatletter
deff#1{pst@mod{pscalculate{(#1+2)**2+8}}{3127}xx}
degrees[11]
begin{document}
begin{pspicture}[radius=16pt,arrows=->,nodesep=2pt,arrowinset=0](-5,-5)(5,5)
foreach i in {0,1,...,10}{Cnodeput(!4 ispace PtoCrel){Ai}{f{i}}}
foreach i [count=j from 1] in {0,...,10}
{
ifnumi=10
ncarc{A0}{A10}
else
ncarc{Aj}{Ai}
fi
}
end{pspicture}
end{document}
edited Jan 8 at 23:03
answered Jan 8 at 22:25
God Must Be CrazyGod Must Be Crazy
6,09011039
6,09011039
add a comment |
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.
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%2f469160%2fhow-to-make-all-circles-in-this-example-have-the-same-radii%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
What you want is to control the node size.
– Sigur
Jan 8 at 13:36
Your modulus function should produce labels as shown in my last edit.
– God Must Be Crazy
Jan 8 at 23:06