2

Hei guys, im almost sure there is some very easy solution for this, but i easily dont know anymore what/where to search.

What I want to do can be seen below in the image the red line (with or without an arrowhead, not that important).

enter image description here Do you guys have any idea how to do this? I started trying with \coordinate and invisible nodes, but failed hard.

Codeexample of this code:

\newlength{\spalte}
\setlength{\spalte}{7cm}
\newlength{\double}
\setlength{\double}{0.7cm}

\node (init) [progline] {Download};
\node (preproc) [process, below of = init] {Preprocessing};
\node (shrink) [process, right of=preproc, yshift=\double, node distance=\spalte] {Preprocessing};
\node (clean) [process, right of = preproc, yshift=-\double, node distance=\spalte] {Preprocessing};

% Draw edges
\draw [arrow] (init) -- (preproc);
\draw [arrow] (preproc) -| (shrink);
\draw [arrow] (preproc) -- (clean);

Edit: If someone comes to this point, my final solution now (including arrowheads also) follows: enter image description here

\usepackage{tikz} %Flowchart
\usetikzlibrary{shapes,arrows, positioning} %Flowchart  

% Define block styles
\tikzstyle{treenode} = [shape=rectangle, rounded corners,
draw, anchor=center,
text width=5cm, align=center,
top color=white, bottom color=blue!20,
inner sep=1ex]
\tikzstyle{progline} = [treenode, font=\Large, bottom color=red!30]
\tikzstyle{process} = [treenode, font=\ttfamily\normalsize]
\tikzstyle{invisible} = [inner sep=0,minimum size=0]

\tikzstyle{arrow} = [thick,->,>=stealth]    %Arrow shape
\tikzstyle{arrow_right} = [thick,<-,>=stealth]  %Arrow shape



\pgfmathsetlengthmacro{\double}{0.7cm}

\begin{tikzpicture}[node distance = 1cm, auto]
% Place nodes
\node (init) [progline] {Download};
\node (preproc) [process, below=of init] {Preprocessing};
    \node (shrink) [process, right=of preproc, yshift=\double] {shrinking};

\node (clean) [process, right=of preproc, yshift=-\double] {cleaning};
% Draw edges
\draw [arrow] (init) -- (preproc);
\draw [arrow] (preproc) -| (shrink);
\draw [arrow] (preproc) -- (clean);
\draw [arrow_right] (shrink.west) -- ++(-0.5,0) -- (preproc.east);
\end{tikzpicture}
  • Welcome to TeX.SX! As I mention below, in general it is always nice if you post a minimal example of the code you have. That way we don't have to make any assumptions about what you have, and it makes it easier for us if we want to test our suggestions. – Torbjørn T. Sep 24 '15 at 08:18
  • sorry :) added if someone stumbles over it anytime – groebsgr Sep 24 '15 at 08:23
  • Sorry from me as well, I could have been more specific. Complete examples, where we can copy-paste and compile the code directly, without making changes, is by far the best (similar to the code I added to my answer). There were no libraries required, but the style definitions are missing, so one has to "reinvent" those, which is always a bit annoying. (Your example wasn't the most complex, but for larger code pieces it makes it a lot easier. And in some cases it is required to have a complete example to understand the cause of a problem.) – Torbjørn T. Sep 24 '15 at 08:39
  • I added the full code now, I see, my bad :) – groebsgr Sep 24 '15 at 08:44

1 Answers1

1

It would be nice if you had posted the code of your initial attempts. However, assuming the leftmost Preprocessing node is called prepro1, and the topmost prepro2, you can try something like

\draw [red] (prepro2.west) -- ++(-0.5,0) -- (prepro1.east);

Whether -0.5 is suitable or not depends on your setup, you may have to increase or decrease it.

Using your snippet, and adding simple definitions of the styles that were missing, it may look like the code below. Some notes:

  • For reference I added an alternative way of defining those lengths, via \pgfmathsetlengthmacro, which is provided by PGF/TikZ.
  • The syntax below of= is deprecated in favour of using loading the positioning library and using below=of, see Difference between "right of=" and "right=of" in PGF/TikZ.

enter image description here

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[progline/.style={draw,fill=red!30},process/.style={draw,fill=blue!20},arrow/.style={-stealth}]
\pgfmathsetlengthmacro{\spalte}{7cm}
\pgfmathsetlengthmacro{\double}{0.7cm}

\node (init) [progline] {Download};
\node (preproc) [process, below=of init] {Preprocessing};
\node (shrink) [process, right=of preproc, yshift=\double, node distance=\spalte] {Preprocessing};
\node (clean) [process, right=of preproc, yshift=-\double, node distance=\spalte] {Preprocessing};

% Draw edges
\draw [arrow] (init) -- (preproc);
\draw [arrow] (preproc) -| (shrink);
\draw [arrow] (preproc) -- (clean);

% additional line
\draw [red] (shrink.west) -- ++(-0.5,0) -- (preproc.east);
\end{tikzpicture}
\end{document}
Torbjørn T.
  • 206,688