tikz 链条断裂

tikz 链条断裂

我今天尝试使用 tikz 链功能,几个小时内一切都很顺利,但现在每次我尝试使用链时都会收到错误

./test.tex:7: Package pgfkeys Error: I do not know the key '/tikz/nonterminal' and I am going to ignore it. Perhaps you misspelled it. [    \node [nonterminal]]
./test.tex:8: Package pgfkeys Error: I do not know the key '/tikz/terminal' and I am going to ignore it. Perhaps you misspelled it. [    \node [terminal]]
./test.tex:9: Package pgfkeys Error: I do not know the key '/tikz/terminal' and I am going to ignore it. Perhaps you misspelled it. [    \node [terminal]]
./test.tex:10: Package pgfkeys Error: I do not know the key '/tikz/terminal' and I am going to ignore it. Perhaps you misspelled it. [    \node [terminal]]

以下是代码

\documentclass[a4paper]{memoir}
% Add packages
\usepackage{tikz}
\usetikzlibrary{chains}
\begin{document}
\begin{figure}
  \begin{tikzpicture}[start chain,node distance=5mm, every node/.style={on chain,join}, every join/.style={->}]
    \node [nonterminal]  {unsigned integer};
    \node [terminal]     {.};
    \node [terminal]     {digit};
    \node [terminal]     {E};
  \end{tikzpicture}
\end{figure}
\end{document}

关于如何修复链条,您有什么好主意吗?

答案1

正如 Qrrbrbirlbel(名字选得难写?:p)所说,您还没有定义您的terminalnonterminal样式。pgfkeys 错误暗示了这一点,因为它们抱怨tikz/nonterminaltikz/terminal是未知的。有时,TikZ如果您尝试使用tikzlibrary您应该加载的键usetikzlibrary,并且会这样说。

在 中,TIKZandPGF-manual样式是用 设置的,但在第 60 和 61 页的示例中,在选项 ( )tikzset中给出了样式。您还需要加载库才能生成。代码如下:tikzpicture[]shapes.miscrounded rectangle

\documentclass[a4paper]{memoir}
\usepackage{tikz}
\usetikzlibrary{chains, shapes.misc}
\tikzset{
    nonterminal/.style={
      rectangle,
      minimum size=6mm,
      very thick,
      draw=red!50!black!50,
      top color=white,
      bottom color=red!50!black!20,
      font=\itshape},
    terminal/.style={
      rounded rectangle,
      minimum size=6mm,
      very thick,draw=black!50,
      top color=white,bottom color=black!20,
      font=\ttfamily}
    }
\begin{document}
\begin{figure}
  \begin{tikzpicture}[start chain,node distance=5mm, every node/.style={on chain,join}, every join/.style={->}]
    \node [nonterminal]  {unsigned integer};
    \node [terminal]     {.};
    \node [terminal]     {digit};
    \node [terminal]     {E};
  \end{tikzpicture}
\end{figure}
\end{document}

产生输出

在此处输入图片描述

相关内容