3

How can I place node at the intersection of I and C node (I |- C)? MWE:

\documentclass[border=2pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{chains} 
\usetikzlibrary{arrows,chains,positioning,shapes,scopes}

\begin{document}

\begin{tikzpicture}
[>=latex,node distance=.8cm,
start chain =going below,]

\tikzset{base/.style = {
        draw,rounded corners,minimum width=20mm, minimum height=6mm, align=center,
        inner sep=1mm, outer sep=0mm,
        on chain, join=by {->}}}
\tikzset{start/.style={base,minimum size=6mm,circle,fill=black}}
\tikzset{end/.style={base,circle}}
\tikzset{box/.style={base}}
\tikzset{decision/.style={base,rounded corners=0,minimum size=6mm,diamond,aspect=1.5,on chain}}

{
  \node[start] (A) {};
  \node[box] (B) {clone repository};
  \node[box] (C) {coding};
  \node[box] (D) {commit locally};
  \node[box] (E) {review};
  \node[decision] (F) {};
  {[start branch]
      \node[box,left=2cm of F] (G) {rework};
      \node[box,on chain=going above] (H) {recommit};
  }
  {[start branch]
    \node[box,right=2cm of F] (I) {submit};
    \coordinate  (O)  at (I |- C);
    \node[box] at (O) (J)  {update local repository};
  }

\draw[->] (H) -- (E);
\draw[->] (J) -- (C);
% debug code line
\draw[red] (O) -- (I) (O) -- (C);
}
\end{tikzpicture}
\end{document}

The node J should be placed at O but actually not! enter image description here

1
  • Please, extend your image code to complete document beginning with \documentclass{...} and ending with \end{document}. Don't forget to put in preamble necessary libraries and packages ... – Zarko Jul 12 '17 at 20:50
3

Mismatch in placement of node J is caused by on chain properties of box nodes. If you in this cancel this properties, the node will one place where you wish to be.

Since I don't know, if this is possible to do for particular node in chain, I reorganize your tikzset so, that on chain option remove from base and add to box, which is later used in style definition of others nodes' styles.

With this changes and also some changes in connection lines (for which was non logical in your MWE) I obtain the following image:

enter image description here

Is it what you looking for?

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{chains, shapes}
\begin{document}
    \begin{tikzpicture}[>=latex,
  node distance = 8mm,
    start chain = going below,
    base/.style = {draw, rounded corners,
                   minimum width=20mm, minimum height=6mm, 
                   align=center,
                   inner sep=1mm, outer sep=0mm,
                   },
     box/.style = {base, on chain, join=by {->}},
   start/.style = {box,minimum size=6mm,circle,fill=black},
     end/.style = {box,circle, on chain},
decision/.style = {box, diamond, aspect=1.5, 
                   sharp corners, minimum size=6mm}
                        ]
\node[start] (A) {};
\node[box] (B) {clone repository};
\node[box] (C) {coding};
\node[box] (D) {commit locally};
\node[box] (E) {review};
\node[decision] (F) {};
{%[start branch]
      \node[box,left=2cm of F] (G) {rework};
      \node[box,on chain=going above] (H) {recommit};
  }
  {%[start branch]
    \node[base,
          right=2cm of F] (I) {submit};
    \node[base]  (J)  at (I |- C) {update local repository};
  }

\draw[->] (H) -- (E);
\draw[->] (F) -- (I);
% debug code line
\draw[red,->] (I) edge (J) (J) to (C);
    \end{tikzpicture}
\end{document}
1
  • Yes, the output is exactly what I want. so I and J node will not be a chain then user need to connect it by draw command. – beetlej Jul 12 '17 at 22:54

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.