Tikz 流程图中箭头的问题

Tikz 流程图中箭头的问题

我使用 Tikz 创建的流程图遇到了一点问题。我是 tikz 新手,我使用互联网上的示例创建了这个流程图。我在 Google 上搜索了箭头的定位方式,但找不到令人满意的答案。所以我的问题是,我想改变右侧两个箭头的方向。如果您查看代码或更好的结果,您就会明白我的意思。

\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}

答案1

您可以更改这两个节点的位置

\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$};

他们+(-3.0,-2.5)更早一些。

我也已经更改scale=0.7为,,x=0.675cm,y=0.6cm因为图片对我来说超出了页面范围。此外,建议将所有内容更改tikzstyletikzset

\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'}
}

完整代码(带旧代码\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}

在此处输入图片描述

相关内容