# 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

snssswc

Awesome work!!$\frac{-b\pm \sqrt{{b}^{2}+4ac}}{2a}$

Thanks!!!

sean

Mauricio Piacentini

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…

Thieme Hennis (@hennis)

\lim_{n\rightarrow \infty}\sum_{i=0}^n \frac{1}{p_i}

Thieme Hennis (@hennis)

Andres Riofrio

Not bad if I can write Einstein’s equation!

HO AN De

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

Christian Perfect

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

Alpha

Can you give me a link of demo to use it in Tinymce?

Houcem

Great work !

HO AN De

Are you able to get it work on any wysiwyg editor?

Navin

Navin

\iint _{ 2 }^{ 4 }{ x{ y }^{ 2 } } .dz

Testing

Jay

This is cool!

x^2

Jay

Again with dollar signs

demo

Dont Work

toak

cool man..

Bill

lonely_prince

demo

Drew

Let$a={n}_{1}{p}_{j}$ where ${p}_{j}\in \{2,3,5,7,\dots \},$ so $a\in {{P}_{n}}_{1}.$ Let $b={n}_{2}{p}_{k}$ where ${p}_{k}\in \{2,3,5,7,\dots \},$ 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}_{1}{p}_{j}={n}_{2}{p}_{k}$ .

Note that${p}_{k}{p}_{j}={p}_{k}{p}_{j}$ is clearly true, and multiplying both sides of the equation by some integer $m$ gives us $m{p}_{k}{p}_{j}=m{p}_{k}{p}_{j}$ .

So let${n}_{1}=m{p}_{k}$ and ${n}_{2}=m{p}_{j}$ , which implies ${n}_{1}{p}_{j}={n}_{2}{p}_{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.

Ada

Ada

Junny

amazing

Amazing !

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

dsfds

$a^2+b^4

schartz

tets

a$x+1$

$$\begin{array}{rl}x& =1\\ y& =2\\ z& =3\end{array}$$

akash

r

test

aaa

גכשדכשד$$5x+{3}^{2}=3$$

Rock

I wish music was as easy to work with as math…$$E\mathrm{\u266d}=D\mathrm{\u266f}$$

Rock

Yash

test

test

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

test wrote

y =$\sqrt{(}{x}^{2}+2{x}^{3})$

kom