Blog 1

Random Talk on Random Thoughts

MathJax Local Configuration File (2)

| Comments |

Background

In my opinion, the default display of the $\rm \LaTeX$ command for $\Re z$ and $\Im z$ don’t look good.

default Im(z) display

Problem

I want to reset the \Im command in my local MathJax configuration file source/javascripts/MathJaxLocal.js. I used a script inside the <body> tag to load my local MathJax configurations from GitHub.1 If I want to test the configurations, then I’ll have to push my changes to GitHub before I can see the effect and figure out the errors — this is incredibly slow and inefficient.

How can I locally debug my MathJax configurations?

Solution

To locally test my MathJax configurations, I put another <script> tag containing the local configurations before the <script> that loads MathJax.js.

Put this at the bottom
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
  jax: ["input/TeX", "output/HTML-CSS"],
  tex2jax: {
    inlineMath: [['$', '$']],
    displayMath: [['$$', '$$'],['\\[','\\]']],
    processEscapes: true,
    skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
  },
  messageStyle: "none",
  "HTML-CSS": { preferredFont: "TeX", availableFonts: ["STIX","TeX"] },
  TeX: {
    equationNumbers: { autoNumber: "AMS" },
    extensions: ["AMSmath.js", "AMSsymbols.js","AMScd.js"],
    TagSide: "left",
    Macros: {
      field: ['\\mathbb{#1}', 1],
      C: ['\\field{C}'],
      F: ['\\field{F}'],
      N: ['\\field{N}'],
      Q: ['\\field{Q}'],
      R: ['\\field{R}'],
      Z: ['\\field{Z}'],

      zeros: ['\\mathbf{0}'],
      ud: ['\\,\\mathrm{d}'],

      vect:['\\boldsymbol{\\mathbf{#1}}',1],
      abs: ['\\lvert#1\\rvert', 1],
      abslr:['\\left\\lvert#1\\right\\rvert', 1],
      norm: ['\\lVert#1\\rVert', 1],
      normlr: ['\\left\\lVert#1\\right\\rVert', 1],

      lcm: ['\\mathop{\\mathrm{lcm}}'],
      interior: ['\\mathop{\\mathrm{int}}'],
      exterior: ['\\mathop{\\mathrm{ext}}'],
      volume: ['\\mathop{\\mathrm{vol}}'],

      E: ['{\\rm I\\kern-.3em E}'],
      Var: ['\\mathop{\\mathrm{Var}}'],
      Cov: ['\\mathop{\\mathrm{Cov}}'],
      Binom: ['\\mathop{\\mathrm{Binom}}'],
      Exp: ['\\mathop{\\mathrm{Exp}}'],
      Poi: ['\\mathop{\\mathrm{Poi}}'],

      GL: ['\\mathrm{GL}'],
      SL: ['\\mathrm{SL}'],
      Aut: ['\\mathrm{Aut}'],
      id: ['\\mathrm{id}'],

      // Test your code here
      Re: ['\\mathop{\\mathrm{Re}}'],
      Im: ['\\mathop{\\mathrm{Im}}'],
    }
  }
});
</script>

<script type="text/javascript">
(function() {
  function getScript(url,success){
    var script=document.createElement('script');
    script.src=url;
    var head=document.getElementsByTagName('head')[0],
    done=false;
    script.onload=script.onreadystatechange = function(){
      if ( !done && (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete') ) {
      done=true;
      success();
      script.onload = script.onreadystatechange = null;
      head.removeChild(script);
      }
    };
    head.appendChild(script);
  }

  getScript("https://cdn.mathjax.org/mathjax/latest/MathJax.js?" +
    "config=TeX-AMS-MML_HTMLorMML", function(){});

})();
</script>

I think that rendering $\Re z$ and $\Im z$ with roman font is better.

improved Im(z) display


  1. Refer to my old post titled A Quick Markdown Syntax Error Detection for Writing MathJax Equations in Octopress Posts (3) for details. 

Comments