TeX - LaTeX Asked on July 8, 2021
I want these arrows to be parallel.
Why isn’t yshift working the same way on the start and end of the path?
Is there a better way to choose locations on the boxes? Is there an anchor for halfway up one edge of the box? What about the corners?
Thanks!!
documentclass{standalone}
usepackage{newtxtext}
usepackage{tikz}
usetikzlibrary{shapes,arrows}
begin{document}
tikzstyle{box} = [rectangle, draw, minimum height=6cm, text width=3cm, text centered, rounded corners]
tikzstyle{line} = [draw, -latex']
begin{tikzpicture}[node distance = 6em, auto]
node [box] (box-a) {BOX A};
node [box, right of=box-a, node distance=6cm] (box-b) {BOX B};
path [line] ([yshift=+5cm] box-a) -- node [midway, above] {Path 1 Above} node [midway, below] {Path 1 Below} ([yshift=+5cm] box-b);
path [line] ([yshift=-5cm] box-a) -- node [midway, above] {Path 2 Above} node [midway, below] {Path 2 Below} ([yshift=-5cm] box-b);
end{tikzpicture}
end{document}
Since the node is 6cm tall, add 5cm could be too much. Maybe is .5cm what you wish.
Is this what you want?
documentclass[border=1pt]{standalone}
usepackage{newtxtext}
usepackage{tikz}
usetikzlibrary{shapes,arrows}
begin{document}
tikzstyle{box} = [rectangle, draw, minimum height=6cm, text width=3cm, text centered, rounded corners]
tikzstyle{line} = [draw, -latex']
begin{tikzpicture}[node distance = 6em, auto]
node [box] (box-a) {BOX A};
node [box, right of=box-a, node distance=6cm] (box-b) {BOX B};
path [line] ([yshift=+.5cm] box-a.east) -- node [midway, above] {Path 1 Above} node [midway, below] {Path 1 Below} ([yshift=+.5cm] box-b.west);
path [line] ([yshift=-.5cm] box-a.east) -- node [midway, above] {Path 2 Above} node [midway, below] {Path 2 Below} ([yshift=-.5cm] box-b.west);
end{tikzpicture}
end{document}
Correct answer by Sigur on July 8, 2021
documentclass{standalone}
usepackage{newtxtext}
usepackage{tikz}
usetikzlibrary{shapes,arrows}
begin{document}
tikzstyle{box} = [rectangle, draw, minimum height=6cm, text width=3cm, text centered, rounded corners]
tikzstyle{line} = [draw, -latex']
begin{tikzpicture}[node distance = 6em, auto]
node [box] (box-a) {BOX A};
node [box, right of=box-a, node distance=6cm] (box-b) {BOX B};
foreach i in {0,30,45, 55, 60,90}{
path [line] (box-a.i) -- (box-b.180-i);
}
foreach i in {0,30,45, 55, 60,90}{
path [line] (box-a.-i) -- (box-b.180+i);
}
end{tikzpicture}
end{document}
Answered by js bibra on July 8, 2021
You can use an auxiliar coordinate and perpendicular (|-
, -|
) references to fix the end.
path [line] ([yshift=+5mm] box-a.east) coordinate (aux)--(aux-|box-b.west);
This is a path which starts at aux
and stops at the intersection place where an horizontal line through aux
and a vertical line through box-b.west
cross.
documentclass[border=2mm]{standalone}
usepackage{newtxtext}
usepackage{tikz}
usetikzlibrary{shapes,arrows}
begin{document}
tikzstyle{box} = [rectangle, draw, minimum height=6cm, text width=3cm, text centered, rounded corners]
tikzstyle{line} = [draw, -latex']
begin{tikzpicture}[node distance = 6em, auto]
node [box] (box-a) {BOX A};
node [box, right of=box-a, node distance=6cm] (box-b) {BOX B};
path [line] ([yshift=+5mm] box-a.east) coordinate (aux)-- node [midway, above] {Path 1 Above} node [midway, below] {Path 1 Below} (aux-|box-b.west);
path [line] ([yshift=-5mm] box-a.east) coordinate (aux) -- node [midway, above] {Path 2 Above} node [midway, below] {Path 2 Below} (aux-|box-b.west);
end{tikzpicture}
end{document}
Answered by Ignasi on July 8, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP