12

MathJax 让你爱上数学公式

 3 years ago
source link: https://zhiqiang.org/it/mathjax-make-mathematics-beautiful.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

MathJax 让你爱上数学公式

作者: 张志强

, 发表于 2012-03-22

, 共 958 字 , 共阅读 1028 次

如果让我投票最优秀的开源项目,我会投给MathJax。MathJax 是一个 JavaScript 引擎,用来显示网络上的数学公式。阅微堂上所有数学公式都用 LaTex 写出,通过 MathJax 来显示。

一个好消息是, MathJax 已经更新到了 2.0 ,更新的内容见What's new in MathJax v2.0。比较有用的新增功能是支持公式编号和引用。在一个公式内使用 \label{id}给公式编号,然后再在合适的地方\ref{id}即可引用该公式。比如我可以引用公式(1):

r=rF+β(rM−rF)+ϵ

可惜的是, MathJax 的默认设置文件没有打开上面的两个特性,所以需要进 MathJax 进行额外的配置:

<script type="text/x-mathjax-config">
    MathJax.Hub.Config({
        TeX: {equationNumbers: {autoNumber: ["AMS"], useLabelIds: true}},
        "HTML-CSS": {linebreaks: {automatic: true}},
        SVG: {linebreaks: {automatic: true}}
    });
</script>

可以说,对于普通的数学公式,目前 MathJax 的功能和显示效果已经完全可以媲美于 Latex ,而 HTML/CSS 对位置和格式的控制能力要比 Latex 更强大。以后,看数学论文不需要再下载 pdf 文件,而是可以直接在网页上进行浏览。

不过我写这篇文章的目的是想说:我更新了插件 Latex for WordPress,最新版本为 3.3 ,请大家更新。新版本主要修复了无法显示 LaTex 源代码的 bug ,以及增加了 MathJax 后台配置选项(比如可配置上面公式编号所需的代码)。

Q. E. D.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK