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:

I'm trying to create a simple flowchart (it's actually an archaeological diagram called a Harris Matrix) using TikZ. Below is the code for a small part of the finished diagram which illustrates the problem I'm having. In the current chart the line from the node labeled 7 goes downwards and then touches the node labeled 9 on the right side. What I would like to do is have the line still go downwards from node 7, go to the left, and then go downwards again to touch node 9 on the top. Thanks for any help, I'm quite new to TikZ.

What I have now:

harris_matrix_sample

\documentclass{article} 

\usepackage{tikz}
\usetikzlibrary{shapes,arrows}

\begin{document}

\tikzstyle{block} = [rectangle, draw, text centered]
\tikzstyle{line} = [draw]

\[ \begin{tikzpicture}

\node [block] (g) {7};
\node [block, below left of = g] (h) {9};
\node [block, below right of = g] (i) {12};

\path [line] (g) |- (h);
\path [line] (g) |- (i);
\end{tikzpicture} \]

\end{document}
share|improve this question

marked as duplicate by Qrrbrbirlbel, Gonzalo Medina, Werner, Torbjørn T., T. Verron Apr 23 '13 at 5:20

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.

1 Answer 1

up vote 3 down vote accepted

One possibility using the let syntax:

\documentclass{article} 
\usepackage{tikz}
\usetikzlibrary{calc,shapes,arrows}

\begin{document}

\tikzset{
block/.style={rectangle, draw, text centered},
line/.style={draw}
}

\[ 
\begin{tikzpicture}
\node [block] (g) {7};
\node [block, below left of = g] (h) {9};
\node [block, below right of = g] (i) {12};

\path[line] let \p1=(g.south), \p2=(h.north) in (g.south) -- +(0,0.5*\y2-0.5*\y1) -| (h.north);
\path [line] let \p1=(g.south), \p2=(i.north) in (g.south) -- +(0,0.5*\y2-0.5*\y1) -| (i.north);
\end{tikzpicture} 
\]

\end{document}

enter image description here

One could also do some manual adjustment, but this could produce undesired results if the wrong shift is used:

\documentclass{article} 

\usepackage{tikz}
\usetikzlibrary{calc,shapes,arrows}

\begin{document}

\tikzset{
block/.style={rectangle, draw, text centered},
line/.style={draw}
}

\[ 
\begin{tikzpicture}
\node [block] (g) {7};
\node [block, below left of = g] (h) {9};
\node [block, below right of = g] (i) {12};

\path[line] (g.south) -- +(0,-3pt) -| (h.north);
\path[line] (g.south) -- +(0,-3pt) -| (i.north);
\end{tikzpicture} 
\]

\end{document}
share|improve this answer

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