Mathjax 配置乳胶到中心

Mathjax configuration latex to center

我正在尝试在 javascript 中使用 mathjax-node。

正如你在图片中看到的,我想让 tex 居中而不是左边。

this is rendered picture

mathjax-node 有配置吗?

我试过 text-align 和 displayAlign 居中,但没用。

function convert(tex, options, callback) {
    mathjax.typeset({
        width: options.width,
        ex: 10,
        math: tex,
        format: "TeX",
        // style: "text-align: center;",
        svg: true, // SVG output
        linebreaks: true,
    }, function (data) {
        if (data.errors) return callback(data.errors);
        callback(undefined, data.svg);
    });
}


const mathjax = require('mathjax-node');
mathjax.config({
    TeX: {
        extensions: ["color.js"]
    },
    MathJax: {
        displayAlign: "center",
        // 'text-align': "center"
        extensions: ["TeX/color.js"],
        'fast-preview':{disabled:false}
    },
});
mathjax.start();

这是mathjax.typeset和配置的代码

在显示模式下编写 MathJax 时,MathJax 会自动为您居中 MathJax 代码。

To print your equations in display mode use one of these delimiters: [ ... ], \begin{displaymath} ... \end{displaymath} or \begin{equation} ... \end{equation}. $$ ... $$ is discouraged as it can give inconsistent spacing, and may not work well with some math packages.

<p>
The mass-energy equivalence is described by the famous equation
\[ E=mc^2 \]
discovered in 1905 by Albert Einstein. 
In natural units (\(c = 1 \)), the formula expresses the identity
\begin{equation}
E=m
\end{equation}
</p>

<script type="text/javascript" async  src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML">
</script>

上面的例子和引用来自here

这是一种非常快速的数学居中方法,因为不需要额外的配置。