TeX 容量超出,抱歉 [输入堆栈大小=10000] 错误

TeX 容量超出,抱歉 [输入堆栈大小=10000] 错误

我正在尝试制作流程图。我遇到了一个对我来说很奇怪的错误。我想要的是,当我有“if”条件时,我需要绘制一个菱形,但是当我将“if”条件的形状更改为菱形时,它会抛出此错误“TeX 容量超出,抱歉 [输入堆栈大小=10000]”。当我将其更改为矩形时,它会绘制它。任何帮助都将不胜感激。这是我的代码:

\begin{tikzpicture}[  node distance=2cm,  rect/.style={    draw,    rectangle,    minimum width=3cm,    minimum height=1.5cm,    text centered  },  rectfilled/.style={    rect,    fill=gray!30  },  diamond/.style={    draw,    diamond,    minimum width=1cm,    minimum height=1.5cm, draw=cyan,   text centered  },  arrow/.style={    ->,    very thick,    >=stealth  }]
  \node (start) [rectfilled] {Start};
  \node (input) [rect, below of=start] {Input};
  \node (process1) [rect, below of=input] {Process 1};
  \node (decision) [diamond, below of=process1] {Decision};
  \node (process2a) [rectfilled, below left of=decision, xshift=-4cm] {Process 2a};
  \node (process2b) [rect, below right of=decision, xshift=4cm] {Process 2b};
  \node (output) [rect, below of=process2a] {Output};
  \node (stop) [rectfilled, below of=output] {Stop};
  \draw [arrow] (start) -- (input);
  \draw [arrow] (input) -- (process1);
  \draw [arrow] (process1) -- (decision);
  \draw [arrow] (decision) -- node[anchor=east] {Yes} (process2a);
  \draw [arrow] (decision) -- node[anchor=west] {No} (process2b);
  \draw [arrow] (process2a) -- (output);
  \draw [arrow] (process2b) |- (output);
  \draw [arrow] (output) -- (stop);
\end{tikzpicture}

答案1

diamond是保留字,已用作 Tikz 中形状的名称。

替换diamond/.style为 例如,并通过替换来diamondstyle/.style使用它。\node (decision)diamonddiamondstyle

我还删除了钻石样式中的第一个draw,因为它已被取代draw=cyan

我已经用 替换了anchor=eastanchor=west因此anchor=south“是”和“否”文本不在线上,而是略微靠上一点。

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes}
\begin{document}
\begin{tikzpicture}[
node distance=2cm,  
rect/.style={draw, rectangle, minimum width=3cm, minimum height=1.5cm, text centered},  
rectfilled/.style={rect, fill=gray!30},
diamondshape/.style={
diamond, minimum width=1cm, minimum height=1.5cm, draw=cyan, text centered  
},  
arrow/.style={->, very thick, >=stealth}
]
\node (start) [rectfilled] {Start};
\node (input) [rect, below of=start] {Input};
\node (process1) [rect, below of=input] {Process 1};
\node (decision) [diamondshape, below of=process1] {Decision};
\node (process2a) [rectfilled, below left of=decision, xshift=-4cm] {Process 2a};
\node (process2b) [rect, below right of=decision, xshift=4cm] {Process 2b};
\node (output) [rect, below of=process2a] {Output};
\node (stop) [rectfilled, below of=output] {Stop};
\draw [arrow] (start) -- (input);
\draw [arrow] (input) -- (process1);
\draw [arrow] (process1) -- (decision);
\draw [arrow] (decision) -- node[anchor=south] {Yes} (process2a);
\draw [arrow] (decision) -- node[anchor=south] {No} (process2b);
\draw [arrow] (process2a) -- (output);
\draw [arrow] (process2b) |- (output);
\draw [arrow] (output) -- (stop);
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容