下面是我使用最新的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
的输出也不正确。这是bookdown中的错误,该错误是Github上的I just fixed。您可以通过remotes::install_github('rstudio/bookdown')
尝试开发bookdown的开发版本。