答案1
使用nicematrix
和tikz
:
\documentclass{article}
\usepackage{nicematrix, tikz}
\begin{document}
\[
\tikzset{outer sep=1mm}
\renewcommand{\arraystretch}{4}
\setlength{\arraycolsep}{1cm}
\begin{NiceArray}{lll}
\color{gray}p(A)=0 & p(A)=\frac{1}{3} & p(A)=\frac{1}{6}\\
\color{gray}p(B)=0 & p(B)=\frac{1}{3} & p(A)=\frac{1}{3}+\frac{1}{9}=\frac{4}{9}\\
p(C)=1 & \color{gray}p(C)=0 & p(A)=\frac{1}{6}+\frac{1}{9}=\frac{5}{18}\\
\color{gray}p(D)=0 & \color{gray}p(D)=0 & p(A)=\frac{1}{9}\\
\color{gray}p(E)=0 & p(E)=\frac{1}{3} & \color{gray}p(A)=0
\CodeAfter
\tikz
\draw[thick] (3-1.east)--node[above]{$\frac{1}{3}$}(1-2.west)
(1-2.east)--node[pos=.7, right=2pt]{$\frac{1}{3}\cdot1$}(2-3.west)
(3-1.east)--node[below]{$\frac{1}{3}$}(2-2.west)
(2-2.east)--node[pos=.7, right]{$\frac{1}{3}\cdot\frac{1}{2}$}(1-3.west)
(2-2.east)--node[pos=.7, right=2pt]{$\frac{1}{3}\cdot\frac{1}{22}$}(3-3.west)
(3-1.east)--node[below]{$\frac{1}{3}$}(5-2.west)
(5-2.east)--node[very near end, right=-2pt]{$\frac{1}{3}\cdot\frac{1}{3}$}(2-3.west)
(5-2.east)--node[near end, right=-2pt]{$\frac{1}{3}\cdot\frac{1}{3}$}(3-3.west)
(5-2.east)--node[below right=-4pt]{$\frac{1}{3}\cdot\frac{1}{3}$}(4-3.west)
;
\end{NiceArray}
\]
\end{document}