# Beamer: How to make an environment which is like “altenv”

Reading Section 9.6.3 of the beamer book, I try to make a new environment which should behave just like alertenv but with different visual effects. Here is the code I use for testing this.

\documentclass{beamer}
\begin{document}

\newenvironment<>{itenv}{\mdseries\itshape}{}
\setbeamercovered{transparent}

before items
\pause
\item One
\item Two
\item Three
\end{itemize}
\pause
after items
\end{frame}

\begin{frame}{With \texttt{itenv}}
\setbeamercovered{transparent}
before items
\pause
\begin{itemize}[<+- | it@+>]
\item One
\item Two
\item Three
\end{itemize}
\pause
after items
\end{frame}
\end{document}


As it turns out, if an overlayed frame uses altenv, the current item changes to alert mode, i.e., painted in red. This item changes its color back to black, as the slide number progresses.

On the other hand, if the same overlayed frame uses itenv, the current item changes to italics. Butt, it does not changes back to non-italics as the slide number progresses.

What am I doing wrong here?

## Same Example: More Details

The following is a more verbose version of the example above. If someone cares to solve this problem, it might be used to demonstrate the solution.

\documentclass{beamer}
\begin{document}

\newenvironment<>{itenv}{\only{\mdseries\itshape}}{}
\setbeamercovered{transparent}

before items
\pause
\item I will be \textcolor{red}{red} \textbf{first}, and then return to be black.
\item I will be \textcolor{red}{red} \textbf{second}, and then return to be black.
\item I will be \textcolor{red}{red} \textbf{third}, and then return to be black.
\end{itemize}
\pause
after items
\end{frame}

\begin{frame}{With \texttt{itenv}}
before items
\pause
\begin{itemize}[<+- | it@+>]
\item I should be \textit{italicized} \textbf{first}, and then return to be up shaped.
Take a close look. Did I return to be \textup{Up Shape}''?
\item I should be \textit{italicized} \textbf{second}, and then return to be up shaped.
Ditto.
Am I \textup{Up Shape}'' or \textit{Italicized Shape}''?
\item I should be \textit{italicized} \textbf{third}, and then return to be up shaped.
Did I return to be \textup{Up Shape}'' or am I \textit{Italicized Shape}''?
\end{itemize}
\pause
after items
\end{frame}

\end{document}


And here is a little animation that demonstrates the problem with my code.

A possible solution is to insert the \begin{altenv}...\end{altenv} into the newenvironment definition as displayed below

\newenvironment<>{itenv}{%
\begin{altenv}#1
{\mdseries\itshape}
{}{}{}}
{\end{altenv}}


Code

\documentclass{beamer}
\begin{document}

\newenvironment<>{itenv}{%
\begin{altenv}#1{\mdseries\itshape}
{}{}{}}
{\end{altenv}}

before items
\pause
\item I will be \textcolor{red}{red} \textbf{first}, and then return to be black.
\item I will be \textcolor{red}{red} \textbf{second}, and then return to be black.
\item I will be \textcolor{red}{red} \textbf{third}, and then return to be black.
\end{itemize}
\pause
after items
\end{frame}

\begin{frame}{With \texttt{itenv}}
before items
\pause
\begin{itemize}[<+- | it@+>]
\item I should be \textit{italicized} \textbf{first}, and then return to be up shaped.
Take a close look. Did I return to be \textup{Up Shape}''?
\item I should be \textit{italicized} \textbf{second}, and then return to be up shaped.
Ditto.
Am I \textup{Up Shape}'' or \textit{Italicized Shape}''?
\item I should be \textit{italicized} \textbf{third}, and then return to be up shaped.
Did I return to be \textup{Up Shape}'' or am I \textit{Italicized Shape}''?
\end{itemize}
\pause
after items
\end{frame}

\end{document}