Skip to content

Commit

Permalink
Support both Sphinx 3.x and Sphinx 4.x
Browse files Browse the repository at this point in the history
  • Loading branch information
ckhroulev committed Sep 17, 2021
1 parent 17f283d commit e0982de
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions doc/sphinx/conf.py
Expand Up @@ -149,7 +149,9 @@ def git(command):
'preamble': r'\usepackage{txfonts}'
}

mathjax_config = {"TeX": {"Macros": {}}}
# -- Add custom math definitions ----------------

mathjax3_config = {"tex": {"macros": {}}}

# Add math definitions to the LaTeX preamble and MathJax settings:
for line in open("math-definitions.tex"):
Expand All @@ -162,9 +164,15 @@ def git(command):
args = M.group(3)
if M.group(4):
default = M.group(5)
mathjax_config["TeX"]["Macros"][name] = [definition, args, default]
mathjax3_config["tex"]["macros"][name] = [definition, args, default]
else:
mathjax_config["TeX"]["Macros"][name] = [definition, args]
mathjax3_config["tex"]["macros"][name] = [definition, args]
else:
mathjax_config["TeX"]["Macros"][name] = definition
mathjax3_config["tex"]["macros"][name] = definition
latex_elements["preamble"] += line

# Support Sphinx 3.x:
import sphinx
if sphinx.version_info[0] < 4:
mathjax_config = {"TeX" : {"Macros" : {}}}
mathjax_config["TeX"]["Macros"] = mathjax3_config["tex"]["macros"]

0 comments on commit e0982de

Please sign in to comment.