4

I have a rectangle node and want to draw multiple arrows showing in one direction and have a fixed distance between each other.

The drawback of my current MWE is that the distances written in the foreach-statement are manually try and error as an equal distance between two values will not result in equal distance between the arrows:

\documentclass[tikz]{standalone}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\node[rectangle, draw](down){this is a very long test node};
\node[rectangle, draw, above of = down](up){this is a very long test node};
\foreach \x in {165,150, 90, 30, 15}
{\draw (down.\x) to ++ (0,.4);
}
\end{tikzpicture}
\end{document}

The picture looks as follows [this is wanted]:

enter image description here

Using a more automatic generated way like saying this pattern:

\foreach \x in {160, 150, 140, 130, 120, 110, 100, 90}
{\draw (down.\x) to ++ (0,.4);} 

This result in this one [not wanted]:

enter image description here

Is therre a better way to create arrow going from one nodeside in one direction or to use the postitionmarks of a node (160, 155, ...) 'better' without just try and error?

3
  • According to page 136, when you write (down.10) 10 is the measurement of an angle. Measured from the center of the node.
    – AndréC
    Sep 12, 2018 at 18:46
  • so there is no implemented way to call specific points at the node shape? let's say we 'unwrap' the node-edges and segment the line intervall-like marks from 0-100?
    – SRel
    Sep 12, 2018 at 18:50
  • It's something to write yourself as @marmot just did
    – AndréC
    Sep 12, 2018 at 18:55

2 Answers 2

6

One out of many possibilities. More fancy possibilities arise with the calc library.

\documentclass[tikz]{standalone}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\node[rectangle, draw](down){this is a very long test node};
\node[rectangle, draw, above of = down](up){this is a very long test node};
\foreach \x [count=\y] in {0.1,0.3,0.5,0.7,0.9}
{\path (down.north west) -- (down.north east) coordinate[pos=\x] (p\y);
\draw (p\y) to (up.south -| p\y);
}
\end{tikzpicture}
\end{document}

enter image description here

1
  • oh wow, i was never thinking of such an approach, great. i have never used calc before, will this will make the process much nicer or easier? However I think I will start using you idea
    – SRel
    Sep 12, 2018 at 18:47
2

Like marmot's solution but with calc library:

\documentclass[tikz]{standalone}
\usetikzlibrary{positioning, calc}
\begin{document}
\begin{tikzpicture}
\node[rectangle, draw](down){this is a very long test node};
\node[rectangle, draw, above of = down](up){this is a very long test node};
\foreach \x in {0.1,0.3,0.5,0.7,0.9}
\draw ($(up.south west)!\x!(up.south east)$) coordinate (aux) -- (aux|-down.north);
\end{tikzpicture}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .