Jun 072012
 

MathJax 是一个开源, 基于 Ajax 技术的数学表达式显示解决方案. 它能够在HTMl页面中高质量的显示\(\rm\LaTeX\)和MathML数学符号, 支持大部分浏览器, 不需要安装插件,额外字体或特殊的阅读器, 并且支持复制, 粘贴.

MathJax and LaTeX math formula

MathJax

如何才能在你的网站使用 MathJax 呢? 有几种办法. 官方网站有详细的文档, 参考这个 Using the MathJax Content Delivery Network (CDN).

 一、 使用  MathJax 官方的  Content Delivery Network (CDN)

在 header.php 文件, 查找:

  1. </head>

把下面代码插到前面即可:

  1. <script type=“text/javascript”
  2.    src=“http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML”>
  3. </script>

如果对安全性要求更高, 使用下面的代码可以:

  1. <script type=“text/javascript”
  2.   src=“https://d3eoax9i5htok0.cloudfront.net/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML”>
  3. </script>

需要注意的是,  MathJax 默认, 对行内公式的设定是, 公式夹在两个美元符号 $  $之间是不起作用的. 如果你希望使用美元符号来输入行内公式, 请把下面代码

  1. <script type=“text/x-mathjax-config”>
  2. MathJax.Hub.Config({
  3.   tex2jax: {inlineMath: [[‘$’,’$’], [‘\\(‘,’\\)’]]}
  4. });
  5. </script>

插入到 footer.php 文件的

  1. </body>

之前.

此外,  MathJax 也支持一些 \(\rm\TeX\) 的稍高级的功能, 例如可以实现公式编号, 也已经支持许多环境. 要达到这一目的, 可以把

  1. <script type=“text/x-mathjax-config”>
  2.     MathJax.Hub.Config({
  3.         TeX: {
  4.             equationNumbers: {
  5.                 autoNumber: [“AMS”],
  6.                 useLabelIds: true
  7.             }
  8.         },
  9.         “HTML-CSS”: {
  10.             linebreaks: {
  11.                 automatic: true
  12.             },
  13.             scale: 100
  14.         },
  15.         SVG: {
  16.             linebreaks: {
  17.                 automatic: true
  18.             }
  19.         }
  20.     });
  21. </script>

插入到 footer.php 文件的

  1. </body>

之前.

同样要注意, 在环境中, 所有的 \(\rm\TeX\) 源码必须挤成一堆, MathJax才能正确显示公式.

二、 在服务器安装客户端文件

1.  下载客户端, 到 MathJax 下载即可.

2. 把下载的程序上传到服务器, 然后解压.

3. 类似于方法一, 把下面代码写进header.php 文件:

  1. <script type=“text/javascript”
  2.  src=“http://www.yourdomain.com/filename/MathJax.js?config=TeX-AMS-MML_HTMLorMML”>
  3.  </script>

这里的 yourdomain 是你的域名, filename是你的MathJax 所在的文件夹. 剩下的事情同办法一.

三、 安装插件

这个办法仅仅对 WordPress 有效. 可选的插件有几个, 我们建议 \(\rm\LaTeX\) for WordPress. 安装是简单的, 装上就可以使用.

四、 \(\rm\TeX\) commands supported by MathJax

 MathJax \(\rm\TeX\) and \(\rm\LaTeX\) Support .

More complete details about how to use these macros, with examples and explanations, is available at Carol Fisher’s \(\rm\TeX\) Commands available in MathJax page. also, don’t forget  this page!

 Leave a Reply

(required)

(required)

This site uses Akismet to reduce spam. Learn how your comment data is processed.