# Vertical line in middle of a binomial tree (lattice)

This is a really tough problem that I have no idea how to solve. I wish to have a dotted veritcal line in the middle of my binomial tree, with a $\tau$ underneath.. The kind of thing I want is as follows:

The code for the image WITHOUT this line (or the associated \tau) is as follows:

 \documentclass{article}

\usepackage{tikz}
\usetikzlibrary{matrix,fit,backgrounds}

\begin{document}

\begin{tikzpicture}[>=stealth,sloped]
\matrix (tree) [%
matrix of nodes,
minimum size=1cm,
column sep=2.5cm,
row sep=0.4cm,
]
{
&                    &                     &  $_\tau S_0$             \\
&                    &  $_{2\Delta t}S_0$  &                  \\
& $_{\Delta t}S_0$   &                     &  $_\tau S_1$             \\
$_0S_0$ &                    &  $_{2\Delta t}S_1$  &                  \\
& $_{\Delta t}S_1$   &                      &  $_\tau S_2$         \\
&                    &  $_{2\Delta t}S_2$  &                \\
&                    &                     &  $_\tau S_3$    \\
};

\draw[->] (tree-4-1) -- (tree-3-2) node [midway,above] {$p$};
\draw[->] (tree-4-1) -- (tree-5-2) node [midway,below] {$1-p$};
\draw[->] (tree-3-2) -- (tree-2-3) node [midway,above] {};
\draw[->] (tree-3-2) -- (tree-4-3) node [midway,below] {};
\draw[->] (tree-5-2) -- (tree-4-3) node [midway,above] {};
\draw[->] (tree-5-2) -- (tree-6-3) node [midway,below] {};

\draw[->] (tree-2-3) -- (tree-1-4) node [midway,above] {};
\draw[->] (tree-2-3) -- (tree-3-4) node [midway,below] {};
\draw[->] (tree-4-3) -- (tree-3-4) node [midway,above] {};
\draw[->] (tree-4-3) -- (tree-5-4) node [midway,below] {};
\draw[->] (tree-6-3) -- (tree-5-4) node [midway,above] {};
\draw[->] (tree-6-3) -- (tree-7-4) node [midway,below] {};

\end{tikzpicture}

\end{document}

-
Notice that you could use math of matrix nodes and avoid some $ inside the matrix. – Claudio Fiandrino Sep 8 '12 at 13:02 ## 2 Answers The calc library makes this an easy task, but you have to assign names to empty matrix cells: \usetikzlibrary{calc} \begin{tikzpicture}[>=stealth,sloped] \matrix (tree) [% matrix of nodes, minimum size=1cm, column sep=2.5cm, row sep=0.4cm, ] { & |(top-left)| & |(top-right)| &$_\tau S_0$\\ & &$_{2\Delta t}S_0$& \\ &$_{\Delta t}S_0$& &$_\tau S_1$\\$_0S_0$& &$_{2\Delta t}S_1$& \\ &$_{\Delta t}S_1$& &$_\tau S_2$\\ & &$_{2\Delta t}S_2$& \\ & |(bottom-left)| & |(bottom-right)| &$_\tau S_3$\\ }; \draw[->] (tree-4-1) -- (tree-3-2) node [midway,above] {$p$}; \draw[->] (tree-4-1) -- (tree-5-2) node [midway,below] {$1-p$}; \draw[->] (tree-3-2) -- (tree-2-3) node [midway,above] {}; \draw[->] (tree-3-2) -- (tree-4-3) node [midway,below] {}; \draw[->] (tree-5-2) -- (tree-4-3) node [midway,above] {}; \draw[->] (tree-5-2) -- (tree-6-3) node [midway,below] {}; \draw[->] (tree-2-3) -- (tree-1-4) node [midway,above] {}; \draw[->] (tree-2-3) -- (tree-3-4) node [midway,below] {}; \draw[->] (tree-4-3) -- (tree-3-4) node [midway,above] {}; \draw[->] (tree-4-3) -- (tree-5-4) node [midway,below] {}; \draw[->] (tree-6-3) -- (tree-5-4) node [midway,above] {}; \draw[->] (tree-6-3) -- (tree-7-4) node [midway,below] {}; % τ-line \draw[dashed] ($(top-left.north)!.5!(top-right.north)$) -- ($(bottom-left.south)!.5!(bottom-right.south)$); \node at ($(bottom-left.south)!.5!(bottom-right.south)-(0,1em)$) {$\tau$}; \end{tikzpicture}  - I think you're missing some $ signs in the last few lines of your code which means I can't run it. – user16208 Sep 8 '12 at 12:59
@IssacM: yeah, I forgot to delimit the calc expressions. Fixed now (also added names to empty cells) – knittl Sep 8 '12 at 13:05

You can use orthogonal intersections via |- and -| coordinate qualifiers.

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{matrix,fit,backgrounds}

\begin{document}

\begin{tikzpicture}[>=stealth,sloped]
\matrix (tree) [%
matrix of nodes,
minimum size=1cm,
column sep=2.5cm,
row sep=0.4cm,
]
{
&                    &                     &  $_\tau S_0$             \\
&                    &  $_{2\Delta t}S_0$  &                  \\
& $_{\Delta t}S_0$   &                     &  $_\tau S_1$             \\
$_0S_0$ &                    &  $_{2\Delta t}S_1$  &                  \\
& $_{\Delta t}S_1$   &                      &  $_\tau S_2$         \\
&                    &  $_{2\Delta t}S_2$  &                \\
&                    &                     &  $_\tau S_3$    \\
};

\draw[->] (tree-4-1) -- (tree-3-2) node [midway,above] {$p$};
\draw[->] (tree-4-1) -- (tree-5-2) node [midway,below] {$1-p$};
\draw[->] (tree-3-2) -- (tree-2-3) node [midway,above] (a) {};
\draw[->] (tree-3-2) -- (tree-4-3) node [midway,below] {};
\draw[->] (tree-5-2) -- (tree-4-3) node [midway,above] {};
\draw[->] (tree-5-2) -- (tree-6-3) node [midway,below] {};

\draw[->] (tree-2-3) -- (tree-1-4) node [midway,above] {};
\draw[->] (tree-2-3) -- (tree-3-4) node [midway,below] {};
\draw[->] (tree-4-3) -- (tree-3-4) node [midway,above] {};
\draw[->] (tree-4-3) -- (tree-5-4) node [midway,below] {};
\draw[->] (tree-6-3) -- (tree-5-4) node [midway,above] {};
\draw[->] (tree-6-3) -- (tree-7-4) node [midway,below] {};

\draw[dashed] (tree-7-4 -| a) -- (tree-1-4 -| a);
\end{tikzpicture}

\end{document}


-
This is good! (+1) Had I only known this a while back, when I needed this myself. I used the calc library instead to achieve the same effect – knittl Sep 8 '12 at 13:13
@knittl Thanks. I would also suggest you to use nodes in empty cells option to populate the names of the empty entries in your solution. Then regular (matrixname-row-col) naming works also for the empty cells. – percusse Sep 8 '12 at 13:16
Yeah, but nodes in empty cells often has side effects (i.e. when you apply a style to all cells). I'm sure there's a way round it, I just don't know it … – knittl Sep 8 '12 at 13:18
@knittl Indeed, the relevant key is the execute at empty cell :) You can check in the manual to override the settings for empty cells – percusse Sep 8 '12 at 13:19