N0r*_*ert 4 r docx knitr r-markdown bookdown
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
```
Run Code Online (Sandbox Code Playgroud)
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}
Run Code Online (Sandbox Code Playgroud)
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:
html_document: default and bookdown::html_document2: default are equal and correct.odt_document: default and bookdown::odt_document2: default are incorrect too.