答案1
这种方法使用 tikz,特别是引用当前图片之外的节点(手动的,v.3.1.9a)。我将首先介绍这个想法,然后重构它以使其更易于使用。
每个句子的末尾都有一个不可见的节点(s1
和)。右边距s2
也有一个不可见的节点(e1
和)。然后我们在节点和的中间创建一个节点(),其中包含“Word” 。我们还在单词左侧 1 厘米处创建一个坐标()。箭头用垂直线将节点(分别为)连接到via 。e2
w
e1
e2
p
s1
s2
w
p
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{positioning,arrows.meta}
\tikzset{phantom/.style={inner sep=0,outer sep=0}}
\begin{document}
\begin{frame}
\begin{itemize}
\item Big sentence 1 aaaaaaaaaaaaaaaaa
\tikz[baseline=(s1.base),remember picture] \node[phantom] (s1) {\strut}; \hfill
\tikz[baseline=(e1.base),remember picture] \node[phantom] (e1) {\strut};
\item Big sentence 2 aaaaaaaaaaaaaaaaaaaaaaaa
\tikz[baseline=(s2.base),remember picture] \node[phantom] (s2) {\strut}; \hfill
\tikz[baseline=(e2.base),remember picture] \node[phantom] (e2) {\strut};
\end{itemize}
\begin{tikzpicture}[remember picture,overlay]
\path (e1) -- (e2) node[midway,anchor=east] (w) {Word}
(w.west) +(left:1cm) coordinate (p);
\draw[-Stealth] (s1) -| (p) |- (w.west);
\draw[-Stealth] (s2) -| (p) |- (w.west);
\end{tikzpicture}
\end{frame}
\end{document}
通过一些重构,这种方法可以围绕两个命令构建:\setpoint{p}
将句子的结尾标记为点p
,以及绘制合并点和到给定单词的\mergepoints{p}{q}{Word}
箭头。p
q
\newcommand\setpoint[1]{%
\tikz[baseline=(s#1.base),remember picture] \node[phantom] (s#1) {\strut};
\hfill
\tikz[baseline=(e#1.base),remember picture] \node[phantom] (e#1) {\strut};
}
\newcommand{\mergepoints}[3]{%
\begin{tikzpicture}[remember picture,overlay]
\path (e#1) -- (e#2) node[midway,anchor=east] (w) {#3}
(w.west) +(left:1cm) coordinate (p);
\draw[-Stealth] (s#1) -| (p) |- (w.west);
\draw[-Stealth] (s#2) -| (p) |- (w.west);
\end{tikzpicture}
}
然后,可以得出同样的例子:
\begin{frame}
\begin{itemize}
\item Big sentence 1 aaaaaaaaaaaaaaaaa \setpoint{1}
\item Big sentence 2 aaaaaaaaaaaaaaaaaaaaaaaa \setpoint{2}
\end{itemize}
\mergepoints{1}{2}{Word}
\end{frame}
事实上,这可以用来构建同一想法的更复杂的实例,例如
\begin{frame}
Two sentences:
\begin{itemize}
\item Big sentence 1 aaaaaaaaaaaaaaaaa \setpoint{1}
\item Small sentence 1 aaaaaaaaa \setpoint{2}
\end{itemize}
and two more:
\begin{itemize}
\item Big sentence 2 aaaaaaaaaaaaaaaaaaaaaaaa \setpoint{3}
\item Small sentence 2 aaaaaaa \setpoint{4}
\end{itemize}
\mergepoints{1}{3}{Big}
\mergepoints{2}{4}{Small}
\end{frame}