# Tikz: purely vertical arrow from nodeA.south to nodeB.north

I have the following tikz code

% compilation command: pdflatex --jobname=Diag-f1 Diag.tex
\documentclass{book}
\usepackage{tikz}
\pgfrealjobname{Diag}
\begin{document}
\beginpgfgraphicnamed{Diag-f1}
\begin{tikzpicture}[node distance=3em]
\node(G)[rectangle,fill=red!5,draw=red,text width=5cm]{};
\node(H)[below of=G]{H};
\node(H1)[left of=H]{H1};
\node(H2)[right of=H]{H2};
\draw[->](G.south)-|(H1.north);
\draw[->](G.south)--(H.north);
\draw[->](G.south)-|(H2.north);
\end{tikzpicture}
\endpgfgraphicnamed
\end{document}


but I am not happy with the two arrows going from G.south to H1.north and H2.north. Because of the -| command, there is a spurious horizontal line. How can I achieve the same result without this annoying horizontal line? \draw[->](G.south)--(H1.north); is not a solution. There are available tricks but I may have missed an obvious solution here.

-

The line is normal: -| means: draw an horizontal line, then a vertical.

You could use this:

\draw[->] (G.south -| H1.north) -- (H1.north)


That will compute the intersection between a vertical line through H1.north and a horizontal one through G.south, and then draw a line from it to H1.north

-

I like the use of to paths.

Advantage: The target coordinate/node has only to be given once.

## Code

\documentclass[tikz]{standalone}
\tikzset{
-|/.style={
to path={
(perpendicular cs: horizontal line through={(\tikztostart)},
vertical line through={(\tikztotarget)})
% is the same as (\tikztostart -| \tikztotarget)
% but just to be safe: http://tex.stackexchange.com/a/29781/16595
-- (\tikztotarget) \tikztonodes
}
}
}
\begin{document}
\begin{tikzpicture}[node distance=3em]
\node(G)  [rectangle,fill=red!5,draw=red,text width=5cm] {};
\node(H)  [below of=G] {H};
\node(H1) [left of=H]  {H1};
\node(H2) [right of=H] {H2};
\draw[->,-|] (G.south) to     (H1.north);
\draw[->]    (G.south) --     (H.north);
\draw[->]    (G.south) to[-|] (H2.north);
\end{tikzpicture}
\end{document}


## Output

-
very nice solution as well. Thanks –  pluton Dec 18 '12 at 15:38