An optimized set of tikz code?
I have a question, how can have the shortest set of tikz code for this pecture 
i am tring to optimize this code:
documentclass{article}
usepackage{amsmath}
usepackage{tikz}
begin{document}
La version de TikZ est : pgfversion
vfill
begin{center}
begin{tikzpicture}
%
draw (0,1) -- (1,0);
draw (1,0) -- (0,-1);
draw (0,-1) -- (-1,0);
draw (-1,0) -- (0,1);
draw (0,0) circle (1);
draw ((0,1) circle (1);
draw (0,-1) circle (1);
draw (-1,0) circle (1);
draw (1,0) circle (1);
%
draw (0,2) -- (2,0);
draw (2,0) -- (0,-2);
draw (0,-2) -- (-2,0);
draw (-2,0) -- (0,2);
draw (0,0) circle (2);
draw ((0,2) circle (2);
draw (0,-2) circle (2);
draw (-2,0) circle (2);
draw (2,0) circle (2);
end{tikzpicture}
end{center}
end{document}
tikz-pgf
New contributor
mou-nadal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
I have a question, how can have the shortest set of tikz code for this pecture 
i am tring to optimize this code:
documentclass{article}
usepackage{amsmath}
usepackage{tikz}
begin{document}
La version de TikZ est : pgfversion
vfill
begin{center}
begin{tikzpicture}
%
draw (0,1) -- (1,0);
draw (1,0) -- (0,-1);
draw (0,-1) -- (-1,0);
draw (-1,0) -- (0,1);
draw (0,0) circle (1);
draw ((0,1) circle (1);
draw (0,-1) circle (1);
draw (-1,0) circle (1);
draw (1,0) circle (1);
%
draw (0,2) -- (2,0);
draw (2,0) -- (0,-2);
draw (0,-2) -- (-2,0);
draw (-2,0) -- (0,2);
draw (0,0) circle (2);
draw ((0,2) circle (2);
draw (0,-2) circle (2);
draw (-2,0) circle (2);
draw (2,0) circle (2);
end{tikzpicture}
end{center}
end{document}
tikz-pgf
New contributor
mou-nadal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Do you mean who has the shortest execution time in processor time? Who requires the least memory?
– AndréC
5 hours ago
Some think with a loop will be a great approach, but if we consider CPU and memory we must be more careful.
– mou-nadal
4 hours ago
add a comment |
I have a question, how can have the shortest set of tikz code for this pecture 
i am tring to optimize this code:
documentclass{article}
usepackage{amsmath}
usepackage{tikz}
begin{document}
La version de TikZ est : pgfversion
vfill
begin{center}
begin{tikzpicture}
%
draw (0,1) -- (1,0);
draw (1,0) -- (0,-1);
draw (0,-1) -- (-1,0);
draw (-1,0) -- (0,1);
draw (0,0) circle (1);
draw ((0,1) circle (1);
draw (0,-1) circle (1);
draw (-1,0) circle (1);
draw (1,0) circle (1);
%
draw (0,2) -- (2,0);
draw (2,0) -- (0,-2);
draw (0,-2) -- (-2,0);
draw (-2,0) -- (0,2);
draw (0,0) circle (2);
draw ((0,2) circle (2);
draw (0,-2) circle (2);
draw (-2,0) circle (2);
draw (2,0) circle (2);
end{tikzpicture}
end{center}
end{document}
tikz-pgf
New contributor
mou-nadal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I have a question, how can have the shortest set of tikz code for this pecture 
i am tring to optimize this code:
documentclass{article}
usepackage{amsmath}
usepackage{tikz}
begin{document}
La version de TikZ est : pgfversion
vfill
begin{center}
begin{tikzpicture}
%
draw (0,1) -- (1,0);
draw (1,0) -- (0,-1);
draw (0,-1) -- (-1,0);
draw (-1,0) -- (0,1);
draw (0,0) circle (1);
draw ((0,1) circle (1);
draw (0,-1) circle (1);
draw (-1,0) circle (1);
draw (1,0) circle (1);
%
draw (0,2) -- (2,0);
draw (2,0) -- (0,-2);
draw (0,-2) -- (-2,0);
draw (-2,0) -- (0,2);
draw (0,0) circle (2);
draw ((0,2) circle (2);
draw (0,-2) circle (2);
draw (-2,0) circle (2);
draw (2,0) circle (2);
end{tikzpicture}
end{center}
end{document}
tikz-pgf
tikz-pgf
New contributor
mou-nadal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
mou-nadal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited 2 hours ago
AndréC
8,86911447
8,86911447
New contributor
mou-nadal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 6 hours ago
mou-nadalmou-nadal
384
384
New contributor
mou-nadal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
mou-nadal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
mou-nadal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Do you mean who has the shortest execution time in processor time? Who requires the least memory?
– AndréC
5 hours ago
Some think with a loop will be a great approach, but if we consider CPU and memory we must be more careful.
– mou-nadal
4 hours ago
add a comment |
Do you mean who has the shortest execution time in processor time? Who requires the least memory?
– AndréC
5 hours ago
Some think with a loop will be a great approach, but if we consider CPU and memory we must be more careful.
– mou-nadal
4 hours ago
Do you mean who has the shortest execution time in processor time? Who requires the least memory?
– AndréC
5 hours ago
Do you mean who has the shortest execution time in processor time? Who requires the least memory?
– AndréC
5 hours ago
Some think with a loop will be a great approach, but if we consider CPU and memory we must be more careful.
– mou-nadal
4 hours ago
Some think with a loop will be a great approach, but if we consider CPU and memory we must be more careful.
– mou-nadal
4 hours ago
add a comment |
5 Answers
5
active
oldest
votes
Here is a solution (not the shortest):
documentclass[tikz]{standalone}
begin{document}
begin{tikzpicture}
draw
circle (1) circle(2)
(0:1) --(90:1) -- (180:1) -- (270:1) -- cycle
(0:1) circle(1) (90:1) circle(1) (180:1) circle(1) (270:1) circle(1)
(0:2) --(90:2) -- (180:2) -- (270:2) -- cycle
(0:2) circle(2) (90:2) circle(2) (180:2) circle(2) (270:2) circle(2);
end{tikzpicture}
end{document}
add a comment |
Just for fun:
documentclass[tikz,margin=5mm]{standalone}
begin{document}
begin{tikzpicture}
draw (0,0) circle (1) circle (2);
foreach t/n in {0/1,90/2,180/3,270/4}{
draw (t:1)coordinate(n) circle (1) ;}
foreach t/m in {0/5,90/6,180/7,270/8}{
draw (t:2)coordinate(m) circle (2) ;}
draw (1)--(2)--(3)--(4)--cycle;
draw (5)--(6)--(7)--(8)--cycle;
end{tikzpicture}
end{document}
add a comment |
One path for everything. ;-)
documentclass[tikz,border=3.14mm]{standalone}
begin{document}
begin{tikzpicture}
draw[rotate=45] foreach Y in {1,2}
{(0,0) circle[radius=Y]
(45:Y) rectangle (225:Y)
foreach X in {45,135,225,315}
{ (X:Y) circle[radius=Y]}};
end{tikzpicture}
end{document}

add a comment |
Not as much as @marmot's nicely optimised answer but a try (gives more knobs for fun though):
documentclass[tikz]{standalone}
begin{document}
begin{tikzpicture}[mystyle/.style={circle,draw,fill=none,minimum size=20, line width = 0.1pt}]
foreach x/y/z in {0/0/2,0/1/2,0/-1/2,-1/0/2,1/0/2,0/0/4,0/1/4,0/-1/4,-1/0/4,1/0/4}
node [mystyle, minimum size = z cm, color =black] (2) at (x, y) {};
foreach x/y in {-0.7/0.7, -1.41/1.41}
draw[rotate=45, line width = 0.1pt] (x , x ) rectangle (y, y);
end{tikzpicture}
end{document}
which gives

add a comment |
I am participating in the celebration with two proposals, both of which have been made:
Two loops:
- the first one to make an enlargement (
scale) by two - the second to build the 4 circles and the square using
polar coordinates
The code is indented so that it can be read:
First proposal (easier to read):
documentclass{article}
usepackage{amsmath}
usepackage{tikz}
begin{document}
La version de TikZ est : pgfversion
vfill
begin{center}
begin{tikzpicture}
foreach s in {1,2}{
begin{scope}[scale=s]
draw (0,0) circle (1);
foreach r [remember= r as rr (initially 270)] in {0,90,180,270}{
draw (r:1) circle (1);
draw (rr:1)--(r:1);
}
end{scope}
}
end{tikzpicture}
end{center}
end{document}

Second proposal (with one less scope environment):
documentclass{article}
usepackage{amsmath}
usepackage{tikz}
begin{document}
La version de TikZ est : pgfversion
vfill
begin{center}
begin{tikzpicture}
foreach s in {1,2}{
draw (0,0) circle (s);
foreach r [remember= r as rr (initially 270)] in {0,90,180,270}{
draw (r:s) circle (s);
draw (rr:s)--(r:s);
}
}
end{tikzpicture}
end{center}
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
});
}
});
mou-nadal is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
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%2f473926%2fan-optimized-set-of-tikz-code%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
Here is a solution (not the shortest):
documentclass[tikz]{standalone}
begin{document}
begin{tikzpicture}
draw
circle (1) circle(2)
(0:1) --(90:1) -- (180:1) -- (270:1) -- cycle
(0:1) circle(1) (90:1) circle(1) (180:1) circle(1) (270:1) circle(1)
(0:2) --(90:2) -- (180:2) -- (270:2) -- cycle
(0:2) circle(2) (90:2) circle(2) (180:2) circle(2) (270:2) circle(2);
end{tikzpicture}
end{document}
add a comment |
Here is a solution (not the shortest):
documentclass[tikz]{standalone}
begin{document}
begin{tikzpicture}
draw
circle (1) circle(2)
(0:1) --(90:1) -- (180:1) -- (270:1) -- cycle
(0:1) circle(1) (90:1) circle(1) (180:1) circle(1) (270:1) circle(1)
(0:2) --(90:2) -- (180:2) -- (270:2) -- cycle
(0:2) circle(2) (90:2) circle(2) (180:2) circle(2) (270:2) circle(2);
end{tikzpicture}
end{document}
add a comment |
Here is a solution (not the shortest):
documentclass[tikz]{standalone}
begin{document}
begin{tikzpicture}
draw
circle (1) circle(2)
(0:1) --(90:1) -- (180:1) -- (270:1) -- cycle
(0:1) circle(1) (90:1) circle(1) (180:1) circle(1) (270:1) circle(1)
(0:2) --(90:2) -- (180:2) -- (270:2) -- cycle
(0:2) circle(2) (90:2) circle(2) (180:2) circle(2) (270:2) circle(2);
end{tikzpicture}
end{document}
Here is a solution (not the shortest):
documentclass[tikz]{standalone}
begin{document}
begin{tikzpicture}
draw
circle (1) circle(2)
(0:1) --(90:1) -- (180:1) -- (270:1) -- cycle
(0:1) circle(1) (90:1) circle(1) (180:1) circle(1) (270:1) circle(1)
(0:2) --(90:2) -- (180:2) -- (270:2) -- cycle
(0:2) circle(2) (90:2) circle(2) (180:2) circle(2) (270:2) circle(2);
end{tikzpicture}
end{document}
answered 6 hours ago
Paul GaboritPaul Gaborit
55.3k7140226
55.3k7140226
add a comment |
add a comment |
Just for fun:
documentclass[tikz,margin=5mm]{standalone}
begin{document}
begin{tikzpicture}
draw (0,0) circle (1) circle (2);
foreach t/n in {0/1,90/2,180/3,270/4}{
draw (t:1)coordinate(n) circle (1) ;}
foreach t/m in {0/5,90/6,180/7,270/8}{
draw (t:2)coordinate(m) circle (2) ;}
draw (1)--(2)--(3)--(4)--cycle;
draw (5)--(6)--(7)--(8)--cycle;
end{tikzpicture}
end{document}
add a comment |
Just for fun:
documentclass[tikz,margin=5mm]{standalone}
begin{document}
begin{tikzpicture}
draw (0,0) circle (1) circle (2);
foreach t/n in {0/1,90/2,180/3,270/4}{
draw (t:1)coordinate(n) circle (1) ;}
foreach t/m in {0/5,90/6,180/7,270/8}{
draw (t:2)coordinate(m) circle (2) ;}
draw (1)--(2)--(3)--(4)--cycle;
draw (5)--(6)--(7)--(8)--cycle;
end{tikzpicture}
end{document}
add a comment |
Just for fun:
documentclass[tikz,margin=5mm]{standalone}
begin{document}
begin{tikzpicture}
draw (0,0) circle (1) circle (2);
foreach t/n in {0/1,90/2,180/3,270/4}{
draw (t:1)coordinate(n) circle (1) ;}
foreach t/m in {0/5,90/6,180/7,270/8}{
draw (t:2)coordinate(m) circle (2) ;}
draw (1)--(2)--(3)--(4)--cycle;
draw (5)--(6)--(7)--(8)--cycle;
end{tikzpicture}
end{document}
Just for fun:
documentclass[tikz,margin=5mm]{standalone}
begin{document}
begin{tikzpicture}
draw (0,0) circle (1) circle (2);
foreach t/n in {0/1,90/2,180/3,270/4}{
draw (t:1)coordinate(n) circle (1) ;}
foreach t/m in {0/5,90/6,180/7,270/8}{
draw (t:2)coordinate(m) circle (2) ;}
draw (1)--(2)--(3)--(4)--cycle;
draw (5)--(6)--(7)--(8)--cycle;
end{tikzpicture}
end{document}
edited 5 hours ago
answered 5 hours ago
ferahfezaferahfeza
5,77911931
5,77911931
add a comment |
add a comment |
One path for everything. ;-)
documentclass[tikz,border=3.14mm]{standalone}
begin{document}
begin{tikzpicture}
draw[rotate=45] foreach Y in {1,2}
{(0,0) circle[radius=Y]
(45:Y) rectangle (225:Y)
foreach X in {45,135,225,315}
{ (X:Y) circle[radius=Y]}};
end{tikzpicture}
end{document}

add a comment |
One path for everything. ;-)
documentclass[tikz,border=3.14mm]{standalone}
begin{document}
begin{tikzpicture}
draw[rotate=45] foreach Y in {1,2}
{(0,0) circle[radius=Y]
(45:Y) rectangle (225:Y)
foreach X in {45,135,225,315}
{ (X:Y) circle[radius=Y]}};
end{tikzpicture}
end{document}

