1

HELP ! I am a beginner on LateX and I would like to reproduce this tree by adding the red color on point A and the blue color on the highest point of the tree by enlarging the size of these particular points. Attached is what I have done so far. I thank you in advance for your help. Good day to all !

    \tikzset{pics/arrow/.style={/tikz/sloped, /tikz/allow upside down,code=\pgfarrowdraw{#1}}, pics/arrow/.default=>}
    \begin{tikzcd}[
    dot/.style={circle, fill, draw, inner sep=+0pt, minimum size=+3.5pt,
    /utils/exec=\ifnum\pgfmatrixcurrentcolumn<4 \rar\arrow[ur]\arrow[dr]\fi},
    /tikz/reddot/.style ={circle, fill=red, minimum size=+12.5pt},
    /tikz/bluedot/.style ={circle, fill=blue, minimum size=+12.5pt},
    /tikz/a/.style ={commutative diagrams/dot, label={above:{#1}}},
    /tikz/ar/.style ={commutative diagrams/dot, label={[xshift=+10pt]above:{#1}}},
    /tikz/al/.style ={commutative diagrams/dot, label={[xshift=-10pt]above:{#1}}},
    /tikz/arr/.style ={commutative diagrams/dot, label={[xshift=+25pt]above:{#1}}},
    /tikz/bb/.style ={commutative diagrams/dot, label={[align=center]below:{#1\\ }}},
    /tikz/b/.style={commutative diagrams/dot, label={below:{#1}}},
    /tikz/bl/.style={commutative diagrams/dot, label={[xshift=-10pt]below:{#1}}},
    /tikz/br/.style={commutative diagrams/dot, label={[xshift=+10pt]below:{#1}}},
    /tikz/brrr/.style={commutative diagrams/dot, label={[xshift=+40pt]below:{#1}}},
    /tikz/bbl/.style={commutative diagrams/dot, label={[align=center, xshift=-10pt]below:{#1\\ }}},
    /tikz/bbr/.style={commutative diagrams/dot, label={[align=center, xshift=+10pt]below:{#1\\ }}},
    /tikz/bbrrr/.style={commutative diagrams/dot, label={[align=center, xshift=+40pt]below:{#1\\ }}},
    /tikz/l/.style={commutative diagrams/dot, label={ left:{#1}}},
    /tikz/r/.style={commutative diagrams/dot, label={right:{#1}}},
    arrows={-Stealth},column sep={3cm,between origins}, row sep={1.33cm,between origins},cells={nodes={fill, circle, minimum size=3.5pt, inner sep=0pt, font=\large}}]
                &   &   & |[bluedot, ar=70.00, br=70.00, bbr=0.00]| \\
                &   & |[a=62.99, b=62.99, bb=3.36]|\arrow[ur]\arrow[dr] &  \\
                & |[a=56.12, b=56.12, bb=4.68]|\arrow[ur]\arrow[dr] &   & |[arr=56.12, br=62.99, bbr=6.87,brrr=56.12, bbrrr=0.00]| \\
        |[al=50.00, bl=50.00, bbl=5.47]|\arrow[ur]\arrow[dr] &  & |[reddot, a=50.00, bl=56.12, bbl=6.12, br=50.00, bbr=2.66]|\arrow[ur]\arrow[dr] & \\                            
                & |[a=44.55, b=50.00, bb=6.38]|\arrow[ur]\arrow[dr] &   & |[arr=44.55, br=56.12, bbr=11.57, brrr=50.00, bbrrr=5.45]| \\
                &   & |[a=39.69, b=50.00, bb=10.31]|\arrow[ur]\arrow[dr] &  \\
                &   &   & |[ar=35.36, br=50.00, bbr=14.64]|           
    \end{tikzcd} 

    \begin{tikzcd}[
    dot/.style={circle, fill, draw, inner sep=+0pt, minimum size=+3.5pt,
    /utils/exec=\ifnum\pgfmatrixcurrentcolumn<4 \rar\urar\drar\fi},
    /tikz/a/.style ={commutative diagrams/dot, label={above:{#1}}},
    /tikz/al/.style ={commutative diagrams/dot, label={[xshift=-10pt]above:{#1}}},
    /tikz/bb/.style ={commutative diagrams/dot, label={[align=center]below:{#1\\second line}}},
    /tikz/b/.style={commutative diagrams/dot, label={below:{#1}}},
    /tikz/bl/.style={commutative diagrams/dot, label={[xshift=-10pt]below:{#1}}},
    /tikz/bbl/.style ={commutative diagrams/dot, label={[align=center, xshift=-10pt]below:{#1\\second line}}},
    /tikz/bbr/.style={commutative diagrams/dot, label={[align=center]below right:{#1\\second line}}},
    /tikz/l/.style={commutative diagrams/dot, label={ left:{#1}}},
    /tikz/r/.style={commutative diagrams/dot, label={right:{#1}}},
    arrows={-Stealth},column sep={3cm,between origins}, row sep={1.33cm,between origins},cells={nodes={fill, circle, minimum size=3.5pt, inner sep=0pt, font=\large}}]
                &                                  &                                      & |[fill=blue,minimum size=12.5,"70.70" above right,"70.70" below right, "0.00" below right]| \\
                &                                  & |["62.99" above,"62.99" below, "3.36" below]|\arrow[ur]\arrow[dr] &  \\
                & |[a=56.12, b=56.12, bb=4.68]|\arrow[ur]\arrow[dr] &                                      & |["56.12" above right,"62.99" below left,"6.87" below left, "56.12" below right,"0.00" below right]| \\
        |[al=50.00, bl=50.00, bbl=5.47]|\arrow[ur]\arrow[dr] &             & |[fill=red,minimum size=12.5,"50.00" above,"56.12" below left,"6.12" below left, "50.00" below right,"2.66" below right]|\arrow[ur]\arrow[dr]      & \\                            
                & |["44.55" above,"50.00" below, "6.38" below]|\arrow[ur]\arrow[dr] &                                      & |["44.55" above right,"56.12" below left,"11.57" below left, "50.00" below right,"5.45" below right]| \\
                &                                  & |["39.69" above,"50.00" below, "10.31" below]|\arrow[ur]\arrow[dr] &  \\
                &                                  &                                      & |["35.36" above right,"50.00" below right, "14.64" below right]|           
\end{tikzcd}

american lookback pricing tree

6
  • I am a beginner on LateX and I would like to reproduce this tree by adding the red color on point A and the blue color on the highest point of the tree by enlarging the size of these particular points. Attached is what I have done so far. I thank you in advance for your help. Good day to all !
    – Arthur
    Commented May 4, 2023 at 9:32
  • 2
    Welcome to TeX.SX! You can always edit your question by clicking on the "Edit" button if you want to provide more information to it. Commented May 4, 2023 at 9:33
  • 1
    Welcome @Arthur. // I moved your comment to the question, as it's a good statement. So your comment is obsolete now :)
    – MS-SPO
    Commented May 4, 2023 at 9:34
  • See if tex.stackexchange.com/questions/565525/binomial-tree-using-tikz/… can help you. To the showed tree you can easy add labels and desired colors.
    – Zarko
    Commented May 4, 2023 at 11:46
  • 1
    What is your complete tex code? You have put only a fragment.
    – Sebastiano
    Commented May 4, 2023 at 19:47

3 Answers 3

2

Using the istgame package:

The enlarged color points are plotted using the tzplot package.

enter image description here

\documentclass{standalone} 

\usepackage{tzplot}   % for enlarged color points (\tzdot*)
\usepackage{istgame}  % to draw tree
\usepackage{makecell}

\begin{document}

\begin{istgame}[font=\scriptsize]
\setistgrowdirection'{east}
\setxtshowmidarrows<.95>
\xtShowMidArrows
\xtShowEndPoints
\xtdistance{40mm}{30mm}
\istroot(0)<180>{\makecell[r]{50.00\\50.00\\5.47}}
  \istb \istb \endist
\istroot(a1)(0-1)<90>{56.12}
  \istb \istb \endist
  \xtOwner(a1){\makecell[r]{56.12\\4.68}}[below=3pt]
\istroot(a2)(0-2)<90>{44.55}
  \istb \istb \endist
  \xtOwner(a2){\makecell[r]{50.00\\6.38}}[below]
\istroot(b1)(a1-1){62.99}
  \istb{}{\makecell[r]{70.0\\70.0\\0.0}}
  \istb{}{\makecell[c]{56.12\\
            62.99\quad 56.12\\
            \hphantom{0}6.87\quad \hphantom{0}0.00}
         }
  \endist
  \xtOwner(b1){\makecell[r]{62.99\\3.36}}[below]

\istroot(b2)(a1-2){50.00}
  \istb \istb \endist
  \xtOwner(b2){\makecell[r]{56.12\quad 50.00\\
               \hphantom{0}6.12\quad
               \hphantom{0}2.66}
              }[below=7pt]
\istroot(b3)(a2-1)<0>{\quad A}
  \istb \istb \endist
\istroot(b4)(a2-2){39.69}
  \istb{}{\makecell[c]{44.55\\
            56.12\quad 50.00\\
            11.57\quad \hphantom{0}5.47}
         }
  \istb{}{\makecell[r]{35.36\\50.00\\14.64}}
  \endist
  \xtOwner(b4){\makecell[r]{50.00\\10.31}}[below]

%% points using the "tzplot" package:
\tzdot*[red](b3)(5pt)    % red point,  size=5pt
\tzdot*[blue](b1-1)(5pt) % blue point, size=5pt

\end{istgame}

\end{document}
1

Adapting my similar answer, however instead of a bunch of keys that produce a various labels I'm using the quotes library which uses a very specifical “d label” (d as in direction?) is to be used which puts its content into a tabular environment.

The keys ^, v, < and > are setup so that they stand for above, below, left and right but their value specifies the number of columns in the tabular environment.

It's a bit messy with & acting as active version for the underlying TikZ matrix and also as the normal & (catcode 4), this works if ampersand replacement is not used.

The siunitx package doesn't like an active & either, I had to resort to the basic r column.


It's not clear what you mean by

the highest point of the tree

so I just made the A point red.

If you need one points to be bigger you can use minimum size just with that point and use a bigger value than 3.5pt (which is used here in the options of the tikzcd environment). Making a dot blue shouldn't be a problem either.

Code

\documentclass[tikz]{standalone}
\usetikzlibrary{cd, quotes}
\makeatletter
\def\amp@normal{&}{\catcode`\&=13 \gdef\makeactiveampersandnormal{\let&\amp@normal}}
\makeatother
\newcommand*\mc[1]{\multicolumn{2}{c}{#1}}
\tikzset{
  pics/arrow/.style={/tikz/sloped, /tikz/allow upside down, code=\pgfarrowdraw{#1}}, pics/arrow/.default=>,
  @create d label/n/.initial=1,
  quotes mean d label/.style={
    node quotes mean={
      label={[every d label,create d label shortcuts,##2]\makeactiveampersandnormal\setlength\tabcolsep{.5\tabcolsep}%
        \begin{tabular}{@{}*{\pgfkeysvalueof{/tikz/@create d label/n}}{r}@{}}##1\end{tabular}}}},
  create d label shortcuts/.style={
    ^/.style={label position=90, @create d label/n/.expanded={##1}},^/.default=\pgfkeysvalueof{/tikz/@create d label/n},
    v/.style={label position=-90,@create d label/n/.expanded={##1}},v/.default=\pgfkeysvalueof{/tikz/@create d label/n},
    </.style={label position=180,@create d label/n/.expanded={##1}},>/.default=\pgfkeysvalueof{/tikz/@create d label/n},
    >/.style={label position=0,  @create d label/n/.expanded={##1}},</.default=\pgfkeysvalueof{/tikz/@create d label/n}},
  every d label/.style={rectangle, inner sep=+0pt}}
\begin{document}
\begin{tikzcd}[
  /tikz/dot/.style={circle, fill, draw, inner sep=+0pt, minimum size=+3.5pt,
    /utils/exec=\ifnum\pgfmatrixcurrentcolumn<4 \urar\drar\fi},
  arrows={-, /tikz/every to/.append style={edge node={pic[pos=.95]{arrow=Stealth}}}},
  cells={nodes={dot, quotes mean d label}},
  column sep={3cm,between origins}, row sep={1.5cm,between origins},
  label distance=2ex,
]
  & & & |["70.00 \\ 70.00 \\ 0.00" >]| \\
  & & |["62.99" ^, "62.99 \\ 3.36" v]| \\
  & |["56.12" ^, "56.12 \\ 4.68" v]|
    & & |["\mc{56.12} \\ 62.99 & 56.12 \\ 6.87 & 0.00" >=2]| \\
|["50.00 \\ 50.00 \\ 5.47" <]|
  & & |["50.00"^, "56.12 & 50.00 \\ 6.12 & 2.66" {v=2, below=1ex}, label=right:A, red]| \\
  & |["44.55"^, "50.00 \\ 6.38" v]|
    & & |["\mc{44.55} \\ 56.12 & 50.00 \\ 11.57 & 5.45" >=2]| \\
  & & |["36.69"^, "50.00 \\ 10.31" v]| \\
  & & & |["33.36 \\ 50.00 \\ 14.65" >]|
\end{tikzcd}
\end{document}

Output

enter image description here

1

I think tikz-cd may not be the right tool for this. I suggest plain tikz. Here is one way to do this:

You can use the positioning library to place your nodes precisely so they will not be affected by the labels.

Setting the dot style with a color parameter can be done in a tikzset:

\tikzset{
    dot/.style={draw, #1, fill=#1, circle, inner sep=0pt, minimum size=4pt},
    dot/.default={black}
}

Then the code to place the nodes would look like this:

\begin{tikzpicture}[every node/.style={dot}, node distance=1cm and 3cm]
\node(A){};
\node[above right=of A](B1){};
\node[below right=of A](B2){};
\node[above right=of B1](C1){};
\node[below right=of B1, dot=red](C2){};
\node[below right=of B2](C3){};
\node[above right=of C1, dot=blue](D1){};
\node[below right=of C1](D2){};
\node[above right=of C3](D3){};
\node[below right=of C3](D4){};
\end{tikzpicture}

enter image description here

Next we can draw the arrows. You have a specific kind of arrow in your diagram. The shape is Stealth and it's not quite at the end of the line. You can do this using decorations.markings and arrows.meta. Add to your tikzset:

arrowmark/.style={postaction={decorate, decoration={markings, mark=at position .9 with {\arrow{Stealth}}}}}

Then the \draw command with option arrowmark can draw your arrows:

\draw[arrowmark](A)--(B1); \draw[arrowmark](A)--(B2);
\draw[arrowmark](B1)--(C1); \draw[arrowmark](B1)--(C2);
\draw[arrowmark](B2)--(C2); \draw[arrowmark](B2)--(C3);
\draw[arrowmark](C1)--(D1); \draw[arrowmark](C1)--(D2);
\draw[arrowmark](C2)--(D2); \draw[arrowmark](C2)--(D3);
\draw[arrowmark](C3)--(D3); \draw[arrowmark](C3)--(D4);

enter image description here

Labels can be added to the nodes using label={[<options>]<direction>:<contents>}. You can use angles for directions if you wish and you can change label distance as an option. You can add more than one label to a node. Multiple-line labels are allowed using \\ to separate lines if you add align=right (or any alignment) to your options. So your first few nodes would look like:

\node[label={left:50.00\\50.00\\5.47}](A){};
\node[above right=of A, label={below:56.12\\4.68}, label={above:56.12}](B1){};
\node[below right=of A, label={below:50.00\\6.38}, label={above:44.55}](B2){};

enter image description here

Here is the complete code. I added a "phantom digit" command \phdi to get the spacing right on the far-right labels.

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{positioning, decorations.markings, arrows.meta}
\tikzset{
    dot/.style={draw, #1, fill=#1, circle, inner sep=0pt, minimum size=4pt},
    dot/.default={black},
    arrowmark/.style={postaction={decorate, decoration={markings, mark=at position .9 with {\arrow{Stealth}}}}}
}
\newcommand{\phdi}{\phantom{0}}

\begin{document}

\begin{tikzpicture}[every node/.style={dot}, node distance=1cm and 3cm, align=right, font=\scriptsize]
\node[label={left:50.00\\50.00\\5.47}](A){};
\node[above right=of A, label={below:56.12\\4.68}, label={above:56.12}](B1){};
\node[below right=of A, label={below:50.00\\6.38}, label={above:44.55}](B2){};
\node[above right=of B1, label={below:62.99\\3.36}, label={above:62.99}](C1){};
\node[below right=of B1, dot=red, label={[label distance=2.5mm]-120:56.12\\6.12}, label={[label distance=2.5mm]-60:50.00\\2.66}, label={above:50.00}, label={[label distance=2.5mm]right:A}](C2){};
\node[below right=of B2, label={below:50.00\\10.31}, label={above:39.69}](C3){};
\node[above right=of C1, dot=blue, label={right:70.00\\70.00\\0.00}](D1){};
\node[below right=of C1, label={[align=center]right:56.12\\62.99\quad56.12\\\phdi6.87\quad\phdi0.00}](D2){};
\node[above right=of C3, label={[align=center]right:44.55\\56.12\quad50.00\\11.57\quad\phdi5.45}](D3){};
\node[below right=of C3, label={right:35.36\\50.00\\14.64}](D4){};
\draw[arrowmark](A)--(B1); \draw[arrowmark](A)--(B2);
\draw[arrowmark](B1)--(C1); \draw[arrowmark](B1)--(C2);
\draw[arrowmark](B2)--(C2); \draw[arrowmark](B2)--(C3);
\draw[arrowmark](C1)--(D1); \draw[arrowmark](C1)--(D2);
\draw[arrowmark](C2)--(D2); \draw[arrowmark](C2)--(D3);
\draw[arrowmark](C3)--(D3); \draw[arrowmark](C3)--(D4);
\end{tikzpicture}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .