我如何绘制可能性树?

我如何绘制可能性树?

我可以完成以下板子的绘图:

\documentclass{article}
\usepackage{skak}
\usepackage{chessboard}
\let\boardfont\undefinedcommand
\usepackage{diagram}

\begin{document}
\setboolean{showcomputer}{false}
\setboolean{piececounter}{false}
\specialdiagnum{}

\begin{diagram}[4x4]
\pieces{wDa3, wDb1, wDc4, wDd2}
\end{diagram}
\begin{diagram}[4x4]
\pieces{wDb4}
\end{diagram}

\end{document}

但是,可能性树也是如此:在此处输入图片描述

答案1

以下是一些入门知识,使用tikz以及trees

截屏

% arara: pdflatex
% !arara: indent: {overwrite: yes}
\documentclass[tikz]{standalone}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[
        level 1/.style={sibling distance=3.5cm},
        level 2/.style={sibling distance=2.5cm},
        level distance=2cm,
    ]
    \node {\includegraphics[width=2cm]{example-image}}
    child {
        node {\includegraphics[width=2cm]{example-image-a}}
        child {node {\includegraphics[width=2cm]{example-image-b}}}
        child {
            node {\includegraphics[width=2cm]{example-image-b}}
            child {node {\includegraphics[width=2cm]{example-image-c}}}
        }
    }
    child {
        node {\includegraphics[width=2cm]{example-image-a}}
        child {
            node {\includegraphics[width=2cm]{example-image-b}}
            child {
                node {\includegraphics[width=2cm]{example-image-c}}
                child {node {\includegraphics[width=2cm]{example-image}}}
            }
        }
    }
    child {
        node {\includegraphics[width=2cm]{example-image-a}}
        child {
            node {\includegraphics[width=2cm]{example-image-b}}
            child {
                node {\includegraphics[width=2cm]{example-image-c}}
                child {node {\includegraphics[width=2cm]{example-image}}}
            }
        }
    }
    child {
        node {\includegraphics[width=2cm]{example-image-a}}
        child {
            node {\includegraphics[width=2cm]{example-image-b}}
            child {node {\includegraphics[width=2cm]{example-image-c}}}
        }
        child {node {\includegraphics[width=2cm]{example-image-b}}}
    };
\end{tikzpicture}


\end{document}

还有一些与边界有关的东西:

截屏

% arara: pdflatex
% !arara: indent: {overwrite: yes}
\documentclass[tikz]{standalone}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[
        level 1/.style={sibling distance=3.5cm,},
        level 2/.style={sibling distance=2.5cm},
        special/.style={draw=red,thick,double,inner sep=0mm},
        level distance=3cm,
        line width=3,
    ]
    \node {\includegraphics[width=2cm]{example-image}}
    child {
        node {\includegraphics[width=2cm]{example-image-a}}
        child {node {\includegraphics[width=2cm]{example-image-b}}}
        child {
            node {\includegraphics[width=2cm]{example-image-b}}
            child {node {\includegraphics[width=2cm]{example-image-c}}}
        }
    }
    child {
        node {\includegraphics[width=2cm]{example-image-a}}
        child {
            node {\includegraphics[width=2cm]{example-image-b}}
            child {
                node {\includegraphics[width=2cm]{example-image-c}}
                child {node[special] {\includegraphics[width=2cm]{example-image}}}
            }
        }
    }
    child {
        node {\includegraphics[width=2cm]{example-image-a}}
        child {
            node {\includegraphics[width=2cm]{example-image-b}}
            child {
                node {\includegraphics[width=2cm]{example-image-c}}
                child {node[special]{\includegraphics[width=2cm]{example-image}}}
            }
        }
    }
    child {
        node {\includegraphics[width=2cm]{example-image-a}}
        child {
            node {\includegraphics[width=2cm]{example-image-b}}
            child {node {\includegraphics[width=2cm]{example-image-c}}}
        }
        child {node {\includegraphics[width=2cm]{example-image-b}}}
    };
\end{tikzpicture}


\end{document}

按你认为合适的方式调整:)

答案2

当然,你总是可以使用forest

森林里的国际象棋

\documentclass[tikz]{standalone}
\usepackage{forest}
\usepackage{skak}
\usepackage{chessboard}
\let\boardfont\undefinedcommand
\usepackage{diagram}

\begin{document}
\setboolean{showcomputer}{false}
\setboolean{piececounter}{false}

\specialdiagnum{}
\begin{forest}
  for tree={
    edge path={
        \noexpand\path[\forestoption{edge}, shorten <=-15pt, line width=2.5pt] (!u.parent anchor) -- (.child anchor)\forestoption{edge label};
    },
  }
  [{\begin{diagram}[4x4]\end{diagram}}
    [{\begin{diagram}[4x4]\pieces{wDa4}\end{diagram}}
      [{\begin{diagram}[4x4]\pieces{wDa4, wDc3}\end{diagram}}]
      [{\begin{diagram}[4x4]\pieces{wDa4, wDd3}\end{diagram}}
        [{\begin{diagram}[4x4]\pieces{wDa4, wDd3, wDb2}\end{diagram}}]
      ]
    ]
    [{\begin{diagram}[4x4]\pieces{wDb4}\end{diagram}}
      [{\begin{diagram}[4x4]\pieces{wDb4, wDd3}\end{diagram}}
        [{\begin{diagram}[4x4]\pieces{wDb4, wDd3, wDa2}\end{diagram}}
          [{\begin{diagram}[4x4]\pieces{wDb4, wDd3, wDa2, wDc1}\end{diagram}}]
        ]
      ]
    ]
    [{\begin{diagram}[4x4]\pieces{wDc4}\end{diagram}}
      [{\begin{diagram}[4x4]\pieces{wDc4, wDa3}\end{diagram}}
        [{\begin{diagram}[4x4]\pieces{wDc4, wDa3, wDd2}\end{diagram}}
          [{\begin{diagram}[4x4]\pieces{wDc4, wDa3, wDd2, wDb1}\end{diagram}}]
        ]
      ]
    ]
    [{\begin{diagram}[4x4]\pieces{wDd4}\end{diagram}}
      [{\begin{diagram}[4x4]\pieces{wDd4, wDa3}\end{diagram}}
        [{\begin{diagram}[4x4]\pieces{wDd4, wDa3, wDc2}\end{diagram}}]
      ]
      [{\begin{diagram}[4x4]\pieces{wDd4, wDb3}\end{diagram}}]
    ]
  ]
\end{forest}

相关内容