Adding a javascript script tag some place so that it works for every file in sphinx documentation

后端 未结 5 1047
野的像风
野的像风 2020-12-24 14:59

I am using Sphinx to write some notes. I am using the Mathjax extension for Math in the notes. The default size of the math is little larger than I would like. On the Mathja

5条回答
  •  悲&欢浪女
    2020-12-24 15:38

    In Sphinx 3.0 and later, the easiest way to add short snippets of JavaScript configuration is to call app.add_js_file(None, body="...JS code...") in your conf.py setup function. Example:

    # In your Sphinx project's conf.py:
    
    # 1. Add whatever JS code you need as a string constant.
    #    (This example is from the original question.)
    MATHJAX_CONFIG_JS = """
    MathJax.Hub.Config({
      "HTML-CSS": {scale: 90}
    });
    """
    
    # 2. Create a setup() function if you don't already have one.
    #    (If you do, just add to your existing setup() function.)
    def setup(app):
        # 3. Tell Sphinx to add your JS code. Sphinx will insert
        #    the `body` into the html inside a 
    
                                     
                  
提交回复
热议问题