用下面的程式碼
\documentclass[beamer]{beamer}
\begin{document}
\begin{frame}
\[
\sqrt{\uncover<2->{a\uncover<3->{+b}}}
\]
\end{frame}
\end{document}
我可以發現一個公式,首先顯示外部元素,然後顯示內部元素。
我怎樣才能得到相反的結果?即:先顯示“+b”,然後顯示前面的“a”,然後是和周圍的平方根號?
答案1
平方根就是問題所在。
\documentclass[beamer]{beamer}
\begin{document}
\begin{frame}
\[
\only<1>{\phantom{\sqrt{\vphantom{a+b}}}\hphantom{a}+b}
\only<2>{\phantom{\sqrt{\vphantom{a+b}}}a+b}
\only<3>{\sqrt{a+b}}
\]
\end{frame}
\end{document}
答案2
我在我的範例上做了更多工作(我需要它來創建一個更複雜的公式),並且我發現內部\textcolor
優先於外部,因此以下工作有效:
\begin{frame}
\[
\textcolor<3>{black}{\textcolor<1-2>{white}{%
\sqrt{%
\textcolor<2>{black}{\textcolor<1>{white}{%
a%
\textcolor<1>{black}{%
\vphantom{a}+b%
}%
}}%
}%
}}%
\]
\end{frame}
就我而言,我可以比 @egreg 建議更容易概括這一點(無論如何,這是非常好的和“TeXnical”)作為一個更詳細的示例,請考慮以下內容:
\begin{frame}
\[
\textcolor<6>{black}{\textcolor<1-5>{white}{%
\textcolor<5->{black}{\textcolor<4>{red}{%
{\sqrt{%
\textcolor<3->{black}{\textcolor<2>{red}{%
{\left(%
\textcolor<2->{black}{\textcolor<1>{red}{%
{\frac{a}{2}}%
}}%
\right)^{2}}%
}}%
\textcolor<4->{black}{\textcolor<3>{red}{%
{\vphantom{1}+b}%
}}%
}}%
}}%
\textcolor<6->{black}{\textcolor<5>{red}{%
{\vphantom{1}+\frac{c}{2}}%
}}%
}}%
\]
\end{frame}