1

How do I add $E=mc^2$ math to be rendered with mathjax/katex inside a CSS class? I am trying to use this inside the following classes in markdown:

.theorem {
display: block;
font-style: italic;
}
.theorem:before {
content: "Theorem. ";
font-weight: bold;
font-style: normal;
}
.theorem[text]:before {
content: "Theorem (" attr(text) ") ";
}

e.g.

<div class="theorem" data-text="Foo"> bar is $\alpha = \beta$.
</div>

But it fails to render the example provided.

EDIT: turns out, for math in $...$ to be rendered inside the <div> class, a line has to be skipped. e.g.

<div class="theorem" data-text="Foo">

Given $a, b$:
$$a = b$$
</div>
shnnnms
  • 31
  • 3
  • Okay, cool. You've told us what you want to do and what you've tried. What's the problem? How is this failing to do what you want? Please read [ask]. – ChrisGPT was on strike Dec 07 '21 at 15:59
  • Turns out for the math to be rendered by mathjax/katex, inside a
    class, you have to skip a line before adding `$...$`.
    – shnnnms Dec 07 '21 at 16:04
  • I had a similar problem and found [this answer](https://stackoverflow.com/questions/17111421/how-to-display-math-equations-in-block-with-markdown) might be useful. – Jiahui Sep 12 '22 at 01:36

0 Answers0