add a comment |
One path for everything. ;-)
documentclass[tikz,border=3.14mm]{standalone}
begin{document}
begin{tikzpicture}
draw[rotate=45] foreach Y in {1,2}
{(0,0) circle[radius=Y]
(45:Y) rectangle (225:Y)
foreach X in {45,135,225,315}
{ (X:Y) circle[radius=Y]}};
end{tikzpicture}
end{document}

One path for everything. ;-)
documentclass[tikz,border=3.14mm]{standalone}
begin{document}
begin{tikzpicture}
draw[rotate=45] foreach Y in {1,2}
{(0,0) circle[radius=Y]
(45:Y) rectangle (225:Y)
foreach X in {45,135,225,315}
{ (X:Y) circle[radius=Y]}};
end{tikzpicture}
end{document}

edited 2 hours ago
answered 5 hours ago
marmotmarmot
98.3k4113218
98.3k4113218
add a comment |
add a comment |
Not as much as @marmot's nicely optimised answer but a try (gives more knobs for fun though):
documentclass[tikz]{standalone}
begin{document}
begin{tikzpicture}[mystyle/.style={circle,draw,fill=none,minimum size=20, line width = 0.1pt}]
foreach x/y/z in {0/0/2,0/1/2,0/-1/2,-1/0/2,1/0/2,0/0/4,0/1/4,0/-1/4,-1/0/4,1/0/4}
node [mystyle, minimum size = z cm, color =black] (2) at (x, y) {};
foreach x/y in {-0.7/0.7, -1.41/1.41}
draw[rotate=45, line width = 0.1pt] (x , x ) rectangle (y, y);
end{tikzpicture}
end{document}
which gives

