
Wie kann ich einen Knoten am Schnittpunkt von I- und C-Knoten (I |- C) platzieren? 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}
Der Knoten J müsste bei O stehen, ist es aber eigentlich nicht!
Antwort1
Eine Nichtübereinstimmung bei der Platzierung des Knotens J
wird durch on chain
die Eigenschaften der box
Knoten verursacht. Wenn Sie diese Eigenschaften dabei aufheben, wird der Knoten an der Stelle platziert, an der Sie ihn haben möchten.
Da ich nicht weiß, ob dies für einen bestimmten Knoten in der Kette möglich ist, organisiere ich Ihre Option tikzset
so, dass „ on chain
entfernen von“ base
und „hinzufügen zu“ gilt box
, was später bei der Stildefinition der Stile anderer Knoten verwendet wird.
Mit diesen Änderungen und auch einigen Änderungen an den Verbindungslinien (die in Ihrem MWE nicht logisch waren) erhalte ich das folgende Bild:
Ist es das, wonach Sie suchen?
\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}