
當我將顏色更改為alerted text
in時,我得到了這種意外的行為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}