TransWikia.com

TIKZ. Move the arrow

TeX - LaTeX Asked by chiuki on December 10, 2020

I have very simple tikzpicture table-scheme and I need to move arrow to the right.. Now it is looks like this:
enter image description here

But I want to make it like this: enter image description here

My code:

    ...  
        
        &
        node [block_center] (des1) {X[0] OP Y[0]}; 
        &
        node [block_center] (des2) {X[1] OP Y[1]}; 
        &
        node [block_center] (des3) {X[2] OP Y[2]}; 
        &
        node [block_center] (des4) {X[3] OP Y[3]}; 
        
    };
    begin{scope}[every path/.style=line]
        
        path (x1) -- (op1);
        path (x2) -- (op2);
        path (x3) -- (op3);
        path (x4) -- (op4);
        
        path (y1) -- (op1);
        path (y2) -- (op2);
        path (y3) -- (op3);
        path (y4) -- (op4); ...
        

One Answer

Ok, since you are new here ...

and for exercise and fun:

documentclass[tikz, margin=3mm]{standalone}
usetikzlibrary{arrows.meta,
                chains,
                positioning}

begin{document}
    begin{tikzpicture}[
node distance = 5mm and 3mm,
  start chain = going right,
   box/.style = {draw, thick, 
                 text width=8em, minimum height=3ex, align=#1},
 box/.default = center
                        ]
foreach i in {0,1,...,3}
{
    node  (n1i)  [box, on chain] {X[i]};
    node  (n2i)  [box=right, below=of n1i] {Y[i]};
    node  (n3i)  [box, below=of n2i] {OPERATION};
    draw[-Stealth] (n1i) -- (n3i);
    draw[-Stealth] ([xshift=2em] n2i.south) coordinate (aux) 
                                              -- (aux |- n3i.north);
    node  (n4i)  [box, below=of n3i] {X[i] OP Y[i]};
    draw[-Stealth] (n3i) -- (n4i);
}
    end{tikzpicture}        
end{document}

enter image description here

Addendum: For exercise here is small variation of original answer, result is slightly more fancy ...

documentclass[tikz, margin=3mm]{standalone}
usetikzlibrary{arrows.meta,
                chains,
                positioning}

begin{document}
    begin{tikzpicture}[
node distance = 5mm and 3mm,
  start chain = going right,
   box/.style = {draw, thick, outer sep=0pt,
                 text width=6em, minimum height=3ex, align=#1},
 box/.default = center
                        ]
foreach i in {0,1,...,3}
{
    node  (n1i)  [box, on chain] {X[i]};
    node  (n2i)  [box=right, below=of n1i] {Y[i]};
    node  (n3i)  [box, below=of n2i] {OPERATION};
    draw[-Stealth] (n1i) -- (n3i);
    draw[white, thick, densely dashed] (n2i.north) -- (n2i.south);
    draw[-Stealth, 
          transform canvas={xshift=2em}] (n2i) -- (n3i);
    node  (n4i)  [box, below=of n3i] {X[i] OP Y[i]};
    draw[-Stealth] (n3i) -- (n4i);
}
    end{tikzpicture}        
end{document}

enter image description here

Correct answer by Zarko on December 10, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP