Increase spacing between nodes in tikzpicture











up vote
1
down vote

favorite












enter image description here



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










share|improve this question









New contributor




kanghj91 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 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










  • Note that you need to load the shapes library to get ellipse to work.
    – Skillmon
    yesterday















up vote
1
down vote

favorite












enter image description here



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










share|improve this question









New contributor




kanghj91 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 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










  • Note that you need to load the shapes library to get ellipse to work.
    – Skillmon
    yesterday













up vote
1
down vote

favorite









up vote
1
down vote

favorite











enter image description here



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










share|improve this question









New contributor




kanghj91 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











enter image description here



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






share|improve this question









New contributor




kanghj91 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




kanghj91 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited yesterday





















New contributor




kanghj91 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked yesterday









kanghj91

84




84




New contributor




kanghj91 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





kanghj91 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






kanghj91 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 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










  • Note that you need to load the shapes library to get ellipse to work.
    – Skillmon
    yesterday














  • 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










  • Note that you need to load the shapes library to get ellipse 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










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}


enter image description here






share|improve this answer





















    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',
    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
    });


    }
    });






    kanghj91 is a new contributor. Be nice, and check out our Code of Conduct.










     

    draft saved


    draft discarded


















    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

























    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}


    enter image description here






    share|improve this answer

























      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}


      enter image description here






      share|improve this answer























        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}


        enter image description here






        share|improve this answer












        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}


        enter image description here







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered yesterday









        Skillmon

        20.3k11840




        20.3k11840






















            kanghj91 is a new contributor. Be nice, and check out our Code of Conduct.










             

            draft saved


            draft discarded


















            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.















             


            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Accessing regular linux commands in Huawei's Dopra Linux

            Can't connect RFCOMM socket: Host is down

            Kernel panic - not syncing: Fatal Exception in Interrupt