# [Tex/LaTex] Trying to create a simple binomial tree in beamer

beamertikz-trees

Following the example in
"Single ampersand used with wrong catcode" error using tikz matrix in beamer
I removed the errors I got but the tree is still not produced correctly.
I am trying to reproduce in beamer what I saw in this thread:
http://www.latex-community.org/forum/viewtopic.php?f=45&t=7846&sid=2129f08cf0ff8d6a5473794a64bdf5ac

\documentclass[xcolor=pdflatex,dvipsnames,table]{beamer}

\usepackage{tikz}
\usetikzlibrary{matrix}

\mode<presentation>

\usetheme{JuanLesPins}

\setbeamercovered{transparent=30}

\title[Investment Science II]{ Investment Science II \\  Introduction to Binomial Trees }
\author[ Anonymous]

{ Investment Science II }

\institute{ Blah University }

\begin{document}

\frame{\maketitle}

\begin{frame}

\begin{tikzpicture}

\matrix (tree) [matrix of nodes,ampersand replacement=\&]

{
\&   \& F \\

\& C \&   \\

\$A \& \& E \\ \& B \& \\ \& \& D \\ }; \draw[->] (tree-3-1) -- (tree-2-2) node [midway,above] {$p$}; \draw[->] (tree-3-1) -- (tree-4-2) node [midway,below] {$(1-p)$}; \draw[->] (tree-2-2) -- (tree-1-3) node [midway,above] {$p^2$}; \draw[->] (tree-2-2) -- (tree-3-3) node [midway,below] {$(1-p)p$}; \draw[->] (tree-4-2) -- (tree-3-3) node [midway,above] {$(1-p)p$}; \draw[->] (tree-4-2) -- (tree-5-3) node [midway,below] {$(1-p)^2$}; \end{tikzpicture} \end{frame} \end{document}  #### Best Answer You have too much empty lines in your code. Empty lines cause paragraph breaks. Remove at least the empty lines after author and after beginning the matrix. Better more. It's not produced correctly, because you forgot to specify node size, column sep and row sep. This works correctly: \documentclass[xcolor=pdflatex,dvipsnames,table]{beamer} \usepackage{tikz} \usetikzlibrary{matrix} \mode<presentation> \usetheme{JuanLesPins} \setbeamercovered{transparent=30} \title[Investment Science II]{ Investment Science II \\ Introduction to Binomial Trees } \author[ Anonymous]{ Investment Science II } \institute{ Blah University } \begin{document} \frame{\maketitle} \begin{frame} \begin{tikzpicture}[>=stealth,sloped] \matrix (tree) [% matrix of nodes, minimum size=1cm, column sep=3.5cm, row sep=1cm,ampersand replacement=\& ] { \& \& F \\ \& C \& \\ \$A \&   \& E \\
\& B \&   \\
\&   \& D \\
};
\draw[->] (tree-3-1) -- (tree-2-2) node [midway,above] {$P$};
\draw[->] (tree-3-1) -- (tree-4-2) node [midway,below] {$(1-p)$};
\draw[->] (tree-2-2) -- (tree-1-3) node [midway,above] {$P^2$};
\draw[->] (tree-2-2) -- (tree-3-3) node [midway,below] {$(1-p)p$};
\draw[->] (tree-4-2) -- (tree-3-3) node [midway,above] {$(1-p)p$};
\draw[->] (tree-4-2) -- (tree-5-3) node [midway,below] {$(1-p)^2$};
\end{tikzpicture}
\end{frame}
\end{document}