数学モードでのアラートの奇妙な動作

数学モードでのアラートの奇妙な動作

alerted textで色を に変更すると、この予期しない動作が発生しましたmathmode。特に、 は、が再度呼び出されたalerted text.fgときにのみ変更されるようです。 での変更は、 内の色にのみ影響します。\alert\colorletmathmode

ここに例を挙げる

\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}

ここに画像の説明を入力してください

関連情報