MathJax 指引

参考:MathJax GuideTEX CommandsMathJax.org


1. 基本格式

1.1 引例

MathJax是一个JavaScript引擎,用于在网页上显示和渲染各种学术符号,MathJax可以解析html源代码中的Latex、MathML、ASCIIMathML等标记语言。如:

\(- \frac{\hbar^2}{2m}\nabla^2 \Psi(\mathbf{r},t)+V(\mathbf{r})\Psi(\mathbf{r},t)=i\hbar\frac{\partial}{\partial t}\Psi(\mathbf{r},t)\)

\[e = \sum_{n=0}^\infty \frac{1}{n!}\]

\[\boxed{ \lim _{T \rightarrow 0} f _i = \begin{cases} 1, & \varepsilon _i\lt\mu, \cr 0, & \varepsilon _i \gt \mu. \end{cases} } \]
[TOP]

1.2 标记

公式可以与文字混排在一行,也可以独立成行。

混排的公式记作:\( \backslash ( 公式 \backslash) \);

独立成行的公式记作:\( \backslash [ 公式 \backslash ] \)。

使用\label{id}给公式编号,通过\ ref{id}实现对公式的引用,应用公式引用需要对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>


[TOP]


2. 字母

2.1 拉丁字母

\(A\) \(B\) \(C\) \(D\) \(E\) \(F\) \(G\) \(H\) \(I\) \(J\) \(K\) \(L\) \(M\)
\(N\) \(O\) \(P\) \(Q\) \(R\) \(S\) \(T\) \(U\) \(V\) \(W\) \(X\) \(Y\) \(Z\)
\(a\) \(b\) \(c\) \(d\) \(e\) \(f\) \(g\) \(h\) \(i\) \(j\) \(k\) \(l\) \(m\) \(n\) \(o\) \(p\) \(q\)
\(r\) \(s\) \(t\) \(u\) \(v\) \(w\) \(x\) \(y\) \(z\) \(1\) \(2\) \(3\) \(4\) \(5\) \(6\) \(7\) \(8\) \(9\) \(0\)


[TOP]

2.2 希腊字母

\Gamma \Delta \Lambda \Phi \Pi \Psi
\(\Gamma\) \(\Delta\) \(\Lambda\) \(\Phi\) \(\Pi\) \(\Psi\)
\Sigma \Theta \Upsilon \Xi \Omega
\(\Sigma\) \(\Theta\) \(\Upsilon\) \(\Xi\) \(\Omega\)
\alpha \beta \gamma \delta \epsilon
\(\alpha\) \(\beta\) \(\gamma\) \(\delta\) \(\epsilon\)
\zeta \eta \theta \iota \kappa \lambda
\(\zeta\) \(\eta\) \(\theta\) \(\iota\) \(\kappa\) \(\lambda\)
\mu \nu \xi \pi \rho \sigma \tau \phi
\(\mu\) \(\nu\) \(\xi\) \(\pi\) \(\rho\) \(\sigma\) \(\tau\) \(\phi\)
\upsilon \chi \psi \omega \varepsilon
\(\upsilon\) \(\chi\) \(\psi\) \(\omega\) \(\varepsilon\)
\digamma \varkappa \varsigma
\(\digamma\) \(\varkappa\) \(\varsigma\)
\varphi \varpi \varrho \vartheta
\(\varphi\) \(\varpi\) \(\varrho\) \(\vartheta\)


[TOP]

2.3 其他字母

\(\aleph\) \aleph \(\ell\) \ell \(\complement\) \complement
\(\eth\) \eth \(\hbar\) \hbar \(\hslash\) \hslash
\(\mho\) \mho \(\partial\) \partial \(\Bbbk\) \Bbbk
\(\Im\) \Im \(\Re\) \Re \(\circledS\) \circledS
\(\imath\) \imath \(\jmath\) \jmath \(\)


[TOP]

2.4 字体

\({\rm ABCabc123}\) : {\rm ABCabc123} 罗马体
\({\it ABCabc123}\) : {\it ABCabc123} 意大利体
\({\bf ABCabc123}\) : {\bf ABCabc123} 黑体
\({\cal ABCabc123}\) : {\cal ABCabc123} 花体
\({\sf ABCabc123}\) : {\sf ABCabc123} 等线体
\({\mit ABCabc123}\) : {\mit ABCabc123} 数学斜体
\({\tt ABCabc123}\) : {\tt ABCabc123} 打字机字体
\({\frak ABCabc123}\) : {\frak ABCabc123}  
\({\mathscr {ABCabc123} }\) : {\mathscr {ABCabc123} }  
\({\mathbb {ABCabc123} }\) : {\mathbb {ABCabc123} }  


