Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I've got a little problem with a flow chart that I created using Tikz. I'm new with tikz and I created this flow chart using an example from the internet. I googled for how the positioning of the arrows works but I couldn't find satisfying answers. So my problem is, that I want to change the direction of the two arrows on the right side. If you look at the code or better the result you will see what I mean.

\documentclass[11pt]{article} 
\usepackage{tikz}   
\usetikzlibrary{shadows,arrows,positioning,shapes.geometric} 
% Define the layers to draw the diagram 
\pgfdeclarelayer{background} 
\pgfdeclarelayer{foreground} 
\pgfsetlayers{background,main,foreground}

\tikzstyle{TDK} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm, text centered, text width=4cm, draw=black, fill=red!30, drop shadow] 
\tikzstyle{CFX} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm, text centered, text width=4cm, draw=black, fill=blue!30, drop shadow] 
\tikzstyle{Matlab} = [trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm, minimum height=1cm, text centered, text width=4cm, draw=black, fill=orange!30, drop shadow] 
\tikzstyle{arrow} = [thick, ->, >=stealth] 
\tikzstyle{texto} = [above, text width=6em, text centered] 
\tikzstyle{linepart} = [draw, thick, color=black!50, -latex', dashed] 
\tikzstyle{line} = [draw, thick, color=black!50, -latex']

% Define distances for bordering 
\newcommand{\blockdist}{1.3} 
\newcommand{\edgedist}{1.5}

\newcommand{\etape}[2]{node (p#1) [etape] {#2}} 
\newcommand{\matlab}[2]{node (p#1) [Matlab] {#2}} 
\newcommand{\tdk}[2]{node (p#1) [TDK] {#2}} 
\newcommand{\cfx}[2]{node (p#1) [CFX] {#2}}

% Draw background 
\newcommand{\background}[5]{% 
\begin{pgfonlayer}{background} 
% Left-top corner of the background rectangle 
\path (#1.west |- #2.north)+(-0.5,0.25) node (a1) {}; 
% Right-bottom corner of the background rectanle 
\path (#3.east |- #4.south)+(+0.5,-0.25) node (a2) {}; 
% Draw the background 
\path[fill=yellow!20,rounded corners, draw=black!50, dashed] (a1) rectangle (a2); 
\path (#3.east |- #2.north)+(0,0.25)--(#1.west |- #2.north) node[midway] (#5-n) {}; 
\path (#3.east |- #2.south)+(0,-0.35)--(#1.west |- #2.south) node[midway] (#5-s) {}; 
\path (#3.east |- #2.north)+(0.7,0)--(#3.east |- #4.south) node[midway] (#5-w) {}; 
\path (a1.east |- a1.south)+(1.3,-1.3) node (u1)[texto] {\textit{#5}}; 
\end{pgfonlayer}}

\newcommand{\transreceptor}[3]{% 
 \path [linepart] (#1.east) -- node [above] 
  {\scriptsize #2} (#3);}

\begin{document}

\begin{tikzpicture}[node distance=2cm,scale=0.7] 
\path \tdk{1}{TDK 2D Düsenströmung mit Reaktionskinetik}; 
\path (p1.south)+(0.0,-2.0)\matlab{2}{Matlab Konvertierung von Wärmestromverlauf $\dot{q}_w$}; 
\path (p2.east)+(5.0,0.0) \cfx{3}{Ansys CFX 3D Kühlkanalströmung}; 
\path (p3.east)+(5.0,0.0) \tdk{4}{TDK 2D Düsenströmung mit Reaktionskinetik}; 
\path (p4.north)+(-3.0,2.5) \matlab{5}{Matlab Konvertierung von Wärmestromverlauf $\dot{q}_w$}; 
\path (p4.south)+(-3.0,-2.5) \matlab{6}{Matlab Konvertierung von Wärmestromverlauf $\dot{q}_w$};

\path [line] (p1.south) -- node [above] {} (p2); 
\path [line] (p2.east) -- node [above] {} (p3); 
\path [line] (p3.south) |- node [above] {} (p6); 
\path [line] (p4.north) |- node [below] {} (p5); 
\path [line] (p6.east) -| node [above] {} (p4); 
\path [line] (p5.west) -| node [above] {} (p3); 

\background{p3}{p5}{p4}{p6}{Iterationen in Matlab} 

\end{tikzpicture}

\end{document}
share|improve this question
    
I tried to compile your code but it failed with an error. Could you please strip it down to a minimal working example (MWE)? –  Benedikt Bauer Apr 8 at 8:55
    
sorry, now it should be working –  Adrian Pfeifle Apr 8 at 9:07

1 Answer 1

up vote 10 down vote accepted

You can change the position of these two nodes

\path (p4.north)+(-4.5,2.5) \matlab{5}{Matlab Konvertierung von Wärmestromverlauf $\dot{q}_w$};
\path (p4.south)+(-4.5,-2.5) \matlab{6}{Matlab Konvertierung von Wärmestromverlauf $\dot{q}_w$};

They were +(-3.0,-2.5) earlier.

Also I have changed scale=0.7 to ,x=0.675cm,y=0.6cm as the picture was going out of the page for me. Further, it is advised to change all tikzstyle to tikzset like

\tikzset{
    TDK/.style = {rectangle, rounded corners, minimum width=3cm, minimum height=1cm, text centered, text 
            width=4cm, draw=black, fill=red!30, drop shadow},
    CFX/.style = {rectangle, rounded corners, minimum width=3cm, minimum height=1cm, text centered, text
             width=4cm, draw=black, fill=blue!30, drop shadow},
    Matlab/.stle = {trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm,
             minimum height=1cm, text centered, text width=4cm, draw=black, fill=orange!30, drop shadow},
    arrow/.style = {thick, ->, >=stealth},
    texto/.style = {above, text width=6em, text centered},
    linepart/.style = {draw, thick, color=black!50, -latex', dashed},
    line/.style = {draw, thick, color=black!50, -latex'}
}

Full code (with old \tikzstyle)

\documentclass[11pt]{article}
\usepackage{tikz} \usetikzlibrary{shadows,arrows,positioning,shapes.geometric} % Define the layers to draw the diagram
\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}

\tikzstyle{TDK} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm, text centered, text width=4cm, draw=black, fill=red!30, drop shadow]
\tikzstyle{CFX} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm, text centered, text width=4cm, draw=black, fill=blue!30, drop shadow]
\tikzstyle{Matlab} = [trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm, minimum height=1cm, text centered, text width=4cm, draw=black, fill=orange!30, drop shadow]
\tikzstyle{arrow} = [thick, ->, >=stealth]
\tikzstyle{texto} = [above, text width=6em, text centered]
\tikzstyle{linepart} = [draw, thick, color=black!50, -latex', dashed] \tikzstyle{line} = [draw, thick, color=black!50, -latex']

% Define distances for bordering \newcommand{\blockdist}{1.3} \newcommand{\edgedist}{1.5}

\newcommand{\etape}[2]{node (p#1) [etape] {#2}}
\newcommand{\matlab}[2]{node (p#1) [Matlab] {#2}}
\newcommand{\tdk}[2]{node (p#1) [TDK] {#2}}
\newcommand{\cfx}[2]{node (p#1) [CFX] {#2}}

% Draw background
\newcommand{\background}[5]{%
\begin{pgfonlayer}{background} % Left-top corner of the background rectangle 
\path (#1.west |- #2.north)+(-0.5,0.25) node (a1) {};
% Right-bottom corner of the background rectanle
\path (#3.east |- #4.south)+(+0.5,-0.25) node (a2) {}; % Draw the background
\path[fill=yellow!20,rounded corners, draw=black!50, dashed] (a1) rectangle (a2);
\path (#3.east |- #2.north)+(0,0.25)--(#1.west |- #2.north) node[midway] (#5-n) {};
\path (#3.east |- #2.south)+(0,-0.35)--(#1.west |- #2.south) node[midway] (#5-s) {};
\path (#3.east |- #2.north)+(0.7,0)--(#3.east |- #4.south) node[midway] (#5-w) {};
\path (a1.east |- a1.south)+(1.3,-1.3) node (u1)[texto] {\textit{#5}}; \end{pgfonlayer}}

\newcommand{\transreceptor}[3]{% 
\path [linepart] (#1.east) -- node [above] {\scriptsize #2} (#3);}

\begin{document}
\noindent
\begin{tikzpicture}[node distance=2cm,x=0.675cm,y=0.6cm]
\path \tdk{1}{TDK 2D Düsenströmung mit Reaktionskinetik};
\path (p1.south)+(0.0,-2.0)\matlab{2}{Matlab Konvertierung von Wärmestromverlauf $\dot{q}_w$}; 
\path (p2.east)+(5.0,0.0) \cfx{3}{Ansys CFX 3D Kühlkanalströmung};
\path (p3.east)+(6.0,0.0) \tdk{4}{TDK 2D Düsenströmung mit Reaktionskinetik}; 
\path (p4.north)+(-4.5,2.5) \matlab{5}{Matlab Konvertierung von Wärmestromverlauf $\dot{q}_w$};
\path (p4.south)+(-4.5,-2.5) \matlab{6}{Matlab Konvertierung von Wärmestromverlauf $\dot{q}_w$};

\path [line] (p1.south) -- node [above] {} (p2);
\path [line] (p2.east) -- node [above] {} (p3); \path [line] (p3.south) |- node [above] {} (p6);
\path [line] (p4.north) |- node [below] {} (p5);
\path [line] (p6.east) -| node [above] {} (p4);
\path [line] (p5.west) -| node [above] {} (p3);

\background{p3}{p5}{p4}{p6}{Iterationen in Matlab}

\end{tikzpicture}

\end{document}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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