12

I am testing the MathJax javascript library in a local HTML file. It works and correctly renders math formulas if I include:

script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'

in the HTML file, but it doesn't work if I include instead:

script type="text/javascript" src="/path_to/mathjax.js"

or even if I put the entire javascript source code. What is the reason? I need to load mathjax.js from local js file into a local HTML file, so the first way doesn't help me. (EDIT- I see an error: failed to load /extensions/MathZoom.js)

sevko
  • 1,402
  • 1
  • 18
  • 37
P5music
  • 3,197
  • 2
  • 32
  • 81

2 Answers2

12

I had to load the entire MathJax distribution (17 Mb zip file), expand it and put the right configuration string in the HTML file. The final form is: script type='text/javascript' src='/path_to/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML,local/local'

P5music
  • 3,197
  • 2
  • 32
  • 81
  • 2
    See this [MathJax Documentation Page](https://github.com/mathjax/MathJax/wiki/Shrinking-MathJax-for-%22local%22-installation) for details about how to reduce the MathJax installation for use locally. – Davide Cervone Oct 06 '13 at 23:27
5

This may occur due to two reasons

1.You may have not extracted the entire zip folder, so first do that.

Still you are getting the error look into second reason.

2.You are not referring to the file correctly. eg:

<script type ="text/javascript" src="pathto\mathjax.js">

You have typed an incorrect filename. Correct name of file is MathJax.js.Given below is the correct way.

<script type ="text/javascript" src="pathto\MathJax.js">

MathJax.js is the name of the file in the extracted folder(unless modified)

If all of this is not working,then link to the script in this way:

<script type="text/javascript" src="Pathto\MathJax.js?config=TeX-AMS-MML_HTMLorMML">

The reason that your script is not working is you are not including:

'?config=TeX-AMS-MML_HTMLorMML'

coder
  • 906
  • 1
  • 12
  • 19
  • Thanks, it works for me but i face another problem(I use a repeater to show a list of mathematic phrase) in first page it works normally but when you change repeater page MathJax not work and show a simple text. – Ali Amini Aug 24 '20 at 13:15
  • @AliAmini, make sure the repeater page u mentioned has the mathjax script.Also check your browser console to check for errors. – coder Aug 24 '20 at 14:27
  • thanks for answer, i solved it by adding MathJax.Hub.TypeSet() in repeater page change event(MathJax.Hub.TypeSet() this will run agian MathJax in page) – Ali Amini Aug 24 '20 at 19:07