答案1
这很容易做到forest
。网站上有很多类似的树。我选择单独添加十字架,而不是forest
直接将装饰添加到节点,因为这样可以更好地控制它们的大小。
\documentclass{article}
\usepackage[linguistics]{forest}
\usetikzlibrary{decorations,positioning}
\begin{document}
\begin{forest}for tree={l sep'=1cm,s sep'=1cm}
[Undertaking\\ART,name=Art
[Unsuccesful,name=U
[Spontaneous\\Conception\\(Only SC child)\\{[A]} ]
[No Spontaneous\\Conception\\(no conception)\\{[B]},name=B]
]
[Successful
[Spontaneous\\Conception\\(very rare)\\{[C]},name=C ]
[No Spontaneous\\Conception\\(only ART child)\\{[D]}]
]
]
\node[red,draw,cross out,minimum size=1cm] at (B) {};
\node[red,draw,cross out,minimum size=1cm] at (C) {};
\node[below=1cm of Art] {R.1};
\node[below=.5cm of U] {R.2};
\end{forest}
\end{document}
如果您不喜欢该[linguistics]
库使用的合并分支,请不要加载它,您将获得未合并的分支。在这种情况下,您需要将规范添加align=center
到树中以允许节点中的换行符。
\documentclass{article}
\usepackage[]{forest}
\usetikzlibrary{decorations,positioning}
\begin{document}
\begin{forest}for tree={l sep'=1cm,s sep'=1cm,align=center}
[Undertaking\\ART,name=Art
[Unsuccesful,name=U
[Spontaneous\\Conception\\(Only SC child)\\{[A]} ]
[No Spontaneous\\Conception\\(no conception)\\{[B]},name=B]
]
[Successful
[Spontaneous\\Conception\\(very rare)\\{[C]},name=C]
[No Spontaneous\\Conception\\(only ART child)\\{[D]}]
]
]
\node[red,draw,cross out,minimum size=1cm] at (B) {};
\node[red,draw,cross out,minimum size=1cm] at (C) {};
\node[below=1cm of Art] {R.1};
\node[below=.5cm of U] {R.2};
\end{forest}
\end{document}
答案2
这是我自己的答案,在@Alan Munn 的帮助下找到的:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{calc}
\usetikzlibrary{trees}
\begin{document}
\begin{tikzpicture}[
level 1/.style = {black, sibling distance = 8cm},
level 2/.style = {black, sibling distance = 4cm},
level distance = 3cm, % Increase the level distance
]
\node [align=center] (undertaking) {Undertaking \\ ART cycle}
child {node [align=center] (succ) {Unsuccessful}
child {node (A) [align=center] {Spontaneous \\ Conception \\ {\small (only SC child)} \\ {[A]}}}
child {node (B) [align=center] {No Spontaneous \\ Conception \\ {\small (no conception)} \\ {[B]}}}
}
child {node (unsucc) {Successful}
child {node (C) [align=center] {Spontaneous \\ Conception \\ {\small (only SC child)} \\ {[C]}}}
child {node (D) [align=center] {No Spontaneous \\ Conception \\ {\small (no conception)} \\ {[D]}}}
};
\node [align=center, below=1cm of undertaking] {\bfseries R.1};
\node [align=center, below=1cm of succ] {\bfseries R.2};
\node [align=center, below=1cm of unsucc] {\bfseries R.2};
\node[red,draw,cross out,minimum size=1.5cm] at (B) {};
\node[red,draw,cross out,minimum size=1.5cm] at (C) {};
\end{tikzpicture}
\end{document}