Precise placement of arrow anchors










6















I have a (TikZ) diagram with several "blocks" of text connected by arrows. For reasons the (centers of the) blocks are not precisely horizontally aligned, but I'd still like my vertical arrows to be perfectly, well, vertical. Example:



documentclass[tikz]standalone
begindocument
begintikzpicture
node[rectangle, draw] (a) at (0,0) Some rather long text;
node[rectangle, draw] (b) at (.5,-2) Even more text;
path[->] (a) edge (b);
path[red, ->] (a.315) edge (b.130);
endtikzpicture
enddocument


MWE



Instead of the black arrow, I'd prefer the red one which I've created by fiddling around with stupid numbers. Hence:



Is there a way to create, automatically, instead of the black arrow-between-centers, an arrow which is (1) perfectly vertical and (2) intersects the original arrow roughly at its center?










share|improve this question




























    6















    I have a (TikZ) diagram with several "blocks" of text connected by arrows. For reasons the (centers of the) blocks are not precisely horizontally aligned, but I'd still like my vertical arrows to be perfectly, well, vertical. Example:



    documentclass[tikz]standalone
    begindocument
    begintikzpicture
    node[rectangle, draw] (a) at (0,0) Some rather long text;
    node[rectangle, draw] (b) at (.5,-2) Even more text;
    path[->] (a) edge (b);
    path[red, ->] (a.315) edge (b.130);
    endtikzpicture
    enddocument


    MWE



    Instead of the black arrow, I'd prefer the red one which I've created by fiddling around with stupid numbers. Hence:



    Is there a way to create, automatically, instead of the black arrow-between-centers, an arrow which is (1) perfectly vertical and (2) intersects the original arrow roughly at its center?










    share|improve this question


























      6












      6








      6








      I have a (TikZ) diagram with several "blocks" of text connected by arrows. For reasons the (centers of the) blocks are not precisely horizontally aligned, but I'd still like my vertical arrows to be perfectly, well, vertical. Example:



      documentclass[tikz]standalone
      begindocument
      begintikzpicture
      node[rectangle, draw] (a) at (0,0) Some rather long text;
      node[rectangle, draw] (b) at (.5,-2) Even more text;
      path[->] (a) edge (b);
      path[red, ->] (a.315) edge (b.130);
      endtikzpicture
      enddocument


      MWE



      Instead of the black arrow, I'd prefer the red one which I've created by fiddling around with stupid numbers. Hence:



      Is there a way to create, automatically, instead of the black arrow-between-centers, an arrow which is (1) perfectly vertical and (2) intersects the original arrow roughly at its center?










      share|improve this question
















      I have a (TikZ) diagram with several "blocks" of text connected by arrows. For reasons the (centers of the) blocks are not precisely horizontally aligned, but I'd still like my vertical arrows to be perfectly, well, vertical. Example:



      documentclass[tikz]standalone
      begindocument
      begintikzpicture
      node[rectangle, draw] (a) at (0,0) Some rather long text;
      node[rectangle, draw] (b) at (.5,-2) Even more text;
      path[->] (a) edge (b);
      path[red, ->] (a.315) edge (b.130);
      endtikzpicture
      enddocument


      MWE



      Instead of the black arrow, I'd prefer the red one which I've created by fiddling around with stupid numbers. Hence:



      Is there a way to create, automatically, instead of the black arrow-between-centers, an arrow which is (1) perfectly vertical and (2) intersects the original arrow roughly at its center?







      tikz-pgf alignment






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 14 '18 at 15:24







      Uli Fahrenberg

















      asked Nov 14 '18 at 14:29









      Uli FahrenbergUli Fahrenberg

      1025




      1025




















          2 Answers
          2






          active

          oldest

          votes


















          4














          Or, if you want the arrow to be in the center,



          documentclass[tikz]standalone
          begindocument
          begintikzpicture
          node[rectangle, draw] (a) at (0,0) Some rather long text;
          node[rectangle, draw] (b) at (.5,-2) Even more text;
          path (a) -- (b) coordinate[midway] (aux);
          draw[->] (a.south -| aux) -- (b.north -| aux);
          endtikzpicture
          enddocument


          enter image description here






          share|improve this answer























          • You guys are amazing: this is precisely what I wanted.

            – Uli Fahrenberg
            Nov 14 '18 at 15:11











          • +1: What is the aux node for?

            – Dr. Manuel Kuehner
            Nov 14 '18 at 15:19






          • 1





            @Dr.ManuelKuehner It is midway between a and b and placed solely for calculation.

            – TeXnician
            Nov 14 '18 at 15:19






          • 1





            @Dr.ManuelKuehner This is a trick to find out (what TikZ thinks is) the middle between the two nodes, which then will determine the horizontal position of the arrow.

            – marmot
            Nov 14 '18 at 15:20






          • 2





            @Dr.ManuelKuehner I guess the best explanation for what |- and -| do can be found here.

            – marmot
            Nov 14 '18 at 15:25


















          6














          You can specify the horizontal and vertical position in terms of nodes.



          vertical arrow



          documentclass[tikz]standalone
          begindocument
          begintikzpicture
          node[rectangle, draw] (a) at (0,0) Some rather long text;
          node[rectangle, draw] (b) at (.5,-2) Even more text;
          draw[->] (b|-a.south) -- (b);
          endtikzpicture
          enddocument





          share|improve this answer























          • Nice (+1)... I think that the OP woyld like to use anchor=east too in order to not calculating manually the horizontal alignment. So, documentclass[tikz]standalone begindocument tikzsetmynode/.style=rectangle,draw,anchor=east begintikzpicture node[mynode] (a) at (0,0) Some rather long text; node[mynode] (b) at (0,-2) Even more text; draw[->] (b|-a.south) -- (b); endtikzpicture enddocument would be an easier way.

            – koleygr
            Nov 14 '18 at 14:58










          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%2f459954%2fprecise-placement-of-arrow-anchors%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









          4














          Or, if you want the arrow to be in the center,



          documentclass[tikz]standalone
          begindocument
          begintikzpicture
          node[rectangle, draw] (a) at (0,0) Some rather long text;
          node[rectangle, draw] (b) at (.5,-2) Even more text;
          path (a) -- (b) coordinate[midway] (aux);
          draw[->] (a.south -| aux) -- (b.north -| aux);
          endtikzpicture
          enddocument


          enter image description here






          share|improve this answer























          • You guys are amazing: this is precisely what I wanted.

            – Uli Fahrenberg
            Nov 14 '18 at 15:11











          • +1: What is the aux node for?

            – Dr. Manuel Kuehner
            Nov 14 '18 at 15:19






          • 1





            @Dr.ManuelKuehner It is midway between a and b and placed solely for calculation.

            – TeXnician
            Nov 14 '18 at 15:19






          • 1





            @Dr.ManuelKuehner This is a trick to find out (what TikZ thinks is) the middle between the two nodes, which then will determine the horizontal position of the arrow.

            – marmot
            Nov 14 '18 at 15:20






          • 2





            @Dr.ManuelKuehner I guess the best explanation for what |- and -| do can be found here.

            – marmot
            Nov 14 '18 at 15:25















          4














          Or, if you want the arrow to be in the center,



          documentclass[tikz]standalone
          begindocument
          begintikzpicture
          node[rectangle, draw] (a) at (0,0) Some rather long text;
          node[rectangle, draw] (b) at (.5,-2) Even more text;
          path (a) -- (b) coordinate[midway] (aux);
          draw[->] (a.south -| aux) -- (b.north -| aux);
          endtikzpicture
          enddocument


          enter image description here






          share|improve this answer























          • You guys are amazing: this is precisely what I wanted.

            – Uli Fahrenberg
            Nov 14 '18 at 15:11











          • +1: What is the aux node for?

            – Dr. Manuel Kuehner
            Nov 14 '18 at 15:19






          • 1





            @Dr.ManuelKuehner It is midway between a and b and placed solely for calculation.

            – TeXnician
            Nov 14 '18 at 15:19






          • 1





            @Dr.ManuelKuehner This is a trick to find out (what TikZ thinks is) the middle between the two nodes, which then will determine the horizontal position of the arrow.

            – marmot
            Nov 14 '18 at 15:20






          • 2





            @Dr.ManuelKuehner I guess the best explanation for what |- and -| do can be found here.

            – marmot
            Nov 14 '18 at 15:25













          4












          4








          4







          Or, if you want the arrow to be in the center,



          documentclass[tikz]standalone
          begindocument
          begintikzpicture
          node[rectangle, draw] (a) at (0,0) Some rather long text;
          node[rectangle, draw] (b) at (.5,-2) Even more text;
          path (a) -- (b) coordinate[midway] (aux);
          draw[->] (a.south -| aux) -- (b.north -| aux);
          endtikzpicture
          enddocument


          enter image description here






          share|improve this answer













          Or, if you want the arrow to be in the center,



          documentclass[tikz]standalone
          begindocument
          begintikzpicture
          node[rectangle, draw] (a) at (0,0) Some rather long text;
          node[rectangle, draw] (b) at (.5,-2) Even more text;
          path (a) -- (b) coordinate[midway] (aux);
          draw[->] (a.south -| aux) -- (b.north -| aux);
          endtikzpicture
          enddocument


          enter image description here







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 14 '18 at 14:40









          marmotmarmot

          102k4119229




          102k4119229












          • You guys are amazing: this is precisely what I wanted.

            – Uli Fahrenberg
            Nov 14 '18 at 15:11











          • +1: What is the aux node for?

            – Dr. Manuel Kuehner
            Nov 14 '18 at 15:19






          • 1





            @Dr.ManuelKuehner It is midway between a and b and placed solely for calculation.

            – TeXnician
            Nov 14 '18 at 15:19






          • 1





            @Dr.ManuelKuehner This is a trick to find out (what TikZ thinks is) the middle between the two nodes, which then will determine the horizontal position of the arrow.

            – marmot
            Nov 14 '18 at 15:20






          • 2





            @Dr.ManuelKuehner I guess the best explanation for what |- and -| do can be found here.

            – marmot
            Nov 14 '18 at 15:25

















          • You guys are amazing: this is precisely what I wanted.

            – Uli Fahrenberg
            Nov 14 '18 at 15:11











          • +1: What is the aux node for?

            – Dr. Manuel Kuehner
            Nov 14 '18 at 15:19






          • 1





            @Dr.ManuelKuehner It is midway between a and b and placed solely for calculation.

            – TeXnician
            Nov 14 '18 at 15:19






          • 1





            @Dr.ManuelKuehner This is a trick to find out (what TikZ thinks is) the middle between the two nodes, which then will determine the horizontal position of the arrow.

            – marmot
            Nov 14 '18 at 15:20






          • 2





            @Dr.ManuelKuehner I guess the best explanation for what |- and -| do can be found here.

            – marmot
            Nov 14 '18 at 15:25
















          You guys are amazing: this is precisely what I wanted.

          – Uli Fahrenberg
          Nov 14 '18 at 15:11





          You guys are amazing: this is precisely what I wanted.

          – Uli Fahrenberg
          Nov 14 '18 at 15:11













          +1: What is the aux node for?

          – Dr. Manuel Kuehner
          Nov 14 '18 at 15:19





          +1: What is the aux node for?

          – Dr. Manuel Kuehner
          Nov 14 '18 at 15:19




          1




          1





          @Dr.ManuelKuehner It is midway between a and b and placed solely for calculation.

          – TeXnician
          Nov 14 '18 at 15:19





          @Dr.ManuelKuehner It is midway between a and b and placed solely for calculation.

          – TeXnician
          Nov 14 '18 at 15:19




          1




          1





          @Dr.ManuelKuehner This is a trick to find out (what TikZ thinks is) the middle between the two nodes, which then will determine the horizontal position of the arrow.

          – marmot
          Nov 14 '18 at 15:20





          @Dr.ManuelKuehner This is a trick to find out (what TikZ thinks is) the middle between the two nodes, which then will determine the horizontal position of the arrow.

          – marmot
          Nov 14 '18 at 15:20




          2




          2





          @Dr.ManuelKuehner I guess the best explanation for what |- and -| do can be found here.

          – marmot
          Nov 14 '18 at 15:25





          @Dr.ManuelKuehner I guess the best explanation for what |- and -| do can be found here.

          – marmot
          Nov 14 '18 at 15:25











          6














          You can specify the horizontal and vertical position in terms of nodes.



          vertical arrow



          documentclass[tikz]standalone
          begindocument
          begintikzpicture
          node[rectangle, draw] (a) at (0,0) Some rather long text;
          node[rectangle, draw] (b) at (.5,-2) Even more text;
          draw[->] (b|-a.south) -- (b);
          endtikzpicture
          enddocument





          share|improve this answer























          • Nice (+1)... I think that the OP woyld like to use anchor=east too in order to not calculating manually the horizontal alignment. So, documentclass[tikz]standalone begindocument tikzsetmynode/.style=rectangle,draw,anchor=east begintikzpicture node[mynode] (a) at (0,0) Some rather long text; node[mynode] (b) at (0,-2) Even more text; draw[->] (b|-a.south) -- (b); endtikzpicture enddocument would be an easier way.

            – koleygr
            Nov 14 '18 at 14:58















          6














          You can specify the horizontal and vertical position in terms of nodes.



          vertical arrow



          documentclass[tikz]standalone
          begindocument
          begintikzpicture
          node[rectangle, draw] (a) at (0,0) Some rather long text;
          node[rectangle, draw] (b) at (.5,-2) Even more text;
          draw[->] (b|-a.south) -- (b);
          endtikzpicture
          enddocument





          share|improve this answer























          • Nice (+1)... I think that the OP woyld like to use anchor=east too in order to not calculating manually the horizontal alignment. So, documentclass[tikz]standalone begindocument tikzsetmynode/.style=rectangle,draw,anchor=east begintikzpicture node[mynode] (a) at (0,0) Some rather long text; node[mynode] (b) at (0,-2) Even more text; draw[->] (b|-a.south) -- (b); endtikzpicture enddocument would be an easier way.

            – koleygr
            Nov 14 '18 at 14:58













          6












          6








          6







          You can specify the horizontal and vertical position in terms of nodes.



          vertical arrow



          documentclass[tikz]standalone
          begindocument
          begintikzpicture
          node[rectangle, draw] (a) at (0,0) Some rather long text;
          node[rectangle, draw] (b) at (.5,-2) Even more text;
          draw[->] (b|-a.south) -- (b);
          endtikzpicture
          enddocument





          share|improve this answer













          You can specify the horizontal and vertical position in terms of nodes.



          vertical arrow



          documentclass[tikz]standalone
          begindocument
          begintikzpicture
          node[rectangle, draw] (a) at (0,0) Some rather long text;
          node[rectangle, draw] (b) at (.5,-2) Even more text;
          draw[->] (b|-a.south) -- (b);
          endtikzpicture
          enddocument






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 14 '18 at 14:38









          TeXnicianTeXnician

          25.1k63389




          25.1k63389












          • Nice (+1)... I think that the OP woyld like to use anchor=east too in order to not calculating manually the horizontal alignment. So, documentclass[tikz]standalone begindocument tikzsetmynode/.style=rectangle,draw,anchor=east begintikzpicture node[mynode] (a) at (0,0) Some rather long text; node[mynode] (b) at (0,-2) Even more text; draw[->] (b|-a.south) -- (b); endtikzpicture enddocument would be an easier way.

            – koleygr
            Nov 14 '18 at 14:58

















          • Nice (+1)... I think that the OP woyld like to use anchor=east too in order to not calculating manually the horizontal alignment. So, documentclass[tikz]standalone begindocument tikzsetmynode/.style=rectangle,draw,anchor=east begintikzpicture node[mynode] (a) at (0,0) Some rather long text; node[mynode] (b) at (0,-2) Even more text; draw[->] (b|-a.south) -- (b); endtikzpicture enddocument would be an easier way.

            – koleygr
            Nov 14 '18 at 14:58
















          Nice (+1)... I think that the OP woyld like to use anchor=east too in order to not calculating manually the horizontal alignment. So, documentclass[tikz]standalone begindocument tikzsetmynode/.style=rectangle,draw,anchor=east begintikzpicture node[mynode] (a) at (0,0) Some rather long text; node[mynode] (b) at (0,-2) Even more text; draw[->] (b|-a.south) -- (b); endtikzpicture enddocument would be an easier way.

          – koleygr
          Nov 14 '18 at 14:58





          Nice (+1)... I think that the OP woyld like to use anchor=east too in order to not calculating manually the horizontal alignment. So, documentclass[tikz]standalone begindocument tikzsetmynode/.style=rectangle,draw,anchor=east begintikzpicture node[mynode] (a) at (0,0) Some rather long text; node[mynode] (b) at (0,-2) Even more text; draw[->] (b|-a.south) -- (b); endtikzpicture enddocument would be an easier way.

          – koleygr
          Nov 14 '18 at 14:58

















          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%2f459954%2fprecise-placement-of-arrow-anchors%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







          這個網誌中的熱門文章

          How to read a connectionString WITH PROVIDER in .NET Core?

          Node.js Script on GitHub Pages or Amazon S3

          Museum of Modern and Contemporary Art of Trento and Rovereto