TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to change the color of all math in my document. I understand that several packages and some engines provide support for changing the color of all math, and I understand that something like


almost works, but also ends up coloring things like URLs and captions, while failing to color displayed equations.

Is there a reliable way to change the color of just math, in pdflatex, without relying on special packages or classes?

share|improve this question
easy-peasy with xelatex or lualatex ... – Loop Space Mar 15 '12 at 22:32
This needs a Minimal non-Working Example that shows the mal-colored captions, URLs and display math. Btw, it's strongly discouraged to use $$...$$, better switch to \[...\]. – yo' Mar 15 '12 at 22:39
@tohecz : What is the difference between the two? I am an ignorant who just doesn't know and I wonder. I must say I use the cash's all the time so I guess it's good I ask – Patrick Da Silva Mar 15 '12 at 22:59
The $ ... $ for inline and $$ ... $$ for displayed come from TeX and are not recommended for LaTeX. They do work 'most' of the time. However the do interfere with several packages (and worse the error is ofter very hard to spot. e.g. they conflict with fleqn from amsmath. I teach my students to use ( ..) and [ ...] respectively, and I get fewer LaTeX questions the night before something is due. – R. Schumacher Mar 16 '12 at 0:15
For more details see tex.stackexchange.com/questions/503/why-is-preferable-to – R. Schumacher Mar 16 '12 at 0:22
up vote 11 down vote accepted

will get you most of the way there, although you are still likely to need some special fixup for individual commands here and there that use math internally without using the \m@th command which I redefine above to reset the color. Most "internal" uses of math for vertical centering tables or superscripting footnote marks etc, use that macro but that convention (from Plain TeX originally) is not enforced anywhere, and also redefining it might not be safe in all contexts (\edef for example) so some uses may need more explicit redefinitions to reset the colour.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.