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

  可以通过上面的从MathJax分布式服务器上获取最新的MathJax.js文件。而且加上TeX-AMS-MML_HTMLorMML使得我们可以支持Tex和MathML公式,如果浏览器支持MathML解析,那么就使用它,否则会使用HTML-with-CSS来显示数学公式。而且config=TeX-AMS-MML_HTMLorMML是最常用的,更多的config可以去参加官方文档(http://docs.mathjax.org/en/latest/start.html)。
  下面使用TeX和LaTeX进行说明
   TeX 和 LaTeX 格式的公式使用主要有两种形式,(1)、包含在段落之中的;(2)、独立于其他文字的。TeX 和 LaTeX 格式的默认分隔符是$$...$$ \[ ...\],这个是独立于其他文字的,其实如果想要在段落之中显示TeX 和 LaTeX 格式的公式使,需要使用\(...\)。比如显示行内公式\(\alpha+\beta=\gamma\)可以使用:

\(\alpha+\beta=\gamma\)

\[
\newcommand{\R}{\mathbb{R}}
\newcommand{\E}{\mathbb{E}}
\newcommand{\x}{\mathbf{x}}
\newcommand{\y}{\mathbf{y}}
\newcommand{\wv}{\mathbf{w}}
\newcommand{\av}{\mathbf{\alpha}}
\newcommand{\bv}{\mathbf{b}}
\newcommand{\N}{\mathbb{N}}
\newcommand{\id}{\mathbf{I}}
\newcommand{\ind}{\mathbf{1}}
\newcommand{\0}{\mathbf{0}}
\newcommand{\unit}{\mathbf{e}}
\newcommand{\one}{\mathbf{1}}
\newcommand{\zero}{\mathbf{0}}
\]

独立于其他文字的
$$\alpha+\beta=\gamma$$
或者
\[\alpha+\beta=\gamma\]
可以使用

$$\alpha+\beta=\gamma$$
或者
\[\alpha+\beta=\gamma\]

更复杂的公式显示:

loss function $L(\wv; \x, y)$gradient or sub-gradient
hinge loss
$\max \{0, 1-y \wv^T \x \}, \quad y \in \{-1, +1\}$
$\begin{cases}-y \cdot \x & \text{if $y \wv^T \x <1$}, \\ 0 &
\text{otherwise}.\end{cases}$
logistic loss
$\log(1+\exp( -y \wv^T \x)), \quad y \in \{-1, +1\}$
$-y \left(1-\frac1{1+\exp(-y \wv^T \x)} \right) \cdot \x$
squared loss
$\frac{1}{2} (\wv^T \x - y)^2, \quad y \in \R$
$(\wv^T \x - y) \cdot \x$

When $a \ne 0$, there are two solutions to \(ax^2 + bx + c = 0\) and they are
$$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$


$$\left[-\frac{\mathrm{SW}\;\mathrm{periods}}{\epsilon_1}\right] $$
$$ {{\Lambda}} = \frac{2\,\sin \,\phi }{{\sqrt 3 \,\left( {3 - \sin \,\phi } \right)}} $$
$$\mathrm{\mathcal{B}}\left({\Lambda}_{\mathrm{b}}^0\to \Lambda \beta^{\prime}\right) $$
$$\LARGE XX大学,数学与应用数学 \hfill 2009年至今 $$


更多关于数学公式的使用可以参照http://docs.mathjax.org/en/latest/start.html文档。

本博客文章除特别声明,全部都是原创!
原创文章版权归过往记忆大数据(过往记忆)所有,未经许可不得转载。
本文链接: 【MathJax:在浏览器上显示LaTeX等数学公式的JS引擎】(https://www.iteblog.com/archives/1319.html)
喜欢 (42)
分享 (0)
发表我的评论
取消评论

表情
本博客评论系统带有自动识别垃圾评论功能,请写一些有意义的评论,谢谢!
(3)个小伙伴在吐槽
  1. Latex 有不少宏包,在MathJax上面怎么使用这些宏包?

    Alex2016-08-17 13:46 回复
  2. 博主,我公司最近在使用LaTex显示公式,我发现公司给我的文本中有些公式不识别,是我配置错了还是说这个公式的文本有问题啊?
    下面的 \hfill 、 \upepsilon 、 \uplambda 、 \upeta 这些在显示的时候都报红,
    最后面那个直接显示公式文本
    $$ \large XX大学,数学与应用数学 \hfill 2009年至今\\ $$
    $$ \left[-\frac{\mathrm{SW}\;\mathrm{periods}}{\upepsilon_1}\right] $$
    $$ {{\uplambda}} = \frac{2\,\sin \,\phi }{{\sqrt 3 \,\left( {3 - \sin \,\phi } \right)}} $$
    $$ \mathrm{\mathcal{B}}\left({\Lambda}_{\mathrm{b}}^0\to \Lambda \upeta^{\prime}\right) $$
    $$ \large XX大学,数学与应用数学 \hfill 2009年至今 $$

    Alex2016-08-17 09:34 回复
  3. 你看看我文章上面显示的是不是你需要的?变成红色说明是你写的有问题,你可以参考:http://docs.mathjax.org/en/latest/tex.html,里面显示了很多用法。

    w3970907702016-08-28 16:55 回复