特定のテキストのオーバーレイ色

特定のテキストのオーバーレイ色
\documentclass{beamer}
\mode<presentation>
\usepackage{amsfonts,amsmath,amssymb,graphicx,xcolor}
\newtheorem{thm}{Theorem}
\begin{document}
\title{...} 

\begin{frame}
    \titlepage
\end{frame}

\begin{frame}
    \begin{thm}
        $\sqrt{2}$ is irrational.
    \end{thm}\pause
    \begin{proof}
        The proof is by contradiction.\pause

     \begin{itemize}
        \item\only<3>{\textcolor{red}{Suppose, for a contradiction, that $\sqrt{2}$ is rational. 
 That is, there are coprime integers $a$ and $b$ such that $\sqrt{2}=\frac{a}{b}.$}}\pause

        \item\only<4>{\textcolor{red}{$\sqrt{2}$}}
     \end{itemize}
    \end{proof}
\end{frame}
\end{document}

私は作ろうとしている

Suppose, for a contradiction, that $\sqrt{2}$ is rational.
That is, there are coprime integers $a$ and $b$ such that \sqrt{2}=\frac{a}{b}.

オーバーレイの 3 番目のスライドでは赤、4 番目のスライドでは通常の黒ですが、4 番目のスライドでは完全に消えてしまいました。なぜでしょうか?

答え1

-コマンド\onlyは次の内容を出力しますのみそのスライドで、定義します。したがって、\only<3>オーバーレイ 3 にのみ文章が印刷されます。オーバーレイ 4 以降では表示されません。したがって、テキストが表示されないという問題が発生します。

オーバーレイ 3 に特別な準備をして、他のすべてのオーバーレイでは通常の外観にしたい場合は、\altコマンドを使用します。 がオーバーレイのセット (この場合<3>、最初の括弧のペア) を取る場合、そのオーバーレイで何が起こるかを定義できます。他のオーバーレイでは、2 番目の括弧のペアの内容が使用されます。

を参照してくださいビーマーマニュアル\uncoverさらに、、、\invisibleなどのコマンドについては、\visible...

あなたの場合、\color{red}オーバーレイ 3 を呼び出すだけで十分です\color。 はコマンドなので、後続のすべてが赤色になります。色付けは周囲の環境で自動的に終了します (ここではitemize)。

\color{green}(証明のために、環境外には何も影響しない5 番目のオーバーレイを追加しました。コマンドをさらに制御したい場合は、\textcolor{}ここに示すように、テキストを使用したり、コピーして貼り付けたりできます。\alt<3>{\color{red} text}{pure uncolored text})

MWE:

\documentclass{beamer}
\mode<presentation>
\usepackage{amsfonts,amsmath,amssymb,graphicx,xcolor}
\newtheorem{thm}{Theorem}
\begin{document}
\title{...} 

\begin{frame}
    \titlepage
\end{frame}

\begin{frame}
    \begin{thm}
        $\sqrt{2}$ is irrational.
    \end{thm}\pause
    \begin{proof}
        The proof is by contradiction.\pause

     \begin{itemize}
     \item\alt<3>{\color{red}}{} Suppose, for a contradiction, that
       $\sqrt{2}$ is rational.  That is, there are coprime integers
       $a$ and $b$ such that $\sqrt{2}=\frac{a}{b}.$\pause

        \item\alt<4>{\color{red}}{\color{green}}$\sqrt{2}$
     \end{itemize}
     \only<5>{Easy Peasy!}
    \end{proof}
\end{frame}
\end{document}

結果:

ここに画像の説明を入力してください

答え2

\alertコマンドを使うといいかもしれません

 \documentclass{beamer}
 \mode<presentation>
 \usepackage{amsfonts,amsmath,amssymb,graphicx,xcolor}
 \newtheorem{thm}{Theorem}
 \begin{document}
 \title{...} 

 \begin{frame}
     \titlepage
 \end{frame}

 \begin{frame}
     \begin{thm}
         $\sqrt{2}$ is irrational.
     \end{thm}\pause
     \begin{proof}
         The proof is by contradiction.\pause

          \begin{itemize}
             \item\alert<3>{Suppose, for a contradiction, that $\sqrt{2}$ is rational. That is, there are coprime integers $a$ and $b$ such that $\sqrt{2}=\frac{a}{b}.$}\pause

                 \item\alert<4>{$\sqrt{2}$}
          \end{itemize}
     \end{proof}
 \end{frame}
 \end{document}

関連情報