\begin{frame} {Family work up }
\begin{tikzpicture}[level 1/.style={sibling distance=5cm},level 2/.style={sibling distance=2.5cm}]
\node {Patient}[edge from parent fork down]
child { node {Daughter 32 years}}
child { node {Son 28 years}}
child { node {\color{red} {Daughter 23 years}}}
;
\end{tikzpicture}
\end{frame}
你好,上面的代码生成了一个小型家谱。我想突出显示一个孩子(女儿 23 岁),表明她也患有疾病。这可以通过用方框圈出它或用颜色突出显示来实现。请帮忙。
答案1
你喜欢这样的东西吗?
代码:
\documentclass[compress,final]{beamer}
\usepackage{tikz}
\usetikzlibrary{trees}
\begin{document}
\begin{frame}{Family work up }
\begin{tikzpicture}[
level 1/.style={sibling distance=3cm},level 2/.style={sibling distance=2.5cm}]
\node {Patient}[edge from parent fork down]
child { node {Daughter 32 years}}
child { node {Son 28 years}}
child { node[draw=red] {Daughter 23 years}}
;
\end{tikzpicture}
or
\begin{tikzpicture}[
level 1/.style={sibling distance=3cm},level 2/.style={sibling distance=2.5cm}]
\node {Patient}[edge from parent fork down]
child { node {Daughter 32 years}}
child { node {Son 28 years}}
child { node[fill=gray!30] {Daughter 23 years}}
;
\end{tikzpicture}
\end{frame}
\end{document}
您可以将树中的节点设计为其他节点tikzpicture
,只需向它们添加所需的参数,就像我上面所做的一样。顺便说一句:兄弟距离 5cm 太大了,树无法安装在幻灯片上,所以我将其减小到 3cm。
答案2
另外,使用来自使用投影机叠加森林生成的树木,有两个叠加层:
\documentclass[compress,final]{beamer}
\usepackage{tikz}
\tikzset{
invisible/.style={opacity=0},
visible on/.style={alt={#1{}{invisible}}},
alt/.code args={<#1>#2#3}{%
\alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} % \pgfkeysalso doesn't change the path
},
}
\usetikzlibrary{trees}
\begin{document}
\begin{frame}{Family work up }
\begin{tikzpicture}[
level 1/.style={sibling distance=3cm},level 2/.style={sibling distance=2.5cm}]
\node {Patient}[edge from parent fork down]
child { node {Daughter 32 years}}
child { node {Son 28 years}}
child { node[alt={<2->{fill=yellow}{}}] {Daughter 23 years}}
;
\end{tikzpicture}
\end{frame}
\end{document}
结果是: