Increase spacing between nodes in tikzpicture
up vote
1
down vote
favorite
How can I increase the spacing between nodes A and B? Right now they are right beside each other. Also, is there a way to prevent node H from overlapping with the other nodes?
The above output is produced from the following commands.
documentclass[tikz]{standalone}
usetikzlibrary{arrows,quotes, positioning}
tikzset{block/.style={ellipse, draw, fill=gray!20,
text width=8em, text centered, rounded corners, minimum height=4em, width=4em},
line/.style={draw, -latex'},}
begin{document}
begin{tikzpicture}[node distance = 3cm, auto]
node [block] (A) {A};
node [block,right of=A] (B) {B};
node [block, above of=A] (C) {C};
node [block, above of=B] (D) {D};
node [block, below left of=B, below right of=A] (E) {E};
node [block, right of=E] (F) {F};
node [block, above right of=F, node distance=3cm] (G) {G};
node [block, above of=G] (H) {H};
% Draw edges
path [line] (C) edge["a"'] (A) ;
path [line] (D) edge["b"'] (B) ;
path [line] (A) -- (E);
path [line] (B) -- (E);
path [line] (F) -- (E);
path [line] (F) edge["g"'] (G) ;
path [line] (G) edge["h"'] (H);
end{tikzpicture}
end{document}
Edit: edited to include environment based on Skillmon's answer. Apologies for not making my code compilable initially
tikz-arrows
New contributor
add a comment |
up vote
1
down vote
favorite
How can I increase the spacing between nodes A and B? Right now they are right beside each other. Also, is there a way to prevent node H from overlapping with the other nodes?
The above output is produced from the following commands.
documentclass[tikz]{standalone}
usetikzlibrary{arrows,quotes, positioning}
tikzset{block/.style={ellipse, draw, fill=gray!20,
text width=8em, text centered, rounded corners, minimum height=4em, width=4em},
line/.style={draw, -latex'},}
begin{document}
begin{tikzpicture}[node distance = 3cm, auto]
node [block] (A) {A};
node [block,right of=A] (B) {B};
node [block, above of=A] (C) {C};
node [block, above of=B] (D) {D};
node [block, below left of=B, below right of=A] (E) {E};
node [block, right of=E] (F) {F};
node [block, above right of=F, node distance=3cm] (G) {G};
node [block, above of=G] (H) {H};
% Draw edges
path [line] (C) edge["a"'] (A) ;
path [line] (D) edge["b"'] (B) ;
path [line] (A) -- (E);
path [line] (B) -- (E);
path [line] (F) -- (E);
path [line] (F) edge["g"'] (G) ;
path [line] (G) edge["h"'] (H);
end{tikzpicture}
end{document}
Edit: edited to include environment based on Skillmon's answer. Apologies for not making my code compilable initially
tikz-arrows
New contributor
1
Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it withdocumentclass{...}
, the requiredusepackage
's,begin{document}
, andend{document}
. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem.
– Skillmon
yesterday
Note that you need to load theshapes
library to getellipse
to work.
– Skillmon
yesterday
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
How can I increase the spacing between nodes A and B? Right now they are right beside each other. Also, is there a way to prevent node H from overlapping with the other nodes?
The above output is produced from the following commands.
documentclass[tikz]{standalone}
usetikzlibrary{arrows,quotes, positioning}
tikzset{block/.style={ellipse, draw, fill=gray!20,
text width=8em, text centered, rounded corners, minimum height=4em, width=4em},
line/.style={draw, -latex'},}
begin{document}
begin{tikzpicture}[node distance = 3cm, auto]
node [block] (A) {A};
node [block,right of=A] (B) {B};
node [block, above of=A] (C) {C};
node [block, above of=B] (D) {D};
node [block, below left of=B, below right of=A] (E) {E};
node [block, right of=E] (F) {F};
node [block, above right of=F, node distance=3cm] (G) {G};
node [block, above of=G] (H) {H};
% Draw edges
path [line] (C) edge["a"'] (A) ;
path [line] (D) edge["b"'] (B) ;
path [line] (A) -- (E);
path [line] (B) -- (E);
path [line] (F) -- (E);
path [line] (F) edge["g"'] (G) ;
path [line] (G) edge["h"'] (H);
end{tikzpicture}
end{document}
Edit: edited to include environment based on Skillmon's answer. Apologies for not making my code compilable initially
tikz-arrows
New contributor
How can I increase the spacing between nodes A and B? Right now they are right beside each other. Also, is there a way to prevent node H from overlapping with the other nodes?
The above output is produced from the following commands.
documentclass[tikz]{standalone}
usetikzlibrary{arrows,quotes, positioning}
tikzset{block/.style={ellipse, draw, fill=gray!20,
text width=8em, text centered, rounded corners, minimum height=4em, width=4em},
line/.style={draw, -latex'},}
begin{document}
begin{tikzpicture}[node distance = 3cm, auto]
node [block] (A) {A};
node [block,right of=A] (B) {B};
node [block, above of=A] (C) {C};
node [block, above of=B] (D) {D};
node [block, below left of=B, below right of=A] (E) {E};
node [block, right of=E] (F) {F};
node [block, above right of=F, node distance=3cm] (G) {G};
node [block, above of=G] (H) {H};
% Draw edges
path [line] (C) edge["a"'] (A) ;
path [line] (D) edge["b"'] (B) ;
path [line] (A) -- (E);
path [line] (B) -- (E);
path [line] (F) -- (E);
path [line] (F) edge["g"'] (G) ;
path [line] (G) edge["h"'] (H);
end{tikzpicture}
end{document}
Edit: edited to include environment based on Skillmon's answer. Apologies for not making my code compilable initially
tikz-arrows
tikz-arrows
New contributor
New contributor
edited yesterday
New contributor
asked yesterday
kanghj91
84
84
New contributor
New contributor
1
Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it withdocumentclass{...}
, the requiredusepackage
's,begin{document}
, andend{document}
. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem.
– Skillmon
yesterday
Note that you need to load theshapes
library to getellipse
to work.
– Skillmon
yesterday
add a comment |
1
Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it withdocumentclass{...}
, the requiredusepackage
's,begin{document}
, andend{document}
. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem.
– Skillmon
yesterday
Note that you need to load theshapes
library to getellipse
to work.
– Skillmon
yesterday
1
1
Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with
documentclass{...}
, the required usepackage
's, begin{document}
, and end{document}
. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem.– Skillmon
yesterday
Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with
documentclass{...}
, the required usepackage
's, begin{document}
, and end{document}
. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem.– Skillmon
yesterday
Note that you need to load the
shapes
library to get ellipse
to work.– Skillmon
yesterday
Note that you need to load the
shapes
library to get ellipse
to work.– Skillmon
yesterday
add a comment |
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
I added a minimal environment to your code so that I can work on it. You shouldn't use the right of=A
syntax but instead use right=of A
. I've also added a between
key to place E, note that below right=of A, below left=of B
will just result in below left=of B
the former being ignored. Also the ysep
and xsep
keys seem to not exist in current TikZ versions (mine is 3.0.1a).
documentclass[tikz]{standalone}
usetikzlibrary{arrows,quotes,positioning,shapes,calc}
tikzset
{
block/.style=%
{%
ellipse, draw, fill=gray!20, text width=8em, text centered, rounded
corners, minimum height=4em, minimum width=4em
}
,line/.style={draw, -latex'}
% https://tex.stackexchange.com/a/138828/117050
,between/.style args={#1 and #2}{at=($(#1)!0.5!(#2)$)}
}
begin{document}
begin{tikzpicture}[node distance = 2cm, auto]
node [block] (A) {A};
node [block,right=of A] (B) {B};
node [block, above=of A] (C) {C};
node [block, above=of B] (D) {D};
node [block, between=A and B, yshift=-2.5cm] (E) {E};
node [block, right=of E] (F) {F};
node [block, right=of B] (G) {G};
node [block, right=of D] (H) {H};
% Draw edges
path [line] (C) edge["a"'] (A) ;
path [line] (D) edge["b"'] (B) ;
path [line] (A) -- (E);
path [line] (B) -- (E);
path [line] (F) -- (E);
path [line] (F) edge["g"'] (G) ;
path [line] (G) edge["h"'] (H);
end{tikzpicture}
end{document}
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
I added a minimal environment to your code so that I can work on it. You shouldn't use the right of=A
syntax but instead use right=of A
. I've also added a between
key to place E, note that below right=of A, below left=of B
will just result in below left=of B
the former being ignored. Also the ysep
and xsep
keys seem to not exist in current TikZ versions (mine is 3.0.1a).
documentclass[tikz]{standalone}
usetikzlibrary{arrows,quotes,positioning,shapes,calc}
tikzset
{
block/.style=%
{%
ellipse, draw, fill=gray!20, text width=8em, text centered, rounded
corners, minimum height=4em, minimum width=4em
}
,line/.style={draw, -latex'}
% https://tex.stackexchange.com/a/138828/117050
,between/.style args={#1 and #2}{at=($(#1)!0.5!(#2)$)}
}
begin{document}
begin{tikzpicture}[node distance = 2cm, auto]
node [block] (A) {A};
node [block,right=of A] (B) {B};
node [block, above=of A] (C) {C};
node [block, above=of B] (D) {D};
node [block, between=A and B, yshift=-2.5cm] (E) {E};
node [block, right=of E] (F) {F};
node [block, right=of B] (G) {G};
node [block, right=of D] (H) {H};
% Draw edges
path [line] (C) edge["a"'] (A) ;
path [line] (D) edge["b"'] (B) ;
path [line] (A) -- (E);
path [line] (B) -- (E);
path [line] (F) -- (E);
path [line] (F) edge["g"'] (G) ;
path [line] (G) edge["h"'] (H);
end{tikzpicture}
end{document}
add a comment |
up vote
3
down vote
accepted
I added a minimal environment to your code so that I can work on it. You shouldn't use the right of=A
syntax but instead use right=of A
. I've also added a between
key to place E, note that below right=of A, below left=of B
will just result in below left=of B
the former being ignored. Also the ysep
and xsep
keys seem to not exist in current TikZ versions (mine is 3.0.1a).
documentclass[tikz]{standalone}
usetikzlibrary{arrows,quotes,positioning,shapes,calc}
tikzset
{
block/.style=%
{%
ellipse, draw, fill=gray!20, text width=8em, text centered, rounded
corners, minimum height=4em, minimum width=4em
}
,line/.style={draw, -latex'}
% https://tex.stackexchange.com/a/138828/117050
,between/.style args={#1 and #2}{at=($(#1)!0.5!(#2)$)}
}
begin{document}
begin{tikzpicture}[node distance = 2cm, auto]
node [block] (A) {A};
node [block,right=of A] (B) {B};
node [block, above=of A] (C) {C};
node [block, above=of B] (D) {D};
node [block, between=A and B, yshift=-2.5cm] (E) {E};
node [block, right=of E] (F) {F};
node [block, right=of B] (G) {G};
node [block, right=of D] (H) {H};
% Draw edges
path [line] (C) edge["a"'] (A) ;
path [line] (D) edge["b"'] (B) ;
path [line] (A) -- (E);
path [line] (B) -- (E);
path [line] (F) -- (E);
path [line] (F) edge["g"'] (G) ;
path [line] (G) edge["h"'] (H);
end{tikzpicture}
end{document}
add a comment |
up vote
3
down vote
accepted
up vote
3
down vote
accepted
I added a minimal environment to your code so that I can work on it. You shouldn't use the right of=A
syntax but instead use right=of A
. I've also added a between
key to place E, note that below right=of A, below left=of B
will just result in below left=of B
the former being ignored. Also the ysep
and xsep
keys seem to not exist in current TikZ versions (mine is 3.0.1a).
documentclass[tikz]{standalone}
usetikzlibrary{arrows,quotes,positioning,shapes,calc}
tikzset
{
block/.style=%
{%
ellipse, draw, fill=gray!20, text width=8em, text centered, rounded
corners, minimum height=4em, minimum width=4em
}
,line/.style={draw, -latex'}
% https://tex.stackexchange.com/a/138828/117050
,between/.style args={#1 and #2}{at=($(#1)!0.5!(#2)$)}
}
begin{document}
begin{tikzpicture}[node distance = 2cm, auto]
node [block] (A) {A};
node [block,right=of A] (B) {B};
node [block, above=of A] (C) {C};
node [block, above=of B] (D) {D};
node [block, between=A and B, yshift=-2.5cm] (E) {E};
node [block, right=of E] (F) {F};
node [block, right=of B] (G) {G};
node [block, right=of D] (H) {H};
% Draw edges
path [line] (C) edge["a"'] (A) ;
path [line] (D) edge["b"'] (B) ;
path [line] (A) -- (E);
path [line] (B) -- (E);
path [line] (F) -- (E);
path [line] (F) edge["g"'] (G) ;
path [line] (G) edge["h"'] (H);
end{tikzpicture}
end{document}
I added a minimal environment to your code so that I can work on it. You shouldn't use the right of=A
syntax but instead use right=of A
. I've also added a between
key to place E, note that below right=of A, below left=of B
will just result in below left=of B
the former being ignored. Also the ysep
and xsep
keys seem to not exist in current TikZ versions (mine is 3.0.1a).
documentclass[tikz]{standalone}
usetikzlibrary{arrows,quotes,positioning,shapes,calc}
tikzset
{
block/.style=%
{%
ellipse, draw, fill=gray!20, text width=8em, text centered, rounded
corners, minimum height=4em, minimum width=4em
}
,line/.style={draw, -latex'}
% https://tex.stackexchange.com/a/138828/117050
,between/.style args={#1 and #2}{at=($(#1)!0.5!(#2)$)}
}
begin{document}
begin{tikzpicture}[node distance = 2cm, auto]
node [block] (A) {A};
node [block,right=of A] (B) {B};
node [block, above=of A] (C) {C};
node [block, above=of B] (D) {D};
node [block, between=A and B, yshift=-2.5cm] (E) {E};
node [block, right=of E] (F) {F};
node [block, right=of B] (G) {G};
node [block, right=of D] (H) {H};
% Draw edges
path [line] (C) edge["a"'] (A) ;
path [line] (D) edge["b"'] (B) ;
path [line] (A) -- (E);
path [line] (B) -- (E);
path [line] (F) -- (E);
path [line] (F) edge["g"'] (G) ;
path [line] (G) edge["h"'] (H);
end{tikzpicture}
end{document}
answered yesterday
Skillmon
20.3k11840
20.3k11840
add a comment |
add a comment |
kanghj91 is a new contributor. Be nice, and check out our Code of Conduct.
kanghj91 is a new contributor. Be nice, and check out our Code of Conduct.
kanghj91 is a new contributor. Be nice, and check out our Code of Conduct.
kanghj91 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');
});
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%2f460704%2fincrease-spacing-between-nodes-in-tikzpicture%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
Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with
documentclass{...}
, the requiredusepackage
's,begin{document}
, andend{document}
. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem.– Skillmon
yesterday
Note that you need to load the
shapes
library to getellipse
to work.– Skillmon
yesterday