Ask Your Question

How change latex background text color in jupyter?

asked 2020-11-22 17:19:41 +0200

rob gravatar image

Expression Math( r"\color{green}{sample}") displays green text in latex in jupyter workbook. What is the directive to change the background color of the text? The directives \textcolor, \colorbox do not work.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2020-11-22 21:09:50 +0200

slelievre gravatar image

updated 2020-11-29 04:53:37 +0200

Jupyter uses MathJax to render LaTeX. The reference for this question is therefore:

One solution indicated there involves modifying "the load array of the loader block of your MathJax configuration". I did not try that.

The other one, which I tried with success, consists in fist executing a markdown cell with


and then using \colorbox, for example:

$\colorbox{yellow}{Writing on yellow background!}$

This enables math fragments on color background, as part of displayed equations.

For instance:

\text{Change to }\colorbox{yellow}{yellow background}\text{ and write }
\colorbox{yellow}{$\sum_{k=1}^n e^{i \cdot k \cdot \tau / n} = 0$}

For inline math, $\colorbox{yellow}{$ ... $}$ would not parse.

The trick is to use $\colorbox{yellow}{\( ... \)}$ instead.

In the screenshot below, relevant markdown cells are duplicated, and showed once in edit mode and once in displayed mode.

Jupyter LaTeX color background

edit flag offensive delete link more


Thank you very much. This is it:

rob gravatar imagerob ( 2020-11-23 18:22:55 +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


Asked: 2020-11-22 17:19:41 +0200

Seen: 278 times

Last updated: Nov 29 '20