Wordpress Mimetex plug-in (modified)
Introduction
You can embed Latex math formulas to Wordpress posts using mimetex plug-in.
There were some problems with the original plug-in:
- If libcurl is not installed to PHP on your hosting plan, or disabled for security reasons and dl() module is not enabled because of safe mode you will not be able to use this plug-in.
- Rich text editor clears “<tex></tex>” tags.
- Does not support tex code in comments.
Download
If you suffer from these problems use this modified version: Modified Dahnielson Mimetex
Install
Unpack the zip archive to the Wordpress plugins directory and activate the plug-in.
As usual: “Important: You need a writable /wp-content/cache directory on the server!”
Details
- Use “[ tex ] [ /tex ]” tags (without spaces) to embed math formulas.
- Now plugin supports mimetex code written on comments. (Thanks to Robert Jones)
- You can also change the formula image appereance from your CSS file. It’s class is “tex”. Example:
.tex{ padding: 0; } - Instead of using libcurl, Snoopy is used. That is the reason for the second file. Probably this detail is not very important for most of the users.
Example
\large f^\prime(x)\=\lim_{\Delta x\to0}\frac{f(x+\Delta x)-f(x)}{\Delta x}will produce:

Alternatives
Martin Becker made the plug-in more compatible and the code more clear. You may wish to try that version if this does not work for you. You can find it here.
Changelog
- 1.1 Support on comments and CSS support for tex images.
- 1.0 Rich editor problem and curl issue fixed
October 10, 2006
Yazar: bitkidoku
Kategori: Uncategorized
Amacimiz, zihinlerimizin birer kopyasini dijital ortama aktarip, bu simulasyonu uzay bosluguna firlatmaktir. Baslangic olarak bu tip islerle altyapimizi gelistirmekteyiz.



October 10th, 2006 at 11:15 am
[...] Follow any comments here with the RSS feed for this post. Post a comment or leave a trackback: Trackback URL. On Failure Verhoeff’s Dihedral Group D5Check [...]
October 18th, 2006 at 5:12 pm
Immediately after clicking activivate, I get the warnings below:
Warning: main() [function.main]: open_basedir restriction in effect. File(C:\php5\pear/Snoopy.class.php) is not within the allowed path(s): (/) in d:\home\ABC.COM\wordpress\wp-content\plugins\dahnielson_mimetex.php on line 34
Warning: main(Snoopy.class.php) [function.main]: failed to open stream: Operation not permitted in d:\home\ABC.COM\wordpress\wp-content\plugins\dahnielson_mimetex.php on line 34
Warning: main() [function.include]: Failed opening ‘Snoopy.class.php’ for inclusion (include_path=’.;C:\php5\pear’) in d:\home\ABC.COM\wordpress\wp-content\plugins\dahnielson_mimetex.php on line 34
Warning: Cannot modify header information - headers already sent by (output started at d:\home\ABC.COM\wordpress\wp-content\plugins\dahnielson_mimetex.php:34) in d:\home\ABC.COM\wordpress\wp-includes\pluggable-functions.php on line 270
This always displays above any page now. The error occurs whether or not the snoopy file is there. I don’t see anything related to the Snoopy plug-in for activation, although it is in the plug-in folder. I only see “mimeTeX”. Any ideas?
Thanks,
Brett
October 19th, 2006 at 7:46 pm
@Brett: it seems that the script cannot include Snoopy.class.php try changing the line 34 in danhielson_mimetex.php from:
include "Snoopy.class.php";to:
include "./Snoopy.class.php";October 19th, 2006 at 8:06 pm
Thanks. Now it gives this error:
Warning: main(./Snoopy.class.php) [function.main]: failed to
open stream: No such file or directory in
d:\home\ABC.COM\blog\wp-content\plugins\dahnielson_mimetex.php
on line 34
Warning: main() [function.include]: Failed opening
‘./Snoopy.class.php’ for inclusion
(include_path=’.;C:\php5\pear’) in
d:\home\ABC.COM\blog\wp-content\plugins\dahnielson_mimetex.php
on line 34
Warning: Cannot modify header information - headers already sent
by (output started at
d:\home\ABC.COM\blog\wp-content\plugins\dahnielson_mimetex.php
:34) in
d:\home\ABC.COM\blog\wp-includes\pluggable-functions.php on
line 270
October 19th, 2006 at 11:38 pm
Did you install wordpress on your local machine or on an hosting plan?
I think it is the first case (local machine). Change the code back to the previous version (include “Snoopy.class.php”;) and copy Snoopy.class.php file to the folder C:\php5\pear\
October 20th, 2006 at 1:36 am
I have a hosting plan and installed WordPress. That was the only way I could use plugins (WordPress.com doesn’t allow them). I haven’t noticed any other issues with WordPress.
Thanks,
Brett
October 20th, 2006 at 11:15 am
I am not really sure what causes the problem. You have uploaded Snoopy.class.php to plugins folder, right?
October 20th, 2006 at 6:12 pm
Yes.
October 22nd, 2006 at 5:46 am
I replaced the include with this line
require_once(dirname(__FILE__) . ‘\\Snoopy.class.php’);
Everything is fine now.
November 3rd, 2006 at 4:56 am
Hello,
Apparently, [tex] tags inserted in comments does not work, is it possible to have the plugin recognize them?
Thank you,
November 3rd, 2006 at 5:17 pm
yes, it is possible. I can’t promise but I will try to look into it in future. I am very busy nowadays.
November 5th, 2006 at 10:15 pm
[...] mimeTeX 1.1 Use tags to embed LaTeX math in posts, see the mimeTeX manual for details. By Anders Dahnielson. I had to install the modified version located here http://www.anlak.com/?page_id=66. Then there was a modified to using includes that I’ve mentioned in the code snippets. [...]
November 22nd, 2006 at 12:08 am
This is a brilliant piece of collaborative work! In response to bitidoku’s request, I have just about cracked mimetex in comments, but I’ve hit one snag. Somewhere along the line, plus signs are being chopped out of comments before they get picked up by the plugin. If someone can suggest a way to stop doing this, we should be there. All I did was add this to the list of filters:
add_filter(’comment_text’, array($dahnielson_mimetex_object, ‘parse’));
then did a bit of fiddling to stop Snoopy getting double included/not included at all.
November 22nd, 2006 at 7:09 pm
testing comments :)

November 22nd, 2006 at 7:39 pm
Not bad.. However I always wondered why mimetex is not nicely antialiased.. the font looks like a 1950 textbook :-(
November 22nd, 2006 at 10:29 pm
Seems to be working OK here. I have had a problem with the wp-includes/class-snoopy.php file. I had to change line 38 to
if ( !class_exists(’Snoopy’) ) :
in order to prevent “can’t redeclare….” errors
This is a bug in the class-snoopy.php file, as it is clearly attempting to prevent redeclaration.
Hopefully we can convince the wordpress people to fix this in a future release. Meanwhile the fix above should enable us to use
in comments.
November 22nd, 2006 at 11:36 pm
Doh’.. I get this error when entering the wordpress dashboard at /wp-admin/index.php :
Fatal error: Cannot redeclare class snoopy in /home/content/s/t/r/www/html/wp-includes/class-snoopy.php on line 40
November 22nd, 2006 at 11:55 pm
Yep - I had that problem (tried to post a comment to that effect but it got swallowed somehow)
You can fix this by editing wp-includes/class-snoopy.php and replacing the line
if ( !in_array(’Snoopy’, get_declared_classes() ) ) :
with the line
if ( !class_exists(’Snoopy’) ) :
November 22nd, 2006 at 11:57 pm
Yep - I had that problem (tried to post a comment to that effect but it got swallowed somehow)
You can fix this by editing wp-includes/class-snoopy.php….
November 23rd, 2006 at 1:49 am
Yeah sorry about the Snoopy bug it is fixed now. (by the way there is a comment moderation that is why your comments wont show up instantly)
November 23rd, 2006 at 2:47 am
I tried to put
if (!class_exists(’Snoopy’)) include “Snoopy.class.php”;
But the dashboard still has same error. If I comment out the line, then no error in Dashboard, but error when displaying the blog posts containing tex tags.
November 25th, 2006 at 1:38 am
Rawk - what version of Wordpress are you using? There must be a good, robust solution to this problem. I’ll ponder over the weekend :)
November 25th, 2006 at 1:47 am
[...] Anyhoo - David Gilmour emailed me to say that he was exploring the possibility of incorporating a plugin into the exc-el wordpress installation that would allow users to put into their posts. This inspired me to hunt around, and I came across this site, which offered just such a plugin. After a bit of playing around, I decided that i would be better to use the adapted version created by Barış. [...]
November 26th, 2006 at 5:31 pm
OK - how about this. Change line 38 of the plugin to read:
if (!class_exists(’Snoopy’)) include get_settings(’siteurl’).”/wp-includes/class-snoopy.php”;
This works for me. It may not be backwards compatible with anything prior to 2.05 though. Worth a try.
December 22nd, 2006 at 9:47 pm
[...] I was having some kind of odysee around the web to find some working mimeTeX-Plugin to use with WordPress. I found Anders Dahnielson’s Version leading to a Version using Snoopy instead of Curl: Baris Evrim Demiroz’s Version. [...]
December 22nd, 2006 at 10:25 pm
Hi, I had a lot of trouble getting this Plugin to work. Now that it does work, I want to share with you people for I don’t wanna do stuff like that just for myself ;-). I cleanded up the code, made one or the other change and it works perfectly for me now. I fixed some problem I kept having with the Admin-Index and repeating use of TeX-Expression in Comments as well as some other crazy Problems. If you are interested, check this out and tell me what you think:
http://studium.fstyle.de/weblog/2006/12/22/mimetex_112/
December 28th, 2006 at 2:38 am
[...] Posted by RandomWalker on 27 Dec 2006 at 06:02 pm | Tagged as: 有關網誌 對於數理方面的科學工作者早已經是不可或缺的寫作工具,但如何與網頁技術結合卻一直沒有很完美的解決方案。尤其對於 WordPress 的使用者來說,LaTeX 指令前面的 “” 會被 WorePress「吃掉」,造成 LaTeX 編譯器無法辨認指令。不過熱心的人還是有的,網路上有好幾個整合 LaTeX 與 WordPress 的外掛可以用。如果伺服器有安裝 LaTeX 編譯器以及 ImageMagic 的話,可以考慮 latexrender 這個外掛。萬一伺服器沒有安裝 LaTeX 編譯器,作者的網頁中有提到可以安裝 mimetex 代替。像我一樣不想安裝 mimetex 的人可以試試 Anders Dahnielson 或者是 Martin Becker 的 Wordpress Mimetex 外掛。這個外掛利用外部的伺服器來編譯 LaTeX 指令,對於把網誌架在公共伺服器上的人而言這是個相當方面的外掛。我安裝的是 Martin Becker 的修正版,底下是利用這個外掛所編譯的結果: 使用的方式是利用一對 [ tex ][ /tex ] 標籤包住 LaTeX 的指令: lim_{taurightarrowinfty}e^{-tau{cal H}}|Psi_tranglerightarrow|Psi_0rangle [...]
January 3rd, 2007 at 7:47 am
I have just installed this plugin. There seems to be problem when I am trying to use

The “&” is showing as #038. Is there any way I can fix this?
January 28th, 2007 at 8:25 pm
[...] There is more work to be done on this. But it is sufficient for today. There are modifications of mimeTeX for WordPress- here and here. [...]
April 9th, 2007 at 4:19 pm
[...] anlak WordPress MimeTex plugin (tags: wordpress tex) [...]
April 21st, 2007 at 12:44 am
This plugin needs a wee patch, to reflect the new url of the public mimetex server:
http://www.forkosh.dreamhost.com/mimetex.cgi?
should replace the old one.
April 22nd, 2007 at 5:38 pm
[...] As luck would have it, I then fell across a LaTeX to image translation plugin for wordpress and decided to go with that for the time being. The original homepage I found: Mimetex Plugin. Unfortunately, this hosting doesn’t permit libcurl. But then I found this revision, which very nearly worked perfectly. From there, I got to this version of same. Which did everything right, except for one minor detail, which was that it pointed to a nonexistent public mimetex server. For those with the same problem, the new address is: http://www.forkosh.dreamhost.com/mimetex.cgi - edit line 82 of mimetex-plugin.php [...]
November 12th, 2007 at 2:45 am
[...] It was originally developed by Anlak. [...]
December 15th, 2007 at 1:57 am
[...] This will help me display equations like this one: uhhhhhh … nasty. For this to work, the first thing I did was googling for “wordpress mimetex” which lead me to this page. The script takes the mimetex sequence you are entering, connects to the server, requests the apropriate image, downloads it to the cache folder of the blog and inserts the link to the image. However, i never got it to work … maybe beacause I failed to realize how to chmod 777 my cache directory, preventing the script to write in the files it created … whatever. Creating a workaround seemed easy, just take the string the regex produces and tinker with the return function to directly link to the mimetex server, alas generating all images on the fly. However, when i first tried it, it just wouldn’t work. I always had a dubious character in my regex string, screwing up my images. Today I looked again and it was quite easy to solve. I even added a functionality to automatically reverse the image to make it white on transparent instead of black on transparent background. [...]
January 27th, 2008 at 11:56 pm
any help here would be appreciated: i’ve installed and activated the plugin (used both mimetex-plugin and dahnielson_mimetex phps) but for some reason it will not render on my site. it just drops the tags and prints the code, so that the published post would read \small y_t = x_t + \epsilon_t instead of the image. It has worked in prior posts but recently I switched themes, and now it doesn’t seem to. Any ideas?
February 2nd, 2008 at 6:16 am
Great post and thx for help…
February 19th, 2008 at 6:10 am
i have some problems with the plugins with them asking us to input HTTP-Referrer.
How can I resolve this?
June 30th, 2008 at 10:17 pm
thank for post
October 5th, 2008 at 3:11 am
[...] LaTeX Equation Editor for the InternetUsing LaTeX in WordPress » LatexRender as a pluginanlakMeadow/Emacs memo:File-local Variables in [...]
March 11th, 2009 at 4:01 pm
[...] follow up info — check this post or look [...]
July 22nd, 2009 at 8:40 am
July 22nd, 2009 at 8:43 am
Can’t wait to test this on my site’s wordpress component. Will need to create a patch for Elgg as well.
Nice work, many thanks!