I want to put all math mode in a color, for example, red. But I don't know how to do that. In this web I found how to do it, but in Beamer, I want do it too in Article, Book, etc.

Thanks for your time.

  • 5
    \everymath{\color{red}}, \everydisplay{\color{red}}? Commented Nov 12, 2014 at 7:22
  • 1
    Welcome to TeX.SX! I'm not sure why you'd want such a device.
    – egreg
    Commented Nov 12, 2014 at 10:43
  • Sort of related: tex.stackexchange.com/q/335/86 Commented Nov 12, 2014 at 21:56

1 Answer 1


Here is a way:




\renewcommand{\)}{\relax\ifmmode\ifinner$\color{black}\else\@badmath\fi\else \@badmath\fi}



Una funzione $f:U \longrightarrow \mathbb{C}, U\){} aperto di $\mathbb{C}${} si dice  \textbf{olomorfa} se \`{e} \(\mathbb{C}\)-derivabile in ogni punto di \(U\), ovvero se \(\forall\) \(z_0 \in U\ \exists\){} finito
\lim_{h \to 0}\frac{f(z_0+h)-f(z_0)}{h}=\frac{\partial f}{\partial z_0}, h\in \mathbb{C}.
\(f\){} \textbf{intera} se olomorfa su \(U=\mathbb{C}\).


However this solution is a little impractical for inline math mode. I suggest to use this trick only for display math mode, and use a contracted extra command when inline. Doing this with \everymath and \everydisplay is unsafe, as mentioned here: \everymath and author color

  • You can use the xspace package and then use \def${\ifmmode)\xspace\else(\fi} instead of \def${\ifmmode)\else(\fi}. With this we avoid using {} to add spaces
    – G al Cubo
    Commented Jan 23, 2018 at 2:39

You must log in to answer this question.

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