3

I am using tikzpicture to draw the connection between node in Latex. However, the connections are not fine. I would like to know how can I obtain the expected result as right side. Currently, I used bellow code and result shown in left side. Thank you in advance

enter image description here This is my code

\documentclass{article}
\usepackage{graphicx}
\usepackage{caption,subfig}
\usepackage{float}
\usepackage{xcolor}
\usepackage{tikz-qtree}
\usetikzlibrary{trees} % this is to allow the fork right path
\usepackage{tikz, xcolor}
\usetikzlibrary{shapes,arrows}
\usepackage[draft]{todonotes}   % notes showed

\begin{document}
\begin{figure} [H]
\centering
\begin{tikzpicture}[node distance = 3cm, auto]
    % Place nodes
    \node [label=above: A](A) {\includegraphics[width=0.15\textwidth]{example-image-a}}; 
    \node [label=below: B,below right=1cm and 1cm of A] (B) {\includegraphics[width=0.15\textwidth]{example-image-b}};
    \node [label=above: C ,above right=1cm and 1cm of A] (C) {\includegraphics[width=0.15\textwidth]{example-image-c}};
    \node [label=below: D,right = 1cm of B] (D) {\includegraphics[width=0.15\textwidth]{example-image-a}};
    \node [label=above: E,right = 1cm of C] (E) {\includegraphics[width=0.15\textwidth]{example-image-b}}; 
    \node [label=above: result1 ,right = 1cm of D] (result1){}; 
    \node [label=above: result2 ,right = 1cm of E] (result2){}; 
    \node [label=above: result3 ,above  of= result1] (result3){};
    % Draw arrow
    \draw[line width=0.3mm,->] (A) to (B);
    \draw[line width=0.3mm,->] (A) to (C);
    \draw[line width=0.3mm,->] (B) to (D);
    \draw[line width=0.3mm,->] (C) to (E);
    \draw[line width=0.3mm,->] (D) to (result1);
    \draw[line width=0.3mm,->] (E) to (result2);
    \draw[line width=0.3mm,->] (E) to (result3);
    \draw[line width=0.3mm,->] (D) to (result3);
\end{tikzpicture}
\captionsetup{labelfont={bf},font={color=blue}}
\caption{Test graph}
\label{fig:2n}
\end{figure}

\end{document}

1 Answer 1

5

You can use |- and -| in combination with --

\draw[line width=0.3mm,->] (A) -- ++(1.5cm,0) |- (B);
\draw[line width=0.3mm,->] (A) -- ++(1.5cm,0) |- (C);
\draw[line width=0.3mm,->] (E) -- ++(1.5cm,0) |- (result3);
\draw[line width=0.3mm,->] (D) -- ++(1.5cm,0) |- (result3);
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .