2

I would like to add additional node (block [X] with arrow) at selected node [C] just like in the image:

enter image description here

I have something like this, how can I do that?

\begin{figure}[!h]
\centering
    \begin{tikzpicture}[node distance = 5mm and 7mm, start chain = going right, block/.style = {draw, align=center, font=\linespread{0.8}\small}]
        \begin{scope}[every node/.append style={on chain, join=by -Stealth}]
            \node (n0)  {A};
            \node (n1) [block]  {B};
            \node (n2) [block]  {C};
            \node (n3) [block]  {D};
            \node (n4)  {E};
        \end{scope}
    \end{tikzpicture}
\end{figure}
2

For example as below.

enter image description here

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,chains,arrows.meta}
\begin{document}
    \begin{tikzpicture}[node distance = 5mm and 7mm, start chain = going right, block/.style = {draw, align=center, font=\linespread{0.8}\small}]
        \begin{scope}[every node/.append style={on chain, join=by -Stealth}]
            \node (n0)  {A};
            \node (n1) [block]  {B};
            \node (n2) [block]  {C};
            \node (n3) [block]  {D};
            \node (n4)  {E};
        \end{scope}
        \node [block,above=of n2] (nx) {X};
        \draw [-Stealth] (nx) -- (n2);
    \end{tikzpicture}
\end{document}

Or by making a branch on your chain, output is as above:

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,chains,arrows.meta,scopes}
\begin{document}
\begin{tikzpicture}[
   node distance = 5mm and 7mm,
   block/.style = {
       draw, align=center, font=\linespread{0.8}\small
       }
   ]

\begin{scope}[
   every node/.append style={
       on chain, join=by -Stealth
   },
   start chain = going right]

   \node (n0)  {A};
   \node (n1) [block]  {B};
   \node (n2) [block]  {C};
   { [start branch=x going above] } % scopes library is needed for this syntax
   \node (n3) [block]  {D};
   \node (n4)  {E};
\end{scope}

\begin{scope}[
   continue branch=x, % continue the branch we started above
   every node/.append style={on chain, join=by Stealth-} % note Stealth- instead of -Stealth
   ]
  \node [block] {X};
\end{scope}
\end{tikzpicture}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.