[TOP]

2.5 字号

\({\large xxx}\) : {\large xxx}
\({\Large xxx}\) : {\Large xxx}
\({\LARGE xxx}\) : {\LARGE xxx}
\({\huge xxx}\) : {\huge xxx}
\({\Huge xxx}\) : {\Huge xxx}


[TOP]


3. 符号

3.1 运算符号

\(\times\) \times \(\pm\) \pm \(\bigcup\) \bigcup
\(\div\) \div \(\mp\) \mp \(\bigcap\) \bigcap
\(\int\) \int \(\oint\) \oint \(\iiint\) \iiint
\(\bigoplus\) \bigoplus \(\bigotimes\) \bigotimes \(\bigodot\) \bigodot
\(\sum\) \sum \(\prod\) \prod \(\cdot\) \cdot
\(\prime\) \prime \(\partial\) \partial \(\nabla\) \nabla
\(\sqrt[n]{m}\) \sqrt[n]{m} \(\frac{n}{m}\) \frac{n}{m} \(\)


[TOP]

3.2 逻辑符号

\(\approx\) \approx \(\sim\) \sim \(\doteq\) \doteq
\(\geqslant\) \geqslant \(\gg\) \gg \(\ngtr\) \ngtr
\(\leqslant\) \leqslant \(\ll\) \ll \(\nless\) \nless
\(\equiv\) \equiv \(\because\) \because \(\in\) \in
\(\neq\) \neq \(\therefore\) \therefore \(\ni\) \ni
\(\notin\) \notin \(\perp\) \perp \(\mid\) \mid
\(\propto\) \propto \(\parallel\) \parallel \(\nmid\) \nmid
\(\forall\) \forall \(\exists\) \exists


[TOP]

3.3 图形标记

\(\angle\) \angle \(\infty\) \infty \(\surd\) \surd
\(\bot\) \bot \(\bigstar\) \bigstar \(\varnothing\) \varnothing
\(\triangle\) \triangle \(\square\) \square \(\spadesuit\) \spadesuit
\(\clubsuit\) \clubsuit \(\blacksquare\) \blacksquare \(\vec{x}\) \vec{x}
\(\ldots\) \ldots \(\cdots\) \cdots \(\circ\) \circ


[TOP]

3.4 箭头

\(\gets\) \gets \(\to\) \to
\(\upuparrows\) \upuparrows \(\downdownarrows\) \downdownarrows
\(\nearrow\) \nearrow \(\nwarrow\) \nwarrow
\(\swarrow\) \swarrow \(\searrow\) \searrow
\(\downarrow\) \downarrow \(\Uparrow\) \Uparrow
\(\updownarrow\) \updownarrow \(\Updownarrow\) \Updownarrow
\(\circlearrowleft\) \circlearrowleft \(\circlearrowright\) \circlearrowright
\(\curvearrowleft\) \curvearrowleft \(\curvearrowright\) \curvearrowright


[TOP]

3.5 字母标记

\(\sin\) \sin \(\cos\) \cos \(\exp\) \exp
\(\max\) \max \(\min\) \min \(\det\) \det
\(\ln\) \ln \(\log\) \log \(\lg\) \lg
\(\inf\) \inf \(\deg\) \deg \(\tan\) \tan
\(\lim\) \lim \(\arg\) \arg \(\csc\) \csc
\(\arcsin\) \arcsin \(\arccos\) \arccos \(\arctan\) \arctan


[TOP]

3.6 括号

\(\lbrace\)   \lbrace \(\backslash\)   \backslash \(\vert\)   \vert
\(\rbrace\)   \rbrace \   \ \(\Vert\)   \Vert


如果只需要显示一半,需要使用/left./right.进行标记:

\( \left. \frac{ {\rm d}y}{ {\rm d}x} \right| _{x=0} \) : \left. \frac{ {\rm d}y}{ {\rm d}x} \right| _{x=0}


括号的大小可调整:

(
)
\left
\right
\bigl
\bigr
\Bigl
\Bigr
\biggl
\biggr
\Biggl
\Biggr
\((\dfrac{c}{d})\) \(\left(\dfrac{c}{d}\right)\) \(\bigl(\dfrac{c}{d}\bigr)\) \(\Bigl(\dfrac{c}{d}\Bigr)\) \(\biggl(\dfrac{c}{d}\biggr)\) \(\Biggl(\dfrac{c}{d}\Biggr)\)


[TOP]

3.7 戴帽类符号

\(\acute{x}\) \acute{x} \(\grave{x}\) \grave{x} \(\ddot{x}\) \ddot{x}
\(\tilde{x}\) \tilde{x} \(\bar{x}\) \bar{x} \(\breve{x}\) \breve{x}
\(\check{x}\) \check{x} \(\hat{x}\) \hat{x} \(\vec{x}\) \vec{x}
\(\dot{x}\) \dot{x} \(\ddot{x}\) \ddot{x} \(\dddot{x}\) \dddot{x}


[TOP]

3.8 连线符号

\(\widetilde{xxx}\) \widetilde{xxx}
\(\widehat{xxx}\) \widehat{xxx}
\(\overbrace{xxx}\) \overbrace{xxx}
\(\underbrace{xxx}\) \underbrace{xxx}
\(\overline{xxx}\) \overline{xxx}
\(\underline{xxx}\) \underline{xxx}
\(\overrightarrow{xxx}\) \overrightarrow{xxx}
\(\underleftarrow{xxx}\) \underleftarrow{xxx}
\(\overleftrightarrow{xxx}\) \overleftrightarrow{xxx}
\(\underleftrightarrow{xxx}\) \underleftrightarrow{xxx}

\(\overbrace{a+\underbrace{b+c}_{1.0}+d}^{2.0}\):

\overbrace{a+\underbrace{b+c}_{1.0}+d}^{2.0}


[TOP]


4. 标注

4.1 上下标

^标记上标,_标记下标,两侧都有上下标时,使用\sideset

\(\sideset{^1_2}{^3_4}\bigotimes \) : \sideset{^1_2}{^3_4}\bigotimes


顶部和底部符号用\overset\underset标记。

\(\overset{*}{X} \) : \overset{*}{X}


底部的符号还可以使用\limits标记。

\(\iint\limits_S f(x,y)\;dx\;dy \) : \iint\limits_S f(x,y)\;dx\;dy


[TOP]

4.2 箭头标注

\(A\:\xleftarrow{n+\mu-1}\:B\:\xrightarrow[T]{n\pm i-1}\:C\):

A:\xleftarrow{n+\mu-1}:B:\xrightarrow[T]{n\pm i-1}:C


[TOP]


5. 格式

5.1 外框

\(\boxed{E = mc ^2}\)

\boxed{E = mc ^2}


[TOP]

5.2 矩阵

\[\begin{pmatrix} \alpha& \beta^{*}\\ \gamma^{*}& \delta \end{pmatrix}\]
\begin{pmatrix}
  \alpha& \beta^{*}\\
  \gamma^{*}& \delta
\end{pmatrix}


[TOP]

5.3 多行公式

\标记换行,&类似于制表符,用于元素的对齐。

\[\boxed{ \begin{equation} \begin{split} a =& b+c-d\\ &{}+e-f\\ =& g+h\\ =& i \end{split} \end{equation} } \]

\begin{equation}
  \begin{split}
    a =& b+c-d\\
         &{}+e-f\\
       =& g+h\\
       =& i
  \end{split}
\end{equation}
            
\[\boxed{ \begin{align} a_1& =b_1+c_1\\ a_2& =b_2+c_2-d_2+e_2 \end{align} } \]

\begin{align}
  a_1& =b_1+c_1\\
  a_2& =b_2+c_2-d_2+e_2
\end{align}
        
\[\boxed{ \begin{align} a_{11}& =b_{11}& a_{12}& =b_{12}\\ a_{21}& =b_{21}& a_{22}& =b_{22}+c_{22} \end{align} } \]
\begin{align}
  a_{11}& =b_{11}&
  a_{12}& =b_{12}\\
  a_{21}& =b_{21}&
  a_{22}& =b_{22}+c_{22}
\end{align}
\[\boxed{ \lim _{T \rightarrow 0} f _i = \begin{cases} 1, & \varepsilon _i\lt\mu, \\ 0, & \varepsilon _i \gt \mu. \end{cases} } \]
\lim _{T \rightarrow 0} f _i =
  \begin{cases}
    1, & \varepsilon _i \lt \mu, \\
    0, & \varepsilon _i \gt \mu.
  \end{cases}


[TOP]