Skip to content

Commit 38e2c5c

Browse files
committed
DOC: switch to KaTeX for math rendering
1 parent 059410f commit 38e2c5c

File tree

8 files changed

+25
-31
lines changed

8 files changed

+25
-31
lines changed

doc/conf.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
import os
1818
from subprocess import check_output
1919

20+
import sphinxcontrib.katex as katex
21+
22+
sys.path.insert(0, os.path.abspath('.'))
23+
from math_definitions import latex_macros
24+
2025
# If extensions (or modules to document with autodoc) are in another directory,
2126
# add these directories to sys.path here. If the directory is relative to the
2227
# documentation root, use os.path.abspath to make it absolute, like shown here.
@@ -32,7 +37,7 @@
3237
# ones.
3338
extensions = [
3439
'sphinx.ext.autodoc',
35-
'sphinx.ext.mathjax',
40+
'sphinxcontrib.katex',
3641
'sphinx.ext.viewcode',
3742
'sphinx.ext.napoleon', # support for NumPy-style docstrings
3843
'sphinx.ext.intersphinx',
@@ -149,6 +154,10 @@
149154
# If true, keep warnings as "system message" paragraphs in the built documents.
150155
#keep_warnings = False
151156

157+
# Math settings
158+
katex_macros = katex.latex_defs_to_katex_macros(latex_macros)
159+
katex_options = 'macros: {' + katex_macros + '}'
160+
152161

153162
# -- Options for HTML output ----------------------------------------------
154163

@@ -251,7 +260,7 @@ def setup(app):
251260
#'pointsize': '10pt',
252261

253262
# Additional stuff for the LaTeX preamble.
254-
#'preamble': '',
263+
'preamble': latex_macros,
255264

256265
'printindex': '',
257266
}

doc/math-definitions.rst

Lines changed: 0 additions & 10 deletions
This file was deleted.

doc/math_definitions.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
latex_macros = r"""
2+
\def \dirac #1{\operatorname{\delta}\left(#1\right)}
3+
\def \e #1{\operatorname{e}^{#1}}
4+
\def \Hankel #3{\mathop{{}H_{#2}^{(#1)}}\!\left(#3\right)}
5+
\def \hankel #3{\mathop{{}h_{#2}^{(#1)}}\!\left(#3\right)}
6+
\def \i {\mathrm{i}}
7+
\def \scalarprod #2{\left\langle#1,#2\right\rangle}
8+
\def \vec #1{\mathbf{#1}}
9+
\def \wc {\frac{\omega}{c}}
10+
"""

doc/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Sphinx-RTD-Theme
33
nbsphinx
44
ipykernel
55
sphinxcontrib-bibtex
6+
sphinxcontrib-katex
67

78
NumPy
89
SciPy

sfs/mono/drivingfunction.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
"""Compute driving functions for various systems.
2-
3-
.. include:: math-definitions.rst
4-
5-
"""
6-
1+
"""Compute driving functions for various systems."""
72
import numpy as np
83
from numpy.core.umath_tests import inner1d # element-wise inner product
94
from scipy.special import jn, hankel2

sfs/time/drivingfunction.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
"""Compute time based driving functions for various systems.
2-
3-
.. include:: math-definitions.rst
4-
5-
"""
1+
"""Compute time based driving functions for various systems."""
62
import numpy as np
73
from numpy.core.umath_tests import inner1d # element-wise inner product
84
from .. import defs

sfs/time/source.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
33
The Green's function describes the spatial sound propagation over time.
44
5-
.. include:: math-definitions.rst
6-
75
"""
86

97
import numpy as np

sfs/util.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
"""Various utility functions.
2-
3-
.. include:: math-definitions.rst
4-
5-
"""
6-
1+
"""Various utility functions."""
72
import collections
83
import numpy as np
94
from scipy.special import spherical_jn, spherical_yn

0 commit comments

Comments
 (0)