ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 11 Jun 2020 13:14:59 +0200Jupyter, Mathjax colorhttps://ask.sagemath.org/question/51903/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 ?Thu, 11 Jun 2020 10:55:43 +0200https://ask.sagemath.org/question/51903/jupyter-mathjax-color/Answer by Juanjo for <p>The following page <code>http://adereth.github.io/blog/2013/11/29/colorful-equations/</code> gives advice to add color in mathjax. But this seems not to work with Sage under Jupyter. Has some body a solution ?</p>
https://ask.sagemath.org/question/51903/jupyter-mathjax-color/?answer=51905#post-id-51905Yes, 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](http://adereth.github.io/blog/2013/11/29/colorful-equations/) 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](https://ask.sagemath.org/question/51717/color-in-latex/). 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.Thu, 11 Jun 2020 11:51:36 +0200https://ask.sagemath.org/question/51903/jupyter-mathjax-color/?answer=51905#post-id-51905Comment by Cyrille for <p>Yes, it works. In a Markdown cell, you just need to put the code in math mode and explicitly load the <code>color</code> module. Thus, this code</p>
<pre><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}}$$
</code></pre>
<p>produces <a href="http://adereth.github.io/blog/2013/11/29/colorful-equations/">the colourful formula</a> you linked when the Markdown cell is evaluated:</p>
<p>$$
\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}}
$$</p>
<p>By the way, you have already asked about color in <a href="https://ask.sagemath.org/question/51717/color-in-latex/">this other question</a>. 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.</p>
https://ask.sagemath.org/question/51903/jupyter-mathjax-color/?comment=51906#post-id-51906Juanjo 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.Thu, 11 Jun 2020 12:10:29 +0200https://ask.sagemath.org/question/51903/jupyter-mathjax-color/?comment=51906#post-id-51906Comment by Juanjo for <p>Yes, it works. In a Markdown cell, you just need to put the code in math mode and explicitly load the <code>color</code> module. Thus, this code</p>
<pre><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}}$$
</code></pre>
<p>produces <a href="http://adereth.github.io/blog/2013/11/29/colorful-equations/">the colourful formula</a> you linked when the Markdown cell is evaluated:</p>
<p>$$
\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}}
$$</p>
<p>By the way, you have already asked about color in <a href="https://ask.sagemath.org/question/51717/color-in-latex/">this other question</a>. 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.</p>
https://ask.sagemath.org/question/51903/jupyter-mathjax-color/?comment=51907#post-id-51907It 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`.Thu, 11 Jun 2020 12:51:46 +0200https://ask.sagemath.org/question/51903/jupyter-mathjax-color/?comment=51907#post-id-51907Comment by Juanjo for <p>Yes, it works. In a Markdown cell, you just need to put the code in math mode and explicitly load the <code>color</code> module. Thus, this code</p>
<pre><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}}$$
</code></pre>
<p>produces <a href="http://adereth.github.io/blog/2013/11/29/colorful-equations/">the colourful formula</a> you linked when the Markdown cell is evaluated:</p>
<p>$$
\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}}
$$</p>
<p>By the way, you have already asked about color in <a href="https://ask.sagemath.org/question/51717/color-in-latex/">this other question</a>. 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.</p>
https://ask.sagemath.org/question/51903/jupyter-mathjax-color/?comment=51908#post-id-51908Concerning the [other question](https://ask.sagemath.org/question/51717/color-in-latex/), 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.Thu, 11 Jun 2020 12:59:21 +0200https://ask.sagemath.org/question/51903/jupyter-mathjax-color/?comment=51908#post-id-51908Comment by Cyrille for <p>Yes, it works. In a Markdown cell, you just need to put the code in math mode and explicitly load the <code>color</code> module. Thus, this code</p>
<pre><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}}$$
</code></pre>
<p>produces <a href="http://adereth.github.io/blog/2013/11/29/colorful-equations/">the colourful formula</a> you linked when the Markdown cell is evaluated:</p>
<p>$$
\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}}
$$</p>
<p>By the way, you have already asked about color in <a href="https://ask.sagemath.org/question/51717/color-in-latex/">this other question</a>. 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.</p>
https://ask.sagemath.org/question/51903/jupyter-mathjax-color/?comment=51909#post-id-51909Juanjo 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.Thu, 11 Jun 2020 13:14:59 +0200https://ask.sagemath.org/question/51903/jupyter-mathjax-color/?comment=51909#post-id-51909