![Tikz 和 Beamer 有问题](https://linux22.com/image/307994/Tikz%20%E5%92%8C%20Beamer%20%E6%9C%89%E9%97%AE%E9%A2%98.png)
因此,我尝试将一个功能正常的 tikz 图像插入到 beamer 项目中,但它一直出现错误。
\documentclass{beamer}
\usetheme{Warsaw}
\usepackage{tikz}
\usetikzlibrary{shapes,trees,positioning}
\begin{document}
\begin{frame}{Examples}
\begin{center}
\begin{tikzpicture}[level/.style={sibling distance=60mm/#1},minimum size=20pt,scale=.8,
every node/.style={transform shape}] % If you want to scale the picture insert ``scale=
(something), every node/.style={transform shape}'' Ex:[level/.style={sibling
distance=60mm/#1},minimum size=20pt,scale=.8, every node/.style={transform shape}] would
scale to 80% of original size
\node [circle,draw] (z){\textbf{$u$}}
child {node [circle,draw,fill=black,text=white] (a) {\textbf{$v$}}
child {node [circle,draw,fill=black,text=white] (c) {}}
child {node [circle,draw] (d) {}
}
}
child {node [circle,draw,fill=black,text=white] (b) {\textbf{$w$}}
child {node [circle,draw,fill=black,text=white] (e) {}}
child {node [circle,draw] (f) {}}
};
\end{tikzpicture}
\end{center}
\end{frame}
\end{document}
我不断收到的错误是:
./SDN Presentation.tex:61: Illegal parameter number in definition of \iterate.
<to be read again>
1
l.61 \end{frame}
如果我删除图片开头的 /#1,我会得到一张图像,但不是我想要的。不确定如何修复此问题,因为代码适用于 amsart 文档类。
答案1
您需要将fragile
选项传递给frame
环境以停止beamer
尝试解析不应该解析的内容。
\documentclass{beamer}
\usetheme{Warsaw}
\usepackage{tikz}
\usetikzlibrary{shapes,trees,positioning}
\begin{document}
\begin{frame}[fragile]{Examples}
\begin{center}
\begin{tikzpicture}[level/.style={sibling distance=60mm/#1},minimum size=20pt,scale=.8,
every node/.style={transform shape}] % If you want to scale the picture insert ``scale= (something), every node/.style={transform shape}'' Ex:[level/.style={sibling distance=60mm/#1},minimum size=20pt,scale=.8, every node/.style={transform shape}] would scale to 80% of original size
\node [circle,draw] (z){\textbf{$u$}}
child {node [circle,draw,fill=black,text=white] (a) {\textbf{$v$}}
child {node [circle,draw,fill=black,text=white] (c) {}}
child {node [circle,draw] (d) {}
}
}
child {node [circle,draw,fill=black,text=white] (b) {\textbf{$w$}}
child {node [circle,draw,fill=black,text=white] (e) {}}
child {node [circle,draw] (f) {}}
};
\end{tikzpicture}
\end{center}
\end{frame}
\end{document}