· 

ブログ内でTeX (MathJax)

ブログ内でTeXの文書を書きたい場合、HTMLのheaderに 

<script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-AMS_CHTML"></script>

を付け加えればよい。なお、最新のバージョンは

https://cdnjs.com/libraries/mathjax

で確認できる。

 文書内の数式は、デフォルトでは\(~\)で記述するが、$~$で記述したい場合は代わりに以下を加える。

<script type="text/x-mathjax-config">
MathJax.Hub.Config({
    tex2jax: {  
    inlineMath: [['$','$'], ['\\(','\\)']],
    processEscapes: true
  },   CommonHTML: { matchFontHeight: false }
});
</script>
<script async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-AMS_CHTML"></script>

実際に使ってみた例を以下に示す。


[$Schr\ddot{o}dinger$方程式] $$ \left[-\frac{\hbar^2}{2m}\Delta+V(x)\right]\psi(x)=E\psi(x) $$
[$Maxwell$方程式] $$ \begin{eqnarray} \left\{ \begin{array}{l} \nabla \cdot \boldsymbol{D} & = \rho\\ \nabla \times\boldsymbol{H}-\dfrac{\partial\boldsymbol{D}}{\partial t}&=\boldsymbol{J}\\ \nabla \times \boldsymbol{E} + \dfrac{\partial \boldsymbol{B}}{\partial t} & = 0\\ \nabla \cdot \boldsymbol{B} & = 0 \end{array} \right. \end{eqnarray} $$ [$Fourier$変換] \begin{align} F(\omega) = \cfrac{1}{\sqrt{2\pi}}\int_{-\infty}^{+\infty}f(t)e^{i\omega t}dt \end{align}

コメントをお書きください

コメント: 4
  • #1

    Sebastian (木曜日, 12 9月 2019 19:33)

    Hi,

    I am currently trying to use Mathjax on my Jimdo-Webpage, but without success. Since you appear to have it running beautifully on your webpage, may I ask for your help? Here is what I did: While in editing mode in Jimdo I went to menu>settings>edit head and entered the following line in the head of the page I want to use mathjax in:

    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_CHTML"></script>

    Shouldnt that be working? Unfortunately, it is not. I tried the following minimal html code in a text element on that page:

    <p>\(a^2+b^2=c^2\)</p>

    but I am getting no math formatted output, all I get is "\(a^2+b^2=c^2\)" (on my Firefox and Chrome). I would be so thankful for any insight! I am using the Design Milan, in case this does have anything to do with it,
    Cheers from Germany

    Sebastian

  • #2

    Sebastian (木曜日, 12 9月 2019 20:17)

    Obviously, in my last comment I did not take into account that your Mathjax would interprete my minimal html code and the output I am getting as Tex and display it accordingly. So what I really wanted to say is that I am getting *no* math formatted output!

  • #3

    優曇華院 (木曜日, 12 9月 2019 20:26)

    The script you use is for MathML. To use TeX type, change it to:

    <script async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.6/MathJax.js?config=TeX-AMS_CHTML"></script>

    I think it works.

  • #4

    Sebastian (木曜日, 12 9月 2019 22:39)

    Indeed, it does! Thank you!!