我正在尝试在 Beamer 中添加一个非常大的图表。但是,它返回
软件包 tikz 错误:放弃此路径。您忘记了分号吗?
这是我的代码的一小部分
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{arrows}
\tikzset{
treenode/.style = {align=center, inner sep=0pt, text centered,
font=\sffamily},
arn_n/.style = {treenode, circle,black, draw=black, text width=1.3em}%
}
\begin{document}
\begin{frame}
\frametitle{Paragraphs of Text}
$\bf{Step \ 0 }$
\begin{tikzpicture}[->,>=stealth',level distance = 2.5cm,
level 1/.style={sibling distance=5.75cm},
level 2/.style={sibling distance=1.95cm},
level 3/.style={sibling distance=0.6cm}]
\node [arn_n] {}
child{ node [arn_n] {}
child{ node [arn_n] {}
child{ node [arn_n] {} }
child{ node [arn_n] {}
}
child{ node [arn_n] {}
}
}
}
\end{tikzpicture}
\end{frame}
如何修复?
更新:我已经添加;但它仍然返回错误。
\begin{frame}
\frametitle{Paragraphs of Text}
\begin{tikzpicture}[->,>=stealth',level distance = 2.5cm,
level 1/.style={sibling distance=5.75cm},
level 2/.style={sibling distance=1.95cm},
level 3/.style={sibling distance=0.6cm}]
\node [arn_n] {}
child{ node [arn_n] {} ;
child{ node [arn_n] {}
child{ node [arn_n] {} };
child{ node [arn_n] {}
};
child{ node [arn_n] {}
};
};
};
\end{tikzpicture}
\end{frame}
缺少 $ 插入。$ l.137 \end{frame}
答案1
;
末尾只需要一个。错误来自{}
每个子元素不成对。也就是说,每个子元素必须有一个开头 { 和一个结尾 }。此外,适当的缩进有助于调试。实际上,使用下划线在这里不是问题,因为它是一个样式名称。
这里演示了 3 种情况,因为您定义了 3 个级别。
代码
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{arrows}
\tikzset{
treenode/.style = {align=center, inner sep=0pt, text centered,
font=\sffamily},
arn_n/.style = {treenode, circle,black, draw=black, text width=1.3em},%
level distance = 2.5cm,
level 1/.style={sibling distance=5.75cm},
level 2/.style={sibling distance=1.95cm},
level 3/.style={sibling distance=0.6cm}
}
\begin{document}
\begin{frame}
\frametitle{Paragraphs of Text}
$\bf{Step 0 }$\\
\begin{tikzpicture}[scale=0.5]
\node [arn_n] {0}
child{ node [arn_n] {1}
child{node [arn_n] {2}}
child{node [arn_n] {2}}
child{node [arn_n] {2}}
child{node [arn_n] {2}}};
\end{tikzpicture}
\begin{tikzpicture}[scale=0.5]
\node [arn_n] {0}
child{node [arn_n] {1}}
child{node [arn_n] {1}
child{node [arn_n] {2}}
child{node [arn_n] {2}}
child{node [arn_n] {2}}};
\end{tikzpicture}
\begin{tikzpicture}[scale=0.5]
\node [arn_n] {0}
child{node [arn_n] {1}}
child{node [arn_n] {1}
child{node [arn_n] {2}}
child{node [arn_n] {2}
child{node [arn_n]{3}}}};
\end{tikzpicture}
\end{frame}
\end{document}
答案2
至于您更新的示例,恐怕您插入了太多分号。您只需要在\node [arn_n] {} <all children>;
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{arrows}
\tikzset{
treenode/.style = {align=center, inner sep=0pt, text centered,
font=\sffamily},
arn_n/.style = {treenode, circle,black, draw=black, text width=1.3em}%
}
\begin{document}
\begin{frame}
\frametitle{Paragraphs of Text}
\begin{tikzpicture}[
->,
>=stealth',
level distance = 2.5cm,
level 1/.style={sibling distance=5.75cm},
level 2/.style={sibling distance=1.95cm},
level 3/.style={sibling distance=0.6cm}
]
\node [arn_n] {}
child{
node [arn_n] {}
child{ node [arn_n] {}
child{ node [arn_n] {} }
child{ node [arn_n] {} }
child{ node [arn_n] {} }
}
};
\end{tikzpicture}
\end{frame}
\end{document}
该答案经过编辑,纳入了以下信息@杰西的回答。所以请接受他的答案!