Equation Numbering in Rmarkdown - for Export to Word

Consistent math equation numbering in bookdown across pdf, docx, html output

For equation numbering support in bookdown you need to assign labels. the following works for me:

---
output:
bookdown::html_document2: default
bookdown::word_document2: default
bookdown::pdf_document2: default
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

\begin{equation}
\begin{aligned}
X &= Y \\
Z &= W
\end{aligned}
(\#eq:eq1)
\end{equation}

\begin{align}
X &= Y (\#eq:eq2) \\
Z &= W (\#eq:eq3)
\end{align}

See Equation \@ref(eq:eq1) or Equations \@ref(eq:eq2) and \@ref(eq:eq3).

HTML Output:

Sample Image

PDF output is similar. Word output as seen in LibreOffice is pretty bad, but the equation numbers including references are there. So I guess this is a local or LibreOffice specific problem.

auto-number equations in R markdown documents in RStudio

You can use \notag or \nonumber on an expression to prevent an automatic tag from being applied to it. So if you are using autoNuber: "all", you can do

$$E=mc^2\nonumber$$

to get the equation with no number.



Related Topics



Leave a reply



Submit