LaTeX in WordPress
This:
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:
But that’s not really the point. The point is the mathematical notation; you can integrate
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
.
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).
January 20th, 2007 at 4:51 pm
This is awesome, totally f**king great, I and hardly ever use that word unless something really warrants it. I’ve just gotta try this out and I can’t wait to get my admin to run your script, so I’m trying it here: [tex] F : \mathbb{R}^n \longrightarrow \mathbb{R} ; \boldsymbol{x} \mapsto F( \boldsymbol{x} [/tex].
January 20th, 2007 at 4:52 pm
Hehe, doesn’t work in comments unless you enable it manually in the plugin code. My script doesn’t do that. But it’s straightforward to do manually; the plugin readme explains how.
January 20th, 2007 at 5:36 pm
I read the joke, serving as the introduction to the LaTeX Renderer good new… and its starting to bug me. Tucker self-referential formula? It says it makes a picture of itself, do you mean the formula? Does it make a picture of the formula text? And further, “if you plot it over particular value of [tex] x,y [/tex]“, which particular values are they?
Sorry for being so pedantic, but I’d really like to try it, and I’ve got a lot of time on my hands… hehe
January 20th, 2007 at 5:53 pm
If you have a lot of time on your hands, surely you had time to notice ;) that I provided a link to further info about Tupper’s self-referential formula. It’s no joke, it’s real and quite neat.
January 28th, 2007 at 8:03 am
Does the plugin work with wordpress 2.1?
January 28th, 2007 at 12:41 pm
Yep; this blog is running Wordpress 2.1.
February 5th, 2007 at 11:18 am
I got the following error on my Debian installation:
install-latexrender.bash: line 31: conditional binary operator expected
install-latexrender.bash: line 31: syntax error near `=~’
install-latexrender.bash: line 31: `if [[ `pwd` =~ ".+"${PLUGINS_REL_PATH}'$' ]]’
bash-version: GNU bash, version 2.05b.0(1)-release (i386-pc-linux-gnu)
I uncommented that particular section and then it seemed to work (since I was in the right directory).
February 5th, 2007 at 11:56 am
Right, I guess you need a bash that supports the regexp match operator.
Could you possibly patch it so that it makes the same check in a way that works in your bash? I would incorporate that change. I’d rather not remove the check altogether; I want to keep this script on the cautious side.
February 5th, 2007 at 1:01 pm
replacing line with
if [[ "${PWD: -18}" == "${PLUGINS_REL_PATH}" ]];
works for me. Don’t know how portable it is or what the risk that this construction doesn’t work with yet other setups.
February 6th, 2007 at 8:01 am
Hm, are you sure about that? From the Bash reference manual:
That doesn’t sound like it does what we want here.
February 6th, 2007 at 8:04 am
Oh sorry, you’re doing substring expansion, since the second operand is numeric:
That sounds about right. I’ll try it out and make the change.
February 6th, 2007 at 8:29 am
Matthijs’ suggestion was applied and made robust to changes in PLUGINS_REL_PATH; the line is now:
so now there are no known (to me) issues with this script.
February 10th, 2007 at 8:49 pm
I am getting the following error message! Any clue?
Warning: copy(a25f9ada91d715ec1a4c89d961a729ff.gif): failed to open stream: No such file or directory in /home/sumansan/public_html/dynamicequations-org/wp-content/plugins/latexrender/class.latexrender.php on line 314
Warning: unlink(/home/sumansan/www/dynamicequations-org/wp-content/plugins/latexrender/tmp/a25f9ada91d715ec1a4c89d961a729ff.gif): No such file or directory in /home/sumansan/public_html/dynamicequations-org/wp-content/plugins/latexrender/class.latexrender.php on line 338
February 11th, 2007 at 12:51 am
Nope, no clue, sorry. :) I just made the installation script; you could try asking the author.
February 13th, 2007 at 7:52 pm
I am the author. Suman: it looks like the gif is not being created. If you aren’t getting any other error messages it could be because ImageMagick can’t find Ghostscript. Have a look at http://sixthform.info/steve/wordpress/index.php?p=34 for how to put this right.
February 27th, 2007 at 5:37 am
Hello, Sir
I try to implement wp-latexrender to bbpress by rewrite some parameters. But latexrender alwaly recognize
“\ ” as ”\\” for an example if I type [tex]\Sigma[/tex] then the rendered tex file will show
…..
$\\Sigma$
Can you take a glance about that ?
February 27th, 2007 at 8:37 am
I just made the installation script. You could try asking the latexrender author, Steve Mayer, but my (blind) guess is that the backslashes are doubled by bbPress itself, not by latexrender. You probably need to find a way to tell bbPress not to do that — or add something to latexrender to unescape the text. It is probably not too hard, if you are willing to get into it.
February 27th, 2007 at 10:58 am
I agree that doubling slashes must be done by bbPress, presumably for use in its database. If you can’t stop bbPress doing it then in latex.php try:
after the line
$latex_formula = $tex_matches[1][$i];
add
$latex_formula = stripslashes($latex_formula);
and see what happens.
Alternatively (but not both at the same time ) in the same place you could try
$latex_formula = str_replace(“\\”,”\”,$latex_formula);
February 27th, 2007 at 10:31 pm
Steve, Thank you very much, It works !!
March 20th, 2007 at 8:28 am
Hi,
thanks for the script. One question I have is that when I finally render latex, I don’t get an inline image like yours, rather I get a “raised” image with a drop shadow, which is ok, but doesn’t look right for inline things. Do you know what might be causing that ?
March 20th, 2007 at 8:39 am
No, I don’t know what might cause a drop-shadow … does it look like that in all browsers? Can you post a link to it? My first thought is browser weirdness.
March 21st, 2007 at 3:14 pm
Suresh: the drop-shadow is probably caused by something in your theme’s CSS. Maybe you could post a link…
April 9th, 2007 at 10:49 pm
The script currently fails to fetch the plugin. The path to the wp-latexrender zip file seems to have changed from
http://sixthform.info/steve/wordpress/uploads/wp-latexrender.zip
to
http://sixthform.info/steve/wordpress/wp-content/uploads/wp-latexrender.zip
April 10th, 2007 at 10:22 am
Thanks — updated.
April 18th, 2007 at 10:41 pm
I… I think I love you. This is incredibly handy; thanks!
May 21st, 2007 at 2:54 am
I just started hosting a series of blogs for my projects through Dreamhost.com, which makes it a snap to install WordPress. I searched for how to put LaTeX in entires and ended up here. I used your script and it worked on the first try (well, second, but the first time I pointed it to the wrong directory). Fantastic work.
Also it was great to find out about the self-plotting function. Fascinating.
May 21st, 2007 at 11:58 am
Does that mean that Dreamhost.com has LaTeX installed or is that only on dedicated servers? I’m sure that many users would be interested in a host that offers LaTeX.