数学模式中出现警报的奇怪行为

数学模式中出现警报的奇怪行为

alerted text当我将中的颜色更改为 时,出现了这种意外行为mathmode。特别是,alerted text.fg似乎只有在再次调用 时才会改变\alert。更改\colorlet只会影响 内部的颜色mathmode

以下是一个例子

\documentclass{beamer}
\begin{document}    
\begin{frame}{Title}
    $\begingroup\setbeamercolor{alerted text}{fg=blue}\alert{blue}\endgroup+\textcolor{alerted text.fg}{red}$  These should be \textcolor{alerted text.fg}{red}, \alert{red} and \textcolor{alerted text.fg}{red}
    
    $\begingroup\setbeamercolor{alerted text}{fg=blue}\alert{blue}\endgroup\setbeamercolor{alerted text}{fg=red}+\textcolor{alerted text.fg}{red}$  These should be \textcolor{alerted text.fg}{red}, \alert{red} and \textcolor{alerted text.fg}{red}
    
    $\begingroup\setbeamercolor{alerted text}{fg=blue}\alert{blue}\endgroup\setbeamercolor{alerted text}{fg=red}\colorlet{alerted text.fg}{red}+\textcolor{alerted text.fg}{red}$  These should be \textcolor{alerted text.fg}{red}, \alert{red} and \textcolor{alerted text.fg}{red}
    
    $\begingroup\setbeamercolor{alerted text}{fg=blue}\alert{blue}\endgroup\setbeamercolor{alerted text}{fg=red}\alert{}+\textcolor{alerted text.fg}{red}$  These should be \textcolor{alerted text.fg}{red}, \alert{red} and \textcolor{alerted text.fg}{red}
\end{frame}

\end{document}

答案1

\setbeamercolor{}{}它本身还不能创建.fg.bg颜色,只有在使用投影仪颜色时才会创建它们。

但是,您不必来回更改警报颜色,而是可以使用您喜欢的任何颜色创建更多类似警报的宏 - 或者简单地使用\structure,默认情况下为蓝色。

\documentclass{beamer}

\setbeamercolor{foo}{fg=green}

\newenvironment<>{fooenv}{\begin{altenv}#1%
    {\usebeamercolor[fg]{foo}\usebeamerfont{foo}\usebeamertemplate{foo text begin}}
    {\usebeamertemplate{foo text end}}{\color{.}}{}\ignorespaces}{\ifhmode\unskip\fi\end{altenv}}

\newcommand<>{\foo}[1]{\begin{fooenv}#2\relax#1\end{fooenv}}


\begin{document}    
\begin{frame}{Title}
    $\structure{blue}+\textcolor{alerted text.fg}{red}$  These should be \textcolor{alerted text.fg}{red}, \alert{red} and \textcolor{alerted text.fg}{red}
    
    $\foo{green}+\textcolor{alerted text.fg}{red}$  These should be \textcolor{alerted text.fg}{red}, \alert{red} and \textcolor{alerted text.fg}{red}    

\end{frame}

\end{document}

在此处输入图片描述

相关内容