javascript - Mathjax 配置乳胶到中心
问题描述
我正在尝试在 javascript 中使用 mathjax-node 。
正如你在图片中看到的,我想让 tex 居中而不是离开。
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 和 config 的代码
解决方案
在显示模式下编写 MathJax 时,MathJax 会自动为您将 MathJax 代码居中。
要在显示模式下打印方程,请使用以下分隔符之一:[ ... ]、\begin{displaymath} ... \end{displaymath} 或 \begin{equation} ... \end{equation}。$$ ... $$ 不鼓励使用,因为它可能会给出不一致的间距,并且可能不适用于某些数学包。
<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>
上面的例子和引用来自这里。
这是一种非常快速的使数学居中的方法,因为不需要额外的配置。
推荐阅读
- csv - ssconvert 在将 CSV 转换为 XLSX 时不保留新行
- pine-script - 如何在 pine 脚本中计算时间
- java - 如何使用 Java 代码从 Git 存储库下载文件
- java - 如何在不模拟的情况下从 JUnit 测试命令行 Java 应用程序?
- java - android上的谷歌地图如何将当前位置更改为坐标
- c - 在c中,这个参数是什么意思`myfunc(mystruct_t * const * pVar)`?
- vue.js - 如何将十六进制颜色代码设置为“tbody-tr-class”?(引导程序)
- visual-studio - 如何使此代码概述选项卡出现在您的屏幕上(Visual Studio)
- c# - 将数据库中存储的图像转换为字符串并返回字节?
- javascript - 如何防止会话在顶点过期?