2

I'm trying to diagram an extensive form game using TikZ trees. The following code generates errors at compile time. Specifically, it complains about missing $'s and a bad math delimiter. I've been over the brackets with a fine-tooth comb and I can't find where the error is being generated.

\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}

The relevant error log output looks like

! 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.

Can anyone explain what is causing these errors? It usually wouldn't be a problem, but I use rubber to compile from org-mode, and these errors are tripping it up. (These errors also trip up texi2dvi, for those interested.)

  • OK, so s/\[|\]/$/g seems to fix things with rubber. Does anyone know why arrays wouldn't play nice in displaymath environments? – jrhorn424 Mar 3 '11 at 17:09
  • 1
    jrhorn424: array works fine also in displaymath environments, but the latter not in nodes. How should they be centered and what would be the spacing before and after if they stand alone in a node? A parbox or minipage would fix it. – Stefan Kottwitz Mar 3 '11 at 20:23
5

Use $...$ instead of \[ ... \] and it can be compiled.

Displayed math, even if done by $$ ... $$, doesn't directly work in TikZ tree nodes. You probably dont't need it. Regarding the font size, you could use \displaystyle if necessary.

  • 4
    Or you can use \(…\) – Matsaya Mar 3 '11 at 17:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.