Math & ScienceGlobal command for color equations?

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
peaches2165
Posts: 25
Joined: Wed Oct 22, 2008 5:03 pm

Global command for color equations?

Post by peaches2165 »

Hi All,

I'm new to the list and have been working with Latex for a couple of years now. What I would like to do is to make the equations in a document all one color. Other than using beamer is there a global command that will allow this?

I have been using

\documentclass{article}
\usepackage[dvips]{color}
\usepackage{epsfig}
%\topmargin -.7in
\textheight 9in
%\oddsidemargin .25in
%\evensidemargin .25in
%\textwidth 6in
\parskip .15in
\pagestyle{empty}

\vspace*{-.25in}


\newcommand{\green}[1]{ {\color{green} #1} }
\newcommand{\black}[1]{ {\color{black} #1} }
\newcommand{\red}[1]{ {\color{red} #1} }
\newcommand{\blue}[1]{ {\color{blue} #1} }
\newcommand{\magenta}[1]{ {\color{magenta} #1} }
\newcommand{\skyblue}[1]{ {\color{sky} #1} }
\newcommand{\mauve}[1]{ {\color{lightbrown} #1}}
\newcommand{\bluebox}[1]{ \skyblue{\ovalbox{ \black{#1} } } }
\definecolor{sky}{rgb}{0,.6,1}
\definecolor{lightbrown}{rgb}{.8,.5,.1}

and I know that I can code like this

\color{blue}{$\Gamma \alpha 234 \int \pi$}

but I have quite a few equations in the document. Anyone know of a solution?

Thanks,

Peaches
:idea:

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Global command for color equations?

Post by Stefan Kottwitz »

Hi Peaches,

welcome to the board!
The empheq package could be useful for you.

Without that package there's another quick solution:

Code: Select all

\everymath{\color{blue}}
for inline formulas, you could add

Code: Select all

\everydisplay{\color{blue}}
for displayed formulas. But if you're using footnotes: footnote markers/numbers would be set in math mode and would be colored too.

Stefan
LaTeX.org admin
peaches2165
Posts: 25
Joined: Wed Oct 22, 2008 5:03 pm

Re: Global command for color equations?

Post by peaches2165 »

That worked. Many thanks!

Peaches
chipheo
Posts: 2
Joined: Mon Apr 27, 2009 4:52 pm

Re: Global command for color equations?

Post by chipheo »

Hi Stefan_K,

I would like to change globally equation color of the whole slides and I did exactly what you recommended but it did not work:

\everymath{\color{blue}}

\everydisplay{\color{blue}}

As I used latex for the slides for presentation so I'm not sure if it works for slides? Or it just works for report/article only? Can you please help me? Thanks.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Re: Global command for color equations?

Post by Stefan Kottwitz »

Hi chipheo,

welcome to the board!
Did you get an error message? Which one? The package color or xcolor would be needed. Did you load it?

Which class are you using for your presentation - beamer, powerdot, slides, ... ?

Stefan
LaTeX.org admin
chipheo
Posts: 2
Joined: Mon Apr 27, 2009 4:52 pm

Global command for color equations?

Post by chipheo »

Hi Stefan_K,

Many thanks for answering my question...

I don't use the special packages like beamer or powerdor, I use the normal one 'lecture' (I think it is very standard package in Latex!)

There was no error message but there is also no effect to the slides, e.g., it does not change the color globally of the equations.

In the two commands you gave, only the second one works

Code: Select all

\everydisplay{\color{blue}}
but in each slide only -- I have to put this command at the beginning of each slide so that it changes the color of all equations in this particular slide, it do not change globally all equations of all slides even when I put it in the preamble.

The first one

Code: Select all

\everymath{\color{blue}}
does not work even in each slide.

I also tried the 'xcolor' but it is still the same.

Actually, since I'm doing slides for presentation I would like to change the color globally of text/equations/background in the slides -- but I don't want to install new packages. So could you please tell me the easiest way to change color globally of the above things...?

Once again, many thanks for helping me.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Global command for color equations?

Post by Stefan Kottwitz »

On my system there's no lecture class, even the search feature of CTAN did not return one.
So I cannot test what you are describing. Could you post your class as attachment here? Or is it another standard class not named "lecture"?

Stefan
LaTeX.org admin
Post Reply