Take the 2-minute tour ×
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.

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.

WORKING CODE:

\documentclass[svgnames]{report}
\usepackage{tikz}
\usepackage[cp1250]{inputenc}
\usepackage[slovak]{babel}
\usepackage{kpfonts}



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

% example
\begin{document}

% MATH
            $$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}} $$                                       


% ILLUSTRATION
\setlength{\unitlength}{1mm}
\begin{picture}(120,100)(-8,0)
   \put(35,5){\vector(1,0){50}}
   \put(88,5){\makebox(0,0){$h$}}
   \put(40,2){\makebox(0,0){$h_A$}}
   \put(70,2){\makebox(0,0){$h_B$}}
   \multiput(40,5)(30,0){2}{\line(0,1){90}}
   \multiput(40,5)(0,10){7}{\line(1,1){30}}
   \multiput(40,35)(6,0){5}{\line(1,0){3}}
   \multiput(40,65)(6,0){5}{\line(1,0){3}}
   \multiput(40,5)(0,30){3}{\circle*{2}}
   \multiput(70,35)(0,15){3}{\circle*{2}}
   \multiput(40,35)(0,30){2}{\line(1,-1){30}}
   \multiput(39.75,15)(.25,0){3}{\line(0,1){10}}
   \multiput(39,15)(0,10){2}{\line(1,0){2}}
   \multiput(69.75,55)(.25,0){3}{\line(0,1){10}}
   \multiput(69.75,40)(.25,0){3}{\line(0,1){5}}
   \multiput(69,35)(0,5){7}{\line(1,0){2}}
   \put(97,60){\makebox(0,0){$
     \left\}\rule[-4mm]{0mm}{8mm}\right.\leftarrow
     \Delta\tau = 2T_{Cs}\mbox{(lokale Uhr)}
     $}}
   \put(98,50){\makebox(0,0){$\leftarrow$ \emph{Explosion der 2. Uhr}}}
   \put(96,42.5){\makebox(0,0){$\left\}\rule[-1.5mm]{0mm}{3mm}\right.
     \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(38,8){\makebox(0,0){1}}
   \put(17,35){\makebox(0,0){ \emph{Start der 1. Uhr} $\rightarrow$ 2$A$}}
   \put(13,65){\makebox(0,0)
                {\emph{Explosion der 1. Uhr} $\rightarrow$ 3$A$}}
   \put(93,35){\makebox(0,0)
                { 2$B \leftarrow$ \emph{Start der 2. Uhr}}}
   \put(74,68){\makebox(0,0){$3B$}}
\end{picture}

\end{document}

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

share|improve this question
2  
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

2 Answers 2

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

\everydisplay{\color{colMATH}}
\usepackage{etoolbox}
\AtBeginEnvironment{picture}{\color{colILLUS}}

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
1  
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
1  
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?

CODE:

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


\let\oldbmath\[
\renewcommand{\[}{\begingroup\color{colMATH}\oldbmath}
\let\endoldmath\]
\renewcommand{\]}{\endoldmath\endgroup}


%math function
\[
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}}
\]
share|improve this answer
3  
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

 
discard

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.