I'm trying to use mathjax-node in javascript.
as you can see in picture, I want to make tex to center not left.
is there any configuration on mathjax-node?
I tried text-align and displayAlign to center, but it doesn't worked.
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();
this is code of mathjax.typeset and config
When writing MathJax in display mode, MathJax will automatically center the MathJax code for you.
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>
The above example and quote is derived from here.
This a very quick way of centering the Math as no extra configuration is required.