Is there any established best practice for putting LaTeX inside diagrams on the web?
It seems that MathJax can render to SVG outlines. It’s probably also possible to get HTML elements (rendered by KaTeX) positioned over/inside an SVG file, but I’m not sure how friendly it plays with resizing etc.
I had this same question and found this post while searching the forum for an answer.
David Cervone says that the only way to get typeset math into SVG with MathJaX is to use the SVG foreignObject element. This same technique seems to work with KaTeX. I used exactly this technique to place the labels on the axis for this dynamic cycloid.