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}

在此輸入影像描述

相關內容