Tools 是非官方社区Wiki。社区文档正在编写中,欢迎参与。 Wiki编辑答疑群:717421103
版本250722.2
全站通知:

数学公式

阅读

    

2025-08-14更新

    

最新编辑:glamcurrent

阅读:

  

更新日期:2025-08-14

  

最新编辑:glamcurrent

来自WIKI实验室WIKI_BWIKI_哔哩哔哩
跳到导航 跳到搜索
页面贡献者 :
glamcurrent
庄森

数学公式是 MediaWiki 自带的能力,MediaWiki 会调用 MathJax 将使用 <math></math> 包裹的代码块转换为数学公式。

MathJax 使用 [math]\displaystyle{ \LaTeX }[/math] 语法来编写数学公式。

例子

代码 效果
<math>E=mc^2</math>
[math]\displaystyle{ E=mc^2 }[/math]
<math>\mathrm e^{\mathrm i\pi}+1=0</math>
[math]\displaystyle{ \mathrm e^{\mathrm i\pi}+1=0 }[/math]
<math>
-\frac{\hbar^2}{2m}\nabla^2\Psi(\mathbf r, t)
+V(\mathbf r, t)\Psi(\mathbf r, t)
=\mathrm i\hbar\frac\partial{\partial t}\Psi(\mathbf r, t)
</math>
[math]\displaystyle{ -\frac{\hbar^2}{2m}\nabla^2\Psi(\mathbf r, t) +V(\mathbf r, t)\Psi(\mathbf r, t) =\mathrm i\hbar\frac\partial{\partial t}\Psi(\mathbf r, t) }[/math]
<math>
\left\{
\begin{aligned}
  &\oint_{\partial\Omega} \mathbf E \,   \mathrm d \mathbf S     = \frac1{\varepsilon_0} \iiint_\Sigma \rho \, \mathrm dV \\
  &\oint_{\partial\Omega} \mathbf B \,   \mathrm d \mathbf S     = 0 \\
  &\oint_{\partial\Sigma}  \mathbf E \cdot \mathrm d \boldsymbol\ell = -\frac{\mathrm d}{\mathrm dt} \iint_\Sigma \mathbf B\cdot\mathrm d\mathbf S \\
  &\oint_{\partial\Sigma}  \mathbf B \cdot \mathrm d \boldsymbol\ell = \mu_0 \left( \iint_\Sigma \mathbf J \cdot \mathrm d \mathbf S + \varepsilon_0 \frac{\mathrm d}{\mathrm dt} \iint_\Sigma \mathbf E \cdot \mathrm d \mathbf S \right) \\
\end{aligned}
\right.
</math>
[math]\displaystyle{ \left\{ \begin{aligned} &\oint_{\partial\Omega} \mathbf E \, \mathrm d \mathbf S = \frac1{\varepsilon_0} \iiint_\Sigma \rho \, \mathrm dV \\ &\oint_{\partial\Omega} \mathbf B \, \mathrm d \mathbf S = 0 \\ &\oint_{\partial\Sigma} \mathbf E \cdot \mathrm d \boldsymbol\ell = -\frac{\mathrm d}{\mathrm dt} \iint_\Sigma \mathbf B\cdot\mathrm d\mathbf S \\ &\oint_{\partial\Sigma} \mathbf B \cdot \mathrm d \boldsymbol\ell = \mu_0 \left( \iint_\Sigma \mathbf J \cdot \mathrm d \mathbf S + \varepsilon_0 \frac{\mathrm d}{\mathrm dt} \iint_\Sigma \mathbf E \cdot \mathrm d \mathbf S \right) \\ \end{aligned} \right. }[/math]

编号功能

由于biligame的simple MathJax默认不开启ams自动编号,因此以下两种公式表达方法在外观上无任何区别:

基本公式表达
示例代码 效果
不使用\begin{equation}
<math>
    e=\lim_{n\to \infty}(1+\frac{1}{n})^n
</math>
[math]\displaystyle{ e=\lim_{n\to \infty}(1+\frac{1}{n})^n }[/math]
使用\begin{equation}
<math>
    \begin{equation}
        e=\lim_{n\to \infty}(1+\frac{1}{n})^n 
    \end{equation} 
</math>
[math]\displaystyle{ \begin{equation} e=\lim_{n\to \infty}(1+\frac{1}{n})^n \end{equation} }[/math]


若有编号需求,须自行进行标记,\begin{equation}不会自动进行编号,例如以下示例:

<math>
    \begin{equation}
        m=\frac{m_0}{\sqrt{1-v^2/c^2}}
    \end{equation} 
</math>

[math]\displaystyle{ \begin{equation} m=\frac{m_0}{\sqrt{1-v^2/c^2}} \end{equation} }[/math]


以下是带编号示例:

<math>
    \begin{equation}
       \label{first}
       \tag{1}
        e=\lim_{1\to \infty}(1+\frac{1}{n})^n 
    \end{equation}  
</math>

[math]\displaystyle{ \begin{equation} \label{first} \tag{1} e=\lim_{1\to \infty}(1+\frac{1}{n})^n \end{equation} }[/math]

其中\tag{}控制显示的公式编号,\label{}控制在引用时的编号参数,若为\label{first},则引用时为\ref{first} ,例如引用上方的公式的效果:[math]\displaystyle{ \ref{first} }[/math](\ref{first})

数组示例

代码 渲染效果
<math>
\begin{array}{lcl}
g(x) & = & (x+2)^2 & = (x+2)(x+2)\\ % This row triggers the error
& = & x^2+4x+4\\
\end{array}
</math>
[math]\displaystyle{ \begin{array}{lcl} g(x) & = & (x+2)^2 & = (x+2)(x+2)\\ % This row triggers the error & = & x^2+4x+4\\ \end{array} }[/math]

矩阵示例

矩阵类型 代码 渲染效果
matrix
<math>
    \begin{matrix}
        0 & 1 \\
        1 & 0 \\
    \end{matrix} 
</math>
[math]\displaystyle{ \begin{matrix} 0 & 1 \\ 1 & 0 \\ \end{matrix} }[/math]
bmatrix
<math>
    \begin{bmatrix}
        0 & 1 \\
        1 & 0 \\
    \end{matrix} 
</math>
[math]\displaystyle{ \begin{bmatrix} 0 & 1 \\ 1 & 0 \\ \end{bmatrix} }[/math]
pmatrix
<math>
    \begin{pmatrix}
        0 & 1 \\
        1 & 0 \\
    \end{pmatrix} 
</math>
[math]\displaystyle{ \begin{pmatrix} 0 & 1 \\ 1 & 0 \\ \end{pmatrix} }[/math]
vmatrix
<math>
    \begin{vmatrix}
        0 & 1 \\
        1 & 0 \\
    \end{vmatrix} 
</math>
[math]\displaystyle{ \begin{vmatrix} 0 & 1 \\ 1 & 0 \\ \end{vmatrix} }[/math]
Vmatrix
<math>
    \begin{Vmatrix}
        0 & 1 \\
        1 & 0 \\
    \end{Vmatrix} 
</math>
[math]\displaystyle{ \begin{Vmatrix} 0 & 1 \\ 1 & 0 \\ \end{Vmatrix} }[/math]

MathJax代码的展示

当展示带<math></math>[math]\displaystyle{ \LaTeX }[/math]代码时,请勿使用<code>标签,优先考虑使用<syntaxhighlight>,关于syntaxhighlight的更多介绍,参见Extension:SyntaxHighlight