KaTeX, MathJax and JSXGraph on the same page

This page has JSXGraph boards containing math processed by KaTeX or MathJax. I needed to surround some of the math with $...$ in some places for it to render as math.

The rest of the page has math processed by both KaTeX (blue background) and MathJax (magenta background). The calls to MathJax within JSXGraph are made using the usual useMathJax: true, whereas the KaTeX on the graph is handled outside of the JSXGraph flow, by wrapping it in a DIV with class="kat". That is, we're not using the standard JXG.Options.text.useKatex = true; call that you would use if you were only using KaTeX.

The KaTeX on the page (with class "kat") is processed first, then MathJax scans the page and processes what's left (which has class "mat" for demo purposes).

KaTeX board - random expressions

MathJax board - label and vectors

KaTeX board - slider label and expression

MathJax board - glider and derivative

MathJax board - function graph and slider

Processed with KaTeX

Some inline math: $ c = \pm \sqrt{a^2 + b^2} $

Display math:

$$ 3 + 4i = 5(\cos \theta + i \sin \theta) $$

{align} - automatic numbering:

\begin{align} a_1& =b_1+c_1\\ a_2& =b_2+c_2-d_2+e_2 \end{align}

{alignat} - automatic numbering:

\begin{alignat}{2} &A &&= b-c\\ &B &&= a+d \end{alignat}

Processed with MathJax

Some inline math: $ c = \pm \sqrt{a^2 + b^2} $

Display math:

$$ 3 + 4i = 5(\cos \theta + i \sin \theta) $$

{align} - automatic numbering:

\begin{align} a_1& =b_1+c_1\\ a_2& =b_2+c_2-d_2+e_2 \end{align}

{alignat} - automatic numbering:

\begin{alignat}{2} &A &&= b-c\\ &B &&= a+d \end{alignat}

Processed with KaTeX

$$ Y_k = 1 \text{ if } G = k \text{ else } 0. $$ $$ Y = \begin{bmatrix} 1 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 \\ & & \vdots & & \\ 0 & 0 & 0 & 0 & 1 \end{bmatrix} $$ \begin{equation} \hat{G}(x) = \arg\max_{k\in\mathcal{G}} \hat{f}_k(x). \end{equation}

Processed with MathJax

$$ Y_k = 1 \text{ if } G = k \text{ else } 0. $$ $$ Y = \begin{bmatrix} 1 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 \\ & & \vdots & & \\ 0 & 0 & 0 & 0 & 1 \end{bmatrix} $$ \begin{equation} \hat{G}(x) = \arg\max_{k\in\mathcal{G}} \hat{f}_k(x). \end{equation}