软件包 tikz 错误:未知链“chain”

软件包 tikz 错误:未知链“chain”

我正在尝试编译 pgfmanual v3.0.1a (第 541 页) 第 46.2 节“启动和继续链条”中的第一个示例:

\begin{tikzpicture}[start chain]
% The chain is called just "chain"
\node [on chain] {A};
\node [on chain] {B};
\node [on chain] {C};
\end{tikzpicture}

我的代码是:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{chains}
\begin{document}

\begin{tikzpicture}
% Same as above, using the scope shorthand
{ [start chain=1]
\node [on chain] {A};
\node [on chain] {B};
\node [on chain] {C};
}
\end{tikzpicture}

\end{document}

错误信息如下:

! Package tikz Error: Unknown chain ``chain''.

See the tikz package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.9 \node [on chain]
                     {A};
? 
! Emergency stop.
 ...                                              

l.9 \node [on chain]
                     {A};
!  ==> Fatal error occurred, no output PDF file produced!
Transcript written on debug.log.

我的软件包版本

\documentclass{minimal}
\listfiles
\usepackage{tikz}
\usetikzlibrary{chains}
\begin{document}
\end{document}

tikz.sty    2015/08/07 v3.0.1a (rcs-revision 1.151)
 pgf.sty    2015/08/07 v3.0.1a (rcs-revision 1.15)

答案1

您错过了相关的库scopes(用于速记)。

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{chains,scopes}
\begin{document}

\begin{tikzpicture}
% Same as above, using the scope shorthand
{[start chain=1]
\node [on chain] {A};
\node [on chain] {B};
\node [on chain] {C};
}
\end{tikzpicture}

\end{document}

相关内容