TIKZ 流程图编译时错误

TIKZ 流程图编译时错误

请参阅 MWE。不知道为什么它不工作,错误说

“抱歉,您的编译耗时过长,已超时。这可能是由于包含大量高分辨率图像或复杂图表。”

但是,这不是一个很大的流程图,所以任何建议/解释为什么会发生这种情况。

谢谢

山姆

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows}

\begin{document}

\begin{center}
\begin{tikzpicture}[node distance=2cm]
\node (start) [startstop] {Start};
\node (in1) [io, right of=start, xshift=4cm] {Input};
\node (dec1) [decision, below of=start] {Is $t< \epsilon$};
\node (pro1) [process, below of=dec1] {Predict Price Data};
\node (pro2) [process, below of=pro1] {Solve Optimisation Problem};
\node (out1) [io, below of=pro2] {Output $A_i$};
\node (out2) [io, right of =out1] {Output `ERROR'};
\node (dec2) [decision, right of =dec1, xshift=4cm] {Is $t= \epsilon$};
\node (stop) [startstop, below of=out1] {Stop};

\draw [arrow] (start) -- (dec1);
\draw [arrow] (in1) -- (dec1);
\draw [arrow] (dec1) -- node[anchor=east] {No} (dec2);
\draw [arrow] (dec1) -- node[anchor=south] {Yes} (pro1);
\draw [arrow] (dec2) -- node[anchor=east] {No} (out2);
\draw [arrow] (dec2) -- node[anchor=south] {Yes} (stop);
\draw [arrow] (pro1) -- (pro2)
\draw [arrow] (pro2) -- (out1)
\draw [arrow] (out1) -- (dec1)

\end{tikzpicture}
\end{center}

\end{document}

答案1

除了 @Zarko 和 @CarLateX 提到的事情之外,您可能会受益于加载定位库并以不同方式放置 Yes/No 节点,以及公开你的风格的来源

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows,positioning}

\begin{document}
\tikzset{startstop/.style={rectangle, text width=3cm, minimum   height=1cm,text centered, draw=black, fill=red!30},
 io/.style={trapezium, trapezium left angle=70, trapezium right 
   angle=110, text width=3cm, minimum height=1cm, text centered, draw=black, fill=blue!30},
 process/.style={rectangle, text width=3cm, minimum height=1cm,    text centered, draw=black, fill=orange!30},
 decision/.style={diamond, text width=3cm, minimum height=1cm, text centered, draw=black, fill=green!30},
 arrow/.style={thick,-stealth}}

\begin{center}
\begin{tikzpicture}[node distance=2cm]
\node (start) [startstop] {Start};
\node (in1) [io, right=3cm of start] {Input};
\node (dec1) [decision, below=of start] {Is $t< \epsilon$};
\node (pro1) [process, below=of dec1] {Predict Price Data};
\node (pro2) [process, below=of pro1] {Solve Optimisation Problem};
\node (out1) [io, below=of pro2] {Output $A_i$};
\node (out2) [io, right=of out1] {Output `ERROR'};
\node (dec2) [decision, right of =dec1, xshift=4cm] {Is $t= \epsilon$};
\node (stop) [startstop, below right=2cm and 2cm of out1] {Stop};

\draw [arrow] (start) -- (dec1);
\draw [arrow] (in1) -- (dec1);
\draw [arrow] (dec1) --(dec2)  node[midway,above] {No} ;
\draw [arrow] (dec1) -- (pro1) node[midway,left] {Yes};
\draw [arrow] (dec2) --  (out2) node[midway,right] {No};
\draw [arrow] (dec2) --  (stop) node[midway,left] {Yes};
\draw [arrow] (pro1) -- (pro2);
\draw [arrow] (pro2) -- (out1);
\draw [arrow] (out1.west) -- ++(-1cm,0) |- (dec1);
\end{tikzpicture}
\end{center}

在此处输入图片描述

答案2

大部分都是题外话(问题通过评论解决,土拨鼠答案)...因为我从来没有见过这样的流程图,所以让我建议一下,我将如何绘制它:

在此处输入图片描述

(代码基于我对类似问题的回答)

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                chains,
                positioning,
                quotes,
                shapes.geometric}
\tikzset{FlowChart/.style={
     base/.style = {draw,
                    minimum height=1cm, minimum width=3cm,
                    text width =\pgfkeysvalueof{/pgf/minimum width}-2*\pgfkeysvalueof{/pgf/inner xsep},
                    align=center, outer sep=0pt,
                    on chain, join=by arrow},
startstop/.style = {base, fill=red!30},
  process/.style = {base, rounded corners, fill=orange!30},
 decision/.style = {diamond, aspect=1.3,
                    draw, minimum height=1cm, minimum width=2cm, align=center,
                    on chain, join=by arrow,
                    fill=green!30},
       io/.style = {base, trapezium, trapezium stretches body,
                    trapezium left angle=70, trapezium right angle=110,
                    fill=blue!30},
    arrow/.style = {semithick, -Triangle}
        }   }
\makeatletter
\tikzset{suspend join/.code={\def\tikz@after@path{}}}
\makeatother

\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{1em}

\begin{document}
    \begin{center}
\begin{tikzpicture}[FlowChart,
node distance = 5mm and 12mm,
  start chain = going below
                    ]
\node (start)   [startstop] {Start};
\node (in1)     [io]        {Input};
\node (dec1)    [decision]  {Is\\ $t< \epsilon$};
\node (pro1)    [process]   {Predict Price Data};
\node (pro2)    [process]   {Solve Optimisation Problem};
\node (out1)    [io] {Output $A_i$};
\node (dec2)    [decision, suspend join,
                 right=of dec1 -| start.east] {Is\\ $t= \epsilon$};
\node (out2)    [io,
                 below=of pro2.south -| dec2] {Output `ERROR'};
\node (stop)    [startstop, suspend join,
                 right=of out2] {Stop};
\path           (dec1) to ["No"] (pro1);
\path           (dec2) to ["No"] (out2);
\draw [arrow]   (dec1) to ["Yes"] (dec2);
\draw [arrow]   (dec2) to ["Yes"] (dec2 -| stop) -- (stop);
% \draw [arrow]   (out1.west) -- ++ (-1,0) |- (dec1); % it is illogical ...
\end{tikzpicture}
    \end{center}
\end{document}

编译报告:错误:0 警告:0 坏框:0

相关内容