正如标题所说,我在用 LaTeX 绘制树形图时遇到了麻烦。使用 TexSE,我找到了库“Tikz”,并尝试编写一些东西,但没有成功。
任何帮助都将受到赞赏。
编辑:我忘了放上我尽力而为的代码了。请帮忙。
\begin{tikzpicture}[node distance={15mm}, thick, main/.style = {draw, circle}]
\node[main] (1) {$C$};
\node[main] (2) [below left of=1] {$C_{00}$};
\node[main] (3) [right of=2] {$C_{01}$};
\node[main] (4) [below right of=1] {${C_10}$};
\node[main] (5) [right of=4] {$C_{11}$};
\draw[->] (1) -- (2);
\draw[->] (1) -- (3);
\draw[->] (1) -- (4);
\draw[->] (1) -- (5);
\end{tikzpicture}
答案1
如果您的完整“巨大”树类似于您的示例,并且非常重复,那么用一个\foreach
句子(或几个,嵌套或其他)很容易绘制。
像这样:
\documentclass[border=2mm,tikz]{standalone}
\tikzset
{%
empty/.style={minimum size=0,inner sep=0,outer sep=0},
circled/.style={circle,draw}
}
\begin{document}
\begin{tikzpicture}
\node[circled] (O2) at (11,8) {$\mathcal{C}$};
\node[empty] (O1) at (11,6) {};
\draw[-latex] (O2) -- (O1) node[pos=0.8,right] {$\tau$};;
\foreach[count=\j]\i in {00,01,10,11}
{%
\node[circled] (A\j) at (4*\j,0) {$\mathcal{C}_{\i0}$};
\node[circled] (B\j) at (4*\j+2,0) {$\mathcal{C}_{\i1}$};
\node[circled] (D\j) at (4*\j+1,4) {$\mathcal{C}_{\i}$};
\draw (A\j) --++ (1,2) node[midway, left] {$\frac{1}{2}$}
node[empty] (C\j) {} -- (B\j)
node[midway,right] {$\frac{1}{2}$};
\draw[-latex] (D\j) -- (C\j) node [pos=0.8,right] {$\tau^3$};
\draw (O1) -- (D\j) node[pos=0.7,above] {$\frac{1}{4}$};
}
\end{tikzpicture}
\end{document}