Following @Ian's information, you can get your initial HTML-CSS MathJax configuration from python with the below code (demjson is a soft requirement which allows us to partially process json in a javascript file: pip install demjson
):
import sys
from pathlib import Path
MathJax_cfg_pth = (
Path(sys.executable).parents[0] /
# below path may differ
'Lib/site-packages/notebook/static/components/MathJax/jax/output/HTML-CSS/config.js'
)
with open(MathJax_cfg_pth, 'r') as f:
MathJax_cfg = f.read()
import demjson
start_cfg = MathJax_cfg.find("config:{") + 7
open_braces = 0
for i, c in enumerate(MathJax_cfg[start_cfg:]):
if c == '{':
open_braces += 1
elif c == '}':
if open_braces == 0:
break
open_braces -= 1
initial_configuration = demjson.decode(
MathJax_cfg[
start_cfg : start_cfg + i
].replace("(", "'(").replace(")", ")'")
)
Having this will be helpful if you want to revert any changes without restarting your notebook kernel. For the curious, my initial_configuration
is here: https://pastebin.com/JkatcrAC
Next we can update a HTML-CSS MathJax setting in our current runtime by displaying HTML containing a short script. If you wanted to update the size of HTML-CSS displays you could use the following function:
from IPython.core.display import HTML
MathJax_scale_script = """
<script>
MathJax.Hub.Config({
"HTML-CSS": {
scale: %s
}
});
</script>
"""
def update_Math_size(size):
# 100 is default
display(HTML(MathJax_scale_script%size))
For example, update_Math_size(200)
for double the size, and update_Math_size(100)
to revert back to my default setting.
config.js
go? – Hie