TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

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

My problem is that I want my math functions and drawing illustrations to be in different colors. I want my colors to be defined at the beginning so they will automatically change the color of math and illustration as i like. I was never working with math and drawing before so that's why it is a bit problem for me. Thank you very much for your help.



\definecolor{colMATH}{RGB}{255,0,0} % color of the math functions
\definecolor{colILLUS}{RGB}{0,0,255} % line color in illustration

% example

            $$detA=|A|= \left|\begin{array}{cccc}
            a_11 & a_12 & \ldots & a_{1n} \\
            a_21 & a_22 & \ldots & a_{2n} \\
            . & . &  & . \\
            . & . &  & . \\
            . & . &  & . \\
            a_{n1} & a_{n2} & \ldots & a_{nn} \\
            \end{array} \right|=\sum{(-1)^ja_{1k_1}\cdot a_{2k_2}\cdot a_{3k_3}\cdot...\cdot a_{nk_n}} $$                                       

     \Delta\tau = 2T_{Cs}\mbox{(lokale Uhr)}
   \put(98,50){\makebox(0,0){$\leftarrow$ \emph{Explosion der 2. Uhr}}}
     \hskip1mm\leftarrow\Delta\tau = T_{Cs}\mbox{(lokale Uhr)}$}}
   \put(25,20){\makebox(0,0){$\Delta\tau = T_{Cs}\rightarrow
     \left\{\rule[-4mm]{0mm}{8mm}\right.$}}  %}
   \put(17,35){\makebox(0,0){ \emph{Start der 1. Uhr} $\rightarrow$ 2$A$}}
                {\emph{Explosion der 1. Uhr} $\rightarrow$ 3$A$}}
                { 2$B \leftarrow$ \emph{Start der 2. Uhr}}}


THIS IS WHAT I WANT TO HAVE: enter image description here

share|improve this question
This example does not require TikZ, though I would use TikZ instead of a LaTeX picture environment. – Stefan Kottwitz Jan 14 '12 at 13:28

In your example, it can be solved using \everydisplay for displayed math and the etoolbox package for the pictures:


colored environments

Some advice: your should not use $$, further better use math operators such as \det, consider using TikZ (or PSTricks), for more math features use amsmath. The latter can have problems with \everydisplay though.

share|improve this answer
This is a partial solution. I've been playing with this as well. The problem is that it doesn't work for ordinary math. You can use \everymath to set the color but then the colour of any text after ordinary math in a Tikz node will revert to black. (So \draw node {blah $a=b$ blur}; will colour blah $a=b$ as requird but will colour blur in the default colour.) – Marc van Dongen Jan 14 '12 at 13:41
I notice your solution is for the picture environment, so I should have rephrased my comment. Still it would be nice to also make it work for TikZ. – Marc van Dongen Jan 14 '12 at 13:45
For finer control over the colour of maths, see Will Robertson's answer to tex.stackexchange.com/q/335/86 – Loop Space Jan 14 '12 at 14:05
@Andrew Thanks for the link. Unfortunately, it's not for pdflatex. – Marc van Dongen Jan 14 '12 at 14:30
Allegedly, it's on its way (see tex.stackexchange.com/q/2986/86) – Loop Space Jan 14 '12 at 14:51

I have found a solution for math but it is not super cool. Is there any other possibility to make it work like this?


\definecolor{colMATH}{RGB}{255,0,0} % color of the math functions


%math function
       a_11 & a_12   & \ldots & a_{1n} \\
       a_21 & a_22   & \ldots & a_{2n} \\
          . & .      &        & . \\
          . & .      &        & . \\
          . & .      &        & . \\
     a_{n1} & a_{n2} & \ldots & a_{nn} \\
\right|=\sum{(-1)^ja_{1k_1}\cdot a_{2k_2}\cdot a_{3k_3}\cdot...\cdot 
share|improve this answer
What's bad about Stefan Kottwitz's answer? This one won't work for other display math environments. – egreg Jan 15 '12 at 17:41

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.