13

I am trying to define math text is some predefined color as in my preamble:

\setbeamercolor{math text}{pmsGreen}
\everymath{\color{pmsGreen}}
\everydisplay{\relax \ifx \\\@eqncr \else \color{pmsGreen}\fi }

NB: I have not understood the last line, just found it somewhere. But the problem is while mathmode is in pmsGreen, text inside eqnarray is still in default color. How can I manage this?

EDIT: A minimal example:

 \documentclass[10pt,a4paper,xcolor=dvipsnames,xcolor=table]{beamer}
\definecolor{pmsGreen}{RGB}{0,156,121}

\mode<presentation>
{
\usetheme{Darmstadt}
\usetheme{Warsaw}
\setbeamercovered{transparent}
}
\setbeamercolor{math text}{pmsGreen}
\everymath{\color{pmsGreen}}
\everydisplay{\relax \ifx \\\@eqncr \else \color{pmsGreen}\fi }
\DeclareMathOperator{\Tr}{Tr}
\DeclareMathOperator{\im}{Im}

\begin{document}
$1=2$
\begin{eqnarray}
  1=2\\
  2=3
\end{eqnarray}
\end{document}

NB: I have seen examples where the sample code shows the output as well, dont know how to do that.

ShreevatsaR
  • 45,428
  • 10
  • 117
  • 149
BaRud
  • 2,179

1 Answers1

13

Quoting the manual:

Beamer-Color math text

This color is the parent of math text inlined and math text displayed. It is empty by default. See those colors for details.

Beamer-Color math text displayed

Color parents: math text

Like math text inlined, only for so-called “displayed” mathematical text. This is mathematical text between [ and ] or between $$ and $$ or inside environments like equation or align. The setup of this color is somewhat fragile, use at your own risk. The background is currently ignored.

So, you have to exploit:

\setbeamercolor{math text}{fg=pmsGreen}
\setbeamercolor{math text displayed}{fg=pmsGreen}

to have also equations in align colored (avoid using eqnarray, see eqnarray vs align).

An example:

\documentclass[10pt,a4paper,xcolor=dvipsnames,xcolor=table]{beamer}
\definecolor{pmsGreen}{RGB}{0,156,121}
\usepackage{lmodern}
\mode<presentation>
{
\usetheme{Darmstadt}
\usetheme{Warsaw}
\setbeamercovered{transparent}
\setbeamercolor{math text}{fg=pmsGreen}
\setbeamercolor{math text displayed}{fg=pmsGreen}
}
\DeclareMathOperator{\Tr}{Tr}
\DeclareMathOperator{\im}{Im}

\begin{document}
\begin{frame}{Title}
$1=2$
\begin{quotation}
  1=2
\end{quotation}

\begin{equation}
x+y=100
\end{equation}

\begin{align}
  1=2 \\
  2=3
\end{align}
\begin{itemize}
\item \only<2>{Contains essentially \textit{all} physical information of a given system} $A(\vec{r},\vec{r}^{'})=-\dfrac{1}{\pi}\im\Tr\int^{\mu}_{\curvearrowright} dz~\hat{A}~G(\vec{r},\vec{r}^{'};z)$
\end{itemize}
\end{frame}
\end{document}

The result:

enter image description here

  • What's the purpose of \everymath and \everydisplay? I'd remove those lines; in any case, the second one should go between \makeatletter and \makeatother. – egreg Sep 04 '13 at 14:32
  • To be honest, I didn't check their meaning: just copied and paste from OP's code. I'll have a look in the beamer's manual for further explanation before removing them :) – Claudio Fiandrino Sep 04 '13 at 14:36
  • Cannot explain, but \item \only<2>{Contains essentially \textit{all} physical information of a given system} $A(\vec{r},\vec{r}^{'})=-\dfrac{1}{\pi}\im\Tr\int^{\mu}_{\curvearrowright} dz~\hat{A}~G(\vec{r},\vec{r}^{'};z)$
    requires \everymath
    – BaRud Sep 04 '13 at 14:38
  • @Rudra: no, I've tested that example and it works too. – Claudio Fiandrino Sep 04 '13 at 17:29
  • If you want to keep a separate color for \text{} in math mode, try this – Gautam Sreekumar Jun 12 '22 at 19:39