# Jupyter, Mathjax color

The following page http://adereth.github.io/blog/2013/11/29/colorful-equations/ gives advice to add color in mathjax. But this seems not to work with Sage under Jupyter. Has some body a solution ?

edit retag close merge delete

Sort by ยป oldest newest most voted

Yes, it works. In a Markdown cell, you just need to put the code in math mode and explicitly load the color module. Thus, this code

$$\require{color} \definecolor{energy}{RGB}{114,0,172} \definecolor{freq}{RGB}{45,177,93} \definecolor{spin}{RGB}{251,0,29} \definecolor{signal}{RGB}{18,110,213} \definecolor{circle}{RGB}{217,86,16} \definecolor{average}{RGB}{203,23,206} \color{energy} X_{\color{freq} k} \color{black} = \color{average} \frac{1}{N} \sum_{n=0}^{N-1} \color{signal}x_n \color{spin} e^{\mathrm{i} \color{circle} 2\pi \color{freq}k \color{average} \frac{n}{N}}$$


produces the colourful formula you linked when the Markdown cell is evaluated:

$$\require{color} \definecolor{energy}{RGB}{114,0,172} \definecolor{freq}{RGB}{45,177,93} \definecolor{spin}{RGB}{251,0,29} \definecolor{signal}{RGB}{18,110,213} \definecolor{circle}{RGB}{217,86,16} \definecolor{average}{RGB}{203,23,206} \color{energy} X_{\color{freq} k} \color{black} = \color{average} \frac{1}{N} \sum_{n=0}^{N-1} \color{signal}x_n \color{spin} e^{\mathrm{i} \color{circle} 2\pi \color{freq}k \color{average} \frac{n}{N}}$$

By the way, you have already asked about color in this other question. It seems that you haven't read the answers. It would be nice to mark some of them as accepted or comment why they are not valid.

more

Juanjo I read answer but that one was not effectiove. For yours I have never seen the command \require{color}. So I have copied you suggestion and I have an error invalid syntax. So I change $\$\$.. \$\ for only one but the error remains. I am under Windows10.

( 2020-06-11 12:10:29 +0100 )edit

It seems that you have copied the above code in a code cell. So you obviously got an invalid syntax error. No, you should paste it in a Markdown cell. If you want color in a result yielded by some computation, check the answer in the other question.

MathJax has several extensions. Not all of them seem to be active by default in the Jupyter notebook. They can be loaded as needed using the \require command. This is why I added \require{color}, so as MathJax recognizes \color and \definecolor.

( 2020-06-11 12:51:46 +0100 )edit

Concerning the other question, if answers are not valid or ineffective, at least, comment it and explain why. This may lead to better answers. In any case, people spends time trying to help you, so it is polite to offer some feedback.

( 2020-06-11 12:59:21 +0100 )edit

Juanjo I apologize I was persuaded that I was in a markdown cell. You are true It works. For the other question I recognize the help effort but some times and thanks the community for it, but sometime I postpone the comment because I do other thing and of course I forget the question. I am sincerely sorry.

( 2020-06-11 13:14:59 +0100 )edit