How to fix a colliding arrow between two labelled box












1















Hi everyone and thanks for reading my post.



In a TikZ drawing, I have two boxes defined one above the other with node[draw] type command. I also added boxed labels above each. The problem is that when drawing an arrow between the two boxes, only the coordinates of the basic box is considered, so the arrow croses the labels instead of stopping just before it.



I understand why TikZ does that, but how could I fix it? I tried to point to a (A2.label) node but it appears that it does not exist...



Below is my minimum working example and what it gives for now. Thank you for your help!



documentclass[10pt]{standalone}
usepackage[english]{babel}

usepackage{tikz}
usetikzlibrary{positioning}

begin{document}
begin{tikzpicture}

% BOX 1
node[draw,text width=7cm,
label={[text width=7cm,fill=black!10,draw,minimum height=12pt]{bfseries box 1}}
] (A1) at (0,0) {
some text for box 1
} ;

% BOX 2
node[draw,text width=5cm,
label={[text width=5cm,fill=black!10,draw,minimum height=12pt]{bfseries box 2}}
] (A2) [below of=A1,yshift=-4cm] {
some other text for box 2
} ;

% ARROW
draw[->,>=latex] (A1) -- node[right] {test} (A2) ;


end{tikzpicture}
end{document}


result with colliding arrow










