Hi.  I just discovered how to use MathJax in our Sphinx docs, and it's
really easy.  You just have to copy a file to the doc/src directory
and make a couple of changes to the conf.py file.  I have done this at
my mathjax branch (https://github.com/asmeurer/sympy/tree/mathjax).
More information (also in the commit message):

See https://bitbucket.org/kevindunn/sphinx-extension-mathjax/wiki/Home
and
https://groups.google.com/forum/#!msg/sphinx-dev/SkLZlqapcM8/tI2qk5uTY3gJ.

MathJax renders the LaTeX equations in the browser.  This has several
advantages:

- Compiling the Sphinx docs from scratch is *way* faster, since it
doesn't have to compile the LaTeX images.  Previously on my machine, it
took about half an hour to compile from scratch (mainly due to heavy
LaTeX use in the mpmath docs).  Now it only takes a couple of minutes.

- Because no LaTeX images are stored, the overall size of the compiled
docs is smaller.

- The rendered math in the browser is selectable (which also means it's
searchable), and crisp at arbitrary zoom levels, since it renders the
math using actual fonts, not images.  So it's just like an equation in a
regular LaTeX pdf document.

- You can right click on the equation and get a menu that will show the
source.  As a side benefit, you can also use this to convert the LaTeX
to mathml.

- No changes are required in the source files.  This uses the same
:math: pragma as the previous system, so it's very swappable.

- This currently uses an online version of the mathjax.js file that is
free to use for production, but this can easily be downloaded and used
locally for offline use.

Disadvantages:

- You will not be warned about LaTeX errors at doc compile time.  The
only way I know to find them is to look at all the rendered html files
for yellow MathJax error boxes.  Perhaps there is a more streamlined way
to do this, though.

- There currently are some errors in the GA docs, due to some strange
control sequences like \W and \lbrk.  I'm not sure where these are
defined, but this will have to be fixed if we use this.

- Your browser has to render the math at load time, which makes it a
little slower for LaTeX intensive pages.  Actually, it isn't too bad.
And it seems to render from the top down, so you can see the math at the
top almost immediately.  And while it is rendering, you see the LaTeX
source, so you can at least read it.

To compare this against the old system checkout my branch and, do

cd doc
make clean # To clear the old docs
make html

And open a LaTeX intensive page like
_build/html/modules/mpmath/functions/hypergeometric.html in your browser
and compare it against the current page at docs.sympy.org (in this case,
http://docs.sympy.org/0.7.0/modules/mpmath/functions/hypergeometric.html#mpmath.hyp0f1).

Note how with the MathJax, you can select parts of the math equations,
you can zoom in (using your browser's zoom functionality) without any
loss of resolution, and you right click on the equation to get the
source.

Aaron Meurer

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to