latex - RMarkdown : Auto Number Equations

标签 latex r-markdown

如何在 Rmarkdown 文档中自动编号方程式?

我试过在标题中包含“\usepackage{mathajax}”,但方程不会自动编号。我相信我需要配置 mathjax,但不知道如何配置。

我愿意接受任何解决方案。

请注意,此 post 中的解决方案不起作用。

编辑:

下面是所需输出的简化示例。

enter image description here

上图的代码如下。我尝试使用\begin{equation} 和\end{equation} 代替“对齐”;但是,HTML 文档没有正确输出公式。

---
header-includes:
- \usepackage{amsmath}
output:
  html_document: default
---

\begin{align}
2+2 = 4 \tag{1} \\
3+2 = 5 \tag{2} \\
4+2 = 6 \tag{3} \\
5+2=7 \tag{4} \\
\end{align}

最佳答案

您可以通过使用 bookdown::html_document2 获得非常接近的结果,c.f. the documentation :

---
output:
  bookdown::html_document2: default
---

\begin{align}
2+2 &= 4 \\
3+2 &= 5 (\#eq:three) \\
4+2 &= 6 (\#eq:four) \\
5+2 &= 7 (\#eq:five)
\end{align}

结果:

enter image description here

对于放置标签的每个方程式,您都会得到一个方程式编号。我省略了第一个等式上的标签以显示此效果。这与 LaTeX 的行为略有不同,您必须在 align 环境中使用 \notag 才能获得方程编号。

关于latex - RMarkdown : Auto Number Equations,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59315976/

相关文章:

ruby-on-rails - Mathjax 不渲染 latex 公式

r - 针织 latex forloop

RMarkdown ioslides - 浏览器中不显示幻灯片编号

css - 如何在 .Rmd html 输出中跨平台强制使用相同的代码块字体?

r - 使用 rmarkdown/knitr 将所有代码保存到最后

r - 如何在 r markdown 中将 kable 和 ggplot 对齐在一行(并排)?

pdf - Markdown 中的特殊字符 - Pandoc 和 Github Flavored

python - 从字面上呈现一个 sympy 表达式,没有简化

R 演示 reveal.js : background image not shown after copying file

r - 如何在Rmarkdown中 "box"输出 "summary()"