Index: docs/sphinx-docs/Makefile
===================================================================
--- docs/sphinx-docs/Makefile	(revision 1d5f5c20a9deebda81aa660ca4fd66d8695ed081)
+++ docs/sphinx-docs/Makefile	(revision 31943715d145c5ad0cc2df2ac75442591490886e)
@@ -16,5 +16,5 @@
 PAPEROPT_a4     = -D latex_paper_size=a4
 PAPEROPT_letter = -D latex_paper_size=letter
-ALLSPHINXOPTS   = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
+ALLSPHINXOPTS   = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source-temp
 # the i18n builder cannot share the environment and doctrees with the others
 I18NSPHINXOPTS  = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
@@ -53,5 +53,5 @@
 	rm -rf source/dev/api
 	sphinx-apidoc -o source/dev/api -d 8 ../../src
-	
+
 html: stubs
 	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
Index: docs/sphinx-docs/build_sphinx.py
===================================================================
--- docs/sphinx-docs/build_sphinx.py	(revision 01f1e174e9a9bcc2a3ecebc3d6448a75d9028016)
+++ docs/sphinx-docs/build_sphinx.py	(revision 31943715d145c5ad0cc2df2ac75442591490886e)
@@ -324,4 +324,18 @@
         print("!!!!NO MODEL DOCS WILL BE BUILT!!!!")
 
+def fetch_katex(version, destination="_static"):
+    from zipfile import ZipFile
+    import urllib2
+    url = "https://github.com/Khan/KaTeX/releases/download/%s/katex.zip" % version
+    cache_path = "katex_%s.zip" % version
+    if not os.path.exists(cache_path):
+        try:
+            fd_in = urllib2.urlopen(url)
+            with open(cache_path, "wb") as fd_out:
+                fd_out.write(fd_in.read())
+        finally:
+            fd_in.close()
+    with ZipFile(cache_path) as zip:
+        zip.extractall(destination)
 
 def retrieve_bumps_docs():
@@ -360,9 +374,35 @@
                      SASVIEW_BUILD])
 
+def build_pdf():
+    """
+    Runs sphinx-build for pdf.  Reads in all .rst files and spits out the final html.
+    """
+    print("=== Build PDF Docs from ReST Files ===")
+    subprocess.call(["sphinx-build",
+                     "-b", "latex", # Builder name. TODO: accept as arg to setup.py.
+                     "-d", os.path.join(SPHINX_BUILD, "doctrees"),
+                     SPHINX_SOURCE,
+                     os.path.join(SPHINX_BUILD, "latex")])
+
+    LATEXDIR = os.path.join(SPHINX_BUILD, "latex")
+    def pdflatex():
+        subprocess.call(["pdflatex", "Sasview.tex"], cwd=LATEXDIR)
+    pdflatex()
+    pdflatex()
+    pdflatex()
+    subprocess.call(["makeindex", "-s", "python.ist", "Sasview.idx"], cwd=LATEXDIR)
+    pdflatex()
+    pdflatex()
+
+    print("=== Copy PDF to HTML Directory ===")
+    source = os.path.join(LATEXDIR, "Sasview.pdf")
+    target = os.path.join(SASVIEW_DOCS, "Sasview.pdf")
+    shutil.copyfile(source, target)
+
 def build():
     """
     Runs sphinx-build.  Reads in all .rst files and spits out the final html.
     """
