2

enter image description here

How to add this line?

Current code:

\documentclass{article}
\usepackage{graphicx} % Required for inserting images
\usepackage{fp, tikz}
\usetikzlibrary{arrows,shapes,backgrounds,patterns,fadings,matrix,arrows,calc,
    intersections,decorations.markings,
    positioning,external,arrows.meta}
\tikzset{
    block/.style = {draw, rectangle,
        minimum height=1cm,
        minimum width=2cm},
    input/.style = {coordinate,node distance=1cm},
    output/.style = {coordinate,node distance=6cm},
    arrow/.style={draw, -latex,node distance=2cm},
    pinstyle/.style = {pin edge={latex-, black,node distance=2cm}},
    sum/.style = {draw, circle, node distance=1cm},
}
\begin{document}

\begin{tikzpicture}[auto, >=latex', transform shape,font={\sffamily \small}]

\node [draw=black,
minimum width=1.6cm,
minimum height=1.2cm, 
align=center]   (1) {1};

\node [draw=black,
minimum width=1.6cm,
minimum height=1.2cm, 
align=center,
right=0.6cm of 1]   (2) {2};

\node [draw=black,
minimum width=1.6cm,
minimum height=1.2cm, 
align=center,
right=0.6cm of 2]   (3) {3}; 

\draw[->,line width=0.25mm] (1.east) -- (2.west);
\draw[->,line width=0.25mm] (2.east) -- (3.west);

\end{tikzpicture}

\end{document}

Skillmon
  • 60,462
Aleni
  • 65

4 Answers4

4

You can set a coordinate on the segment from (1) to (2) just like a node. the midpoint of the line is the default. Then you can draw the new arrow from there.

Also, I simplified your code quite a bit.

enter image description here

\documentclass{article}

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

\tikzset{ block/.style = {draw, rectangle, minimum height=1.2cm, minimum width=1.6cm} }

\begin{document}

\begin{tikzpicture}[>=latex',font={\sffamily\small}, node distance=.6cm]

\node [block] (1) {1};
\node [block, right=of 1] (2) {2};
\node [block, right=of 2] (3) {3}; 

\draw[->,line width=0.25mm] (1.east) --coordinate(M) (2.west);
\draw[->,line width=0.25mm] (2.east) -- (3.west);
\draw[->,line width=0.25mm] (M) --++ (0,1) -| (3);

\end{tikzpicture}

\end{document}

Sandy G
  • 42,558
2

Since you loaded the calc library, you could use its ability to find the mid point between two nodes. You oudl add the following line after your code.

\draw[->,line width=0.25mm] ($(1)!0.5!(2)$) --++ (0,1.3cm) -| (3.north);

The first coordinate ($(1)!0.5!(2)$) evalutate the mid point between your node (1) and (2).

The second coordinate --++ (0,1.3cm) is a dummy point that I created to lift the arrow above your node. You can adjust the 1.3cm to your need.

1

Like this:

enter image description here

Code (without use of any library):

\documentclass{article}
\usepackage{tikz}

\begin{document} \begin{tikzpicture} \draw[line width=3pt] (0,0) node[minimum height=2cm,minimum width=3cm,draw] (1) {\Huge \bfseries 1}; \draw[line width=3pt] (5,0) node[minimum height=2cm,minimum width=3cm,draw] (2) {\Huge \bfseries 2}; \draw[line width=3pt] (10,0) node[minimum height=2cm,minimum width=3cm,draw] (3) {\Huge \bfseries 3};
\draw[-latex,line width=3pt] (1) -- (2); \draw[-latex,line width=3pt] (2) -- (3); \draw[-latex,line width=3pt] (2.5,0)--(2.5,2)--(10,2)--(3);
\end{tikzpicture} \end{document}

1

By use of the ext.paths.ortho library, a really MWE (Minimal Working Example) focused on your problem:

\documentclass[margin=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                chains,
                ext.paths.ortho,    % defined in the tikz-ext package
                positioning,
                }

\begin{document} \begin{tikzpicture}[ node distance = 4mm and 6mm, start chain = going right, arr/.style = {-{Straight Barb[scale=0.8]}, semithick}, box/.style = {% default is rectangle draw, minimum height = 10mm, minimum width=20mm, on chain, join=by arr} ] \foreach \i in {1,2,3} \node [box] (n\i) {\i}; % \path (n1) -- coordinate (aux) (n2); \draw[arr] (aux) r-ud (n3.north); \end{tikzpicture} \end{document}

enter image description here

Zarko
  • 296,517