编织后rmarkdown中数学公式的可见性
Visibility of math formula in rmarkdown after knitting
我正在尝试创建一个 R Markdown 文件并包含一个公式。问题是,当我编织文档时,公式出现在我输入的乳胶样式中。
---
output: github_document
---
$$P(E|L) = \frac{P(L|E) * P(E)}{P(L)} = \frac{0.3 * 0.5}{0.3 * 0.5 + 0.5*1} = 0.23$$
所以当我编织它时,它看起来像:
它出现在代码中的位置。
我应该怎么做才能让我编织文档的时候公式变成第二张图的样子?
问题出在您使用输出格式github_document
。 github 输出格式不能直接支持数学模式。正如 rmarkdown 软件包作者在 this issue:
中所述
I'd say that if you really care about LaTeX math in Markdown, you should render to HTML output instead of waiting indefinitely for Github to support MathJax in Markdown, which I doubt will ever happen.
执行他的建议,我们可以将输出格式更改为 html_document
:
---
output: html_document
---
$$
P(E|L) = \frac{P(L|E) * P(E)}{P(L)} = \frac{0.3 * 0.5}{0.3 * 0.5 + 0.5*1} = 0.23
$$
我正在尝试创建一个 R Markdown 文件并包含一个公式。问题是,当我编织文档时,公式出现在我输入的乳胶样式中。
---
output: github_document
---
$$P(E|L) = \frac{P(L|E) * P(E)}{P(L)} = \frac{0.3 * 0.5}{0.3 * 0.5 + 0.5*1} = 0.23$$
所以当我编织它时,它看起来像:
它出现在代码中的位置。
我应该怎么做才能让我编织文档的时候公式变成第二张图的样子?
问题出在您使用输出格式github_document
。 github 输出格式不能直接支持数学模式。正如 rmarkdown 软件包作者在 this issue:
I'd say that if you really care about LaTeX math in Markdown, you should render to HTML output instead of waiting indefinitely for Github to support MathJax in Markdown, which I doubt will ever happen.
执行他的建议,我们可以将输出格式更改为 html_document
:
---
output: html_document
---
$$
P(E|L) = \frac{P(L|E) * P(E)}{P(L)} = \frac{0.3 * 0.5}{0.3 * 0.5 + 0.5*1} = 0.23
$$