创建流程图时从 PGF 和 TikZ 包获取错误

创建流程图时从 PGF 和 TikZ 包获取错误

我需要将 (dec1) 和 (pro6) 很好地连接起来。当我编译代码时,我收到此错误“Package PGF Math Error: 您要求我计算 `1/0.0',但我无法将任何数字除以零。\path [line] (dec1) -| (pro6)”

有人能帮忙解决这个问题吗?谢谢。

\documentclass[journal]{IEEEtran}
\IEEEoverridecommandlockouts                             
\newcounter{ct}
\usepackage{multirow}
\usepackage{epstopdf}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows}  
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}
\usepackage{fp}

\begin{document}
\tikzstyle{startstop} = [rectangle, rounded corners, minimum width=3cm,   minimum height=1cm,text centered, draw=black, fill=red!30]
\tikzstyle{io} = [trapezium, trapezium left angle=70, trapezium right angle=110, text width=4cm, minimum height=1cm, text centered, draw=black, fill=blue!10]
\tikzstyle{process} = [rectangle, minimum width=3cm, minimum height=1cm,text width=6cm, text centered, draw=black, fill=blue!10]
\tikzstyle{decision} = [diamond, minimum width=2cm, minimum height=1.5cm,text width=3cm, text centered, draw=black, fill=blue!10,aspect=3]
\tikzstyle{arrow} = [thick,->,>=stealth]
\tikzstyle{line} = [draw, -latex']

\begin{center}

%\begin{frame}
\begin{tikzpicture}[node distance=1.5cm]

\node (in1) [io] {Load historical data available};
\node (pro1) [process, below of=in1] {Calculate };
\draw [arrow] (in1) -- (pro1);
\node (pro2) [process, below of=pro1] {Plug };
\draw [arrow] (pro1) -- (pro2);
\node (pro3) [process, below of=pro2] {Set   };
\draw [arrow] (pro2) -- (pro3);
\node (pro4) [process, below of=pro3] {Apply  };
\draw [arrow] (pro3) -- (pro4);
\node (pro5) [process, below of=pro4] {If  };
\draw [arrow] (pro4) -- (pro5);
\node (pro6) [process, below of=pro5] {Calculate };
\draw [arrow] (pro5) -- (pro6);
\node (pro7) [process, below of=pro6,yshift=-1em] {Plug  };
\draw [arrow] (pro6) -- (pro7);
\node (pro8) [process, below of=pro7,yshift=-1em] {gg};
\draw [arrow] (pro7) -- (pro8);
\node (dec1) [decision, below of=pro8,yshift=-1.1cm] {};
\draw [arrow] (pro8) -- (dec1);
\node (out1) [io, below of=dec1,yshift=-2em] {Release};
\draw [arrow] (dec1) -- node[anchor=east] {yes} (out1);
%\draw [-latex]  (dec1) -| (pro6) ;
%\path (dec1)   --++  (-3,0) node [near start] {no} |- (pro6);
\path [line] (dec1) -|  (pro6);
\end{tikzpicture}
%\end{frame}
\end{center}



\end{document}

答案1

问题是你告诉 TiZ 从一个节点到另一个节点画一条直线,从直线开始,然后在中间转 90°。这在数学上毫无意义,错误也很明显。似乎你强迫 PGF 将某个变量除以 0。我在下面为你的方法提出了一些解决方案。我希望我理解得没错。

% arara: pdflatex

\documentclass{IEEEtran}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows} 
\tikzset{%
    ,io/.style={%
        ,trapezium
        ,trapezium left angle=70,trapezium right angle=110
        ,text width=4cm
        ,minimum height=1cm
        ,text centered
        ,draw
        ,fill=blue!10
        }
    ,process/.style={%
        ,rectangle
        ,minimum width=3cm,minimum height=1cm
        ,text width=6cm
        ,text centered
        ,draw
        ,fill=blue!10
        }
    ,decision/.style={%
        ,diamond
        ,minimum width=2cm,minimum height=1.5cm
        ,text width=3cm
        ,text centered
        ,draw
        ,fill=blue!10
        ,aspect=3
        }
    ,arrow/.style={%
        ,thick
        ,->
        ,>=stealth
        }
    ,line/.style={%
        ,draw
        ,-latex'
        }
    }

\begin{document}
    \begin{tikzpicture}[node distance=1.5cm]        
        \node (in1) [io] {Load historical data available};
        \node (pro1) [process, below of=in1] {Calculate };
        \draw [arrow] (in1) -- (pro1);
        \node (pro2) [process, below of=pro1] {Plug };
        \draw [arrow] (pro1) -- (pro2);
        \node (pro3) [process, below of=pro2] {Set   };
        \draw [arrow] (pro2) -- (pro3);
        \node (pro4) [process, below of=pro3] {Apply  };
        \draw [arrow] (pro3) -- (pro4);
        \node (pro5) [process, below of=pro4] {If  };
        \draw [arrow] (pro4) -- (pro5);
        \node (pro6) [process, below of=pro5] {Calculate };
        \draw [arrow] (pro5) -- (pro6);
        \node (pro7) [process, below of=pro6,yshift=-1em] {Plug  };
        \draw [arrow] (pro6) -- (pro7);
        \node (pro8) [process, below of=pro7,yshift=-1em] {gg};
        \draw [arrow] (pro7) -- (pro8);
        \node (dec1) [decision, below of=pro8,yshift=-1.1cm] {};
        \draw [arrow] (pro8) -- (dec1);
        \node (out1) [io, below of=dec1,yshift=-2em] {Release};
        \draw [arrow] (dec1) -- node[anchor=east] {yes} (out1);
        \path [line] (dec1) -- ++(-4,0) |- (pro6);
    \end{tikzpicture}
\end{document}

答案2

问题是和的中心(dec1)(pro6)垂直对齐的,所以\path [line] (dec1) -| (pro6)没有意义。通过指定箭头应该在(pro6)直线的右侧部分结束,可以进行 90 度旋转,例如

\draw [line] (dec1) -| (pro6.east);

但这也不是你想要的,因为它从正下方接近盒子。因此,首先瞄准它右侧 2 厘米处的点,得到

\draw [line] (dec1) -| ($(pro6.east)+(2cm,0)$) -- (pro6);

我认为这更符合您的要求。要使用计算,您还必须添加 tikzlibrary calc

相关内容