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 five nodes defined and positioned as following:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning, fit, calc, shapes, arrows}
\renewcommand{\figurename}{Figure}
    \begin{figure}[!htb]
        \begin{tikzpicture} [title/.style={font=\fontsize{18}{18}\color{black!45}},
            block/.style={rectangle, draw, fill=blue!23, rounded corners, minimum height=4em},
            bloc/.style={rectangle, draw, fill=green!23, rounded corners, minimum height=2em},
            store/.style={cylinder, draw, shape border rotate=90, aspect=0.4, minimum height=1.5cm, minimum width=1.2cm, fill=cyan!23},
            dot/.style={circle, fill=black, minimum size=2pt, inner sep=0pt, outer sep=2pt},
            blob/.style={cloud, draw, cloud puffs=17.8, cloud ignores aspect, minimum width=4cm, minimum height=2.5cm, align=center},
            link/.style={latex-latex, shorten <=8pt, shorten >=1pt}]
            % Place nodes
            \node [title] (backend) at (5.5,10.05) {Sample};
            \node [block, outer sep=5pt, align=center] (server3) at (3.7,6.75) {Component A};
            \node [block, outer sep=5pt, align=center] (server1) at (7.15,9.0) {Component B\\(Blah)};
            \node [block, outer sep=5pt, align=center] (server2) at (7.15,7.45) {Component C\\(Blah)};
            \node [block, outer sep=5pt, align=center] (server4) at (7.15,5.9) {Component D\\(Blah)};
            \node [block, outer sep=5pt, align=center] (server5) at (7.15,4.35) {Component E\\(Blah)};
            \node [draw=black!50, fit={(backend) (server1) (server2) (server3) (server4) (server5)}] (sample) {};
        \end{tikzpicture}
        \caption{A Test Graph}
    \end{figure}
\end{document}

I want to make float-chart-style arrows between Component A and the other four nodes, and I want them look like in the answer to this question: Horizontal hierarchy tree in tikz-qtree: bad layout for longer node-names, but with arrow heads at both ends. In other words, ignoring other parts, replace nice-child0 with Component A, and grandchild0-0-grandchild0-3 with Component B-Component E in my example.

Is there any way to do this without using the tree packages?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

Something like this?

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning, fit, calc, shapes, arrows}
\renewcommand{\figurename}{Figure}

\begin{document}
    \begin{figure}[!htb]
\centering
        \begin{tikzpicture} [title/.style={font=\fontsize{18}{18}\color{black!45}},
            block/.style={rectangle, draw, fill=blue!23, rounded corners, minimum height=4em},
            bloc/.style={rectangle, draw, fill=green!23, rounded corners, minimum height=2em},
            store/.style={cylinder, draw, shape border rotate=90, aspect=0.4, minimum height=1.5cm, minimum width=1.2cm, fill=cyan!23},
            dot/.style={circle, fill=black, minimum size=2pt, inner sep=0pt, outer sep=2pt},
            blob/.style={cloud, draw, cloud puffs=17.8, cloud ignores aspect, minimum width=4cm, minimum height=2.5cm, align=center},
            link/.style={latex-latex, shorten <=8pt, shorten >=1pt}]
            % Place nodes
            \node [title] (backend) at (5.5,10.05) {Sample};
            \node [block, outer sep=5pt, align=center] (server3) at (3.7,6.75) {Component A};
            \node [block, outer sep=5pt, align=center] (server1) at (7.15,9.0) {Component B\\(Blah)};
            \node [block, outer sep=5pt, align=center] (server2) at (7.15,7.45) {Component C\\(Blah)};
            \node [block, outer sep=5pt, align=center] (server4) at (7.15,5.9) {Component D\\(Blah)};
            \node [block, outer sep=5pt, align=center] (server5) at (7.15,4.35) {Component E\\(Blah)};
            \node [draw=black!50, fit={(backend) (server1) (server2) (server3) (server4) (server5)}] (sample) {};

\foreach \i in {1,2,4,5}
  \draw[<->] (server3.east) -- +(10pt,0) |- (server\i.west);
        \end{tikzpicture}
        \caption{A Test Graph}
    \end{figure}
\end{document}

enter image description here

Instead of "manually" adding 10pt to the x-coordinate in

 \foreach \i in {1,2,4,5}
  \draw[<->] (server3.east) -- +(10pt,0) |- (server\i.west);

one can use

\foreach \i in {1,2,4,5}
  \draw[<->] let \p1= (server2.west|-server3.east) in 
    (server3.east) -- +( $ 0.5*(\x1,\y1) - 0.5*(server3.east) $ ) |- (server\i.west);
share|improve this answer
    
that's perfect! Thanks! –  Skyork Nov 3 '12 at 19:46

Your Answer

 
discard

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.