如何让 \shortintertext 和 \intertext 在 beamer 中为它们的内联数学内容着色?

如何让 \shortintertext 和 \intertext 在 beamer 中为它们的内联数学内容着色?

我希望数学的互文性即使在内部也能被赋予色彩\shortintertext\intertext使用

\newcommand{\colorInlinedMath}{\everymath{\color{SpringGreen3}}\sisetup{color=SpringGreen3}}

我换了颜色,但我必须每次都使用它\shortintertext\intertext

在此处输入图片描述

如何获得第三个条目的结果而不必为每个\shortintertextand手动更改颜色\intertext

\documentclass[aspectratio=169, xcolor={x11names}, t, handout]{beamer}

\usetheme{Dresden}

\usepackage{mathtools}

\usepackage{siunitx}
\usefonttheme{professionalfonts}
\usepackage[defaultmathsizes, subdued, italic, LGRgreek, symbolre]{mathastext}

\setbeamercolor{math text inlined}{fg=SpringGreen3}
\newcommand{\colorInlinedMath}{\everymath{\color{SpringGreen3}}\sisetup{color=SpringGreen3}}

\begin{document}
        
\begin{frame}
    
    \begin{itemize}
        
        \item  $I_{f} = i_{L}(\infty) = \SI{0}{\ampere}$ (\alert{why?}). $\omega_{d}$ is given by
            
            \begin{alignat*}{2}
            \shortintertext{$I_{f} = i_{L}(\infty) = \SI{0}{\ampere}$ (\alert{why?}). $\omega_{d}$ is given by}
                \omega_{d} &= \sqrt{\omega_{0}^{2} - \alpha^{2}}
            \\
            \shortintertext{\colorInlinedMath $I_{f} = i_{L}(\infty) = \SI{0}{\ampere}$ (\alert{why?}). $\omega_{d}$ is given by}
                \omega_{d} &= \sqrt{\omega_{0}^{2} - \alpha^{2}}
            \end{alignat*}
        
    \end{itemize}
    
\end{frame}
    
\end{document}

答案1

\pretocmd使用以下命令解决etoolbox

\documentclass[aspectratio=169, xcolor={x11names}, t, handout]{beamer}

\usetheme{Dresden}

\usepackage{mathtools}
\usepackage{siunitx}
\usefonttheme{professionalfonts}
\usepackage[defaultmathsizes, subdued, italic, LGRgreek, symbolre]{mathastext}

\setbeamercolor{math text inlined}{fg=SpringGreen3}
\newcommand{\colorInlinedMath}{\everymath{\color{SpringGreen3}}\sisetup{color=SpringGreen3}}
\usepackage{etoolbox}
\makeatletter
\pretocmd{\intertext@}{\colorInlinedMath}{}{}
\makeatother

\begin{document}

\begin{frame}

    \begin{itemize}

        \item $I_{f} = i_{L}(\infty) = \SI{0}{\ampere}$ (\alert{why?}). $\omega_{d}$ is given by

            \begin{alignat*}{2}
            \shortintertext{$I_{f} = i_{L}(\infty) = \SI{0}{\ampere}$ (\alert{why?}). $\omega_{d}$ is given by}
                \omega_{d} &= \sqrt{\omega_{0}^{2} - \alpha^{2}}
            \\
            \shortintertext{\colorInlinedMath $I_{f} = i_{L}(\infty) = \SI{0}{\ampere}$ (\alert{why?}). $\omega_{d}$ is given by}
                \omega_{d} &= \sqrt{\omega_{0}^{2} - \alpha^{2}}
            \end{alignat*}

    \end{itemize}

\end{frame}

\end{document} 

在此处输入图片描述

相关内容