Precise placement of arrow anchors
up vote
6
down vote
favorite
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}
begin{document}
begin{tikzpicture}
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);
end{tikzpicture}
end{document}
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
add a comment |
up vote
6
down vote
favorite
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}
begin{document}
begin{tikzpicture}
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);
end{tikzpicture}
end{document}
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
add a comment |
up vote
6
down vote
favorite
up vote
6
down vote
favorite
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}
begin{document}
begin{tikzpicture}
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);
end{tikzpicture}
end{document}
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
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}
begin{document}
begin{tikzpicture}
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);
end{tikzpicture}
end{document}
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
tikz-pgf alignment
edited Nov 14 at 15:24
asked Nov 14 at 14:29
Uli Fahrenberg
975
975
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
4
down vote
accepted
Or, if you want the arrow to be in the center,
documentclass[tikz]{standalone}
begin{document}
begin{tikzpicture}
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);
end{tikzpicture}
end{document}
You guys are amazing: this is precisely what I wanted.
– Uli Fahrenberg
Nov 14 at 15:11
+1: What is theaux
node for?
– Dr. Manuel Kuehner
Nov 14 at 15:19
1
@Dr.ManuelKuehner It is midway between a and b and placed solely for calculation.
– TeXnician
Nov 14 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 at 15:20
2
@Dr.ManuelKuehner I guess the best explanation for what|-
and-|
do can be found here.
– marmot
Nov 14 at 15:25
|
show 2 more comments
up vote
6
down vote
You can specify the horizontal and vertical position in terms of nodes.
documentclass[tikz]{standalone}
begin{document}
begin{tikzpicture}
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);
end{tikzpicture}
end{document}
Nice (+1)... I think that the OP woyld like to useanchor=east
too in order to not calculating manually the horizontal alignment. So,documentclass[tikz]{standalone} begin{document} tikzset{mynode/.style={rectangle,draw,anchor=east}} begin{tikzpicture} node[mynode] (a) at (0,0) {Some rather long text}; node[mynode] (b) at (0,-2) {Even more text}; draw[->] (b|-a.south) -- (b); end{tikzpicture} end{document}
would be an easier way.
– koleygr
Nov 14 at 14:58
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
accepted
Or, if you want the arrow to be in the center,
documentclass[tikz]{standalone}
begin{document}
begin{tikzpicture}
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);
end{tikzpicture}
end{document}
You guys are amazing: this is precisely what I wanted.
– Uli Fahrenberg
Nov 14 at 15:11
+1: What is theaux
node for?
– Dr. Manuel Kuehner
Nov 14 at 15:19
1
@Dr.ManuelKuehner It is midway between a and b and placed solely for calculation.
– TeXnician
Nov 14 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 at 15:20
2
@Dr.ManuelKuehner I guess the best explanation for what|-
and-|
do can be found here.
– marmot
Nov 14 at 15:25
|
show 2 more comments
up vote
4
down vote
accepted
Or, if you want the arrow to be in the center,
documentclass[tikz]{standalone}
begin{document}
begin{tikzpicture}
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);
end{tikzpicture}
end{document}
You guys are amazing: this is precisely what I wanted.
– Uli Fahrenberg
Nov 14 at 15:11
+1: What is theaux
node for?
– Dr. Manuel Kuehner
Nov 14 at 15:19
1
@Dr.ManuelKuehner It is midway between a and b and placed solely for calculation.
– TeXnician
Nov 14 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 at 15:20
2
@Dr.ManuelKuehner I guess the best explanation for what|-
and-|
do can be found here.
– marmot
Nov 14 at 15:25
|
show 2 more comments
up vote
4
down vote
accepted
up vote
4
down vote
accepted
Or, if you want the arrow to be in the center,
documentclass[tikz]{standalone}
begin{document}
begin{tikzpicture}
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);
end{tikzpicture}
end{document}
Or, if you want the arrow to be in the center,
documentclass[tikz]{standalone}
begin{document}
begin{tikzpicture}
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);
end{tikzpicture}
end{document}
answered Nov 14 at 14:40
marmot
76.7k487161
76.7k487161
You guys are amazing: this is precisely what I wanted.
– Uli Fahrenberg
Nov 14 at 15:11
+1: What is theaux
node for?
– Dr. Manuel Kuehner
Nov 14 at 15:19
1
@Dr.ManuelKuehner It is midway between a and b and placed solely for calculation.
– TeXnician
Nov 14 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 at 15:20
2
@Dr.ManuelKuehner I guess the best explanation for what|-
and-|
do can be found here.
– marmot
Nov 14 at 15:25
|
show 2 more comments
You guys are amazing: this is precisely what I wanted.
– Uli Fahrenberg
Nov 14 at 15:11
+1: What is theaux
node for?
– Dr. Manuel Kuehner
Nov 14 at 15:19
1
@Dr.ManuelKuehner It is midway between a and b and placed solely for calculation.
– TeXnician
Nov 14 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 at 15:20
2
@Dr.ManuelKuehner I guess the best explanation for what|-
and-|
do can be found here.
– marmot
Nov 14 at 15:25
You guys are amazing: this is precisely what I wanted.
– Uli Fahrenberg
Nov 14 at 15:11
You guys are amazing: this is precisely what I wanted.
– Uli Fahrenberg
Nov 14 at 15:11
+1: What is the
aux
node for?– Dr. Manuel Kuehner
Nov 14 at 15:19
+1: What is the
aux
node for?– Dr. Manuel Kuehner
Nov 14 at 15:19
1
1
@Dr.ManuelKuehner It is midway between a and b and placed solely for calculation.
– TeXnician
Nov 14 at 15:19
@Dr.ManuelKuehner It is midway between a and b and placed solely for calculation.
– TeXnician
Nov 14 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 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 at 15:20
2
2
@Dr.ManuelKuehner I guess the best explanation for what
|-
and -|
do can be found here.– marmot
Nov 14 at 15:25
@Dr.ManuelKuehner I guess the best explanation for what
|-
and -|
do can be found here.– marmot
Nov 14 at 15:25
|
show 2 more comments
up vote
6
down vote
You can specify the horizontal and vertical position in terms of nodes.
documentclass[tikz]{standalone}
begin{document}
begin{tikzpicture}
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);
end{tikzpicture}
end{document}
Nice (+1)... I think that the OP woyld like to useanchor=east
too in order to not calculating manually the horizontal alignment. So,documentclass[tikz]{standalone} begin{document} tikzset{mynode/.style={rectangle,draw,anchor=east}} begin{tikzpicture} node[mynode] (a) at (0,0) {Some rather long text}; node[mynode] (b) at (0,-2) {Even more text}; draw[->] (b|-a.south) -- (b); end{tikzpicture} end{document}
would be an easier way.
– koleygr
Nov 14 at 14:58
add a comment |
up vote
6
down vote
You can specify the horizontal and vertical position in terms of nodes.
documentclass[tikz]{standalone}
begin{document}
begin{tikzpicture}
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);
end{tikzpicture}
end{document}
Nice (+1)... I think that the OP woyld like to useanchor=east
too in order to not calculating manually the horizontal alignment. So,documentclass[tikz]{standalone} begin{document} tikzset{mynode/.style={rectangle,draw,anchor=east}} begin{tikzpicture} node[mynode] (a) at (0,0) {Some rather long text}; node[mynode] (b) at (0,-2) {Even more text}; draw[->] (b|-a.south) -- (b); end{tikzpicture} end{document}
would be an easier way.
– koleygr
Nov 14 at 14:58
add a comment |
up vote
6
down vote
up vote
6
down vote
You can specify the horizontal and vertical position in terms of nodes.
documentclass[tikz]{standalone}
begin{document}
begin{tikzpicture}
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);
end{tikzpicture}
end{document}
You can specify the horizontal and vertical position in terms of nodes.
documentclass[tikz]{standalone}
begin{document}
begin{tikzpicture}
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);
end{tikzpicture}
end{document}
answered Nov 14 at 14:38
TeXnician
23.4k62984
23.4k62984
Nice (+1)... I think that the OP woyld like to useanchor=east
too in order to not calculating manually the horizontal alignment. So,documentclass[tikz]{standalone} begin{document} tikzset{mynode/.style={rectangle,draw,anchor=east}} begin{tikzpicture} node[mynode] (a) at (0,0) {Some rather long text}; node[mynode] (b) at (0,-2) {Even more text}; draw[->] (b|-a.south) -- (b); end{tikzpicture} end{document}
would be an easier way.
– koleygr
Nov 14 at 14:58
add a comment |
Nice (+1)... I think that the OP woyld like to useanchor=east
too in order to not calculating manually the horizontal alignment. So,documentclass[tikz]{standalone} begin{document} tikzset{mynode/.style={rectangle,draw,anchor=east}} begin{tikzpicture} node[mynode] (a) at (0,0) {Some rather long text}; node[mynode] (b) at (0,-2) {Even more text}; draw[->] (b|-a.south) -- (b); end{tikzpicture} end{document}
would be an easier way.
– koleygr
Nov 14 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} begin{document} tikzset{mynode/.style={rectangle,draw,anchor=east}} begin{tikzpicture} node[mynode] (a) at (0,0) {Some rather long text}; node[mynode] (b) at (0,-2) {Even more text}; draw[->] (b|-a.south) -- (b); end{tikzpicture} end{document}
would be an easier way.– koleygr
Nov 14 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} begin{document} tikzset{mynode/.style={rectangle,draw,anchor=east}} begin{tikzpicture} node[mynode] (a) at (0,0) {Some rather long text}; node[mynode] (b) at (0,-2) {Even more text}; draw[->] (b|-a.south) -- (b); end{tikzpicture} end{document}
would be an easier way.– koleygr
Nov 14 at 14:58
add a comment |
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%2f459954%2fprecise-placement-of-arrow-anchors%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