使用带有 \includegraphics 的宏时出现 \pause 问题

使用带有 \includegraphics 的宏时出现 \pause 问题

我定义了以下命令,允许我将图标置于数学模式:

\newcommand{\icon}[1]{%
\mathord{\raisebox{-0.25ex}{\includegraphics[height=2ex]{#1}}}%
}

问题是,如果我想在 beamer 中使用它,如下面的 MWE 中所示,图标无法正确地着色。

\documentclass[12pt,aspectratio=169]{beamer}

\usetheme{Copenhagen}
\setbeamercovered{dynamic}

\newcommand{\icon}[1]{%
\mathord{\raisebox{-0.25ex}{\includegraphics[height=2ex]{#1}}}%
}

\begin{document}

\begin{frame}
    \begin{itemize}
        \item x
        \pause
        \item $\icon{file.png}$
        \pause
        \item x
    \end{itemize}
\end{frame}

\end{document}

我如何修改icon命令以便以可重复使用的方式正确“传播”阴影信息?

答案1

你可以使用@Ulrike Fischer 的这个技巧

\documentclass[12pt,aspectratio=169]{beamer}

\usetheme{Copenhagen}
\setbeamercovered{dynamic}


\usepackage{transparent}
\makeatletter
\def\beamer@startcovered{%
  \beamer@smuggle{%
  \global\advance\beamer@coveringdepth by 1\relax%
  \beamer@actions{\pgfsys@begininvisible\aftergroup\beamer@@spacingcover}{%
     \pgfsys@endinvisible\aftergroup\beamer@@spacingcover%
     }%
  \def\opaqueness<##1>##2{%
    \only<##1>{%
      \beamer@actions{%
    \transparent{\fpeval{##2/100}}%
      }%
      {% end code needed???
      }}}%
  \ifnum\beamer@slideinframe<\beamer@minimum %ok, at beginning
    \begingroup
      \beamer@saveanother
      \advance\beamer@minimum by-\beamer@slideinframe
      \beamer@slideinframe=\beamer@minimum
      \beamer@uncoverbeforeactions
      \beamer@restoreanother
    \endgroup
  \else
    \begingroup
      \beamer@saveanother
      \advance\beamer@slideinframe by-\beamer@minimum
      \beamer@uncoverafteractions
      \beamer@restoreanother
    \endgroup
  \fi
  \beamer@do
  }%
}

\makeatother



\newcommand{\icon}[1]{%
\text{\raisebox{-0.25ex}{\includegraphics[height=2ex]{#1}}}%
}

\begin{document}

\begin{frame}
    \begin{itemize}
        \item x
        \pause
        \item $\icon{example-image-duck}$
        \pause
        \item x
    \end{itemize}
\end{frame}

\end{document}

在此处输入图片描述

相关内容