Archive for the ‘Stuff I use here’ Category

LaTeX in WordPress

Saturday, January 20th, 2007

This:

\displaystyle\frac12 < \left\lfloor \mathrm{mod} \left( \left\lfloor \frac{y}{17}\right\rfloor 2^{-17\lfloor x\rfloor -\mathrm{mod}(\lfloor y\rfloor , 17)},2\right)\right\rfloor

is called Tupper’s self-referential formula. If you graph it over particular values of x and y, it makes a picture of itself, and that is quite neat. Follow the link for details.

And this is a property of the unit impulse:

\displaystyle\int_{-\infty}^t\delta(\tau)d\tau = u(t)

But that’s not really the point. The point is the mathematical notation; you can integrate \LaTeX mathematical notation in your WordPress blog very easily, using Steve Mayer’s LatexRender plugin.

And the point here is that you can install that plugin even more easily and correct a nasty bug in the offset beta functionality, using my LatexRender installation script (or the BSD version).

Go to the wp-content/plugins subdirectory of your WordPress installation, and then either:

wget http://fugato.net/wp-content/install-latexrender.bash
bash install-latexrender.bash

or, if your webserver is running BSD (or anything with the same kooky version of sed as my hosting provider’s BSD installation):

wget http://fugato.net/wp-content/install-latexrender.bsd.bash
bash install-latexrender.bsd.bash

and with any luck, the script will set everything up right. Then you’ll just need to activate the plugin LatexRender in your WordPress admin panel, and try it out by putting something like [tex]e^{i\pi}=-1[/tex] in a blog entry. That should render the classic e^{i\pi}=-1.

This is tested working fine in WordPress versions 2.0 through 2.5.1 (the current stable version, which this blog is running).

The script assumes that your blog is located at the root of your website. If it isn’t, then you must provide the base path as an argument to the script. E.g. if your blog is at http://o.com/all/ye/faithful/, then you must run the script like this:

bash install-latexrender.bash /all/ye/faithful

and it should work right.

Some formulas may be slightly misaligned with the text baseline. You can work around this by manually surrounding them with stuff like <span style="vertical-align: -0.5px;"> ... </span> on a case-by-case basis (assuming you edit your blog entries in straight HTML, not the rich text editor).