Beamer:如何创建一个类似“altenv”的环境

Beamer:如何创建一个类似“altenv”的环境

阅读本书第 9.6.3 节后beamer,我尝试创建一个新的环境,其行为应该与上述环境相同alertenv,但具有不同的视觉效果。这是我用于测试的代码。

\documentclass{beamer}
\begin{document}

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


\begin{frame}{With \texttt{alertenv}}
before items
  \pause
  \begin{itemize}[<+- | alert@+>]
    \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}

事实证明,如果覆盖框架使用altenv,则当前项目将更改为alert模式,即涂成红色。随着幻灯片编号的进展,此项目的颜色将变回黑色。

另一方面,如果相同的叠加框架使用itenv,则当前项目将变为斜体。但是,随着幻灯片编号的增加,它不会变回非斜体。

按顺序显示帧的动画

我在这里做错了什么?

相同示例:更多详细信息

以下是上述示例的更详细版本。如果有人想解决这个问题,它可能会被用来演示解决方案。

\documentclass{beamer}
\begin{document}

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

\begin{frame}{With \texttt{alertenv}}
    before items
    \pause
    \begin{itemize}[<+- | alert@+>]
        \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}

下面是一个小动画,演示了我的代码存在的问题。 在此处输入图片描述

答案1

一种可能的解决方案是将插入\begin{altenv}...\end{altenv}到定义中newenvironment,如下所示

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

在此处输入图片描述 在此处输入图片描述 在此处输入图片描述

代码

\documentclass{beamer}
\begin{document}

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

\begin{frame}{With \texttt{alertenv}}
    before items
    \pause
    \begin{itemize}[<+- | alert@+>]
        \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}

相关内容