Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

数学公式支持 MathJax #89

Closed
mlsjla opened this issue Jan 26, 2020 · 7 comments
Closed

数学公式支持 MathJax #89

mlsjla opened this issue Jan 26, 2020 · 7 comments
Assignees

Comments

@mlsjla
Copy link

mlsjla commented Jan 26, 2020

因为mathjax公式用的比较多。

比如下面的就用不了了。

$$\begin {align*}
 &800(1+0.04t)=1000\\
  &\Rightarrow n=6.25years
 \end{align*}$$
@AGJackie
Copy link

同需要mathjax!想知道具体在哪个文档代码处能把katex配置改成mathjax配置

@Vanessa219 Vanessa219 changed the title 数学公式是否能支持mathjax 数学公式支持 mathjax Jan 27, 2020
@Vanessa219
Copy link
Owner

mathjax 从包大小,渲染速度、效果都不如 katex,这个需求会在 bug 修复的差不多后再支持。

@mlsjla
Copy link
Author

mlsjla commented Jan 27, 2020

@Vanessa219 可以考虑以扩展方式增加,即可以选择性引入或开启。

因为首先考虑能用,兼容性, 其次是渲染速度和包大小。 毕竟现在算力和流量不算贵。

说明下原因。 实际上大量用markdown替代富文本的普通用户群体, 一方面是程序员, 一方面就是对数学公式需求量大的用户。 而数学公式需求量大,就必须用markdown编辑器了。web的富文本主要是图文。

@88250
Copy link
Collaborator

88250 commented Jan 27, 2020

建议加入配置项,让用户能够选择所需的数学公式渲染引擎。

@88250 88250 changed the title 数学公式支持 mathjax 数学公式支持 MathJax Jan 27, 2020
@AGJackie
Copy link

AGJackie commented Jan 30, 2020

另外建议对mathjax的配置增加自定义宏(Macros)的支持。比如给一个输入框,可以输入mathjax的自定义macros,这样可以定义新命令。原因:mathjax可以满足大部分公式需求。但用到latex宏包的地方会无法使用,这种不满足的情形可以用macro的形式把latex宏包在mathjax上模拟出来。

以下为mathjax的配置项,Macros的部分是我对LaTeX精算宏包actuarialsymbol在mathjax中的模拟:

<script type="text/x-mathjax-config">
MathJax.Hub.Config({
  showProcessingMessages: false,
  messageStyle: "none",
  jax: ["input/TeX", "output/HTML-CSS"], 
    tex2jax: {
      preview: 'none',
      inlineMath: [ ['$','$'], ["\\(","\\)"] ],
      displayMath: [ ['$$','$$'], ["\\[","\\]"] ]
    },
  TeX: {
    TagSide: "left",
    Macros: {
      actuarialangle: ['{\\mkern1mu\\overline\{#1\\,\}\\kern-3mu\\lower-1mu\\small|}',1],
      angl: ['{\\actuarialangle\{#1\\mkern1mu\}}',1],
      angln: '{\\angl n}',
      anglk: '{\\angl k}',
      anglr: '{\\angl r}',
      term: ['{\\overset\{1\}\{#1\}:\\angl\{#2\}}',2],
      termxn: '{\\term\{x\}\{n\}}',
      pureendow: ['{#1:\\overset\{1\}\{\\angl\{#2\}\}}',2],
      pureendowxn: '{\\pureendow\{x\}\{n\}}',
      endow: ['{#1:\\angl\{#2\}}',2],
      endowxn: '{\\endow\{x\}\{n\}}',
      joint: ['{\\overline\{#1\}}',1],
      actsymb: ['{\\sideset\{_\{#1\\mkern3mu\}^\{#2\\mkern3mu\}\}\{^\{#4\}_\{#5\}}\{#3\}}',5],
      Ax: ['{\\actsymb\{#1\}\{#2\}\{A\}\{#3\}\{#4\}}',4],
      Axz: ['{\\actsymb\{#1\}\{#2\}\{\\bar\{A\}\}\{#3\}\{#4\}}',4],
      Axzz: ['{\\actsymb\{#1\}\{#2\}\{\\ddot\{A\}\}\{#3\}\{#4\}}',4],
      ax: ['{\\actsymb\{#1\}\{#2\}\{a\}\{#3\}\{#4\}}',4],
      axz: ['{\\actsymb\{#1\}\{#2\}\{\\bar\{a\}\}\{#3\}\{#4\}}',4],
      axzz: ['{\\actsymb\{#1\}\{#2\}\{\\ddot\{a\}\}\{#3\}\{#4\}}',4],
      Ex: ['{\\actsymb\{#1\}\{\}\{E\}\{\}\{#2\}}',2],
      px: ['{\\actsymb\{#1\}\{\}\{p\}\{\}\{#2\}}',2],
      qx: ['{\\actsymb\{#1\}\{\}\{q\}\{\}\{#2\}}',2],
      sx: ['{\\actsymb\{\}\{\}\{s\}\{\}\{#1\}}',1],
      sxz: ['{\\actsymb\{\}\{\}\{\\bar\{s\}\}\{\}\{#1\}}',1],
      sxzz: ['{\\actsymb\{\}\{\}\{\\ddot\{s\}\}\{\}\{#1\}}',1],
      Vx: ['{\\actsymb\{#1\}\{\}\{V\}\{\}\{#2\}}',2],
    }
  },

"HTML-CSS": {
    availableFonts: ["MathJax TeX"],
    preferredFonts: "MathJax TeX" }
});
</script>

<script type="text/javascript"
  src="https://cdn.jsdelivr.net/npm/mathjax@2/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>

加载上述mathjax自定义宏后,输入精算符号时需要使用的代码及其效果可以看这个帖子:
寿险精算符号的mathjax代码

@88250
Copy link
Collaborator

88250 commented Jan 30, 2020

@AGJackie 谢谢反馈,等后续会研究一下。

@AGJackie
Copy link

@88250 谢谢!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants