Mathjax逗号数字 [英] mathjax commas in digits

查看:95
本文介绍了Mathjax逗号数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是TeX的遗留问题-在需要空格时更需要空格:12,123可能是数字,而12, 123可能是列表. las,就是这样.

This is a TeX legacy issue---it would have made more sense to require a whitespace when a whitespace is desired: 12,123 is probably a number, while 12, 123 is probably a list. Alas, it is what it is.

数字中的逗号的MathJax渲染有关,解决方法是通过{,}抑制空格.可行,但不方便.有没有办法使它自动执行?

Related to MathJax rendering of commas in numbers, where the solution is suppression of spaces via {,}. Works, but inconvenient. Is there a way to make this automatic?

https://github.com/mathjax/MathJax/issue/169#issuecomment-2040235 与欧洲诉盎格鲁之争有关.等价的骇客,

The hack in https://github.com/mathjax/MathJax/issues/169#issuecomment-2040235 is concerned with European vs Anglo. The equivalent hack,

<script type="text/x-mathjax-config">
  MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
    MathJax.InputJax.TeX.Definitions.number =
      /^(?:[0-9]+(?:\,[0-9]{3})*(?:\{\.\}[0-9]*)*|\{\.\}[0-9]+)/
  });
</script>

解决了1,234.56中的逗号问题,但是句点之后(即5之前)现在有一个空格.我不确定上面的正则表达式如何工作.有人可以帮忙吗?

solves the comma problem in 1,234.56 but now there is a space after the period (i.e., before 5). I am not sure how the regex above works. can someone help?

推荐答案

将模式更改为

/^(?:[0-9]+(?:,[0-9]{3})*(?:\.[0-9]*)*|\.[0-9]+)/

允许将12,345.6视为数字,而12, 345是两个数字的列表.在原始模式中,\{\.\}需要文字{.}(包括花括号),而不仅仅是十进制.

to allow 12,345.6 to be treated as a number, while 12, 345 is a list of two numbers. In the original pattern, the \{\.\} requires a literal {.} (braces included), not just a decimal.

这篇关于Mathjax逗号数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