Frank Vel
Frank Vel

Reputation: 1208

Changing the color in MathJax or MathML

If I have an equation like ax+b and I want to be able to display these with the coefficients highlighted, I could write

MathJax:

\(\color{blue}{m}x+\color{red}{c}\)

MathML:

<math>
    <mi style="color: blue">m</mi>
    <mi>x</mi>
    <mo>+</mo>
    <mi style="color: red">c</mi>
</math>

If I want to change the colors of the MathML-code I can simply use class-tags for the coefficients

    <mi class="mColor">m</mi>

and I can use a simple jQuery script (.css()) to change the colour of this class. Is there a similar tool for MathJax? Something like

\color{$mColor}{m}

Which I can change with a jQuery script?

tldr:
Is there a script in JS/jQuery which lets me change the colour of a MathJax symbol?

Upvotes: 0

Views: 1261

Answers (1)

Davide Cervone
Davide Cervone

Reputation: 12205

Use \(\class{mColor}{m}x+\class{cColor}{c}\). This will produce

<math xmlns="http://www.w3.org/1998/Math/MathML">
  <mi class="mColor">m</mi>
  <mi>x</mi>
  <mo>+</mo>
  <mi class="cColor">c</mi>
</math>

so that you can change the styling of those two classes as you normally would.

Upvotes: 2

Related Questions