MathJax

MathJax is an open source JavaScript display engine for mathematics that works in all modern browsers.
http://www.mathjax.org/
總之,透過MathJax,我們可以輕鬆的在Blog上打出方程式。
在這裡大致跟大家講一下如何使用

照官方網站的說法,請在<head>及</head>間加入
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>

或者你也可以改成加入這段別人修改過的(這個幫你做了一些設定,比較易於使用)
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
MathJax.Hub.Config({
 extensions: ["tex2jax.js","TeX/AMSmath.js","TeX/AMSsymbols.js"],
 jax: ["input/TeX", "output/HTML-CSS"],
 tex2jax: {
     inlineMath: [ ['$','$'], ["\\(","\\)"] ],
     displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
 },
 "HTML-CSS": { availableFonts: ["TeX"] }
});
</script>
如果沒辦法在<head>及</head>間加入,你也可以加在Script小工具中

以PIXNET為例

1.首先在側邊欄位設定新增欄位


2.把程式碼貼上去


3.把剛剛新增的欄位拖近來


4.別忘了按儲存



緊接著來如何講講,如何打出方程式。一般來說MathJax支援兩種類型的格式-$\LaTeX$及MathML。
Each <script> tag has a type attribute that identifies the kind of script that the tag contains. The usual (and default) value is type="text/javascript", and when a script has this type, the browser executes the script as a javascript program. MathJax, however, uses the type math/tex to identify mathematics in the TeX and LaTeX notation, and math/mml for mathematics in MathML notation. When the tex2jax or mml2jax preprocessors run, they create <script> tags with these types so that MathJax can process them when it runs its main typesetting pass.
 (上面我怕翻錯,就先貼原文)

先談談一官方給的方法, 首先我們得先切到HTML的編輯模式,鍵入我們要呈現方程式。

以下為一個行內顯示的TeX方程式:
<script type="math/tex">x+\sqrt{1-x^2}</script>


如果要獨立顯示的TeX方程式,則如下例稍做一些修改:
<script type="math/tex; mode=display">
  \sum_{n=1}^\infty {1\over n^2} = {\pi^2\over 6}
</script> 




此外,要使用MathML格式也是使用相似的辦法(雖然一般來說,不會有人直接打MathML這種格式,不過總有些時候,從別的地方複製來的方程式是這種格式)

行內顯示的方程式:
<script type="math/mml">
  <math>
    <mi>x</mi>
    <mo>+</mo>
    <msqrt>
      <mn>1</mn>
      <mo>&#x2212;<!-- − --></mo>
      <msup>
        <mi>x</mi>
        <mn>2</mn>
      </msup>
    </msqrt>
  </math>
</script>


一樣稍作修改,可得獨立顯示的方程式:
<script type="math/mml">
  <math display="block">
    <mrow>
      <munderover>
        <mo>&#x2211;<!-- ∑ --></mo>
        <mrow>
          <mi>n</mi>
          <mo>=</mo>
          <mn>1</mn>
        </mrow>
        <mi mathvariant="normal">&#x221E;<!-- ∞ --></mi>
      </munderover>
    </mrow>
    <mrow>
      <mfrac>
        <mn>1</mn>
        <msup>
          <mi>n</mi>
          <mn>2</mn>
        </msup>
      </mfrac>
    </mrow>
    <mo>=</mo>
    <mrow>
      <mfrac>
        <msup>
          <mi>&#x03C0;<!-- π --></mi>
          <mn>2</mn>
        </msup>
        <mn>6</mn>
      </mfrac>
    </mrow>
  </math>
</script>

首先如果是要插入在文字(這個不須切換到HTML模式,但需使用另外那段SCRIPT)中,請打在兩個$之間
範例:
牛隊第二運動定律$\vec{F}=m\vec{a}$ 是牛頓發現的
牛隊第二運動定律$\vec{F}=m\vec{a}$ 是牛頓發現的
如果是要打成一整段獨立的式子,請打在\[\]
範例:
重力和庫倫力的大小都跟距離平方成反比:
\[\begin{align}\\F=\frac{G m_1 m_2}{r^2} \\ F=\frac{k q_1 q_2}{r^2}\end{align}\]
重力和庫倫力的大小都跟距離平方成反比:
\[\begin{align}\\F=\frac{G m_1 m_2}{r^2}\\F=\frac{k q_1 q_2}{r^2}\end{align}\]

特別說明一下,如果沒有在前後加上\begin{align}\end{align}的話換行的\\會不能用



此外,如果哪一天你有需要使用你曾打在BLOG上的公式,有或者是別的使用MathJax網站上的式子時,MathJax也提供了很輕鬆的辦法,詳細見下面這段影片。






當然有些人實在不會OR不喜歡直接打TeX,沒關西,在這裡推薦一個好物,如果你使用的瀏覽器是Google Chrome的話,推薦一個實用的APP

Daum Equation Editor
按我安裝

簡介:

今後,可以在谷歌浏覽器上迅速容易地進行公式編輯了。
Daum公式編輯器可以使無論簡單的還是複雜的公式都能夠得以迅速容易的編輯,直接點擊本編輯器提供的多種公式的按鈕就可以做公式。並且,還可以通過Tex輸入編輯分析Tex,完成公式。
★★★ New in version 1.1.73 ★★★
▶ Add new equations. (quad, 3/18quad, 4/18quad, 5/18quad, under dot, tilde )
▶ LaTex save as text file.
▶ Improve usability
▶ Add supported launguage ( Chinese, Japanese )
★★★ 功能 ★★★
▶ 通過點擊按鈕做公式。
▶ 設計利用TeX輸入編輯做公式。
▶ 輸入該公式的文本說明。
▶ 調整公式的大小或版面。
▶ 做完的公式保存爲電腦圖片。
▶ 提供複制、粘貼
▶ 提供曆史任務
▶ 提供多種數學符號

底下的那段就是TeX










2 則留言:

  1. 最前面head和/head在講什麼?

    回覆刪除
  2. @匿名
    請見
    http://wellsli.com/htm/html_head.htm

    回覆刪除