Changing text color of math in editor

Hello everyone, this is my first post in the forum and I apologize if I put this in the wrong category.

What I am/was trying to do

As one or two other posters, I had difficulty to change the color of math environments away from the default dark red when using dark themes.

What I tried (with partial success)

Using the css inspection, I found that something like

  .cm-s-obsidian .cm-inline-code,
    .cm-s-obsidian .cm-math {
      color: #ffe495;
    }

should change the color to a yellowish white, but inserting this into the css file under .obsidian/themes did not change the color as I had hoped.
I am not sure yet whether this is just a simple mistake on my side (I have approximately zero experience with css) or whether there is a reason why the themes cannot change the color of math text.

My current solution is to activate the option “Appearance>Apply Custom CSS”
and just add the lines above to the obsidian.css file in the main vault folder. This does change the text color of math environments without visibly changing the theme chosen from .obsidian/themes in other ways.

Although this is not a great solution (the ‘Apply Custom CSS’ option is marked as legacy), it does work, so I wanted to share in case that others had the same problem.

And, of course, if there is a nicer way to do this or if my solution is problematic for some reason, I would be happy to learn about it.

Try adding !important to the attribute you want to change. See above.

!important overrides other styles added to that attribute. It should be used sparingly but if you’re just doing something quick and simple it can often help.

1 Like

This works perfectly, thanks!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.