sobrepor cores de um texto específico

sobrepor cores de um texto específico
\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}

Estou tentando fazer

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}.

Vermelho no terceiro slide da sobreposição e preto normal no quarto, porém no quarto ele simplesmente desapareceu completamente. Por que é isso?

Responder1

O \only-command imprimirá o seguinte conteúdoapenasnesses slides, você define. Portanto, você \only<3>imprimirá a frase apenas na sobreposição 3. Ela é invisível na sobreposição 4 e nas seguintes. Daí o seu problema, de não ver o texto.

Se você deseja ter alguma preparação especial na sobreposição 3, mas com aparência normal em todas as outras sobreposições, use o \altcomando. Se pegar o conjunto de sobreposições (no seu caso <3>e no primeiro par de colchetes, você pode definir o que deve acontecer naquela sobreposição. Em qualquer outra sobreposição, é usado o conteúdo do segundo par de colchetes.

Veja omanual do projetorpara comandos adicionais como \uncover, \invisible, \visible, ...

No seu caso, basta chamar \color{red}o overlay 3. Como \coloré um comando, tudo o que segue ficará na cor vermelha. A coloração terminará automaticamente no ambiente circundante (aqui: itemize).

(Adicionei uma quinta sobreposição, para prova, que \color{green}não afeta nada fora do ambiente. Se quiser mais controle sobre os comandos, é claro que você pode usar \textcolor{}ou copiar e colar o texto, conforme mostrado aqui \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}

Resultado:

insira a descrição da imagem aqui

Responder2

Você pode querer usar o comando \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}

informação relacionada