Loading [MathJax]/jax/output/HTML-CSS/jax.js
Ask Your Question
-1

Jupyter, Mathjax color

asked 4 years ago

Cyrille gravatar image

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 ?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 4 years ago

Juanjo gravatar image

updated 4 years ago

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:

Xk=1NN1n=0xnei2πknN

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.

Preview: (hide)
link

Comments

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.

Cyrille gravatar imageCyrille ( 4 years ago )

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.

Juanjo gravatar imageJuanjo ( 4 years ago )

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.

Juanjo gravatar imageJuanjo ( 4 years ago )

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.

Cyrille gravatar imageCyrille ( 4 years ago )

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 4 years ago

Seen: 1,173 times

Last updated: Jun 11 '20