share|improve this question



























    1















    Hi everyone and thanks for reading my post.



    In a TikZ drawing, I have two boxes defined one above the other with node[draw] type command. I also added boxed labels above each. The problem is that when drawing an arrow between the two boxes, only the coordinates of the basic box is considered, so the arrow croses the labels instead of stopping just before it.



    I understand why TikZ does that, but how could I fix it? I tried to point to a (A2.label) node but it appears that it does not exist...



    Below is my minimum working example and what it gives for now. Thank you for your help!



    documentclass[10pt]{standalone}
    usepackage[english]{babel}

    usepackage{tikz}
    usetikzlibrary{positioning}

    begin{document}
    begin{tikzpicture}

    % BOX 1
    node[draw,text width=7cm,
    label={[text width=7cm,fill=black!10,draw,minimum height=12pt]{bfseries box 1}}
    ] (A1) at (0,0) {
    some text for box 1
    } ;

    % BOX 2
    node[draw,text width=5cm,
    label={[text width=5cm,fill=black!10,draw,minimum height=12pt]{bfseries box 2}}
    ] (A2) [below of=A1,yshift=-4cm] {
    some other text for box 2
    } ;

    % ARROW
    draw[->,>=latex] (A1) -- node[right] {test} (A2) ;


    end{tikzpicture}
    end{document}


    result with colliding arrow










    share|improve this question

























      1












      1








      1








      Hi everyone and thanks for reading my post.



      In a TikZ drawing, I have two boxes defined one above the other with node[draw] type command. I also added boxed labels above each. The problem is that when drawing an arrow between the two boxes, only the coordinates of the basic box is considered, so the arrow croses the labels instead of stopping just before it.



      I understand why TikZ does that, but how could I fix it? I tried to point to a (A2.label) node but it appears that it does not exist...



      Below is my minimum working example and what it gives for now. Thank you for your help!



      documentclass[10pt]{standalone}
      usepackage[english]{babel}

      usepackage{tikz}
      usetikzlibrary{positioning}

      begin{document}
      begin{tikzpicture}

      % BOX 1
      node[draw,text width=7cm,
      label={[text width=7cm,fill=black!10,draw,minimum height=12pt]{bfseries box 1}}
      ] (A1) at (0,0) {
      some text for box 1
      } ;

      % BOX 2
      node[draw,text width=5cm,
      label={[text width=5cm,fill=black!10,draw,minimum height=12pt]{bfseries box 2}}
      ] (A2) [below of=A1,yshift=-4cm] {
      some other text for box 2
      } ;

      % ARROW
      draw[->,>=latex] (A1) -- node[right] {test} (A2) ;


      end{tikzpicture}
      end{document}


      result with colliding arrow










      share|improve this question














      Hi everyone and thanks for reading my post.



      In a TikZ drawing, I have two boxes defined one above the other with node[draw] type command. I also added boxed labels above each. The problem is that when drawing an arrow between the two boxes, only the coordinates of the basic box is considered, so the arrow croses the labels instead of stopping just before it.



      I understand why TikZ does that, but how could I fix it? I tried to point to a (A2.label) node but it appears that it does not exist...



      Below is my minimum working example and what it gives for now. Thank you for your help!



      documentclass[10pt]{standalone}
      usepackage[english]{babel}

      usepackage{tikz}
      usetikzlibrary{positioning}

      begin{document}
      begin{tikzpicture}

      % BOX 1
      node[draw,text width=7cm,
      label={[text width=7cm,fill=black!10,draw,minimum height=12pt]{bfseries box 1}}
      ] (A1) at (0,0) {
      some text for box 1
      } ;

      % BOX 2
      node[draw,text width=5cm,
      label={[text width=5cm,fill=black!10,draw,minimum height=12pt]{bfseries box 2}}
      ] (A2) [below of=A1,yshift=-4cm] {
      some other text for box 2
      } ;

      % ARROW
      draw[->,>=latex] (A1) -- node[right] {test} (A2) ;


      end{tikzpicture}
      end{document}


      result with colliding arrow







      tikz-arrows draw






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 4 hours ago









      jeannejjeannej

      1449




      1449






















          1 Answer
          1






          active

          oldest

          votes


















          1














          A label is a node, too. So one possibility is to give it a name or alias, and draw the arrow to the label node.



          documentclass[10pt]{standalone}
          usepackage[english]{babel}

          usepackage{tikz}
          usetikzlibrary{positioning}

          begin{document}
          begin{tikzpicture}

          % BOX 1
          node[draw,text width=7cm,
          label={[text width=7cm,fill=black!10,draw,minimum height=12pt]{bfseries box 1}}
          ] (A1) at (0,0) {
          some text for box 1
          } ;

          % BOX 2
          node[draw,text width=5cm,
          label={[text width=5cm,fill=black!10,draw,minimum
          height=12pt,alias=stop here]{bfseries box 2}}
          ] (A2) [below of=A1,yshift=-4cm] {
          some other text for box 2
          } ;

          % ARROW
          draw[->,>=latex] (A1) -- node[right] {test} (stop here) ;


          end{tikzpicture}
          end{document}


          enter image description here



          Another way to achieve this output is to build a compound of A2 and the label node using the fit library.



          documentclass[10pt]{standalone}
          usepackage[english]{babel}

          usepackage{tikz}
          usetikzlibrary{positioning,fit}

          begin{document}
          begin{tikzpicture}

          % BOX 1
          node[draw,text width=7cm,
          label={[text width=7cm,fill=black!10,draw,minimum height=12pt]{bfseries box 1}}
          ] (A1) at (0,0) {
          some text for box 1
          } ;

          % BOX 2
          node[draw,text width=5cm,
          label={[text width=5cm,fill=black!10,draw,minimum
          height=12pt,alias=include me]{bfseries box 2}}
          ] (A2) [below of=A1,yshift=-4cm] {
          some other text for box 2
          } ;
          node[inner sep=0pt,fit=(A2) (include me)] (A2compound){};
          % ARROW
          draw[->,>=latex] (A1) -- node[right] {test} (A2compound) ;


          end{tikzpicture}
          end{document}





          share|improve this answer
























          • perfect, I didn't know about the alias thing, very handy! Thanks a lot :)

            – jeannej
            3 hours ago











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


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f480594%2fhow-to-fix-a-colliding-arrow-between-two-labelled-box%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









          1














          A label is a node, too. So one possibility is to give it a name or alias, and draw the arrow to the label node.



          documentclass[10pt]{standalone}
          usepackage[english]{babel}

          usepackage{tikz}
          usetikzlibrary{positioning}

          begin{document}
          begin{tikzpicture}

          % BOX 1
          node[draw,text width=7cm,
          label={[text width=7cm,fill=black!10,draw,minimum height=12pt]{bfseries box 1}}
          ] (A1) at (0,0) {
          some text for box 1
          } ;

          % BOX 2
          node[draw,text width=5cm,
          label={[text width=5cm,fill=black!10,draw,minimum
          height=12pt,alias=stop here]{bfseries box 2}}
          ] (A2) [below of=A1,yshift=-4cm] {
          some other text for box 2
          } ;

          % ARROW
          draw[->,>=latex] (A1) -- node[right] {test} (stop here) ;


          end{tikzpicture}
          end{document}


          enter image description here



          Another way to achieve this output is to build a compound of A2 and the label node using the fit library.



          documentclass[10pt]{standalone}
          usepackage[english]{babel}

          usepackage{tikz}
          usetikzlibrary{positioning,fit}

          begin{document}
          begin{tikzpicture}

          % BOX 1
          node[draw,text width=7cm,
          label={[text width=7cm,fill=black!10,draw,minimum height=12pt]{bfseries box 1}}
          ] (A1) at (0,0) {
          some text for box 1
          } ;

          % BOX 2
          node[draw,text width=5cm,
          label={[text width=5cm,fill=black!10,draw,minimum
          height=12pt,alias=include me]{bfseries box 2}}
          ] (A2) [below of=A1,yshift=-4cm] {
          some other text for box 2
          } ;
          node[inner sep=0pt,fit=(A2) (include me)] (A2compound){};
          % ARROW
          draw[->,>=latex] (A1) -- node[right] {test} (A2compound) ;


          end{tikzpicture}
          end{document}





          share|improve this answer
























          • perfect, I didn't know about the alias thing, very handy! Thanks a lot :)

            – jeannej
            3 hours ago
















          1














          A label is a node, too. So one possibility is to give it a name or alias, and draw the arrow to the label node.



          documentclass[10pt]{standalone}
          usepackage[english]{babel}

          usepackage{tikz}
          usetikzlibrary{positioning}

          begin{document}
          begin{tikzpicture}

          % BOX 1
          node[draw,text width=7cm,
          label={[text width=7cm,fill=black!10,draw,minimum height=12pt]{bfseries box 1}}
          ] (A1) at (0,0) {
          some text for box 1
          } ;

          % BOX 2
          node[draw,text width=5cm,
          label={[text width=5cm,fill=black!10,draw,minimum
          height=12pt,alias=stop here]{bfseries box 2}}
          ] (A2) [below of=A1,yshift=-4cm] {
          some other text for box 2
          } ;

          % ARROW
          draw[->,>=latex] (A1) -- node[right] {test} (stop here) ;


          end{tikzpicture}
          end{document}


          enter image description here



          Another way to achieve this output is to build a compound of A2 and the label node using the fit library.



          documentclass[10pt]{standalone}
          usepackage[english]{babel}

          usepackage{tikz}
          usetikzlibrary{positioning,fit}

          begin{document}
          begin{tikzpicture}

          % BOX 1
          node[draw,text width=7cm,
          label={[text width=7cm,fill=black!10,draw,minimum height=12pt]{bfseries box 1}}
          ] (A1) at (0,0) {
          some text for box 1
          } ;

          % BOX 2
          node[draw,text width=5cm,
          label={[text width=5cm,fill=black!10,draw,minimum
          height=12pt,alias=include me]{bfseries box 2}}
          ] (A2) [below of=A1,yshift=-4cm] {
          some other text for box 2
          } ;
          node[inner sep=0pt,fit=(A2) (include me)] (A2compound){};
          % ARROW
          draw[->,>=latex] (A1) -- node[right] {test} (A2compound) ;


          end{tikzpicture}
          end{document}





          share|improve this answer
























          • perfect, I didn't know about the alias thing, very handy! Thanks a lot :)

            – jeannej
            3 hours ago














          1












          1








          1







          A label is a node, too. So one possibility is to give it a name or alias, and draw the arrow to the label node.



          documentclass[10pt]{standalone}
          usepackage[english]{babel}

          usepackage{tikz}
          usetikzlibrary{positioning}

          begin{document}
          begin{tikzpicture}

          % BOX 1
          node[draw,text width=7cm,
          label={[text width=7cm,fill=black!10,draw,minimum height=12pt]{bfseries box 1}}
          ] (A1) at (0,0) {
          some text for box 1
          } ;

          % BOX 2
          node[draw,text width=5cm,
          label={[text width=5cm,fill=black!10,draw,minimum
          height=12pt,alias=stop here]{bfseries box 2}}
          ] (A2) [below of=A1,yshift=-4cm] {
          some other text for box 2
          } ;

          % ARROW
          draw[->,>=latex] (A1) -- node[right] {test} (stop here) ;


          end{tikzpicture}
          end{document}


          enter image description here



          Another way to achieve this output is to build a compound of A2 and the label node using the fit library.



          documentclass[10pt]{standalone}
          usepackage[english]{babel}

          usepackage{tikz}
          usetikzlibrary{positioning,fit}

          begin{document}
          begin{tikzpicture}

          % BOX 1
          node[draw,text width=7cm,
          label={[text width=7cm,fill=black!10,draw,minimum height=12pt]{bfseries box 1}}
          ] (A1) at (0,0) {
          some text for box 1
          } ;

          % BOX 2
          node[draw,text width=5cm,
          label={[text width=5cm,fill=black!10,draw,minimum
          height=12pt,alias=include me]{bfseries box 2}}
          ] (A2) [below of=A1,yshift=-4cm] {
          some other text for box 2
          } ;
          node[inner sep=0pt,fit=(A2) (include me)] (A2compound){};
          % ARROW
          draw[->,>=latex] (A1) -- node[right] {test} (A2compound) ;


          end{tikzpicture}
          end{document}





          share|improve this answer













          A label is a node, too. So one possibility is to give it a name or alias, and draw the arrow to the label node.



          documentclass[10pt]{standalone}
          usepackage[english]{babel}

          usepackage{tikz}
          usetikzlibrary{positioning}

          begin{document}
          begin{tikzpicture}

          % BOX 1
          node[draw,text width=7cm,
          label={[text width=7cm,fill=black!10,draw,minimum height=12pt]{bfseries box 1}}
          ] (A1) at (0,0) {
          some text for box 1
          } ;

          % BOX 2
          node[draw,text width=5cm,
          label={[text width=5cm,fill=black!10,draw,minimum
          height=12pt,alias=stop here]{bfseries box 2}}
          ] (A2) [below of=A1,yshift=-4cm] {
          some other text for box 2
          } ;

          % ARROW
          draw[->,>=latex] (A1) -- node[right] {test} (stop here) ;


          end{tikzpicture}
          end{document}


          enter image description here



          Another way to achieve this output is to build a compound of A2 and the label node using the fit library.



          documentclass[10pt]{standalone}
          usepackage[english]{babel}

          usepackage{tikz}
          usetikzlibrary{positioning,fit}

          begin{document}
          begin{tikzpicture}

          % BOX 1
          node[draw,text width=7cm,
          label={[text width=7cm,fill=black!10,draw,minimum height=12pt]{bfseries box 1}}
          ] (A1) at (0,0) {
          some text for box 1
          } ;

          % BOX 2
          node[draw,text width=5cm,
          label={[text width=5cm,fill=black!10,draw,minimum
          height=12pt,alias=include me]{bfseries box 2}}
          ] (A2) [below of=A1,yshift=-4cm] {
          some other text for box 2
          } ;
          node[inner sep=0pt,fit=(A2) (include me)] (A2compound){};
          % ARROW
          draw[->,>=latex] (A1) -- node[right] {test} (A2compound) ;


          end{tikzpicture}
          end{document}






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 3 hours ago









          marmotmarmot

          110k5136255




          110k5136255













          • perfect, I didn't know about the alias thing, very handy! Thanks a lot :)

            – jeannej
            3 hours ago



















          • perfect, I didn't know about the alias thing, very handy! Thanks a lot :)

            – jeannej
            3 hours ago

















          perfect, I didn't know about the alias thing, very handy! Thanks a lot :)

          – jeannej
          3 hours ago





          perfect, I didn't know about the alias thing, very handy! Thanks a lot :)

          – jeannej
          3 hours ago


















          draft saved

          draft discarded




















































          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.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f480594%2fhow-to-fix-a-colliding-arrow-between-two-labelled-box%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

          Contact image not getting when fetch all contact list from iPhone by CNContact

          count number of partitions of a set with n elements into k subsets

          A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks