MimeTex for WordPress & bbPress

Document (in English) are hosted at WordPress.org

Download

以下的中文文档只作参考,一切以英文文档为准

功能:

在文章内输入latex公式,将自动生成公式图片。图片的alt属性使得即使插件运行不正常(比如CGI服务器中断服务),也不会影响文章的可读性。

latex公式指左右各两个美元$符号所包含的部分。

下面是两个例子:

  1. 行内公式: \alpha+\beta\geq\gamma,源代码$$\alpha+\beta\geq\gamma$$,类似于Latex中的
  2. 行间公式(独立一行,居中显示):

    \left\{\begin{array}{ccc}x_1+x_2&\leq&2\\x_1-x_2&\leq&3\\end{array}

    源代码:$$!\left\{\begin{array}{ccc}x_1+x_2&\leq&2\\x_1-x_2&\leq&3\end{array}$$在源代码前面添加!号即表示此公式为一个行间公式,独立一行显示,等价于Latex中的

  3. 如何显示源代码:要想显示latex源代码,不替换成图片怎么办?在公式的最后添加一个!号,比如要想直接显示$$1+1\neq2$$,使用源代码$$1+1\neq2!$$。
  4. 要想显示2个$号怎么办?不好意思,现在还没有解决办法,请尽量避免这样做。你说你没事写2个$干吗呢。或者用$$这样的HTML字符写法。

插件是如何实现的?

  • 利用正则表达式查找文章中的数学公式
  • 查找此公式对应的公式图片是否存在,如果不存在,向MimeTex服务器请求图片,并缓存它。
  • 将数学公式替换成相应图片。

安装:

MimeTex for WordPress

  • 下载插件后上传到WordPress的插件目录。
  • 到管理员后台激活插件。
  • 在wp-content下新建cache文件夹,并赋予777权限。

MimeTex for bbPress

  • 察看你的bbPress根目录下是否有my-plugins目录,没有的话,新建它。
  • 下载MimeTex for bbPress,并上传到my-plugins目录下。
  • 察看你的bbPress根目录下是否有my-plugins目录,没有的话,新建它。赋予777的读写权限。

注意事项:

建立你自己的MimeTex服务

由于公用的MimeTex服务关掉了,现在插件里填写的是我能找到的公用服务器,随时有可能失效。请尽量使用自己的服务。

建立方法:到MimeTex首页下载源代码,按照它所给方法编辑,将编译后的mimetex.cgi文件放到你想要的文件夹,比如根目录的cgi-bin下,然后你便可以通过http://yourdomain/cgi-bin/mimetex.cgi?访问你的mimetex服务了。修改你的mimetex-plugin.php的$mimetex_server变量:

<?php
// change it to your server
$mimetex_server = "http://zhiqiang.org/cgi-bin/mimetex.cgi"
?>

你甚至不需要编译它,它的首页上直接提供编译好的版本下载:WindowsLinux (i386)FreeBSD (i386)NetBSD (i386)Sparc/Solaris8Alpha/VMSVAX/VMS

修改公式的tag:

这个插件默认的公式是两边各两个美元符号(与平时写latex文档一致),如果你喜欢的话,你也可以改成别的,到mimetex-plugin.php,修改$regex变量的值

<?php
// change it to
// $regex = '#

tex

(.*?)

/tex

#si';
// if you want [tex]your formula[/tex] stype in your post
$regex = '#\$\$(.*?)\$\$#si';
?>

图片式样

所有生成图片都拥有class="tex",你可以到你的css文件设置它的式样。

Change Log

version 2.0

  • 修改公式形式,与latex文档兼容。
  • 修改MimeTex服务器地址
  • 增加一层decode函数,处理"&"等特殊字符
关于 »
68条留言 -> 跳到留言表格
    18 old comments are not displayed. Click to display all comments
  • At 2008.05.01 21:54, zhiqiang said:

    我不太明白你说的几何图形是啥意思。你可以在这里试试看,留言也支持latex的。

    • At 2008.05.31 21:03, AI said:

      貌似回复错地方了,抱歉抱歉

    • At 2008.05.26 19:52, Feng said:

      试试。
      \alpha \Rightarrow \beta

      • At 2008.06.26 08:42, gman said:

        \alpha

      • At 2008.07.06 00:26, Stand Alone Complex » 安装latex插件 said:

        [...] 在网上搜索了一下,找到了由zhiqiang制作的latex for wordpress插件(这里是帮助文档),以后可以在blog里输入公式了,比如输入alpha+betageqgamma就可以生成公式: [...]

        • At 2008.07.06 00:33, 魔群月光 said:

          非常感谢你的插件和帮助文档,今天安装上了,很好用~

          • [...] 最近在家研究了一下——巨牛的文字排版系统,安装了从阅微堂下载的MimeTex for WordPress插件,修改了一下之后非常好用,其最大威力在于显示漂亮的数学公式。下面敲几个公式看看效果: [...]

            • At 2008.08.03 23:21, Stand Alone Complex - 安装latex插件 said:

              [...] 在网上搜索了一下,找到了由zhiqiang制作的latex for wordpress插件(这里是帮助文档),以后可以在blog里输入公式了,比如输入alpha+betageqgamma就可以生成公式: [...]

              • At 2008.10.15 03:29, Mads said:

                Hello, thanks for a great plugin... But I was wondering how I can get it to use display style math (eg where the lower and upper bounds of a summation are printed on top of Sigma instead of beside)?

                .. mads

                • At 2008.10.15 08:53, zhiqiang said:

                  Are you saying the equations like \sum\limits_{i=1}^ni=n(n+1)/2?

                  Try to insert code

                  $$\sum\limits_{i=1}^n=n(n+1)/2$$
                  

                  in your posts

                • At 2008.10.30 23:01, qq said:

                  try: x_n

                  • At 2008.10.31 17:54, Markus said:
                    • At 2008.11.13 01:54, 魔群月光 said:

                      请问编译的时候是不是要上传到虚拟主机上进行?

                      • At 2009.07.18 21:26, seatop· said:

                        我是传到服务器上编译才成功的

                      • At 2008.11.13 09:22, zhang said:

                        我没有编译过,以前用mimetex的时候都是直接下载可执行文件。现在用72pines提供的latex服务了,这个效果感觉比mimetex要好。

                        • [...] some work to some time ago nicely taken care of by zhiqiang. Here is a link to the article: http://zhiqiang.org/blog/plugin/mimetex and here is the Wordpress link: [...]

                          • At 2008.11.27 07:01, Martin Becker said:

                            Hi,
                            thanks for maintaining the Latex-Plugin ...

                            I was having some trouble getting the plugin to work with Wordpress 2.6.5. The first problem was that I forgot to create a "cache" folder, the second was that its permissions weren't set right. The third was that the .png files where not set with the permissions to read them from the browser.

                            So what I did was adding some error messages to the code to make debugging for stupid ones like me easier and managed the permission setting to read. If you want to check it out, you can get it here:
                            http://fstyle.de/hp_fstyle/wordpress/2008/11/27/latex-for-wordpress/
                            Let me know if it helped.

                            Regards,
                            Martin Becker

                          • At 2009.02.13 06:35, np said:

                            bbPress

                            请问我在哪里可以找到

                            MimeTex for bbPress

                            • At 2009.02.15 16:07, np said:

                              测试$$$\frac{a}{b}$

                              • At 2009.02.15 16:08, np said:

                                \frac{a}{b}

                                • At 2009.02.15 16:13, np said:

                                  恩这里的还是好的,论坛里的已经失效,而且凡是包含公式的帖子打开都需要30秒以上
                                  请问在哪里找到“MimeTex for bbPress”插件?
                                  我尝试从“for wordpress”修改,但自己水平太差没能成功

                            • At 2009.02.16 06:52, np said:

                              恩,通过修改一个官方bbcode插件实现了

                              • At 2009.06.05 14:54, giantlab said:

                                博主你好,我在linux上安装了mimetex,按官方的教程进行安装,在终端下执行./mimetex "x^2 y^2" 也能象官网上那样正确显示,可是在浏览器里输入http://localhost/cgi-bin/mimetex.cgi?x^2 y^2后,就会弹出一个要我下载文件的对话框,当然下载下来的文件是.cgi,很不解,我认为mimetex. cgi应该编译成功了,而且权限也改了,但为什么还出现这种情况,在浏览器里面怎么也显示不出图片来? 搞了我两天了,实在是头大了 :-(

                                • At 2009.07.27 22:47, Malloc said:

                                  我也遇到同样问题了。如果你解决了这个问题,请告诉我。

                                • At 2009.07.12 11:10, watchmath said:

                                  Hi, instead of using ! to produce a display style can you modify the regex so that display style is render when using the standard

                                  ?

                                  • At 2009.07.13 12:31, zhiqiang said:

                                    Sorry, but what's you meaning of standard?

                                    • At 2009.08.11 20:55, watchmath said:

                                      By standard mean using

                                      as in the latex original syntax.
                                      I modified your plugin so that it uses the usual latex $\latex$ for the inline symbols and

                                      \latex

                                      for the displayed one. If anyone interested, you can check the modified plugin features here:http://watchmath.com/vlog/?p=586
                                      and here for the installation: http://watchmath.com/vlog/?p=750

                                  • At 2009.07.17 17:33, seatop· said:

                                    您好,安装成功了,不过我的系统式bo-blog,有没有mimetex for bo-blog或需要对MimeTex for WordPress 作怎样的修改啊,好像插件格式不同啊,请帮帮忙!谢谢

                                    • At 2009.07.18 09:29, zhiqiang said:

                                      没用过bo-blog,也就没打算移植到bo-blog上。不过我想大致思路一样,你可以依样画葫芦自己写一个。

                                      • At 2009.07.18 21:20, seatop· said:

                                        谢谢,我写了个定义UBB代码插件,也方便使用了,只是没生成图片!

                                    • At 2009.07.24 12:14, zhu said:

                                      为什么我总是找不到你说的mimetex-plugin.php以及mimetex.php?

                                      • At 2009.07.24 14:13, zhu said:

                                        问题已经解决了,就是latex.php :-)

                                        • At 2009.07.26 22:53, Malloc said:

                                          测试一下\large\zeta (s)=\sum_{n=1}^\infty

                                          • At 2009.07.26 23:01, Malloc said:

                                            再试试
                                            \large\zeta (s)=\sum\limits_{n=1}^\infty \frac{1}{n^s}

                                            • At 2009.07.27 09:53, Malloc said:

                                              自建的cgi产生的图片无法显示,是什么原因捏?

                                              • At 2009.09.13 10:15, chin said:

                                                \left\{\begin{array}{ccc}x_1+x_2&\leq&2\\x_1-x_2&\leq&3\end{array}

                                                • At 2009.09.13 10:32, c said:

                                                   \mathcal{H}_{\alpha, \beta}^{\frac{1}{2}}

                                                  • At 2009.09.27 13:42, chin said:

                                                    x+y=z

                                                    • [...] we have a wordpress plugin Latex for WordPess ( MimeTex for wordpress & bbPress,from here ). After the installation, it will automatically convert latex codes into gif images and cache them [...]

                                                      • [...] 不过上面的是不是有点麻烦呢?每次都要改链接。所幸已经有了wordpress插件,Latex for WordPess(MimeTex for wordpress & bbPress,来自阅微堂)。安装好后,他会自动请求服务器。哈哈,适用于我这种懒人。 [...]

                                                        • At 2009.10.28 17:38, dutor said:

                                                          如果多次反复编辑同一个公式的话,\LARGE \tilde{cache}里面就会有大量的无用图片,只好全部删除,再次打开页面时重新缓存。

                                                          • At 2009.11.23 03:23, Math on Web II « Ramblings and Musings said:

                                                            [...] Few plugins for WordPress, I checked this one mimtex [...]

                                                            • At 2010.01.21 23:11, robert said:

                                                              let me try if it works well: $$! \alpha + \beta = \mu

                                                              • At 2010.01.21 23:12, robert said:

                                                                et me try if it works well:

                                                                 \alpha + \beta = \mu

                                                                • At 2010.02.28 11:28, Hieu said:

                                                                  $$$$!{x^{\log }}{_2^3} + \,{x^{\log }}{_2^5}\, = \,{\log _2}{x^6}\, + \,2

                                                                  • At 2010.02.28 11:28, Hieu said:

                                                                    [tex]\alpha + \beta = \mu[/tex]

                                                                    • At 2010.03.07 01:37, Test $$e^pi$$ « Logic Engine said:

                                                                      [...] 这里介绍了如何在自己主机上用mimetex实现公式显示: http://zhiqiang.org/blog/plugin/mimetex [...]

                                                                      • [...] 这里介绍了如何在自己主机上用mimetex实现公式显示: http://zhiqiang.org/blog/plugin/mimetex [...]

                                                                        • [...] 这里介绍了如何在自己主机上用mimetex实现公式显示: http://zhiqiang.org/blog/plugin/mimetex [...]

                                                                          18 old comments are not displayed. Click to display all comments

                                                                          (Required)
                                                                          (Required, not published)

                                                                            B | I | U | D | 添加链接 | 插入引用 | 插入代码 | 插入表情 | | + | ?
                                                                          guest | 注册 | 管理 | English | 繁體 | https

                                                                          阅微堂

                                                                          zhiqiang's personal blog
                                                                          Loading...
                                                                          Loading...
                                                                          Loading...