如果我犯了一些错误,请原谅,我完全是新手。我正在尝试与 Beamer 一起做一个关于句法结构的演示,我需要画两棵树。第二棵树(以 ForceP 开头)是第一棵树的一部分的缩放/分割。我还需要用箭头将它们连接起来。
我用两棵树(用森林绘制)和一个单独的箭头用 tikzpicture 完成了这个任务。你知道我怎样才能让它更精确吗?也许在树上使用一些锚点、tikzmark 或标签?非常感谢!
\documentclass[10pt]{beamer}
%------- CODIFICA ------------------------------------
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}
%---- LINGUISTICA -----------------------------------
\usepackage{tikz}
\usepackage{tikz-qtree}
\usetikzlibrary{tikzmark,arrows.meta}
\usepackage{forest}
\useforestlibrary{linguistics}
\begin{document}
\forestset{
xlist/.style={
phantom,
for children={no edge,replace by={[,append,
delay={content/.wrap pgfmath arg={\csname @alph\endcsname{##1}.}{n()+##1}}
]}}
},
xlist/.default=0
}
\begin{columns}
\begin{column}{5cm}
\begin{forest}
[CP,tikz={\node [draw,red,fit=()(!1)(AB)] {};}
[SpecCP] [C' [C$_0$] [IP,name=AB [SpecIP] [I' [I$_0$] [VP [,roof]]]]]]
\end{forest}
\end{column}
\begin{column}{5cm}
\begin{forest}
[ForceP,tikz={\node [draw,red,fit to=tree] {};}
[SpecForce]
[Force' [Force$_0$]
[\ldots [FinP [SpecFin]
[Fin' [Fin$_0$] [IP [,roof]]]
]]]]
\end{forest}
\end{column}
\end{columns}
\begin{tikzpicture}[remember picture, overlay]
\draw [-Latex, red] (2.80,5) [out=75, in=230]to (5.9,4);
\end{tikzpicture}
\end{document}
答案1
最简单的解决方案可能是使用一个phantom
根并将两棵树画成一棵树。
\documentclass[border=10pt,beamer]{standalone}
\usepackage[linguistics]{forest}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{frame}{Two in One}
\centering
\begin{forest}
[, phantom, for children={fit=band}, s sep'+=20pt
[CP, name=CP
[SpecCP]
[C'
[C$_0$]
[IP, name=AB
[SpecIP]
[I'
[I$_0$]
[VP
[,roof]
]
]
]
]
]
[ForceP, tikz+={
\node (fit1) [draw, red, fit to={name=CP,1,name=AB}] {};
\node (fit2) [draw, red, fit to=tree] {};
\draw [-Latex, red] (fit1.east) [out=75, in=230]to (fit2.west);
}
[SpecForce
]
[Force'
[Force$_0$]
[\ldots
[FinP
[SpecFin]
[Fin'
[Fin$_0$]
[IP
[,roof]
]
]
]
]
]
]
]
\end{forest}
\end{frame}
\end{document}