4

How to add this line?

enter image description here 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}

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

4 Answers 4

3

We can use |- to go first vertically and then horizontally from point A to point B. (Or -| for horizontal and then vertical movement.)

We can also use 2.east as a rough marker. If we can ([yshift=1cm]2.east) for the second point, we'll end up above the right most side of 2. So we could say

$(1)!.5!(2)$ |- (yshift=1cm]2.east

for the first part. Now we need to go across a bit more, then down and then across to a point a bit above 3.west. Let's take the halfway point between the west and north west anchors, ($(3.west)!.5!(3.north west)$).

We could manage the changes of direction with a manual adjustment and either -| or |-, but why go to the trouble if we don't have to?

The ext.paths.ortho library allows us to use an enhanced syntax for specifying paths. In our case -|- tells tikz to go horizontally, then vertically, then horizontally between two points.

\draw[->,line width=0.25mm] ($(1.east)!0.5!(2.west)$) |- ([yshift=1cm]2.east) -|- ($(3.west)!.5!(3.north west)$);

diverted arrow up across across down across

Complete 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,ext.paths.ortho}
\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);
    \draw[->,line width=0.25mm] ($(1.east)!0.5!(2.west)$) |- ([yshift=1cm]2.east) -|- ($(3.west)!.5!(3.north west)$);
    
    \end{tikzpicture}
\end{document}
8

You can name 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.

The point (3.160) is on the boundary of node (3) at an angle of 160 degrees (slightly above west which would be 180). You could alternatively use ([yshift=3mm]3.west) for the final point, which would be 3mm above center.

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) --coordinate(M1) (2);
    \draw[->,line width=0.25mm] (2) --coordinate(M2) (3);
    \draw[->,line width=0.25mm] (M1) |- ([yshift=9mm]M2) |- (3.160);

    \end{tikzpicture}

\end{document}
5

Based on my answer on your previous question, i.e. by use of the chains and ext.paths.ortho libraries. My MWE is focused only on your problem, so in comparison to your MWE it is quite shorter, however by the way it also show how can you block schemes can be drawn more efficiently:

\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};  % nodes are in chain
%
\path       (n1) -- coordinate  (aux) (n2);   % defined coordinate between nodes n1 and n2
\draw[arr]  (aux)  |- ([yshift=5mm] n2.north) % first part of arrow  
                  -|- [distance=-3mm] ([yshift=3mm] n3.west); % second part of arrow
    \end{tikzpicture}
\end{document}

enter image description here

3

Like this:

enter image description here

Code (only tikz - no 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)--(7.5,2)--(7.5,.5)--(8.5,.5);     
    \end{tikzpicture}
\end{document}

You must log in to answer this question.

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