Ask Your Question
-1

Jupyter, Mathjax color

asked 2020-06-11 10:55:43 +0200

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 ?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2020-06-11 11:51:36 +0200

Juanjo gravatar image

updated 2020-06-11 11:56:48 +0200

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.

edit flag offensive delete link more

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 ( 2020-06-11 12:10:29 +0200 )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.

Juanjo gravatar imageJuanjo ( 2020-06-11 12:51:46 +0200 )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.

Juanjo gravatar imageJuanjo ( 2020-06-11 12:59:21 +0200 )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.

Cyrille gravatar imageCyrille ( 2020-06-11 13:14:59 +0200 )edit

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: 2020-06-11 10:55:43 +0200

Seen: 761 times

Last updated: Jun 11 '20