次のような出力を希望します。
\documentclass{beamer}
\begin{document}
\begin{frame}[<+->]{Sampling}
\begin{itemize}
\item A random sample of ten people from the US will \alt<5>{{\color{blue}on average}}{on average} produce
five men and five women, but... \uncover<+->{ any given trial is likely to over-represent one sex and underrepresent
the other.}
\item Analogy: if you flip a fair coin 10 times, \alt<5>{{\color{blue}on average}}{on average} you'll get 5
heads and 5 tails, but... \uncover<+->{ sometimes we might get 7 heads and 3 tails, and other times 8 tails
and 2 heads.}
\item What does ``\alt<5>{{\color{blue}on average}}{on average}'' mean above?
\item It means that if we were to take a lot of samples.... blah blah.
\end{itemize}
\end{frame}
\end{document}
ただし、 の代わりに、最初の 2 つの「平均」インスタンスに を\alt<5>{{\color{blue}on average}}{on average}
遅延配置し、3 番目と最後のインスタンスに のようなものを配置します。つまり、次のコードを記述して、上記と同じ出力を実現したいのです。\groupA{on average}
\revealGroupA{on average}
\documentclass{beamer}
\begin{document}
\begin{frame}[<+->]{Sampling}
\begin{itemize}
\item A random sample of ten people from the US will \groupA{on average} produce
five men and five women, but... \uncover<+->{ any given trial is likely to over-represent one sex and underrepresent
the other.}
\item Analogy: if you flip a fair coin 10 times, \groupA{on average} you'll get 5
heads and 5 tails, but... \uncover<+->{ sometimes we might get 7 heads and 3 tails, and other times 8 tails
and 2 heads.}
\item What does ``\revealGroupA{on average}'' mean above?
\item It means that if we were to take a lot of samples.... blah blah.
\end{itemize}
\end{frame}
\end{document}
いくつかの注意点:
この例では、引数 (「平均して」) は常に同じですが、他の使用例ではそうではありません。
私も数学でこれをよく行うので、数学だけでなく数学以外でもコマンドが機能すると便利です。
おそらく、このメカニズムは同じファイルの複数の異なるフレームで使用されるでしょう。
関連があるかどうかはわかりませんが、回答を拡張して、基本的に同じことを行うが、異なる色を使用するコマンドも作成する予定です。その理由は、 との両方を同じフレームで
\groupB
使用したい場合があるからです。\groupA
\groupB
答え1
パッケージを使用してtotcount
、コンパイル間でグループが表示されるオーバーレイ番号を保存できます (異なるフレームで同じグループを再利用しないでください)。
\documentclass{beamer}
\makeatletter
\newcommand*{\slideinframe}{\beamer@slideinframe}
\makeatother
\usepackage{totcount}
\setbeamercolor{alerted text}{fg=blue}
\newcounter{overlaygroupA}
\setcounter{overlaygroupA}{0}
\newcommand{\revealGroupA}[1]{%
\only<.>{\setcounter{overlaygroupA}{\slideinframe}}%
\alert<.>{#1}%
}
\newcommand{\groupA}[1]{%
\alert<\totvalue{overlaygroupA}>{#1}%
}
\regtotcounter{overlaygroupA}
\begin{document}
\begin{frame}[<+->]{Sampling}
\begin{itemize}
\item A random sample of ten people from the US will \groupA{on average} produce
five men and five women, but... \uncover<+->{ any given trial is likely to over-represent one sex and underrepresent
the other.}
\item Analogy: if you flip a fair coin 10 times, \groupA{on average} you'll get 5
heads and 5 tails, but... \uncover<+->{ sometimes we might get 7 heads and 3 tails, and other times 8 tails
and 2 heads.}
\item What does ``\revealGroupA{on average}'' mean above?
\item It means that if we were to take a lot of samples.... blah blah.
\end{itemize}
\end{frame}
\end{document}