Below is the simplest Rmd file which I'm knitting to MS Word document using latest RStudio:
---
output:
word_document: default
bookdown::word_document2: default
---
```{sh, echo=FALSE, comment=''}
cat ~/latex-test.Rmd
```
The contents of ~/latex-test.Rmd
are as follows:
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}
Knitting to word_document: default
gives exactly the same contents of docx file as contained in ~/latex-test.Rmd
.
So I will not include it here to save the space.
But knitting to bookdown::word_document2: default
gives extra $$...$$
which surround equation
environments:
(I have highlighted the unexpected $$
manually)
Why this happening? What am I doing wrong? Is it a bug?
Notes:
- the outputs of
html_document: default
andbookdown::html_document2: default
are equal and correct. - the outputs of
odt_document: default
andbookdown::odt_document2: default
are incorrect too.