add a comment |
Not as much as @marmot's nicely optimised answer but a try (gives more knobs for fun though):
documentclass[tikz]{standalone}
begin{document}
begin{tikzpicture}[mystyle/.style={circle,draw,fill=none,minimum size=20, line width = 0.1pt}]
foreach x/y/z in {0/0/2,0/1/2,0/-1/2,-1/0/2,1/0/2,0/0/4,0/1/4,0/-1/4,-1/0/4,1/0/4}
node [mystyle, minimum size = z cm, color =black] (2) at (x, y) {};
foreach x/y in {-0.7/0.7, -1.41/1.41}
draw[rotate=45, line width = 0.1pt] (x , x ) rectangle (y, y);
end{tikzpicture}
end{document}
which gives

add a comment |
Not as much as @marmot's nicely optimised answer but a try (gives more knobs for fun though):
documentclass[tikz]{standalone}
begin{document}
begin{tikzpicture}[mystyle/.style={circle,draw,fill=none,minimum size=20, line width = 0.1pt}]
foreach x/y/z in {0/0/2,0/1/2,0/-1/2,-1/0/2,1/0/2,0/0/4,0/1/4,0/-1/4,-1/0/4,1/0/4}
node [mystyle, minimum size = z cm, color =black] (2) at (x, y) {};
foreach x/y in {-0.7/0.7, -1.41/1.41}
draw[rotate=45, line width = 0.1pt] (x , x ) rectangle (y, y);
end{tikzpicture}
end{document}
which gives

