17
\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\begin{document}
\begin{tikzpicture}
\draw (0,2.5) node[minimum height=1cm,minimum width=3cm,draw] (A) {A};
\draw (5,0) node[minimum height=1cm,minimum width=3cm,draw] (B){B};
\draw (5,1.5) node[minimum height=1cm,minimum width=3cm,draw] (C) {C};
\draw (5,3) node[minimum height=1cm,minimum width=3cm,draw] (D) {D};
\draw (5,4.5) node[minimum height=1cm,minimum width=3cm,draw] (E) {E};

\draw[-latex] (A.east) |- (B.west);
\draw[-latex] (A.east) |- (C.west);
\draw[-latex] (A.east) |- (D.west);
\draw[-latex] (A.east) |- (E.west);
\end{tikzpicture}

\end{document}

With Stefan's help I manage to draw the lines that travel straight and make 90 turn. The output of that solution is on the left side of the attached image. My goal is to produce result as shown on the right side of the image. I already asked similar question earlier, check here Tikz Drawing Arrow between nodes alt text

17

One way would be to add a stage at the start of the arrows that goes horizontally for a bit:

\draw[-latex] (A.east) -- ++(1,0) |- (B.west);

(adjust the 1 to get the length you want).

This does mean that the first part of the line would get drawn 4 times. It may not show (I don't know). To avoid that, you could draw it only the once; thus the later lines would be:

\draw[-latex] (A.east) ++(1,0) |- (C.west);

An alternative would be to put a coordinate node at that point:

\draw (A.east) -- ++(1,0) coordinate (div);
\draw[-latex] (div) |- (B.west);
\draw[-latex] (div) |- (C.west);
7

You can create a new command with an intermediate point

\documentclass{article}

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

\newcommand{\myline}[2]{
\path(#1.east) --(#2.west)  coordinate[pos=0.4](mid);
\draw[-latex] (#1.east) -| (mid) |- (#2.west);
}
\begin{document}
\begin{tikzpicture}
\draw (0,2.5) node[minimum height=1cm,minimum width=3cm,draw] (A) {A};
\draw (5,0) node[minimum height=1cm,minimum width=3cm,draw] (B){B};
\draw (5,1.5) node[minimum height=1cm,minimum width=3cm,draw] (C) {C};
\draw (5,3) node[minimum height=1cm,minimum width=3cm,draw] (D) {D};
\draw (5,4.5) node[minimum height=1cm,minimum width=3cm,draw] (E) {E};

\myline{A}{E}
\myline{A}{D}
\myline{A}{C}
\myline{A}{B}

\end{tikzpicture}

\end{document}

line with intermediate point

  • The best way to mark code here is to select it and press the {} button (or Ctrl-K), rather than by enclosing it in <pre>...</pre> – egreg Mar 24 '12 at 19:11
  • 1
    every node/.style ={minimum height=1cm,minimum width=3cm,draw} would be nice too ! – Alain Matthes Mar 24 '12 at 19:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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