下面是我使用最新的 RStudio 编织到 MS Word 文档的最简单的 Rmd 文件:
---
output:
word_document: default
bookdown::word_document2: default
---
```{sh, echo=FALSE, comment=''}
cat ~/latex-test.Rmd
```
~/latex-test.Rmd
的内容如下面所述:Auto-numbered equation:
$$ f(x) = \sin(x) $$
---
LaTeX equation without label (using `\begin{equation}...\end{equation}`)
\begin{equation}
h(z) = \sinh(z)
\end{equation}
---
LaTeX equation with bookdown-supported label (using `\begin{equation}...(\#eq:label)\end{equation}`)
\begin{equation}
f\left(k\right) = \binom{n}{k} p^k\left(1-p\right)^{n-k}
(\#eq:binom)
\end{equation}
---
LaTeX equation with Xaringan-supported label (using `\begin{equation}...\label{label}\end{equation}`):
\begin{equation}
g\left(k\right) = \binom{n}{k} p^k\left(1-p\right)^{n-k}
\label{binom2}
\end{equation}
针织到
word_document: default
给出与 ~/latex-test.Rmd
中包含的 docx 文件完全相同的内容.所以为了节省篇幅,我不会在这里包含它。
而是针织到
bookdown::word_document2: default
提供额外 $$...$$
围绕 equation
环境:(我已经手动突出显示了意想不到的
$$
)为什么会发生这种情况?我究竟做错了什么?这是一个错误吗?
笔记:
html_document: default
的输出和 bookdown::html_document2: default
是平等和正确的。 odt_document: default
的输出和 bookdown::odt_document2: default
也不正确。 最佳答案
这是 中的一个错误预订 那个I just fixed在 Github 上。你可以试试的开发版预订 通过 remotes::install_github('rstudio/bookdown')
.
关于r - 为什么在使用 rmarkdown 和 bookdown 时将外部 Rmd 文件包含在 latex 方程环境中会导致不同的 DOCX 输出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58845968/