我正在尝试使用 TikZ 树绘制一个扩展形式游戏的图表。以下代码在编译时生成错误。具体来说,它抱怨缺少$
's 和错误的数学分隔符。我仔细检查了括号,但找不到错误产生的位置。
\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{trees}
\begin{document}
\begin{tikzpicture}[%
%%% Styles
player/.style={draw,circle},
level 2/.style={sibling distance=10mm}
%every node/.style={node distance=1cm}
]
%%% Nodes
\node [player] (root) {1}
child { node [player] (2a) {2}
child { node (aa) {
\[ \begin{array}{c}
1 \\ 2
\end{array} \]}
edge from parent
node [left] {A}
}
child { node (ab) {
\[ \begin{array}{c}
3 \\ 4
\end{array} \]}
edge from parent
node [right] {B}
}
edge from parent
node [left] {A}
}
child { node [player] (2b) {2}
child { node (ba) {
\[ \begin{array}{c}
5 \\ 6
\end{array} \]}
edge from parent
node [left] {A}
}
child { node (bb) {
\[ \begin{array}{c}
7 \\ 8
\end{array} \]}
edge from parent
node [right] {B}
}
edge from parent
node [right] {B}
};
\end{tikzpicture}
\end{document}
相关错误日志输出如下
! Missing $ inserted.
<inserted text>
$
l.48 };
I've inserted a begin-math/end-math symbol since I think
you left one out. Proceed, with fingers crossed.
! Missing $ inserted.
<inserted text>
$
l.48 };
I've inserted something that you may have forgotten.
(See the <inserted text> above.)
With luck, this will get me unwedged. But if you
really didn't forget anything, try typing `2' now; then
my insertion and my current dilemma will both disappear.
! LaTeX Error: Bad math environment delimiter.
有人能解释一下是什么导致了这些错误吗?通常这不会是个问题,但我习惯rubber
从 进行编译org-mode
,而这些错误使它出错了。(texi2dvi
对于那些感兴趣的人来说,这些错误也会出错。)
答案1
使用$...$
而不是\[ ... \]
就可以编译。
即使通过 完成$$ ... $$
,显示的数学运算也无法直接在 TikZ 树节点中起作用。您可能不需要它。至于字体大小,您可以\displaystyle
在必要时使用。