Tikz, issue with applying style to nodes
I am a beginner in LaTeX, especially in TikZ package.
I want to draw Peterson graph with some styles.
My code
documentclass{article}
usepackage{tikz}
usepackage{caption}
usepackage{graphicx}
usetikzlibrary{graphs}
usetikzlibrary{graphs.standard}
usetikzlibrary[graphs]
tikzset{
every node/.style={draw, circle, very thick},
mark/.style={fill=black!50, circle},
}
begin{document}
begin{figure}
begin{tikzpicture}
graph [simple, edges={thick}, clockwise] {
subgraph C_n [n=5, name=A, radius=2cm];
subgraph I_n [V={a,b,c,d,e}, name=B, radius=1cm];
(A 5)[mark] --[red] (A 4)[mark],
A 1 -- B a,
A 2 -- B b,
A 3 -- B c,
A 4 -- B d,
A 5 -- B e,
B a -- B c,
B a -- B d,
B b -- B e,
B b -- B d,
B e -- B c
};
end{tikzpicture}
end{figure}
end{document}
I expect, that nodes 4 and 5 will be gray, but I have only red edge.
What did I do wrong?
tikz-pgf nodes graphs
add a comment |
I am a beginner in LaTeX, especially in TikZ package.
I want to draw Peterson graph with some styles.
My code
documentclass{article}
usepackage{tikz}
usepackage{caption}
usepackage{graphicx}
usetikzlibrary{graphs}
usetikzlibrary{graphs.standard}
usetikzlibrary[graphs]
tikzset{
every node/.style={draw, circle, very thick},
mark/.style={fill=black!50, circle},
}
begin{document}
begin{figure}
begin{tikzpicture}
graph [simple, edges={thick}, clockwise] {
subgraph C_n [n=5, name=A, radius=2cm];
subgraph I_n [V={a,b,c,d,e}, name=B, radius=1cm];
(A 5)[mark] --[red] (A 4)[mark],
A 1 -- B a,
A 2 -- B b,
A 3 -- B c,
A 4 -- B d,
A 5 -- B e,
B a -- B c,
B a -- B d,
B b -- B e,
B b -- B d,
B e -- B c
};
end{tikzpicture}
end{figure}
end{document}
I expect, that nodes 4 and 5 will be gray, but I have only red edge.
What did I do wrong?
tikz-pgf nodes graphs
1
your code is not compileable !
– AndréC
Mar 5 at 20:06
tikzset be before begin{document}, and begin{tikzpicture} in right place.
– Noctus
Mar 5 at 20:08
Modify your question by clicking on theedit
button.
– AndréC
Mar 5 at 20:09
In my opinion, this is a bug in thegraphs.standard
library, I tried in vain to apply a style to the graphs in this library. It does not work. Let's wait and see what other TikZ users think about it.
– AndréC
Mar 5 at 21:42
3
You can not change the color of existing node. The node (A 5) is created in thesubgraph
command before you try to apply[mark]
to it. Check TikZ 3.0: Colorate a specific node in a subgraph.
– Kpym
Mar 5 at 22:29
add a comment |
I am a beginner in LaTeX, especially in TikZ package.
I want to draw Peterson graph with some styles.
My code
documentclass{article}
usepackage{tikz}
usepackage{caption}
usepackage{graphicx}
usetikzlibrary{graphs}
usetikzlibrary{graphs.standard}
usetikzlibrary[graphs]
tikzset{
every node/.style={draw, circle, very thick},
mark/.style={fill=black!50, circle},
}
begin{document}
begin{figure}
begin{tikzpicture}
graph [simple, edges={thick}, clockwise] {
subgraph C_n [n=5, name=A, radius=2cm];
subgraph I_n [V={a,b,c,d,e}, name=B, radius=1cm];
(A 5)[mark] --[red] (A 4)[mark],
A 1 -- B a,
A 2 -- B b,
A 3 -- B c,
A 4 -- B d,
A 5 -- B e,
B a -- B c,
B a -- B d,
B b -- B e,
B b -- B d,
B e -- B c
};
end{tikzpicture}
end{figure}
end{document}
I expect, that nodes 4 and 5 will be gray, but I have only red edge.
What did I do wrong?
tikz-pgf nodes graphs
I am a beginner in LaTeX, especially in TikZ package.
I want to draw Peterson graph with some styles.
My code
documentclass{article}
usepackage{tikz}
usepackage{caption}
usepackage{graphicx}
usetikzlibrary{graphs}
usetikzlibrary{graphs.standard}
usetikzlibrary[graphs]
tikzset{
every node/.style={draw, circle, very thick},
mark/.style={fill=black!50, circle},
}
begin{document}
begin{figure}
begin{tikzpicture}
graph [simple, edges={thick}, clockwise] {
subgraph C_n [n=5, name=A, radius=2cm];
subgraph I_n [V={a,b,c,d,e}, name=B, radius=1cm];
(A 5)[mark] --[red] (A 4)[mark],
A 1 -- B a,
A 2 -- B b,
A 3 -- B c,
A 4 -- B d,
A 5 -- B e,
B a -- B c,
B a -- B d,
B b -- B e,
B b -- B d,
B e -- B c
};
end{tikzpicture}
end{figure}
end{document}
I expect, that nodes 4 and 5 will be gray, but I have only red edge.
What did I do wrong?
tikz-pgf nodes graphs
tikz-pgf nodes graphs
edited Mar 6 at 9:08
JouleV
5,33621242
5,33621242
asked Mar 5 at 20:04
NoctusNoctus
284
284
1
your code is not compileable !
– AndréC
Mar 5 at 20:06
tikzset be before begin{document}, and begin{tikzpicture} in right place.
– Noctus
Mar 5 at 20:08
Modify your question by clicking on theedit
button.
– AndréC
Mar 5 at 20:09
In my opinion, this is a bug in thegraphs.standard
library, I tried in vain to apply a style to the graphs in this library. It does not work. Let's wait and see what other TikZ users think about it.
– AndréC
Mar 5 at 21:42
3
You can not change the color of existing node. The node (A 5) is created in thesubgraph
command before you try to apply[mark]
to it. Check TikZ 3.0: Colorate a specific node in a subgraph.
– Kpym
Mar 5 at 22:29
add a comment |
1
your code is not compileable !
– AndréC
Mar 5 at 20:06
tikzset be before begin{document}, and begin{tikzpicture} in right place.
– Noctus
Mar 5 at 20:08
Modify your question by clicking on theedit
button.
– AndréC
Mar 5 at 20:09
In my opinion, this is a bug in thegraphs.standard
library, I tried in vain to apply a style to the graphs in this library. It does not work. Let's wait and see what other TikZ users think about it.
– AndréC
Mar 5 at 21:42
3
You can not change the color of existing node. The node (A 5) is created in thesubgraph
command before you try to apply[mark]
to it. Check TikZ 3.0: Colorate a specific node in a subgraph.
– Kpym
Mar 5 at 22:29
1
1
your code is not compileable !
– AndréC
Mar 5 at 20:06
your code is not compileable !
– AndréC
Mar 5 at 20:06
tikzset be before begin{document}, and begin{tikzpicture} in right place.
– Noctus
Mar 5 at 20:08
tikzset be before begin{document}, and begin{tikzpicture} in right place.
– Noctus
Mar 5 at 20:08
Modify your question by clicking on the
edit
button.– AndréC
Mar 5 at 20:09
Modify your question by clicking on the
edit
button.– AndréC
Mar 5 at 20:09
In my opinion, this is a bug in the
graphs.standard
library, I tried in vain to apply a style to the graphs in this library. It does not work. Let's wait and see what other TikZ users think about it.– AndréC
Mar 5 at 21:42
In my opinion, this is a bug in the
graphs.standard
library, I tried in vain to apply a style to the graphs in this library. It does not work. Let's wait and see what other TikZ users think about it.– AndréC
Mar 5 at 21:42
3
3
You can not change the color of existing node. The node (A 5) is created in the
subgraph
command before you try to apply [mark]
to it. Check TikZ 3.0: Colorate a specific node in a subgraph.– Kpym
Mar 5 at 22:29
You can not change the color of existing node. The node (A 5) is created in the
subgraph
command before you try to apply [mark]
to it. Check TikZ 3.0: Colorate a specific node in a subgraph.– Kpym
Mar 5 at 22:29
add a comment |
1 Answer
1
active
oldest
votes
I followed the link given by @Kpym in his commentary and adapted the solution given by hftf.
documentclass[tikz,border=5mm]{standalone}
%usepackage{tikz}
%usepackage{caption}
usepackage{graphicx}
usetikzlibrary{graphs}
usetikzlibrary{graphs.standard}
tikzset{
every node/.style={draw, circle, very thick},
marko/.style={fill=cyan!50, circle},
}
begin{document}
% begin{figure}
begin{tikzpicture}
graph [simple, edges={thick},n=5,radius=2cm, clockwise] {
1;2;3;4[marko];5[marko];
subgraph C_n [n=5, name=A, radius=2cm];
subgraph I_n [V={a,b,c,d,e}, name=B, radius=1cm];
(A 5) --[blue] (A 4),
A 1 -- B a,
A 2 -- B b,
A 3 -- B c,
A 4 -- B d,
A 5 -- B e,
B a -- B c,
B a -- B d,
B b -- B e,
B b -- B d,
B e -- B c
};
end{tikzpicture}
%
% tikz
%graph [nodes={draw, circle}, n=5, radius=1.5cm, clockwise]
%{ 1; 2; 3[fill=gray]; 4; 5; subgraph K_n };
% end{figure}
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%2f477920%2ftikz-issue-with-applying-style-to-nodes%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I followed the link given by @Kpym in his commentary and adapted the solution given by hftf.
documentclass[tikz,border=5mm]{standalone}
%usepackage{tikz}
%usepackage{caption}
usepackage{graphicx}
usetikzlibrary{graphs}
usetikzlibrary{graphs.standard}
tikzset{
every node/.style={draw, circle, very thick},
marko/.style={fill=cyan!50, circle},
}
begin{document}
% begin{figure}
begin{tikzpicture}
graph [simple, edges={thick},n=5,radius=2cm, clockwise] {
1;2;3;4[marko];5[marko];
subgraph C_n [n=5, name=A, radius=2cm];
subgraph I_n [V={a,b,c,d,e}, name=B, radius=1cm];
(A 5) --[blue] (A 4),
A 1 -- B a,
A 2 -- B b,
A 3 -- B c,
A 4 -- B d,
A 5 -- B e,
B a -- B c,
B a -- B d,
B b -- B e,
B b -- B d,
B e -- B c
};
end{tikzpicture}
%
% tikz
%graph [nodes={draw, circle}, n=5, radius=1.5cm, clockwise]
%{ 1; 2; 3[fill=gray]; 4; 5; subgraph K_n };
% end{figure}
end{document}
add a comment |
I followed the link given by @Kpym in his commentary and adapted the solution given by hftf.
documentclass[tikz,border=5mm]{standalone}
%usepackage{tikz}
%usepackage{caption}
usepackage{graphicx}
usetikzlibrary{graphs}
usetikzlibrary{graphs.standard}
tikzset{
every node/.style={draw, circle, very thick},
marko/.style={fill=cyan!50, circle},
}
begin{document}
% begin{figure}
begin{tikzpicture}
graph [simple, edges={thick},n=5,radius=2cm, clockwise] {
1;2;3;4[marko];5[marko];
subgraph C_n [n=5, name=A, radius=2cm];
subgraph I_n [V={a,b,c,d,e}, name=B, radius=1cm];
(A 5) --[blue] (A 4),
A 1 -- B a,
A 2 -- B b,
A 3 -- B c,
A 4 -- B d,
A 5 -- B e,
B a -- B c,
B a -- B d,
B b -- B e,
B b -- B d,
B e -- B c
};
end{tikzpicture}
%
% tikz
%graph [nodes={draw, circle}, n=5, radius=1.5cm, clockwise]
%{ 1; 2; 3[fill=gray]; 4; 5; subgraph K_n };
% end{figure}
end{document}
add a comment |
I followed the link given by @Kpym in his commentary and adapted the solution given by hftf.
documentclass[tikz,border=5mm]{standalone}
%usepackage{tikz}
%usepackage{caption}
usepackage{graphicx}
usetikzlibrary{graphs}
usetikzlibrary{graphs.standard}
tikzset{
every node/.style={draw, circle, very thick},
marko/.style={fill=cyan!50, circle},
}
begin{document}
% begin{figure}
begin{tikzpicture}
graph [simple, edges={thick},n=5,radius=2cm, clockwise] {
1;2;3;4[marko];5[marko];
subgraph C_n [n=5, name=A, radius=2cm];
subgraph I_n [V={a,b,c,d,e}, name=B, radius=1cm];
(A 5) --[blue] (A 4),
A 1 -- B a,
A 2 -- B b,
A 3 -- B c,
A 4 -- B d,
A 5 -- B e,
B a -- B c,
B a -- B d,
B b -- B e,
B b -- B d,
B e -- B c
};
end{tikzpicture}
%
% tikz
%graph [nodes={draw, circle}, n=5, radius=1.5cm, clockwise]
%{ 1; 2; 3[fill=gray]; 4; 5; subgraph K_n };
% end{figure}
end{document}
I followed the link given by @Kpym in his commentary and adapted the solution given by hftf.
documentclass[tikz,border=5mm]{standalone}
%usepackage{tikz}
%usepackage{caption}
usepackage{graphicx}
usetikzlibrary{graphs}
usetikzlibrary{graphs.standard}
tikzset{
every node/.style={draw, circle, very thick},
marko/.style={fill=cyan!50, circle},
}
begin{document}
% begin{figure}
begin{tikzpicture}
graph [simple, edges={thick},n=5,radius=2cm, clockwise] {
1;2;3;4[marko];5[marko];
subgraph C_n [n=5, name=A, radius=2cm];
subgraph I_n [V={a,b,c,d,e}, name=B, radius=1cm];
(A 5) --[blue] (A 4),
A 1 -- B a,
A 2 -- B b,
A 3 -- B c,
A 4 -- B d,
A 5 -- B e,
B a -- B c,
B a -- B d,
B b -- B e,
B b -- B d,
B e -- B c
};
end{tikzpicture}
%
% tikz
%graph [nodes={draw, circle}, n=5, radius=1.5cm, clockwise]
%{ 1; 2; 3[fill=gray]; 4; 5; subgraph K_n };
% end{figure}
end{document}
answered Mar 6 at 8:57
AndréCAndréC
1
1
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%2f477920%2ftikz-issue-with-applying-style-to-nodes%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
1
your code is not compileable !
– AndréC
Mar 5 at 20:06
tikzset be before begin{document}, and begin{tikzpicture} in right place.
– Noctus
Mar 5 at 20:08
Modify your question by clicking on the
edit
button.– AndréC
Mar 5 at 20:09
In my opinion, this is a bug in the
graphs.standard
library, I tried in vain to apply a style to the graphs in this library. It does not work. Let's wait and see what other TikZ users think about it.– AndréC
Mar 5 at 21:42
3
You can not change the color of existing node. The node (A 5) is created in the
subgraph
command before you try to apply[mark]
to it. Check TikZ 3.0: Colorate a specific node in a subgraph.– Kpym
Mar 5 at 22:29