Problems getting Mathjax to work in an offline environment

381 views
Skip to first unread message

craig...@gmail.com

unread,
Jul 12, 2017, 11:52:32 AM7/12/17
to MathJax Users

Hi,

I can see webpages that have math formulas, and when I do a view-source, I might see:

$e^{-z} \rightarrow \infty$, and $\sigma(z) \approx 0$. So when $z = w \cdot x +b$

And

“we call $z^l$ the <em>weighted input</em>

and more.

I wrote a program to concatenate several webpages at once.   The main advantage of this is that you can view a tutorial from a website offline, perhaps on an e-reader.

I find, however, that when it concatenates pages with this kind of notation, the notation no longer represents the formulas.

So my guess is that either

  1. a script is not running when I view the concatenated page offline on my PC, or that
  2. a stylesheet is not working or
  3. something mysterious is missing.

So my main question is: is there a way to get MathJax to work in this type of situation? 

Thanks in advance

Peter Krautzberger

unread,
Jul 13, 2017, 4:36:22 AM7/13/17
to mathja...@googlegroups.com
Hi Gideon,

Thanks for re-posting here.

Our documentation at http://docs.mathjax.org/en/latest/start.html#installing-your-own-copy-of-mathjax should get you started with a local installation.

Regards
Peter.

--
You received this message because you are subscribed to the Google Groups "MathJax Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathjax-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

jahvascr...@gmail.com

unread,
Jul 20, 2017, 9:16:03 PM7/20/17
to MathJax Users, craig...@gmail.com
Hi,


Le mercredi 12 juillet 2017 17:52:32 UTC+2, craig...@gmail.com a écrit :

I find, however, that when it concatenates pages with this kind of notation, the notation no longer represents the formulas.

So my guess is that either

  1. a script is not running when I view the concatenated page offline on my PC, or that
  2. a stylesheet is not working or
  3. something mysterious is missing.

So my main question is: is there a way to get MathJax to work in this type of situation? 


Most likely, these web pages load MathJax from a CDN (a third-party web server). However, the policy of most browsers do not allow file://…/file.html pages to load scripts from the internet for security reasons.

You can download MathJax into the MathJax folder next to your file.html (getting a .zip from MathJax's GitHub repository and extracting it should be enough), and edit the relevant <script src="…"></script> to point to your freshly-downloaded ./MathJax/MathJax.js file

Otherwise, you can run a local web server (using Apache or another HTTP server, be sure to close the corresponding port on your machine's firewall), put the page in a folder published by your server, and access the page through http://127.0.0.1/page.html (note that you will need an internet connection in this case, as it will try to download MathJax from the CDN).

To troubleshoot things, do right-click → inspect element on the page, go to the "console" tab or the "network" tab (you may need to reload the page) and look for any error messages indicating that the browser failed to load MathJax or one of the resources it uses.

Finally, if you are concatenating HTML files you will likely run into trouble: the header of the second HTML file will appear after the body of the first. HTML files are unfortunately not easy to concatenate that way, because each page has its stylesheets, scripts and metadata, which would cause havoc if applied to another page.

Cheers,
Georges Dupéron

Davide Cervone

unread,
Jul 21, 2017, 10:57:56 AM7/21/17
to mathja...@googlegroups.com

I find, however, that when it concatenates pages with this kind of notation, the notation no longer represents the formulas.

So my guess is that either

  1. a script is not running when I view the concatenated page offline on my PC, or that
  2. a stylesheet is not working or
  3. something mysterious is missing.

So my main question is: is there a way to get MathJax to work in this type of situation? 


Most likely, these web pages load MathJax from a CDN (a third-party web server). However, the policy of most browsers do not allow file://…/file.html pages to load scripts from the internet for security reasons.

Actually, it is the other way around:  file:// URLs can load http:// ones, but http:// URLs can't load file:// ones.  (And in some browsers, file:// URLs can't load file:// URLs from directories outside the one of the original page.)

You can download MathJax into the MathJax folder next to your file.html (getting a .zip from MathJax's GitHub repository and extracting it should be enough), and edit the relevant <script src="…"></script> to point to your freshly-downloaded ./MathJax/MathJax.js file

Yes, that is the way to make a stand-alone version of a page with MathJax.  But as I mentioned, some browsers (notably Firefox) will not load some resources from a directory outside the one containing the original page.  In particular, that applies to MathJax's web fonts.  So if you are using Firefox for local viewing, you may want to install the MathJax fonts locally to avoid that problem.  Use the ones in the MathJax/fonts/HTML-CSS/TeX/otf directory.

Otherwise, you can run a local web server (using Apache or another HTTP server, be sure to close the corresponding port on your machine's firewall), put the page in a folder published by your server, and access the page through http://127.0.0.1/page.html (note that you will need an internet connection in this case, as it will try to download MathJax from the CDN).

If you make a copy of MathJax available to that server, and change the link in the page to point to that MathJax on your local server, then you can get a copy that does not require a network connection (and this is one way to avoid the Firefox web-font security issue).

Davide

Craig Oknin

unread,
Jul 21, 2017, 3:44:57 PM7/21/17
to mathja...@googlegroups.com
Thanks Georges and David.   I will try out your suggestions.

--
You received this message because you are subscribed to a topic in the Google Groups "MathJax Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mathjax-users/m-yb17XjQak/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mathjax-users+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages