Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
    
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

1 Answer 1

up vote 4 down vote accepted

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.

share|improve this answer
3  
Or you can use \(…\) –  Matsaya Mar 3 '11 at 17:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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