I'm drawing an org chart and I'd like to have arrows pointing to each of the nodes I do so. I'm also lazily using a single draw command to draw a line from each of the nodes as the last part of my process. Is there some way that I can specify an [->]
going to C and B but not to hub1 in the example I've shown without drawing each line individually?
\documentclass[10pt]{article}
\usepackage{tikz}
\usetikzlibrary{calc,positioning}
\tikzstyle{a}=[rectangle,draw]
\begin{document}
\begin{tikzpicture}
\node [a] (A) at (0,0) {A};
\node [a,below=1cm of A] (B) {B};
\node [a,left=1cm of B] (C) {C};
\node [a,right=1cm of B] (D) {D};
\node [below=0.25cm of A] (hub1) {};
\draw [->] (A.south) -- (hub1.south) -| (C.north) (hub1.south) -- (B.north) (hub1.south) -| (D.north);
\end{tikzpicture}
\end{document}
editing on from @texenthusiast comment below I've tried using a \foreach
loop to edit this, but now the arrow for B points the wrong way. Any thoughts?
\documentclass[a6]{minimal}
\usepackage{tikz}
\usetikzlibrary{calc,positioning}
\tikzstyle{a}=[rectangle,draw]
\begin{document}
\begin{tikzpicture}
\node [a] (A) at (0,0) {A};
\node [a,below=1cm of A] (B) {B};
\node [a,left=1cm of B] (C) {C};
\node [a,right=1cm of B] (D) {D};
\coordinate [below=0.6cm of A] (hub1) {};
\foreach \a/\b/\c in {C/east/0.1cm,B/north/0,D/west/-0.1cm}
\draw [->] (hub1) -| ($(\a.\b)+(\c,0)$) -- (\a.\b);
\end{tikzpicture}
\end{document}
\coordinate[below=0.5cm of A] (hub1);
instead of your node definition, you can refer to(hub1)
instead of the(hub1.south)
anchor inside your\draw
command. Perhaps a bit more elegant, as you don't have to take node dimensions into account when specifying positions. – bencarabelli Mar 18 '13 at 8:18