LoginSignup
4
4

More than 5 years have passed since last update.

【Jupyter】MathJaxの設定をいじる

Posted at

動機

お馴染みの $\mathrm{grad}, \mathrm{div}, \mathrm{rot}$をいちいち\mathrm{grad}, \mathrm{div}, \mathrm{rot}と書くのが面倒なので、普段$\TeX$を使うときはマクロを設定しています。研究するにはもう手放すことのできないipython notebookでもマクロを設定したいですよね。

方法

設定ファイルの置き場所

(pythonのインストール場所)/site-packages/IPython/html/static/notebook/js/mathjaxutils.js

にあります。私はpyenvを使っているので~/.pyenv/versions/XXX/lib/pythonXX/site-packages/IPython/html/static/notebook/js/mathjaxutils.js (XX=バージョン)になります。

編集

MathJax.Hub.Configというオブジェクトに色々追加すればよい。例えば、マクロを追加するなら

            // MathJax loaded
            MathJax.Hub.Config({
                tex2jax: {
                  ...
                },
                // Added by me!!!
                TeX: {
                  Macros:{
                    grad:   ['\\mathrm{grad}\\,'],
                    diver:  ['\\mathrm{div}\\,'],
                    rot:    ['\\mathrm{rot}\\,'],
                    bm:     ['{\\boldsymbol{#1}}', 1],
                  }
                },
                ...
            });

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4