How to add color to Maths formulas which contain power exponent or fraction?

I'd like to add highlight to my Maths formulas.
I've found that "\colorbox{aqua}{...}" works great but it doesn't like when there are exponent or fraction:

This formula with exponent doesn't work:
$\colorbox{aqua}{E = mc^2}$


KaTeX parse error: Expected 'EOF', got '^' at position 23: …ox{aqua}{E = mc^̲2}

And this formula with fraction inside neither:
$\colorbox{aqua}{U = -\frac{G m_1 m_2}{r} }$
gives the error:

KaTeX parse error: Can't use function '\frac' in text mode at position 17: …colorbox{aqua}{\̲f̲r̲a̲c̲{

How can I find a way to highlight my Maths formulas when they contain power exponent or fraction?
Thanks a lot in advance!

version: Joplin 2.7.10 (prod Linux)

This is more of a KaTeX question. Not sure if it has forum/chat, but you could create an issue on the github GitHub - KaTeX/KaTeX: Fast math typesetting for the web.

Thanks for the tip!
I've found the solution on the Katex Github issues:

LaTeX expects the second argument to be text. If you write math there, you need the $…$ delimiters.


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