首页 > 解决方案 > 如何在 Rmarkdown github_document 中使用 MathJax?

问题描述

我想在 Rmarkdown 生成的 GitHub README 文件中包含一些数学符号。但是,将符号$括起来并不会将它们呈现为符号:它只是在它们周围加上括号。根据这个文档,我想也许我可以使用 MathJax,但到目前为止我努力让它工作没有成功。任何帮助,将不胜感激!

尝试1:

---
output:
  github_document
---
Here are some math symbols: $/alpha$ $A$ $1$ 

尝试2:

---
output:
  github_document:
    pandoc_args: "--mathjax"
---
Here are some math symbols: $/alpha$ $A$ $1$ 

尝试 3:

---
output:
  github_document:
    pandoc_args: [
      "--mathjax", "https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"
    ]
---
Here are some math symbols: $/alpha$ $A$ $1$

尝试4:

---
output:
  github_document:
    md_extensions: -tex_math_single_backslash+tex_math_dollars
---
Here are some math symbols: $/alpha$ $A$ $1$

到目前为止,所有这些尝试都产生了这样的结果:

在此处输入图像描述

标签: rr-markdownknitr

解决方案


这是一个很难的问题,很多人之前都问过他们,例如 https://github.com/github/markup/issues/897

我为一些小公式找到了一个简单的解决方案,例如 alpha:

只需使用&alpha 您也可以使用......子或上标 (在此处查看更多信息:https ://www.w3schools.com/html/html_entities.asp )

在这里找到的解决方案: How to show math equations in general github's markdown(not github's blog)


推荐阅读