在浏览器中使用Latex,使用Mathjax库
MathJax是一套开源js库,它并不是将公式转化为一个图片,而是在浏览器端通过位置控制、字体、大小来显示一个公式。支持LaTeX数学公式。
对于hexo博客框架:首先更改next主题中的mathjax库的URL,MathJax2.4版有些许bug:显示尾随的竖线。
vi themes/next/layout/_scripts/third-party/mathjax.swig
if config.language === 'zh-Hans'
到配对的endif标签
替换为固定的js链接:
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
使用两个美元符号开始和结束,代表公式居中显示,使用一个美元符号,则不居中
右键某个生成的图案,可以查看Mathjax在网页上的源码,快速知道latex源码
$\times$ |
\times |
$\div$ |
$a^x$ |
$a^{xyz}$ |
a^{xyz} |
$\sqrt{x}$ |
\sqrt{x} |
$\sqrt[n]{x}$ |
\sqrt[n]{x} |
$\oplus$ |
\oplus |
$\vee$ |
$\wedge$ |
\wedge |
$\sum$ |
$\int$ |
$\oint$ |
\oint |
$\prod$ |
\prod |
$\not=$ |
\not= |
$\approx$ |
\approx |
$\equiv$ |
\equiv |
$\le$ |
$\ge$ |
$\ll$ |
$\gg$ |
$\frac{1+\frac{1}{x}}{3x + 2}$ |
\frac{1+\frac{1}{x}}{3x + 2} |
$\dfrac{1+\frac{1}{x}}{3x + 2}$ |
\dfrac{1+\frac{1}{x}}{3x + 2} |
$\cfrac{2}{1+\cfrac{2}{1+\cfrac{2}{1+\cfrac{2}{1}}}}$ |
\cfrac{2}{1+\cfrac{2}{1+\cfrac{2}{1+\cfrac{2}{1}}}} |
$\sqrt(2)$ |
\sqrt(2) |
$\sqrt{2}$ |
\sqrt{2} |
$\sqrt{x+y}$ |
\sqrt{x+y} |
$\sqrt{x+\frac{1}{2}}$ |
\sqrt{x+\frac{1}{2}} |
$\sqrt[3]{3}$ |
\sqrt[3]{3} |
$\sqrt[n]{x}$ |
\sqrt[n]{x} |
$\sum_{i=1}^{\infty}\frac{1}{i}$ |
\sum_{i=1}^{\infty}\frac{1}{i} |
$\prod_{n=1}^5\frac{n}{n-1}$ |
\prod_{n=1}^5\frac{n}{n-1} |
$\lim_{x\to\infty}\frac{1}{x}$ |
\lim_{x\to\infty}\frac{1}{x} |
$\frac{d}{dx}\left(x^2\right) = 2x$ |
\frac{d}{dx}\left(x^2\right) = 2x |
$\int 2x,dx = x^2+C$ |
\int 2x,dx = x^2+C |
$\frac{\partial^2U}{\partial x^2} + \frac{\partial^2U}{\partial y^2}$ |
\frac{\partial^2U}{\partial x^2} + \frac{\partial^2U}{\partial y^2} |
$\cos$ |
$\arccos$ |
\arccos |
$\cosh$ |
\cosh |