Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have the following tikz code

% compilation command: pdflatex --jobname=Diag-f1 Diag.tex
\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};

enter image description here

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.

share|improve this question

2 Answers 2

up vote 21 down vote accepted

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

share|improve this answer

I like the use of to paths.

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


        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{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);


enter image description here

share|improve this answer
very nice solution as well. Thanks –  pluton Dec 18 '12 at 15:38
thanks! This is a lifesaver, much easier. –  Jason S Apr 10 at 20:30
How do you make it work the other way? (drawing H to G), using the x-coordinate of H but the y-coordinate of G? –  Jason S Apr 10 at 20:32
@JasonS Are you interested in something like what my German answer on TeXwelt.de shows? The same code is used in my paths.ortho library (using files 1 and 2). –  Qrrbrbirlbel Apr 10 at 21:27
Hmm... not sure, still trying to understand what this code is doing + what I need. I essentially want a vertical (or horizontal) line between the given edges of shapes A and B, through a point C between them. (sometimes point C is an edge on shape A or B.) –  Jason S Apr 10 at 22:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.