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 did several research and many tests and I didn't figure out how to draw the line from (U) and goes to the bottom of S and Q. This is the code of what I did right now and I want your help to add the line wanted...

enter image description here

\documentclass{report}

\usepackage[latin1]{inputenc}
\usepackage{tikz}
\definecolor{arm}{RGB}{100,140,171}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{shapes,arrows}
\usetikzlibrary{positioning}

\begin{document}
 \pagestyle{empty}
\begin{figure} [htbp]
\hspace{-1.9cm}
\resizebox{!}{10cm}{\begin{tikzpicture}[node distance = 1.5cm, auto,>=stealth]

\tikzstyle{los} = [diamond, draw,fill=arm,text width=3em, text badly centered, text=white, node distance=3cm, inner sep=0pt]
 \tikzstyle{quadri} = [rectangle, draw, fill=arm, text width=6em, text centered,text=white , rounded corners, minimum height=2.5em]
 \tikzstyle{line} = [draw, thick, color=black, -latex']


 \node[quadri] (A) {A};
 \node[quadri, below of=A, node distance=1.6cm] (B) {B};
 \node[quadri, below left=1cm and 2cm of B ] (C) {C};
 \node[los, below of=C , node distance=2.2cm] (D) {D};
 \node[quadri,below left=1cm and 1.6cm of D] (E) {E}; 
 \node[quadri,below of=E, node distance=1.6cm](F) {F};
 \node[quadri,below of=D, node distance=1.97cm](G) {G };
 \node[quadri,below of=G, node distance=1.6cm](H) {H};
 \node[quadri,below right=1cm and 1.6cm of D] (I) {I};
 \node[quadri,below of=I, node distance=1.6cm](J) {J};
  \node[quadri, below right=1cm and 2cm of B ] (K) {K};
\node[quadri,below left=1.3cm and 0.22cm of K] (L) {L};
\node[quadri,below of=L,node distance=1.6cm] (M) {M};
\node[los,below right of=K,node distance=3cm] (O) {O};
\node[quadri,below left=1cm and 0.05cm of O](P){P};
\node[quadri,below of=P, node distance=1.6cm](Q) {Q};
\node[quadri,below right=1cm and 0.05cm of O](R){R};
\node[quadri,below of=R, node distance=1.6cm](S) {S};
\node[quadri,right of=A ,node distance=3.5cm](T) {T};
\node[quadri, text width=7em,right of=T ,node distance=3.4cm](U){U};


\path [line] (A) -- (T);
\path [line] (T) -- (U);
\path [line] (A) -- (B);
\path [line] (B) -- (C);
 \path [line] (B) -- (K);
 \path [line] (C) -- (D);
 \draw[line] (D) -| node [near start,above] {$=0$} (E);
\path [line] (E) -- (F);
\draw[line] (D) -- node[right] {$=1$} (G);
\path [line] (G) -- (H);
\draw[line] (D) -| node [near start,above] {$=0$} (I);
 \path [line] (I) -- (J);
 \path [line] (K) -- (L);
 \path [line] (K) -- (O);
 \path [line] (L) -- (M);
 \draw[line] (O) -| node [near start,above] {$=1$} (P);
 \draw[line] (O) -| node [near start,above] {$>1$} (R);
 \path [line] (P) -- (Q);
 \path [line] (R) -- (S);

 \end{tikzpicture}
 }
  \caption{Flowchart}
  \label{fig:flowchart}

\end{figure}

\end{document}
share|improve this question
    
Welcome to TeX.SX! Usually, we don't put a greeting or a “thank you” in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Accepting and upvoting answers is the preferred way here to say “thank you” to users who helped you. –  Andrew Swann Jul 29 '13 at 10:21
    
Hi luke. Do you mean an arrow starting on the right of U going to the right of S or pointing to both S and Q? –  Claudio Fiandrino Jul 29 '13 at 10:22
    
@ClaudioFiandrino It goes from right of (U) going right of the scheme and point (S) and (M) From the bottom! –  luke Jul 29 '13 at 10:27
    
Ok @AndrewSwann , i understand! –  luke Jul 29 '13 at 10:28

1 Answer 1

up vote 4 down vote accepted

First of all, I would like to recommend you to not use \tikzstyle to define your styles in favor of \tikzset (for further information see Should \tikzset or \tikzstyle be used to define TikZ styles?).

Another remark: I noticed you used both \draw and \path; actually, \draw is a shortcut for \path[draw] thus, as your style line already contains the key draw, there's not difference in using one or the other one. Notice: only in case both exploit the line style.

Also, the connections can be drawn much more easily thanks to a loop: indeed, most of the lines of code are identical.

Said that, the straight way to solve the problem is to use the library calc, which helps in defining a commodity coordinate useful to draw the paths.

\documentclass{report}

\usepackage{tikz}
\definecolor{arm}{RGB}{100,140,171}
\usetikzlibrary{arrows,calc,positioning,shapes.geometric}

\begin{document}
\pagestyle{empty}
\begin{figure} [htbp]
\hspace{-1.9cm}
\resizebox{!}{7.5cm}{
\begin{tikzpicture}[node distance = 1.5cm, auto,>=stealth]

\tikzset{los/.style={diamond, draw,fill=arm,text width=3em, text badly centered, text=white, node distance=3cm, inner sep=0pt}}
\tikzset{quadri/.style={rectangle, draw, fill=arm, text width=6em, text centered,text=white , rounded corners, minimum height=2.5em}}
\tikzset{line/.style={draw, thick, color=black, -latex'}}


\node[quadri] (A) {A};
\node[quadri, below of=A, node distance=1.6cm] (B) {B};
\node[quadri, below left=1cm and 2cm of B ] (C) {C};
\node[los, below of=C , node distance=2.2cm] (D) {D};
\node[quadri,below left=1cm and 1.6cm of D] (E) {E}; 
\node[quadri,below of=E, node distance=1.6cm](F) {F};
\node[quadri,below of=D, node distance=1.97cm](G) {G };
\node[quadri,below of=G, node distance=1.6cm](H) {H};
\node[quadri,below right=1cm and 1.6cm of D] (I) {I};
\node[quadri,below of=I, node distance=1.6cm](J) {J};
\node[quadri, below right=1cm and 2cm of B ] (K) {K};
\node[quadri,below left=1.3cm and 0.22cm of K] (L) {L};
\node[quadri,below of=L,node distance=1.6cm] (M) {M};
\node[los,below right of=K,node distance=3cm] (O) {O};
\node[quadri,below left=1cm and 0.05cm of O](P){P};
\node[quadri,below of=P, node distance=1.6cm](Q) {Q};
\node[quadri,below right=1cm and 0.05cm of O](R){R};
\node[quadri,below of=R, node distance=1.6cm](S) {S};
\node[quadri,right of=A ,node distance=3.5cm](T) {T};
\node[quadri, text width=7em,right of=T ,node distance=3.4cm](U){U};


\foreach \source/\dest in {
A/T,T/U,A/B,B/C,B/K,C/D,E/F,G/H,I/J,K/L,K/O,
L/M,P/Q,R/S}{
\path [line]  (\source) -- (\dest);  
}
\path [line] (D) -| node [near start,above] {$=0$} (E);
\path [line] (D) -- node[right] {$=1$} (G);
\path [line] (D) -| node [near start,above] {$=0$} (I);
\path [line] (O) -| node [near start,above] {$=1$} (P);
\path [line] (O) -| node [near start,above] {$>1$} (R);


% useful coordinate: 
% it is defined as half way between S and Q shifted
% below of 1 cm
\coordinate (below scheme) at ($(S)!0.5!(Q)-(0,1)$);
% path from U to the south of the scheme
\path [line,-] (U.east) -- ($(U.east)+(1.5,0)$) |- (below scheme); % I used again the style line, but - removes the arrow that in this case should not be deployed
\path [line] (S|-below scheme)--(S);
\path [line] (below scheme)-|(M);

\end{tikzpicture}
 }
\caption{Flowchart}
\label{fig:flowchart}
\end{figure}

\end{document}

The result:

enter image description here

If your aim is to connect all the leaves of the tree, you might exploit a different solution:

% = = = = = = = = = = = = = = = = = = = =
% THIS IS TO CONNECT U TO all
% = = = = = = = = = = = = = = = = = = = =
\coordinate (below scheme) at ($(F)-(0,1)$);
\path [line,-] (U.east) -- ($(U.east)+(1.5,0)$) |- (below scheme); % I used again the style line, but - removes the arrow that in this case should not be deployed
\foreach \module in {F,H,J,M,Q,S}
\path [line] (\module|-below scheme)--(\module);

The snippet should replace:

% useful coordinate: 
% it is defined as half way between S and Q shifted
% below of 1 cm
\coordinate (below scheme) at ($(S)!0.5!(Q)-(0,1)$);
% path from U to the south of the scheme
\path [line,-] (U.east) -- ($(U.east)+(1.5,0)$) |- (below scheme); % I used again the style line, but - removes the arrow that in this case should not be deployed
\path [line] (S|-below scheme)--(S);
\path [line] (below scheme)-|(M);

in the previous document.

The new code defines the commodity coordinate (below scheme) to be 1cm south of F. Now, by exploiting the ability of the calc library to compute intersections, each arrow is defined as a path starting from module |- below scheme towards module. Please refer to the pgfmanual for further information on the calc library.

This provides you:

enter image description here

share|improve this answer
    
how can i add the same thing to F H J Q ????? –  luke Jul 29 '13 at 10:50
    
@luke: please see my edit answer. :) –  Claudio Fiandrino Jul 29 '13 at 11:01
    
Brilliant! Exactly what i want. hope this will help others! –  luke Jul 29 '13 at 11:04

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.