MathML 使用入門

MathML 使用入門 - 超完整版

MathML 使用入門 - 超完整版

基本數學標記

簡單運算式

插入一個簡單的數學式子:

<math>
  <mi>x</mi>
  <mo>=</mo>
  <mn>5</mn>
</math>
    
x = 5

分組:<mrow>

<mrow>
  <mi>a</mi>
  <mo>+</mo>
  <mi>b</mi>
</mrow>
    
a + b

分數與向量

分數:<mfrac>

<math>
  <mfrac>
    <mn>1</mn>
    <mn>2</mn>
  </mfrac>
</math>
    
1 2

多重分數(分數中嵌套分數)

<math>
  <mfrac>
    <mfrac>
      <mn>1</mn>
      <mn>2</mn>
    </mfrac>
    <mn>3</mn>
  </mfrac>
</math>
    
1 2 3

向量表示:<mover>

<math>
  <mover>
    <mi>v</mi>
    <mo>→</mo>
  </mover>
</math>
    
v

根式與次方

開平方根:<msqrt>

<msqrt>
  <mi>x</mi>
</msqrt>
    
x

多重根式(任意次根):<mroot>

使用 <mroot> 可表示任意次的根式,例如立方根:

<math>
  <mroot>
    <mi>x</mi>
    <mn>3</mn>
  </mroot>
</math>
    
x 3

指數次方:<msup>

例如:e 的 x 次方:

<math>
  <msup>
    <mi>e</mi>
    <mi>x</mi>
  </msup>
</math>
    
e x

對數與求和

對數

使用 <msub> 表示對數的底數,例如以 2 為底的 log x:

<math>
  <msub>
    <mi>log</mi>
    <mn>2</mn>
  </msub>
  <mo>( </mo>
  <mi>x</mi>
  <mo>) </mo>
</math>
    
log 2 ( x )

求和符號 (Sigma)

使用 <munderover> 表示帶有下標與上標的求和符號,例如從 i = 1 到 n 的求和:

<math>
  <munderover>
    <mo>∑</mo>
    <mrow>
      <mi>i</mi>
      <mo>=</mo>
      <mn>1</mn>
    </mrow>
    <mi>n</mi>
  </munderover>
  <msub>
    <mi>a</mi>
    <mi>i</mi>
  </msub>
</math>
    
i = 1 n a i

多重積分

多重積分可由連續的積分符號表示,例如雙重積分:

<math display="block">
  <mrow>
    <mo>∫</mo>
    <mo>∫</mo>
    <mi>f(x,y)</mi>
    <mi>dx</mi>
    <mi>dy</mi>
  </mrow>
</math>
    
f(x,y) dx dy

小結

  • <math>:數學公式容器
  • <mrow>:元素分組
  • <mfrac>:分數
  • <mover>:向量或上方標記
  • <msqrt>:平方根
  • <mroot>:任意次根
  • <msup>:指數次方
  • <msub>:下標(常用於對數底數或變數下標)
  • <munderover>:上下標(如求和符號)
  • <mtable>:矩陣