-    print("=== Build HTML Docs from Rest Files ===")
+    print("=== Build HTML Docs from ReST Files ===")
     subprocess.call(["sphinx-build",
                      "-b", "html", # Builder name. TODO: accept as arg to setup.py.
@@ -375,16 +415,7 @@
     copy_tree(html, SASVIEW_DOCS)
 
-    #We are building latex doc on linux only
-    if "linux" in platform:
-        print "=== Build Latex Docs from Rest Files ==="
-        subprocess.call(["sphinx-build",
-                     "-b", "latex", # Builder name. TODO: accept as arg to setup.py.
-                     "-d", os.path.join(SPHINX_BUILD, "doctrees"),
-                     SPHINX_SOURCE,
-                     os.path.join(SPHINX_BUILD, "latex")])
-
-        print "=== Copy Latex Docs to Build Directory ==="
-        latex = os.path.join(SPHINX_BUILD, "latex")
-        copy_tree(latex, SASVIEW_DOCS)
+def convert_katex():
+    print("=== Preprocess HTML, converting latex to html ===")
+    subprocess.call(["node", "convertKaTex.js", SASVIEW_DOCS])
 
 def rebuild():
@@ -393,6 +424,9 @@
     retrieve_user_docs()
     retrieve_bumps_docs()
+    fetch_katex(version=KATEX_VERSION, destination=KATEX_PARENT)
     apidoc()
     build()
+    #build_pdf()
+    #convert_katex()
 
     print("=== Done ===")
Index: docs/sphinx-docs/convertKaTex.js
===================================================================
--- docs/sphinx-docs/convertKaTex.js	(revision 31943715d145c5ad0cc2df2ac75442591490886e)
+++ docs/sphinx-docs/convertKaTex.js	(revision 31943715d145c5ad0cc2df2ac75442591490886e)
@@ -0,0 +1,1 @@
+/Users/pkienzle/Source/KaTeX/contrib/preprocess/convertTree.js
Index: docs/sphinx-docs/source/_extensions/mathjax.py
===================================================================
--- docs/sphinx-docs/source/_extensions/mathjax.py	(revision afca48850c5f8018d72eb8d0b9c040637c7eb3bf)
+++ docs/sphinx-docs/source/_extensions/mathjax.py	(revision afca48850c5f8018d72eb8d0b9c040637c7eb3bf)
@@ -0,0 +1,115 @@
+# -*- coding: utf-8 -*-
+"""
+    sphinx.ext.mathjax
+    ~~~~~~~~~~~~~~~~~~
+
+    Allow `MathJax <http://mathjax.org/>`_ to be used to display math in
+    Sphinx's HTML writer -- requires the MathJax JavaScript library on your
+    webserver/computer.
+
+    :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
+    :license: BSD, see LICENSE for details.
+
+    sample lines in conf.py to use this::
+
+        mathjax_path = ['https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.6.0/katex.min.js',
+                        'http://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.6.0/contrib/auto-render.min.js',
+                        'rendermath.js']
+        mathjax_css = 'https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.6.0/katex.min.css'
+
+    with rendermath.js containing::
+
+        document.addEventListener("DOMContentLoaded", function(event) {
+            renderMathInElement(document.body);
+        });
+
+    2016-08-09 Jason Sachs
+    * allow list of URLS for mathjax_path, which permits use of katex.js
+"""
+
+from docutils import nodes
+
+import sphinx
+from sphinx.locale import _
+from sphinx.errors import ExtensionError
+from sphinx.ext.mathbase import setup_math as mathbase_setup
+
+
+def html_visit_math(self, node):
+    self.body.append(self.starttag(node, 'span', '', CLASS='math'))
+    self.body.append(self.builder.config.mathjax_inline[0] +
+                     self.encode(node['latex']) +
+                     self.builder.config.mathjax_inline[1] + '</span>')
+    raise nodes.SkipNode
+
+
+def html_visit_displaymath(self, node):
+    self.body.append(self.starttag(node, 'div', CLASS='math'))
+    if node['nowrap']:
+        self.body.append(self.encode(node['latex']))
+        self.body.append('</div>')
+        raise nodes.SkipNode
+
+    # necessary to e.g. set the id property correctly
+    if node['number']:
+        self.body.append('<span class="eqno">(%s)' % node['number'])
+        self.add_permalink_ref(node, _('Permalink to this equation'))
+        self.body.append('</span>')
+    self.body.append(self.builder.config.mathjax_display[0])
+    parts = [prt for prt in node['latex'].split('\n\n') if prt.strip()]
+    if len(parts) > 1:  # Add alignment if there are more than 1 equation
+        self.body.append(r' \begin{align}\begin{aligned}')
+    for i, part in enumerate(parts):
+        part = self.encode(part)
+        if r'\\' in part:
+            self.body.append(r'\begin{split}' + part + r'\end{split}')
+        else:
+            self.body.append(part)
+        if i < len(parts) - 1:  # append new line if not the last equation
+            self.body.append(r'\\')
+    if len(parts) > 1:  # Add alignment if there are more than 1 equation
+        self.body.append(r'\end{aligned}\end{align} ')
+    self.body.append(self.builder.config.mathjax_display[1])
+    self.body.append('</div>\n')
+    raise nodes.SkipNode
+
+try:
+    basestring
+except:
+    basestring = str
+
+def builder_inited(app):
+    jaxpath = app.config.mathjax_path
+    if not jaxpath:
+        raise ExtensionError('mathjax_path config value must be set for the '
+                             'mathjax extension to work')
+
+    # app.config.mathjax_path can be a string or a list of strings
+    if isinstance(jaxpath, basestring):
+        app.add_javascript(jaxpath)
+    else:
+        for p in jaxpath:
+            app.add_javascript(p)
+
+    if app.config.mathjax_css:
+        app.add_stylesheet(app.config.mathjax_css)
+
+
+def setup(app):
+    try:
+        mathbase_setup(app, (html_visit_math, None), (html_visit_displaymath, None))
+    except ExtensionError:
+        raise ExtensionError('sphinx.ext.mathjax: other math package is already loaded')
+
+    # more information for mathjax secure url is here:
+    # http://docs.mathjax.org/en/latest/start.html#secure-access-to-the-cdn
+    app.add_config_value('mathjax_path',
+                         'https://cdn.mathjax.org/mathjax/latest/MathJax.js?'
+                         'config=TeX-AMS-MML_HTMLorMML', False)
+    app.add_config_value('mathjax_css', None, 'html')
+    app.add_config_value('mathjax_use_katex', False, 'html')
+    app.add_config_value('mathjax_inline', [r'\(', r'\)'], 'html')
+    app.add_config_value('mathjax_display', [r'\[', r'\]'], 'html')
+    app.connect('builder-inited', builder_inited)
+
+    return {'version': sphinx.__display_version__, 'parallel_read_safe': True}
Index: docs/sphinx-docs/source/_static/rendermath.js
===================================================================
--- docs/sphinx-docs/source/_static/rendermath.js	(revision afca48850c5f8018d72eb8d0b9c040637c7eb3bf)
+++ docs/sphinx-docs/source/_static/rendermath.js	(revision afca48850c5f8018d72eb8d0b9c040637c7eb3bf)
@@ -0,0 +1,4 @@
+// Render katex on page.
+document.addEventListener("DOMContentLoaded", function(event) {
+	    renderMathInElement(document.body);
+});
Index: docs/sphinx-docs/source/conf.py
===================================================================
--- docs/sphinx-docs/source/conf.py	(revision 959eb0181ad06828a748f04512f953aad5b31659)
+++ docs/sphinx-docs/source/conf.py	(revision 28c4a3d988315381236573e496a71f02d1fd6a84)
@@ -35,7 +35,17 @@
               'sphinx.ext.todo',
               'sphinx.ext.coverage',
-              'sphinx.ext.mathjax',
+              'mathjax',
               'dollarmath',
               'sphinx.ext.viewcode']
+
+#STATIC_PATH = '../../_static/'
+STATIC_PATH = ''
+mathjax_path = [
+    STATIC_PATH + 'katex/katex.min.js',
+    STATIC_PATH + 'katex/contrib/auto-render.min.js',
+    STATIC_PATH + 'rendermath.js'
+]
+mathjax_css = STATIC_PATH + 'katex/katex.min.css'
+
 
 # Add any paths that contain templates here, relative to this directory.