Not as much as @marmot's nicely optimised answer but a try (gives more knobs for fun though):
documentclass[tikz]{standalone}
begin{document}
begin{tikzpicture}[mystyle/.style={circle,draw,fill=none,minimum size=20, line width = 0.1pt}]
foreach x/y/z in {0/0/2,0/1/2,0/-1/2,-1/0/2,1/0/2,0/0/4,0/1/4,0/-1/4,-1/0/4,1/0/4}
node [mystyle, minimum size = z cm, color =black] (2) at (x, y) {};
foreach x/y in {-0.7/0.7, -1.41/1.41}
draw[rotate=45, line width = 0.1pt] (x , x ) rectangle (y, y);
end{tikzpicture}
end{document}
which gives

answered 5 hours ago
RaajaRaaja
3,60521037
3,60521037
add a comment |
add a comment |
I am participating in the celebration with two proposals, both of which have been made:
Two loops:
- the first one to make an enlargement (
scale) by two - the second to build the 4 circles and the square using
polar coordinates
The code is indented so that it can be read:
First proposal (easier to read):
documentclass{article}
usepackage{amsmath}
usepackage{tikz}
begin{document}
La version de TikZ est : pgfversion
vfill
begin{center}
begin{tikzpicture}
foreach s in {1,2}{
begin{scope}[scale=s]
draw (0,0) circle (1);
foreach r [remember= r as rr (initially 270)] in {0,90,180,270}{
draw (r:1) circle (1);
draw (rr:1)--(r:1);
}
end{scope}
}
end{tikzpicture}
end{center}
end{document}

Second proposal (with one less scope environment):
documentclass{article}
usepackage{amsmath}
usepackage{tikz}
begin{document}
La version de TikZ est : pgfversion
vfill
begin{center}
begin{tikzpicture}
foreach s in {1,2}{
draw (0,0) circle (s);
foreach r [remember= r as rr (initially 270)] in {0,90,180,270}{
draw (r:s) circle (s);
draw (rr:s)--(r:s);
}
}
end{tikzpicture}
end{center}
end{document}
add a comment |
I am participating in the celebration with two proposals, both of which have been made:
Two loops:
- the first one to make an enlargement (
scale) by two - the second to build the 4 circles and the square using
polar coordinates
The code is indented so that it can be read:
First proposal (easier to read):
documentclass{article}
usepackage{amsmath}
usepackage{tikz}
begin{document}
La version de TikZ est : pgfversion
vfill
begin{center}
begin{tikzpicture}
foreach s in {1,2}{
begin{scope}[scale=s]
draw (0,0) circle (1);
foreach r [remember= r as rr (initially 270)] in {0,90,180,270}{
draw (r:1) circle (1);
draw (rr:1)--(r:1);
}
end{scope}
}
end{tikzpicture}
end{center}
end{document}

Second proposal (with one less scope environment):
documentclass{article}
usepackage{amsmath}
usepackage{tikz}
begin{document}
La version de TikZ est : pgfversion
vfill
begin{center}
begin{tikzpicture}
foreach s in {1,2}{
draw (0,0) circle (s);
foreach r [remember= r as rr (initially 270)] in {0,90,180,270}{
draw (r:s) circle (s);
draw (rr:s)--(r:s);
}
}
end{tikzpicture}
end{center}
end{document}
add a comment |
I am participating in the celebration with two proposals, both of which have been made:
Two loops:
- the first one to make an enlargement (
scale) by two - the second to build the 4 circles and the square using
polar coordinates
The code is indented so that it can be read:
First proposal (easier to read):
documentclass{article}
usepackage{amsmath}
usepackage{tikz}
begin{document}
La version de TikZ est : pgfversion
vfill
begin{center}
begin{tikzpicture}
foreach s in {1,2}{
begin{scope}[scale=s]
draw (0,0) circle (1);
foreach r [remember= r as rr (initially 270)] in {0,90,180,270}{
draw (r:1) circle (1);
draw (rr:1)--(r:1);
}
end{scope}
}
end{tikzpicture}
end{center}
end{document}

