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.

4
  • 1
    Could you please add a minimal example?
    – egreg
    Sep 4, 2013 at 14:04
  • The 1=2 in quotation is not marked as math, so TeX considers it normal text.
    – egreg
    Sep 4, 2013 at 14:16
  • sorry for this mistake; actual problem is updated. it is in eqnarray
    – BaRud
    Sep 4, 2013 at 14:20
  • See also tex.stackexchange.com/q/37541/86 and the questions/answers linked therein. Sep 4, 2013 at 15:36

1 Answer 1

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

5
  • 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 4, 2013 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 :) Sep 4, 2013 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 4, 2013 at 14:38
  • @Rudra: no, I've tested that example and it works too. Sep 4, 2013 at 17:29
  • If you want to keep a separate color for \text{} in math mode, try this Jun 12, 2022 at 19:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .