我正在尝试在 LaTex 中绘制一个特定的二项式树,该树取自 Hull 的书《期权、期货和其他衍生品》。我已附上我想要创建的树,并附上了我之前准备的三项式 LaTeX。
\usepackage{tikz-cd}[![enter image description here][1]][1]
\tikzset{
pics/arrow/.style={/tikz/sloped, /tikz/allow upside down,
code=\pgfarrowdraw{#1}}, pics/arrow/.default=>}
\begin{document}
\begin{tikzcd}[
dot/.style={circle, fill, draw, inner sep=+0pt, minimum size=+3.5pt,
/utils/exec=\ifnum\pgfmatrixcurrentcolumn<4 \rar\urar\drar\fi},
/tikz/d/.style ={commutative diagrams/dot, label={above:{#1}}},
/tikz/d</.style={commutative diagrams/dot, label={ left:{#1}}},
/tikz/d>/.style={commutative diagrams/dot, label={right:{#1}}},
arrows={-, /tikz/every to/.append style={
edge node={pic[pos=.95]{arrow=Stealth}}}},
column sep={3cm,between origins}, row sep={1.33cm,between origins},
]
& & & |[d>=X_0 u^3]| \\
& & |[d=X_0 u^2]| & |[d>=X_0 u^2]| \\
& |[d=X_0 u]| & |[d=X_0 u ]| & |[d>=X_0 u ]| \\
|[d<=X_0]| & |[d=X_0 ]| & |[d=X_0 ]| & |[d>=X_0 ]| \\
& |[d=X_0 d]| & |[d=X_0 d ]| & |[d>=X_0 d ]| \\
& & |[d=X_0 d^2]| & |[d>=X_0 d^2]| \\
& & & |[d>=X_0 d^3]|
\end{tikzcd}
答案1
我假设这里的问题是如何让标签同时出现在节点上方和下方。这可以使用["label1" above, "label2" below]
相关节点的语法来实现。您也可以使用above left
等。
\documentclass{article}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}[column sep=3cm, row sep=0mm, arrows={-Stealth}, cells={nodes={fill, circle, minimum size=3.5pt, inner sep=0pt, font=\small}}]
& & |["S_0u^2" above right, "f_{uu}" below right]|\\
& |["S_0u" above, "f_u" below]|\arrow[ur]\arrow[dr] &\\
|["S_0" above left, "f" below left]|\arrow[ur]\arrow[dr] & & |["S_0ud" above right, "f_{ud}" below right]| \\
& |["S_0d" above, "f_d" below]|\arrow[ur]\arrow[dr] &\\
& & |["S_0d^2" above right, "f_{dd}" below right]|\\
\end{tikzcd}
\end{document}