In the following example, I'd like to move the dotted vertical lines to the (horizontal) center of the arrows connecting the lower elements. For example, the right dotted line should be centered with regard to the arrow connecting l2
and l3
. The best I could do is centering it between the nodes l2
and l3
, which looks bad since the arrows are of different length.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,arrows}
\begin{document}
\begin{tikzpicture}[x=2cm, every path/.style={>=latex'}]
\node (h1) at (.5, 1) {$\{S1,S2\}$};
\node (h2) at (2, 1) {$\{S4\}$};
\node (l1) at (0, 0) {$\{S5, S6\}$};
\node (l2) at (1, 0) {$\{S5, S7\}$};
\node (l3) at (2, 0) {$\{S4\}$};
\draw[->] (-.75, 1) -- (h1);
\draw[->] (h1) -- (h2);
\draw[->] (-.75, 0) -- (l1);
\draw[->] (l1) -- (l2);
\draw[->] (l2) -- (l3);
\draw[dotted] ($ (l2) !.5! (l3) $) to ++(90:1);
\draw[dotted] ($ (-.75,0) !.5! (l1) $) to ++(90:1);
\end{tikzpicture}
\end{document}
Best Answer
In the example you give, the line is drawn at the midpoint between the centers of nodes
l2
andl3
. One solution is to add a coordinate at the midpoint of the lower line betweenl2
andl3
, call itl4
gives me a line halfway along the arrow between![enter image description here](https://i.stack.imgur.com/xclk3.png)
{S5,S7}
and{S4}
.