![从一个矩阵节点绘制到其他节点的箭头,并在其上方标注标签(Beamer)](https://linux22.com/image/415044/%E4%BB%8E%E4%B8%80%E4%B8%AA%E7%9F%A9%E9%98%B5%E8%8A%82%E7%82%B9%E7%BB%98%E5%88%B6%E5%88%B0%E5%85%B6%E4%BB%96%E8%8A%82%E7%82%B9%E7%9A%84%E7%AE%AD%E5%A4%B4%EF%BC%8C%E5%B9%B6%E5%9C%A8%E5%85%B6%E4%B8%8A%E6%96%B9%E6%A0%87%E6%B3%A8%E6%A0%87%E7%AD%BE%EF%BC%88Beamer%EF%BC%89.png)
我有一张带有单行矩阵的幻灯片,我希望它以以下方式出现:首先出现中间的元素,周围有一个框;然后它左边和右边的元素同时出现,自然的箭头从中心元素指向它们两个,一些值写在箭头上方或下方(我会根据它们的外观选择上方或下方)。
目前,我有一些这样的代码,但有几个问题:1) 整行都应该居中,但实际上没有;2) 只显示一个箭头;3) 文本没有出现在正确的位置;4) 箭头太靠下。我希望它们离行近一点,现在看起来空隙很大。
\documentclass{beamer}
\mode<presentation>
{
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{caption}[numbered]
}
%%%%%%%%%
\usepackage{tikz}
\usetikzlibrary{fit,overlay-beamer-styles,tikzmark, matrix}
\usepackage{tcolorbox}
\begin{document}
\section{Proofs}
\begin{frame}[fragile]
\frametitle{title}
\begin{tcolorbox}[left = .8 mm, right=.8 mm]
Idea: here is the idea.
\end{tcolorbox}
\begin{tikzpicture}[optimization problem/.style = {%
rounded corners,
draw = green,
thick,
fill= white,
inner ysep=5pt,
inner xsep=5pt,
align = center},
row 1 column 2/.style={visible on = <2->},
row 1 column 1/.style = {visible on = <3->},
row 1 column 3/.style = {visible on =<3->}
]
\matrix[matrix of nodes,row sep=1em,column sep=1em,
nodes={anchor=west}
](M){
$f$ & |[alt=<2>{draw=green,thick,fill=white, rounded corners}{}]|$g$ & $r$\\
};
\draw[->, thick, visible on=<3->] (M-1-2)[out=-90,in=-90,loop,looseness=1] (M-1-1) node[midway, above] {$t=1$};
\draw[->, thick, visible on=<3->] (M-1-2) to [out=-90,in=-90,loop,looseness=1] (M-1-3) node[midway, below] {$t=0$};
\end{tikzpicture}
\vspace{2em}
\onslide<4->{
If the following inequality holds: \[a \leq b,\] then combine with result 1 + result 2 + result 3 to finish the proof.}
\vspace{2em}
\onslide<5->{
However, this is {\color{red}FALSE}; counter-example:
\[1 + 1 = 2.\]}
\end{frame}
\end{document}
答案1
至于您的问题:
- 您可以使用
\hfill
来使 居中tikzpicture
。 - 你忘了
to
,不应该用于loop
从 A 到 B 的箭头,如果你想沿着弯曲的路径放置一个节点,你需要把它前目标。1 要仅在特定覆盖层上获取框架,您可以使用
|[draw=green,thick,fill=white, rounded corners,alt=<2>{opacity=1}{opacity=0,text opacity=1}]|
我还在代码中添加了一些注释。
\documentclass{beamer}
\mode<presentation>
{
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{caption}[numbered]
}
%%%%%%%%%
\usepackage{tikz}
\usetikzlibrary{fit,overlay-beamer-styles,tikzmark, matrix}
\usepackage{tcolorbox}
\begin{document}
\section{Proofs}
\begin{frame}[fragile]
\frametitle{title}
\begin{tcolorbox}[left = .8 mm, right=.8 mm]
Idea: here is the idea.
\end{tcolorbox}
\hfill
\begin{tikzpicture}[optimization problem/.style = {%
rounded corners,
draw = green,
thick,
fill= white,
inner ysep=5pt,
inner xsep=5pt,
align = center},
row 1 column 2/.style={visible on = <2->},
row 1 column 1/.style = {visible on = <3->},
row 1 column 3/.style = {visible on =<3->}
]
\matrix[matrix of nodes,row sep=1em,column sep=1em,
nodes={anchor=west}
](M){
$f$ & |[draw=green,thick,fill=white, rounded
corners,alt=<2>{opacity=1}{opacity=0,text opacity=1}]|$g$ & $r$\\
};
\draw[->, thick, visible on=<3->]
(M-1-2) to[out=90,in=90,looseness=1] node[midway, above] {$t=1$}
(M-1-1) ; % target node needs to be last, no loop & you forgot "to"
\draw[->, thick, visible on=<3->] (M-1-2) to [out=-90,in=-90,looseness=1]
node[midway, below] {$t=0$} (M-1-3); % target node needs to be last, no loop
\end{tikzpicture}\hfill\mbox{}\par
\vspace{2em}
\onslide<4->{
If the following inequality holds: \[a \leq b,\] then combine with result 1 + result 2 + result 3 to finish the proof.}
\vspace{2em}
\onslide<5->{
However, this is \textcolor{red}{FALSE}; counter-example:
\[1 + 1 = 2.\]}
\end{frame}
\end{document}
1钛钾Z 对于直线路径非常宽容,你可以把node[pos=0.5]{...}
后目标。我有时认为,如果你总是需要把它放在前面,那会更容易……