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.

This question already has an answer here:

Assume there are two nodes A and B, with B below A. These nodes are of different width. Connecting A.south to B.north results in a slanted line. I wonder how I can connect A.south to B with the connection being vertical. I do not want to use A.south to, say, B.8 which results in a straight line however when the width of B changes the connection will not be straight anymore.

A MWE is as follows:

\documentclass[10pt]{article}

\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}

\tikzset{font=\Large,
every node/.style=
    {minimum height=8mm,
    draw=blue,
    very thick,
    },
data/.style = {draw, node distance=3cm}
    }

The line from A to B is vertical in the following example.


\begin{tikzpicture}
\node (a) {A};
\node[below right=of a] (c) {C};
\node[left=of c] (B) {BBBBBBBBBBBBBBBBBB};
\draw[->][very thick](a.south) -- (B.8);
\end{tikzpicture}

\medskip 

The line from A to B is not vertical in the following example.

\medskip

\begin{tikzpicture}
\node (a) {A};
\node[below right=of a] (c) {C};
\node[left=of c] (B) {BBBBBBBBBBBBBBBBBBBBB};
\draw[->][very thick](a.south) -- (B.8);
\end{tikzpicture}

\end{document}
share|improve this question

marked as duplicate by Qrrbrbirlbel, Xavier, Kurt, Claudio Fiandrino, Andrew Swann Apr 29 '13 at 19:57

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. –  Jubobs Apr 29 '13 at 14:37
    
While I was preparing a MWE, Gonzalo answered my query. –  Reza Apr 29 '13 at 17:17
    
Still, it's good to add a MWE for future visitors to this page. –  Jubobs Apr 29 '13 at 17:23
    
@Jubobs I have edited the original posting to include a MWE. –  Reza Apr 29 '13 at 18:01
    
Great! You're a good TeX.SE citizen :) –  Jubobs Apr 29 '13 at 18:03

1 Answer 1

up vote 9 down vote accepted

You can use the perpendicular coordinate system; for example

\draw (A.south) -- (A.south|-B.north);

will draw a line from A.south to the point that has the same x-coordinate as A.south and the same y-coordinate as B.north. A little example:

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\node[draw] at (0,0) (A) {short text};
\node[draw] at (0.2,-2) (B) {Some longer text};
\draw[green] (A.south) -- (B.north);
\draw[red] (A.south) -- (A.south|-B.north);
\end{tikzpicture}

\end{document}

enter image description here

share|improve this answer

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