Second proposal (with one less scope environment):
documentclass{article}
usepackage{amsmath}
usepackage{tikz}
begin{document}
La version de TikZ est : pgfversion
vfill
begin{center}
begin{tikzpicture}
foreach s in {1,2}{
draw (0,0) circle (s);
foreach r [remember= r as rr (initially 270)] in {0,90,180,270}{
draw (r:s) circle (s);
draw (rr:s)--(r:s);
}
}
end{tikzpicture}
end{center}
end{document}
I am participating in the celebration with two proposals, both of which have been made:
Two loops:
- the first one to make an enlargement (
scale) by two - the second to build the 4 circles and the square using
polar coordinates
The code is indented so that it can be read:
First proposal (easier to read):
documentclass{article}
usepackage{amsmath}
usepackage{tikz}
begin{document}
La version de TikZ est : pgfversion
vfill
begin{center}
begin{tikzpicture}
foreach s in {1,2}{
begin{scope}[scale=s]
draw (0,0) circle (1);
foreach r [remember= r as rr (initially 270)] in {0,90,180,270}{
draw (r:1) circle (1);
draw (rr:1)--(r:1);
}
end{scope}
}
end{tikzpicture}
end{center}
end{document}

Second proposal (with one less scope environment):
documentclass{article}
usepackage{amsmath}
usepackage{tikz}
begin{document}
La version de TikZ est : pgfversion
vfill
begin{center}
begin{tikzpicture}
foreach s in {1,2}{
draw (0,0) circle (s);
foreach r [remember= r as rr (initially 270)] in {0,90,180,270}{
draw (r:s) circle (s);
draw (rr:s)--(r:s);
}
}
end{tikzpicture}
end{center}
end{document}
edited 2 hours ago
answered 2 hours ago
AndréCAndréC
8,86911447
8,86911447
add a comment |
add a comment |
mou-nadal is a new contributor. Be nice, and check out our Code of Conduct.
mou-nadal is a new contributor. Be nice, and check out our Code of Conduct.
mou-nadal is a new contributor. Be nice, and check out our Code of Conduct.
mou-nadal is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
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%2f473926%2fan-optimized-set-of-tikz-code%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');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
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');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
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');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
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
Do you mean who has the shortest execution time in processor time? Who requires the least memory?
– AndréC
5 hours ago
Some think with a loop will be a great approach, but if we consider CPU and memory we must be more careful.
– mou-nadal
4 hours ago