答案1
欢迎!恕我直言,这些不是树。您可以使用tikz
或tikz-cd
绘制此类图表。此答案定义了一种针对此类方案构建的样式。
\documentclass{article}
\usepackage{tikz-cd}
\newcounter{mylabels}
\tikzset{label label/.code={\stepcounter{mylabels}},
label labels/.style={every label/.append style={label label,
alias=mylabel-\number\value{mylabels}}},
fit in labels/.style={label labels,
execute at begin picture={\edef\myfirstlabel{\the\numexpr\value{mylabels}+1}},
execute at end picture={\edef\mylastlabel{\the\numexpr\value{mylabels}}
\path foreach \X in {\myfirstlabel,\the\numexpr\myfirstlabel+1,...,\mylastlabel}
{foreach \Anchor in {north,south,west,east}
{(mylabel-\X.\Anchor)}};}}}
\tikzcdset{mdiagram/.style={every arrow/.append style={-latex,semithick},
/tikz/column sep=2em,/tikz/row sep=2em,
/tikz/.cd,dot/.style={circle,fill,inner sep=2pt},
every label/.append style={overlay},fit in labels},
}
\begin{document}
Some text.
\[
\begin{tikzcd}[mdiagram]
& |[dot,label=above:\textsf{Court order (CO)}]| \arrow[d]& \\
& |[dot,label=right:\textsf{Captain (C)}]| \arrow[dl] \arrow[dr]& \\
|[dot,label=left:\textsf{A}]| \arrow[dr] & &
|[dot,label=right:\textsf{B}]| \arrow[dl]\\
& |[dot,label=below:\textsf{Death (D)}]| & \\
\end{tikzcd}\qquad
\begin{tikzcd}[mdiagram]
& |[dot,label=above:\textsf{Court order (CO)}]| \arrow[d]& \\
& |[dot,label=right:\textsf{Captain (C)}]| \arrow[dr]& \\
|[dot,label=left:\textsf{A}=\textsf{type}]| \arrow[dr] & &
|[dot,label=right:\textsf{B}]| \arrow[dl]\\
& |[dot,label=below:\textsf{Death (D)}]| & \\
\end{tikzcd}
\]
More text.
\end{document}
答案2
您还可以使用pstricks
(即psmatrix
在 中定义的环境)来执行此操作pst-node
:
\documentclass{article}
\usepackage{pst-node}
\usepackage{auto-pst-pdf}
\begin{document}
\psset{dotsize=4pt, arrows=->, arrowinset=0.1, linewidth=0.6pt, nodesep=0pt, labelsep=3pt}
\everypsbox{\scriptsize\sffamily}
\begin{psmatrix}[rowsep=0.6cm, colsep = 1cm]
%%%nodes
& \dotnode{CO} \\%
& \dotnode{C} \\%
\dotnode{A}& & \dotnode{B} \\%
& \dotnode{D}%
%%% labels
\uput[u](CO){Court Order (CO)}
\uput[r](C){ Captain (C)}
\uput[l](A){A}\uput[r](B){B}
\uput[d](D){Death (D)}
%%% arrows
\ncline{CO}{C}
\ncline{C}{A} \ncline{C}{B}
\ncline{A}{D} \ncline{B}{D}
\end{psmatrix}
\hskip 6em
\begin{psmatrix}[rowsep=0.6cm, colsep = 1cm]
%%%nodes
& \dotnode{CO} \\%
& \dotnode{C} \\%
\dotnode{A}& & \dotnode{B} \\%
& \dotnode{D}%
%%% labels
\uput[u](CO){Court Order (CO)}
\uput[r](C){ Captain (C)}
\uput[l](A){A\,=\,True}\uput[r](B){B}
\uput[d](D){Death (D)}
%%% arrows
\ncline{CO}{C}
\ncline{C}{B}
\ncline{A}{D} \ncline{B}{D}
\end{psmatrix}
\end{document}