TikZ: how to draw a diamond child
I need to draw an "easy" flowchart. I would do that, using the child statement. I've used (as example) an example found here. I've modified it and this is the code:
documentclass{article}
usepackage{tikz}
usetikzlibrary{trees}
usepackage[active,tightpage]{preview}% just for showing image
PreviewEnvironment{tikzpicture}
setlengthPreviewBorder{5pt}%
%-------definisce stile dei nodi---------------
tikzstyle{startstop} = [rectangle, rounded corners, minimum width=5cm, minimum height=1cm,text centered, draw=black, fill=red!50]
tikzstyle{io} = [trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=blue!30]
tikzstyle{process} = [rectangle, minimum width=3cm, minimum height=1cm, text centered, text width=3cm, draw=black, fill=orange!30]
tikzstyle{decision} = [diamond, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=green!30]
tikzstyle{arrow} = [thick,->,>=stealth]
%--------------------------------------
begin{document}
begin{tikzpicture}[
thick,
every node/.style = {
text width = 5em,
top color = blue!60,
bottom color = blue!60,
rectangle,
font = sffamily,
text=white
},
sibling distance = 7em,
edge from parent fork down
]
node[text width=10em] (T0) {test0}
child {node (T1) {test1}
%child {node[ellipse,draw] (right node) {right}};
child {node[diamond, red] (T4) {test4}
child {node (T5) {test5}}
}}
child {node (T2) {test2}}
;
end{tikzpicture}
end{document}
But the "diamond" icon doesn't work. I've also tried to insert the "decision" style that I've created
tikzstyle{decision} = [diamond, minimum width=3cm, minimum
height=1cm, text centered, draw=black, fill=green!30]
and neither this nor "diamond" works.
How can I draw a "diamond" (because I need to draw a decision Icon)?
tikz-pgf workflow
add a comment |
I need to draw an "easy" flowchart. I would do that, using the child statement. I've used (as example) an example found here. I've modified it and this is the code:
documentclass{article}
usepackage{tikz}
usetikzlibrary{trees}
usepackage[active,tightpage]{preview}% just for showing image
PreviewEnvironment{tikzpicture}
setlengthPreviewBorder{5pt}%
%-------definisce stile dei nodi---------------
tikzstyle{startstop} = [rectangle, rounded corners, minimum width=5cm, minimum height=1cm,text centered, draw=black, fill=red!50]
tikzstyle{io} = [trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=blue!30]
tikzstyle{process} = [rectangle, minimum width=3cm, minimum height=1cm, text centered, text width=3cm, draw=black, fill=orange!30]
tikzstyle{decision} = [diamond, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=green!30]
tikzstyle{arrow} = [thick,->,>=stealth]
%--------------------------------------
begin{document}
begin{tikzpicture}[
thick,
every node/.style = {
text width = 5em,
top color = blue!60,
bottom color = blue!60,
rectangle,
font = sffamily,
text=white
},
sibling distance = 7em,
edge from parent fork down
]
node[text width=10em] (T0) {test0}
child {node (T1) {test1}
%child {node[ellipse,draw] (right node) {right}};
child {node[diamond, red] (T4) {test4}
child {node (T5) {test5}}
}}
child {node (T2) {test2}}
;
end{tikzpicture}
end{document}
But the "diamond" icon doesn't work. I've also tried to insert the "decision" style that I've created
tikzstyle{decision} = [diamond, minimum width=3cm, minimum
height=1cm, text centered, draw=black, fill=green!30]
and neither this nor "diamond" works.
How can I draw a "diamond" (because I need to draw a decision Icon)?
tikz-pgf workflow
I would try including the libraryshapes.geometric
. You may also want to have a look to TikZ picture shapes.
– Claudio Fiandrino
Aug 27 '15 at 10:42
add a comment |
I need to draw an "easy" flowchart. I would do that, using the child statement. I've used (as example) an example found here. I've modified it and this is the code:
documentclass{article}
usepackage{tikz}
usetikzlibrary{trees}
usepackage[active,tightpage]{preview}% just for showing image
PreviewEnvironment{tikzpicture}
setlengthPreviewBorder{5pt}%
%-------definisce stile dei nodi---------------
tikzstyle{startstop} = [rectangle, rounded corners, minimum width=5cm, minimum height=1cm,text centered, draw=black, fill=red!50]
tikzstyle{io} = [trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=blue!30]
tikzstyle{process} = [rectangle, minimum width=3cm, minimum height=1cm, text centered, text width=3cm, draw=black, fill=orange!30]
tikzstyle{decision} = [diamond, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=green!30]
tikzstyle{arrow} = [thick,->,>=stealth]
%--------------------------------------
begin{document}
begin{tikzpicture}[
thick,
every node/.style = {
text width = 5em,
top color = blue!60,
bottom color = blue!60,
rectangle,
font = sffamily,
text=white
},
sibling distance = 7em,
edge from parent fork down
]
node[text width=10em] (T0) {test0}
child {node (T1) {test1}
%child {node[ellipse,draw] (right node) {right}};
child {node[diamond, red] (T4) {test4}
child {node (T5) {test5}}
}}
child {node (T2) {test2}}
;
end{tikzpicture}
end{document}
But the "diamond" icon doesn't work. I've also tried to insert the "decision" style that I've created
tikzstyle{decision} = [diamond, minimum width=3cm, minimum
height=1cm, text centered, draw=black, fill=green!30]
and neither this nor "diamond" works.
How can I draw a "diamond" (because I need to draw a decision Icon)?
tikz-pgf workflow
I need to draw an "easy" flowchart. I would do that, using the child statement. I've used (as example) an example found here. I've modified it and this is the code:
documentclass{article}
usepackage{tikz}
usetikzlibrary{trees}
usepackage[active,tightpage]{preview}% just for showing image
PreviewEnvironment{tikzpicture}
setlengthPreviewBorder{5pt}%
%-------definisce stile dei nodi---------------
tikzstyle{startstop} = [rectangle, rounded corners, minimum width=5cm, minimum height=1cm,text centered, draw=black, fill=red!50]
tikzstyle{io} = [trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=blue!30]
tikzstyle{process} = [rectangle, minimum width=3cm, minimum height=1cm, text centered, text width=3cm, draw=black, fill=orange!30]
tikzstyle{decision} = [diamond, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=green!30]
tikzstyle{arrow} = [thick,->,>=stealth]
%--------------------------------------
begin{document}
begin{tikzpicture}[
thick,
every node/.style = {
text width = 5em,
top color = blue!60,
bottom color = blue!60,
rectangle,
font = sffamily,
text=white
},
sibling distance = 7em,
edge from parent fork down
]
node[text width=10em] (T0) {test0}
child {node (T1) {test1}
%child {node[ellipse,draw] (right node) {right}};
child {node[diamond, red] (T4) {test4}
child {node (T5) {test5}}
}}
child {node (T2) {test2}}
;
end{tikzpicture}
end{document}
But the "diamond" icon doesn't work. I've also tried to insert the "decision" style that I've created
tikzstyle{decision} = [diamond, minimum width=3cm, minimum
height=1cm, text centered, draw=black, fill=green!30]
and neither this nor "diamond" works.
How can I draw a "diamond" (because I need to draw a decision Icon)?
tikz-pgf workflow
tikz-pgf workflow
edited Dec 13 '18 at 12:23
samcarter
85.8k794275
85.8k794275
asked Aug 27 '15 at 10:11
RenatoP
32829
32829
I would try including the libraryshapes.geometric
. You may also want to have a look to TikZ picture shapes.
– Claudio Fiandrino
Aug 27 '15 at 10:42
add a comment |
I would try including the libraryshapes.geometric
. You may also want to have a look to TikZ picture shapes.
– Claudio Fiandrino
Aug 27 '15 at 10:42
I would try including the library
shapes.geometric
. You may also want to have a look to TikZ picture shapes.– Claudio Fiandrino
Aug 27 '15 at 10:42
I would try including the library
shapes.geometric
. You may also want to have a look to TikZ picture shapes.– Claudio Fiandrino
Aug 27 '15 at 10:42
add a comment |
2 Answers
2
active
oldest
votes
As Claudio Fiandrino said, you need to load the shapes
(or shapes.geometric
) tikzlibrary
, too, in order to make diamond
work.
When I tried your code, the setting every node./style={...}
gave some problems, because it was overriding the decision
style (and all the other styles):
Since you have defined a style for each node, I'd suggest you to use them:
This is the code:
documentclass{article}
usepackage{tikz}
usetikzlibrary{trees,shapes.geometric}
usepackage[active,tightpage]{preview}% just for showing image
PreviewEnvironment{tikzpicture}
setlengthPreviewBorder{5pt}%
%-------definisce stile dei nodi---------------
tikzstyle{startstop} = [rectangle, rounded corners, minimum width=5cm, minimum height=1cm,text centered, draw=black, fill=red!50]
tikzstyle{io} = [trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=2cm, minimum height=1cm, text centered, draw=black, fill=blue!30]
tikzstyle{process} = [rectangle, minimum width=2cm, minimum height=1cm, text centered, text width=2cm, draw=black, fill=orange!30]
tikzstyle{decision} = [diamond, minimum width=2cm, minimum height=1cm, text centered, draw=black, fill=green!30]
tikzstyle{arrow} = [thick,->,>=stealth]
%--------------------------------------
begin{document}
begin{tikzpicture}[
thick,
every node/.style = {
font = sffamily,
text=white
},
sibling distance = 7em,
edge from parent fork down
]
node[startstop,text width=10em] (T0) {test0}
child {node[process] (T1) {test1}
%child {node[ellipse,draw] (right node) {right}};
child {node[decision,text=red] (T4) {test4}
child {node[process] (T5) {test5}}
}}
child {node[process] (T2) {test2}}
;
end{tikzpicture}
end{document}
EDIT: some more suggestions, thanks to Claudio Fiandrino's comment:
In order to show only the image the
standalone
class is better, and you won't need this code:
usepackage[active,tightpage]{preview}% just for showing image
PreviewEnvironment{tikzpicture}
setlengthPreviewBorder{5pt}%
but only
documentclass{standalone}
.
Usually it's better to use
tikset{...}
thantikzstyle{...}
to define the style of a node. For more information, you can read the answer linked by Claudio Fiandrino (Should tikzset or tikzstyle be used to define TikZ styles?).
The new improved code, that produces the same output, is the following:
documentclass{standalone}
usepackage{tikz}
usetikzlibrary{trees,shapes.geometric}
%-------definisce stile dei nodi---------------
tikzset{%
startstop/.style={rectangle, rounded corners, minimum width=5cm, minimum height=1cm,text centered, draw=black, fill=red!50},
io/.style={trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=blue!30},
process/.style={rectangle, minimum width=2cm, minimum height=1cm, text centered, text width=2cm, draw=black, fill=orange!30},
decision/.style={diamond, minimum width=2cm, minimum height=1cm, text centered, draw=black, fill=green!30},
arrow/.style={thick,->,>=stealth},
every node/.style={font = sffamily,text=white}
}
%--------------------------------------
begin{document}
begin{tikzpicture}[
thick,
sibling distance = 7em,
edge from parent fork down
]
node[startstop,text width=10em] (T0) {test0}
child {node[process] (T1) {test1}
%child {node[ellipse,draw] (right node) {right}};
child {node[decision,text=red] (T4) {test4}
child {node[process] (T5) {test5}}
}}
child {node[process] (T2) {test2}}
;
end{tikzpicture}
end{document}
EDIT 2: After some trial and error, I obtained this result:
I defined three diffent styles for the edge
between the diamond
and its child
s:
tikzset{%
MyEdgeA/.style={edge from parent path={(tikzparentnode.west) -| (tikzchildnode.north)}},
MyEdgeB/.style={edge from parent path={(tikzparentnode.south) -| (tikzchildnode.north)}},
MyEdgeC/.style={edge from parent path={(tikzparentnode.east) -| (tikzchildnode.north)}}
}
You can set the type of edge you want giving it as a child
option:
child[MyEdgeA]{...}
Moreover, I changed the distance between the diamond and the subsequent nodes with:
level 3/.style={level distance=5em}
The complete code is:
documentclass{standalone}
usepackage{tikz}
usetikzlibrary{trees,shapes.geometric}
%-------definisce stile dei nodi---------------
tikzset{%
startstop/.style={rectangle, rounded corners, minimum width=5cm, minimum height=1cm,text centered, draw=black, fill=red!50},
io/.style={trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=blue!30},
process/.style={rectangle, minimum width=2cm, minimum height=1cm, text centered, text width=2cm, draw=black, fill=orange!30},
decision/.style={diamond, minimum width=2cm, minimum height=1cm, text centered, draw=black, fill=green!30},
arrow/.style={thick,->,>=stealth},
every node/.style={font=sffamily,text=white}
}
tikzset{%
MyEdgeA/.style={edge from parent path={(tikzparentnode.west) -| (tikzchildnode.north)}},
MyEdgeB/.style={edge from parent path={(tikzparentnode.south) -| (tikzchildnode.north)}},
MyEdgeC/.style={edge from parent path={(tikzparentnode.east) -| (tikzchildnode.north)}}
}
%--------------------------------------
begin{document}
begin{tikzpicture}[
thick,
sibling distance = 7em,
edge from parent fork down,
level 3/.style={level distance=5em}
]
node[startstop,text width=10em] (T0) {test0}
child {node[process] (T1) {test1}
%child {node[ellipse,draw] (right node) {right}};
child {node[decision,text=red] (T4) {test4}
child[MyEdgeA] {node[process] (T5) {test5}
edge from parent
node[pos=0.5,above,text=black] {No}}
child[MyEdgeB] {node[process] (T6) {test6}
edge from parent
node[pos=0.7,right,text=black] {bla bla..}}
child[MyEdgeC] {node[process] (T7) {test7}
edge from parent
node[pos=0.5,above,text=black] {Yes}}
}}
child {node[process] (T2) {test2}}
;
end{tikzpicture}
end{document}
Does the diamond have the same line width?
– Sigur
Aug 27 '15 at 11:00
1
@Sigur Actually, I changed only the width of the process blocks to make them fit in the block diagram; probably it is better to change the diamond, too. Thanks, I'll edit my answer.
– MarcoG
Aug 27 '15 at 11:05
Small tips: I believe today usingstandalone
gives more flexibility andtikzset
should be preferred totikzstyle
(see Should tikzset or tikzstyle be used to define TikZ styles?.
– Claudio Fiandrino
Aug 27 '15 at 13:00
@ClaudioFiandrino I knew that, but since I'm not an expert in defining node styles, I didn't try it :-)! However, this time I was able to do it! Thanks for the suggestions!
– MarcoG
Aug 27 '15 at 13:55
As last thing... I need three arrow from diamond (one west, second east, last below) with the label: "yes", "no", "bla bla bla...". Is it possible? Renato
– RenatoP
Aug 27 '15 at 14:01
|
show 1 more comment
To draw diamonds, you have to include the shapes
tikz library (and for arrows the arrows
tikz library) in the preamble:
documentclass{article}
usepackage{tikz}
usetikzlibrary{trees}
usepackage[active,tightpage]{preview}% just for showing image
PreviewEnvironment{tikzpicture}
usetikzlibrary{shapes,arrows}
setlengthPreviewBorder{5pt}%
%-------definisce stile dei nodi---------------
tikzstyle{decision} = [diamond, draw=brown, fill=green!30!yellow, inner sep=0em]
%--------------------------------------
begin{document}
begin{tikzpicture}[
thick,
every node/.style = {
text width = 5em,
fill=blue!60,
rectangle,
font = sffamily,
text=white,
text centered,
},
sibling distance = 7em]%,
%edge from parent fork down
% ]
%begin{tikzpicture}
node[text width=10em] (T0) {test0}
child {node (T1) {test1}
%child {node[ellipse,draw] (right node) {right}};
child {node[decision] (T4) {test4}
child {node (T5) {test5}}
}}
child {node (T2) {test2}}
;
end{tikzpicture}
end{document}
I've furthermore applied some other minor changes to improve your code and result. The default background color for all nodes is set to fill=blue!60
, rather than the bottom and top colors (because this is used for gradient fills, and it overwrites the standard fill). I've removed defined styles that were not used; I've kept and adjusted the decision
style to which I refer (rather than diamond
) from the tikzpicture. The inner sep=0em
in the definition of the style decision
is used to shrink the (imho) oversized diamond.
EDIT: If you want to use the edge from parent fork down
you would have to shrink the diamond even more, or redefine other dimensions to prevent connecting elements and blocks from crossing each other.
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%2f263432%2ftikz-how-to-draw-a-diamond-child%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
As Claudio Fiandrino said, you need to load the shapes
(or shapes.geometric
) tikzlibrary
, too, in order to make diamond
work.
When I tried your code, the setting every node./style={...}
gave some problems, because it was overriding the decision
style (and all the other styles):
Since you have defined a style for each node, I'd suggest you to use them:
This is the code:
documentclass{article}
usepackage{tikz}
usetikzlibrary{trees,shapes.geometric}
usepackage[active,tightpage]{preview}% just for showing image
PreviewEnvironment{tikzpicture}
setlengthPreviewBorder{5pt}%
%-------definisce stile dei nodi---------------
tikzstyle{startstop} = [rectangle, rounded corners, minimum width=5cm, minimum height=1cm,text centered, draw=black, fill=red!50]
tikzstyle{io} = [trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=2cm, minimum height=1cm, text centered, draw=black, fill=blue!30]
tikzstyle{process} = [rectangle, minimum width=2cm, minimum height=1cm, text centered, text width=2cm, draw=black, fill=orange!30]
tikzstyle{decision} = [diamond, minimum width=2cm, minimum height=1cm, text centered, draw=black, fill=green!30]
tikzstyle{arrow} = [thick,->,>=stealth]
%--------------------------------------
begin{document}
begin{tikzpicture}[
thick,
every node/.style = {
font = sffamily,
text=white
},
sibling distance = 7em,
edge from parent fork down
]
node[startstop,text width=10em] (T0) {test0}
child {node[process] (T1) {test1}
%child {node[ellipse,draw] (right node) {right}};
child {node[decision,text=red] (T4) {test4}
child {node[process] (T5) {test5}}
}}
child {node[process] (T2) {test2}}
;
end{tikzpicture}
end{document}
EDIT: some more suggestions, thanks to Claudio Fiandrino's comment:
In order to show only the image the
standalone
class is better, and you won't need this code:
usepackage[active,tightpage]{preview}% just for showing image
PreviewEnvironment{tikzpicture}
setlengthPreviewBorder{5pt}%
but only
documentclass{standalone}
.
Usually it's better to use
tikset{...}
thantikzstyle{...}
to define the style of a node. For more information, you can read the answer linked by Claudio Fiandrino (Should tikzset or tikzstyle be used to define TikZ styles?).
The new improved code, that produces the same output, is the following:
documentclass{standalone}
usepackage{tikz}
usetikzlibrary{trees,shapes.geometric}
%-------definisce stile dei nodi---------------
tikzset{%
startstop/.style={rectangle, rounded corners, minimum width=5cm, minimum height=1cm,text centered, draw=black, fill=red!50},
io/.style={trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=blue!30},
process/.style={rectangle, minimum width=2cm, minimum height=1cm, text centered, text width=2cm, draw=black, fill=orange!30},
decision/.style={diamond, minimum width=2cm, minimum height=1cm, text centered, draw=black, fill=green!30},
arrow/.style={thick,->,>=stealth},
every node/.style={font = sffamily,text=white}
}
%--------------------------------------
begin{document}
begin{tikzpicture}[
thick,
sibling distance = 7em,
edge from parent fork down
]
node[startstop,text width=10em] (T0) {test0}
child {node[process] (T1) {test1}
%child {node[ellipse,draw] (right node) {right}};
child {node[decision,text=red] (T4) {test4}
child {node[process] (T5) {test5}}
}}
child {node[process] (T2) {test2}}
;
end{tikzpicture}
end{document}
EDIT 2: After some trial and error, I obtained this result:
I defined three diffent styles for the edge
between the diamond
and its child
s:
tikzset{%
MyEdgeA/.style={edge from parent path={(tikzparentnode.west) -| (tikzchildnode.north)}},
MyEdgeB/.style={edge from parent path={(tikzparentnode.south) -| (tikzchildnode.north)}},
MyEdgeC/.style={edge from parent path={(tikzparentnode.east) -| (tikzchildnode.north)}}
}
You can set the type of edge you want giving it as a child
option:
child[MyEdgeA]{...}
Moreover, I changed the distance between the diamond and the subsequent nodes with:
level 3/.style={level distance=5em}
The complete code is:
documentclass{standalone}
usepackage{tikz}
usetikzlibrary{trees,shapes.geometric}
%-------definisce stile dei nodi---------------
tikzset{%
startstop/.style={rectangle, rounded corners, minimum width=5cm, minimum height=1cm,text centered, draw=black, fill=red!50},
io/.style={trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=blue!30},
process/.style={rectangle, minimum width=2cm, minimum height=1cm, text centered, text width=2cm, draw=black, fill=orange!30},
decision/.style={diamond, minimum width=2cm, minimum height=1cm, text centered, draw=black, fill=green!30},
arrow/.style={thick,->,>=stealth},
every node/.style={font=sffamily,text=white}
}
tikzset{%
MyEdgeA/.style={edge from parent path={(tikzparentnode.west) -| (tikzchildnode.north)}},
MyEdgeB/.style={edge from parent path={(tikzparentnode.south) -| (tikzchildnode.north)}},
MyEdgeC/.style={edge from parent path={(tikzparentnode.east) -| (tikzchildnode.north)}}
}
%--------------------------------------
begin{document}
begin{tikzpicture}[
thick,
sibling distance = 7em,
edge from parent fork down,
level 3/.style={level distance=5em}
]
node[startstop,text width=10em] (T0) {test0}
child {node[process] (T1) {test1}
%child {node[ellipse,draw] (right node) {right}};
child {node[decision,text=red] (T4) {test4}
child[MyEdgeA] {node[process] (T5) {test5}
edge from parent
node[pos=0.5,above,text=black] {No}}
child[MyEdgeB] {node[process] (T6) {test6}
edge from parent
node[pos=0.7,right,text=black] {bla bla..}}
child[MyEdgeC] {node[process] (T7) {test7}
edge from parent
node[pos=0.5,above,text=black] {Yes}}
}}
child {node[process] (T2) {test2}}
;
end{tikzpicture}
end{document}
Does the diamond have the same line width?
– Sigur
Aug 27 '15 at 11:00
1
@Sigur Actually, I changed only the width of the process blocks to make them fit in the block diagram; probably it is better to change the diamond, too. Thanks, I'll edit my answer.
– MarcoG
Aug 27 '15 at 11:05
Small tips: I believe today usingstandalone
gives more flexibility andtikzset
should be preferred totikzstyle
(see Should tikzset or tikzstyle be used to define TikZ styles?.
– Claudio Fiandrino
Aug 27 '15 at 13:00
@ClaudioFiandrino I knew that, but since I'm not an expert in defining node styles, I didn't try it :-)! However, this time I was able to do it! Thanks for the suggestions!
– MarcoG
Aug 27 '15 at 13:55
As last thing... I need three arrow from diamond (one west, second east, last below) with the label: "yes", "no", "bla bla bla...". Is it possible? Renato
– RenatoP
Aug 27 '15 at 14:01
|
show 1 more comment
As Claudio Fiandrino said, you need to load the shapes
(or shapes.geometric
) tikzlibrary
, too, in order to make diamond
work.
When I tried your code, the setting every node./style={...}
gave some problems, because it was overriding the decision
style (and all the other styles):
Since you have defined a style for each node, I'd suggest you to use them:
This is the code:
documentclass{article}
usepackage{tikz}
usetikzlibrary{trees,shapes.geometric}
usepackage[active,tightpage]{preview}% just for showing image
PreviewEnvironment{tikzpicture}
setlengthPreviewBorder{5pt}%
%-------definisce stile dei nodi---------------
tikzstyle{startstop} = [rectangle, rounded corners, minimum width=5cm, minimum height=1cm,text centered, draw=black, fill=red!50]
tikzstyle{io} = [trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=2cm, minimum height=1cm, text centered, draw=black, fill=blue!30]
tikzstyle{process} = [rectangle, minimum width=2cm, minimum height=1cm, text centered, text width=2cm, draw=black, fill=orange!30]
tikzstyle{decision} = [diamond, minimum width=2cm, minimum height=1cm, text centered, draw=black, fill=green!30]
tikzstyle{arrow} = [thick,->,>=stealth]
%--------------------------------------
begin{document}
begin{tikzpicture}[
thick,
every node/.style = {
font = sffamily,
text=white
},
sibling distance = 7em,
edge from parent fork down
]
node[startstop,text width=10em] (T0) {test0}
child {node[process] (T1) {test1}
%child {node[ellipse,draw] (right node) {right}};
child {node[decision,text=red] (T4) {test4}
child {node[process] (T5) {test5}}
}}
child {node[process] (T2) {test2}}
;
end{tikzpicture}
end{document}
EDIT: some more suggestions, thanks to Claudio Fiandrino's comment:
In order to show only the image the
standalone
class is better, and you won't need this code:
usepackage[active,tightpage]{preview}% just for showing image
PreviewEnvironment{tikzpicture}
setlengthPreviewBorder{5pt}%
but only
documentclass{standalone}
.
Usually it's better to use
tikset{...}
thantikzstyle{...}
to define the style of a node. For more information, you can read the answer linked by Claudio Fiandrino (Should tikzset or tikzstyle be used to define TikZ styles?).
The new improved code, that produces the same output, is the following:
documentclass{standalone}
usepackage{tikz}
usetikzlibrary{trees,shapes.geometric}
%-------definisce stile dei nodi---------------
tikzset{%
startstop/.style={rectangle, rounded corners, minimum width=5cm, minimum height=1cm,text centered, draw=black, fill=red!50},
io/.style={trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=blue!30},
process/.style={rectangle, minimum width=2cm, minimum height=1cm, text centered, text width=2cm, draw=black, fill=orange!30},
decision/.style={diamond, minimum width=2cm, minimum height=1cm, text centered, draw=black, fill=green!30},
arrow/.style={thick,->,>=stealth},
every node/.style={font = sffamily,text=white}
}
%--------------------------------------
begin{document}
begin{tikzpicture}[
thick,
sibling distance = 7em,
edge from parent fork down
]
node[startstop,text width=10em] (T0) {test0}
child {node[process] (T1) {test1}
%child {node[ellipse,draw] (right node) {right}};
child {node[decision,text=red] (T4) {test4}
child {node[process] (T5) {test5}}
}}
child {node[process] (T2) {test2}}
;
end{tikzpicture}
end{document}
EDIT 2: After some trial and error, I obtained this result:
I defined three diffent styles for the edge
between the diamond
and its child
s:
tikzset{%
MyEdgeA/.style={edge from parent path={(tikzparentnode.west) -| (tikzchildnode.north)}},
MyEdgeB/.style={edge from parent path={(tikzparentnode.south) -| (tikzchildnode.north)}},
MyEdgeC/.style={edge from parent path={(tikzparentnode.east) -| (tikzchildnode.north)}}
}
You can set the type of edge you want giving it as a child
option:
child[MyEdgeA]{...}
Moreover, I changed the distance between the diamond and the subsequent nodes with:
level 3/.style={level distance=5em}
The complete code is:
documentclass{standalone}
usepackage{tikz}
usetikzlibrary{trees,shapes.geometric}
%-------definisce stile dei nodi---------------
tikzset{%
startstop/.style={rectangle, rounded corners, minimum width=5cm, minimum height=1cm,text centered, draw=black, fill=red!50},
io/.style={trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=blue!30},
process/.style={rectangle, minimum width=2cm, minimum height=1cm, text centered, text width=2cm, draw=black, fill=orange!30},
decision/.style={diamond, minimum width=2cm, minimum height=1cm, text centered, draw=black, fill=green!30},
arrow/.style={thick,->,>=stealth},
every node/.style={font=sffamily,text=white}
}
tikzset{%
MyEdgeA/.style={edge from parent path={(tikzparentnode.west) -| (tikzchildnode.north)}},
MyEdgeB/.style={edge from parent path={(tikzparentnode.south) -| (tikzchildnode.north)}},
MyEdgeC/.style={edge from parent path={(tikzparentnode.east) -| (tikzchildnode.north)}}
}
%--------------------------------------
begin{document}
begin{tikzpicture}[
thick,
sibling distance = 7em,
edge from parent fork down,
level 3/.style={level distance=5em}
]
node[startstop,text width=10em] (T0) {test0}
child {node[process] (T1) {test1}
%child {node[ellipse,draw] (right node) {right}};
child {node[decision,text=red] (T4) {test4}
child[MyEdgeA] {node[process] (T5) {test5}
edge from parent
node[pos=0.5,above,text=black] {No}}
child[MyEdgeB] {node[process] (T6) {test6}
edge from parent
node[pos=0.7,right,text=black] {bla bla..}}
child[MyEdgeC] {node[process] (T7) {test7}
edge from parent
node[pos=0.5,above,text=black] {Yes}}
}}
child {node[process] (T2) {test2}}
;
end{tikzpicture}
end{document}
Does the diamond have the same line width?
– Sigur
Aug 27 '15 at 11:00
1
@Sigur Actually, I changed only the width of the process blocks to make them fit in the block diagram; probably it is better to change the diamond, too. Thanks, I'll edit my answer.
– MarcoG
Aug 27 '15 at 11:05
Small tips: I believe today usingstandalone
gives more flexibility andtikzset
should be preferred totikzstyle
(see Should tikzset or tikzstyle be used to define TikZ styles?.
– Claudio Fiandrino
Aug 27 '15 at 13:00
@ClaudioFiandrino I knew that, but since I'm not an expert in defining node styles, I didn't try it :-)! However, this time I was able to do it! Thanks for the suggestions!
– MarcoG
Aug 27 '15 at 13:55
As last thing... I need three arrow from diamond (one west, second east, last below) with the label: "yes", "no", "bla bla bla...". Is it possible? Renato
– RenatoP
Aug 27 '15 at 14:01
|
show 1 more comment
As Claudio Fiandrino said, you need to load the shapes
(or shapes.geometric
) tikzlibrary
, too, in order to make diamond
work.
When I tried your code, the setting every node./style={...}
gave some problems, because it was overriding the decision
style (and all the other styles):
Since you have defined a style for each node, I'd suggest you to use them:
This is the code:
documentclass{article}
usepackage{tikz}
usetikzlibrary{trees,shapes.geometric}
usepackage[active,tightpage]{preview}% just for showing image
PreviewEnvironment{tikzpicture}
setlengthPreviewBorder{5pt}%
%-------definisce stile dei nodi---------------
tikzstyle{startstop} = [rectangle, rounded corners, minimum width=5cm, minimum height=1cm,text centered, draw=black, fill=red!50]
tikzstyle{io} = [trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=2cm, minimum height=1cm, text centered, draw=black, fill=blue!30]
tikzstyle{process} = [rectangle, minimum width=2cm, minimum height=1cm, text centered, text width=2cm, draw=black, fill=orange!30]
tikzstyle{decision} = [diamond, minimum width=2cm, minimum height=1cm, text centered, draw=black, fill=green!30]
tikzstyle{arrow} = [thick,->,>=stealth]
%--------------------------------------
begin{document}
begin{tikzpicture}[
thick,
every node/.style = {
font = sffamily,
text=white
},
sibling distance = 7em,
edge from parent fork down
]
node[startstop,text width=10em] (T0) {test0}
child {node[process] (T1) {test1}
%child {node[ellipse,draw] (right node) {right}};
child {node[decision,text=red] (T4) {test4}
child {node[process] (T5) {test5}}
}}
child {node[process] (T2) {test2}}
;
end{tikzpicture}
end{document}
EDIT: some more suggestions, thanks to Claudio Fiandrino's comment:
In order to show only the image the
standalone
class is better, and you won't need this code:
usepackage[active,tightpage]{preview}% just for showing image
PreviewEnvironment{tikzpicture}
setlengthPreviewBorder{5pt}%
but only
documentclass{standalone}
.
Usually it's better to use
tikset{...}
thantikzstyle{...}
to define the style of a node. For more information, you can read the answer linked by Claudio Fiandrino (Should tikzset or tikzstyle be used to define TikZ styles?).
The new improved code, that produces the same output, is the following:
documentclass{standalone}
usepackage{tikz}
usetikzlibrary{trees,shapes.geometric}
%-------definisce stile dei nodi---------------
tikzset{%
startstop/.style={rectangle, rounded corners, minimum width=5cm, minimum height=1cm,text centered, draw=black, fill=red!50},
io/.style={trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=blue!30},
process/.style={rectangle, minimum width=2cm, minimum height=1cm, text centered, text width=2cm, draw=black, fill=orange!30},
decision/.style={diamond, minimum width=2cm, minimum height=1cm, text centered, draw=black, fill=green!30},
arrow/.style={thick,->,>=stealth},
every node/.style={font = sffamily,text=white}
}
%--------------------------------------
begin{document}
begin{tikzpicture}[
thick,
sibling distance = 7em,
edge from parent fork down
]
node[startstop,text width=10em] (T0) {test0}
child {node[process] (T1) {test1}
%child {node[ellipse,draw] (right node) {right}};
child {node[decision,text=red] (T4) {test4}
child {node[process] (T5) {test5}}
}}
child {node[process] (T2) {test2}}
;
end{tikzpicture}
end{document}
EDIT 2: After some trial and error, I obtained this result:
I defined three diffent styles for the edge
between the diamond
and its child
s:
tikzset{%
MyEdgeA/.style={edge from parent path={(tikzparentnode.west) -| (tikzchildnode.north)}},
MyEdgeB/.style={edge from parent path={(tikzparentnode.south) -| (tikzchildnode.north)}},
MyEdgeC/.style={edge from parent path={(tikzparentnode.east) -| (tikzchildnode.north)}}
}
You can set the type of edge you want giving it as a child
option:
child[MyEdgeA]{...}
Moreover, I changed the distance between the diamond and the subsequent nodes with:
level 3/.style={level distance=5em}
The complete code is:
documentclass{standalone}
usepackage{tikz}
usetikzlibrary{trees,shapes.geometric}
%-------definisce stile dei nodi---------------
tikzset{%
startstop/.style={rectangle, rounded corners, minimum width=5cm, minimum height=1cm,text centered, draw=black, fill=red!50},
io/.style={trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=blue!30},
process/.style={rectangle, minimum width=2cm, minimum height=1cm, text centered, text width=2cm, draw=black, fill=orange!30},
decision/.style={diamond, minimum width=2cm, minimum height=1cm, text centered, draw=black, fill=green!30},
arrow/.style={thick,->,>=stealth},
every node/.style={font=sffamily,text=white}
}
tikzset{%
MyEdgeA/.style={edge from parent path={(tikzparentnode.west) -| (tikzchildnode.north)}},
MyEdgeB/.style={edge from parent path={(tikzparentnode.south) -| (tikzchildnode.north)}},
MyEdgeC/.style={edge from parent path={(tikzparentnode.east) -| (tikzchildnode.north)}}
}
%--------------------------------------
begin{document}
begin{tikzpicture}[
thick,
sibling distance = 7em,
edge from parent fork down,
level 3/.style={level distance=5em}
]
node[startstop,text width=10em] (T0) {test0}
child {node[process] (T1) {test1}
%child {node[ellipse,draw] (right node) {right}};
child {node[decision,text=red] (T4) {test4}
child[MyEdgeA] {node[process] (T5) {test5}
edge from parent
node[pos=0.5,above,text=black] {No}}
child[MyEdgeB] {node[process] (T6) {test6}
edge from parent
node[pos=0.7,right,text=black] {bla bla..}}
child[MyEdgeC] {node[process] (T7) {test7}
edge from parent
node[pos=0.5,above,text=black] {Yes}}
}}
child {node[process] (T2) {test2}}
;
end{tikzpicture}
end{document}
As Claudio Fiandrino said, you need to load the shapes
(or shapes.geometric
) tikzlibrary
, too, in order to make diamond
work.
When I tried your code, the setting every node./style={...}
gave some problems, because it was overriding the decision
style (and all the other styles):
Since you have defined a style for each node, I'd suggest you to use them:
This is the code:
documentclass{article}
usepackage{tikz}
usetikzlibrary{trees,shapes.geometric}
usepackage[active,tightpage]{preview}% just for showing image
PreviewEnvironment{tikzpicture}
setlengthPreviewBorder{5pt}%
%-------definisce stile dei nodi---------------
tikzstyle{startstop} = [rectangle, rounded corners, minimum width=5cm, minimum height=1cm,text centered, draw=black, fill=red!50]
tikzstyle{io} = [trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=2cm, minimum height=1cm, text centered, draw=black, fill=blue!30]
tikzstyle{process} = [rectangle, minimum width=2cm, minimum height=1cm, text centered, text width=2cm, draw=black, fill=orange!30]
tikzstyle{decision} = [diamond, minimum width=2cm, minimum height=1cm, text centered, draw=black, fill=green!30]
tikzstyle{arrow} = [thick,->,>=stealth]
%--------------------------------------
begin{document}
begin{tikzpicture}[
thick,
every node/.style = {
font = sffamily,
text=white
},
sibling distance = 7em,
edge from parent fork down
]
node[startstop,text width=10em] (T0) {test0}
child {node[process] (T1) {test1}
%child {node[ellipse,draw] (right node) {right}};
child {node[decision,text=red] (T4) {test4}
child {node[process] (T5) {test5}}
}}
child {node[process] (T2) {test2}}
;
end{tikzpicture}
end{document}
EDIT: some more suggestions, thanks to Claudio Fiandrino's comment:
In order to show only the image the
standalone
class is better, and you won't need this code:
usepackage[active,tightpage]{preview}% just for showing image
PreviewEnvironment{tikzpicture}
setlengthPreviewBorder{5pt}%
but only
documentclass{standalone}
.
Usually it's better to use
tikset{...}
thantikzstyle{...}
to define the style of a node. For more information, you can read the answer linked by Claudio Fiandrino (Should tikzset or tikzstyle be used to define TikZ styles?).
The new improved code, that produces the same output, is the following:
documentclass{standalone}
usepackage{tikz}
usetikzlibrary{trees,shapes.geometric}
%-------definisce stile dei nodi---------------
tikzset{%
startstop/.style={rectangle, rounded corners, minimum width=5cm, minimum height=1cm,text centered, draw=black, fill=red!50},
io/.style={trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=blue!30},
process/.style={rectangle, minimum width=2cm, minimum height=1cm, text centered, text width=2cm, draw=black, fill=orange!30},
decision/.style={diamond, minimum width=2cm, minimum height=1cm, text centered, draw=black, fill=green!30},
arrow/.style={thick,->,>=stealth},
every node/.style={font = sffamily,text=white}
}
%--------------------------------------
begin{document}
begin{tikzpicture}[
thick,
sibling distance = 7em,
edge from parent fork down
]
node[startstop,text width=10em] (T0) {test0}
child {node[process] (T1) {test1}
%child {node[ellipse,draw] (right node) {right}};
child {node[decision,text=red] (T4) {test4}
child {node[process] (T5) {test5}}
}}
child {node[process] (T2) {test2}}
;
end{tikzpicture}
end{document}
EDIT 2: After some trial and error, I obtained this result:
I defined three diffent styles for the edge
between the diamond
and its child
s:
tikzset{%
MyEdgeA/.style={edge from parent path={(tikzparentnode.west) -| (tikzchildnode.north)}},
MyEdgeB/.style={edge from parent path={(tikzparentnode.south) -| (tikzchildnode.north)}},
MyEdgeC/.style={edge from parent path={(tikzparentnode.east) -| (tikzchildnode.north)}}
}
You can set the type of edge you want giving it as a child
option:
child[MyEdgeA]{...}
Moreover, I changed the distance between the diamond and the subsequent nodes with:
level 3/.style={level distance=5em}
The complete code is:
documentclass{standalone}
usepackage{tikz}
usetikzlibrary{trees,shapes.geometric}
%-------definisce stile dei nodi---------------
tikzset{%
startstop/.style={rectangle, rounded corners, minimum width=5cm, minimum height=1cm,text centered, draw=black, fill=red!50},
io/.style={trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=blue!30},
process/.style={rectangle, minimum width=2cm, minimum height=1cm, text centered, text width=2cm, draw=black, fill=orange!30},
decision/.style={diamond, minimum width=2cm, minimum height=1cm, text centered, draw=black, fill=green!30},
arrow/.style={thick,->,>=stealth},
every node/.style={font=sffamily,text=white}
}
tikzset{%
MyEdgeA/.style={edge from parent path={(tikzparentnode.west) -| (tikzchildnode.north)}},
MyEdgeB/.style={edge from parent path={(tikzparentnode.south) -| (tikzchildnode.north)}},
MyEdgeC/.style={edge from parent path={(tikzparentnode.east) -| (tikzchildnode.north)}}
}
%--------------------------------------
begin{document}
begin{tikzpicture}[
thick,
sibling distance = 7em,
edge from parent fork down,
level 3/.style={level distance=5em}
]
node[startstop,text width=10em] (T0) {test0}
child {node[process] (T1) {test1}
%child {node[ellipse,draw] (right node) {right}};
child {node[decision,text=red] (T4) {test4}
child[MyEdgeA] {node[process] (T5) {test5}
edge from parent
node[pos=0.5,above,text=black] {No}}
child[MyEdgeB] {node[process] (T6) {test6}
edge from parent
node[pos=0.7,right,text=black] {bla bla..}}
child[MyEdgeC] {node[process] (T7) {test7}
edge from parent
node[pos=0.5,above,text=black] {Yes}}
}}
child {node[process] (T2) {test2}}
;
end{tikzpicture}
end{document}
edited Apr 13 '17 at 12:35
Community♦
1
1
answered Aug 27 '15 at 10:59
MarcoG
1,1131414
1,1131414
Does the diamond have the same line width?
– Sigur
Aug 27 '15 at 11:00
1
@Sigur Actually, I changed only the width of the process blocks to make them fit in the block diagram; probably it is better to change the diamond, too. Thanks, I'll edit my answer.
– MarcoG
Aug 27 '15 at 11:05
Small tips: I believe today usingstandalone
gives more flexibility andtikzset
should be preferred totikzstyle
(see Should tikzset or tikzstyle be used to define TikZ styles?.
– Claudio Fiandrino
Aug 27 '15 at 13:00
@ClaudioFiandrino I knew that, but since I'm not an expert in defining node styles, I didn't try it :-)! However, this time I was able to do it! Thanks for the suggestions!
– MarcoG
Aug 27 '15 at 13:55
As last thing... I need three arrow from diamond (one west, second east, last below) with the label: "yes", "no", "bla bla bla...". Is it possible? Renato
– RenatoP
Aug 27 '15 at 14:01
|
show 1 more comment
Does the diamond have the same line width?
– Sigur
Aug 27 '15 at 11:00
1
@Sigur Actually, I changed only the width of the process blocks to make them fit in the block diagram; probably it is better to change the diamond, too. Thanks, I'll edit my answer.
– MarcoG
Aug 27 '15 at 11:05
Small tips: I believe today usingstandalone
gives more flexibility andtikzset
should be preferred totikzstyle
(see Should tikzset or tikzstyle be used to define TikZ styles?.
– Claudio Fiandrino
Aug 27 '15 at 13:00
@ClaudioFiandrino I knew that, but since I'm not an expert in defining node styles, I didn't try it :-)! However, this time I was able to do it! Thanks for the suggestions!
– MarcoG
Aug 27 '15 at 13:55
As last thing... I need three arrow from diamond (one west, second east, last below) with the label: "yes", "no", "bla bla bla...". Is it possible? Renato
– RenatoP
Aug 27 '15 at 14:01
Does the diamond have the same line width?
– Sigur
Aug 27 '15 at 11:00
Does the diamond have the same line width?
– Sigur
Aug 27 '15 at 11:00
1
1
@Sigur Actually, I changed only the width of the process blocks to make them fit in the block diagram; probably it is better to change the diamond, too. Thanks, I'll edit my answer.
– MarcoG
Aug 27 '15 at 11:05
@Sigur Actually, I changed only the width of the process blocks to make them fit in the block diagram; probably it is better to change the diamond, too. Thanks, I'll edit my answer.
– MarcoG
Aug 27 '15 at 11:05
Small tips: I believe today using
standalone
gives more flexibility and tikzset
should be preferred to tikzstyle
(see Should tikzset or tikzstyle be used to define TikZ styles?.– Claudio Fiandrino
Aug 27 '15 at 13:00
Small tips: I believe today using
standalone
gives more flexibility and tikzset
should be preferred to tikzstyle
(see Should tikzset or tikzstyle be used to define TikZ styles?.– Claudio Fiandrino
Aug 27 '15 at 13:00
@ClaudioFiandrino I knew that, but since I'm not an expert in defining node styles, I didn't try it :-)! However, this time I was able to do it! Thanks for the suggestions!
– MarcoG
Aug 27 '15 at 13:55
@ClaudioFiandrino I knew that, but since I'm not an expert in defining node styles, I didn't try it :-)! However, this time I was able to do it! Thanks for the suggestions!
– MarcoG
Aug 27 '15 at 13:55
As last thing... I need three arrow from diamond (one west, second east, last below) with the label: "yes", "no", "bla bla bla...". Is it possible? Renato
– RenatoP
Aug 27 '15 at 14:01
As last thing... I need three arrow from diamond (one west, second east, last below) with the label: "yes", "no", "bla bla bla...". Is it possible? Renato
– RenatoP
Aug 27 '15 at 14:01
|
show 1 more comment
To draw diamonds, you have to include the shapes
tikz library (and for arrows the arrows
tikz library) in the preamble:
documentclass{article}
usepackage{tikz}
usetikzlibrary{trees}
usepackage[active,tightpage]{preview}% just for showing image
PreviewEnvironment{tikzpicture}
usetikzlibrary{shapes,arrows}
setlengthPreviewBorder{5pt}%
%-------definisce stile dei nodi---------------
tikzstyle{decision} = [diamond, draw=brown, fill=green!30!yellow, inner sep=0em]
%--------------------------------------
begin{document}
begin{tikzpicture}[
thick,
every node/.style = {
text width = 5em,
fill=blue!60,
rectangle,
font = sffamily,
text=white,
text centered,
},
sibling distance = 7em]%,
%edge from parent fork down
% ]
%begin{tikzpicture}
node[text width=10em] (T0) {test0}
child {node (T1) {test1}
%child {node[ellipse,draw] (right node) {right}};
child {node[decision] (T4) {test4}
child {node (T5) {test5}}
}}
child {node (T2) {test2}}
;
end{tikzpicture}
end{document}
I've furthermore applied some other minor changes to improve your code and result. The default background color for all nodes is set to fill=blue!60
, rather than the bottom and top colors (because this is used for gradient fills, and it overwrites the standard fill). I've removed defined styles that were not used; I've kept and adjusted the decision
style to which I refer (rather than diamond
) from the tikzpicture. The inner sep=0em
in the definition of the style decision
is used to shrink the (imho) oversized diamond.
EDIT: If you want to use the edge from parent fork down
you would have to shrink the diamond even more, or redefine other dimensions to prevent connecting elements and blocks from crossing each other.
add a comment |
To draw diamonds, you have to include the shapes
tikz library (and for arrows the arrows
tikz library) in the preamble:
documentclass{article}
usepackage{tikz}
usetikzlibrary{trees}
usepackage[active,tightpage]{preview}% just for showing image
PreviewEnvironment{tikzpicture}
usetikzlibrary{shapes,arrows}
setlengthPreviewBorder{5pt}%
%-------definisce stile dei nodi---------------
tikzstyle{decision} = [diamond, draw=brown, fill=green!30!yellow, inner sep=0em]
%--------------------------------------
begin{document}
begin{tikzpicture}[
thick,
every node/.style = {
text width = 5em,
fill=blue!60,
rectangle,
font = sffamily,
text=white,
text centered,
},
sibling distance = 7em]%,
%edge from parent fork down
% ]
%begin{tikzpicture}
node[text width=10em] (T0) {test0}
child {node (T1) {test1}
%child {node[ellipse,draw] (right node) {right}};
child {node[decision] (T4) {test4}
child {node (T5) {test5}}
}}
child {node (T2) {test2}}
;
end{tikzpicture}
end{document}
I've furthermore applied some other minor changes to improve your code and result. The default background color for all nodes is set to fill=blue!60
, rather than the bottom and top colors (because this is used for gradient fills, and it overwrites the standard fill). I've removed defined styles that were not used; I've kept and adjusted the decision
style to which I refer (rather than diamond
) from the tikzpicture. The inner sep=0em
in the definition of the style decision
is used to shrink the (imho) oversized diamond.
EDIT: If you want to use the edge from parent fork down
you would have to shrink the diamond even more, or redefine other dimensions to prevent connecting elements and blocks from crossing each other.
add a comment |
To draw diamonds, you have to include the shapes
tikz library (and for arrows the arrows
tikz library) in the preamble:
documentclass{article}
usepackage{tikz}
usetikzlibrary{trees}
usepackage[active,tightpage]{preview}% just for showing image
PreviewEnvironment{tikzpicture}
usetikzlibrary{shapes,arrows}
setlengthPreviewBorder{5pt}%
%-------definisce stile dei nodi---------------
tikzstyle{decision} = [diamond, draw=brown, fill=green!30!yellow, inner sep=0em]
%--------------------------------------
begin{document}
begin{tikzpicture}[
thick,
every node/.style = {
text width = 5em,
fill=blue!60,
rectangle,
font = sffamily,
text=white,
text centered,
},
sibling distance = 7em]%,
%edge from parent fork down
% ]
%begin{tikzpicture}
node[text width=10em] (T0) {test0}
child {node (T1) {test1}
%child {node[ellipse,draw] (right node) {right}};
child {node[decision] (T4) {test4}
child {node (T5) {test5}}
}}
child {node (T2) {test2}}
;
end{tikzpicture}
end{document}
I've furthermore applied some other minor changes to improve your code and result. The default background color for all nodes is set to fill=blue!60
, rather than the bottom and top colors (because this is used for gradient fills, and it overwrites the standard fill). I've removed defined styles that were not used; I've kept and adjusted the decision
style to which I refer (rather than diamond
) from the tikzpicture. The inner sep=0em
in the definition of the style decision
is used to shrink the (imho) oversized diamond.
EDIT: If you want to use the edge from parent fork down
you would have to shrink the diamond even more, or redefine other dimensions to prevent connecting elements and blocks from crossing each other.
To draw diamonds, you have to include the shapes
tikz library (and for arrows the arrows
tikz library) in the preamble:
documentclass{article}
usepackage{tikz}
usetikzlibrary{trees}
usepackage[active,tightpage]{preview}% just for showing image
PreviewEnvironment{tikzpicture}
usetikzlibrary{shapes,arrows}
setlengthPreviewBorder{5pt}%
%-------definisce stile dei nodi---------------
tikzstyle{decision} = [diamond, draw=brown, fill=green!30!yellow, inner sep=0em]
%--------------------------------------
begin{document}
begin{tikzpicture}[
thick,
every node/.style = {
text width = 5em,
fill=blue!60,
rectangle,
font = sffamily,
text=white,
text centered,
},
sibling distance = 7em]%,
%edge from parent fork down
% ]
%begin{tikzpicture}
node[text width=10em] (T0) {test0}
child {node (T1) {test1}
%child {node[ellipse,draw] (right node) {right}};
child {node[decision] (T4) {test4}
child {node (T5) {test5}}
}}
child {node (T2) {test2}}
;
end{tikzpicture}
end{document}
I've furthermore applied some other minor changes to improve your code and result. The default background color for all nodes is set to fill=blue!60
, rather than the bottom and top colors (because this is used for gradient fills, and it overwrites the standard fill). I've removed defined styles that were not used; I've kept and adjusted the decision
style to which I refer (rather than diamond
) from the tikzpicture. The inner sep=0em
in the definition of the style decision
is used to shrink the (imho) oversized diamond.
EDIT: If you want to use the edge from parent fork down
you would have to shrink the diamond even more, or redefine other dimensions to prevent connecting elements and blocks from crossing each other.
edited Aug 27 '15 at 11:12
answered Aug 27 '15 at 11:03
JJM Driessen
406314
406314
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f263432%2ftikz-how-to-draw-a-diamond-child%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
I would try including the library
shapes.geometric
. You may also want to have a look to TikZ picture shapes.– Claudio Fiandrino
Aug 27 '15 at 10:42