树虚线

树虚线

我想在数学文本中重现以下树。但由于版权原因,我不能使用 includegraphics{},我必须在 latex 中绘制此图。你有什么建议吗?什么是(相对简单的)适合生成虚线的包?

在此处输入图片描述

答案1

先给你一个开始。在尝试寻找答案时,我偷用了 @cfr 的许多精彩答案(当然,这些答案都得到了点赞)。希望他/她能给你提供一个不那么笨拙的解决方案。

\documentclass[tikz,border=10pt]{standalone}
% stolen from nice cfr answers such as https://tex.stackexchange.com/a/278184/121799
\usepackage{forest}
\begin{document}
\begin{forest}
  anchors/.style={anchor=#1,child anchor=#1,parent anchor=#1},
  /tikz/every node/.append style={font=\footnotesize},
  for tree={
    s sep=5mm,l=15mm,
    if n=0{anchors=east}{
    if n=1{anchors=east}{anchors=west}},
     content format={$\forestoption{content}$},
  },
  anchors=south, outer sep=2pt,
  nodot/.style={content format={},draw=none},
  dot/.style={tikz+={\draw[#1](.anchor)circle[radius=2pt];}},
  if content={}{}{dot={fill}}
  [\phi,dot=fill
    [y_{1,1},dot=fill
      [y_{1,1}y_{2,1},dot=fill
       [,edge=dashed]
       [,edge=dashed]]
      [y_{1,1}y_{2,2},dot=fill
       [,edge=dashed]
       [,edge=dashed]]
      [,edge=dashed]
      [y_{1,1}y_{2,{m_2}},dot=fill
       [,edge=dashed]
       [,edge=dashed]]
      ]
    [y_{1,1},dot=fill
        [,edge=dashed]
        [,edge=dashed]
      ]
    [y_{1,{m_1}},dot=fill
      [y_{{m_1},1}y_{2,1},dot=fill
       [,edge=dashed]
       [,edge=dashed]]
      [y_{{m_1},1}y_{2,2},dot=fill
       [,edge=dashed]
       [,edge=dashed]]
      [,edge=dashed]
      [y_{{m_1},1}y_{2,{m_2}},dot=fill
       [,edge=dashed]
       [,edge=dashed]]
      ]
    ]
  ]
\end{forest}
\end{document}

在此处输入图片描述

相关内容