TIKZ。移动箭头

TIKZ。移动箭头

我有非常简单的 tikzpicture 表格方案,我需要将箭头向右移动。现在它看起来像这样: 在此处输入图片描述

但我想把它做成这样:在此处输入图片描述

我的代码:

    ... \\ 
        \\
        &
        \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); ...
        

答案1

好的,因为你是新来的……

以及锻炼和娱乐:

\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  (n1\i)  [box, on chain] {X[\i]};
    \node  (n2\i)  [box=right, below=of n1\i] {Y[\i]};
    \node  (n3\i)  [box, below=of n2\i] {OPERATION};
    \draw[-Stealth] (n1\i) -- (n3\i);
    \draw[-Stealth] ([xshift=2em] n2\i.south) coordinate (aux) 
                                              -- (aux |- n3\i.north);
    \node  (n4\i)  [box, below=of n3\i] {X[\i] OP Y[\i]};
    \draw[-Stealth] (n3\i) -- (n4\i);
}
    \end{tikzpicture}        
\end{document}

在此处输入图片描述

附录: 为了练习,这里是原始答案的一个小变化,结果稍微更花哨......

\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  (n1\i)  [box, on chain] {X[\i]};
    \node  (n2\i)  [box=right, below=of n1\i] {Y[\i]};
    \node  (n3\i)  [box, below=of n2\i] {OPERATION};
    \draw[-Stealth] (n1\i) -- (n3\i);
    \draw[white, thick, densely dashed] (n2\i.north) -- (n2\i.south);
    \draw[-Stealth, 
          transform canvas={xshift=2em}] (n2\i) -- (n3\i);
    \node  (n4\i)  [box, below=of n3\i] {X[\i] OP Y[\i]};
    \draw[-Stealth] (n3\i) -- (n4\i);
}
    \end{tikzpicture}        
\end{document}

在此处输入图片描述

相关内容