答案1
绘图
使用 TikZ graphdrawing
(需要 LuaLaTeX)。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{graphs,graphdrawing}
\usegdlibrary{trees}
\begin{document}
\begin{tikzpicture}
\graph[
tree layout,grow=right,fresh nodes,
nodes={draw,fill=lightgray,rounded corners}
] {
Patients -> {
Treatment $A_1$ -> {
Treatment $B_1$,
Treatment $B_2$
},
Treatment $A_2$ -> {
Treatment $B_1$,
Treatment $B_2$
}
}
};
\end{tikzpicture}
\end{document}
森林
或者你也可以使用forest
。(感谢@cfr 提供的有关 的提示parent anchor=children,child anchor=parent
)
\documentclass{article}
\usepackage{forest}
\begin{document}
\begin{forest}
for tree={grow=east,parent anchor=children,child anchor=parent,
draw,fill=lightgray,rounded corners}
[Patients
[Treatment $A_1$
[Treatment $B_1$]
[Treatment $B_2$]
]
[Treatment $A_2$
[Treatment $B_1$]
[Treatment $B_2$]
]
]
\end{forest}
\end{document}
tikz-qtree
你也可以滥用tikz-qtree
(这实际上是针对语言树的)
\documentclass{article}
\usepackage{tikz-qtree}
\begin{document}
\begin{tikzpicture}[
grow'=right,level distance=3cm,
every node/.style={draw,fill=lightgray,rounded corners}
]
\Tree [.Patients
[.{Treatment $A_1$}
[.{Treatment $B_1$} ]
[.{Treatment $B_2$} ]
]
[.{Treatment $A_2$}
[.{Treatment $B_1$} ]
[.{Treatment $B_2$} ]
]
]
\end{tikzpicture}
\end{document}
康特克斯 MkIV
如果您不知道 ConTeXt 是什么,您可以停止阅读。
我用的是charts
。
\无页眉和页脚行
\usemodule[chart]
\setupFLOWcharts
[
width=9\bodyfontsize,
height=2\bodyfontsize,
dx=1\bodyfontsize,
dy=0pt,
]
\starttext
\startFLOWchart[treatment]
\startFLOWcell
\shape {action}
\name {pat}
\location {1,4}
\text {Patient}
\connect [rl]{tA1}
\connect [rl]{tA2}
\stopFLOWcell
\startFLOWcell
\shape {action}
\name {tA1}
\location {2,2}
\text {Treatment $A_1$}
\connect [rl]{tA1B1}
\connect [rl]{tA1B2}
\stopFLOWcell
\startFLOWcell
\shape {action}
\name {tA1B1}
\location {3,1}
\text {Treatment $B_1$}
\stopFLOWcell
\startFLOWcell
\shape {action}
\name {tA1B2}
\location {3,3}
\text {Treatment $B_2$}
\stopFLOWcell
\startFLOWcell
\shape {action}
\name {tA2}
\location {2,6}
\text {Treatment $A_2$}
\connect [rl]{tA2B1}
\connect [rl]{tA2B2}
\stopFLOWcell
\startFLOWcell
\shape {action}
\name {tA2B1}
\location {3,5}
\text {Treatment $B_1$}
\stopFLOWcell
\startFLOWcell
\shape {action}
\name {tA2B2}
\location {3,7}
\text {Treatment $B_2$}
\stopFLOWcell
\stopFLOWchart
\FLOWchart[treatment]
\stoptext
答案2
还有一种替代方法,就是用普通的树:-):
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[
every node/.style = {draw=gray, rounded corners, fill=gray!10, inner sep=2mm},
level 1/.style = {sibling distance = 22mm},
level 2/.style = {sibling distance = 11mm},
level distance = 33mm,
grow = right,
edge from parent/.style = {draw, thick, ->},
edge from parent path = {(\tikzparentnode.east) -- (\tikzchildnode.west)},
]
\node {Patients}
child { node {Treatment $A_1$}
child { node {Treatment $B_1$}}
child { node {Treatment $B_2$}}
}
child { node {Treatment $A_2$}
child { node {Treatment $B_1$}}
child { node {Treatment $B_2$}}
};
\end{tikzpicture}
\end{document}
答案3
更接近OP图:
来源:
\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-qtree}
\begin{document}
\begin{tikzpicture}[grow' = right,
line width = 1.5pt,
level distance = 44mm,
every node/.style = {shape = rectangle,
minimum size = 13mm,
text width = 24mm,
rounded corners = 2mm,
draw,
fill=black!10,
align=center,
},
level 1/.style = {sibling distance = 36mm},
level 2/.style = {sibling distance = 17mm},
]
\node {Patients}
child {node {Treatment $ A_1 $}
child {node {Treatment $ B_2 $}}
child {node {Treatment $ B_1 $}}}
child {node {Treatment $ A_2 $}
child {node {Treatment $ B_1 $}}
child {node {Treatment $ B_2 $}}};
\end{tikzpicture}
\end{document}