谁能向我解释一下为什么在下面的 MWE 中从第一张幻灯片转到第二张幻灯片时,物体会出现这种奇怪的“移动”?
\documentclass{beamer}
\usepackage{beamerthemeshadow}
\usepackage{mathtools}
\usepackage{tikz}
\usetikzlibrary{shadows,shapes.arrows}
\tikzset{
invisible/.style={opacity=0,text opacity=0},
visible on/.style={alt=#1{}{invisible}},
alt/.code args={<#1>#2#3}{%
\alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}}
},
beameralert/.style={alt=<#1>{fill=red!30,rounded corners,inner sep=1pt}{},anchor=base},
}
\newcommand*{\tikzarrow}[2]{%
\tikz[
baseline=(A.base),
]\node[
single arrow,
single arrow head extend=2pt,
draw,
inner sep=2pt,
top color=white,
bottom color=#1,
drop shadow
] (A) {#2};%
}
\begin{document}
\begin{frame}
\begin{block}{Theorem}
Assume:
\begin{itemize}
\item Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna.
\end{itemize}
\tikzarrow{yellow}{Then} \tikz[baseline=(A.base)] \node[beameralert=2] (A) {$a+b+c+d+e+f+g=47$.};
\end{block}
\end{frame}
\end{document}
PS:从某种意义上说,这个问题是对使用 TikZ 节点在 Beamer 中突出显示。
答案1
通过代码,您可以感知幻灯片之间的转换(跳跃效应beameralert
),因为我怀疑如果只在第二张幻灯片中显示,则添加的样式inner sep=1pt
会改变节点的尺寸。如果我将其删除,则会得到:
确实,
\tikzset{
invisible/.style={opacity=0,text opacity=0},
visible on/.style={alt=#1{}{invisible}},
alt/.code args={<#1>#2#3}{%
\alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}}
}
}
避免跳跃效果的方法是让 TikZ 图片的元素(节点、路径或其他)总是存在,但仅可见的在某些时刻。当不同幻灯片中的元素在某些时刻神奇地以它们的尺寸出现时,人们会感觉到跳跃效果(至少这是我在这里阅读有关这个主题的一些问题/答案时所理解的)。
回想一下我之前的回答 使用 TikZ 节点在 Beamer 中突出显示,也可以使用下面的样式:
\tikzset{
background fill/.style={fill=#1},
background fill/.default={block body.bg},
fill on/.style={alt=#1{}{background fill}},
}
注意将默认值设置为与块主体的背景颜色相等。然后:
\documentclass{beamer}
\usepackage{beamerthemeshadow}
\usepackage{mathtools}
\usepackage{tikz}
\usetikzlibrary{shadows,shapes.arrows}
\tikzset{
invisible/.style={opacity=0,text opacity=0},
visible on/.style={alt=#1{}{invisible}},
alt/.code args={<#1>#2#3}{%
\alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}}
}
}
\tikzset{
background fill/.style={fill=#1},
background fill/.default={block body.bg},
fill on/.style={alt=#1{}{background fill}},
}
\newcommand*{\tikzarrow}[2]{%
\tikz[
baseline=(A.base),
]\node[
single arrow,
single arrow head extend=2pt,
draw,
inner sep=2pt,
top color=white,
bottom color=#1,
drop shadow
] (A) {#2};%
}
\begin{document}
\begin{frame}
\begin{block}{Theorem}
Assume:
\begin{itemize}
\item Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna.
\end{itemize}
\tikzarrow{yellow}{Then} \tikz[baseline=(A.base)] \node[rounded corners,background fill=red!30,fill on=<2>] (A) {$a+b+c+d+e+f+g=47$.};
\end{block}
\end{frame}
\end{document}
将提供与上面报道相同的图片。