If you are using MathJax, here's a possible solution. I'm still looking for a nicer solution, but it might help if you need a quick hack.
Create a file under the directory specified in the html_static_path
configuration option (typically _static
), say mathconf.js
. This will contain the JS configuration for MathJax. For instance (from the MathJax documentation):
MathJax.Hub.Config({
TeX: {
Macros: {
RR: '{\bf R}',
bold: ['{\bf #1}', 1]
}
}
});
You can add more commands following the syntax above. The contents shown define the macros RR
and old{#1}
, this last one accepting one argument.
Add a layout.html
file at the _templates
directory. The idea is to extend the current theme, so it searches the previous MathJax configuration file. Thus, the contents are:
{% extends "!layout.html" %}
{% set script_files = script_files + ["_static/mathconf.js"] %}
Note that in this case it is the _static
directory, because in this case it refers to where to search after the build. Sphinx will have moved the file from html_static_path
to the _static
directory under the build directory.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…