xaoxuu / hexo-theme-stellar

内置文档系统的简约商务风Hexo主题,支持大量的标签组件和动态数据组件。
https://xaoxuu.com/wiki/stellar/
MIT License
1.3k stars 319 forks source link

希望能加入对数学公式的支持 #67

Closed Heyya-x closed 8 months ago

Heyya-x commented 2 years ago

Stellar是一个简洁而高级的主题,期待作者能完善对数学公式的支持,个人认为在学术笔记博客中还是数学公式频繁出现的。

十分感谢!

xaoxuu commented 2 years ago

求个PR

zhenxiang-shawn commented 2 years ago

同求加入对LaTeX的支持

hermitlsr commented 2 years ago

这是我的做法使用 katex,效果还是很不错的,不过这个不好提PR

参考 https://www.micdz.cn/article/katex-on-volantis/

1.首先更换公式编译插件:

npm uninstall hexo-renderer-marked --save
npm install hexo-renderer-markdown-it-plus --save

2.在站点根文件中 _config.yml 设置:

# npm i hexo-renderer-markdown-it-plus
markdown_it_plus:
    highlight: true
    html: true
    xhtmlOut: true
    breaks: true
    langPrefix:
    linkify: true
    typographer:
    quotes: “”‘’
    plugins:
        - plugin:
            name: markdown-it-mark
            enable: false

3.根据进阶设定中的外部文件注入,在 _config.yml 中添加如下:

inject:
  head:
    - <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.css" integrity="sha384-AfEj0r4/OFrOo5t7NnNe46zW/tFgW6x/bCJG8FqQCEo3+Aro6EYUG4+cU+KJWu/X" crossorigin="anonymous">
    - <script defer src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.js" integrity="sha384-g7c+Jr9ZivxKLnZTDUhnkOnsh30B4H0rpLUpJ4jAIKs4fnJI+sEnkvrMWph2EDg4" crossorigin="anonymous"></script>
    - <script defer src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/contrib/auto-render.min.js" integrity="sha384-mll67QQFJfxn0IYznZYonOWZ644AWYC+Pt2cHqMaRhXVrursRwvLnLaebdGIlYNa" crossorigin="anonymous" onload="renderMathInElement(document.body);"></script>

  script:
github-actions[bot] commented 1 year ago

:wave: Hello, Your suggestion is great, we will add this feature in subsequent versions, thank you very much!

:wave: 您好, 您的建议很棒,我们将会在后续版本中加入这个功能,非常感谢!

shaoyaoqian commented 1 year ago

今天我测试了下数学公式,用的是pandoc+mathjax,发现能编译复杂公式,但是换上pandoc后,时间线的显示有问题

shaoyaoqian commented 1 year ago

不要用hexo-renderer-marked,用hexo-renderer-kramed,感觉完美 https://blog.pengfeima.cn/2022-11-18/uncategorized/使用数学公式/

xaoxuu commented 1 year ago

不要用hexo-renderer-marked,用hexo-renderer-kramed,感觉完美 https://blog.pengfeima.cn/2022-11-18/uncategorized/使用数学公式/

@shaoyaoqian 很棒 👍 建议在「探索号」这里提交一下。

shaoyaoqian commented 1 year ago

在使用数学公式时发现一个问题,下标不能正确识别,行内公式有_时,需要替换成\_,否则会被识别为markdown语言_斜体_

image
hermitlsr commented 1 year ago

@shaoyaoqian 语法如此,都需要用 \

shaoyaoqian commented 1 year ago

@shaoyaoqian 语法如此,都需要用 \

应该是hexo特有的吧,因为在vscode、typora这些编辑器里不需要,加了还会显示成别的。

hermitlsr commented 1 year ago

@shaoyaoqian 啊,是我搞混了,太久没写了,想成写程序的时候要加 \ 才能转义。我用的 katex,在 hexo 里不需要加 \,可以正确识别的。 image

$$
\mu_t=\beta_0+\beta_1t+\beta_2t+…+\beta_nt
$$
shaoyaoqian commented 1 year ago

行间公式mathjax也不需要,行内公式需要

hermitlsr commented 1 year ago

@shaoyaoqian 行内也不用: image

其中对所有的$t$有$E(X)=0$。使用观测到的时间序列$Y_1,Y_2,…,Y_n$ 来估计$\mu$ 。则可由$OLSE$得出$\mu$的估计为样
shaoyaoqian commented 1 year ago

@hermitlsr 谢谢你,我现在解决这个问题了,用 katex + hexo-renderer-markdown-it-plus 替换了 mathjax + hexo-renderer-kramed

Yuanzidan081 commented 1 year ago

请问一下,我使用了katex + hexo-renderer-markdown-it-plus来输入我的公式,公式是渲染成功了,但是在公式下面又出现了公式,有没有人遇到这个问题呢?是我写Markdown公式的格式不对吗?

RYZFC$O6}E%S)~OB4HQCM%N

UGEEC~C)J5QFF U)DP2T%M8

Yuanzidan081 commented 1 year ago

今天解决问题了,不仅需要安装hexo-renderer-markdown-it-plus,还需要安装hexo-math。所以需要的命令有:

npm uninstall hexo-renderer-marked --save
npm install hexo-renderer-markdown-it-plus --save
npm install hexo-math --save

IC9B09WV9NFX_X`)TUY6 FC

xaoxuu commented 8 months ago

文档已经加上了

github-actions[bot] commented 8 months ago

:wave: Hello, This issue has been marked as resolved. If there are other issues, please contact us with a new issue.

:wave: 您好, 此 issue 已经被标记为已解决,如果还有其它问题,请提出新的 issue 联系我们。