Skip to content

How to make a background box around a fraction (“bbox”) with Katex? #2531

Answered by ronkok
q2apro asked this question in Q&A
Discussion options

You must be logged in to vote

In LaTeX, \colorbox puts its contents into text mode. And KaTeX is a bit pickier about text mode than MathJax is.

You can still put math inside the box, but you have to explicitly shift it from text mode back into math mode with $…$ delimiters. So, to get your example working, try \colorbox{#e1ffc1}{$ \frac{1}{2} $}

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by q2apro
Comment options

You must be logged in to vote
1 reply
@edemaine
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants