I don't know if MathJax 3 is faster than version 2 or faster than KaTeX but it works for me when I am writing scientific papers using Multimarkdown.
This works in nvUltra Beta.
I have an example of using MathJax 3 with equation numbering. There are two files, one a javascript file that loads MathJax 3 if needed and sets up equation numbering. The other is a sample of several environments that are supported in MathJax 2 but not in KaTeX. I do a fair amount of writing in LaTeX as well as MultiMarkdown. Some of it requires equations and I do like numbering equations as needed. Note, it also works in Marked 2 but I do use the "dev" branch of Multimarkdown. I even have this working in Coderunner and a couple of other apps that work with Multimarkdown.
MathJax file: check-for-tex.js
(function () {
var body = document.body.textContent;
if (body.match(/(?:\$|\\\(|\\\[|\\begin\{.*?})/)) {
if (!window.MathJax) {
window.MathJax = {
tex: {
inlineMath: {'[+]': [['$', '$']]},
tags: 'ams'
}
};
}
var script = document.createElement('script');
script.src = 'https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js';
document.head.appendChild(script);
}
})();%
Test file in same directory:
HTML Header: <script type="application/javascript" src="./check-for-tex.js" defer></script>
Author: David Loeffler
Date: Feb 3, 2021
# Test of MathJax v3 #
Author: [%author]
Date: [%date]
Things I want to test
{{TOC:2-3}}
## Math
This file is originally from one I used to test equation numbering in nvUltra using MathJax. I have updated it to run inside of CodeRunner and it uses a javascript function that loads MathJax v3.1.2 only if it thinks the file is has math equations and does a minimal setting of processing options.
### Equation\* ###
This equation does not get a number because environment ends in '*'.
$$\begin{equation*}
E=mc^{2}
\end{equation*}$$
### Equation ###
$$\begin{equation}
\label{energy_mass_eq}
E=mc^{2}
\end{equation}$$
The equation $\eqref{energy_mass_eq}$ represents the relationship between mass and energy.
### Align ###
$$\begin{align}
\ddot{\underline{\mathbf{r}}} &= \frac{d{^2}\underline{\mathbf{r}}}{dt^2}\\
&= 0
\end{align}$$
### Align With NoNumber ###
`nonumber` blocks number of a line in `align`
$$\begin{align}
\ddot{\underline{\mathbf{r}}} &= \frac{d{^2}\underline{\mathbf{r}}}{dt^2}\nonumber\\
&= 0
\end{align}$$
### Eqnarray ###
$$\begin{eqnarray}
7x + 4y & = & 0 \\
2x - 5y & = & 0
\end{eqnarray}$$
### Eqnarray and NoNumber ###
$$\begin{eqnarray}
-\Delta u & = & f \\
u & = & 0 \nonumber
\end{eqnarray}$$
### Cases ###
`cases` gets one number
$$\begin{equation}
\begin{cases}
\frac{1}{ T(t)} \partial_{tt} T(t) = - \lambda^2, \\
\\
c^2 \frac{1}{R(r)} \partial_{rr} R(r) + \frac{1}{R(r)} \frac{1}{r}
\partial_{r} R(r) + \frac{1}{r^2} \partial_{\theta \theta} \frac{1}{\Theta
( \theta) } \Theta( \theta ) = - \lambda^2. \label{eq:sep_var2} \\
\end{cases}
\end{equation}$$
### Gather ###
$$\begin{gather}
\frac{dS(t)}{dt} = -\beta.(\frac{S(t)}{P}).I(t) + \alpha R(t) + \mu (P-S(t))\\
\frac{dI(t)}{dt} = \beta.(\frac{S(t)}{P}).I(t) - \gamma I(t) - \mu I(t)\\
\frac{dR(t)}{dt} = \gamma.I(t) - \alpha R(t) - \mu R(t)
\end{gather}$$
### Multiline ###
$$\begin{multline}
f(x) = 4x^{12} -7x^{11} - x^{10} - 3x^9 + 31x^8 + x^7 + 4x^6 + 50x^5 \\ +21x^4 + 9x^3 + x^2
+201x +4
\end{multline}$$
### AlignAt ###
$$\begin{alignat}{3}
& m \quad && módulo \quad && m > 0\\
& a \quad && multiplicador \quad && 0 \lt a \lt m\\
& c \quad && constante aditiva \quad && 0 \leq c \lt m\\
& x_0 \quad && valor inicial \quad && 0\leq x_0 \lt m
\end{alignat}$$
### Equation and Split ###
$$\begin{equation}
\begin{split}
Area & = \frac{length \times breadth }{2} \\
& = \frac{1}{2} length \times breadth
\end{split}
\end{equation}$$
Comments
0 comments