Search code examples
rr-markdownmarkdownmathjax

Adding colorful background to equation by acting directly on MathJax without CSS


I am trying to add a colorful background to an equation. I can accomplish that by using CSS, but now I am wondering where it is possible to do that directly in the script calling MathJax.

Please, find below a rmarkdown example.

---
title: "Untitled"
output: html_document
---

Some text:

$$Y = \beta_0 + \beta_ 1 X_1 + \ldots + \beta_n X_n.$$

Solution

  • It is easy:

    $$\require{color}\colorbox{magenta}{y = (sin)x}$$
    

    enter image description here

    For the coloring text of an equation you can use:

    $$\color{green}{y = (cos)x}$$
    

    enter image description here