Skip to main content

Instant MathJax preview of LaTeX typed into HTML textareas

I’ve completely rewritten my write maths, see maths library to be a little jQuery plugin that attaches itself to editable areas on pages, like contenteditable elements, textareas, and input boxes. When your cursor is inside some LaTeX, a little preview box appears just above it with the LaTeX rendered through MathJax. I’ve made a demo page on GitHub, and the code itself is available there too. It also works in TinyMCE, if you’re into that sort of thing.

The first I thing I did with it was to write a WordPress plugin which applies the plugin to the comment boxes underneath posts (source code). I’ve installed it on this site and The Aperiodical, so you can use LaTeX with confidence, knowing that it’ll appear how you want on the page. Please try it in the comments box below!

Comments

Comments

That is great! Let me test:
$\sqrt{3x-1}+(1+x)^2$
It would be cool to integrate with Aloha Editor in some way. The problem is how to define the workflow, but looks very cool…

Hi, great works.
May I have the link to the code where you integrate writemaths with wysiwyg editor? I cannot get it to work. Thanks for your help

Do you mean in WordPress? I haven’t got it to work in WordPress’s wysiwyg editor.

$\sum_{m=1}^\infty\sum_{n=1}^\infty\frac{m^2\,n}
{3^m\left(m\,3^n+n\,3^m\right)}$

Great work !

\[ 1 + \frac{q^2}{(1-q)}+\frac{q^6}{(1-q)(1-q^2)}+\cdots =
\prod_{j=0}^{\infty}\frac{1}{(1-q^{5j+2})(1-q^{5j+3})},
\quad\quad \text{for $|q|<1$}. \]

cool man..

Let $a = n_1p_j$ where $p_j \in \{2, 3, 5, 7, \ldots\},$ so $a \in {P_n}_1.$ Let $b = n_2p_k$ where $p_k \in \{2, 3, 5, 7, \ldots\},$ so $b \in {P_n}_2.$

Now assume that ${P_n}_1 \cap {P_n}_2$ is nonempty. Then there exists some $n_1$ and $n_2$ such that for some $p_j$ and $p_k$ such that $a = b$. Thus we have $n_1p_j = n_2p_k$.

Note that $p_kp_j = p_kp_j$ is clearly true, and multiplying both sides of the equation by some integer $m$ gives us $mp_kp_j = mp_kp_j$.

So let $n_1 = mp_k$ and $n_2 = mp_j$, which implies $n_1p_j = n_2p_k$, and thus $a = b$ as desired. This means that ${P_n}_1 \cap {P_n}_2$ is guaranteed to be nonempty if we can divide any common factors from $n_1$ and $n_2$ and be left with only prime numbers.

(A) is out as $1$ is not prime. (B) is is out because if we divide $7$ and $21$ by their common factor $7$, we are left with $1$ and $7$, and $1$ is not prime. (D) is out because $24/4 = 6$ which is not prime. (E) is out because $5/5 =1$ is not prime. (C) is correct as $12/4 = 3$ and $20/4 = 5$, which are both prime.

\(J_\alpha(x) = \sum\limits_{m=0}^\infty \frac{(-1)^m}{m! \, \Gamma(m + \alpha + 1)}{\left({\frac{x}{2}}\right)}^{2 m + \alpha}\)

Amazing !

$$ \frac{\partial f}{\partial t} = \frac{\partial ^{2} f}{\partial x^{2}} $$

I will try to install it on my own wordpress. Thanks a lot !

$\left [ – \frac{\hbar^2}{2 m} \frac{\partial^2}{\partial x^2} + V \right ] \Psi
= i \hbar \frac{\partial}{\partial t} \Psi
$\

$\frac{1}{\Bigl(\sqrt{\phi \sqrt{5}}-\phi\Bigr) e^{\frac25 \pi}} = 1+\frac{e^{-2\pi}} {1+\frac{e^{-4\pi}} {1+\frac{e^{-6\pi}} {1+\frac{e^{-8\pi}} {1+\cdots} } } }$

\texttt{dst} (I) = \fork{\texttt{src}(I)^power}{if \texttt{power} is integer}{|\texttt{src}(I)|^power}{otherwise}